Skip to content

Commit 3eb3d3e

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 3b5af0e commit 3eb3d3e

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 4 additions & 0 deletions
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);
@@ -17913,6 +17915,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
1791317915
configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]);
1791417916
}
1791517917
}
17918+
17919+
configtbl->interesting = dumpobj;
1791617920
}
1791717921
}
1791817922
if (extconfigarray)

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

Lines changed: 22 additions & 2 deletions
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

Lines changed: 5 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy