FAQ
The following bug has been logged online:

Bug reference: 4957
Logged by: Maxim.Boguk
Email address: maxim.boguk@gmail.com
PostgreSQL version: 8.3
Operating system: Any
Description: search_path and pg_dump -T switch
Details:

If table lies outside of database search path
pg_dump -T table will dump this table contents/structure.

(i found that bug when i creating custom backup plan for complicated db).

Test case:

empty DB:

pgsql@[local] postgres=#CREATE schema test;
CREATE SCHEMA
pgsql@[local] postgres=#CREATE TABLE test.test1 (id serial);
CREATE TABLE
pgsql@[local] postgres=#CREATE TABLE test2 (id serial);
CREATE TABLE
pgsql@[local] postgres=#INSERT into test.test1 values (1);
INSERT 0 1
pgsql@[local] postgres=#INSERT into test2 values (1);
INSERT 0 1

Now we have table test1 with one row outside of search_path and table test2
with one row inside of search path.

Now
pg_dump -F p -D -T test1 -a test_db | grep test1
will out:
INSERT INTO test1 (id) VALUES (1);

And
pg_dump -F p -D -T test2 -a test_db | grep test2
will out empty.

First result is wrong.

Search Discussions

  • Tom Lane at Jul 31, 2009 at 2:09 pm

    "Maxim.Boguk" <maxim.boguk@gmail.com> writes:
    Now we have table test1 with one row outside of search_path and table test2
    with one row inside of search path.
    Now
    pg_dump -F p -D -T test1 -a test_db | grep test1
    will out:
    INSERT INTO test1 (id) VALUES (1);
    And
    pg_dump -F p -D -T test2 -a test_db | grep test2
    will out empty.
    First result is wrong.
    No, I don't believe it is. The switch means "don't dump the table named
    test1 as found in your search path". So in this case it doesn't do
    anything. You could do "-T test.test1" or "-T *.test1" if you want to
    suppress that table.

    We could have pg_dump throw an error if -t or -T doesn't seem to refer
    to any actual table, but I'm not sure that would make it more useful.
    Particularly not with wild-card-pattern switches.

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-bugs @
categoriespostgresql
postedJul 31, '09 at 10:32a
activeJul 31, '09 at 2:09p
posts2
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Maxim.Boguk: 1 post Tom Lane: 1 post

People

Translate

site design / logo © 2021 Grokbase