Re: DB & Schema - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: DB & Schema
Date
Msg-id 505C929D.5070400@vmware.com
Whole thread Raw
In response to DB & Schema  ("md@rpzdesign.com" <md@rpzdesign.com>)
Responses External Replication  ("md@rpzdesign.com" <md@rpzdesign.com>)
List pgsql-hackers
On 21.09.2012 17:58, md@rpzdesign.com wrote:
> During the execution of ProcessUtility() function in
> /src/backend/xxx/utility.c,
>
> the CreateStmt node type is processed to create a table.
>
> Is there a global function in the context of the backend process that
> will deliver what the current database and schema names?

There's a global variable MyDatabaseId for the database the backend is 
connected to. It doesn't change after login.

There's no such thing as a "current schema", but I think you'll want to 
take a look at src/backend/catalog/namespace.c, which handles the 
search_path. There's a variable activeCreationNamespace there; look at 
the functions in namespace.c to see how it works.

- Heikki



pgsql-hackers by date:

Previous
From: "Karl O. Pinc"
Date:
Subject: Re: Suggestion for --truncate-tables to pg_restore
Next
From: Tom Lane
Date:
Subject: Re: 64-bit API for large object