3131 * Create a namespace (schema) with the given name and owner OID.
3232 *
3333 * 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).
3839 * ---------------
3940 */
4041Oid
@@ -49,6 +50,7 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
4950 TupleDesc tupDesc ;
5051 ObjectAddress myself ;
5152 int i ;
53+ Acl * nspacl ;
5254
5355 /* sanity checks */
5456 if (!nspName )
@@ -60,6 +62,12 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
6062 (errcode (ERRCODE_DUPLICATE_SCHEMA ),
6163 errmsg ("schema \"%s\" already exists" , nspName )));
6264
65+ if (!isTemp )
66+ nspacl = get_user_default_acl (ACL_OBJECT_NAMESPACE , ownerId ,
67+ InvalidOid );
68+ else
69+ nspacl = NULL ;
70+
6371 /* initialize nulls and values */
6472 for (i = 0 ; i < Natts_pg_namespace ; i ++ )
6573 {
@@ -69,7 +77,10 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
6977 namestrcpy (& nname , nspName );
7078 values [Anum_pg_namespace_nspname - 1 ] = NameGetDatum (& nname );
7179 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;
7384
7485 nspdesc = heap_open (NamespaceRelationId , RowExclusiveLock );
7586 tupDesc = nspdesc -> rd_att ;
0 commit comments