Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qolBN-002lXB-GT for pgsql-general@arkaria.postgresql.org; Fri, 06 Oct 2023 13:47:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qolBL-007Ohf-9y for pgsql-general@arkaria.postgresql.org; Fri, 06 Oct 2023 13:47:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qolBK-007OhL-VK for pgsql-general@lists.postgresql.org; Fri, 06 Oct 2023 13:47:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qolBJ-000Jym-7G for pgsql-general@lists.postgresql.org; Fri, 06 Oct 2023 13:47:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 396DlpoC2949798; Fri, 6 Oct 2023 09:47:51 -0400 From: Tom Lane To: Luca Ferrari cc: pgsql-general Subject: Re: why generated columsn cannot be used in COPY TO? In-reply-to: References: Comments: In-reply-to Luca Ferrari message dated "Fri, 06 Oct 2023 13:53:33 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2949796.1696600071.1@sss.pgh.pa.us> Date: Fri, 06 Oct 2023 09:47:51 -0400 Message-ID: <2949797.1696600071@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Luca Ferrari 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. 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. regards, tom lane