pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: why generated columsn cannot be used in COPY TO?
Date: Fri, 6 Oct 2023 08:16:35 -0500
Message-ID: <2fc8c4ab-4ecc-2adb-4236-3142fde13bde@gmail.com> (raw)
In-Reply-To: <3183166f-ff95-7ca3-48fe-8e87827bf202@a-kretschmer.de>
References: <CAKoxK+5=P6wJw=_UrzAQOBnGiHuq3kaXuPxuFh9_hTQc4nv89Q@mail.gmail.com>
	<3183166f-ff95-7ca3-48fe-8e87827bf202@a-kretschmer.de>

On 10/6/23 07:20, Andreas Kretschmer wrote:
>
>
> Am 06.10.23 um 13:53 schrieb Luca Ferrari:
>> Hi all,
>> 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?
>>
>> Example:
>>
>> testdb=# CREATE TABLE test( pk int generated always as identity primary key
>> , ts timestamp default current_timestamp
>> , month int generated always as ( extract( month from ts ) ) stored
>> );
>>
>> testdb=# insert into test( ts ) values( current_timestamp );
>>
>> testdb=# copy test to program 'head'; -- ok but silently removes the column
>> COPY 1
>> testdb=# copy test( month ) to program 'head';
>> ERROR:  column "month" is a generated column
>> DETAIL:  Generated columns cannot be used in COPY.
>
> you can use copy (select * ...) to ...

But why not?

-- 
Born in Arizona, moved to Babylonia.





view thread (14+ messages)  latest in thread

Message-ID: <2fc8c4ab-4ecc-2adb-4236-3142fde13bde@gmail.com>
Permalink:  ../2fc8c4ab-4ecc-2adb-4236-3142fde13bde@gmail.com/
Also on:    postgresql.org/message-id/2fc8c4ab-4ecc-2adb-4236-3142fde13bde@gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: why generated columsn cannot be used in COPY TO?
  In-Reply-To: <2fc8c4ab-4ecc-2adb-4236-3142fde13bde@gmail.com>
  References: <CAKoxK+5=P6wJw=_UrzAQOBnGiHuq3kaXuPxuFh9_hTQc4nv89Q@mail.gmail.com> <3183166f-ff95-7ca3-48fe-8e87827bf202@a-kretschmer.de> <2fc8c4ab-4ecc-2adb-4236-3142fde13bde@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox