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

Commit 7285748

Browse files
committed
Collect attribute data on extension owned tables being dumped
If this data is not collected, pg_dump segfaults if asked for column inserts. Fix by Fabrízio de Royes Mello Backpatch to release 12 where the bug was introduced.
1 parent 7574af1 commit 7285748

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/bin/pg_dump/pg_dump.c

+4
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,8 @@ dumpTableData_insert(Archive *fout, void *dcontext)
20952095
if (nfields == 0)
20962096
continue;
20972097

2098+
Assert(tbinfo->attgenerated);
2099+
20982100
/* Emit a row heading */
20992101
if (rows_per_statement == 1)
21002102
archputs(" (", fout);
@@ -18137,6 +18139,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
1813718139
configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]);
1813818140
}
1813918141
}
18142+
18143+
configtbl->interesting = dumpobj;
1814018144
}
1814118145
}
1814218146
if (extconfigarray)

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

+22-2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@
135135
"$tempdir/defaults_tar_format.tar",
136136
],
137137
},
138+
extension_schema => {
139+
dump_cmd => [
140+
'pg_dump', '--schema=public', '--inserts',
141+
"--file=$tempdir/extension_schema.sql", 'postgres',
142+
],
143+
},
138144
pg_dumpall_globals => {
139145
dump_cmd => [
140146
'pg_dumpall', '--no-sync',
@@ -301,8 +307,9 @@
301307
\n/xm,
302308
like => {
303309
%full_runs,
304-
data_only => 1,
305-
section_data => 1,
310+
data_only => 1,
311+
section_data => 1,
312+
extension_schema => 1,
306313
},
307314
},
308315
@@ -536,6 +543,7 @@
536543
like => {%pgdump_runs},
537544
unlike => {
538545
data_only => 1,
546+
extension_schema => 1,
539547
pg_dumpall_globals => 1,
540548
section_data => 1,
541549
section_pre_data => 1,
@@ -549,6 +557,7 @@
549557
like => {%pgdump_runs},
550558
unlike => {
551559
data_only => 1,
560+
extension_schema => 1,
552561
pg_dumpall_globals => 1,
553562
section_data => 1,
554563
section_pre_data => 1,
@@ -569,6 +578,17 @@
569578
schema_only => 1,
570579
section_pre_data => 1,
571580
},
581+
},
582+
583+
# Dumpable object inside specific schema
584+
'INSERT INTO public.regress_table_dumpable VALUES (1);' => {
585+
create_sql => 'INSERT INTO public.regress_table_dumpable VALUES (1);',
586+
regexp => qr/^
587+
\QINSERT INTO public.regress_table_dumpable VALUES (1);\E
588+
\n/xm,
589+
like => {
590+
extension_schema => 1,
591+
},
572592
},);
573593
574594
#########################################

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

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ CREATE SEQUENCE regress_pg_dump_seq;
1313
CREATE SEQUENCE regress_seq_dumpable;
1414
SELECT pg_catalog.pg_extension_config_dump('regress_seq_dumpable', '');
1515

16+
CREATE TABLE regress_table_dumpable (
17+
col1 int
18+
);
19+
SELECT pg_catalog.pg_extension_config_dump('regress_table_dumpable', '');
20+
1621
CREATE SCHEMA regress_pg_dump_schema;
1722

1823
GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role;

0 commit comments

Comments
 (0)