Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5e65df6

Browse files
committed
pg_dump: make dumpPublication et al. less unlike sibling functions.
dumpPublication, dumpPublicationNamespace, dumpPublicationTable, and dumpSubscription failed to check dataOnly. This is just a latent bug, because pg_backup_archiver.c would filter out the ArchiveEntry later; but they're wasting cycles in data-only dumps, and the omission might become a live bug someday. In any case, it's not good to have some dumpFoo functions do this and some not. On the same reasoning, make dumpPublicationNamespace follow the same pattern as every other dumpFoo function for checking the DUMP_COMPONENT_DEFINITION flag. (Since 5209c0b, we wouldn't even get here if that flag isn't set, so checking it is just pro forma right now. But it might not be so forever.) Since this is just cosmetic and/or future-proofing, no need for back-patch.
1 parent c9105dd commit 5e65df6

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3847,11 +3847,16 @@ getPublications(Archive *fout, int *numPublications)
38473847
static void
38483848
dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
38493849
{
3850+
DumpOptions *dopt = fout->dopt;
38503851
PQExpBuffer delq;
38513852
PQExpBuffer query;
38523853
char *qpubname;
38533854
bool first = true;
38543855

3856+
/* Do nothing in data-only dump */
3857+
if (dopt->dataOnly)
3858+
return;
3859+
38553860
delq = createPQExpBuffer();
38563861
query = createPQExpBuffer();
38573862

@@ -4112,12 +4117,14 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
41124117
static void
41134118
dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
41144119
{
4120+
DumpOptions *dopt = fout->dopt;
41154121
NamespaceInfo *schemainfo = pubsinfo->pubschema;
41164122
PublicationInfo *pubinfo = pubsinfo->publication;
41174123
PQExpBuffer query;
41184124
char *tag;
41194125

4120-
if (!(pubsinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
4126+
/* Do nothing in data-only dump */
4127+
if (dopt->dataOnly)
41214128
return;
41224129

41234130
tag = psprintf("%s %s", pubinfo->dobj.name, schemainfo->dobj.name);
@@ -4131,13 +4138,16 @@ dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
41314138
* There is no point in creating drop query as the drop is done by schema
41324139
* drop.
41334140
*/
4134-
ArchiveEntry(fout, pubsinfo->dobj.catId, pubsinfo->dobj.dumpId,
4135-
ARCHIVE_OPTS(.tag = tag,
4136-
.namespace = schemainfo->dobj.name,
4137-
.owner = pubinfo->rolname,
4138-
.description = "PUBLICATION TABLES IN SCHEMA",
4139-
.section = SECTION_POST_DATA,
4140-
.createStmt = query->data));
4141+
if (pubsinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
4142+
ArchiveEntry(fout, pubsinfo->dobj.catId, pubsinfo->dobj.dumpId,
4143+
ARCHIVE_OPTS(.tag = tag,
4144+
.namespace = schemainfo->dobj.name,
4145+
.owner = pubinfo->rolname,
4146+
.description = "PUBLICATION TABLES IN SCHEMA",
4147+
.section = SECTION_POST_DATA,
4148+
.createStmt = query->data));
4149+
4150+
/* These objects can't currently have comments or seclabels */
41414151

41424152
free(tag);
41434153
destroyPQExpBuffer(query);
@@ -4150,11 +4160,16 @@ dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
41504160
static void
41514161
dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo)
41524162
{
4163+
DumpOptions *dopt = fout->dopt;
41534164
PublicationInfo *pubinfo = pubrinfo->publication;
41544165
TableInfo *tbinfo = pubrinfo->pubtable;
41554166
PQExpBuffer query;
41564167
char *tag;
41574168

4169+
/* Do nothing in data-only dump */
4170+
if (dopt->dataOnly)
4171+
return;
4172+
41584173
tag = psprintf("%s %s", pubinfo->dobj.name, tbinfo->dobj.name);
41594174

41604175
query = createPQExpBuffer();
@@ -4180,6 +4195,8 @@ dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo)
41804195
.section = SECTION_POST_DATA,
41814196
.createStmt = query->data));
41824197

4198+
/* These objects can't currently have comments or seclabels */
4199+
41834200
free(tag);
41844201
destroyPQExpBuffer(query);
41854202
}
@@ -4339,6 +4356,7 @@ getSubscriptions(Archive *fout)
43394356
static void
43404357
dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
43414358
{
4359+
DumpOptions *dopt = fout->dopt;
43424360
PQExpBuffer delq;
43434361
PQExpBuffer query;
43444362
PQExpBuffer publications;
@@ -4348,6 +4366,10 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
43484366
int i;
43494367
char two_phase_disabled[] = {LOGICALREP_TWOPHASE_STATE_DISABLED, '\0'};
43504368

4369+
/* Do nothing in data-only dump */
4370+
if (dopt->dataOnly)
4371+
return;
4372+
43514373
delq = createPQExpBuffer();
43524374
query = createPQExpBuffer();
43534375

0 commit comments

Comments
 (0)