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

Commit 562f06f

Browse files
committed
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.
1 parent 8359077 commit 562f06f

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

src/bin/pg_dump/pg_dump.c

+14-12
Original file line numberDiff line numberDiff line change
@@ -12472,20 +12472,22 @@ dumpAccessMethod(Archive *fout, AccessMethodInfo *aminfo)
1247212472
appendPQExpBuffer(labelq, "ACCESS METHOD %s",
1247312473
qamname);
1247412474

12475-
ArchiveEntry(fout, aminfo->dobj.catId, aminfo->dobj.dumpId,
12476-
aminfo->dobj.name,
12477-
NULL,
12478-
NULL,
12479-
"",
12480-
false, "ACCESS METHOD", SECTION_PRE_DATA,
12481-
q->data, delq->data, NULL,
12482-
NULL, 0,
12483-
NULL, NULL);
12475+
if (aminfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
12476+
ArchiveEntry(fout, aminfo->dobj.catId, aminfo->dobj.dumpId,
12477+
aminfo->dobj.name,
12478+
NULL,
12479+
NULL,
12480+
"",
12481+
false, "ACCESS METHOD", SECTION_PRE_DATA,
12482+
q->data, delq->data, NULL,
12483+
NULL, 0,
12484+
NULL, NULL);
1248412485

1248512486
/* Dump Access Method Comments */
12486-
dumpComment(fout, labelq->data,
12487-
NULL, "",
12488-
aminfo->dobj.catId, 0, aminfo->dobj.dumpId);
12487+
if (aminfo->dobj.dump & DUMP_COMPONENT_COMMENT)
12488+
dumpComment(fout, labelq->data,
12489+
NULL, "",
12490+
aminfo->dobj.catId, 0, aminfo->dobj.dumpId);
1248912491

1249012492
pg_free(qamname);
1249112493

src/test/modules/test_pg_dump/t/001_base.pl

+20
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,26 @@
317317
section_post_data => 1,
318318
},
319319
},
320+
'CREATE ACCESS METHOD regress_test_am' => {
321+
regexp => qr/^
322+
\QCREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;\E
323+
$/xm,
324+
like => {
325+
binary_upgrade => 1,
326+
},
327+
unlike => {
328+
clean => 1,
329+
clean_if_exists => 1,
330+
createdb => 1,
331+
defaults => 1,
332+
no_privs => 1,
333+
no_owner => 1,
334+
pg_dumpall_globals => 1,
335+
schema_only => 1,
336+
section_pre_data => 1,
337+
section_post_data => 1,
338+
},
339+
},
320340
'COMMENT ON EXTENSION test_pg_dump' => {
321341
regexp => qr/^
322342
\QCOMMENT ON EXTENSION test_pg_dump \E

src/test/modules/test_pg_dump/test_pg_dump--1.0.sql

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ GRANT SELECT(col1) ON regress_pg_dump_table TO public;
1313

1414
GRANT SELECT(col2) ON regress_pg_dump_table TO dump_test;
1515
REVOKE SELECT(col2) ON regress_pg_dump_table FROM dump_test;
16+
17+
CREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;

0 commit comments

Comments
 (0)