CREATE OR REPLACE FUNCTION now validates it's dependents - Mailing list pgsql-hackers

From jian he
Subject CREATE OR REPLACE FUNCTION now validates it's dependents
Date
Msg-id CACJufxE90w-dE98-HxGxYDviuh9gFYWai_ZHO-O1DhWSm8p2bQ@mail.gmail.com
Whole thread Raw
Responses Re: CREATE OR REPLACE FUNCTION now validates it's dependents
List pgsql-hackers
hi.

The attached patch allows CREATE OR REPLACE FUNCTION to correctly update domain
constraints when the function they depend on is changed.

so this thread[1] mentioned the problem can be resolved.
for example:

create function sqlcheck(int) returns bool as 'select $1 > 0' language sql;
create domain checkedint as int check(sqlcheck(value));
select 0::checkedint;  -- fail
ERROR:  value for domain checkedint violates check constraint "checkedint_check"
create or replace function sqlcheck(int) returns bool as 'select $1 <=
0' language sql;
select 1::checkedint;  -- fail?

the last query won't fail on the master. with the patch it will fail.

I also make CREATE OR REPLACE FUNCTION validate each domain value when
the domain constraint conditions is associated the function we are
gonname changes
Of course, this will make CREATE OR REPLACE FUNCTION  take way longer time
compared to the current.



Similar to domain constraints, attached patch also apply to table
check constraints too.
Is this what we want to do?

[1]: https://postgr.es/m/12539.1544107316%40sss.pgh.pa.us

Attachment

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Add CHECK_FOR_INTERRUPTS in polling loop code path in XactLockTableWait
Next
From: Tom Lane
Date:
Subject: Re: CREATE OR REPLACE FUNCTION now validates it's dependents