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

Commit09d09d4

Browse files
committed
Fix pg_get_constraintdef for NOT NULL constraints on domains
We added pg_constraint rows for all not-null constraints, first fortables and later for domains; but while the ones for tables werereverted, the ones for domains were not. However, we did accidentallyrevert ruleutils.c support for the ones on domains in6f8bb7c,which breaks running pg_get_constraintdef() on them. Put that back.This is only needed in branch 17, because we've reinstated this code inbranch master with commit14e87ff. Add some new tests in bothbranches.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 parent0d884f5 commit09d09d4

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 domnotnullset col1=null;
431431

432+
update domnotnullset col1=5;
433+
434+
-- these constraints can also be added and removed by name
435+
alterdomain dnotnulltest addconstraint dnotnulltest_notnullnot null;
436+
update domnotnullset col1=null;-- fails
437+
select conname, pg_get_constraintdef(oid)from pg_constraint
438+
where contypid='dnotnulltest'::regtype;
439+
440+
alterdomain dnotnulltest dropconstraint dnotnulltest_notnull;
441+
update domnotnullset col1=null;
442+
432443
dropdomain dnotnulltest cascade;
433444

434445
-- Test ALTER DOMAIN .. DEFAULT ..

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp