You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "viminizer (via GitHub)" <gi...@apache.org> on 2026/08/08 19:10:09 UTC
[I] PostgreSQL dialect omits SYSTEM_USER from unparenthesized function names [shardingsphere]
viminizer opened a new issue, #39384:
URL: https://github.com/apache/shardingsphere/issues/39384
## Bug Report
### Which version of ShardingSphere did you use?
master @ d26c87dc
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
Both (kernel-level binder)
### Expected behavior
Under the PostgreSQL dialect, the niladic function `SYSTEM_USER` should bind as a function, like the sibling user-value functions `CURRENT_USER`, `SESSION_USER`, and `USER`. PostgreSQL 16 added `SYSTEM_USER` as a SQL standard keyword; it returns the authenticated identity and the authentication method used to establish the session.
### Actual behavior
`SYSTEM_USER` is missing from `PostgreSQLFunctionOption.UNPARENTHESIZED_FUNCTION_NAMES`, so the binder misclassifies it as a column reference and fails with:
```
ColumnNotFoundException: Unknown column 'SYSTEM_USER' in 'field list'.
```
### Reason analyze (If you can)
`PostgreSQLFunctionOption` (database/connector/dialect/postgresql/.../metadata/database/option/PostgreSQLFunctionOption.java lines 31-33) lists 11 names and omits `SYSTEM_USER`.
`ColumnSegmentBinder.isUnparenthesizedFunction()` (infra/binder/core/.../expression/type/ColumnSegmentBinder.java line 149) reads this set via `.contains()` to decide function vs column. When the lookup fails, `bind()` throws at line 102.
`MySQLFunctionOption` and `SQLServerFunctionOption` already include `SYSTEM_USER`.
Unlike SQL92, the PostgreSQL grammar does not declare `SYSTEM_USER` as a keyword token, so it already lexes as an identifier and parses as a column projection. The failure is at bind time only, and no grammar change is required.
### Steps to reproduce the behavior
Bind `SELECT SYSTEM_USER` against a PostgreSQL-typed schema; the identifier is treated as a column rather than a niladic function.
### Additional notes
Two points worth a maintainer's decision:
1. `OpenGaussDatabaseMetaData#getFunctionOption` returns `new PostgreSQLFunctionOption()`, so openGauss inherits this change. openGauss forked from PostgreSQL 9.2, which predates `SYSTEM_USER` by roughly a decade. Should openGauss get its own `OpenGaussFunctionOption`, following the existing `OpenGaussSchemaOption` and `OpenGaussDataTypeOption`? I have kept the fix minimal and not done this.
2. `infra/binder/core` has only `shardingsphere-database-connector-hive` on its test classpath, so binder tests naming any other dialect silently resolve to `DefaultFunctionOption`, whose unparenthesized name set is empty. A test for this bug cannot fail correctly without adding the dialect. Adding `postgresql` at test scope follows `infra/common` and `kernel/sql-federation/executor`.
Related: #39099 is the same gap in the SQL92 dialect.
--
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] PostgreSQL dialect omits SYSTEM_USER from unparenthesized function names [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #39384: PostgreSQL dialect omits SYSTEM_USER from unparenthesized function names
URL: https://github.com/apache/shardingsphere/issues/39384
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org