SQLAdvisor icon indicating copy to clipboard operation
SQLAdvisor copied to clipboard

Segmentation fault

Open wakaka2017 opened this issue 8 years ago • 13 comments

1.OS version:CentOS release 6.5 (Final) MySQL version:5.7.16-log

2.error 2017-03-10 14:41:26 18622 [Note] 第1步: 对SQL解析优化之后得到的SQL:select count(1) AS COUNT(1) from (mydb.archive a left join mydb.archive_detail ad on((a.id = ad.archive_id))) where (a.user_id = 231) 2017-03-10 14:41:26 18622 [Note] 第2步:开始解析where中的条件:(a.user_id = 231) 2017-03-10 14:41:26 18622 [Note] show index from archive 2017-03-10 14:41:26 18622 [Note] show table status like 'archive' 2017-03-10 14:41:26 18622 [Note] select count(*) from ( select user_id from archive FORCE INDEX( PRIMARY ) order by id DESC limit 4) a where (a.user_id = 231)
2017-03-10 14:41:26 18622 [Note] 第3步:表archive的行数:9,limit行数:4,得到where条件中(a.user_id = 231)的选择度:4 2017-03-10 14:41:26 18622 [Note] 第4步:开始解析join on条件:a.id=ad.archive_id 2017-03-10 14:41:26 18622 [Note] 第5步:开始选择驱动表,一共有1个候选驱动表 2017-03-10 14:41:26 18622 [Note] explain select * from archive Segmentation fault

3.table ddl CREATE TABLE archive ( id bigint(20) NOT NULL AUTO_INCREMENT, signed_summary_id bigint(20) DEFAULT NULL, user_id bigint(20) DEFAULT NULL, tilte varchar(200) DEFAULT NULL, archive_type int(11) DEFAULT NULL, archive_date date DEFAULT NULL, created1 bigint(20) DEFAULT NULL, created2 varchar(50) DEFAULT NULL, created_date datetime DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=270 DEFAULT CHARSET=utf8mb4;

CREATE TABLE archive_detail ( id bigint(20) NOT NULL AUTO_INCREMENT, archive_id bigint(20) DEFAULT NULL, archive_type int(11) DEFAULT NULL, archive_type_name varchar(20) DEFAULT NULL, content varchar(2000) DEFAULT NULL, pic varchar(200) DEFAULT NULL, voice varchar(2000) DEFAULT NULL, created_date datetime DEFAULT NULL, service_remark int(5) DEFAULT '0', PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=420 DEFAULT CHARSET=utf8mb4;

wakaka2017 avatar Mar 10 '17 07:03 wakaka2017

同问

Zhifeiyu avatar Mar 23 '17 11:03 Zhifeiyu

请问这个问题解决了吗, 我也碰到同样的问题

linmoyu avatar Apr 11 '17 01:04 linmoyu

关注这个问题

pandakll avatar Apr 27 '17 08:04 pandakll

同问

imuse2012 avatar May 05 '17 01:05 imuse2012

工具基于mysql5.7的bug吧,5.6没问题

pandakll avatar May 05 '17 09:05 pandakll

同5.7也出现了

nbsky avatar May 21 '17 03:05 nbsky

这个问题我简单修改下代码可以不出现这个错误了:

把322行左右的下面文本: if ((row = mysql_fetch_row(result))) { result_set_count = atoi(row[EXPLAIN_ROWS]); } 修改为: if ((row = mysql_fetch_row(result))) { if (row[EXPLAIN_ROWS]!=NULL) { result_set_count = atoi(row[EXPLAIN_ROWS]); } }

empo007 avatar Dec 05 '17 06:12 empo007

好的,谢谢!

[email protected]

From: empo007 Date: 2017-12-05 14:39 To: Meituan-Dianping/SQLAdvisor CC: Subscribed Subject: Re: [Meituan-Dianping/SQLAdvisor] Segmentation fault (#3) 这个问题我简单修改下代码可以不出现这个错误了: 把322行左右的下面文本: if ((row = mysql_fetch_row(result))) { result_set_count = atoi(row[EXPLAIN_ROWS]); } 修改为: if ((row = mysql_fetch_row(result))) { if (row[EXPLAIN_ROWS]!=NULL) { result_set_count = atoi(row[EXPLAIN_ROWS]); } } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

leiyifang avatar Dec 05 '17 06:12 leiyifang

关注这个问题

jpfss avatar Jan 09 '18 09:01 jpfss

修改哪个文件?

jpfss avatar Jan 09 '18 09:01 jpfss

出现这个问题是因为mysql 5.7 的执行计划默认返回的字段和5.7 以前的不同。工具不能正常判断出执行计划范围的影响行数,所以报错。按照empo007 的方法改,虽然不出错了,但是也失去了针对join的进一步分析的功能。

shihuizhen avatar Jan 09 '18 09:01 shihuizhen

同样出现错误,持续关注中。Mysql环境 5.7

jakehu avatar May 19 '18 08:05 jakehu

同出现此问题 mysql5.7 上面改代码的方式验证有效

dev-zhangchenxi avatar Jun 23 '20 10:06 dev-zhangchenxi