Re: COPY WHERE clause generated/system column reference - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: COPY WHERE clause generated/system column reference
Date
Msg-id dcd6bab8-6c02-41ac-879f-ad54987ff506@eisentraut.org
Whole thread Raw
In response to Re: COPY WHERE clause generated/system column reference  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers
On 05.11.25 19:19, Masahiko Sawada wrote:
>> Attached is my proposed patch.  I kept it similar to the recently
>> committed fix in commit ba99c9491c4.  Note that we also need to consider
>> whole-row references, as that patch did.
> 
> Here are some minor comments for the proposed patch:
> 
> +                   ereport(ERROR,
> +                           errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> +                           errmsg("generated columns are not
> supported in COPY FROM WHERE conditions"),
> +                           errdetail("Column \"%s\" is a generated column.",
> +
> get_attname(RelationGetRelid(rel), attno, false)));
> 
> How about using ERRCODE_INVALID_COLUMN_REFERENCE instead? It's more
> consistent with other places where we check the column references.
> 
> ---
> --- a/src/test/regress/sql/copy2.sql
> +++ b/src/test/regress/sql/copy2.sql
> @@ -161,7 +161,6 @@ COPY x from stdin WHERE a IN (generate_series(1,5));
> 
>   COPY x from stdin WHERE a = row_number() over(b);
> 
> -
>   -- check results of copy in
>   SELECT * FROM x;
> 
> Unnecessary line removal.
> 
> The rest looks good to me.

Thanks.  I have committed it with these corrections.




pgsql-hackers by date:

Previous
From: "Euler Taveira"
Date:
Subject: Re: log_min_messages per backend type
Next
From: Thomas Munro
Date:
Subject: Re: [PATCH] O_CLOEXEC not honored on Windows - handle inheritance chain