Re: COPY WHERE clause generated/system column reference
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Kirill Reshke <reshkekirill@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-10-28T05:28:55Z
Lists: pgsql-hackers
On Tue, Oct 28, 2025 at 2:02 AM Kirill Reshke <reshkekirill@gmail.com> wrote:
>
> Small comment: in 0002:
>
> > + if (has_stored_generated)
> > + ExecComputeStoredGenerated(resultRelInfo, estate, myslot,
> > + CMD_INSERT);
>
> Should we use CMD_UTILITY here? Comment in nodes.h suggests so. Also,
> ExecComputeStoredGenerated only check for equality with CMD_UPDATE, so
> this is just a cosmetic change.
>
hi.
use CMD_UTILITY will also work as expected.
ExecComputeStoredGenerated expects the command type (cmdtype) to be either
UPDATE or INSERT.
in ExecComputeStoredGenerated, we have:
if (cmdtype == CMD_UPDATE)
else
{
if (resultRelInfo->ri_GeneratedExprsI == NULL)
ExecInitGenerated(resultRelInfo, estate, cmdtype);
/* Early exit is impossible given the prior Assert */
Assert(resultRelInfo->ri_NumGeneratedNeededI > 0);
ri_GeneratedExprs = resultRelInfo->ri_GeneratedExprsI;
}
in struct ResultRelInfo also has comments like:
/*
* Arrays of stored generated columns ExprStates for INSERT/UPDATE/MERGE.
*/
ExprState **ri_GeneratedExprsI;
ExprState **ri_GeneratedExprsU;
I think using CMD_INSERT should be fine. Also, note that below
ExecComputeStoredGenerated uses CMD_INSERT too.
Commits
-
Disallow generated columns in COPY WHERE clause
- 3717849e622d 13.23 landed
- ccfe28eb4237 14.20 landed
- 8278737bfd0a 15.15 landed
- 26958f4d99b1 16.11 landed
- 07f787e57399 17.7 landed
- 0f9e0068bc62 18.1 landed
- aa606b9316a3 19 (unreleased) landed
-
Tighten check for generated column in partition key expression
- ba99c9491c44 18.1 cited