You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/05/27 04:10:30 UTC

[GitHub] [shardingsphere] wenmingwei opened a new issue #5802: "ClassCastException" during parsing SQL

wenmingwei opened a new issue #5802:
URL: https://github.com/apache/shardingsphere/issues/5802


   ## Bug Report
   
   while parsing SQL like below sharding proxy throws an exception "ClassCastException"
   
   ```sql
   SELECT t.typname,t.oid FROM pg_catalog.pg_type t JOIN pg_catalog.pg_namespace n ON (t.typnamespace = n.oid)  WHERE n.nspname  != 'pg_toast' AND  (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid))
   ```
   
   Exception stack trace
   
   ```
   [ERROR] 18:40:50.216 [pool-326-thread-1] o.a.s.s.f.c.CommandExecutorTask - Exception occur: 
   java.lang.ClassCastException: org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.PredicateSegment cannot be cast to org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.simple.LiteralExpressionSegment
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.createProjection(PostgreSQLDMLVisitor.java:383)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitProjection(PostgreSQLDMLVisitor.java:345)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitProjection(PostgreSQLDMLVisitor.java:112)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$ProjectionContext.accept(PostgreSQLStatementParser.java:2413)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitProjections(PostgreSQLDMLVisitor.java:321)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitProjections(PostgreSQLDMLVisitor.java:112)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$ProjectionsContext.accept(PostgreSQLStatementParser.java:2150)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitSelectClause(PostgreSQLDMLVisitor.java:260)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitSelectClause(PostgreSQLDMLVisitor.java:112)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SelectClauseContext.accept(PostgreSQLStatementParser.java:1987)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitUnionClause(PostgreSQLDMLVisitor.java:253)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitUnionClause(PostgreSQLDMLVisitor.java:112)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$UnionClauseContext.accept(PostgreSQLStatementParser.java:1894)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementBaseVisitor.visitSubquery(PostgreSQLStatementBaseVisitor.java:286)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SubqueryContext.accept(PostgreSQLStatementParser.java:3705)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitSimpleExpr(PostgreSQLVisitor.java:394)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitSimpleExpr(PostgreSQLVisitor.java:113)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SimpleExprContext.accept(PostgreSQLStatementParser.java:6259)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitBitExpr(PostgreSQLVisitor.java:359)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitBitExpr(PostgreSQLVisitor.java:113)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$BitExprContext.accept(PostgreSQLStatementParser.java:6024)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitPredicate(PostgreSQLVisitor.java:299)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitPredicate(PostgreSQLVisitor.java:113)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$PredicateContext.accept(PostgreSQLStatementParser.java:5814)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitBooleanPrimary(PostgreSQLVisitor.java:256)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitBooleanPrimary(PostgreSQLVisitor.java:113)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$BooleanPrimaryContext.accept(PostgreSQLStatementParser.java:5588)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitExpr(PostgreSQLVisitor.java:241)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitExpr(PostgreSQLVisitor.java:113)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$ExprContext.accept(PostgreSQLStatementParser.java:5384)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitExpr(PostgreSQLVisitor.java:244)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitExpr(PostgreSQLVisitor.java:113)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$ExprContext.accept(PostgreSQLStatementParser.java:5384)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitExpr(PostgreSQLVisitor.java:247)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitExpr(PostgreSQLVisitor.java:113)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$ExprContext.accept(PostgreSQLStatementParser.java:5384)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitExpr(PostgreSQLVisitor.java:244)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLVisitor.visitExpr(PostgreSQLVisitor.java:113)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$ExprContext.accept(PostgreSQLStatementParser.java:5384)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitWhereClause(PostgreSQLDMLVisitor.java:486)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitWhereClause(PostgreSQLDMLVisitor.java:112)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$WhereClauseContext.accept(PostgreSQLStatementParser.java:3257)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitSelectClause(PostgreSQLDMLVisitor.java:271)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitSelectClause(PostgreSQLDMLVisitor.java:112)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SelectClauseContext.accept(PostgreSQLStatementParser.java:1987)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitUnionClause(PostgreSQLDMLVisitor.java:253)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitUnionClause(PostgreSQLDMLVisitor.java:112)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$UnionClauseContext.accept(PostgreSQLStatementParser.java:1894)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitSelect(PostgreSQLDMLVisitor.java:245)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.impl.PostgreSQLDMLVisitor.visitSelect(PostgreSQLDMLVisitor.java:112)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SelectContext.accept(PostgreSQLStatementParser.java:1843)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse0(SQLParserEngine.java:80)
   	at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse(SQLParserEngine.java:61)
   	at org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandlerFactory.newInstance(TextProtocolBackendHandlerFactory.java:69)
   	at org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.query.text.PostgreSQLComQueryExecutor.<init>(PostgreSQLComQueryExecutor.java:60)
   	at org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandExecutorFactory.java:58)
   	at org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.PostgreSQLCommandExecuteEngine.getCommandExecutor(PostgreSQLCommandExecuteEngine.java:60)
   	at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:92)
   	at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   	at java.lang.Thread.run(Thread.java:748)
   
   ```
   
   ### Which version of ShardingSphere did you use?
   4.1.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   proposal demo, ShardingSphere-proxy
   
   ### Expected behavior
   return results of SQL without exception
   
   ### Actual behavior
   exception while parsing sql.
   
   ### Reason analyze (If you can)
   
   None
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   1. connect with psql
   2. execute supplied sql
   3. then we will get ClassCastException.
   
   ### 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] goodliukai commented on issue #5802: "ClassCastException" during parsing SQL

Posted by GitBox <gi...@apache.org>.
goodliukai commented on issue #5802:
URL: https://github.com/apache/shardingsphere/issues/5802#issuecomment-639278365


   I also have this problem。 Lower vesion  like 4.0.0 is ok.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero closed issue #5802: "ClassCastException" during parsing SQL

Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #5802:
URL: https://github.com/apache/shardingsphere/issues/5802


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on issue #5802: "ClassCastException" during parsing SQL

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #5802:
URL: https://github.com/apache/shardingsphere/issues/5802#issuecomment-634378639


   I'll track this problem.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wenmingwei commented on issue #5802: "ClassCastException" during parsing SQL

Posted by GitBox <gi...@apache.org>.
wenmingwei commented on issue #5802:
URL: https://github.com/apache/shardingsphere/issues/5802#issuecomment-635139499


   another sql which cannot be parsed:
   
   ```sql
   SELECT typinput='array_in'::regproc as is_array, typtype, typname   FROM pg_catalog.pg_type   LEFT JOIN (select ns.oid as nspoid, ns.nspname, r.r           from pg_namespace as ns           join ( select s.r, (current_schemas(false))[s.r] as nspname                    from generate_series(1, array_upper(current_schemas(false), 1)) as s(r) ) as r          using ( nspname )        ) as sp     ON sp.nspoid = typnamespace  ORDER BY sp.r, pg_type.oid DESC
   ```


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org