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 <[email protected]> Reviewed-by: Jian He <[email protected]> Discussion: https://postgr.es/m/CAHg+QDcfpGDoPL3fvfjXRtfn=fny6ddjr6bay6tps1xj2ez...@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(-)
