FlyingZC opened a new issue, #26006:
URL: https://github.com/apache/shardingsphere/issues/26006

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   Master.
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   Proxy.
   
   ### Expected behavior
   Execute sql successful.
   
   ### Actual behavior
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   ```sql
   SELECT t.tableoid, t.oid, t.typname, t.typnamespace, (SELECT 
pg_catalog.array_agg(acl ORDER BY row_n) FROM (SELECT acl, row_n FROM 
pg_catalog.unnest(coalesce(t.typacl,pg_catalog.acldefault('T',t.typowner))) 
WITH ORDINALITY AS perm(acl,row_n) WHERE NOT EXISTS ( SELECT 1 FROM 
pg_catalog.unnest(coalesce(pip.initprivs,pg_catalog.acldefault('T',t.typowner)))
 AS init(init_acl) WHERE acl = init_acl)) as foo) AS typacl, (SELECT 
pg_catalog.array_agg(acl ORDER BY row_n) FROM (SELECT acl, row_n FROM 
pg_catalog.unnest(coalesce(pip.initprivs,pg_catalog.acldefault('T',t.typowner)))
 WITH ORDINALITY AS initp(acl,row_n) WHERE NOT EXISTS ( SELECT 1 FROM 
pg_catalog.unnest(coalesce(t.typacl,pg_catalog.acldefault('T',t.typowner))) AS 
permp(orig_acl) WHERE acl = orig_acl)) as foo) AS rtypacl, NULL AS inittypacl, 
NULL AS initrtypacl, (SELECT rolname FROM pg_catalog.pg_roles WHERE oid = 
t.typowner) AS rolname, t.typelem, t.typrelid, CASE WHEN t.typrelid = 0 THEN ' 
'::"char" ELSE (SELECT relkind FROM pg_c
 lass WHERE oid = t.typrelid) END AS typrelkind, t.typtype, t.typisdefined, 
t.typname[0] = '_' AND t.typelem != 0 AND (SELECT typarray FROM pg_type te 
WHERE oid = t.typelem) = t.oid AS isarray FROM pg_type t LEFT JOIN 
pg_init_privs pip ON (t.oid = pip.objoid AND pip.classoid = 'pg_type'::regclass 
AND pip.objsubid = 0) 
   ```
   
   ```
   [WARN ] 2023-06-02 11:41:02.431 [ShardingSphere-Command-0] 
o.a.s.p.f.p.c.q.s.PostgreSQLComQueryExecutor - PostgreSQLComQueryExecutor: 
SELECT t.tableoid, t.oid, t.typname, t.typnamespace, (SELECT 
pg_catalog.array_agg(acl ORDER BY row_n) FROM (SELECT acl, row_n FROM 
pg_catalog.unnest(coalesce(t.typacl,pg_catalog.acldefault('T',t.typowner))) 
WITH ORDINALITY AS perm(acl,row_n) WHERE NOT EXISTS ( SELECT 1 FROM 
pg_catalog.unnest(coalesce(pip.initprivs,pg_catalog.acldefault('T',t.typowner)))
 AS init(init_acl) WHERE acl = init_acl)) as foo) AS typacl, (SELECT 
pg_catalog.array_agg(acl ORDER BY row_n) FROM (SELECT acl, row_n FROM 
pg_catalog.unnest(coalesce(pip.initprivs,pg_catalog.acldefault('T',t.typowner)))
 WITH ORDINALITY AS initp(acl,row_n) WHERE NOT EXISTS ( SELECT 1 FROM 
pg_catalog.unnest(coalesce(t.typacl,pg_catalog.acldefault('T',t.typowner))) AS 
permp(orig_acl) WHERE acl = orig_acl)) as foo) AS rtypacl, NULL AS inittypacl, 
NULL AS initrtypacl, (SELECT rolname FROM pg_catalog.pg_rol
 es WHERE oid = t.typowner) AS rolname, t.typelem, t.typrelid, CASE WHEN 
t.typrelid = 0 THEN ' '::"char" ELSE (SELECT relkind FROM pg_class WHERE oid = 
t.typrelid) END AS typrelkind, t.typtype, t.typisdefined, t.typname[0] = '_' 
AND t.typelem != 0 AND (SELECT typarray FROM pg_type te WHERE oid = t.typelem) 
= t.oid AS isarray FROM pg_type t LEFT JOIN pg_init_privs pip ON (t.oid = 
pip.objoid AND pip.classoid = 'pg_type'::regclass AND pip.objsubid = 0) ;
   [ERROR] 2023-06-02 11:43:17.550 [ShardingSphere-Command-0] 
o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
   java.lang.NullPointerException: null
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitColumnref(PostgreSQLStatementVisitor.java:504)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitColumnref(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$ColumnrefContext.accept(PostgreSQLStatementParser.java:17290)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitCExpr(PostgreSQLStatementVisitor.java:381)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitCExpr(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$CExprContext.accept(PostgreSQLStatementParser.java:16526)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitAExpr(PostgreSQLStatementVisitor.java:289)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitAExpr(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$AExprContext.accept(PostgreSQLStatementParser.java:15448)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.createBinaryOperationSegment(PostgreSQLStatementVisitor.java:372)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitAExpr(PostgreSQLStatementVisitor.java:305)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitAExpr(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$AExprContext.accept(PostgreSQLStatementParser.java:15448)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.createBinaryOperationSegment(PostgreSQLStatementVisitor.java:372)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitAExpr(PostgreSQLStatementVisitor.java:305)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitAExpr(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$AExprContext.accept(PostgreSQLStatementParser.java:15448)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.createBinaryOperationSegment(PostgreSQLStatementVisitor.java:372)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitAExpr(PostgreSQLStatementVisitor.java:305)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitAExpr(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$AExprContext.accept(PostgreSQLStatementParser.java:15448)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.createProjectionSegment(PostgreSQLStatementVisitor.java:1043)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitTargetEl(PostgreSQLStatementVisitor.java:1026)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitTargetEl(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$TargetElContext.accept(PostgreSQLStatementParser.java:8005)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitTargetList(PostgreSQLStatementVisitor.java:1019)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitTargetList(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$TargetListContext.accept(PostgreSQLStatementParser.java:7924)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitSimpleSelect(PostgreSQLStatementVisitor.java:950)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitSimpleSelect(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SimpleSelectContext.accept(PostgreSQLStatementParser.java:5675)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitSelectClauseN(PostgreSQLStatementVisitor.java:918)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitSelectClauseN(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SelectClauseNContext.accept(PostgreSQLStatementParser.java:5510)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitSelectNoParens(PostgreSQLStatementVisitor.java:886)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitSelectNoParens(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SelectNoParensContext.accept(PostgreSQLStatementParser.java:5303)
        at 
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitSelect(PostgreSQLStatementVisitor.java:879)
        at 
org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementVisitor.visitSelect(PostgreSQLStatementVisitor.java:203)
        at 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$SelectContext.accept(PostgreSQLStatementParser.java:5180)
        at 
org.apache.shardingsphere.sql.parser.api.SQLStatementVisitorEngine.visit(SQLStatementVisitorEngine.java:48)
        at 
org.apache.shardingsphere.infra.parser.sql.SQLStatementParserExecutor.parse(SQLStatementParserExecutor.java:46)
        at 
org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine.parse(SQLStatementParserEngine.java:47)
        at 
org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine.parse(ShardingSphereSQLParserEngine.java:52)
        at 
org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandlerFactory.newInstance(ProxyBackendHandlerFactory.java:88)
        at 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor.<init>(PostgreSQLComQueryExecutor.java:74)
        at 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecutorFactory.getCommandExecutor(PostgreSQLCommandExecutorFactory.java:112)
        at 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecutorFactory.newInstance(PostgreSQLCommandExecutorFactory.java:77)
        at 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecuteEngine.getCommandExecutor(PostgreSQLCommandExecuteEngine.java:66)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:120)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
        at com.alibaba.ttl.TtlRunnable.run(TtlRunnable.java:60)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
   
   ```
   ### Example codes for reproduce this issue (such as a github link).
   ```sql
   postgres=# create table t2(id name);
   CREATE TABLE
   
   postgres=# insert into t2 values('test');
   INSERT 0 1
   
   -- It reports NPE in ShardingSphere-Proxy
   postgres=# select * from t2 where t2.id[0]='t';
   ```
   


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