git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1aa8324)
Simplify signature of CopyAttributeOutCSV() in copyto.c
Wed, 7 Feb 2024 03:28:55 +0000 (12:28 +0900)
Wed, 7 Feb 2024 03:28:55 +0000 (12:28 +0900)
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/ZcCKwAeFrlOqPBuN@paquier.xyz


diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index d3dc3fc854f1437d222e581176e20aaed1dd456e..bd4710a79be99ab604bdde89362f1322d07ea2df 100644 (file)
--- 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)
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /