alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.98k stars 8.58k forks source link

pgsql 语句能正常执行,但是druid报错 #4790

Open shengpj opened 2 years ago

shengpj commented 2 years ago

1.环境 数据库:PG13.4 ORM: mybatis DRUID:1.2.8 2.sql,类似下面这种

select * from XX where crf_k @?? ? @?是pg支持的操作符,,后面多加一个?是解决mybatis替换参数报错的问题,,最后一个?是占位符

3.错误输出
com.alibaba.druid.filter.stat.StatFilter : merge sql error, dbType postgresql, druid-1.2.8, sql : XXXXX
com.alibaba.druid.sql.parser.ParserException: syntax error, expect ), actual VARIANT pos 494, line 12, column 37, token VARIANT at com.alibaba.druid.sql.parser.SQLExprParser.accept(SQLExprParser.java:4567) at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:789) at com.alibaba.druid.sql.dialect.postgresql.parser.PGExprParser.primary(PGExprParser.java:152) at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:96) at com.alibaba.druid.sql.parser.SQLSelectParser.parseWhere(SQLSelectParser.java:718) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSelectParser.query(PGSelectParser.java:133) at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:61) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser.parseSelect(PGSQLStatementParser.java:418) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser.parseSelect(PGSQLStatementParser.java:30) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:213) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:114) at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:153) at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:126) at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:167) at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:694) at com.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:344) at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:124) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:568) at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:341)

2022-05-19 09:51:30,565 WARN --- [http-nio-8001-exec-1] - [ddb6bd6] com.alibaba.druid.sql.SQLUtils : rowFormat error com.alibaba.druid.sql.parser.ParserException: syntax error, expect ), actual VARIANT pos 494, line 12, column 37, token VARIANT at com.alibaba.druid.sql.parser.SQLExprParser.accept(SQLExprParser.java:4567) at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:789) at com.alibaba.druid.sql.dialect.postgresql.parser.PGExprParser.primary(PGExprParser.java:152) at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:96) at com.alibaba.druid.sql.parser.SQLSelectParser.parseWhere(SQLSelectParser.java:718) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSelectParser.query(PGSelectParser.java:133) at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:61) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser.parseSelect(PGSQLStatementParser.java:418) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser.parseSelect(PGSQLStatementParser.java:30) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:213) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:114) at com.alibaba.druid.sql.SQLUtils.format(SQLUtils.java:346) at com.alibaba.druid.sql.SQLUtils.format(SQLUtils.java:339) at com.alibaba.druid.filter.logging.LogFilter.logExecutableSql(LogFilter.java:610) at com.alibaba.druid.filter.logging.LogFilter.statementExecuteAfter(LogFilter.java:507) at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:442) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3459) at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3459) at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:167) at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:497) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)

我看有个类似的问题 以下pg语句执行通过,但是mergeSql里面报错了,可我用的是最新版本,还是有问题呢

ShenFeng312 commented 2 years ago

堆栈和sql不符。能给个demo吗

azhsmesos commented 2 years ago

postgresql和 mysql的占位符是一样的吗,会不会是这个原因

shengpj commented 2 years ago

语句其实成功执行并返回结果了,就是在druid记录执行语句报错了,,,我现在把druid日志关掉了。。。