public inbox for [email protected]
help / color / mirror / Atom feedFrom: Paul A Jungwirth <[email protected]>
To: jian he <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Chao Li <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: SQL:2011 Application Time Update & Delete
Date: Wed, 15 Apr 2026 14:59:21 -0700
Message-ID: <CA+renyV6_xRwrDGBiNj79oCPfMqOoAqDQg7b=EerEpq0HHmb4Q@mail.gmail.com> (raw)
In-Reply-To: <CACJufxHALFKca5SMn5DNnbrX2trPamVL6napn_nm35p15yw+rg@mail.gmail.com>
References: <[email protected]>
<[email protected]>
<CA+renyXH3AF6JVzZGVcT5mAo=0QncB-MpWJeqb2JG66sgyq09g@mail.gmail.com>
<[email protected]>
<CA+renyUazgR-hB_6RY60n23L0y-n_h9G1AappZmPENO0k5pL1g@mail.gmail.com>
<[email protected]>
<CA+renyVXg5pV84wQnGQuK8-=qoKw3BiBgQzesxM_LkcxxWmYjA@mail.gmail.com>
<[email protected]>
<CA+renyWKOj5=rMmQmJcbybu-Vdomxdp=eJ93kp76AgmQKYdfiQ@mail.gmail.com>
<[email protected]>
<CA+renyUhuXB2nTVCMREXew9E4DZOnFxQNjME5bcw91+k72Bosg@mail.gmail.com>
<CA+renyWUCSyTMn3s03kviEN-oaVrJP-QkDQCLNfaY=MHV5QEiQ@mail.gmail.com>
<CA+renyV4tWU2d=n9_v=XNPHbZfNqqLokzd-Xt78M-zLd+46ubA@mail.gmail.com>
<[email protected]>
<CA+renyUSgqXpjj+vV7w+wirPB49VQFrmPjVT_s04JmZSOPNNsQ@mail.gmail.com>
<[email protected]>
<CA+renyX-eV+2hFUaZg3BSREqLE7dh+LoWm7ZqhFAiGsirjjtRQ@mail.gmail.com>
<CACJufxHALFKca5SMn5DNnbrX2trPamVL6napn_nm35p15yw+rg@mail.gmail.com>
On Mon, Apr 6, 2026 at 9:04 PM jian he <[email protected]> wrote:
>
> As you can see, ExecGetAllUpdatedCols does not account for the valid_at column,
> even though it is actively being updated. ExecGetAllUpdatedCols is being used
> serval places, IMHO, we need to add some comments on
> ExecGetAllUpdatedCols explaining
> this behavior and maybe add some regression tests.
>
> I'm not sure if it's safe for ExecGetAllUpdatedCols to ignore the FOR
> PORTION OF column.
The other threads have found a couple problems with that now. I wonder
if we should have ExecGetExtraUpdatedCols add the application-time
attno to the returned bitmapset? Or even add it to updatedCols in
analysis and then ignore it for permission checking. That seems more
robust than finding all the places we need to add it, except
updatedCols is in a struct called RTEPermissionInfo. Best of all I
think would be to add a new bitmapset somewhere else and not use
permissions infrastructure for GENERATED columns, UPDATE OF triggers,
skipping CHECK constraints, etc. But is it too late in the cycle to
make a change like that?
In the short term, what about just doing this?:
@@ -1449,6 +1449,7 @@ ExecGetAllUpdatedCols(ResultRelInfo *relinfo,
EState *estate)
oldcxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
ret = bms_union(ExecGetUpdatedCols(relinfo, estate),
+ ExecGetForPortionOfCol(relinfo, estate),
ExecGetExtraUpdatedCols(relinfo, estate));
MemoryContextSwitchTo(oldcxt);
(Implementing that function is left as an exercise for the reader.)
> transformForPortionOfClause
> if (contain_volatile_functions_after_planning((Expr *) result->targetRange))
> ereport(ERROR,
> (errmsg("FOR PORTION OF bounds cannot contain volatile
> functions")));
>
> Need
> errcode(ERRCODE_FEATURE_NOT_SUPPORTED).
Okay.
> coerce_to_target_type function comment:
> * This is the general-purpose entry point for arbitrary type coercion
> * operations. Direct use of the component operations can_coerce_type,
> * coerce_type, and coerce_type_typmod should be restricted to special
> * cases (eg, when the conversion is expected to succeed).
>
> We should use coerce_to_target_type more, not can_coerce_type,
> coerce_type individually.
> coerce_to_target_type also handles `UNKNOWN` constant, which ensures
> the deparsing casts to the correct data type.
Including the casts when we deparse does seem like an improvement.
The patch looks good to me.
Yours,
--
Paul ~{:-)
[email protected]
view thread (54+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: SQL:2011 Application Time Update & Delete
In-Reply-To: <CA+renyV6_xRwrDGBiNj79oCPfMqOoAqDQg7b=EerEpq0HHmb4Q@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox