pg_dump: Only dump publications when dumping everything
Don't dump publications with pg_dump -t or similar cases that select specific groups of objects. Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
This commit is contained in:
parent
9212810c4f
commit
05227e0c34
@ -1621,6 +1621,23 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
|
|||||||
DUMP_COMPONENT_NONE;
|
DUMP_COMPONENT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* selectDumpablePublicationTable: policy-setting subroutine
|
||||||
|
* Mark a publication table as to be dumped or not
|
||||||
|
*
|
||||||
|
* Publication tables have schemas, but those are ignored in decision making,
|
||||||
|
* because publications are only dumped when we are dumping everything.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
selectDumpablePublicationTable(DumpableObject *dobj, Archive *fout)
|
||||||
|
{
|
||||||
|
if (checkExtensionMembership(dobj, fout))
|
||||||
|
return; /* extension membership overrides all else */
|
||||||
|
|
||||||
|
dobj->dump = fout->dopt->include_everything ?
|
||||||
|
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* selectDumpableObject: policy-setting subroutine
|
* selectDumpableObject: policy-setting subroutine
|
||||||
* Mark a generic dumpable object as to be dumped or not
|
* Mark a generic dumpable object as to be dumped or not
|
||||||
@ -3414,6 +3431,9 @@ getPublications(Archive *fout)
|
|||||||
if (strlen(pubinfo[i].rolname) == 0)
|
if (strlen(pubinfo[i].rolname) == 0)
|
||||||
write_msg(NULL, "WARNING: owner of publication \"%s\" appears to be invalid\n",
|
write_msg(NULL, "WARNING: owner of publication \"%s\" appears to be invalid\n",
|
||||||
pubinfo[i].dobj.name);
|
pubinfo[i].dobj.name);
|
||||||
|
|
||||||
|
/* Decide whether we want to dump it */
|
||||||
|
selectDumpableObject(&(pubinfo[i].dobj), fout);
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
@ -3427,11 +3447,10 @@ getPublications(Archive *fout)
|
|||||||
static void
|
static void
|
||||||
dumpPublication(Archive *fout, PublicationInfo *pubinfo)
|
dumpPublication(Archive *fout, PublicationInfo *pubinfo)
|
||||||
{
|
{
|
||||||
DumpOptions *dopt = fout->dopt;
|
|
||||||
PQExpBuffer delq;
|
PQExpBuffer delq;
|
||||||
PQExpBuffer query;
|
PQExpBuffer query;
|
||||||
|
|
||||||
if (dopt->dataOnly)
|
if (!(pubinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
delq = createPQExpBuffer();
|
delq = createPQExpBuffer();
|
||||||
@ -3560,6 +3579,9 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
|
|||||||
pubrinfo[j].dobj.name = tbinfo->dobj.name;
|
pubrinfo[j].dobj.name = tbinfo->dobj.name;
|
||||||
pubrinfo[j].pubname = pg_strdup(PQgetvalue(res, j, i_pubname));
|
pubrinfo[j].pubname = pg_strdup(PQgetvalue(res, j, i_pubname));
|
||||||
pubrinfo[j].pubtable = tbinfo;
|
pubrinfo[j].pubtable = tbinfo;
|
||||||
|
|
||||||
|
/* Decide whether we want to dump it */
|
||||||
|
selectDumpablePublicationTable(&(pubrinfo[j].dobj), fout);
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
}
|
}
|
||||||
@ -3573,12 +3595,11 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
|
|||||||
static void
|
static void
|
||||||
dumpPublicationTable(Archive *fout, PublicationRelInfo *pubrinfo)
|
dumpPublicationTable(Archive *fout, PublicationRelInfo *pubrinfo)
|
||||||
{
|
{
|
||||||
DumpOptions *dopt = fout->dopt;
|
|
||||||
TableInfo *tbinfo = pubrinfo->pubtable;
|
TableInfo *tbinfo = pubrinfo->pubtable;
|
||||||
PQExpBuffer query;
|
PQExpBuffer query;
|
||||||
char *tag;
|
char *tag;
|
||||||
|
|
||||||
if (dopt->dataOnly)
|
if (!(pubrinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tag = psprintf("%s %s", pubrinfo->pubname, tbinfo->dobj.name);
|
tag = psprintf("%s %s", pubrinfo->pubname, tbinfo->dobj.name);
|
||||||
|
@ -653,22 +653,22 @@ my %tests = (
|
|||||||
exclude_test_table_data => 1,
|
exclude_test_table_data => 1,
|
||||||
no_privs => 1,
|
no_privs => 1,
|
||||||
no_blobs => 1,
|
no_blobs => 1,
|
||||||
only_dump_test_schema => 1, # XXX Should be unlike
|
|
||||||
only_dump_test_table => 1, # XXX Should be unlike
|
|
||||||
pg_dumpall_dbprivs => 1,
|
pg_dumpall_dbprivs => 1,
|
||||||
role => 1, # XXX Should be unlike
|
|
||||||
schema_only => 1,
|
schema_only => 1,
|
||||||
section_post_data => 1,
|
section_post_data => 1,
|
||||||
test_schema_plus_blobs => 1, # XXX Should be unlike
|
|
||||||
with_oids => 1, },
|
with_oids => 1, },
|
||||||
unlike => {
|
unlike => {
|
||||||
column_inserts => 1,
|
column_inserts => 1,
|
||||||
data_only => 1,
|
data_only => 1,
|
||||||
no_owner => 1,
|
no_owner => 1,
|
||||||
|
only_dump_test_schema => 1,
|
||||||
|
only_dump_test_table => 1,
|
||||||
pg_dumpall_globals => 1,
|
pg_dumpall_globals => 1,
|
||||||
pg_dumpall_globals_clean => 1,
|
pg_dumpall_globals_clean => 1,
|
||||||
|
role => 1,
|
||||||
section_pre_data => 1,
|
section_pre_data => 1,
|
||||||
section_data => 1, }, },
|
section_data => 1,
|
||||||
|
test_schema_plus_blobs => 1, }, },
|
||||||
|
|
||||||
'ALTER LARGE OBJECT ... OWNER TO' => {
|
'ALTER LARGE OBJECT ... OWNER TO' => {
|
||||||
all_runs => 1,
|
all_runs => 1,
|
||||||
@ -4168,19 +4168,18 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
|
|||||||
no_blobs => 1,
|
no_blobs => 1,
|
||||||
no_privs => 1,
|
no_privs => 1,
|
||||||
no_owner => 1,
|
no_owner => 1,
|
||||||
only_dump_test_schema => 1, # XXX Should be unlike
|
|
||||||
only_dump_test_table => 1, # XXX Should be unlike
|
|
||||||
pg_dumpall_dbprivs => 1,
|
pg_dumpall_dbprivs => 1,
|
||||||
role => 1, # XXX Should be unlike
|
|
||||||
schema_only => 1,
|
schema_only => 1,
|
||||||
section_post_data => 1,
|
section_post_data => 1,
|
||||||
test_schema_plus_blobs => 1, # XXX Should be unlike
|
|
||||||
with_oids => 1, },
|
with_oids => 1, },
|
||||||
unlike => {
|
unlike => {
|
||||||
section_pre_data => 1,
|
only_dump_test_schema => 1,
|
||||||
|
only_dump_test_table => 1,
|
||||||
pg_dumpall_globals => 1,
|
pg_dumpall_globals => 1,
|
||||||
pg_dumpall_globals_clean => 1,
|
pg_dumpall_globals_clean => 1,
|
||||||
section_pre_data => 1, }, },
|
role => 1,
|
||||||
|
section_pre_data => 1,
|
||||||
|
test_schema_plus_blobs => 1, }, },
|
||||||
|
|
||||||
'CREATE PUBLICATION pub2' => {
|
'CREATE PUBLICATION pub2' => {
|
||||||
all_runs => 1,
|
all_runs => 1,
|
||||||
@ -4206,19 +4205,18 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
|
|||||||
no_blobs => 1,
|
no_blobs => 1,
|
||||||
no_privs => 1,
|
no_privs => 1,
|
||||||
no_owner => 1,
|
no_owner => 1,
|
||||||
only_dump_test_schema => 1, # XXX Should be unlike
|
|
||||||
only_dump_test_table => 1, # XXX Should be unlike
|
|
||||||
pg_dumpall_dbprivs => 1,
|
pg_dumpall_dbprivs => 1,
|
||||||
role => 1, # XXX Should be unlike
|
|
||||||
schema_only => 1,
|
schema_only => 1,
|
||||||
section_post_data => 1,
|
section_post_data => 1,
|
||||||
test_schema_plus_blobs => 1, # XXX Should be unlike
|
|
||||||
with_oids => 1, },
|
with_oids => 1, },
|
||||||
unlike => {
|
unlike => {
|
||||||
section_pre_data => 1,
|
only_dump_test_schema => 1,
|
||||||
|
only_dump_test_table => 1,
|
||||||
pg_dumpall_globals => 1,
|
pg_dumpall_globals => 1,
|
||||||
pg_dumpall_globals_clean => 1,
|
pg_dumpall_globals_clean => 1,
|
||||||
section_pre_data => 1, }, },
|
role => 1,
|
||||||
|
section_pre_data => 1,
|
||||||
|
test_schema_plus_blobs => 1, }, },
|
||||||
|
|
||||||
'CREATE SUBSCRIPTION sub1' => {
|
'CREATE SUBSCRIPTION sub1' => {
|
||||||
all_runs => 1,
|
all_runs => 1,
|
||||||
@ -4274,12 +4272,9 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
|
|||||||
no_blobs => 1,
|
no_blobs => 1,
|
||||||
no_privs => 1,
|
no_privs => 1,
|
||||||
no_owner => 1,
|
no_owner => 1,
|
||||||
only_dump_test_schema => 1,
|
|
||||||
only_dump_test_table => 1,
|
|
||||||
pg_dumpall_dbprivs => 1,
|
pg_dumpall_dbprivs => 1,
|
||||||
schema_only => 1,
|
schema_only => 1,
|
||||||
section_post_data => 1,
|
section_post_data => 1,
|
||||||
test_schema_plus_blobs => 1,
|
|
||||||
with_oids => 1, },
|
with_oids => 1, },
|
||||||
unlike => {
|
unlike => {
|
||||||
column_inserts => 1,
|
column_inserts => 1,
|
||||||
@ -4289,8 +4284,11 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
|
|||||||
section_pre_data => 1,
|
section_pre_data => 1,
|
||||||
exclude_dump_test_schema => 1,
|
exclude_dump_test_schema => 1,
|
||||||
exclude_test_table => 1,
|
exclude_test_table => 1,
|
||||||
|
only_dump_test_schema => 1,
|
||||||
|
only_dump_test_table => 1,
|
||||||
pg_dumpall_globals => 1,
|
pg_dumpall_globals => 1,
|
||||||
pg_dumpall_globals_clean => 1, }, },
|
pg_dumpall_globals_clean => 1,
|
||||||
|
test_schema_plus_blobs => 1, }, },
|
||||||
'ALTER PUBLICATION pub1 ADD TABLE test_second_table' => {
|
'ALTER PUBLICATION pub1 ADD TABLE test_second_table' => {
|
||||||
create_order => 52,
|
create_order => 52,
|
||||||
create_sql =>
|
create_sql =>
|
||||||
@ -4308,17 +4306,17 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
|
|||||||
exclude_test_table_data => 1,
|
exclude_test_table_data => 1,
|
||||||
no_privs => 1,
|
no_privs => 1,
|
||||||
no_owner => 1,
|
no_owner => 1,
|
||||||
only_dump_test_schema => 1,
|
|
||||||
pg_dumpall_dbprivs => 1,
|
pg_dumpall_dbprivs => 1,
|
||||||
schema_only => 1,
|
schema_only => 1,
|
||||||
section_post_data => 1,
|
section_post_data => 1, },
|
||||||
test_schema_plus_blobs => 1, },
|
|
||||||
unlike => {
|
unlike => {
|
||||||
section_pre_data => 1,
|
section_pre_data => 1,
|
||||||
exclude_dump_test_schema => 1,
|
exclude_dump_test_schema => 1,
|
||||||
|
only_dump_test_schema => 1,
|
||||||
only_dump_test_table => 1,
|
only_dump_test_table => 1,
|
||||||
pg_dumpall_globals => 1,
|
pg_dumpall_globals => 1,
|
||||||
pg_dumpall_globals_clean => 1, }, },
|
pg_dumpall_globals_clean => 1,
|
||||||
|
test_schema_plus_blobs => 1, }, },
|
||||||
|
|
||||||
'CREATE SCHEMA dump_test' => {
|
'CREATE SCHEMA dump_test' => {
|
||||||
all_runs => 1,
|
all_runs => 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user