OSDN Git Service

Fix bugs in relpersistence handling during table creation.
[pg-rex/syncrep.git] / src / backend / commands / tablecmds.c
index cfc685b..a3a99d2 100644 (file)
@@ -432,6 +432,13 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId)
                                 errmsg("constraints on foreign tables are not supported")));
 
        /*
+        * Look up the namespace in which we are supposed to create the relation,
+        * and check we have permission to create there.
+        */
+       namespaceId = RangeVarGetAndCheckCreationNamespace(stmt->relation);
+       RangeVarAdjustRelationPersistence(stmt->relation, namespaceId);
+
+       /*
         * Security check: disallow creating temp tables from security-restricted
         * code.  This is needed because calling code might not expect untrusted
         * tables to appear in pg_temp at the front of its search path.
@@ -443,12 +450,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId)
                                 errmsg("cannot create temporary table within security-restricted operation")));
 
        /*
-        * Look up the namespace in which we are supposed to create the relation,
-        * and check we have permission to create there.
-        */
-       namespaceId = RangeVarGetAndCheckCreationNamespace(stmt->relation);
-
-       /*
         * Select tablespace to use.  If not specified, use default tablespace
         * (which may in turn default to database's default).
         */