[MDEV-3637] LP:680943 - Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed with subquery Created: 2010-11-24  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: Timour Katchaounov (Inactive)
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug680943.xml    

 Description   

Assertion:

mysqld: field.cc:3730: virtual longlong Field_long::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.

backtrace:

#8 0x00a72d98 in __assert_fail () from /lib/libc.so.6
#9 0x082507db in Field_long::val_int (this=0xae549dc8) at field.cc:3730
#10 0x081bf7e1 in Item_field::val_int (this=0xae52f738) at item.cc:2122
#11 0x08321e78 in evaluate_join_record (join=0xae584f38, join_tab=0xae589db8, error=0) at sql_select.cc:13232
#12 0x08321adc in sub_select (join=0xae584f38, join_tab=0xae589db8, end_of_records=false) at sql_select.cc:13138
#13 0x08320ed8 in do_select (join=0xae584f38, fields=0xae52ea6c, table=0x0, procedure=0x0) at sql_select.cc:12684
#14 0x083071f5 in JOIN::exec (this=0xae584f38) at sql_select.cc:2340
#15 0x08237f14 in subselect_single_select_engine::exec (this=0xae52f950) at item_subselect.cc:2749
#16 0x0823243b in Item_subselect::exec (this=0xae52f888) at item_subselect.cc:552
#17 0x08233393 in Item_singlerow_subselect::val_int (this=0xae52f888) at item_subselect.cc:995
#18 0x082dd9de in SQL_SELECT::skip_record (this=0xae558060, thd=0xb38d0e8) at opt_range.h:847
#19 0x083c8dd4 in find_all_keys (param=0xae89efc8, select=0xae558060, sort_keys=0xae563040, buffpek_pointers=0xae89ee00, tempfile=0xae89eee4, indexfile=0x0)
at filesort.cc:619
#20 0x083c7984 in filesort (thd=0xb38d0e8, table=0xae561960, sortorder=0xae58a888, s_length=1, select=0xae558060, max_rows=18446744073709551615,
sort_positions=false, examined_rows=0xae89f130) at filesort.cc:246
#21 0x08328d4e in create_sort_index (thd=0xb38d0e8, join=0xae5800b8, order=0xae52f980, filesort_limit=18446744073709551615,
select_limit=18446744073709551615, is_order_by=false) at sql_select.cc:15904
#22 0x08306efa in JOIN::exec (this=0xae5800b8) at sql_select.cc:2283
#23 0x08307961 in mysql_select (thd=0xb38d0e8, rref_pointer_array=0xb38eb64, tables=0xae52e7d0, wild_num=0, fields=..., conds=0xae52f888, og_num=1,
order=0xae52f980, group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0xae557850, unit=0xb38e7c4, select_lex=0xb38ea60)
at sql_select.cc:2550
#24 0x0830004d in handle_select (thd=0xb38d0e8, lex=0xb38e768, result=0xae557850, setup_tables_done_option=0) at sql_select.cc:281
#25 0x0829d91b in execute_sqlcom_select (thd=0xb38d0e8, all_tables=0xae52e7d0) at sql_parse.cc:5102
#26 0x08294423 in mysql_execute_command (thd=0xb38d0e8) at sql_parse.cc:2281
#27 0x0829feac in mysql_parse (thd=0xb38d0e8,
rawbuf=0xae52d9b8 "SELECT f2\nFROM ( SELECT * FROM t2 ) AS alias1\nWHERE (\nSELECT SQ2_t2.f1\nFROM t1 JOIN t1 AS SQ2_t2 ON SQ2_t2.f3\nWHERE SQ2_t2.f3 AND alias1.f1\n)\nORDER BY f3", length=153, found_semicolon=0xae8a0228) at sql_parse.cc:6109
#28 0x08291f0c in dispatch_command (command=COM_QUERY, thd=0xb38d0e8,
packet=0xb3a5789 "SELECT f2\nFROM ( SELECT * FROM t2 ) AS alias1\nWHERE (\nSELECT SQ2_t2.f1\nFROM t1 JOIN t1 AS SQ2_t2 ON SQ2_t2.f3\nWHERE SQ2_t2.f3 AND alias1.f1\n)\nORDER BY f3 ", packet_length=154) at sql_parse.cc:1209
#29 0x08291376 in do_command (thd=0xb38d0e8) at sql_parse.cc:902
#30 0x0828e454 in handle_one_connection (arg=0xb38d0e8) at sql_connect.cc:1154
#31 0x00bea919 in start_thread () from /lib/libpthread.so.0
#32 0x00b2ccbe in clone () from /lib/libc.so.6

explain:

id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where; Using filesort
3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY SQ2_t2 ALL NULL NULL NULL NULL 2 Using where
2 DERIVED t2 ALL NULL NULL NULL NULL 2

test case:

CREATE TABLE t1 (f1 int,f3 int) ;
INSERT IGNORE INTO t1 VALUES ('6','0'),('4','0');

CREATE TABLE t2 (f1 int,f2 int,f3 int) ;
INSERT IGNORE INTO t2 VALUES ('6','0','0'),('2','0','0');

SELECT f2
FROM ( SELECT * FROM t2 ) AS alias1
WHERE (
SELECT SQ2_t2.f1
FROM t1 JOIN t1 AS SQ2_t2 ON SQ2_t2.f3
WHERE SQ2_t2.f3 AND alias1.f1
)
ORDER BY f3 ;



 Comments   
Comment by Timour Katchaounov (Inactive) [ 2010-11-25 ]

Re: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed with subquery
Confirmed in 5.3-MWL#89. Not present in main 5.3.

Comment by Timour Katchaounov (Inactive) [ 2010-11-29 ]

Re: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed with subquery
Bugs with the same assert:
https://bugs.launchpad.net/maria/+bug/607566
https://bugs.launchpad.net/maria/+bug/603654
https://bugs.launchpad.net/maria/+bug/625841

http://bugs.mysql.com/bug.php?id=53830
http://bugs.mysql.com/bug.php?id=56484

Comment by Timour Katchaounov (Inactive) [ 2010-11-30 ]

Re: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed with subquery
Analysis:

The problem lies in filesort.cc:find_all_keys().

When find_all_keys() is called for the outer query, it resets all
of the tree sets of fields - [read,write,vcol]_set and recomputes
them with respect to sorting.

However, in the loop for each current record the procedure calls
select->skip_record(thd), which evaluates the where clause, which
in turns evaluates the subquery. The JOIN evaluation of the
subquery eventually calls Field_long::val_int to evaluate the field
alias1.f1. The assertion condition
"bitmap_is_set(table->read_set, field_index)"
fails, because the outer query changed the read_set of table "alias1".

Comment by Igor Babaev [ 2012-01-13 ]

Re: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed with subquery
This is a duplicate of http://bugs.mysql.com/bug.php?id=58690
Should it be fixed in mariadb-5.2?

Comment by Rasmus Johansson (Inactive) [ 2012-01-13 ]

Launchpad bug id: 680943

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