On Mon, Jul 13, 2020 at 3:29 PM Andrew Dunstan < andrew.duns...@2ndquadrant.com> wrote: > > > On 7/13/20 10:52 AM, Fabrízio de Royes Mello wrote: > > > > On Sat, Jul 11, 2020 at 8:07 PM Andrew Dunstan > > <andrew.duns...@2ndquadrant.com > > <mailto:andrew.duns...@2ndquadrant.com>> wrote: > > > > > > > > > On 6/26/20 2:10 PM, Fabrízio de Royes Mello wrote: > > > > > > > > On Fri, Jun 26, 2020 at 11:55 AM Fabrízio de Royes Mello > > > > <fabriziome...@gmail.com <mailto:fabriziome...@gmail.com> > > <mailto:fabriziome...@gmail.com <mailto:fabriziome...@gmail.com>>> wrote: > > > > > > > > > > > > > > > On Fri, Jun 26, 2020 at 11:24 AM Andrew Dunstan > > > > <andrew.duns...@2ndquadrant.com > > <mailto:andrew.duns...@2ndquadrant.com> > > > > <mailto:andrew.duns...@2ndquadrant.com > > <mailto:andrew.duns...@2ndquadrant.com>>> wrote: > > > > > > > > > > > > > > > > > > On 6/26/20 9:57 AM, Andrew Dunstan wrote: > > > > > > > It appears that for extension owned tables > > tbinfo.attgenerated isn't > > > > > > > being properly populated, so line 2050 in REL_12_STABLE, which > > > > is line > > > > > > > 2109 in git tip, is failing. > > > > > > > > > > > > > > > > > > > > > > > > > > Should have mentioned this is in src/bin/pg_dump/pg_dump.c > > > > > > > > > > > > > > > > Having a look on it. > > > > > > > > > > > > > Seems when qualify the schemaname the the "tbinfo->interesting" field > > > > is not setted for extensions objects, so the getTableAttrs can't fill > > > > the attgenerated field properly. > > > > > > > > I'm not 100% sure it's the correct way but the attached patch works > > > > for me and all tests passed. Maybe we should add more TAP tests? > > > > > > > > > > > > > > > > > I just tried this patch out on master, with the test case I gave > > > upthread. It's not working, still getting a segfault. > > > > > > > Ohh really sorry about it... my bad... i completely forgot about it!!! > > > > Due to my rush I ended up adding the wrong patch version. Attached the > > correct version. > > > > Will add TAP tests to src/test/modules/test_pg_dump > > > yeah, that's the fix I came up with too. The only thing I added was > "Assert(tbinfo->attgenerated);" at about line 2097. >
Cool. > > Will wait for your TAP tests. > Actually I've sent it already but it seems to have gone to the moderation queue. Anyway attached with your assertion and TAP tests. Regards, -- Fabrízio de Royes Mello Timbira - http://www.timbira.com.br/ PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index e758b5c50a..baacd7af63 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -2094,6 +2094,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); @@ -18037,6 +18039,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 ae120a5ee3..78aa07ce51 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 3ed007a7b1..90e461ed35 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;