agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Andrew Dunstan <andrew@dunslane.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix COPY TO FORMAT JSON to exclude generated columns.
Date: Wed, 15 Apr 2026 11:59:12 +0000
Message-ID: <E1wCytk-0015Dl-0V@gemulon.postgresql.org> (raw)
Fix COPY TO FORMAT JSON to exclude generated columns.
COPY TO with FORMAT json was including generated columns in the
output, unlike TEXT and CSV formats. Virtual generated columns
appeared as null, and stored ones showed their computed values.
The JSON code path only built a restricted TupleDesc when an explicit
column list was given (attnamelist != NIL), but CopyGetAttnums()
also excludes generated columns from the default list. Fix by
checking whether the attnumlist is shorter than the full TupleDesc
instead.
Bug introduced in 7dadd38cda9.
Author: Satya Narlapuram <satya.narlapuram@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDcfpGDoPL3fvfjXRtfn=fny6DdJR6BAy6TpS1Xj2EZfXA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f30d0c720f2ec979ab1b5b44b1f9f201d6efdf8c
Modified Files
--------------
src/backend/commands/copyto.c | 2 +-
src/test/regress/expected/generated_stored.out | 6 ++++++
src/test/regress/expected/generated_virtual.out | 6 ++++++
src/test/regress/sql/generated_stored.sql | 3 +++
src/test/regress/sql/generated_virtual.sql | 3 +++
5 files changed, 19 insertions(+), 1 deletion(-)
Message-ID: <E1wCytk-0015Dl-0V@gemulon.postgresql.org>
Permalink: ../E1wCytk-0015Dl-0V@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wCytk-0015Dl-0V@gemulon.postgresql.org
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: andrew@dunslane.net, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix COPY TO FORMAT JSON to exclude generated columns.
In-Reply-To: <E1wCytk-0015Dl-0V@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox