From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | Amul Sul <sulamul(at)gmail(dot)com> |
Cc: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Joel Jacobson <joel(at)compiler(dot)org>, Alexandra Wang <alexandra(dot)wang(dot)oss(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Suraj Kharage <suraj(dot)kharage(at)enterprisedb(dot)com> |
Subject: | Re: NOT ENFORCED constraint feature |
Date: | 2025-03-27 12:58:26 |
Message-ID: | fa4e0175-67a3-416e-9c2f-78454e50063d@eisentraut.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 25.03.25 17:48, Peter Eisentraut wrote:
> I have committed patches 0001 through 0003. I made some small changes:
> I will work through the remaining patches. It looks good to me so far.
For the time being, here are the remaining patches rebased.
I think you could squash these together at this point. This is
especially useful since 0003 overwrites part of the changes in 0002, so
it's better to see them all together.
Some details:
In CloneFkReferenced() and also in DetachPartitionFinalize(), you have
this change:
- fkconstraint->initially_valid = true;
+ fkconstraint->initially_valid = constrForm->convalidated;
I'm having a hard time understanding this. Is this an pre-existing
problem? What does this change do?
Most of the other stuff is mechanical and fits into existing structures,
so it seems ok.
Small cosmetic suggestion: write count(*) instead of count(1). This
fits better with existing practices.
The merge rules for inheritance and partitioning are still confusing. I
don't understand the behavior inh_check_constraint10 in the inherit.sql
test:
+-- the invalid state of the child constraint will be ignored here.
+alter table p1 add constraint inh_check_constraint10 check (f1 < 10)
not enforced;
+alter table p1_c1 add constraint inh_check_constraint10 check (f1 < 10)
not valid enforced;
Why is that correct? At least we should explain it here, or somewhere.
I'm also confused about the changes of the constraint names in the
foreign_key.sql test:
-ERROR: insert or update on table "fk_partitioned_fk_2" violates
foreign key constraint "fk_partitioned_fk_a_b_fkey"
+ERROR: insert or update on table "fk_partitioned_fk_2" violates
foreign key constraint "fk_partitioned_fk_2_a_b_fkey"
And then patch 0003 changes it again. This seems pretty random. We
should make sure that tests don't contain unrelated changes like that.
(Or at least it's not clear why they are related.)
There is also in 0002
+-- should be having two constraints
and then in 0003:
--- should be having two constraints
+-- should only have one constraint
So another reason for squashing these together, so we don't have
confusing intermediate states.
That said, is there a simpler way? Patch 0003 appears to add a lot of
complexity. Could we make this simpler by saying, if you have otherwise
matching constraints with different enforceability, make this an error.
Then users can themselves adjust the enforceability how they want to
make it match.
Attachment | Content-Type | Size |
---|---|---|
v18.1-0001-Remove-hastriggers-flag-check-before-fetching-.patch | text/plain | 11.0 KB |
v18.1-0002-Add-support-for-NOT-ENFORCED-in-foreign-key-co.patch | text/plain | 67.0 KB |
v18.1-0003-Merge-the-parent-and-child-constraints-with-di.patch | text/plain | 27.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Jakub Wartak | 2025-03-27 13:02:03 | Re: Draft for basic NUMA observability |
Previous Message | Tomas Vondra | 2025-03-27 12:56:08 | Re: Improve monitoring of shared memory allocations |