postgresql/src/include/utils
Andrew Dunstan 7dadd38cda json format for COPY TO
This introduces the JSON format option for the COPY TO command, allowing
users to export query results or table data directly as a stream of JSON
objects (one per line, NDJSON style).

The JSON format is currently supported only for COPY TO operations; it
is not available for COPY FROM.

JSON format is incompatible with some standard text/CSV formatting
options, including HEADER, DEFAULT, NULL, DELIMITER, FORCE QUOTE,
FORCE NOT NULL, and FORCE NULL.

Column list support is included: when a column list is specified, only
the named columns are emitted in each JSON object.

Regression tests covering valid JSON exports and error handling for
incompatible options have been added to src/test/regress/sql/copy.sql.

Author: Joe Conway <mail@joeconway.com>
Author: jian he <jian.universality@gmail.com>
Co-Authored-By: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Daniel Verite <daniel@manitou-mail.org>
Reviewed-by: Davin Shearer <davin@apache.org>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CALvfUkBxTYy5uWPFVwpk_7ii2zgT07t3d-yR_cy4sfrrLU%3Dkcg%40mail.gmail.com
Discussion: https://postgr.es/m/6a04628d-0d53-41d9-9e35-5a8dc302c34c@joeconway.com
2026-03-20 08:40:04 -04:00
..
.gitignore Fix build inconsistency due to the generation of wait-event code 2026-02-02 08:02:39 +09:00
acl.h Allow choosing specific grantors via GRANT/REVOKE ... GRANTED BY. 2026-03-19 11:41:39 -05:00
aclchk_internal.h Allow choosing specific grantors via GRANT/REVOKE ... GRANTED BY. 2026-03-19 11:41:39 -05:00
array.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
arrayaccess.h Refactor att_align_nominal() to improve performance. 2026-02-02 14:39:50 -05:00
ascii.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
attoptcache.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
backend_progress.h Introduce the REPACK command 2026-03-10 19:56:39 +01:00
backend_status.h Add backendType to PGPROC, replacing isRegularBackend 2026-02-04 13:06:04 +02:00
builtins.h Guard against unexpected dimensions of oidvector/int2vector. 2026-02-09 09:57:43 -05:00
bytea.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
cash.h Convert *GetDatum() and DatumGet*() macros to inline functions 2022-09-27 20:50:21 +02:00
catcache.h Clarify where various catcache.h dlist_nodes are used 2026-01-06 14:39:36 +13:00
combocid.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
conffiles.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
date.h Remove #include <math.h> where not needed 2026-01-15 19:09:47 +01:00
datetime.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
datum.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
dsa.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
elog.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
evtcache.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
expandeddatum.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
expandedrecord.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
float.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
fmgrtab.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
formatting.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
freepage.h Rename AssertVariableIsOfType to StaticAssertVariableIsOfType 2026-02-03 08:45:24 +01:00
funccache.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
geo_decls.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
guc.h ssl: Serverside SNI support for libpq 2026-03-18 12:37:11 +01:00
guc_hooks.h ssl: Serverside SNI support for libpq 2026-03-18 12:37:11 +01:00
guc_tables.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
help_config.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
hsearch.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
index_selfuncs.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
inet.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
injection_point.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
inval.h Switch SysCacheIdentifier to a typedef enum 2026-02-18 09:58:38 +09:00
json.h json format for COPY TO 2026-03-20 08:40:04 -04:00
jsonb.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
jsonfuncs.h make immutability tests in to_json and to_jsonb complete 2026-03-17 11:28:33 -04:00
jsonpath.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
logtape.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
lsyscache.h SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
memdebug.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
memutils.h Fix accidentally cast away qualifiers 2026-01-26 16:02:31 +01:00
memutils_internal.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
memutils_memorychunk.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
meson.build Fix build inconsistency due to the generation of wait-event code 2026-02-02 08:02:39 +09:00
multirangetypes.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
numeric.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
palloc.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
partcache.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_crc.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_locale.h Clean up ICU includes. 2026-01-06 17:19:51 -08:00
pg_locale_c.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_lsn.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_rusage.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pgstat_internal.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pgstat_kind.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pidfile.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
plancache.h Add some const qualifiers enabled by typeof_unqual change on copyObject 2026-03-19 06:35:54 +01:00
portal.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
ps_status.h Speedup and increase usability of set proc title functions 2023-02-20 16:18:27 +13:00
queryenvironment.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
rangetypes.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
regproc.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
rel.h Allow Boolean reloptions to have ternary values 2026-01-21 20:06:01 +01:00
relcache.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
relfilenumbermap.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
relmapper.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
relptr.h Rename AssertVariableIsOfType to StaticAssertVariableIsOfType 2026-02-03 08:45:24 +01:00
reltrigger.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
resowner.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
rls.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
ruleutils.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sampling.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
selfuncs.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sharedtuplestore.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
skipsupport.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
snapmgr.h Fix bug due to confusion about what IsMVCCSnapshot means 2026-03-13 13:53:19 -04:00
snapshot.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sortsupport.h Perform radix sort on SortTuples with pass-by-value Datums 2026-02-14 13:50:06 +07:00
spccache.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
syscache.h Switch SysCacheIdentifier to a typedef enum 2026-02-18 09:58:38 +09:00
timeout.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
timestamp.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tuplesort.h Perform radix sort on SortTuples with pass-by-value Datums 2026-02-14 13:50:06 +07:00
tuplestore.h Improve hash join's handling of tuples with null join keys. 2026-03-19 15:21:36 -04:00
typcache.h Extend DomainHasConstraints() to optionally check constraint volatility 2026-03-12 18:04:16 -04:00
tzparser.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
usercontext.h Perform logical replication actions as the table owner. 2023-04-04 11:25:23 -04:00
uuid.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
varbit.h Improve type handling of varlena structures 2026-02-11 07:33:24 +09:00
varlena.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
wait_classes.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
wait_event.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
xid8.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
xml.h Improve type handling of varlena structures 2026-02-11 07:33:24 +09:00