git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a5d489c)
Improve pg_restore's -t switch to match all types of relations.
Thu, 2 Jul 2015 22:13:34 +0000 (18:13 -0400)
Thu, 2 Jul 2015 22:13:34 +0000 (18:13 -0400)
-t will now match views, foreign tables, materialized views, and sequences,
not only plain tables. This is more useful, and also more consistent with
the behavior of pg_dump's -t switch, which has always matched all relation
types.

We're still not there on matching pg_dump's behavior entirely, so mention
that in the docs.

Craig Ringer, reviewed by Pavel Stehule


diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 7c28bd2876ddd809db1749c25e3f0b916aa085df..7467e868e35929f0f4d5560e3632f1b07d749e45 100644 (file)
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -497,8 +497,10 @@ PostgreSQL documentation
<term><option>--table=<replaceable class="parameter">table</replaceable></option></term>
<listitem>
<para>
- Dump only tables (or views or sequences or foreign tables) matching
- <replaceable class="parameter">table</replaceable>. Multiple tables
+ Dump only tables with names matching
+ <replaceable class="parameter">table</replaceable>.
+ For this purpose, <quote>table</> includes views, materialized views,
+ sequences, and foreign tables. Multiple tables
can be selected by writing multiple <option>-t</> switches. Also, the
<replaceable class="parameter">table</replaceable> parameter is
interpreted as a pattern according to the same rules used by
diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml
index ebdf58020eed00194a280f0a98583116f75bd44b..97e3420489d4e6302aae113b44038010855c2090 100644 (file)
--- a/doc/src/sgml/ref/pg_restore.sgml
+++ b/doc/src/sgml/ref/pg_restore.sgml
@@ -395,10 +395,39 @@
<term><option>--table=<replaceable class="parameter">table</replaceable></option></term>
<listitem>
<para>
- Restore definition and/or data of named table only. Multiple tables
- may be specified with multiple <option>-t</> switches. This can be
- combined with the <option>-n</option> option to specify a schema.
- </para>
+ Restore definition and/or data of only the named table.
+ For this purpose, <quote>table</> includes views, materialized views,
+ sequences, and foreign tables. Multiple tables
+ can be selected by writing multiple <option>-t</> switches.
+ This option can be combined with the <option>-n</option> option to
+ specify table(s) in a particular schema.
+ </para>
+
+ <note>
+ <para>
+ When <option>-t</option> is specified, <application>pg_restore</>
+ makes no attempt to restore any other database objects that the
+ selected table(s) might depend upon. Therefore, there is no
+ guarantee that a specific-table restore into a clean database will
+ succeed.
+ </para>
+ </note>
+
+ <note>
+ <para>
+ This flag does not behave identically to the <option>-t</option>
+ flag of <application>pg_dump</application>. There is not currently
+ any provision for wild-card matching in <application>pg_restore</>,
+ nor can you include a schema name within its <option>-t</>.
+ </para>
+ </note>
+
+ <note>
+ <para>
+ In versions prior to <productname>PostgreSQL</> 9.6, this flag
+ matched only tables, not any other type of relation.
+ </para>
+ </note>
</listitem>
</varlistentry>
@@ -494,7 +523,7 @@
fail if the user does not have the right to insert the rows from the
dump into the table.
</para>
-
+
<para>
Note that this option currently also requires the dump be in INSERT
format as COPY TO does not support row security.
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 0d52babc4f1794f3ce006e3846a1813b4b7c834a..8f1f6c1a24b09e12d72283dca363a1a74ddbf483 100644 (file)
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -2663,7 +2663,13 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
if (ropt->selTypes)
{
if (strcmp(te->desc, "TABLE") == 0 ||
- strcmp(te->desc, "TABLE DATA") == 0)
+ strcmp(te->desc, "TABLE DATA") == 0 ||
+ strcmp(te->desc, "VIEW") == 0 ||
+ strcmp(te->desc, "FOREIGN TABLE") == 0 ||
+ strcmp(te->desc, "MATERIALIZED VIEW") == 0 ||
+ strcmp(te->desc, "MATERIALIZED VIEW DATA") == 0 ||
+ strcmp(te->desc, "SEQUENCE") == 0 ||
+ strcmp(te->desc, "SEQUENCE SET") == 0)
{
if (!ropt->selTable)
return 0;
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index ec82d0b98d5ca9e2540d36623233ba64439437ef..b12948823c3795979b6fcb11997da6a28885135b 100644 (file)
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -227,7 +227,7 @@ main(int argc, char **argv)
if (strlen(optarg) != 0)
opts->superuser = pg_strdup(optarg);
break;
- case 't': /* Dump data for this table only */
+ case 't': /* Dump specified table(s) only */
opts->selTypes = 1;
opts->selTable = 1;
simple_string_list_append(&opts->tableNames, optarg);
@@ -455,7 +455,7 @@ usage(const char *progname)
printf(_(" -P, --function=NAME(args) restore named function\n"));
printf(_(" -s, --schema-only restore only the schema, no data\n"));
printf(_(" -S, --superuser=NAME superuser user name to use for disabling triggers\n"));
- printf(_(" -t, --table=NAME restore named table\n"));
+ printf(_(" -t, --table=NAME restore named relation (table, view, etc)\n"));
printf(_(" -T, --trigger=NAME restore named trigger\n"));
printf(_(" -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"));
printf(_(" -1, --single-transaction restore as a single transaction\n"));
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /