[MDEV-4942] Assertion `((Item_cond *) cond)->functype() == ((Item_cond *) new_item)->functype()' fails on a query with LEFT JOIN and <date> IS NULL Created: 2013-08-23  Updated: 2013-08-28  Resolved: 2013-08-28

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: 10.0.5, 5.5.33, 5.3.13

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None


 Description   

It's the same assertion failure as in MDEV-4908, and appeared with the same revno 3676, but the fix for MDEV-4908 is already in the tree, and this test case still fails.

bzr version-info

revision-id: bar@mariadb.org-20130822112027-wew8m2o6f38qqukw
revno: 3682
branch-nick: 5.3

Version: '5.3.13-MariaDB-debug-log'  
mysqld: sql_select.cc:13356: COND* remove_eq_conds(THD*, COND*, Item::cond_result*): Assertion `((Item_cond *) cond)->functype() == ((Item_cond *) new_item)->functype()' failed.
[ERROR] mysqld got signal 6 ;

#6  0x00007f7890d720ee in __assert_fail_base (fmt=<optimized out>, assertion=0xd2fa90 "((Item_cond *) cond)->functype() == ((Item_cond *) new_item)->functype()", file=0xd2ebbf "sql_select.cc", line=<optimized out>, function=<optimized out>) at assert.c:94
#7  0x00007f7890d72192 in __GI___assert_fail (assertion=0xd2fa90 "((Item_cond *) cond)->functype() == ((Item_cond *) new_item)->functype()", file=0xd2ebbf "sql_select.cc", line=13356, function=0xd31480 "COND* remove_eq_conds(THD*, COND*, Item::cond_result*)") at assert.c:103
#8  0x00000000007277c4 in remove_eq_conds (thd=0x1bb48c8, cond=0x7f787401a5f8, cond_value=0x7f787401aae0) at sql_select.cc:13355
#9  0x00000000007271af in optimize_cond (join=0x7f787401a7f0, conds=0x7f787401a5f8, join_list=0x1bb74d0, ignore_on_conds=false, cond_value=0x7f787401aae0, cond_equal=0x7f787401ac00) at sql_select.cc:13142
#10 0x0000000000707bb4 in JOIN::optimize (this=0x7f787401a7f0) at sql_select.cc:1019
#11 0x000000000070ef81 in mysql_select (thd=0x1bb48c8, rref_pointer_array=0x1bb75b8, tables=0x7f7874019190, wild_num=1, fields=..., conds=0x7f787401a5f8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0x7f787401a7d0, unit=0x1bb6e58, select_lex=0x1bb7360) at sql_select.cc:2990
#12 0x0000000000705989 in handle_select (thd=0x1bb48c8, lex=0x1bb6db8, result=0x7f787401a7d0, setup_tables_done_option=0) at sql_select.cc:288
#13 0x0000000000691c62 in execute_sqlcom_select (thd=0x1bb48c8, all_tables=0x7f7874019190) at sql_parse.cc:5172
#14 0x0000000000688a2a in mysql_execute_command (thd=0x1bb48c8) at sql_parse.cc:2305
#15 0x00000000006946ec in mysql_parse (thd=0x1bb48c8, rawbuf=0x7f7874018f40 "SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL", length=72, found_semicolon=0x7f7883d497e0) at sql_parse.cc:6173
#16 0x0000000000686147 in dispatch_command (command=COM_QUERY, thd=0x1bb48c8, packet=0x1c2eb29 "SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL", packet_length=72) at sql_parse.cc:1243
#17 0x00000000006853b8 in do_command (thd=0x1bb48c8) at sql_parse.cc:923
#18 0x0000000000682252 in handle_one_connection (arg=0x1bb48c8) at sql_connect.cc:1231
#19 0x00007f789190de9a in start_thread (arg=0x7f7883d4a700) at pthread_create.c:308
#20 0x00007f7890e36cbd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

CREATE TABLE t1 ( i1 INT, d1 DATE );
INSERT INTO t1 VALUES (1,'2001-06-26'), (2,'2000-11-16');
 
CREATE TABLE t2 ( i2 INT, d2 DATE NOT NULL );
INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25');
 
SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL;



 Comments   
Comment by Sergei Petrunia [ 2013-08-23 ]

The failing assert is:

DBUG_ASSERT(((Item_cond *) cond)->functype() ==
((Item_cond *) new_item)->functype());

when assert is failing, we have:

(gdb) p (Item*)cond
$23 = (Item_cond_and *) 0x7fff7800aba8
(gdb) p (Item*)new_item
$24 = (Item_cond_or *) 0x7fff7805c740

Comment by Sergei Petrunia [ 2013-08-23 ]

The Item_cond_or represents this:

(gdb) p dbug_print_item(cond)
$34 = 0x11f1360 "((`j5`.`t2`.`d2` = 0) or isnull(`j5`.`t2`.`d2`))"

This is what "d2 IS NULL" was converted into.

Apparently, the fix for MDEV-4355 does not take into account the (datecol IS NULL) -> (datecol=0 OR datecol IS NULL) rewrite?

Comment by Igor Babaev [ 2013-08-28 ]

The fixed for the bug was pushed into the 5.3 tree and later merged into the 5.5 tree.

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