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

Commit 09d09d4

Browse files
committed
Fix pg_get_constraintdef for NOT NULL constraints on domains
We added pg_constraint rows for all not-null constraints, first for tables and later for domains; but while the ones for tables were reverted, the ones for domains were not. However, we did accidentally revert ruleutils.c support for the ones on domains in 6f8bb7c, which breaks running pg_get_constraintdef() on them. Put that back. This is only needed in branch 17, because we've reinstated this code in branch master with commit 14e87ff. Add some new tests in both branches. I couldn't find anything else that needs de-reverting. Reported-by: Erki Eessaar <erki.eessaar@taltech.ee> Reviewed-by: Magnus Hagander <magnus@hagander.net> Discussion: https://postgr.es/m/AS8PR01MB75110350415AAB8BBABBA1ECFE222@AS8PR01MB7511.eurprd01.prod.exchangelabs.com
1 parent 0d884f5 commit 09d09d4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/test/regress/expected/domain.out

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,20 @@ update domnotnull set col1 = null; -- fails
743743
ERROR: domain dnotnulltest does not allow null values
744744
alter domain dnotnulltest drop not null;
745745
update domnotnull set col1 = null;
746+
update domnotnull set col1 = 5;
747+
-- these constraints can also be added and removed by name
748+
alter domain dnotnulltest add constraint dnotnulltest_notnull not null;
749+
update domnotnull set col1 = null; -- fails
750+
ERROR: domain dnotnulltest does not allow null values
751+
select conname, pg_get_constraintdef(oid) from pg_constraint
752+
where contypid = 'dnotnulltest'::regtype;
753+
conname | pg_get_constraintdef
754+
----------------------+----------------------
755+
dnotnulltest_notnull | NOT NULL
756+
(1 row)
757+
758+
alter domain dnotnulltest drop constraint dnotnulltest_notnull;
759+
update domnotnull set col1 = null;
746760
drop domain dnotnulltest cascade;
747761
NOTICE: drop cascades to 2 other objects
748762
DETAIL: drop cascades to column col2 of table domnotnull

src/test/regress/sql/domain.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,17 @@ alter domain dnotnulltest drop not null;
429429

430430
update domnotnull set col1 = null;
431431

432+
update domnotnull set col1 = 5;
433+
434+
-- these constraints can also be added and removed by name
435+
alter domain dnotnulltest add constraint dnotnulltest_notnull not null;
436+
update domnotnull set col1 = null; -- fails
437+
select conname, pg_get_constraintdef(oid) from pg_constraint
438+
where contypid = 'dnotnulltest'::regtype;
439+
440+
alter domain dnotnulltest drop constraint dnotnulltest_notnull;
441+
update domnotnull set col1 = null;
442+
432443
drop domain dnotnulltest cascade;
433444

434445
-- Test ALTER DOMAIN .. DEFAULT ..

0 commit comments

Comments
 (0)