shardingsphere
shardingsphere copied to clipboard
Sharding-JDBC 4.0.0-RC2 not support '~' Operator of PostgreSQL
Bug Report
Which version of ShardingSphere did you use?
4.0.0-RC2 4.0.0-RC3
Which project did you use? Sharding-JDBC or Sharding-Proxy?
Sharding-JDBC
Expected behavior
org.apache.shardingsphere.core.exception.ShardingException: Cannot support multiple schemas in one SQL
at org.apache.shardingsphere.core.optimize.api.segment.Tables.setSchema(Tables.java:61)
at org.apache.shardingsphere.core.optimize.api.segment.Tables.<init>(Tables.java:53)
at org.apache.shardingsphere.core.optimize.sharding.segment.condition.engine.WhereClauseShardingConditionEngine.createShardingConditions(WhereClauseShardingConditionEngine.java:76)
at org.apache.shardingsphere.core.optimize.sharding.engnie.dml.ShardingSelectOptimizeEngine.optimize(ShardingSelectOptimizeEngine.java:58)
at org.apache.shardingsphere.core.optimize.sharding.engnie.dml.ShardingSelectOptimizeEngine.optimize(ShardingSelectOptimizeEngine.java:47)
at org.apache.shardingsphere.core.route.router.sharding.ParsingSQLRouter.route(ParsingSQLRouter.java:72)
at org.apache.shardingsphere.core.route.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:66)
at org.apache.shardingsphere.core.PreparedQueryShardingEngine.route(PreparedQueryShardingEngine.java:60)
at org.apache.shardingsphere.core.BaseShardingEngine.executeRoute(BaseShardingEngine.java:86)
at org.apache.shardingsphere.core.BaseShardingEngine.shard(BaseShardingEngine.java:70)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.shard(ShardingPreparedStatement.java:224)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:170)
SQL
select count(1)
from (
select h.id, p.id, o.id
from t_household h,
t_project p,
t_sys_org o
where h.project_id = p.id
and o.id = p.gov_org_id
and o.parent_ids ~ (',1087190707023683585,')
order by o.id) as total
Reason analyze (If you can)
If I replace ~ with LIKE, is ok.
In Tables class, the program treats alias as schema: h.id, p.id, o.id
@terrymanu Please assgin this issue to me.
@SteNicholas Thank you, assigned.
@zcqshine Your SQL was wrong which subquery used ~ operator.In PostgreSQL,~~ operator is equal to LIKE.
@zcqshine Your SQL was wrong which subquery used ~ operator.In PostgreSQL,~~ operator is equal to LIKE.
postgresql support ~ operator:
~Match regular expression, case related 'Thomas' ~'. * Thomas. *