| From: | Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: SQL:2011 Application Time Update & Delete |
| Date: | 2026-04-15 21:59:21 |
| Message-ID: | CA+renyV6_xRwrDGBiNj79oCPfMqOoAqDQg7b=EerEpq0HHmb4Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Apr 6, 2026 at 9:04 PM jian he <jian(dot)universality(at)gmail(dot)com> 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 ~{:-)
pj(at)illuminatedcomputing(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Paul A Jungwirth | 2026-04-15 22:40:41 | Re: DELETE/UPDATE FOR PORTION OF with rule system is not working |
| Previous Message | Tristan Partin | 2026-04-15 21:36:35 | Re: Validate user-supplied c_args in meson builds |