mirror of
https://github.com/postgres/postgres.git
synced 2025-05-03 22:24:49 +03:00
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 5209c0ba0, 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.
This commit is contained in:
parent
c9105dd366
commit
5e65df64d6
@ -3847,11 +3847,16 @@ getPublications(Archive *fout, int *numPublications)
|
||||
static void
|
||||
dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
|
||||
{
|
||||
DumpOptions *dopt = fout->dopt;
|
||||
PQExpBuffer delq;
|
||||
PQExpBuffer query;
|
||||
char *qpubname;
|
||||
bool first = true;
|
||||
|
||||
/* Do nothing in data-only dump */
|
||||
if (dopt->dataOnly)
|
||||
return;
|
||||
|
||||
delq = createPQExpBuffer();
|
||||
query = createPQExpBuffer();
|
||||
|
||||
@ -4112,12 +4117,14 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
|
||||
static void
|
||||
dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
|
||||
{
|
||||
DumpOptions *dopt = fout->dopt;
|
||||
NamespaceInfo *schemainfo = pubsinfo->pubschema;
|
||||
PublicationInfo *pubinfo = pubsinfo->publication;
|
||||
PQExpBuffer query;
|
||||
char *tag;
|
||||
|
||||
if (!(pubsinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
|
||||
/* Do nothing in data-only dump */
|
||||
if (dopt->dataOnly)
|
||||
return;
|
||||
|
||||
tag = psprintf("%s %s", pubinfo->dobj.name, schemainfo->dobj.name);
|
||||
@ -4131,13 +4138,16 @@ dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
|
||||
* There is no point in creating drop query as the drop is done by schema
|
||||
* drop.
|
||||
*/
|
||||
ArchiveEntry(fout, pubsinfo->dobj.catId, pubsinfo->dobj.dumpId,
|
||||
ARCHIVE_OPTS(.tag = tag,
|
||||
.namespace = schemainfo->dobj.name,
|
||||
.owner = pubinfo->rolname,
|
||||
.description = "PUBLICATION TABLES IN SCHEMA",
|
||||
.section = SECTION_POST_DATA,
|
||||
.createStmt = query->data));
|
||||
if (pubsinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
|
||||
ArchiveEntry(fout, pubsinfo->dobj.catId, pubsinfo->dobj.dumpId,
|
||||
ARCHIVE_OPTS(.tag = tag,
|
||||
.namespace = schemainfo->dobj.name,
|
||||
.owner = pubinfo->rolname,
|
||||
.description = "PUBLICATION TABLES IN SCHEMA",
|
||||
.section = SECTION_POST_DATA,
|
||||
.createStmt = query->data));
|
||||
|
||||
/* These objects can't currently have comments or seclabels */
|
||||
|
||||
free(tag);
|
||||
destroyPQExpBuffer(query);
|
||||
@ -4150,11 +4160,16 @@ dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
|
||||
static void
|
||||
dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo)
|
||||
{
|
||||
DumpOptions *dopt = fout->dopt;
|
||||
PublicationInfo *pubinfo = pubrinfo->publication;
|
||||
TableInfo *tbinfo = pubrinfo->pubtable;
|
||||
PQExpBuffer query;
|
||||
char *tag;
|
||||
|
||||
/* Do nothing in data-only dump */
|
||||
if (dopt->dataOnly)
|
||||
return;
|
||||
|
||||
tag = psprintf("%s %s", pubinfo->dobj.name, tbinfo->dobj.name);
|
||||
|
||||
query = createPQExpBuffer();
|
||||
@ -4180,6 +4195,8 @@ dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo)
|
||||
.section = SECTION_POST_DATA,
|
||||
.createStmt = query->data));
|
||||
|
||||
/* These objects can't currently have comments or seclabels */
|
||||
|
||||
free(tag);
|
||||
destroyPQExpBuffer(query);
|
||||
}
|
||||
@ -4339,6 +4356,7 @@ getSubscriptions(Archive *fout)
|
||||
static void
|
||||
dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
|
||||
{
|
||||
DumpOptions *dopt = fout->dopt;
|
||||
PQExpBuffer delq;
|
||||
PQExpBuffer query;
|
||||
PQExpBuffer publications;
|
||||
@ -4348,6 +4366,10 @@ dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
|
||||
int i;
|
||||
char two_phase_disabled[] = {LOGICALREP_TWOPHASE_STATE_DISABLED, '\0'};
|
||||
|
||||
/* Do nothing in data-only dump */
|
||||
if (dopt->dataOnly)
|
||||
return;
|
||||
|
||||
delq = createPQExpBuffer();
|
||||
query = createPQExpBuffer();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user