Re: SQL:2011 application time

From: Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: Sam Gabrielsson <sam(at)movsom(dot)se>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: SQL:2011 application time
Date: 2024-11-14 17:31:40
Message-ID: 78b43581-35f6-4478-8d8a-98e66a763e74@illuminatedcomputing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Just sharing my progress here since it's been a week:

On 11/6/24 17:03, Paul Jungwirth wrote:
> On 11/4/24 13:16, Sam Gabrielsson wrote:
>> Foreign key violation errors are incorrectly raised in a few cases for a temporal foreign key with
>> default ON UPDATE NO ACTION. Test is based on the commited v39 patches (used a snapshot version of
>> PG18 devel available from PGDG).
>
> Thank you for the report! I confirmed that this is a problem. In ri_restrict we fail if any fk
> records still match the being-changed pk, but for temporal if you're merely shrinking the pk range,
> fk references could still wind up being valid (if you're only shrinking it a little). So we need to
> do more work.

I'm nearly done with a patch for this. I'll try to wrap it up today and get it sent this evening.

> IIRC for RESTRICT it is *correct* to reject the change, so we would want to keep the old SQL there,
> and only update it for NOACTION.

I realized there are problems with the RESTRICT case also. I've got a fix written for that too, but
it needs some tidying up. I'll submit both patches together.

The RESTRICT case needs to find the *lost* time span(s) (because it might not be the whole thing)
and check for references to those. To do that, it calls our without_portion support function. That
function was intended to support FOR PORTION OF, but it happens to be exactly what we need here. So
I'm reordering the patches a bit and adjusting the documentation there.

Yours,

--
Paul ~{:-)
pj(at)illuminatedcomputing(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2024-11-14 17:45:32 Re: [PoC] Federated Authn/z with OAUTHBEARER
Previous Message Paul Jungwirth 2024-11-14 17:25:15 Re: SQL:2011 application time