summaryrefslogtreecommitdiff
path: root/src/backend/commands/copyto.c
diff options
context:
space:
mode:
authorPeter Eisentraut2022-01-28 08:22:53 +0000
committerPeter Eisentraut2022-01-28 08:44:47 +0000
commit43f33dc018a4b77ced78a0a6df8ed5d450cfe5f4 (patch)
treef372e2f7e3f37ee968c08f6cc6220b6657f90394 /src/backend/commands/copyto.c
parent5553cbd4fe3eb177b3266ca4a7e80159323608c2 (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.c5
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);