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

Commit 0eede96

Browse files
committed
pg_dump: fix failure to dump comments on constraints in some cases.
Thinko in commit 5209c0b: I checked the wrong object's DUMP_COMPONENT_COMMENT bit in two places. Per bug #17675 from Franz-Josef Färber. Discussion: https://postgr.es/m/17675-c69c001e06390867@postgresql.org
1 parent d5e1748 commit 0eede96

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10986,7 +10986,7 @@ dumpDomain(Archive *fout, const TypeInfo *tyinfo)
1098610986
appendPQExpBuffer(conprefix, "CONSTRAINT %s ON DOMAIN",
1098710987
fmtId(domcheck->dobj.name));
1098810988

10989-
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
10989+
if (domcheck->dobj.dump & DUMP_COMPONENT_COMMENT)
1099010990
dumpComment(fout, conprefix->data, qtypname,
1099110991
tyinfo->dobj.namespace->dobj.name,
1099210992
tyinfo->rolname,
@@ -15865,7 +15865,7 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
1586515865
if (constr->separate || !constr->conislocal)
1586615866
continue;
1586715867

15868-
if (tbinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
15868+
if (constr->dobj.dump & DUMP_COMPONENT_COMMENT)
1586915869
dumpTableConstraintComment(fout, constr);
1587015870
}
1587115871

src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,13 +1690,16 @@
16901690
COLLATE "C"
16911691
DEFAULT \'10014\'
16921692
CHECK(VALUE ~ \'^\d{5}$\' OR
1693-
VALUE ~ \'^\d{5}-\d{4}$\');',
1693+
VALUE ~ \'^\d{5}-\d{4}$\');
1694+
COMMENT ON CONSTRAINT us_postal_code_check
1695+
ON DOMAIN dump_test.us_postal_code IS \'check it\';',
16941696
regexp => qr/^
16951697
\QCREATE DOMAIN dump_test.us_postal_code AS text COLLATE pg_catalog."C" DEFAULT '10014'::text\E\n\s+
16961698
\QCONSTRAINT us_postal_code_check CHECK \E
16971699
\Q(((VALUE ~ '^\d{5}\E
16981700
\$\Q'::text) OR (VALUE ~ '^\d{5}-\d{4}\E\$
1699-
\Q'::text)));\E
1701+
\Q'::text)));\E(.|\n)*
1702+
\QCOMMENT ON CONSTRAINT us_postal_code_check ON DOMAIN dump_test.us_postal_code IS 'check it';\E
17001703
/xm,
17011704
like =>
17021705
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
@@ -2617,7 +2620,9 @@
26172620
col3 text,
26182621
col4 text,
26192622
CHECK (col1 <= 1000)
2620-
) WITH (autovacuum_enabled = false, fillfactor=80);',
2623+
) WITH (autovacuum_enabled = false, fillfactor=80);
2624+
COMMENT ON CONSTRAINT test_table_col1_check
2625+
ON dump_test.test_table IS \'bounds check\';',
26212626
regexp => qr/^
26222627
\QCREATE TABLE dump_test.test_table (\E\n
26232628
\s+\Qcol1 integer NOT NULL,\E\n
@@ -2626,7 +2631,9 @@
26262631
\s+\Qcol4 text,\E\n
26272632
\s+\QCONSTRAINT test_table_col1_check CHECK ((col1 <= 1000))\E\n
26282633
\Q)\E\n
2629-
\QWITH (autovacuum_enabled='false', fillfactor='80');\E\n/xm,
2634+
\QWITH (autovacuum_enabled='false', fillfactor='80');\E\n(.|\n)*
2635+
\QCOMMENT ON CONSTRAINT test_table_col1_check ON dump_test.test_table IS 'bounds check';\E
2636+
/xm,
26302637
like => {
26312638
%full_runs,
26322639
%dump_test_schema_runs,

0 commit comments

Comments
 (0)