Skip to content

[BUG] JSQLParser 5.4-SNAPSHOT : PostgreSQL : GROUPS cannot be used as an identifier anymore (regression via #2460) #2473

Description

@fudianchn

Failing SQL Feature:

GROUPS cannot be used as an identifier (column, table, or alias) anymore.

The GROUPS keyword was introduced for PostgreSQL GROUPS window frames in d92f407 (#2460) and was placed into the reserved keyword token section of the grammar. However, GROUPS is a non-reserved keyword in PostgreSQL (see the key words table: GROUPS is marked "non-reserved"), so it remains a perfectly legal identifier.

As a result, SQL which parsed fine before #2460 now fails on current master.

SQL Example:

SELECT groups FROM mytable;
SELECT * FROM groups;
SELECT a AS groups FROM mytable;
SELECT a groups FROM mytable;
CREATE TABLE t (groups INT);

Each statement throws a JSQLParserException (e.g. Encountered unexpected token: "groups").

Verified on master 406a4d4.

The grammar already has the right mechanism for such keywords: tokens declared inside the NonReservedWord() production are automatically accepted as identifiers via the MIN_NON_RESERVED_WORD / MAX_NON_RESERVED_WORD range guards (used by RelObjectName() and isAliasAhead()), and KeywordsTest covers every one of them parameterized as identifiers. GROUPS just needs to move from the reserved token section into NonReservedWord().

Software Information:

  • JSqlParser version: 5.4-SNAPSHOT (master 406a4d4)
  • Database: PostgreSQL (affects any user with a column, table, or alias named groups)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions