diff options
| author | Robert Haas | 2015-12-16 12:43:56 +0000 |
|---|---|---|
| committer | Robert Haas | 2015-12-16 12:43:56 +0000 |
| commit | f27a6b15e6566fba7748d0d9a3fc5bcfd52c4a1b (patch) | |
| tree | 8fbfe141a6684f3517078414fb007b496d007be3 /src/test | |
| parent | 0625dbb0b96e2ecd557eb5bcdc458679123951db (diff) | |
Mark CHECK constraints declared NOT VALID valid if created with table.
FOREIGN KEY constraints have behaved this way for a long time, but for
some reason the behavior of CHECK constraints has been inconsistent up
until now.
Amit Langote and Amul Sul, with assorted tweaks by me.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/alter_table.out | 11 | ||||
| -rw-r--r-- | src/test/regress/sql/alter_table.sql | 5 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 61669b6c7f1..228ae6ec221 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -380,7 +380,16 @@ DROP TABLE tmp2; -- NOT VALID with plan invalidation -- ensure we don't use a constraint for -- exclusion until validated set constraint_exclusion TO 'partition'; -create table nv_parent (d date); +create table nv_parent (d date, check (false) no inherit not valid); +-- not valid constraint added at creation time should automatically become valid +\d nv_parent + Table "public.nv_parent" + Column | Type | Modifiers +--------+------+----------- + d | date | +Check constraints: + "nv_parent_check" CHECK (false) NO INHERIT + create table nv_child_2010 () inherits (nv_parent); create table nv_child_2011 () inherits (nv_parent); alter table nv_child_2010 add check (d between '2010-01-01'::date and '2010-12-31'::date) not valid; diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index c0bb77ee221..3db34609733 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -327,7 +327,10 @@ DROP TABLE tmp2; -- NOT VALID with plan invalidation -- ensure we don't use a constraint for -- exclusion until validated set constraint_exclusion TO 'partition'; -create table nv_parent (d date); +create table nv_parent (d date, check (false) no inherit not valid); +-- not valid constraint added at creation time should automatically become valid +\d nv_parent + create table nv_child_2010 () inherits (nv_parent); create table nv_child_2011 () inherits (nv_parent); alter table nv_child_2010 add check (d between '2010-01-01'::date and '2010-12-31'::date) not valid; |
