Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.5, 10.6, 10.7
-
None
Description
--source include/have_innodb.inc
|
|
CREATE TABLE t1 (a INT, b INT, c INT, KEY(a), KEY(c)) ENGINE=InnoDB; |
INSERT INTO t1 VALUES (NULL,1,NULL),(2,2,2); |
|
SET optimizer_switch= 'not_null_range_scan=on'; |
|
SELECT COUNT(*) FROM t1 WHERE GREATEST(DEFAULT(a),b,c) > 0; |
|
# Cleanup
|
DROP TABLE t1; |
10.5 4d53a758 |
mariadbd: /data/src/10.5/storage/innobase/handler/ha_innodb.cc:7366: void ha_innobase::build_template(bool): Assertion `m_prebuilt->idx_cond_n_cols > 0' failed.
|
210514 18:07:55 [ERROR] mysqld got signal 6 ;
|
|
#7 0x00007fc46b728f36 in __GI___assert_fail (assertion=0x55d54c57b330 "m_prebuilt->idx_cond_n_cols > 0", file=0x55d54c576c68 "/data/src/10.5/storage/innobase/handler/ha_innodb.cc", line=7366, function=0x55d54c57b288 "void ha_innobase::build_template(bool)") at assert.c:101
|
#8 0x000055d54bc8abc1 in ha_innobase::build_template (this=0x7fc428230f10, whole_row=false) at /data/src/10.5/storage/innobase/handler/ha_innodb.cc:7366
|
#9 0x000055d54bc8f41d in ha_innobase::change_active_index (this=0x7fc428230f10, keynr=0) at /data/src/10.5/storage/innobase/handler/ha_innodb.cc:9082
|
#10 0x000055d54bc8e3d4 in ha_innobase::index_init (this=0x7fc428230f10, keynr=0) at /data/src/10.5/storage/innobase/handler/ha_innodb.cc:8652
|
#11 0x000055d54b3db550 in handler::ha_index_init (this=0x7fc428230f10, idx=0, sorted=true) at /data/src/10.5/sql/handler.h:3352
|
#12 0x000055d54b9bff49 in QUICK_RANGE_SELECT::reset (this=0x7fc428058a00) at /data/src/10.5/sql/opt_range.cc:12579
|
#13 0x000055d54b51d891 in join_init_read_record (tab=0x7fc428019790) at /data/src/10.5/sql/sql_select.cc:21753
|
#14 0x000055d54b51b4fb in sub_select (join=0x7fc428017440, join_tab=0x7fc428019790, end_of_records=false) at /data/src/10.5/sql/sql_select.cc:20822
|
#15 0x000055d54b51a9f4 in do_select (join=0x7fc428017440, procedure=0x0) at /data/src/10.5/sql/sql_select.cc:20359
|
#16 0x000055d54b4ee010 in JOIN::exec_inner (this=0x7fc428017440) at /data/src/10.5/sql/sql_select.cc:4505
|
#17 0x000055d54b4ed131 in JOIN::exec (this=0x7fc428017440) at /data/src/10.5/sql/sql_select.cc:4285
|
#18 0x000055d54b4ee97d in mysql_select (thd=0x7fc428000db8, tables=0x7fc428015aa0, fields=..., conds=0x7fc4280168f0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fc428017418, unit=0x7fc428004f70, select_lex=0x7fc4280153d8) at /data/src/10.5/sql/sql_select.cc:4761
|
#19 0x000055d54b4de2e1 in handle_select (thd=0x7fc428000db8, lex=0x7fc428004ea8, result=0x7fc428017418, setup_tables_done_option=0) at /data/src/10.5/sql/sql_select.cc:443
|
#20 0x000055d54b4a0859 in execute_sqlcom_select (thd=0x7fc428000db8, all_tables=0x7fc428015aa0) at /data/src/10.5/sql/sql_parse.cc:6313
|
#21 0x000055d54b497b81 in mysql_execute_command (thd=0x7fc428000db8) at /data/src/10.5/sql/sql_parse.cc:4009
|
#22 0x000055d54b4a5708 in mysql_parse (thd=0x7fc428000db8, rawbuf=0x7fc428015300 "SELECT COUNT(*) FROM t1 WHERE GREATEST(DEFAULT(a),b,c) > 0", length=58, parser_state=0x7fc464983490, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:8099
|
#23 0x000055d54b49167f in dispatch_command (command=COM_QUERY, thd=0x7fc428000db8, packet=0x7fc42800b5b9 "", packet_length=58, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1891
|
#24 0x000055d54b48fe71 in do_command (thd=0x7fc428000db8) at /data/src/10.5/sql/sql_parse.cc:1370
|
#25 0x000055d54b63fbb1 in do_handle_one_connection (connect=0x55d54f05dec8, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1410
|
#26 0x000055d54b63f914 in handle_one_connection (arg=0x55d54f04aeb8) at /data/src/10.5/sql/sql_connect.cc:1312
|
#27 0x000055d54bba40ef in pfs_spawn_thread (arg=0x55d54f092368) at /data/src/10.5/storage/perfschema/pfs.cc:2201
|
#28 0x00007fc46bc40609 in start_thread (arg=<optimized out>) at pthread_create.c:477
|
#29 0x00007fc46b814293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
|
Reproducible on 10.5-10.6 debug builds, also on older 10.5, at least 10.5.4; probably ever since the optimizer flag was introduced, although I didn't check earlier versions.
Not applicable to pre-10.5 due to not_null_range_scan, and if there is a way to modify the test case to avoid using it, I haven't found one.
rowid_filter=on is also important for the failure (it is ON by default, so not set in the test case).
No obvious problem on a non-debug build, it returns 0 as I would expect. No obvious problem with MyISAM instead of InnoDB.
Plan for the query from the test case above:
EXPLAIN EXTENDED SELECT COUNT(*) FROM t1 WHERE GREATEST(DEFAULT(a),b,c) > 0;
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
1 SIMPLE t1 range|filter NULL a|c 5|5 NULL 1 (50%) 50.00 Using where; Using rowid filter
|
Warnings:
|
Note 1003 select count(0) AS `COUNT(*)` from `test`.`t1` where greatest(<cache>(default(`test`.`t1`.`a`)),`test`.`t1`.`b`,`test`.`t1`.`c`) > 0
|