Re: Fixing backslash dot for COPY FROM...CSV - Mailing list pgsql-hackers

From Artur Zakirov
Subject Re: Fixing backslash dot for COPY FROM...CSV
Date
Msg-id CAKNkYnxur+x6KoOy0gfTyoQ=uTYo=d6f1eZRsB0Wmc+qh8RrNA@mail.gmail.com
Whole thread Raw
In response to Re: Fixing backslash dot for COPY FROM...CSV  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-hackers
On Wed, 31 Jul 2024 at 15:42, Daniel Verite <daniel@manitou-mail.org> wrote:
>
>         Sutou Kouhei wrote:
>
> > BTW, here is a diff after pgindent:
>
> PFA a v5 with the cosmetic changes applied.

Thank you Daniel for working on it. I've tested the patch and it seems
it works as expected.

I have a couple of minor comments.

It seems it isn't necessary to handle "\." within
"CopyAttributeOutCSV()" (file "src/backend/commands/copyto.c")
anymore.

    /*
     * Because '\.' can be a data value, quote it if it appears alone on a
     * line so it is not interpreted as the end-of-data marker.
     */
    if (single_attr && strcmp(ptr, "\\.") == 0)
        use_quote = true;

You might see the difference in the test "cooy2.sql". Without changes
the output is:

    =# COPY testeoc TO stdout CSV;
    a\.
    \.b
    c\.d
    "\."

Another thing is that the comparison "copystream ==
pset.cur_cmd_source" happens twice within "handleCopyIn()". TBH it is
a bit confusing to me what is the real purpose of that check, but one
of the comparisons looks unnecessary.

-- 
Kind regards,
Artur
Supabase



pgsql-hackers by date:

Previous
From: Magnus Holmgren
Date:
Subject: restrict_nonsystem_relation_kind led to regression (kinda)
Next
From: Alvaro Herrera
Date:
Subject: Re: restrict_nonsystem_relation_kind led to regression (kinda)