summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier2024-02-07 03:28:55 +0000
committerMichael Paquier2024-02-07 03:28:55 +0000
commitb9d6038d7048ddb837aa1d286fb8f5ca0e9b3a83 (patch)
treef43c112f28bffb732b677061ef006311458a7f5f /src
parent1aa8324b81fa4979ffdc6ccf81d560eac9446948 (diff)
Simplify signature of CopyAttributeOutCSV() in copyto.c
This has come up in 2889fd23be56, reverted later on, and is still useful on its own to reduce a bit the differences between the code paths dedicated to CSV and text. Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/copyto.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index d3dc3fc854f..bd4710a79be 100644
--- a/src/backend/commands/copyto.c
+++ b/src/backend/commands/copyto.c
@@ -119,7 +119,7 @@ static void ClosePipeToProgram(CopyToState cstate);
static void CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot);
static void CopyAttributeOutText(CopyToState cstate, const char *string);
static void CopyAttributeOutCSV(CopyToState cstate, const char *string,
- bool use_quote, bool single_attr);
+ bool use_quote);
/* Low-level communications functions */
static void SendCopyBegin(CopyToState cstate);
@@ -837,8 +837,7 @@ DoCopyTo(CopyToState cstate)
colname = NameStr(TupleDescAttr(tupDesc, attnum - 1)->attname);
if (cstate->opts.csv_mode)
- CopyAttributeOutCSV(cstate, colname, false,
- list_length(cstate->attnumlist) == 1);
+ CopyAttributeOutCSV(cstate, colname, false);
else
CopyAttributeOutText(cstate, colname);
}
@@ -952,8 +951,7 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot)
value);
if (cstate->opts.csv_mode)
CopyAttributeOutCSV(cstate, string,
- cstate->opts.force_quote_flags[attnum - 1],
- list_length(cstate->attnumlist) == 1);
+ cstate->opts.force_quote_flags[attnum - 1]);
else
CopyAttributeOutText(cstate, string);
}
@@ -1139,7 +1137,7 @@ CopyAttributeOutText(CopyToState cstate, const char *string)
*/
static void
CopyAttributeOutCSV(CopyToState cstate, const char *string,
- bool use_quote, bool single_attr)
+ bool use_quote)
{
const char *ptr;
const char *start;
@@ -1147,6 +1145,7 @@ CopyAttributeOutCSV(CopyToState cstate, const char *string,
char delimc = cstate->opts.delim[0];
char quotec = cstate->opts.quote[0];
char escapec = cstate->opts.escape[0];
+ bool single_attr = (list_length(cstate->attnumlist) == 1);
/* force quoting if it matches null_print (before conversion!) */
if (!use_quote && strcmp(string, cstate->opts.null_print) == 0)