diff options
author | Peter Eisentraut | 2022-01-28 08:22:53 +0000 |
---|---|---|
committer | Peter Eisentraut | 2022-01-28 08:44:47 +0000 |
commit | 43f33dc018a4b77ced78a0a6df8ed5d450cfe5f4 (patch) | |
tree | f372e2f7e3f37ee968c08f6cc6220b6657f90394 /src/backend/commands/copyto.c | |
parent | 5553cbd4fe3eb177b3266ca4a7e80159323608c2 (diff) |
Add HEADER support to COPY text format
The COPY CSV format supports the HEADER option to output a header
line. This patch adds the same option to the default text format. On
input, the HEADER option causes the first line to be skipped, same as
with CSV.
Author: Rémi Lapeyre <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CAF1-J-0PtCWMeLtswwGV2M70U26n4g33gpe1rcKQqe6wVQDrFA@mail.gmail.com
Diffstat (limited to 'src/backend/commands/copyto.c')
-rw-r--r-- | src/backend/commands/copyto.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c index 20bfd49112a..e793b64bdab 100644 --- a/src/backend/commands/copyto.c +++ b/src/backend/commands/copyto.c @@ -863,8 +863,11 @@ DoCopyTo(CopyToState cstate) colname = NameStr(TupleDescAttr(tupDesc, attnum - 1)->attname); - CopyAttributeOutCSV(cstate, colname, false, + if (cstate->opts.csv_mode) + CopyAttributeOutCSV(cstate, colname, false, list_length(cstate->attnumlist) == 1); + else + CopyAttributeOutText(cstate, colname); } CopySendEndOfRow(cstate); |