Обсуждение: END is not a reserved word

Поиск
Список
Период
Сортировка

END is not a reserved word

От
Vicky Vergara
Дата:
Hello all

A simplification of the problem I found:

Here is a function (taken from the postgres documentation)
```
CREATE FUNCTION add(integer, integer) RETURNS integer
    AS 'select $1 + $2;'
    LANGUAGE SQL
    IMMUTABLE
    RETURNS NULL ON NULL INPUT;
```

"Accidentally" did the following:
```
SELECT add(3,4) END;
```
On postgres 14 and over+ there is no problem:
```
 end 
-----
   7
(1 row)
```
On Postgres 13 and under:
```
ERROR:  syntax error at or near "END"
LINE 1: SELECT add(3,4) END;
```

On the list of reserved words, END is marked as reserved.
https://www.postgresql.org/docs/current/sql-keywords-appendix.html

Since postgres 14+ is not reserved and can be used, for example as a column name.
Unless I am mistaken that shouldn't happen.

Made a small CI test with the code above: (link will be unavailable when gihub removes the workflow)
Fails as expected as `end` is a reserved word (pg13)

Regards
Vicky Vergara
pgRouting developer

Re: END is not a reserved word

От
"David G. Johnston"
Дата:
On Mon, Aug 25, 2025 at 3:49 PM Vicky Vergara <vicky_vergara@hotmail.com> wrote:
On the list of reserved words, END is marked as reserved.

The text on that page notes a couple of times that using reserved words as column labels is accepted - with the only caveat being sometimes you have to use 'AS'.

There may be some that do not get accepted for some reason or other but it's always OK if they are accepted as column labels.

David J.

Re: END is not a reserved word

От
Vicky Vergara
Дата:
Thanks,

Just found the note on 


Reduce the number of keywords that can't be used as column labels without AS (Mark Dilger) §
  • There are now 90% fewer restricted keywords.
    Next time I will read the releases changes before I post.

    Thanks again

    Vicky


    De: David G. Johnston <david.g.johnston@gmail.com>
    Enviado: lunes, 25 de agosto de 2025 06:53 p. m.
    Para: Vicky Vergara <vicky_vergara@hotmail.com>
    Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
    Asunto: Re: END is not a reserved word
     
    On Mon, Aug 25, 2025 at 3:49 PM Vicky Vergara <vicky_vergara@hotmail.com> wrote:
    On the list of reserved words, END is marked as reserved.

    The text on that page notes a couple of times that using reserved words as column labels is accepted - with the only caveat being sometimes you have to use 'AS'.

    There may be some that do not get accepted for some reason or other but it's always OK if they are accepted as column labels.

    David J.