From: shreeseva.it@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6660: losing schema name in pg_dump
Date: Tue, 22 May 2012 07:23:33 +0000
Message-ID: <E1SWjRN-0006yQ-Sx@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 6660
Logged by: C P Kulkarni
Email address: shreeseva.it@gmail.com
PostgreSQL version: 9.1.3
Operating system: Fedora 16
Description:
Many times I have to dump all objects from a schema (single schema holding
only functions and views) in plain text format. It is found that pg_dump
includes a set search_path statement at the beginning and drops all
occurrences of the schema name (to which dumped object belongs) from
function/view bodies even if they are explicitly defined while creating
functions/views.
Functions or view definition from information_schema tables shows the
explicitly defined schema names but pg_dump does not shows them.
This makes it problematic to maintain the software available for another
RDBMS as for most other RDBMS we have to explicitly define schema names
always.
I have two tables software.orders and software.products.
I created two views.
CREATE OR REPLACE VIEW software.o1 AS
SELECT orders.orderid, orders.productid, orders.amount
FROM software.orders;
CREATE OR REPLACE VIEW software.o2 AS
SELECT o1.orderid, o1.productid, o1.amount, products.productname
FROM software.o1
JOIN software.products ON o1.productid = products.productid;
Now I take backup for plain type to generate a sql file.
In that file pg_dump shows the view definitions as follows.
CREATE VIEW o1 AS
SELECT orders.orderid, orders.productid, orders.amount FROM orders;
CREATE VIEW o2 AS
SELECT o1.orderid, o1.productid, o1.amount, products.productname FROM
(o1 JOIN products ON ((o1.productid = products.productid)));
If I changed view o2 like this.
CREATE OR REPLACE VIEW software.o2 AS
SELECT o1.orderid, o1.productid, o1.amount, products.productname
FROM software.o1
JOIN core.products ON o1.productid = products.productid;
and again generated sql script from pg_dump then it still removes the schema
name occurrences of the same schema only where the object resides, from the
view definition.
CREATE VIEW o2 AS
SELECT o1.orderid, o1.productid, o1.amount, products.productname FROM
(o1 JOIN core.products ON ((o1.productid = products.productid)));
It keeps the schema name 'core' as it is but removes 'software'.
So it makes difficult porting the database to other RDBMS systems and also
to manage updates to customer installations. Having few hundred views and
few hundred functions makes it more difficult. So it will be better not to
remove any schema name when it is explicitly defined.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: shreeseva.it@gmail.com
Subject: Re: BUG #6660: losing schema name in pg_dump
In-Reply-To: <E1SWjRN-0006yQ-Sx@wrigleys.postgresql.org>
References: <E1SWjRN-0006yQ-Sx@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox