pg_dump: Add --no-subscriptions option
Author: Michael Paquier <michael.paquier@gmail.com> Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>
This commit is contained in:
parent
ab178bb2f4
commit
26aa1cf376
|
@ -798,6 +798,15 @@ PostgreSQL documentation
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-subscriptions</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Do not dump subscriptions.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-synchronized-snapshots</></term>
|
||||
<listitem>
|
||||
|
|
|
@ -354,6 +354,15 @@ PostgreSQL documentation
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-subscriptions</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Do not dump subscriptions.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-sync</option></term>
|
||||
<listitem>
|
||||
|
|
|
@ -591,6 +591,16 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-subscriptions</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Do not output commands to restore subscriptions, even if the archive
|
||||
contains them.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-tablespaces</option></term>
|
||||
<listitem>
|
||||
|
|
|
@ -75,6 +75,7 @@ typedef struct _restoreOptions
|
|||
int column_inserts;
|
||||
int if_exists;
|
||||
int no_security_labels; /* Skip security label entries */
|
||||
int no_subscriptions; /* Skip subscription entries */
|
||||
int strict_names;
|
||||
|
||||
const char *filename;
|
||||
|
@ -145,6 +146,7 @@ typedef struct _dumpOptions
|
|||
int column_inserts;
|
||||
int if_exists;
|
||||
int no_security_labels;
|
||||
int no_subscriptions;
|
||||
int no_synchronized_snapshots;
|
||||
int no_unlogged_table_data;
|
||||
int serializable_deferrable;
|
||||
|
|
|
@ -167,6 +167,7 @@ dumpOptionsFromRestoreOptions(RestoreOptions *ropt)
|
|||
dopt->disable_dollar_quoting = ropt->disable_dollar_quoting;
|
||||
dopt->dump_inserts = ropt->dump_inserts;
|
||||
dopt->no_security_labels = ropt->no_security_labels;
|
||||
dopt->no_subscriptions = ropt->no_subscriptions;
|
||||
dopt->lockWaitTimeout = ropt->lockWaitTimeout;
|
||||
dopt->include_everything = ropt->include_everything;
|
||||
dopt->enable_row_security = ropt->enable_row_security;
|
||||
|
@ -2795,6 +2796,10 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
|
|||
if (ropt->no_security_labels && strcmp(te->desc, "SECURITY LABEL") == 0)
|
||||
return 0;
|
||||
|
||||
/* If it's a subcription, maybe ignore it */
|
||||
if (ropt->no_subscriptions && strcmp(te->desc, "SUBSCRIPTION") == 0)
|
||||
return 0;
|
||||
|
||||
/* Ignore it if section is not to be dumped/restored */
|
||||
switch (curSection)
|
||||
{
|
||||
|
|
|
@ -355,6 +355,7 @@ main(int argc, char **argv)
|
|||
{"no-security-labels", no_argument, &dopt.no_security_labels, 1},
|
||||
{"no-synchronized-snapshots", no_argument, &dopt.no_synchronized_snapshots, 1},
|
||||
{"no-unlogged-table-data", no_argument, &dopt.no_unlogged_table_data, 1},
|
||||
{"no-subscriptions", no_argument, &dopt.no_subscriptions, 1},
|
||||
{"no-sync", no_argument, NULL, 7},
|
||||
|
||||
{NULL, 0, NULL, 0}
|
||||
|
@ -862,6 +863,7 @@ main(int argc, char **argv)
|
|||
ropt->disable_dollar_quoting = dopt.disable_dollar_quoting;
|
||||
ropt->dump_inserts = dopt.dump_inserts;
|
||||
ropt->no_security_labels = dopt.no_security_labels;
|
||||
ropt->no_subscriptions = dopt.no_subscriptions;
|
||||
ropt->lockWaitTimeout = dopt.lockWaitTimeout;
|
||||
ropt->include_everything = dopt.include_everything;
|
||||
ropt->enable_row_security = dopt.enable_row_security;
|
||||
|
@ -950,6 +952,7 @@ help(const char *progname)
|
|||
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
||||
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
|
||||
printf(_(" --no-security-labels do not dump security label assignments\n"));
|
||||
printf(_(" --no-subscriptions do not dump subscriptions\n"));
|
||||
printf(_(" --no-synchronized-snapshots do not use synchronized snapshots in parallel jobs\n"));
|
||||
printf(_(" --no-tablespaces do not dump tablespace assignments\n"));
|
||||
printf(_(" --no-unlogged-table-data do not dump unlogged table data\n"));
|
||||
|
@ -3674,6 +3677,7 @@ is_superuser(Archive *fout)
|
|||
void
|
||||
getSubscriptions(Archive *fout)
|
||||
{
|
||||
DumpOptions *dopt = fout->dopt;
|
||||
PQExpBuffer query;
|
||||
PGresult *res;
|
||||
SubscriptionInfo *subinfo;
|
||||
|
@ -3688,7 +3692,7 @@ getSubscriptions(Archive *fout)
|
|||
int i,
|
||||
ntups;
|
||||
|
||||
if (fout->remoteVersion < 100000)
|
||||
if (dopt->no_subscriptions || fout->remoteVersion < 100000)
|
||||
return;
|
||||
|
||||
if (!is_superuser(fout))
|
||||
|
|
|
@ -75,6 +75,7 @@ static int inserts = 0;
|
|||
static int no_tablespaces = 0;
|
||||
static int use_setsessauth = 0;
|
||||
static int no_security_labels = 0;
|
||||
static int no_subscriptions = 0;
|
||||
static int no_unlogged_table_data = 0;
|
||||
static int no_role_passwords = 0;
|
||||
static int server_version;
|
||||
|
@ -129,6 +130,7 @@ main(int argc, char *argv[])
|
|||
{"role", required_argument, NULL, 3},
|
||||
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
|
||||
{"no-security-labels", no_argument, &no_security_labels, 1},
|
||||
{"no-subscriptions", no_argument, &no_subscriptions, 1},
|
||||
{"no-sync", no_argument, NULL, 4},
|
||||
{"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
|
||||
{"no-role-passwords", no_argument, &no_role_passwords, 1},
|
||||
|
@ -385,6 +387,8 @@ main(int argc, char *argv[])
|
|||
appendPQExpBufferStr(pgdumpopts, " --use-set-session-authorization");
|
||||
if (no_security_labels)
|
||||
appendPQExpBufferStr(pgdumpopts, " --no-security-labels");
|
||||
if (no_subscriptions)
|
||||
appendPQExpBufferStr(pgdumpopts, " --no-subscriptions");
|
||||
if (no_unlogged_table_data)
|
||||
appendPQExpBufferStr(pgdumpopts, " --no-unlogged-table-data");
|
||||
|
||||
|
@ -591,6 +595,7 @@ help(void)
|
|||
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
||||
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
|
||||
printf(_(" --no-security-labels do not dump security label assignments\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-tablespaces do not dump tablespace assignments\n"));
|
||||
printf(_(" --no-unlogged-table-data do not dump unlogged table data\n"));
|
||||
|
|
|
@ -72,6 +72,7 @@ main(int argc, char **argv)
|
|||
static int outputNoTablespaces = 0;
|
||||
static int use_setsessauth = 0;
|
||||
static int no_security_labels = 0;
|
||||
static int no_subscriptions = 0;
|
||||
static int strict_names = 0;
|
||||
|
||||
struct option cmdopts[] = {
|
||||
|
@ -118,6 +119,7 @@ main(int argc, char **argv)
|
|||
{"strict-names", no_argument, &strict_names, 1},
|
||||
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
|
||||
{"no-security-labels", no_argument, &no_security_labels, 1},
|
||||
{"no-subscriptions", no_argument, &no_subscriptions, 1},
|
||||
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
@ -355,6 +357,7 @@ main(int argc, char **argv)
|
|||
opts->noTablespace = outputNoTablespaces;
|
||||
opts->use_setsessauth = use_setsessauth;
|
||||
opts->no_security_labels = no_security_labels;
|
||||
opts->no_subscriptions = no_subscriptions;
|
||||
|
||||
if (if_exists && !opts->dropSchema)
|
||||
{
|
||||
|
@ -477,6 +480,7 @@ usage(const char *progname)
|
|||
printf(_(" --no-data-for-failed-tables do not restore data of tables that could not be\n"
|
||||
" created\n"));
|
||||
printf(_(" --no-security-labels do not restore security labels\n"));
|
||||
printf(_(" --no-subscriptions do not restore subscriptions\n"));
|
||||
printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
|
||||
printf(_(" --section=SECTION restore named section (pre-data, data, or post-data)\n"));
|
||||
printf(_(" --strict-names require table and/or schema include patterns to\n"
|
||||
|
|
Loading…
Reference in New Issue