| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
| Cc: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Fix bug of CHECK constraint enforceability recursion |
| Date: | 2026-06-08 10:28:55 |
| Message-ID: | CACJufxE2B6nrfV9inubVifY-8Y6hObBAtyXHEAtPLA6JATXjgA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sat, Jun 6, 2026 at 11:06 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> PFA v8: 0001 and 0003 unchanged. 0002 addressed Zsolt’s comment.
>
drop table root_t cascade;
create table root_t (a int constraint c check (a > 0) enforced);
create table p2 (a int constraint c check (a > 0) enforced);
create table d () inherits (root_t, p2);
create table e () inherits (d);
CREATE OR REPLACE PROCEDURE create_table(i int) AS $$
DECLARE
r int;
query text;
BEGIN
FOR i IN 20..$1 LOOP
query := 'create table f' || i || '() inherits (e)';
raise notice 'query: %', query;
EXECUTE query;
END LOOP;
END; $$ LANGUAGE plpgsql;
call create_table(1000);
alter table root_t alter constraint c not enforced;
ATCheckCheckConstrHasEnforcedParent invoked 996070 times
ATCheckCheckConstrHasEnforcedParent will call itself, so I think we
need check_stack_depth() on it.
I also made a minor refactoring to reduce unnecessary work in
ATCheckCheckConstrHasEnforcedParent().
A single call to table_open(parentoid, ...) is enough.
Keep errmsg() messages on a single line to improve grepability.
| Attachment | Content-Type | Size |
|---|---|---|
| v8-0001-Minor-refactoring-for-v8.nocfbot | application/octet-stream | 2.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nazir Bilal Yavuz | 2026-06-08 10:30:03 | Re: ci: CCache churns through available space too quickly |
| Previous Message | Amit Kapila | 2026-06-08 09:51:44 | Re: synchronized_standby_slots behavior inconsistent with quorum-based synchronous replication |