Re: CREATE COLLATION - check for duplicate options and error out if found one - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: CREATE COLLATION - check for duplicate options and error out if found one
Date
Msg-id CAEZATCU0J9MAnC3qu5Xzj70vBwj-+cUP1n5eWn6a=7UOK6V-aw@mail.gmail.com
Whole thread Raw
In response to Re: CREATE COLLATION - check for duplicate options and error out if found one  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
List pgsql-hackers
On Sat, 17 Jul 2021 at 05:24, Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> I also think that if it is specified as CREATE FUNCTION ... STRICT
> STRICT, CREATE FUNCTION ... CALLED ON NULL INPUT RETURNS NULL ON NULL
> INPUT etc. isn't the syntaxer catching that error while parsing the
> SQL text, similar to CREATE COLLATION mycoll1 FROM FROM "C";?

No, they're processed quite differently. The initial parsing of CREATE
FUNCTION allows an arbitrary list of things like STRICT, CALLED ON
NULL INPUT, etc., which it turns into a list of DefElem that is only
checked later on. That's the most natural way to do it, since this is
really just a list of options that can appear in any order, much like
the version of CREATE COLLATION that allows options in parentheses,
which is quite different from the version that takes a single FROM.
Reading the relevant portions of gram.y is probably the easiest way to
understand it.

It's actually quite instructive to search for "makeDefElem" in gram.y,
and see all the places that create a DefElem that doesn't match the
user-entered syntax. There are quite a few of them, and there may be
others elsewhere.

Regards,
Dean



pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: CREATE COLLATION - check for duplicate options and error out if found one
Next
From: Ranier Vilela
Date:
Subject: Re: Remove redundant strlen call in ReplicationSlotValidateName