diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2020-09-04 13:53:09 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2020-09-04 13:54:54 -0400 |
commit | 3eb3d3e7822d5eecfcaba871a90263c6025c5216 (patch) | |
tree | 62373dd8d12681a490df5f39a53bfdc266f2cbf6 | |
parent | 3b5af0e95ad5a3d9b478826336a11ad1d201c378 (diff) | |
download | postgresql-3eb3d3e7822d5eecfcaba871a90263c6025c5216.tar.gz postgresql-3eb3d3e7822d5eecfcaba871a90263c6025c5216.zip |
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.
-rw-r--r-- | src/bin/pg_dump/pg_dump.c | 4 | ||||
-rw-r--r-- | src/test/modules/test_pg_dump/t/001_base.pl | 24 | ||||
-rw-r--r-- | src/test/modules/test_pg_dump/test_pg_dump--1.0.sql | 5 |
3 files changed, 31 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index d3ca54e4dc6..784bceaec39 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -2095,6 +2095,8 @@ dumpTableData_insert(Archive *fout, void *dcontext) if (nfields == 0) continue; + Assert(tbinfo->attgenerated); + /* Emit a row heading */ if (rows_per_statement == 1) archputs(" (", fout); @@ -17913,6 +17915,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[], configtbl->dataObj->filtercond = pg_strdup(extconditionarray[j]); } } + + configtbl->interesting = dumpobj; } } if (extconfigarray) diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index ae120a5ee36..78aa07ce511 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -135,6 +135,12 @@ my %pgdump_runs = ( "$tempdir/defaults_tar_format.tar", ], }, + extension_schema => { + dump_cmd => [ + 'pg_dump', '--schema=public', '--inserts', + "--file=$tempdir/extension_schema.sql", 'postgres', + ], + }, pg_dumpall_globals => { dump_cmd => [ 'pg_dumpall', '--no-sync', @@ -301,8 +307,9 @@ my %tests = ( \n/xm, like => { %full_runs, - data_only => 1, - section_data => 1, + data_only => 1, + section_data => 1, + extension_schema => 1, }, }, @@ -536,6 +543,7 @@ my %tests = ( like => {%pgdump_runs}, unlike => { data_only => 1, + extension_schema => 1, pg_dumpall_globals => 1, section_data => 1, section_pre_data => 1, @@ -549,6 +557,7 @@ my %tests = ( like => {%pgdump_runs}, unlike => { data_only => 1, + extension_schema => 1, pg_dumpall_globals => 1, section_data => 1, section_pre_data => 1, @@ -569,6 +578,17 @@ my %tests = ( schema_only => 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, + }, },); ######################################### diff --git a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql index 3ed007a7b1b..90e461ed357 100644 --- a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql +++ b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql @@ -13,6 +13,11 @@ CREATE SEQUENCE regress_pg_dump_seq; CREATE SEQUENCE 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; GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role; |