diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-09 23:32:05 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-09 23:32:05 +0000 |
commit | cd902b331dc4b0c170e800441a98f9213d98b46b (patch) | |
tree | bef3eacf7ff474dd0fb96b368e80137f73658d52 /src/test/regress/sql/alter_table.sql | |
parent | f8df836ae396be28a6c9e4f79a6adf3e5c0187b5 (diff) | |
download | postgresql-cd902b331dc4b0c170e800441a98f9213d98b46b.tar.gz postgresql-cd902b331dc4b0c170e800441a98f9213d98b46b.zip |
Change the rules for inherited CHECK constraints to be essentially the same
as those for inherited columns; that is, it's no longer allowed for a child
table to not have a check constraint matching one that exists on a parent.
This satisfies the principle of least surprise (rows selected from the parent
will always appear to meet its check constraints) and eliminates some
longstanding bogosity in pg_dump, which formerly had to guess about whether
check constraints were really inherited or not.
The implementation involves adding conislocal and coninhcount columns to
pg_constraint (paralleling attislocal and attinhcount in pg_attribute)
and refactoring various ALTER TABLE actions to be more like those for
columns.
Alex Hunsaker, Nikhil Sontakke, Tom Lane
Diffstat (limited to 'src/test/regress/sql/alter_table.sql')
-rw-r--r-- | src/test/regress/sql/alter_table.sql | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 81cc70612d5..46aacd1bef8 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -389,19 +389,20 @@ select test2 from atacc2; drop table atacc2 cascade; drop table atacc1; --- let's try only to add only to the parent +-- adding only to a parent is disallowed as of 8.4 create table atacc1 (test int); -create table atacc2 (test2 int); -create table atacc3 (test3 int) inherits (atacc1, atacc2); -alter table only atacc2 add constraint foo check (test2>0); --- fail and then succeed on atacc2 -insert into atacc2 (test2) values (-3); -insert into atacc2 (test2) values (3); --- both succeed on atacc3 -insert into atacc3 (test2) values (-3); -insert into atacc3 (test2) values (3); -drop table atacc3; +create table atacc2 (test2 int) inherits (atacc1); +-- fail: +alter table only atacc1 add constraint foo check (test>0); +-- ok: +alter table only atacc2 add constraint foo check (test>0); +-- check constraint not there on parent +insert into atacc1 (test) values (-3); +insert into atacc1 (test) values (3); +-- check constraint is there on child +insert into atacc2 (test) values (-3); +insert into atacc2 (test) values (3); drop table atacc2; drop table atacc1; |