Re: why generated columsn cannot be used in COPY TO?

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: why generated columsn cannot be used in COPY TO?
Date: 2023-10-06 15:45:58
Message-ID: 7f80a4a3-af51-6863-b72d-bee1118b8f79@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/6/23 09:04, Andreas Kretschmer wrote:
>
>
> Am 06.10.23 um 15:47 schrieb Tom Lane:
>> Luca Ferrari <fluca1978(at)gmail(dot)com> writes:
>>> I'm wondering why in COPY TO (file or program) I cannot use generated
>>> columns: since I'm pushing data out of the table, why they are not
>>> allowed?
>> There's a comment about that in copy.c:
>>
>>   * We don't include generated columns in the generated full list and we
>> don't
>>   * allow them to be specified explicitly.  They don't make sense for COPY
>>   * FROM, but we could possibly allow them for COPY TO.  But this way
>> it's at
>>   * least ensured that whatever we copy out can be copied back in.
>
> ha, as always: read the source ;-)
>
>>
>> Not sure how convincing that reasoning is, but it was at least
>> thought about.  I do agree with it as far as the default column
>> list goes, but maybe we could allow explicit selection of these
>> columns in COPY TO.
>
> sounds okay

Nah.  "The programmer -- and DBA -- on the Clapham omnibus" quite reasonably
expects that COPY table_name TO (output)" copies all the columns listed in
"\d table_name".

https://en.wikipedia.org/wiki/Man_on_the_Clapham_omnibus
"The man on the Clapham omnibus is a hypothetical ordinary and reasonable
person, used by the courts in English law where it is necessary to decide
whether a party has acted as a *reasonable person* would – for example, in a
civil action for negligence. The character is a *reasonably educated,
intelligent but nondescript person*, against whom the defendant's conduct
can be measured."

--
Born in Arizona, moved to Babylonia.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2023-10-06 15:53:28 Re: why generated columsn cannot be used in COPY TO?
Previous Message Dominique Devienne 2023-10-06 15:06:43 Re: why generated columsn cannot be used in COPY TO?