Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' with aggregates
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
Critical
|
Sergey Petrunia |
Bug Description
The following query:
SELECT COUNT(DISTINCT t2.b), CONCAT(t1.c)
FROM t1, t2
WHERE (t2.c = t1.c)
AND (
t1.b IN ( 4 )
OR t1.a = 137
AND EXISTS ( SELECT a FROM t3 )
)
GROUP BY 2;
crashes as follows:
#8 0x006b0d98 in __assert_fail () from /lib/libc.so.6
#9 0x0826497d in Field_long::val_str (this=0xae630478, val_buffer=
#10 0x081ce347 in Item_field::val_str (this=0xae513248, str=0xae89ebb4) at item.cc:2262
#11 0x0821d319 in Item_func_
#12 0x081e13ed in Item::str_result (this=0xae513300, tmp=0xae89ebb4) at item.h:839
#13 0x083e8e39 in make_sortkey (param=0xae89eef4, to=0xae549f69 "", ref_pos=0xae6305b0 "") at filesort.cc:819
#14 0x083e874f in find_all_keys (param=0xae89eef4, select=0xae537758, sort_keys=
at filesort.cc:650
#15 0x083e735b in filesort (thd=0x9d4a6b8, table=0xae62e630, sortorder=
sort_
#16 0x083427db in create_sort_index (thd=0x9d4a6b8, join=0xae529728, order=0xae514ab8, filesort_
select_
#17 0x0831f4d0 in JOIN::exec (this=0xae529728) at sql_select.cc:2623
#18 0x0831ffb0 in mysql_select (thd=0x9d4a6b8, rref_pointer_
order=0x0, group=0xae514ab8, having=0x0, proc_param=0x0, select_
at sql_select.cc:2901
#19 0x08317da3 in handle_select (thd=0x9d4a6b8, lex=0x9d4bdc0, result=0xae514b60, setup_tables_
#20 0x082b3171 in execute_
#21 0x082a9f75 in mysql_execute_
#22 0x082b57ad in mysql_parse (thd=0x9d4a6b8,
rawbuf=
#23 0x082a7bf2 in dispatch_command (command=COM_QUERY, thd=0x9d4a6b8,
packet=
#24 0x082a704d in do_command (thd=0x9d4a6b8) at sql_parse.cc:906
#25 0x082a40b5 in handle_
#26 0x00821919 in start_thread () from /lib/libpthread
#27 0x0076acce in clone () from /lib/libc.so.6
explain:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index_merge PRIMARY,b b,PRIMARY 5,4 NULL 2 Using union(b,PRIMARY); Using where; Using filesort
1 PRIMARY t2 ref c c 5 test.t1.c 1 Using index
2 SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found
full optimizer_switch:
index_merge=
bzr version-info
revision-id: <email address hidden>
date: 2011-08-23 15:51:47 +0300
build-date: 2011-08-26 11:35:58 +0300
revno: 3166
branch-nick: maria-5.3
test case:
CREATE TABLE t1 ( a int , b int, c int, KEY (b), PRIMARY KEY (a)) ;
INSERT INTO t1 VALUES (1,4,0)
CREATE TABLE t2 ( b int, c int, KEY (c,b)) ;
INSERT INTO t2 VALUES (7,0),(
CREATE TABLE t3 ( a int ) ;
SELECT COUNT(DISTINCT t2.b), CONCAT(t1.c)
FROM t1, t2
WHERE (t2.c = t1.c)
AND (
t1.b IN ( 4 )
OR t1.a = 137
AND EXISTS ( SELECT a FROM t3 )
)
GROUP BY 2;
Reproducible in maria-5.3. Not reproducible in maria-5.2, mysql-5.5
Changed in maria: | |
milestone: | none → 5.3 |
summary: |
Assertion Assertion `!table || (!table->read_set || - bitmap_is_set(table->read_set, field_index))' with semijoin, aggregates + bitmap_is_set(table->read_set, field_index))' with aggregates |
Changed in maria: | |
assignee: | nobody → Oleksandr "Sanja" Byelkin (sanja-byelkin) |
status: | New → In Progress |
importance: | Undecided → High |
Changed in maria: | |
importance: | High → Critical |
summary: |
- Assertion Assertion `!table || (!table->read_set || - bitmap_is_set(table->read_set, field_index))' with aggregates + Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, + field_index))' with aggregates |
Changed in maria: | |
status: | In Progress → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
Type of the subquery is not important, emptiness of t3 also is not important.
A bit simplified query:
SELECT COUNT(DISTINCT t2.b), CONCAT(t1.c)
FROM t1, t2
WHERE (t2.c = t1.c)
AND (
t1.b = 4
OR t1.a = 137
AND (SELECT a FROM t3 )
)
GROUP BY 2;
drop tables t1,t2,t3;