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)
4950TupleDesc tupDesc ;
5051ObjectAddress myself ;
5152int i ;
53+ Acl * nspacl ;
5254
5355/* sanity checks */
5456if (!nspName )
@@ -60,6 +62,12 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
6062(errcode (ERRCODE_DUPLICATE_SCHEMA ),
6163errmsg ("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 */
6472for (i = 0 ;i < Natts_pg_namespace ;i ++ )
6573{
@@ -69,7 +77,10 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
6977namestrcpy (& nname ,nspName );
7078values [Anum_pg_namespace_nspname - 1 ]= NameGetDatum (& nname );
7179values [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
7485nspdesc = heap_open (NamespaceRelationId ,RowExclusiveLock );
7586tupDesc = nspdesc -> rd_att ;