Assertion `tab->ref.use_count' failed in join_read_key_unlock_row() with derived_merge + InnoDB + DISTINCT
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| MariaDB |
Fix Released
|
High
|
Igor Babaev | ||
Bug Description
Query:
SELECT *
FROM t1 , t2
WHERE ( t2.a , t1.b ) NOT IN (
SELECT DISTINCT c , a
FROM ( SELECT * FROM t3 ) AS SQ1_alias1
);
asserts as follows:
mysqld: sql_select.
#8 0x006b0d98 in __assert_fail () from /lib/libc.so.6
#9 0x0833ee94 in join_read_
#10 0x0833e093 in evaluate_
#11 0x0833d8dc in sub_select (join=0xb81cfe8, join_tab=0xb85a2e0, end_of_
#12 0x0833d12f in do_select (join=0xb81cfe8, fields=0xb82218c, table=0x0, procedure=0x0) at sql_select.cc:14770
#13 0x08321a61 in JOIN::exec (this=0xb81cfe8) at sql_select.cc:2679
#14 0x0824c7ed in subselect_
#15 0x08246539 in Item_subselect:
#16 0x082469e0 in Item_in_
#17 0x08248534 in Item_in_
#18 0x081e21e8 in Item::val_
#19 0x0820e62e in Item_in_
#20 0x081ca44c in Item::val_bool (this=0xb816670) at item.cc:197
#21 0x0820b1dc in Item_func_
#22 0x0833dc71 in evaluate_
#23 0x0833d8dc in sub_select (join=0xb817d60, join_tab=0xb81712c, end_of_
#24 0x0833d12f in do_select (join=0xb817d60, fields=0xb795cdc, table=0x0, procedure=0x0) at sql_select.cc:14770
#25 0x08321a61 in JOIN::exec (this=0xb817d60) at sql_select.cc:2679
#26 0x0832228e in mysql_select (thd=0xb794208, rref_pointer_
group=0x0, having=0x0, proc_param=0x0, select_
#27 0x0831a05f in handle_select (thd=0xb794208, lex=0xb79590c, result=0xb815e10, setup_tables_
#28 0x082b482c in execute_
#29 0x082ab5e9 in mysql_execute_
#30 0x082b6e5b in mysql_parse (thd=0xb794208,
rawbuf=
length=119, found_semicolon
#31 0x082a9238 in dispatch_command (command=COM_QUERY, thd=0xb794208, packet=0xb830529 "", packet_length=119) at sql_parse.cc:1221
#32 0x082a8693 in do_command (thd=0xb794208) at sql_parse.cc:916
#33 0x082a5677 in handle_
#34 0x00821919 in start_thread () from /lib/libpthread
#35 0x0076acce in clone () from /lib/libc.so.6
explain:
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00 Using where
2 DEPENDENT SUBQUERY t3 index PRIMARY,c c 4 NULL 1 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`b` AS `b`,1 AS `a` from `test`.`t1` join `test`.`t2` where (not(<in_
minimal optimizer_switch: derived_merge=ON
full optimizer_switch: index_merge=
bzr version-info:
revision-id: <email address hidden>
date: 2011-10-12 02:04:03 +0400
build-date: 2011-10-12 11:49:39 +0300
revno: 3224
branch-nick: maria-5.3
test case:
--source include/
CREATE TABLE t1 ( b int NOT NULL) ENGINE=InnoDB;
INSERT IGNORE INTO t1 VALUES (9);
CREATE TABLE t2 ( a int NOT NULL ) ;
INSERT IGNORE INTO t2 VALUES (1);
CREATE TABLE t3 ( a int NOT NULL , c int NOT NULL, d varchar(1) NOT NULL, KEY (c) , PRIMARY KEY (a)) ENGINE=InnoDB;
INSERT IGNORE INTO t3 VALUES (14,4,'
SET SESSION optimizer_
SELECT *
FROM t1 , t2
WHERE ( t2.a , t1.b ) NOT IN (
SELECT DISTINCT c , a
FROM ( SELECT * FROM t3 ) AS SQ1_alias1
);
| Changed in maria: | |
| milestone: | none → 5.3 |
| assignee: | nobody → Igor Babaev (igorb-seattle) |
| Changed in maria: | |
| status: | New → Confirmed |
| importance: | Undecided → High |
| Changed in maria: | |
| status: | Confirmed → In Progress |
| Changed in maria: | |
| status: | In Progress → Fix Committed |
| Changed in maria: | |
| status: | Fix Committed → Fix Released |

I failed to reproduce this bug with rev3224:
igor@sophia: ~/maria/ maria-5. 3-r3224/ mysql-test> ../client/mysql test beta-debug Source distribution
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.3.2-MariaDB-
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [test]> CREATE TABLE t1 ( b int NOT NULL) ENGINE=InnoDB;
Query OK, 0 rows affected (0.02 sec)
MariaDB [test]> INSERT IGNORE INTO t1 VALUES (9);
Query OK, 1 row affected (0.00 sec)
MariaDB [test]>
MariaDB [test]> CREATE TABLE t2 ( a int NOT NULL ) ;
Query OK, 0 rows affected (0.01 sec)
MariaDB [test]> INSERT IGNORE INTO t2 VALUES (1);
Query OK, 1 row affected (0.00 sec)
MariaDB [test]>
MariaDB [test]> CREATE TABLE t3 ( a int NOT NULL , c int NOT NULL, d varchar(1) NOT NULL, KEY (c) , PRIMARY KEY (a)) ENGINE=InnoDB;
Query OK, 0 rows affected (0.01 sec)
MariaDB [test]> INSERT IGNORE INTO t3 VALUES (14,4,' a'),(15, 7,'b'), (16,4,' c'),(17, 1,'d'), (18,9,' e'),(19, 4,'f'), (20,8,' g');
Query OK, 7 rows affected (0.00 sec)
Records: 7 Duplicates: 0 Warnings: 0
MariaDB [test]> switch= 'derived_ merge=ON, subquery_ cache=off' ;
MariaDB [test]> SET SESSION optimizer_
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]>
MariaDB [test]> SELECT *
-> FROM t1 , t2
-> WHERE ( t2.a , t1.b ) NOT IN (
-> SELECT DISTINCT c , a
-> FROM ( SELECT * FROM t3 ) AS SQ1_alias1
-> );
+---+---+
| b | a |
+---+---+
| 9 | 1 |
+---+---+
1 row in set (0.01 sec)
MariaDB [test]> alter table t2 engine=innodb;
Query OK, 1 row affected (0.02 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [test]> SELECT * FROM t1 , t2 WHERE ( t2.a , t1.b ) NOT IN ( SELECT DISTINCT c , a FROM ( SELECT * FROM t3 ) AS SQ1_alias1 );
+---+---+
| b | a |
+---+---+
| 9 | 1 |
+---+---+
1 row in set (0.00 sec)