From: | Paul Jungwirth <pj(at)illuminatedcomputing(dot)com> |
---|---|
To: | Peter Eisentraut <peter(at)eisentraut(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: SQL:2011 application time |
Date: | 2024-03-22 00:35:53 |
Message-ID: | a5d8df78-9ff6-4273-8d06-6c85b5520520@illuminatedcomputing.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
v32 attached.
On 3/21/24 07:57, Peter Eisentraut wrote:
> Two more questions:
>
> 1. In ri_triggers.c ri_KeysEqual, you swap the order of arguments to ri_AttributesEqual():
>
> - if (!ri_AttributesEqual(riinfo->ff_eq_oprs[i], RIAttType(rel, attnums[i]),
> - oldvalue, newvalue))
> + if (!ri_AttributesEqual(eq_opr, RIAttType(rel, attnums[i]),
> + newvalue, oldvalue))
>
> But the declared arguments of ri_AttributesEqual() are oldvalue and newvalue, so passing them
> backwards is really confusing. And the change does matter in the tests.
>
> Can we organize this better?
I renamed the params and actually the whole function. All it's doing is execute `oldvalue op
newvalue`, casting if necessary. So I changed it to ri_CompareWithCast and added some documentation.
In an earlier version of this patch I had a separate function for the PERIOD comparison, but it's
just doing the same thing, so I think the best thing is to give the function a more accurate name
and use it.
> 2. There are some tests that error with
>
> ERROR: only b-tree indexes are supported for non-PERIOD foreign keys
>
> But this is an elog() error, so should not normally be visible. I suspect some other error should
> really show here, and the order of checks is a bit wrong or something?
At first I thought I should just make this ereport, because it is reachable now, but I didn't like
the error message or where we were reaching it. The high-level problem is defining a non-temporal FK
against a temporal PK, and we should check for that in those terms, not when looking at individual
attribute opclasses. So I added a check prior to this and gave it a more descriptive error message.
On 3/21/24 01:25, jian he wrote:
> with foreign key "no action",
> in a transaction, we can first insert foreign key data, then primary key data.
> also the update/delete can fail at the end of transaction.
>
> based on [1] explanation about the difference between "no action" and
> "restrict".
> I only refactor the v31-0002-Support-multiranges-in-temporal-FKs.patch test.
I added some tests for deferred NO ACTION checks. I added them for all of range/multirange/PERIOD. I
also adopted your change ALTERing the constraint for NO ACTION (even though it's already that), to
make each test section more independent. Your patch had a lot of other noisy changes, e.g.
whitespace and reordering lines. If there are other things you intended to add to the tests, can you
describe them?
Rebased to 7e65ad197f.
Yours,
--
Paul ~{:-)
pj(at)illuminatedcomputing(dot)com
Attachment | Content-Type | Size |
---|---|---|
v32-0001-Add-temporal-FOREIGN-KEYs.patch | text/x-patch | 122.7 KB |
v32-0002-Support-multiranges-in-temporal-FKs.patch | text/x-patch | 51.3 KB |
v32-0003-Add-support-funcs-for-FOR-PORTION-OF.patch | text/x-patch | 43.0 KB |
v32-0004-Add-UPDATE-DELETE-FOR-PORTION-OF.patch | text/x-patch | 160.6 KB |
v32-0005-Add-CASCADE-SET-NULL-SET-DEFAULT-for-temporal-fo.patch | text/x-patch | 200.9 KB |
v32-0006-Add-PERIODs.patch | text/x-patch | 282.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-03-22 00:46:52 | Re: Catalog domain not-null constraints |
Previous Message | Peter Geoghegan | 2024-03-22 00:32:42 | Re: Optimizing nbtree ScalarArrayOp execution, allowing multi-column ordered scans, skip scan |