pg_dump: Add --no-publications option
Author: Michael Paquier <michael.paquier@gmail.com>
This commit is contained in:
parent
b807f59828
commit
96e1cb4c0f
@ -789,6 +789,15 @@ PostgreSQL documentation
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--no-publications</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Do not dump publications.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--no-security-labels</option></term>
|
<term><option>--no-security-labels</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -345,6 +345,15 @@ PostgreSQL documentation
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--no-publications</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Do not dump publications.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--no-security-labels</option></term>
|
<term><option>--no-security-labels</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -581,6 +581,16 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--no-publications</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Do not output commands to restore publications, even if the archive
|
||||||
|
contains them.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--no-security-labels</option></term>
|
<term><option>--no-security-labels</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -74,6 +74,7 @@ typedef struct _restoreOptions
|
|||||||
int dump_inserts;
|
int dump_inserts;
|
||||||
int column_inserts;
|
int column_inserts;
|
||||||
int if_exists;
|
int if_exists;
|
||||||
|
int no_publications; /* Skip publication entries */
|
||||||
int no_security_labels; /* Skip security label entries */
|
int no_security_labels; /* Skip security label entries */
|
||||||
int no_subscriptions; /* Skip subscription entries */
|
int no_subscriptions; /* Skip subscription entries */
|
||||||
int strict_names;
|
int strict_names;
|
||||||
@ -146,6 +147,7 @@ typedef struct _dumpOptions
|
|||||||
int column_inserts;
|
int column_inserts;
|
||||||
int if_exists;
|
int if_exists;
|
||||||
int no_security_labels;
|
int no_security_labels;
|
||||||
|
int no_publications;
|
||||||
int no_subscriptions;
|
int no_subscriptions;
|
||||||
int no_synchronized_snapshots;
|
int no_synchronized_snapshots;
|
||||||
int no_unlogged_table_data;
|
int no_unlogged_table_data;
|
||||||
|
@ -166,6 +166,7 @@ dumpOptionsFromRestoreOptions(RestoreOptions *ropt)
|
|||||||
|
|
||||||
dopt->disable_dollar_quoting = ropt->disable_dollar_quoting;
|
dopt->disable_dollar_quoting = ropt->disable_dollar_quoting;
|
||||||
dopt->dump_inserts = ropt->dump_inserts;
|
dopt->dump_inserts = ropt->dump_inserts;
|
||||||
|
dopt->no_publications = ropt->no_publications;
|
||||||
dopt->no_security_labels = ropt->no_security_labels;
|
dopt->no_security_labels = ropt->no_security_labels;
|
||||||
dopt->no_subscriptions = ropt->no_subscriptions;
|
dopt->no_subscriptions = ropt->no_subscriptions;
|
||||||
dopt->lockWaitTimeout = ropt->lockWaitTimeout;
|
dopt->lockWaitTimeout = ropt->lockWaitTimeout;
|
||||||
@ -2792,6 +2793,10 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
|
|||||||
if (ropt->aclsSkip && _tocEntryIsACL(te))
|
if (ropt->aclsSkip && _tocEntryIsACL(te))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* If it's a publication, maybe ignore it */
|
||||||
|
if (ropt->no_publications && strcmp(te->desc, "PUBLICATION") == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* If it's security labels, maybe ignore it */
|
/* If it's security labels, maybe ignore it */
|
||||||
if (ropt->no_security_labels && strcmp(te->desc, "SECURITY LABEL") == 0)
|
if (ropt->no_security_labels && strcmp(te->desc, "SECURITY LABEL") == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -352,6 +352,7 @@ main(int argc, char **argv)
|
|||||||
{"snapshot", required_argument, NULL, 6},
|
{"snapshot", required_argument, NULL, 6},
|
||||||
{"strict-names", no_argument, &strict_names, 1},
|
{"strict-names", no_argument, &strict_names, 1},
|
||||||
{"use-set-session-authorization", no_argument, &dopt.use_setsessauth, 1},
|
{"use-set-session-authorization", no_argument, &dopt.use_setsessauth, 1},
|
||||||
|
{"no-publications", no_argument, &dopt.no_publications, 1},
|
||||||
{"no-security-labels", no_argument, &dopt.no_security_labels, 1},
|
{"no-security-labels", no_argument, &dopt.no_security_labels, 1},
|
||||||
{"no-synchronized-snapshots", no_argument, &dopt.no_synchronized_snapshots, 1},
|
{"no-synchronized-snapshots", no_argument, &dopt.no_synchronized_snapshots, 1},
|
||||||
{"no-unlogged-table-data", no_argument, &dopt.no_unlogged_table_data, 1},
|
{"no-unlogged-table-data", no_argument, &dopt.no_unlogged_table_data, 1},
|
||||||
@ -862,6 +863,7 @@ main(int argc, char **argv)
|
|||||||
ropt->use_setsessauth = dopt.use_setsessauth;
|
ropt->use_setsessauth = dopt.use_setsessauth;
|
||||||
ropt->disable_dollar_quoting = dopt.disable_dollar_quoting;
|
ropt->disable_dollar_quoting = dopt.disable_dollar_quoting;
|
||||||
ropt->dump_inserts = dopt.dump_inserts;
|
ropt->dump_inserts = dopt.dump_inserts;
|
||||||
|
ropt->no_publications = dopt.no_publications;
|
||||||
ropt->no_security_labels = dopt.no_security_labels;
|
ropt->no_security_labels = dopt.no_security_labels;
|
||||||
ropt->no_subscriptions = dopt.no_subscriptions;
|
ropt->no_subscriptions = dopt.no_subscriptions;
|
||||||
ropt->lockWaitTimeout = dopt.lockWaitTimeout;
|
ropt->lockWaitTimeout = dopt.lockWaitTimeout;
|
||||||
@ -951,6 +953,7 @@ help(const char *progname)
|
|||||||
printf(_(" --exclude-table-data=TABLE do NOT dump data for the named table(s)\n"));
|
printf(_(" --exclude-table-data=TABLE do NOT dump data for the named table(s)\n"));
|
||||||
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
||||||
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
|
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
|
||||||
|
printf(_(" --no-publications do not dump publications\n"));
|
||||||
printf(_(" --no-security-labels do not dump security label assignments\n"));
|
printf(_(" --no-security-labels do not dump security label assignments\n"));
|
||||||
printf(_(" --no-subscriptions do not dump subscriptions\n"));
|
printf(_(" --no-subscriptions do not dump subscriptions\n"));
|
||||||
printf(_(" --no-synchronized-snapshots do not use synchronized snapshots in parallel jobs\n"));
|
printf(_(" --no-synchronized-snapshots do not use synchronized snapshots in parallel jobs\n"));
|
||||||
@ -3376,6 +3379,7 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
|
|||||||
void
|
void
|
||||||
getPublications(Archive *fout)
|
getPublications(Archive *fout)
|
||||||
{
|
{
|
||||||
|
DumpOptions *dopt = fout->dopt;
|
||||||
PQExpBuffer query;
|
PQExpBuffer query;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
PublicationInfo *pubinfo;
|
PublicationInfo *pubinfo;
|
||||||
@ -3390,7 +3394,7 @@ getPublications(Archive *fout)
|
|||||||
int i,
|
int i,
|
||||||
ntups;
|
ntups;
|
||||||
|
|
||||||
if (fout->remoteVersion < 100000)
|
if (dopt->no_publications || fout->remoteVersion < 100000)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
query = createPQExpBuffer();
|
query = createPQExpBuffer();
|
||||||
|
@ -74,6 +74,7 @@ static int if_exists = 0;
|
|||||||
static int inserts = 0;
|
static int inserts = 0;
|
||||||
static int no_tablespaces = 0;
|
static int no_tablespaces = 0;
|
||||||
static int use_setsessauth = 0;
|
static int use_setsessauth = 0;
|
||||||
|
static int no_publications = 0;
|
||||||
static int no_security_labels = 0;
|
static int no_security_labels = 0;
|
||||||
static int no_subscriptions = 0;
|
static int no_subscriptions = 0;
|
||||||
static int no_unlogged_table_data = 0;
|
static int no_unlogged_table_data = 0;
|
||||||
@ -129,6 +130,7 @@ main(int argc, char *argv[])
|
|||||||
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
|
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
|
||||||
{"role", required_argument, NULL, 3},
|
{"role", required_argument, NULL, 3},
|
||||||
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
|
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
|
||||||
|
{"no-publications", no_argument, &no_publications, 1},
|
||||||
{"no-security-labels", no_argument, &no_security_labels, 1},
|
{"no-security-labels", no_argument, &no_security_labels, 1},
|
||||||
{"no-subscriptions", no_argument, &no_subscriptions, 1},
|
{"no-subscriptions", no_argument, &no_subscriptions, 1},
|
||||||
{"no-sync", no_argument, NULL, 4},
|
{"no-sync", no_argument, NULL, 4},
|
||||||
@ -385,6 +387,8 @@ main(int argc, char *argv[])
|
|||||||
appendPQExpBufferStr(pgdumpopts, " --quote-all-identifiers");
|
appendPQExpBufferStr(pgdumpopts, " --quote-all-identifiers");
|
||||||
if (use_setsessauth)
|
if (use_setsessauth)
|
||||||
appendPQExpBufferStr(pgdumpopts, " --use-set-session-authorization");
|
appendPQExpBufferStr(pgdumpopts, " --use-set-session-authorization");
|
||||||
|
if (no_publications)
|
||||||
|
appendPQExpBufferStr(pgdumpopts, " --no-publications");
|
||||||
if (no_security_labels)
|
if (no_security_labels)
|
||||||
appendPQExpBufferStr(pgdumpopts, " --no-security-labels");
|
appendPQExpBufferStr(pgdumpopts, " --no-security-labels");
|
||||||
if (no_subscriptions)
|
if (no_subscriptions)
|
||||||
@ -594,6 +598,7 @@ help(void)
|
|||||||
printf(_(" --disable-triggers disable triggers during data-only restore\n"));
|
printf(_(" --disable-triggers disable triggers during data-only restore\n"));
|
||||||
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
||||||
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
|
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
|
||||||
|
printf(_(" --no-publications do not dump publications\n"));
|
||||||
printf(_(" --no-security-labels do not dump security label assignments\n"));
|
printf(_(" --no-security-labels do not dump security label assignments\n"));
|
||||||
printf(_(" --no-subscriptions do not dump subscriptions\n"));
|
printf(_(" --no-subscriptions do not dump subscriptions\n"));
|
||||||
printf(_(" --no-sync do not wait for changes to be written safely to disk\n"));
|
printf(_(" --no-sync do not wait for changes to be written safely to disk\n"));
|
||||||
|
@ -71,6 +71,7 @@ main(int argc, char **argv)
|
|||||||
static int no_data_for_failed_tables = 0;
|
static int no_data_for_failed_tables = 0;
|
||||||
static int outputNoTablespaces = 0;
|
static int outputNoTablespaces = 0;
|
||||||
static int use_setsessauth = 0;
|
static int use_setsessauth = 0;
|
||||||
|
static int no_publications = 0;
|
||||||
static int no_security_labels = 0;
|
static int no_security_labels = 0;
|
||||||
static int no_subscriptions = 0;
|
static int no_subscriptions = 0;
|
||||||
static int strict_names = 0;
|
static int strict_names = 0;
|
||||||
@ -118,6 +119,7 @@ main(int argc, char **argv)
|
|||||||
{"section", required_argument, NULL, 3},
|
{"section", required_argument, NULL, 3},
|
||||||
{"strict-names", no_argument, &strict_names, 1},
|
{"strict-names", no_argument, &strict_names, 1},
|
||||||
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
|
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
|
||||||
|
{"no-publications", no_argument, &no_publications, 1},
|
||||||
{"no-security-labels", no_argument, &no_security_labels, 1},
|
{"no-security-labels", no_argument, &no_security_labels, 1},
|
||||||
{"no-subscriptions", no_argument, &no_subscriptions, 1},
|
{"no-subscriptions", no_argument, &no_subscriptions, 1},
|
||||||
|
|
||||||
@ -356,6 +358,7 @@ main(int argc, char **argv)
|
|||||||
opts->noDataForFailedTables = no_data_for_failed_tables;
|
opts->noDataForFailedTables = no_data_for_failed_tables;
|
||||||
opts->noTablespace = outputNoTablespaces;
|
opts->noTablespace = outputNoTablespaces;
|
||||||
opts->use_setsessauth = use_setsessauth;
|
opts->use_setsessauth = use_setsessauth;
|
||||||
|
opts->no_publications = no_publications;
|
||||||
opts->no_security_labels = no_security_labels;
|
opts->no_security_labels = no_security_labels;
|
||||||
opts->no_subscriptions = no_subscriptions;
|
opts->no_subscriptions = no_subscriptions;
|
||||||
|
|
||||||
@ -479,6 +482,7 @@ usage(const char *progname)
|
|||||||
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
||||||
printf(_(" --no-data-for-failed-tables do not restore data of tables that could not be\n"
|
printf(_(" --no-data-for-failed-tables do not restore data of tables that could not be\n"
|
||||||
" created\n"));
|
" created\n"));
|
||||||
|
printf(_(" --no-publications do not restore publications\n"));
|
||||||
printf(_(" --no-security-labels do not restore security labels\n"));
|
printf(_(" --no-security-labels do not restore security labels\n"));
|
||||||
printf(_(" --no-subscriptions do not restore subscriptions\n"));
|
printf(_(" --no-subscriptions do not restore subscriptions\n"));
|
||||||
printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
|
printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user