Commit 3eb3d3e7 authored by Andrew Dunstan's avatar Andrew Dunstan

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.
parent 3b5af0e9
...@@ -2095,6 +2095,8 @@ dumpTableData_insert(Archive *fout, void *dcontext) ...@@ -2095,6 +2095,8 @@ dumpTableData_insert(Archive *fout, void *dcontext)
if (nfields == 0) if (nfields == 0)
continue; continue;
Assert(tbinfo->attgenerated);
/* Emit a row heading */ /* Emit a row heading */
if (rows_per_statement == 1) if (rows_per_statement == 1)
archputs(" (", fout); archputs(" (", fout);
...@@ -17913,6 +17915,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[], ...@@ -17913,6 +17915,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]); configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]);
} }
} }
configtbl->interesting = dumpobj;
} }
} }
if (extconfigarray) if (extconfigarray)
......
...@@ -135,6 +135,12 @@ my %pgdump_runs = ( ...@@ -135,6 +135,12 @@ my %pgdump_runs = (
"$tempdir/defaults_tar_format.tar", "$tempdir/defaults_tar_format.tar",
], ],
}, },
extension_schema => {
dump_cmd => [
'pg_dump', '--schema=public', '--inserts',
"--file=$tempdir/extension_schema.sql", 'postgres',
],
},
pg_dumpall_globals => { pg_dumpall_globals => {
dump_cmd => [ dump_cmd => [
'pg_dumpall', '--no-sync', 'pg_dumpall', '--no-sync',
...@@ -303,6 +309,7 @@ my %tests = ( ...@@ -303,6 +309,7 @@ my %tests = (
%full_runs, %full_runs,
data_only => 1, data_only => 1,
section_data => 1, section_data => 1,
extension_schema => 1,
}, },
}, },
...@@ -536,6 +543,7 @@ my %tests = ( ...@@ -536,6 +543,7 @@ my %tests = (
like => {%pgdump_runs}, like => {%pgdump_runs},
unlike => { unlike => {
data_only => 1, data_only => 1,
extension_schema => 1,
pg_dumpall_globals => 1, pg_dumpall_globals => 1,
section_data => 1, section_data => 1,
section_pre_data => 1, section_pre_data => 1,
...@@ -549,6 +557,7 @@ my %tests = ( ...@@ -549,6 +557,7 @@ my %tests = (
like => {%pgdump_runs}, like => {%pgdump_runs},
unlike => { unlike => {
data_only => 1, data_only => 1,
extension_schema => 1,
pg_dumpall_globals => 1, pg_dumpall_globals => 1,
section_data => 1, section_data => 1,
section_pre_data => 1, section_pre_data => 1,
...@@ -569,6 +578,17 @@ my %tests = ( ...@@ -569,6 +578,17 @@ my %tests = (
schema_only => 1, schema_only => 1,
section_pre_data => 1, section_pre_data => 1,
}, },
},
# Dumpable object inside specific schema
'INSERT INTO public.regress_table_dumpable VALUES (1);' => {
create_sql => 'INSERT INTO public.regress_table_dumpable VALUES (1);',
regexp => qr/^
\QINSERT INTO public.regress_table_dumpable VALUES (1);\E
\n/xm,
like => {
extension_schema => 1,
},
},); },);
######################################### #########################################
......
...@@ -13,6 +13,11 @@ CREATE SEQUENCE regress_pg_dump_seq; ...@@ -13,6 +13,11 @@ CREATE SEQUENCE regress_pg_dump_seq;
CREATE SEQUENCE regress_seq_dumpable; CREATE SEQUENCE regress_seq_dumpable;
SELECT pg_catalog.pg_extension_config_dump('regress_seq_dumpable', ''); SELECT pg_catalog.pg_extension_config_dump('regress_seq_dumpable', '');
CREATE TABLE regress_table_dumpable (
col1 int
);
SELECT pg_catalog.pg_extension_config_dump('regress_table_dumpable', '');
CREATE SCHEMA regress_pg_dump_schema; CREATE SCHEMA regress_pg_dump_schema;
GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role; GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment