Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q0NAi-0000LY-MI for pgsql-hackers@arkaria.postgresql.org; Sat, 20 May 2023 14:03:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q0N9h-0000cC-S4 for pgsql-hackers@arkaria.postgresql.org; Sat, 20 May 2023 14:01:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q0N9h-0000c3-IF for pgsql-hackers@lists.postgresql.org; Sat, 20 May 2023 14:01:57 +0000 Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q0N9Y-000wUU-Si for pgsql-hackers@lists.postgresql.org; Sat, 20 May 2023 14:01:56 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id 09B7C20008; Sat, 20 May 2023 14:01:45 +0000 (UTC) Content-Type: multipart/alternative; boundary="------------YZlLla20Rh2kOWf30Dv827VJ" Message-ID: <513a82bf-2710-b4be-73e8-7251616a3b01@dunslane.net> Date: Sat, 20 May 2023 10:01:44 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Content-Language: en-US To: Joel Jacobson , pgsql-hackers@lists.postgresql.org References: <748b7bfc-9f16-4bea-b7e1-4a59dc9354f5@app.fastmail.com> <0400a90b-ff40-4be5-8f90-6c205c9cd99b@app.fastmail.com> From: Andrew Dunstan Subject: Re: New COPY options: DELIMITER NONE and QUOTE NONE In-Reply-To: <0400a90b-ff40-4be5-8f90-6c205c9cd99b@app.fastmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------YZlLla20Rh2kOWf30Dv827VJ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2023-05-20 Sa 02:59, Joel Jacobson wrote: > On Fri, May 19, 2023, at 19:03, Andrew Dunstan wrote: > > I think you've been a bit too cute with the grammar changes, but as > you say this is a POC. > > Thanks for feedback. > > The approach I took for the new grammar rules was inspired by previous > commits, > such as de7531a971b, which introduced support for 'FORCE QUOTE '*''. > In that > case, a new separate grammar rule was crafted. > > Not sure what you mean with it being "too cute", but maybe you think > it's a bit > verbose with another grammar rule and it would be better to integrate > it into > the existing one? > > Example: > > | DELIMITER opt_as (Sconst | NONE) >         { >                 if ($3 == NONE) >                         $$ = makeDefElem("delimiter", (Node *) > makeString("\0"), @1); >                 else >                         $$ = makeDefElem("delimiter", (Node *) > makeString($3), @1); >         } > > I would probably go for something like this for "DELIMITER NONE" in a separate rule:  | DELIMITER NONE     {        $$ = makeDefElem("delimiter_none", (Node *)makeInteger(true), @1);     } and deal with that element further down the stack. It looks to me at first glance that your changes would allow "DELIMITER ''" which is probably not what we want. Similarly for "QUOTE NONE". cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------YZlLla20Rh2kOWf30Dv827VJ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2023-05-20 Sa 02:59, Joel Jacobson wrote:
On Fri, May 19, 2023, at 19:03, Andrew Dunstan wrote:
> I think you've been a bit too cute with the grammar changes, but as you say this is a POC.

Thanks for feedback.

The approach I took for the new grammar rules was inspired by previous commits,
such as de7531a971b, which introduced support for 'FORCE QUOTE '*''. In that
case, a new separate grammar rule was crafted.

Not sure what you mean with it being "too cute", but maybe you think it's a bit
verbose with another grammar rule and it would be better to integrate it into
the existing one?

Example:

| DELIMITER opt_as (Sconst | NONE)
        {
                if ($3 == NONE)
                        $$ = makeDefElem("delimiter", (Node *) makeString("\0"), @1);
                else
                        $$ = makeDefElem("delimiter", (Node *) makeString($3), @1);
        }




I would probably go for something like this for "DELIMITER NONE" in a separate rule:

 | DELIMITER NONE
    {

       $$ = makeDefElem("delimiter_none", (Node *)makeInteger(true), @1);

    }

and deal with that element further down the stack. It looks to me at first glance that your changes would allow "DELIMITER ''" which is probably not what we want.

Similarly for "QUOTE NONE".


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------YZlLla20Rh2kOWf30Dv827VJ--