summaryrefslogtreecommitdiff
path: root/src/backend/commands/schemacmds.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-05-17 20:53:33 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-05-17 20:53:33 +0000
commit940f772a292124cb4506ffd7c9c2e953f9db3f33 (patch)
tree6f0a70387594f7977dff9808ea8956263eb8f31a /src/backend/commands/schemacmds.c
parent5f21560ae8f7387cfe4e109a5bdc01c58f82fbe5 (diff)
downloadpostgresql-940f772a292124cb4506ffd7c9c2e953f9db3f33.tar.gz
Support temporary setting of search path during CREATE SCHEMA; this
allows the example in the CREATE SCHEMA ref page to actually work now. Also, clean up when the transaction that initially creates a temp-table namespace is later aborted. Simplify internal representation of search path by folding special cases into the main list.
Diffstat (limited to 'src/backend/commands/schemacmds.c')
-rw-r--r--src/backend/commands/schemacmds.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
index 30bc4077d3..8f1870473d 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -8,13 +8,14 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.2 2002/04/27 03:45:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.3 2002/05/17 20:53:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "catalog/catalog.h"
+#include "catalog/namespace.h"
#include "catalog/pg_namespace.h"
#include "commands/schemacmds.h"
#include "miscadmin.h"
@@ -32,6 +33,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
{
const char *schemaName = stmt->schemaname;
const char *authId = stmt->authid;
+ Oid namespaceId;
List *parsetree_list;
List *parsetree_item;
const char *owner_name;
@@ -85,12 +87,19 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
schemaName);
/* Create the schema's namespace */
- NamespaceCreate(schemaName, owner_userid);
+ namespaceId = NamespaceCreate(schemaName, owner_userid);
- /* Let commands in the schema-element-list know about the schema */
+ /* Advance cmd counter to make the namespace visible */
CommandCounterIncrement();
/*
+ * Temporarily make the new namespace be the front of the search path,
+ * as well as the default creation target namespace. This will be undone
+ * at the end of this routine, or upon error.
+ */
+ PushSpecialNamespace(namespaceId);
+
+ /*
* Examine the list of commands embedded in the CREATE SCHEMA command,
* and reorganize them into a sequentially executable order with no
* forward references. Note that the result is still a list of raw
@@ -124,6 +133,9 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
}
}
+ /* Reset search path to normal state */
+ PopSpecialNamespace(namespaceId);
+
/* Reset current user */
SetUserId(saved_userid);
}