Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
The problem appeared on 5.3 tree with the following revision:
revno: 3725 [merge]
|
revision-id: igor@askmonty.org-20131122022820-it39kqzjw8kmwd1j
|
parent: bar@mnogosearch.org-20131121074636-xiubz4tilopaqplg
|
parent: igor@askmonty.org-20131121231925-j30hvvpxpb55v67m
|
committer: Igor Babaev <igor@askmonty.org>
|
branch nick: maria-5.3-merge
|
timestamp: Thu 2013-11-21 18:28:20 -0800
|
message:
|
Merge
|
------------------------------------------------------------
|
revno: 3723.1.1
|
revision-id: igor@askmonty.org-20131121231925-j30hvvpxpb55v67m
|
parent: igor@askmonty.org-20131114212505-bou201elzcouxzo8
|
committer: Igor Babaev <igor@askmonty.org>
|
branch nick: maria-5.3-mdev5103
|
timestamp: Thu 2013-11-21 15:19:25 -0800
|
message:
|
Another attempt to fix bug mdev-5103.
|
The earlier pushed fix for the bug was incomplete. It did not remove
|
the main cause of the problem: the function remove_eq_conds()
|
removed always true multiple equalities from any conjunct, but did not
|
adjust the list of them stored in Item_cond_and::cond_equal.current_level.
|
|
Simplified the test case for the bug and moved it to another test file.
|
|
The fix triggered changes in EXPLAIN EXTENDED for some queries.
|
SET optimizer_switch = 'derived_with_keys=on,in_to_exists=on'; |
|
CREATE TABLE t1 (id INT, a2 CHAR(2), a3 CHAR(3)) ENGINE=MyISAM; |
INSERT INTO t1 VALUES (1,'BE','BEL'); |
|
CREATE TABLE t2 (id INT, a2 CHAR(2), a3 CHAR(3)) ENGINE=MyISAM; |
INSERT INTO t2 VALUES (1,'BE','BEL'),(2,'MX','MEX'); |
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT DISTINCT * FROM t2; |
|
SELECT * FROM t1 AS outer_t1, v2 |
WHERE v2.a3 = outer_t1.a3 |
AND EXISTS ( SELECT * FROM t1 WHERE a2 < v2.a2 AND id = outer_t1.id ) |
AND outer_t1.a3 < 'J' |
ORDER BY v2.id; |
Note: I don't know why derived_with_keys makes a difference, but it does.
mysqld: field.cc:6406: virtual String* Field_string::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
|
131219 0:07:43 [ERROR] mysqld got signal 6 ;
|
#6 0x00007fc734f9f621 in *__GI___assert_fail (assertion=0xcb8af0 "!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))", file=<optimized out>, line=6406, function=0xcbafa0 "virtual String* Field_string::val_str(String*, String*)") at assert.c:81
|
#7 0x0000000000667f0f in Field_string::val_str (this=0x3723818, val_buffer=0x371ef38, val_ptr=0x36ec478) at field.cc:6406
|
#8 0x00000000005a5ac4 in Item_field::val_str (this=0x36ec460, str=0x371ef38) at item.cc:2384
|
#9 0x00000000005efabd in Arg_comparator::compare_string (this=0x371eeb0) at item_cmpfunc.cc:989
|
#10 0x00000000005d0698 in Arg_comparator::compare (this=0x371eeb0) at item_cmpfunc.h:72
|
#11 0x00000000005f282c in Item_func_lt::val_int (this=0x371edf0) at item_cmpfunc.cc:1915
|
#12 0x000000000074f7e9 in do_select (join=0x3727ab8, fields=0x36eb6a0, table=0x0, procedure=0x0) at sql_select.cc:15893
|
#13 0x000000000072ee0b in JOIN::exec (this=0x3727ab8) at sql_select.cc:2788
|
#14 0x000000000063c13e in subselect_single_select_engine::exec (this=0x371f448) at item_subselect.cc:3142
|
#15 0x00000000006349c9 in Item_subselect::exec (this=0x371f318) at item_subselect.cc:588
|
#16 0x000000000063727f in Item_exists_subselect::val_bool (this=0x371f318) at item_subselect.cc:1483
|
#17 0x00000000005fbb8b in Item_cond_and::val_int (this=0x3773378) at item_cmpfunc.cc:4580
|
#18 0x00000000006fc93a in SQL_SELECT::skip_record (this=0x3771b00, thd=0x3666898) at opt_range.h:924
|
#19 0x0000000000820528 in find_all_keys (param=0x7fc72c4bb0d0, select=0x3771b00, sort_keys=0x3776c88, sort_keys_buf=0x3776ce8 "", buffpek_pointers=0x7fc72c4bb2e0, tempfile=0x7fc72c4bb150, indexfile=0x0) at filesort.cc:627
|
#20 0x000000000081f1ef in filesort (thd=0x3666898, table=0x37266f0, sortorder=0x3773718, s_length=1, select=0x3771b00, max_rows=18446744073709551615, sort_positions=false, examined_rows=0x7fc72c4bb570) at filesort.cc:247
|
#21 0x00000000007585ee in create_sort_index (thd=0x3666898, join=0x3725090, order=0x371fa00, filesort_limit=18446744073709551615, select_limit=18446744073709551615, is_order_by=false) at sql_select.cc:19342
|
#22 0x000000000072eade in JOIN::exec (this=0x3725090) at sql_select.cc:2737
|
#23 0x000000000072f6a5 in mysql_select (thd=0x3666898, rref_pointer_array=0x3669588, tables=0x36ea9a0, wild_num=1, fields=..., conds=0x371f488, og_num=1, order=0x371fa00, group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0x3725070, unit=0x3668e28, select_lex=0x3669330) at sql_select.cc:3009
|
#24 0x0000000000726105 in handle_select (thd=0x3666898, lex=0x3668d88, result=0x3725070, setup_tables_done_option=0) at sql_select.cc:288
|
#25 0x00000000006b4dec in execute_sqlcom_select (thd=0x3666898, all_tables=0x36ea9a0) at sql_parse.cc:5172
|
#26 0x00000000006abf88 in mysql_execute_command (thd=0x3666898) at sql_parse.cc:2305
|
#27 0x00000000006b7753 in mysql_parse (thd=0x3666898, rawbuf=0x36ea670 "SELECT * FROM t1 AS outer_t1, v2 \nWHERE v2.a3 = outer_t1.a3 \nAND EXISTS ( SELECT * FROM t1 WHERE a2 < v2.a2 AND id = outer_t1.id )\nAND outer_t1.a3 < 'J' \nORDER BY v2.id", length=172, found_semicolon=0x7fc72c4bccb8) at sql_parse.cc:6173
|
#28 0x00000000006a9768 in dispatch_command (command=COM_QUERY, thd=0x3666898, packet=0x36e1319 "SELECT * FROM t1 AS outer_t1, v2 \nWHERE v2.a3 = outer_t1.a3 \nAND EXISTS ( SELECT * FROM t1 WHERE a2 < v2.a2 AND id = outer_t1.id )\nAND outer_t1.a3 < 'J' \nORDER BY v2.id", packet_length=172) at sql_parse.cc:1243
|
#29 0x00000000006a8a54 in do_command (thd=0x3666898) at sql_parse.cc:923
|
#30 0x00000000006a58dd in handle_one_connection (arg=0x3666898) at sql_connect.cc:1231
|
#31 0x00007fc735cabb50 in start_thread (arg=<optimized out>) at pthread_create.c:304
|
#32 0x00007fc73504ea7d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
|
Stack trace from:
revision-id: sanja@askmonty.org-20131218135951-agw2htf09w418t91
|
revno: 3737
|
branch-nick: 5.3
|
Also reproducible on 5.5, 10.0 trees.
Here is another test case, which also started failing from the same revision on 5.3, and causes a similar assertion, but does not require derived_with_keys (or any other specific optimizer_switch values):
mysqld: field.cc:3664: virtual longlong Field_long::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
140131 18:59:50 [ERROR] mysqld got signal 6 ;
#6 0x00007ff6d9788621 in *__GI___assert_fail (assertion=0xcb8970 "!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))", file=<optimized out>, line=3664, function=0xcbbca0 "virtual longlong Field_long::val_int()") at assert.c:81
#7 0x000000000065de99 in Field_long::val_int (this=0x27992d8) at field.cc:3664
#8 0x00000000005a5c15 in Item_field::val_int (this=0x2804dc8) at item.cc:2402
#9 0x00000000005b1f8f in Item_direct_ref::val_int (this=0x2799b60) at item.cc:6984
#10 0x00000000005b1f8f in Item_direct_ref::val_int (this=0x2793dc8) at item.cc:6984
#11 0x00000000005f05db in Arg_comparator::compare_int_signed (this=0x275e478) at item_cmpfunc.cc:1171
#12 0x00000000005d0638 in Arg_comparator::compare (this=0x275e478) at item_cmpfunc.h:72
#13 0x00000000005f2804 in Item_func_lt::val_int (this=0x275e3b8) at item_cmpfunc.cc:1915
#14 0x000000000074f5f3 in do_select (join=0x2793560, fields=0x27938f0, table=0x0, procedure=0x0) at sql_select.cc:15891
#15 0x000000000072ec15 in JOIN::exec (this=0x2793560) at sql_select.cc:2786
#16 0x000000000063bfa2 in subselect_single_select_engine::exec (this=0x275e798) at item_subselect.cc:3142
#17 0x000000000063482d in Item_subselect::exec (this=0x275e658) at item_subselect.cc:588
#18 0x0000000000636046 in Item_singlerow_subselect::val_int (this=0x275e658) at item_subselect.cc:1155
#19 0x00000000005bbc7b in Item::val_int_result (this=0x275e658) at item.h:872
#20 0x0000000000820ec9 in make_sortkey (param=0x7ff6d0ca40d0, to=0x281a258 "\220\263\201\002", ref_pos=0x27993a0 "8Ɓ\002") at filesort.cc:867
#21 0x0000000000820510 in find_all_keys (param=0x7ff6d0ca40d0, select=0x2802c00, sort_keys=0x281a1f8, sort_keys_buf=0x281a258 "\220\263\201\002", buffpek_pointers=0x7ff6d0ca42e0, tempfile=0x7ff6d0ca4150, indexfile=0x0) at filesort.cc:648
#22 0x000000000081f0c7 in filesort (thd=0x26d8b88, table=0x27981f0, sortorder=0x28055b8, s_length=1, select=0x2802c00, max_rows=18446744073709551615, sort_positions=false, examined_rows=0x7ff6d0ca4570) at filesort.cc:247
#23 0x000000000075840b in create_sort_index (thd=0x26d8b88, join=0x27923e8, order=0x2791e78, filesort_limit=18446744073709551615, select_limit=18446744073709551615, is_order_by=true) at sql_select.cc:19340
#24 0x000000000072e8e8 in JOIN::exec (this=0x27923e8) at sql_select.cc:2735
#25 0x000000000072f4af in mysql_select (thd=0x26d8b88, rref_pointer_array=0x26db878, tables=0x2791fb0, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x2791e78, having=0x0, proc_param=0x0, select_options=2147764736, result=0x27923c8, unit=0x26db118, select_lex=0x26db620) at sql_select.cc:3007
#26 0x0000000000725f45 in handle_select (thd=0x26d8b88, lex=0x26db078, result=0x27923c8, setup_tables_done_option=0) at sql_select.cc:288
#27 0x00000000006b4c7c in execute_sqlcom_select (thd=0x26d8b88, all_tables=0x2791fb0) at sql_parse.cc:5172
#28 0x00000000006abe18 in mysql_execute_command (thd=0x26d8b88) at sql_parse.cc:2305
#29 0x00000000006b75e3 in mysql_parse (thd=0x26d8b88, rawbuf=0x275c8c0 "SELECT ( SELECT MAX(b) FROM t1, t2 WHERE pk = a AND b < from_sq.c ) AS select_sq, COUNT( DISTINCT from_sq.c ) \nFROM ( SELECT DISTINCT t2_1.* FROM t2 AS t2_1, t2 AS t2_2 ) AS from_sq GROUP BY select_sq", length=200, found_semicolon=0x7ff6d0ca5cb8) at sql_parse.cc:6173
#30 0x00000000006a95f8 in dispatch_command (command=COM_QUERY, thd=0x26d8b88, packet=0x2753459 "SELECT ( SELECT MAX(b) FROM t1, t2 WHERE pk = a AND b < from_sq.c ) AS select_sq, COUNT( DISTINCT from_sq.c ) \nFROM ( SELECT DISTINCT t2_1.* FROM t2 AS t2_1, t2 AS t2_2 ) AS from_sq GROUP BY select_sq"..., packet_length=201) at sql_parse.cc:1243
#31 0x00000000006a88e4 in do_command (thd=0x26d8b88) at sql_parse.cc:923
#32 0x00000000006a576d in handle_one_connection (arg=0x26d8b88) at sql_connect.cc:1231
#33 0x00007ff6da494b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
#34 0x00007ff6d9837a7d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
Stack trace from:
revision-id: sanja@montyprogram.com-20140128212314-ha57mco1jb1lpsgp
revno: 3747
branch-nick: 5.3