CREATE OR REPLACE FUNCTION now validates it's dependents

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: CREATE OR REPLACE FUNCTION now validates it's dependents
Date: 2025-05-26 03:36:22
Message-ID: CACJufxE90w-dE98-HxGxYDviuh9gFYWai_ZHO-O1DhWSm8p2bQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
v1-0001-Ensure-CREATE-OR-REPLACE-FUNCTION-validates-its-dependent.patch text/x-patch 27.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-05-26 03:54:01 Re: CREATE OR REPLACE FUNCTION now validates it's dependents
Previous Message Fujii Masao 2025-05-26 03:32:45 Re: Add CHECK_FOR_INTERRUPTS in polling loop code path in XactLockTableWait