1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

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.
This commit is contained in:
Tom Lane
2002-05-17 20:53:33 +00:00
parent 5f21560ae8
commit 940f772a29
5 changed files with 241 additions and 157 deletions

View File

@ -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,11 +87,18 @@ 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
@ -124,6 +133,9 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
}
}
/* Reset search path to normal state */
PopSpecialNamespace(namespaceId);
/* Reset current user */
SetUserId(saved_userid);
}