pg_dump only selected components of ACCESS METHODs

dumpAccessMethod() didn't get the memo that we now have a bitfield for
the components which should be dumped instead of a simple boolean.

Correct that by checking if the relevant bit is set for each component
being dumped out (and not dumping it out if it isn't set).

This corrects an issue where CREATE ACCESS METHOD commands were being
included in non-binary-upgrades when an extension included an access
method (as the bloom extensions does).

Also add a regression test to make sure that we only dump out the
ACCESS METHOD commands, when they are part of an extension, when doing
a binary upgrade.

Pointed out by Thom Brown.
This commit is contained in:
Stephen Frost 2016-06-07 09:56:02 -04:00
parent 8359077124
commit 562f06f3f0
3 changed files with 36 additions and 12 deletions

View File

@ -12472,20 +12472,22 @@ dumpAccessMethod(Archive *fout, AccessMethodInfo *aminfo)
appendPQExpBuffer(labelq, "ACCESS METHOD %s",
qamname);
ArchiveEntry(fout, aminfo->dobj.catId, aminfo->dobj.dumpId,
aminfo->dobj.name,
NULL,
NULL,
"",
false, "ACCESS METHOD", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
if (aminfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, aminfo->dobj.catId, aminfo->dobj.dumpId,
aminfo->dobj.name,
NULL,
NULL,
"",
false, "ACCESS METHOD", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
/* Dump Access Method Comments */
dumpComment(fout, labelq->data,
NULL, "",
aminfo->dobj.catId, 0, aminfo->dobj.dumpId);
if (aminfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, "",
aminfo->dobj.catId, 0, aminfo->dobj.dumpId);
pg_free(qamname);

View File

@ -317,6 +317,26 @@ my %tests = (
section_post_data => 1,
},
},
'CREATE ACCESS METHOD regress_test_am' => {
regexp => qr/^
\QCREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;\E
$/xm,
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
createdb => 1,
defaults => 1,
no_privs => 1,
no_owner => 1,
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1,
},
},
'COMMENT ON EXTENSION test_pg_dump' => {
regexp => qr/^
\QCOMMENT ON EXTENSION test_pg_dump \E

View File

@ -13,3 +13,5 @@ GRANT SELECT(col1) ON regress_pg_dump_table TO public;
GRANT SELECT(col2) ON regress_pg_dump_table TO dump_test;
REVOKE SELECT(col2) ON regress_pg_dump_table FROM dump_test;
CREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;