Open bqwzhl20 opened 6 years ago
这是在确认sql的开始位置出错了,方便提供一下sql语句么,应该是中间有sql语句为空的字符串
@tuteng 我这边也遇到同样的问题, sqlinfo["sample"]=u'commit',导致temp=[],index = min(temp)报错,具体信息如下
# 去除sql语句最前边的无用信息
explain_sql = sqlinfo["sample"]
index = 0
temp = []
for key in ["SELECT", "UPDATE", "DELETE", "INSERT"]:
temp.append(explain_sql.upper().find(key))
temp = list(set(temp))
if -1 in temp:
temp.remove(-1)
index = min(temp)
explain_sql = explain_sql[index:]
对几个mysql数据库的sqlplan进行审核,只有1个审核时报错,错误信息如下:
[2017-12-21 17:27:49,684: ERROR/MainProcess] Task task_other.analysis[b1bf2ce1-2530-4b0b-9b2c-1493197b76bc] raised unexpected: ValueErro r('min() arg is an empty sequence',) Traceback (most recent call last): File "/home/themis-test/python-project/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(*args, *kwargs) File "/home/themis-test/python-project/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__ return self.run(args, kwargs) File "/home/themis-test/Themis/task_other.py", line 15, in analysis command.run_analysis(args) File "/home/themis-test/Themis/command.py", line 214, in run_analysis job_record = themis.run(**job_args) File "/home/themis-test/Themis/rule_analysis/themis.py", line 285, in run hostname, user, passwd) File "/home/themis-test/Themis/rule_analysis/themis.py", line 126, in m_rule_parse self.mys.get_sql_plan(user, passwd) File "/home/themis-test/Themis/rule_analysis/libs/mysql_plan_stat/plan_stat.py", line 100, in get_sql_plan plan = self.get_json_sqlplan_from_mysql(sqlinfo, user, passwd) File "/home/themis-test/Themis/rule_analysis/libs/mysql_plan_stat/plan_stat.py", line 131, in get_json_sqlplan_from_mysql index = min(temp) ValueError: min() arg is an empty sequence