Re: [PATCH] COPY command's data format option allows only lowercase csv, text or binary - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] COPY command's data format option allows only lowercase csv, text or binary
Date
Msg-id 2204307.1593008861@sss.pgh.pa.us
Whole thread Raw
In response to [PATCH] COPY command's data format option allows only lowercase csv,text or binary  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: [PATCH] COPY command's data format option allows only lowercasecsv, text or binary
Re: [PATCH] COPY command's data format option allows only lowercasecsv, text or binary
List pgsql-hackers
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> writes:
> COPY command's FORMAT option allows only all lowercase csv, text or
> binary, this is true because strcmp is being used while parsing these
> values.

This is nonsense, actually:

regression=# create table foo (f1 int);
CREATE TABLE
regression=# copy foo from stdin (format CSV);
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.

As that shows, there's already a round of lowercasing done by the parser.
The only way that strcasecmp in copy.c would be useful is if you wanted to
accept things like
    copy foo from stdin (format "CSV");
I don't find that to be a terribly good idea.  The normal implication
of quoting is that it *prevents* case folding, so why should that
happen anyway?

More generally, though, why would we want to change this policy only
here?  I believe we're reasonably consistent about letting the parser
do any required down-casing and then just checking keyword matches
with strcmp.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: min_safe_lsn column in pg_replication_slots view
Next
From: Alvaro Herrera
Date:
Subject: Re: SIGSEGV from START_REPLICATION 0/XXXXXXX in XLogSendPhysical ()at walsender.c:2762