Re: Keyword docs missing, or mislabelled keywords

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: danny(dot)jones1994(at)live(dot)com, Pg Docs <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: Keyword docs missing, or mislabelled keywords
Date: 2021-09-02 14:54:17
Message-ID: CAKFQuwZFTmBoGzCHF7b_iorWcZKqoU0k_MtaTLz9XD6hm6Z6YQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thu, Sep 2, 2021 at 7:11 AM PG Doc comments form <noreply(at)postgresql(dot)org>
wrote:

>
> https://www.postgresql.org/docs/13/sql-keywords-appendix.html
>
> Missing:
>
> RESTRICTED (as found in CREATE FUNCTION (PARALLEL RESTRICTED))
> SAFE (as found in CREATE FUNCTION (PARALLEL SAFE))
> UNSAFE (as found in CREATE FUNCTION (PARALLEL UNSAFE))
>

I'll agree that the documentation for this doesn't fully describe the
intricacies of the implementation, but the listing, at least for the
PARALLEL related options, is correct. Basically, our parser denotes
PARALLEL as being an unreserved keyword, and because of this is able to
identify the specific usage of PARALLEL {something} in CREATE FUNCTION and
simply take "the next token" as a simple label (ColId) that gets passed
along to the executor as state data. Those labels thus do not need to be
identified formally as keywords and thus are omitted from the table.

Per the cross-referenced 4.1 lead-in paragraph [1]:

"A token can be a key word, an identifier, a quoted identifier, a literal
(or constant), or a special character symbol."

In terms of the above, RESTRICTED, SAFE, and UNSAFE are all "identifiers"
[2].

We don't formally distinguish between "catalog recorded" identifiers and
"simple label" identifiers - the perspective of the parser is that neither
subclass has the limitations of a full keyword and neither requires any
special knowledge or handling by the parser - the text can simply be passed
along and the executor can be programmed to know which ones are which.

David J.

[1]
https://www.postgresql.org/docs/13/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

[2]
https://github.com/postgres/postgres/blob/ba1b763102b89bca2711e921cf3083d8487b8c96/src/backend/parser/gram.y#L15414

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2021-09-02 19:32:52 Re: Keyword docs missing, or mislabelled keywords
Previous Message PG Doc comments form 2021-09-02 12:31:23 Keyword docs missing, or mislabelled keywords