From: | Craig Ringer <craig(at)2ndquadrant(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | pg_restore -t of a view does an empty data-only restore |
Date: | 2015-04-01 02:22:01 |
Message-ID: | CAMsr+YGJ50TvTVK4Dbp66gAjeOC0KaP6KXFEHAOM+neQmHvoQA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
TL;DR: pg_restore -t should match views too, I'll send a patch.
A user reported an issue where they can't selectively restore the schema of
a view. The view is ignored by -t, so they get an empty restore.
When they
pg_restore -t theview -v - d dbname thedump
they get:
pg_restore: connecting to database for restore
pg_restore: implied data-only restore
... and the view is not restored. Omitting the target database shows that
pg_restore is just emitting its prelude then an empty body.
Looking at the pg_restore source, it's emitting that message
from src/bin/pg_dump/pg_backup_archiver.c:404 . It looks like it's scanned
the ToC for wanted entries, determined that none have been found, and
therefore assumed a data-only restore.
It looks like this is by design. -t is stored in opts->tableNames , which
is checked in _tocEntryRequired:
if (strcmp(te->desc, "TABLE") == 0 ||
strcmp(te->desc, "TABLE DATA") == 0)
{
if (!ropt->selTable)
return 0;
if (ropt->tableNames.head != NULL &&
(!(simple_string_list_member(&ropt->tableNames, te->tag))))
return 0;
}
IMO this should also match views, sequences, materialized views, foreign
tables, and anything else in pg_class. Elsewhere we treat them all as
relations, and they share the same namespace so there's no need to
differentiate between them based on object type.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Maxim Boguk | 2015-04-01 04:33:04 | Re: BUG #12933: Custom prepared plan vs partitioning. |
Previous Message | Dreamsxin | 2015-04-01 01:48:56 | 回复: [BUGS] BUG #12909: pg_dump error |