[MDEV-3664] LP:660963 - sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed with join_cache_level=5 Created: 2010-10-15  Updated: 2015-02-02  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Philip Stoev (Inactive) Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug660963.xml    

 Description   

When executing the following query:

SELECT table1 .`pk`
FROM Z table1 LEFT JOIN K table3 JOIN D table4 ON table4 .`col_varchar_1024_latin1` ON table3 .`col_varchar_1024_latin1` ;

the server asserted as follows:

mysqld: sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed.

#8 0x00a72d98 in __assert_fail () from /lib/libc.so.6
#9 0x082d96be in JOIN_CACHE::set_match_flag_if_none (this=0xa4fc048, first_inner=0xa4db168, rec_ptr=0xa4fc15a "\377\001\001") at sql_join_cache.cc:1895
#10 0x082dc081 in JOIN_CACHE::check_match (this=0xa4fc048, rec_ptr=0xa4fc15a "\377\001\001") at sql_join_cache.cc:1998
#11 0x082d9727 in JOIN_CACHE::generate_full_extensions (this=0xa4fc048, rec_ptr=0xa4fc15a "\377\001\001") at sql_join_cache.cc:1933
#12 0x082d95a7 in JOIN_CACHE_BNL::join_matching_records (this=0xa4fc048, skip_last=false) at sql_join_cache.cc:1833
#13 0x082d9076 in JOIN_CACHE::join_records (this=0xa4fc048, skip_last=false) at sql_join_cache.cc:1636
#14 0x0831ef4c in sub_select_cache (join=0xa4d5098, join_tab=0xa4db328, end_of_records=true) at sql_select.cc:12822
#15 0x0831f165 in sub_select (join=0xa4d5098, join_tab=0xa4db168, end_of_records=true) at sql_select.cc:12984
#16 0x0831ef78 in sub_select_cache (join=0xa4d5098, join_tab=0xa4db168, end_of_records=true) at sql_select.cc:12824
#17 0x0831f165 in sub_select (join=0xa4d5098, join_tab=0xa4dafa8, end_of_records=true) at sql_select.cc:12984
#18 0x0831e71f in do_select (join=0xa4d5098, fields=0xa3e769c, table=0x0, procedure=0x0) at sql_select.cc:12580
#19 0x08304aad in JOIN::exec (this=0xa4d5098) at sql_select.cc:2300
#20 0x083051e3 in mysql_select (thd=0xa3e5c88, rref_pointer_array=0xa3e7720, tables=0xa4c0518, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0,
group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0xa4d5068, unit=0xa3e7364, select_lex=0xa3e7604) at sql_select.cc:2501
#21 0x082fd947 in handle_select (thd=0xa3e5c88, lex=0xa3e7308, result=0xa4d5068, setup_tables_done_option=0) at sql_select.cc:276
#22 0x0829beec in execute_sqlcom_select (thd=0xa3e5c88, all_tables=0xa4c0518) at sql_parse.cc:5081
#23 0x082928c4 in mysql_execute_command (thd=0xa3e5c88) at sql_parse.cc:2265
#24 0x0829e0ad in mysql_parse (thd=0xa3e5c88,
inBuf=0xa47d3a0 "SELECT table1 .`pk`\nFROM Z table1 LEFT JOIN K table3 JOIN D table4 ON table4 .`col_varchar_1024_latin1` ON table3 .`col_varchar_1024_latin1`", length=145, found_semicolon=0xa9fb7230) at sql_parse.cc:6027
#25 0x0829037a in dispatch_command (command=COM_QUERY, thd=0xa3e5c88, packet=0xa3e7ca9 "", packet_length=148) at sql_parse.cc:1184
#26 0x0828f868 in do_command (thd=0xa3e5c88) at sql_parse.cc:890
#27 0x0828c8a0 in handle_one_connection (arg=0xa3e5c88) at sql_connect.cc:1153
#28 0x00bea919 in start_thread () from /lib/libpthread.so.0
#29 0x00b2ccbe in clone () from /lib/libc.so.6

bzr version-info:

revision-id: <email address hidden>
date: 2010-09-14 16:43:41 +0300
build-date: 2010-10-15 09:35:55 +0300
revno: 2818
branch-nick: maria-5.3



 Comments   
Comment by Philip Stoev (Inactive) [ 2010-10-15 ]

Re: sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed with join_cache_level=

{5,7}

Test case

--source include/have_innodb.inc

SET SESSION join_cache_level = 5;
CREATE TABLE t1 (
f1 varchar(1024) DEFAULT NULL,
f2 int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (f2)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('one',1);

CREATE TABLE t2 (
`f1` varchar(1024) DEFAULT NULL,
`f2` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`f2`)
) ENGINE=InnoDB;
INSERT INTO t2 VALUES ('right',1);

CREATE TABLE t3 (
f1 int(11) NOT NULL AUTO_INCREMENT,
f2 varchar(1024) DEFAULT NULL,
PRIMARY KEY (f1)
) ENGINE=InnoDB;

SELECT t1.f2
FROM t1
LEFT JOIN t3
JOIN t2
ON t2.f1
ON t3.f2;

Comment by Philip Stoev (Inactive) [ 2010-10-15 ]

Re: sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed with join_cache_level=

{5,7}

See also http://bugs.mysql.com/bug.php?id=52540

Comment by Philip Stoev (Inactive) [ 2010-11-06 ]

Re: sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed with join_cache_level=

{5,7}

Also reproducible with maria-5.1-mwl128

Comment by Igor Babaev [ 2010-11-10 ]

Re: sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed with join_cache_level=

{5,7}

The bug is reproducible for the current 5.3 tree, but is not reproducible for the current maria-5.3-mwl128.
It does not make sense to fix it in the current 5.3 tree as this code will be replaced anyway.

Comment by Philip Stoev (Inactive) [ 2010-11-16 ]

Re: sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed with join_cache_level=

{5,7}

Here is a test case that works against 5.3-mwl128 . It seems that the bug has always been there, but the test case below uses MyISAM for stability and enables outer_join_with_cache.

SET SESSION join_cache_level = 5;
SET SESSION optimizer_switch = 'outer_join_with_cache=on';
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 (
f3 int) ;
INSERT IGNORE INTO t2 VALUES ('0'),('0');

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
f1 int,
f2 int,
PRIMARY KEY (f1)) ;
INSERT IGNORE INTO t1 VALUES ('2','1');

SELECT alias2.f2 FROM t2 LEFT JOIN t1 AS alias2 JOIN t1 AS alias3 ON alias3.f1 = alias2.f1 ON alias3.f2 ;

Comment by Philip Stoev (Inactive) [ 2010-11-16 ]

Re: sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed with join_cache_level=

{5,7}

Not reproducible with join_cache_level=7.

Comment by Philip Stoev (Inactive) [ 2010-11-16 ]

Re: sql_join_cache.cc:1895: bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB*, uchar*): Assertion `cache' failed with join_cache_level=5
Backtrace:

#8 0x00133d98 in __assert_fail () from /lib/libc.so.6
#9 0x082de75f in JOIN_CACHE::set_match_flag_if_none (this=0xae65f630, first_inner=0xae65ddb8, rec_ptr=0xae65f7d1 <incomplete sequence \375>)
at sql_join_cache.cc:2219
#10 0x082e1e95 in JOIN_CACHE::check_match (this=0xae65f630, rec_ptr=0xae65f7d1 <incomplete sequence \375>) at sql_join_cache.cc:2322
#11 0x082de7cb in JOIN_CACHE::generate_full_extensions (this=0xae65f630, rec_ptr=0xae65f7d1 <incomplete sequence \375>) at sql_join_cache.cc:2257
#12 0x082de63b in JOIN_CACHE::join_matching_records (this=0xae65f630, skip_last=false) at sql_join_cache.cc:2159
#13 0x082de1c0 in JOIN_CACHE::join_records (this=0xae65f630, skip_last=false) at sql_join_cache.cc:1967
#14 0x08326041 in sub_select_cache (join=0xae657b60, join_tab=0xae65df90, end_of_records=true) at sql_select.cc:13235
#15 0x0832625a in sub_select (join=0xae657b60, join_tab=0xae65ddb8, end_of_records=true) at sql_select.cc:13397
#16 0x0832606d in sub_select_cache (join=0xae657b60, join_tab=0xae65ddb8, end_of_records=true) at sql_select.cc:13237
#17 0x0832625a in sub_select (join=0xae657b60, join_tab=0xae65dbe0, end_of_records=true) at sql_select.cc:13397
#18 0x08325877 in do_select (join=0xae657b60, fields=0xabe0bc8, table=0x0, procedure=0x0) at sql_select.cc:12993
#19 0x0830b21b in JOIN::exec (this=0xae657b60) at sql_select.cc:2392
#20 0x0830b981 in mysql_select (thd=0xabdf198, rref_pointer_array=0xabe0c50, tables=0xae655320, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0,
group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0xae657b30, unit=0xabe0884, select_lex=0xabe0b28) at sql_select.cc:2602
#21 0x08303ed1 in handle_select (thd=0xabdf198, lex=0xabe0824, result=0xae657b30, setup_tables_done_option=0) at sql_select.cc:286
#22 0x0829fcd7 in execute_sqlcom_select (thd=0xabdf198, all_tables=0xae655320) at sql_parse.cc:5102
#23 0x082967d7 in mysql_execute_command (thd=0xabdf198) at sql_parse.cc:2281
#24 0x082a2248 in mysql_parse (thd=0xabdf198,
rawbuf=0xae631480 "SELECT alias2.f2 FROM t2 LEFT JOIN t1 AS alias2 JOIN t1 AS alias3 ON alias3.f1 = alias2.f1 ON alias3.f2", length=103,
found_semicolon=0xae7ff228) at sql_parse.cc:6109
#25 0x08294344 in dispatch_command (command=COM_QUERY, thd=0xabdf198, packet=0xabe1209 "", packet_length=104) at sql_parse.cc:1209
#26 0x082937f6 in do_command (thd=0xabdf198) at sql_parse.cc:902
#27 0x082907ac in handle_one_connection (arg=0xabdf198) at sql_connect.cc:1154
#28 0x00bea919 in start_thread () from /lib/libpthread.so.0
#29 0x001edcbe in clone () from /lib/libc.so.6

Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ]

Launchpad bug id: 660963

Generated at Thu Feb 08 06:50:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.