pg_dump and schema names - Mailing list pgsql-hackers

From Bruce Momjian
Subject pg_dump and schema names
Date
Msg-id 20130809040455.GA3625@momjian.us
Whole thread Raw
Responses Re: pg_dump and schema names  (James Sewell <james.sewell@lisasoft.com>)
Re: pg_dump and schema names  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: pg_dump and schema names  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
pg_dump goes to great lengths not to hard-code the schema name into
commands like CREATE TABLE, instead setting the search_path before
creating the table;  these commands:
CREATE SCHEMA xx;CREATE TABLE xx.test(x int);

generates this output:
SET search_path = xx, pg_catalog;CREATE TABLE test (    x integer);

If you dump a schema and want to reload it into another schema, you
should only need to update that one search_path line.  However, later in
the dump file, we hardcode the schema name for setting the object owner:
ALTER TABLE xx.test OWNER TO postgres;

Could we use search_path here to avoid the schema designation?  I am not
sure this possible because while CREATE defaults to the first existing
schema in the search_path, I am not sure ALTER has the same behavior
because you are not _creating_ something with ALTER.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +



pgsql-hackers by date:

Previous
From: Jon Nelson
Date:
Subject: Re: 9.4 regression
Next
From: James Sewell
Date:
Subject: Re: pg_dump and schema names