Thanks to visit codestin.com
Credit goes to github.com

Skip to content

规则:使用联合索引时,必须使用联合索引的首字段;禁止对联合索引左侧字段进行IN 、OR等非等值查询;发生报错 #2169

@hasa1K

Description

@hasa1K

SQLe Version

Describe the bug
扫描任务点击立即审核发生报错
image

由于前侧使用的是客户环境的sql,没有办法确定是哪条sql发生报错

根据报错内容定位到这两条规则:使用联合索引时,必须使用联合索引的首字段;禁止对联合索引左侧字段进行IN 、OR等非等值查询
这两个规则使用了同一个函数,所以可以一起进行排查。

  1. 定位报错函数
    image

  2. 函数内部遇到空的tables或者tables中的没有ast.TableName类型的变量直接返回err
    image

  3. 主函数中获取tables是通过util.GetTableSources函数获取
    image

猜测是审核了只有子查询的sql语句导致的错误;例如:
select * from (select * from users) u where u.last_name='1'

本地验证出该问题
image

To Reproduce

Expected behavior

Suggestion

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpublish-pre2verifiedthe issue all pr is verified

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions