terrymanu commented on issue #24862:
URL: 
https://github.com/apache/shardingsphere/issues/24862#issuecomment-3628206408

   ##  Problem Understanding: 
   
   In PostgreSQL 9.6.4 with ShardingSphere-Proxy 5.3.0/5.3.1, running range 
constructor calls like select public.int4range(400, 500, '[]'); fails unless 
the function name is quoted. Using quoted names or range literals/type casts 
works.
   
   ##  Root Cause: 
   
   ShardingSphere’s PostgreSQL grammar treats 
int4range/int8range/numrange/tsrange/tstzrange/daterange as keywords 
(PostgreSQLKeyword.g4). In the function name rule (BaseRule.g4 funcName → 
typeFunctionName), only identifiers, unreserved words, and specific 
typeFuncName keywords are allowed; these range keywords are not included. As a 
result, bare int4range(...) is seen as a reserved token and rejected, leading 
to the “no viable alternative” parse error.
   
   ##  Problem Analysis: 
   
   During parsing, funcName must match typeFunctionName (identifier | 
unreservedWord | typeFuncNameKeyword). The lexer produces INT4RANGE tokens for 
range constructors; those tokens are outside the allowed set, so funcName 
fails. Quoting the name forces it to an IDENTIFIER_ token, which passes. This 
is a parser-layer issue, not a database behavior difference.
   
   ##  Problem Conclusion: 
   
   This is a SQL parser bug: range constructor keywords are excluded from 
allowable function names. Workarounds: quote the function name or use range 
literals/type casts. To fix, the PostgreSQL grammar should allow these range 
keywords as function names (e.g., add them to typeFunctionName/unreserved) to 
match native PostgreSQL syntax.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to