Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ea47e8

Browse files
committed
Fix pg_dump to handle inherited NOT VALID check constraints correctly.
This case seems to have been overlooked when unvalidated check constraintswere introduced, in 9.2. The code would attempt to dump such constraintsover again for each child table, even though adding them to the parenttable is sufficient.In 9.2 and 9.3, also fix contrib/pg_upgrade/Makefile so that the "makeclean" target fully cleans up after a failed test. This evidently gotdealt with at some point in 9.4, but it wasn't back-patched. I ran intoit while testing this fix ...Per bug #13656 from Ingmar Brouns.
1 parenta742ef8 commit5ea47e8

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14713,8 +14713,8 @@ dumpConstraint(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo)
1471314713
{
1471414714
/* CHECK constraint on a table */
1471514715

14716-
/* Ignore if not to be dumped separately */
14717-
if (coninfo->separate)
14716+
/* Ignore if not to be dumped separately, or if it was inherited */
14717+
if (coninfo->separate&&coninfo->conislocal)
1471814718
{
1471914719
/* not ONLY since we want it to propagate to children */
1472014720
appendPQExpBuffer(q,"ALTER TABLE %s\n",

‎src/test/regress/expected/alter_table.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,19 @@ explain (costs off) select * from nv_parent where d between '2009-08-01'::date a
438438
Filter: ((d >= '08-01-2009'::date) AND (d <= '08-31-2009'::date))
439439
(7 rows)
440440

441+
-- add an inherited NOT VALID constraint
442+
alter table nv_parent add check (d between '2001-01-01'::date and '2099-12-31'::date) not valid;
443+
\d nv_child_2009
444+
Table "public.nv_child_2009"
445+
Column | Type | Modifiers
446+
--------+------+-----------
447+
d | date |
448+
Check constraints:
449+
"nv_child_2009_d_check" CHECK (d >= '01-01-2009'::date AND d <= '12-31-2009'::date)
450+
"nv_parent_d_check" CHECK (d >= '01-01-2001'::date AND d <= '12-31-2099'::date) NOT VALID
451+
Inherits: nv_parent
452+
453+
-- we leave nv_parent and children around to help test pg_dump logic
441454
-- Foreign key adding test with mixed types
442455
-- Note: these tables are TEMP to avoid name conflicts when this test
443456
-- is run in parallel with foreign_key.sql.

‎src/test/regress/sql/alter_table.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ explain (costs off) select * from nv_parent where d between '2009-08-01'::date a
340340
altertable nv_child_2011 VALIDATECONSTRAINT nv_child_2011_d_check;
341341
explain (costs off)select*from nv_parentwhere d between'2009-08-01'::dateand'2009-08-31'::date;
342342

343+
-- add an inherited NOT VALID constraint
344+
altertable nv_parent addcheck (d between'2001-01-01'::dateand'2099-12-31'::date) not valid;
345+
\d nv_child_2009
346+
-- we leave nv_parent and children around to help test pg_dump logic
343347

344348
-- Foreign key adding test with mixed types
345349

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp