Bug in create type when missed the comma between element list

Started by Diegoabout 1 year ago3 messages
#1Diego
mrstephenamell@gmail.com

Hi team!

I found this bug in the create type command. If you miss the comma
between the elements, the command doesn't fail; it runs and concatenates
the elements.

I detected the problem in v14.4, and it is alive in v17.

pglatest$ psql -h 127.0.0.1 -p 55532
Password for user daf:
Time: 0.481 ms
psql (16.4 (Ubuntu 16.4-1.pgdg24.04+2), server 17.0 (Debian
17.0-1.pgdg120+1))
WARNING: psql major version 16, server major version 17.
         Some psql features might not work.
Type "help" for help.

u: daf db: daf # CREATE TYPE test_enum AS ENUM(
    'one'
    'two',
    'three',
    'four'
);
CREATE TYPE
Time: 12.242 ms
u: daf db: daf # \dt+
Did not find any relations.
u: daf db: daf # \dT+
                                       List of data types
 Schema |   Name    | Internal name | Size | Elements | Owner | Access
privileges | Description
--------+-----------+---------------+------+----------+-------+-------------------+-------------
 public | test_enum | test_enum     | 4    | onetwo  +| daf
|                   |
        |           |               |      | three   +|
|                   |
        |           |               |      | four     |
|                   |
(1 row)

u: daf db: daf #

maybe, some of you can help me to report it properly.

Thank you,
Diego.

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Diego (#1)
Re: Bug in create type when missed the comma between element list

On Mon, Nov 4, 2024 at 9:17 AM Diego <mrstephenamell@gmail.com> wrote:

u: daf db: daf # CREATE TYPE test_enum AS ENUM(
'one'
'two',
'three',
'four'
);

maybe, some of you can help me to report it properly.

That is working per SQL standard. If you hadn't used newlines between
the elements you would have gotten an error; but the newlines between
literals is valid string literal syntax.

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS

David J.

#3Diego
mrstephenamell@gmail.com
In reply to: David G. Johnston (#2)
Re: Bug in create type when missed the comma between element list

Thank you David!

That note: This slightly bizarre behavior is specified by SQL;
PostgreSQL is following the standard.

Show quoted text

On 11/4/24 13:19, David G. Johnston wrote:

On Mon, Nov 4, 2024 at 9:17 AM Diego <mrstephenamell@gmail.com> wrote:

u: daf db: daf # CREATE TYPE test_enum AS ENUM(
    'one'
    'two',
    'three',
    'four'
);

maybe, some of you can help me to report it properly.

That is working per SQL standard.  If you hadn't used newlines between
the elements you would have gotten an error; but the newlines between
literals is valid string literal syntax.

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS

David J.