Skip to content

Commit 26aa1cf

Browse files
committed
pg_dump: Add --no-subscriptions option
Author: Michael Paquier <michael.paquier@gmail.com> Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>
1 parent ab178bb commit 26aa1cf

File tree

8 files changed

+49
-1
lines changed

8 files changed

+49
-1
lines changed

doc/src/sgml/ref/pg_dump.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,15 @@ PostgreSQL documentation
798798
</listitem>
799799
</varlistentry>
800800

801+
<varlistentry>
802+
<term><option>--no-subscriptions</option></term>
803+
<listitem>
804+
<para>
805+
Do not dump subscriptions.
806+
</para>
807+
</listitem>
808+
</varlistentry>
809+
801810
<varlistentry>
802811
<term><option>--no-synchronized-snapshots</></term>
803812
<listitem>

doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,15 @@ PostgreSQL documentation
354354
</listitem>
355355
</varlistentry>
356356

357+
<varlistentry>
358+
<term><option>--no-subscriptions</option></term>
359+
<listitem>
360+
<para>
361+
Do not dump subscriptions.
362+
</para>
363+
</listitem>
364+
</varlistentry>
365+
357366
<varlistentry>
358367
<term><option>--no-sync</option></term>
359368
<listitem>

doc/src/sgml/ref/pg_restore.sgml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,16 @@
591591
</listitem>
592592
</varlistentry>
593593

594+
<varlistentry>
595+
<term><option>--no-subscriptions</option></term>
596+
<listitem>
597+
<para>
598+
Do not output commands to restore subscriptions, even if the archive
599+
contains them.
600+
</para>
601+
</listitem>
602+
</varlistentry>
603+
594604
<varlistentry>
595605
<term><option>--no-tablespaces</option></term>
596606
<listitem>

src/bin/pg_dump/pg_backup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ typedef struct _restoreOptions
7575
int column_inserts;
7676
int if_exists;
7777
int no_security_labels; /* Skip security label entries */
78+
int no_subscriptions; /* Skip subscription entries */
7879
int strict_names;
7980

8081
const char *filename;
@@ -145,6 +146,7 @@ typedef struct _dumpOptions
145146
int column_inserts;
146147
int if_exists;
147148
int no_security_labels;
149+
int no_subscriptions;
148150
int no_synchronized_snapshots;
149151
int no_unlogged_table_data;
150152
int serializable_deferrable;

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ dumpOptionsFromRestoreOptions(RestoreOptions *ropt)
167167
dopt->disable_dollar_quoting = ropt->disable_dollar_quoting;
168168
dopt->dump_inserts = ropt->dump_inserts;
169169
dopt->no_security_labels = ropt->no_security_labels;
170+
dopt->no_subscriptions = ropt->no_subscriptions;
170171
dopt->lockWaitTimeout = ropt->lockWaitTimeout;
171172
dopt->include_everything = ropt->include_everything;
172173
dopt->enable_row_security = ropt->enable_row_security;
@@ -2795,6 +2796,10 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
27952796
if (ropt->no_security_labels && strcmp(te->desc, "SECURITY LABEL") == 0)
27962797
return 0;
27972798

2799+
/* If it's a subcription, maybe ignore it */
2800+
if (ropt->no_subscriptions && strcmp(te->desc, "SUBSCRIPTION") == 0)
2801+
return 0;
2802+
27982803
/* Ignore it if section is not to be dumped/restored */
27992804
switch (curSection)
28002805
{

src/bin/pg_dump/pg_dump.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ main(int argc, char **argv)
355355
{"no-security-labels", no_argument, &dopt.no_security_labels, 1},
356356
{"no-synchronized-snapshots", no_argument, &dopt.no_synchronized_snapshots, 1},
357357
{"no-unlogged-table-data", no_argument, &dopt.no_unlogged_table_data, 1},
358+
{"no-subscriptions", no_argument, &dopt.no_subscriptions, 1},
358359
{"no-sync", no_argument, NULL, 7},
359360

360361
{NULL, 0, NULL, 0}
@@ -862,6 +863,7 @@ main(int argc, char **argv)
862863
ropt->disable_dollar_quoting = dopt.disable_dollar_quoting;
863864
ropt->dump_inserts = dopt.dump_inserts;
864865
ropt->no_security_labels = dopt.no_security_labels;
866+
ropt->no_subscriptions = dopt.no_subscriptions;
865867
ropt->lockWaitTimeout = dopt.lockWaitTimeout;
866868
ropt->include_everything = dopt.include_everything;
867869
ropt->enable_row_security = dopt.enable_row_security;
@@ -950,6 +952,7 @@ help(const char *progname)
950952
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
951953
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
952954
printf(_(" --no-security-labels do not dump security label assignments\n"));
955+
printf(_(" --no-subscriptions do not dump subscriptions\n"));
953956
printf(_(" --no-synchronized-snapshots do not use synchronized snapshots in parallel jobs\n"));
954957
printf(_(" --no-tablespaces do not dump tablespace assignments\n"));
955958
printf(_(" --no-unlogged-table-data do not dump unlogged table data\n"));
@@ -3674,6 +3677,7 @@ is_superuser(Archive *fout)
36743677
void
36753678
getSubscriptions(Archive *fout)
36763679
{
3680+
DumpOptions *dopt = fout->dopt;
36773681
PQExpBuffer query;
36783682
PGresult *res;
36793683
SubscriptionInfo *subinfo;
@@ -3688,7 +3692,7 @@ getSubscriptions(Archive *fout)
36883692
int i,
36893693
ntups;
36903694

3691-
if (fout->remoteVersion < 100000)
3695+
if (dopt->no_subscriptions || fout->remoteVersion < 100000)
36923696
return;
36933697

36943698
if (!is_superuser(fout))

src/bin/pg_dump/pg_dumpall.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static int inserts = 0;
7575
static int no_tablespaces = 0;
7676
static int use_setsessauth = 0;
7777
static int no_security_labels = 0;
78+
static int no_subscriptions = 0;
7879
static int no_unlogged_table_data = 0;
7980
static int no_role_passwords = 0;
8081
static int server_version;
@@ -129,6 +130,7 @@ main(int argc, char *argv[])
129130
{"role", required_argument, NULL, 3},
130131
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
131132
{"no-security-labels", no_argument, &no_security_labels, 1},
133+
{"no-subscriptions", no_argument, &no_subscriptions, 1},
132134
{"no-sync", no_argument, NULL, 4},
133135
{"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
134136
{"no-role-passwords", no_argument, &no_role_passwords, 1},
@@ -385,6 +387,8 @@ main(int argc, char *argv[])
385387
appendPQExpBufferStr(pgdumpopts, " --use-set-session-authorization");
386388
if (no_security_labels)
387389
appendPQExpBufferStr(pgdumpopts, " --no-security-labels");
390+
if (no_subscriptions)
391+
appendPQExpBufferStr(pgdumpopts, " --no-subscriptions");
388392
if (no_unlogged_table_data)
389393
appendPQExpBufferStr(pgdumpopts, " --no-unlogged-table-data");
390394

@@ -591,6 +595,7 @@ help(void)
591595
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
592596
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
593597
printf(_(" --no-security-labels do not dump security label assignments\n"));
598+
printf(_(" --no-subscriptions do not dump subscriptions\n"));
594599
printf(_(" --no-sync do not wait for changes to be written safely to disk\n"));
595600
printf(_(" --no-tablespaces do not dump tablespace assignments\n"));
596601
printf(_(" --no-unlogged-table-data do not dump unlogged table data\n"));

src/bin/pg_dump/pg_restore.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ main(int argc, char **argv)
7272
static int outputNoTablespaces = 0;
7373
static int use_setsessauth = 0;
7474
static int no_security_labels = 0;
75+
static int no_subscriptions = 0;
7576
static int strict_names = 0;
7677

7778
struct option cmdopts[] = {
@@ -118,6 +119,7 @@ main(int argc, char **argv)
118119
{"strict-names", no_argument, &strict_names, 1},
119120
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
120121
{"no-security-labels", no_argument, &no_security_labels, 1},
122+
{"no-subscriptions", no_argument, &no_subscriptions, 1},
121123

122124
{NULL, 0, NULL, 0}
123125
};
@@ -355,6 +357,7 @@ main(int argc, char **argv)
355357
opts->noTablespace = outputNoTablespaces;
356358
opts->use_setsessauth = use_setsessauth;
357359
opts->no_security_labels = no_security_labels;
360+
opts->no_subscriptions = no_subscriptions;
358361

359362
if (if_exists && !opts->dropSchema)
360363
{
@@ -477,6 +480,7 @@ usage(const char *progname)
477480
printf(_(" --no-data-for-failed-tables do not restore data of tables that could not be\n"
478481
" created\n"));
479482
printf(_(" --no-security-labels do not restore security labels\n"));
483+
printf(_(" --no-subscriptions do not restore subscriptions\n"));
480484
printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
481485
printf(_(" --section=SECTION restore named section (pre-data, data, or post-data)\n"));
482486
printf(_(" --strict-names require table and/or schema include patterns to\n"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy