[MDEV-10716] Assertion `real_type() != FIELD_ITEM' failed in Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**) Created: 2016-08-31  Updated: 2016-09-28  Resolved: 2016-09-28

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.1
Fix Version/s: 10.1.18

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Sprint: 10.1.18

 Description   

CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (1),(2);
SELECT i, COUNT(*) FROM t1 GROUP BY i HAVING i AND 1;

Stack trace from 10.1 f6e47c0031 (post-10.1.17)

mysqld: /data/src/10.1/sql/item.h:3927: virtual COND* Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**): Assertion `real_type() != FIELD_ITEM' failed.
160901  2:16:55 [ERROR] mysqld got signal 6 ;

#7  0x00007f37a6493312 in __GI___assert_fail (assertion=0x7f37a95a09a4 "real_type() != FIELD_ITEM", file=0x7f37a95a090e "/data/src/10.1/sql/item.h", line=3927, function=0x7f37a95a4340 <Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**)::__PRETTY_FUNCTION__> "virtual COND* Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**)") at assert.c:101
#8  0x00007f37a8c418c7 in Item_ref::build_equal_items (this=0x7f379d4e2be0, thd=0x7f379f7f9070, inherited=0x7f379d4e2e38, link_item_fields=false, cond_equal_ref=0x0) at /data/src/10.1/sql/item.h:3927
#9  0x00007f37a8cf608e in Item_cond_and::build_equal_items (this=0x7f379d4e2d58, thd=0x7f379f7f9070, inherited=0x7f379d4e2e38, link_item_fields=false, cond_equal_ref=0x7f379d4e33e0) at /data/src/10.1/sql/sql_select.cc:13111
#10 0x00007f37a8cf69af in build_equal_items (join=0x7f379d4e2f60, cond=0x7f379d4e2d58, inherited=0x0, join_list=0x7f379f7fd330, ignore_on_conds=true, cond_equal_ref=0x7f379d4e33e0, link_equal_fields=false) at /data/src/10.1/sql/sql_select.cc:13358
#11 0x00007f37a8cfa2b4 in optimize_cond (join=0x7f379d4e2f60, conds=0x7f379d4e2d58, join_list=0x7f379f7fd330, ignore_on_conds=true, cond_value=0x7f379d4e32b4, cond_equal=0x7f379d4e33e0, flags=0) at /data/src/10.1/sql/sql_select.cc:15003
#12 0x00007f37a8cd5946 in JOIN::optimize_inner (this=0x7f379d4e2f60) at /data/src/10.1/sql/sql_select.cc:1212
#13 0x00007f37a8cd50c8 in JOIN::optimize (this=0x7f379d4e2f60) at /data/src/10.1/sql/sql_select.cc:1040
#14 0x00007f37a8cdd704 in mysql_select (thd=0x7f379f7f9070, rref_pointer_array=0x7f379f7fd430, tables=0x7f379d4e2488, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f379d4e2b88, having=0x7f379d4e2d58, proc_param=0x0, select_options=2147748608, result=0x7f379d4e2f40, unit=0x7f379f7fcab8, select_lex=0x7f379f7fd1b8) at /data/src/10.1/sql/sql_select.cc:3424
#15 0x00007f37a8cd3288 in handle_select (thd=0x7f379f7f9070, lex=0x7f379f7fc9f0, result=0x7f379d4e2f40, setup_tables_done_option=0) at /data/src/10.1/sql/sql_select.cc:384
#16 0x00007f37a8ca34b5 in execute_sqlcom_select (thd=0x7f379f7f9070, all_tables=0x7f379d4e2488) at /data/src/10.1/sql/sql_parse.cc:5895
#17 0x00007f37a8c993c2 in mysql_execute_command (thd=0x7f379f7f9070) at /data/src/10.1/sql/sql_parse.cc:2961
#18 0x00007f37a8ca6c0e in mysql_parse (thd=0x7f379f7f9070, rawbuf=0x7f379d4e2088 "SELECT i, COUNT(*) FROM t1 GROUP BY i HAVING i AND 1", length=52, parser_state=0x7f37a9bf25e0) at /data/src/10.1/sql/sql_parse.cc:7319
#19 0x00007f37a8c95617 in dispatch_command (command=COM_QUERY, thd=0x7f379f7f9070, packet=0x7f37a113e071 "SELECT i, COUNT(*) FROM t1 GROUP BY i HAVING i AND 1", packet_length=52) at /data/src/10.1/sql/sql_parse.cc:1487
#20 0x00007f37a8c9434e in do_command (thd=0x7f379f7f9070) at /data/src/10.1/sql/sql_parse.cc:1108
#21 0x00007f37a8dca1a5 in do_handle_one_connection (thd_arg=0x7f379f7f9070) at /data/src/10.1/sql/sql_connect.cc:1350
#22 0x00007f37a8dc9f09 in handle_one_connection (arg=0x7f379f7f9070) at /data/src/10.1/sql/sql_connect.cc:1262
#23 0x00007f37a90ac9cc in pfs_spawn_thread (arg=0x7f37a5c27ef0) at /data/src/10.1/storage/perfschema/pfs.cc:1860
#24 0x00007f37a83950a4 in start_thread (arg=0x7f37a9bf3b00) at pthread_create.c:309
#25 0x00007f37a654d87d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Reproducible on previous versions of 10.1 (tried 10.1.14).
10.2 is also affected. 5.5 and 10.0 are apparently not.



 Comments   
Comment by Oleksandr Byelkin [ 2016-09-21 ]

It tryes to process Item_ref as Item_field.

Comment by Oleksandr Byelkin [ 2016-09-22 ]

revision-id: 5a215bae7d77eb6bd9d51e3e7fc6d94b6959d27d (mariadb-10.1.17-14-g5a215ba)
parent(s): ec7e0b7b30ecd301da5990495cdf18b39425a7c6
committer: Oleksandr Byelkin
timestamp: 2016-09-22 17:52:05 +0200
message:

MDEV-10716: Assertion `real_type() != FIELD_ITEM' failed in Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**)

Degenerated condition in AND should be treated in the same
way as in WHERE/HAVING alone (i.e reference should be
processed as well as fields)

Comment by Igor Babaev [ 2016-09-23 ]

So you know how to fix it.

Comment by Oleksandr Byelkin [ 2016-09-25 ]

Is above means "OK to push" or something else?

Comment by Oleksandr Byelkin [ 2016-09-26 ]

Review answered.

Comment by Oleksandr Byelkin [ 2016-09-28 ]

revision-id: 37108948131aa158e0828b5469898d974f91ee9b (mariadb-10.1.17-14-g3710894)
parent(s): ec7e0b7b30ecd301da5990495cdf18b39425a7c6
committer: Oleksandr Byelkin
timestamp: 2016-09-28 14:42:14 +0200
message:

MDEV-10716: Assertion `real_type() != FIELD_ITEM' failed in Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**)

Degenerated condition in AND should be treated in the same
way as in WHERE/HAVING alone (i.e reference should be
processed as well as fields)

Generated at Thu Feb 08 07:44:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.