[BUG] exists, sample and extend cannot be used as unquoted identifiers #2772
Description
JSqlParser version: master 8d12a5d7a (5.5-SNAPSHOT); extend has failed since 5.2, exists and sample have failed since these tokens were reserved. RDBMS: all.
The following statements fail on master although all three words are non-reserved in the common dialects:
SELECT tb_name, exists FROM entity ORDER BY exists;
SELECT * FROM sample;
UPDATE t SET extend = 'x' WHERE id = 1;They reach JSqlParser through downstream SQL rewriting tools (baomidou/mybatis-plus#7029, #5956, #6504, #6871), where users cannot rename their columns or tables.
Root cause: K_EXISTS, K_SAMPLE and K_EXTEND are reserved tokens for specific operator positions (the EXISTS predicate and JSON_TABLE flag, Vertica table sampling, ksqDB pipe operators) but were never added to the reserved-keyword-as-identifier alternatives of RelObjectName(), unlike earlier dual-use keywords such as EXTENDED (#1525) or GROUPS (#2473).
A PR follows.
Activity
fudianchn commentedon Oct 15, 2026
Fixed by #2773 (
exists) and #2774 (sample,extend), both merged. Re-checked the three statements from this issue on current master (bdf8ac3): all of them parse now, andEXISTS (...)predicates are unaffected. Closing.