31
31
* Create a namespace (schema) with the given name and owner OID.
32
32
*
33
33
* If isTemp is true, this schema is a per-backend schema for holding
34
- * temporary tables. Currently, the only effect of that is to prevent it
35
- * from being linked as a member of any active extension. (If someone
36
- * does CREATE TEMP TABLE in an extension script, we don't want the temp
37
- * schema to become part of the extension.)
34
+ * temporary tables. Currently, it is used to prevent it from being
35
+ * linked as a member of any active extension. (If someone does CREATE
36
+ * TEMP TABLE in an extension script, we don't want the temp schema to
37
+ * become part of the extension). And to avoid checking for default ACL
38
+ * for temp namespace (as it is not necessary).
38
39
* ---------------
39
40
*/
40
41
Oid
@@ -49,6 +50,7 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
49
50
TupleDesc tupDesc ;
50
51
ObjectAddress myself ;
51
52
int i ;
53
+ Acl * nspacl ;
52
54
53
55
/* sanity checks */
54
56
if (!nspName )
@@ -60,6 +62,12 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
60
62
(errcode (ERRCODE_DUPLICATE_SCHEMA ),
61
63
errmsg ("schema \"%s\" already exists" ,nspName )));
62
64
65
+ if (!isTemp )
66
+ nspacl = get_user_default_acl (ACL_OBJECT_NAMESPACE ,ownerId ,
67
+ InvalidOid );
68
+ else
69
+ nspacl = NULL ;
70
+
63
71
/* initialize nulls and values */
64
72
for (i = 0 ;i < Natts_pg_namespace ;i ++ )
65
73
{
@@ -69,7 +77,10 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
69
77
namestrcpy (& nname ,nspName );
70
78
values [Anum_pg_namespace_nspname - 1 ]= NameGetDatum (& nname );
71
79
values [Anum_pg_namespace_nspowner - 1 ]= ObjectIdGetDatum (ownerId );
72
- nulls [Anum_pg_namespace_nspacl - 1 ]= true;
80
+ if (nspacl != NULL )
81
+ values [Anum_pg_namespace_nspacl - 1 ]= PointerGetDatum (nspacl );
82
+ else
83
+ nulls [Anum_pg_namespace_nspacl - 1 ]= true;
73
84
74
85
nspdesc = heap_open (NamespaceRelationId ,RowExclusiveLock );
75
86
tupDesc = nspdesc -> rd_att ;