You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "susongyan (via GitHub)" <gi...@apache.org> on 2023/08/03 09:18:26 UTC
[GitHub] [shardingsphere] susongyan opened a new issue, #27892: [proxy] not treat "?" operator correctly
susongyan opened a new issue, #27892:
URL: https://github.com/apache/shardingsphere/issues/27892
## Bug Report
### Which version of ShardingSphere did you use?
5.3.0
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
proxy
### Expected behavior
pgsql execute success
SELECT * from table WHERE receiver ?& $1 OR creater = $2;
parameter 1, test@gmail.com 2, susongyan
### Actual behavior
org.postgresql.util.PSQLException: No value specified for parameter 3.
### Reason analyze (If you can)
PostgreSQLComParseExecutor #convertSQLToJDBCStyle
after proxy parse this sql and convert it to jdbc paramter style
the actual sql to execute in jdbc is "SELECT * from table WHERE receiver ?& ? OR creater = ?;"
jdbc style, treat "?" as parameter marker, then this sql need three parameters in mistake (actually only two)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
### Example codes for reproduce this issue (such as a github link).
--
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
[GitHub] [shardingsphere] TeslaCN closed issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN closed issue #27892: [proxy] not treat "?" operator correctly in postgresql
URL: https://github.com/apache/shardingsphere/issues/27892
--
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
[GitHub] [shardingsphere] susongyan commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "susongyan (via GitHub)" <gi...@apache.org>.
susongyan commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1669098566
process in pg driver @sandynz
org.postgresql.core.Parser#parseJdbcSql
```java
case '?':
nativeSql.append(aChars, fragmentStart, i - fragmentStart);
if (i + 1 < aChars.length && aChars[i + 1] == '?') /* replace ?? with ? */ {
nativeSql.append('?');
i++; // make sure the coming ? is not treated as a bind
}
```
--
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
[GitHub] [shardingsphere] susongyan commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "susongyan (via GitHub)" <gi...@apache.org>.
susongyan commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1665353083
@azexcy i simply convert ? to ?? escaped in pg jdbc driver's style
--
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
[GitHub] [shardingsphere] susongyan commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "susongyan (via GitHub)" <gi...@apache.org>.
susongyan commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1667693303
@RaigorJiang help have a look ?
--
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
[GitHub] [shardingsphere] sandynz commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1667709321
Hi @susongyan , could you supply some PostgreSQL document of
> SELECT * from table WHERE receiver ?& $1 OR creater = $2;
parameter 1, [test@gmail.com](mailto:test@gmail.com) 2, susongyan
--
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
[GitHub] [shardingsphere] susongyan commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "susongyan (via GitHub)" <gi...@apache.org>.
susongyan commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1669115414
@sandynz
https://www.postgresql.org/docs/9.4/functions-json.html this is jsonb function doc
--
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
[GitHub] [shardingsphere] sandynz commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1670744453
> process in pg driver @sandynz org.postgresql.core.Parser#parseJdbcSql
>
> ```java
> case '?':
> nativeSql.append(aChars, fragmentStart, i - fragmentStart);
> if (i + 1 < aChars.length && aChars[i + 1] == '?') /* replace ?? with ? */ {
> nativeSql.append('?');
> i++; // make sure the coming ? is not treated as a bind
> }
> ```
1, Is `?` escape character in PostgreSQL? Is there any document about it?
2,
<img width="672" alt="图片" src="https://github.com/apache/shardingsphere/assets/42492540/4d04d7d5-7686-4a70-a65a-82ccbe20a519">
I found `Parser.parseJdbcSql` is referenced by 2 places, maybe not for every type of SQL. I'm not sure whether the SQL type is equivalent with `PostgreSQLComParseExecutor` handled or not.
--
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
[GitHub] [shardingsphere] susongyan commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "susongyan (via GitHub)" <gi...@apache.org>.
susongyan commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1665043887
>
i checkout master code, it doesn't escape this operator yet,
--
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
[GitHub] [shardingsphere] azexcy commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "azexcy (via GitHub)" <gi...@apache.org>.
azexcy commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1664895318
@susongyan Thanks for the feedback!
Can you help confirm that this is still an issue on the master branch?
--
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
[GitHub] [shardingsphere] susongyan commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "susongyan (via GitHub)" <gi...@apache.org>.
susongyan commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1669026837
> Hi @susongyan , could you supply some PostgreSQL document of
>
> > SELECT * from table WHERE receiver ?& $1 OR creater = $2;
> > parameter 1, [test@gmail.com](mailto:test@gmail.com) 2, susongyan
https://www.postgresql.org/message-id/CADK3HH+Fbr4+TBrpmK7pSbVkBei7pHmB99ANU_Km1HnjCEmO6w@mail.gmail.com
--
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
[GitHub] [shardingsphere] susongyan commented on issue #27892: [proxy] not treat "?" operator correctly in postgresql
Posted by "susongyan (via GitHub)" <gi...@apache.org>.
susongyan commented on issue #27892:
URL: https://github.com/apache/shardingsphere/issues/27892#issuecomment-1670755886
to question 1:
proxy is also a jdbc client , i think pg server doesn't case about escaped ??
PostgreSQLComParseExecutor is transfer pg origin packet to jdbc style , then pass it to pg driver to recover to pg origin packet style ; it's pg driver's jdbc escape int client side
origin pg packet from node:
SELECT * from table WHERE receiver ?& $1 OR creater = $2;
proxy convert it to :
SELECT * from table WHERE receiver ??& ? OR creater = ?;
pg driver recover it and send to pg server:
SELECT * from table WHERE receiver ?& $1 OR creater = $2;
to question2 :
Parser.parseJdbcSql used in SetupQueryRunner( set variables ) and CachedQueryCreateAction( lrucache, common sql)
--
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