alibaba / alibaba/druid

select 语句中的 参数值被当成关键字了

Open
#4,239 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
28.2k
Forks
8.6k
PR merge metrics
No merged PRs in 30d

Description

sql查询语句(SELECT account_id FROM `taobao_office`.`cloud_yunpan` WHERE dt='2021-04-12' AND target='update')中的 ’update‘ 参数值被当成关键字了,把’update‘ 换成其它值就不报错,最新版(druid-1.2.5.jar)也存在bug

**出错方法:**
com.alibaba.druid.sql.SQLUtils#parseStatements(java.lang.String, com.alibaba.druid.DbType)

**错误详情:**
`com.alibaba.druid.sql.parser.ParserException: ERROR. pos 87, line 1, column 82, token UPDATE

at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:1093)
at com.alibaba.druid.sql.dialect.hive.parser.HiveExprParser.primary(HiveExprParser.java:147)
at com.alibaba.druid.sql.parser.SQLExprParser.bitXor(SQLExprParser.java:129)
at com.alibaba.druid.sql.parser.SQLExprParser.multiplicative(SQLExprParser.java:225)
at com.alibaba.druid.sql.parser.SQLExprParser.additive(SQLExprParser.java:2779)
at com.alibaba.druid.sql.parser.SQLExprParser.shift(SQLExprParser.java:2825)
at com.alibaba.druid.sql.parser.SQLExprParser.bitAnd(SQLExprParser.java:2572)
at com.alibaba.druid.sql.parser.SQLExprParser.bitOr(SQLExprParser.java:2591)
at com.alibaba.druid.sql.parser.SQLExprParser.relationalRest(SQLExprParser.java:3080)
at com.alibaba.druid.sql.parser.SQLExprParser.relational(SQLExprParser.java:3068)
at com.alibaba.druid.sql.parser.SQLExprParser.andRest(SQLExprParser.java:2919)
at com.alibaba.druid.sql.parser.SQLSelectParser.parseWhere(SQLSelectParser.java:681)
at com.alibaba.druid.sql.parser.SQLSelectParser.query(SQLSelectParser.java:449)
at com.alibaba.druid.sql.parser.SQLSelectParser.query(SQLSelectParser.java:378)
at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:61)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseSelect(SQLStatementParser.java:4190)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:204)
at com.alibaba.druid.sql.SQLUtils.parseStatements(SQLUtils.java:562)
at com.alibaba.druid.sql.SQLUtils.parseStatements(SQLUtils.java:584)`

Contributor guide

Open the contributing guide

Research direction

Start with the SQLUtils#parseStatements entry point and the SQLExprParser.primary and HiveExprParser.primary frames named in the report. Reproduce the SELECT using target='update', then trace why UPDATE is treated as a token rather than a quoted value. Done means this query parses successfully while keyword handling remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.