8000 Simplify signature of CopyAttributeOutCSV() in copyto.c · postgrespro/postgres@b9d6038 · GitHub
[go: up one dir, main page]

Skip to content
  • Commit b9d6038

    Browse files
    committed
    Simplify signature of CopyAttributeOutCSV() in copyto.c
    This has come up in 2889fd2, 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
    1 parent 1aa8324 commit b9d6038

    File tree

    1 file changed

    +5
    -6
    lines changed

    1 file changed

    +5
    -6
    lines changed

    src/backend/commands/copyto.c

    Lines changed: 5 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -119,7 +119,7 @@ static void ClosePipeToProgram(CopyToState cstate);
    119119
    static void CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot);
    120120
    static void CopyAttributeOutText(CopyToState cstate, const char *string);
    121121
    static void CopyAttributeOutCSV(CopyToState cstate, const char *string,
    122-
    bool use_quote, bool single_attr);
    122+
    bool use_quote);
    123123

    124124
    /* Low-level communications functions */
    125125
    static void SendCopyBegin(CopyToState cstate);
    @@ -837,8 +837,7 @@ DoCopyTo(CopyToState cstate)
    837837
    colname = NameStr(TupleDescAttr(tupDesc, attnum - 1)->attname);
    838838

    839839
    if (cstate->opts.csv_mode)
    840-
    CopyAttributeOutCSV(cstate, colname, false,
    841-
    list_length(cstate->attnumlist) == 1);
    840+
    CopyAttributeOutCSV(cstate, colname, false);
    842841
    else
    843842
    CopyAttributeOutText(cstate, colname);
    844843
    }
    @@ -952,8 +951,7 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot)
    952951
    value);
    953952
    if (cstate->opts.csv_mode)
    954953
    CopyAttributeOutCSV(cstate, string,
    955-
    cstate->opts.force_quote_flags[attnum - 1],
    956-
    list_length(cstate->attnumlist) == 1);
    954+
    cstate->opts.force_quote_flags[attnum - 1]);
    957955
    else
    958956
    CopyAttributeOutText(cstate, string);
    959957
    }
    @@ -1139,14 +1137,15 @@ CopyAttributeOutText(CopyToState cstate, const char *string)
    11391137
    */
    11401138
    static void
    11411139
    CopyAttributeOutCSV(CopyToState cstate, const char *string,
    1142-
    bool use_quote, bool single_attr)
    1140+
    bool use_quote)
    11431141
    {
    11441142
    const char *ptr;
    11451143
    const char *start;
    11461144
    char c;
    11471145
    char delimc = cstate->opts.delim[0];
    11481146
    char quotec = cstate->opts.quote[0];
    11491147
    char escapec = cstate->opts.escape[0];
    1148+
    bool single_attr = (list_length(cstate->attnumlist) == 1);
    11501149

    11511150
    /* force quoting if it matches null_print (before conversion!) */
    11521151
    if (!use_quote && strcmp(string, cstate->opts.null_print) == 0)

    0 commit comments

    Comments
     (0)
    0