GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: allow GROUPS as identifier by making it a non-reserved keyword (#2473) by fudianchn · Pull Request #2474 · JSQLParser/JSqlParser

Conversation

@fudianchn

@fudianchn fudianchn commented Aug 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What

GROUPS becomes a non-reserved keyword again, so it can be used as an identifier (column, table, alias) while the GROUPS window frame unit keeps working:

SELECT groups FROM mytable
SELECT * FROM groups
CREATE TABLE mytable (groups INT)

Why / Root cause

#2460 (commit d92f407) introduced the PostgreSQL GROUPS frame unit and declared <K_GROUPS:"GROUPS"> in the reserved keyword token section. In PostgreSQL, GROUPS is a non-reserved keyword and stays a legal identifier, so statements like the ones above parsed before #2460 and fail on master with Encountered unexpected token: "groups".

The decision in #2460

Making GROUPS reserved was a deliberate, reviewed trade-off, not an oversight. #2460 initially declared K_GROUPS inside NonReservedWord() (24cf1bd); during review the raw <S_IDENTIFIER> productions (CREATE SCHEMA, SET PATH, Oracle KEEP, interval type, COLLATE, the ColDataType lookahead) were called out, and the token was then moved to the reserved set instead of broadening those productions.

One point that was not on the table then: the sibling frame units already live in exactly the state this PR restores for GROUPS. ROWS and RANGE are non-reserved on master, and the same raw-identifier productions reject them identically:

CREATE SCHEMA rows                -- fails on master
CREATE SCHEMA range               -- fails on master
SELECT a COLLATE rows FROM t      -- fails on master

while quoted forms (CREATE SCHEMA "groups") work everywhere. "Non-reserved, raw-identifier positions need quoting" is therefore the existing status quo for frame-unit keywords in this grammar, and this PR makes GROUPS consistent with ROWS and RANGE (all three are non-reserved in PostgreSQL) rather than introducing a new inconsistency.

If keeping GROUPS reserved is preferred, closing this PR is fine. If the raw-identifier productions should accept the frame-unit words, that would be a separate change applying to ROWS, RANGE and GROUPS alike; I can prepare it on request.

How

One symmetric relocation in JSqlParserCC.jjt: the <K_GROUPS:"GROUPS"> declaration moves from the reserved token section into the NonReservedWord() production (between GRANT and GROUP_CONCAT).

Tokens declared inside NonReservedWord() fall into the MIN_NON_RESERVED_WORD … MAX_NON_RESERVED_WORD kind range, which RelObjectName() and isAliasAhead() already accept, and which KeywordsTest covers parameterized as identifiers. No other grammar rule changes, and the explicit <K_GROUPS> match in WindowElement() is unaffected (only the token kind numbering moves).

Scope

Only the keyword classification changes. GROUPS frame units (ROWS / RANGE / GROUPS BETWEEN ... EXCLUDE ...) keep parsing exactly as before; GROUPS additionally works in every identifier position covered by the non-reserved range guards (column, table, schema, alias, function name).

Testing

KeywordsTest.testGroupsAsIdentifier reproduces the issue (column, table, explicit and implicit alias, CREATE TABLE column definition): fails on master with JSQLParserException, passes with this change. The parameterized KeywordsTest identifier cases pick GROUPS up automatically (732 -> 734 tests).

Performance

gradle jmh, JSQLParserBenchmark.parseSQLStatements on performance.sql, version=latest, 10 forks x 10 iterations (100 samples) on a 32-core host:

build ms/op
master (406a4d4) 3.712 ± 0.020
this PR (37b6068) 3.709 ± 0.022

The -0.08% delta lies within the 99.9% confidence intervals (the CIs overlap almost entirely): no regression.

Verification of the original issue

All statements from #2473 fail on master and parse + round-trip with this change.

Fixes #2473

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@fudianchn
fix: allow GROUPS as identifier by making it a non-reserved keyword (J…
37b6068
…SQLParser#2473)

Signed-off-by: 付典 <[email protected]>
@manticore-projects

manticore-projects commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects
manticore-projects merged commit edfbb0a into JSQLParser:master Aug 16, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@fudianchn
fudianchn deleted the fix/groups-nonreserved-2473 branch August 21, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@fudianchn @manticore-projects
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.