Bug #58690 !table || (!table->read_set || bitmap_is_set(table->read_set, field_index))
Submitted: 3 Dec 2010 9:08 Modified: 27 May 2011 14:16
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S1 (Critical)
Version:5.1.54-debug, 5.1.55-debug, 5.5.9-debug, 5.6.1-debug OS:Any
Assigned to: Martin Hansson CPU Architecture:Any

[3 Dec 2010 9:08] Shane Bester
Description:
not the same as bug 56484 or bug 53830

Version: '5.1.55-debug'  socket: ''  port: 3306  Source distribution
Assertion failed: !table || (!table->read_set || bitmap_is_set(table->read_set, field_index)), file .\field.cc, line 3723

mysqld.exe!my_sigabrt_handler()[mysqld.cc:2084]
mysqld.exe!raise()[winsig.c:597]
mysqld.exe!abort()[abort.c:78]
mysqld.exe!_wassert()[assert.c:212]
mysqld.exe!Field_long::val_int()[field.cc:3723]
mysqld.exe!Item_field::val_int()[item.cc:2048]
mysqld.exe!Arg_comparator::compare_int_signed()[item_cmpfunc.cc:1459]
mysqld.exe!Arg_comparator::compare()[item_cmpfunc.h:81]
mysqld.exe!Item_func_eq::val_int()[item_cmpfunc.cc:1946]
mysqld.exe!evaluate_join_record()[sql_select.cc:11473]
mysqld.exe!sub_select()[sql_select.cc:11424]
mysqld.exe!do_select()[sql_select.cc:11182]
mysqld.exe!JOIN::exec()[sql_select.cc:2334]
mysqld.exe!subselect_single_select_engine::exec()[item_subselect.cc:1992]
mysqld.exe!Item_subselect::exec()[item_subselect.cc:280]
mysqld.exe!Item_singlerow_subselect::val_real()[item_subselect.cc:578]
mysqld.exe!Arg_comparator::compare_real()[item_cmpfunc.cc:1363]
mysqld.exe!Arg_comparator::compare()[item_cmpfunc.h:81]
mysqld.exe!Item_func_eq::val_int()[item_cmpfunc.cc:1946]
mysqld.exe!SQL_SELECT::skip_record()[opt_range.h:796]
mysqld.exe!find_all_keys()[filesort.cc:611]
mysqld.exe!filesort()[filesort.cc:247]
mysqld.exe!create_sort_index()[sql_select.cc:13903]
mysqld.exe!JOIN::exec()[sql_select.cc:2283]
mysqld.exe!subselect_single_select_engine::exec()[item_subselect.cc:1992]
mysqld.exe!Item_subselect::exec()[item_subselect.cc:280]
mysqld.exe!Item_exists_subselect::val_int()[item_subselect.cc:745]
mysqld.exe!evaluate_join_record()[sql_select.cc:11473]
mysqld.exe!sub_select()[sql_select.cc:11430]
mysqld.exe!do_select()[sql_select.cc:11182]
mysqld.exe!JOIN::exec()[sql_select.cc:2334]
mysqld.exe!mysql_select()[sql_select.cc:2546]
mysqld.exe!handle_select()[sql_select.cc:269]
mysqld.exe!execute_sqlcom_select()[sql_parse.cc:5144]
mysqld.exe!mysql_execute_command()[sql_parse.cc:2293]
mysqld.exe!mysql_parse()[sql_parse.cc:6072]
mysqld.exe!dispatch_command()[sql_parse.cc:1263]
mysqld.exe!do_command()[sql_parse.cc:889]
mysqld.exe!handle_one_connection()[sql_connect.cc:1136]
mysqld.exe!pthread_start()[my_winthread.c:85]
mysqld.exe!_callthreadstart()[thread.c:295]
mysqld.exe!_threadstart()[thread.c:277]

How to repeat:
on debug build:

drop table if exists `t1`,`t2`;
create table `t1`(`a` int )engine=innodb;
insert into `t1` values (0),(1);
create table `t2`(`b` text,`c` int,primary key (`b`(1)))engine=innodb;
insert into t2 values ('a',0);
(select 1 from `t1` as `t1_2` where exists 
 (select `b`  from `t2`  where `b`= 
  (select 1 from `t1` where 
     `c`=1 or `t1_2`.`a` and 1=2
   )
   group by `b`
 )
);
[3 Dec 2010 9:23] John Embretsen
Looks similar to http://bugs.mysql.com/58655 (but details in this bug report are easier to read ;) )
[3 Dec 2010 9:53] Valeriy Kravchuk
Verified on 32-bit Ubuntu 10.04.
[15 Dec 2010 19:49] MySQL Verification Team
another shorter testcase for 5.5.9-debug:

drop table if exists `t1`;
create table `t1`(`a` blob,`b` blob,primary key(`b`(100)))engine=innodb;
insert into `t1` values('',''),('c','d');
(select 1 from `t1` where 1 > some 
  (select `b` from `t1` as `t4_2` where 1 < 
    (select 1 from dual where `t4_2`.`a`='' and `t4_2`.`a` <=> '')
    and 1 <=>rand()
    group by 1
  )
);
[24 Jan 2011 14:21] MySQL Verification Team
i hit this bug continuously! it hampers testing because my disk fills up with corefiles and i don't know how to exclude this bug from happening.
[9 Feb 2011 7:39] MySQL Verification Team
I get various of these assertions, one for each type e.g here's a extract from my recent mysql-trunk error logs;

mysqld: ./sql/field.cc:2762: virtual double Field_new_decimal::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:2783: virtual my_decimal* Field_new_decimal::val_decimal(my_decimal*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3067: virtual double Field_tiny::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3076: virtual longlong Field_tiny::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3086: virtual String* Field_tiny::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3271: virtual double Field_short::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3500: virtual double Field_medium::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3508: virtual longlong Field_medium::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3708: virtual double Field_long::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3737: virtual String* Field_long::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3943: virtual double Field_longlong::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:3965: virtual longlong Field_longlong::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:4164: virtual double Field_float::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:4453: virtual double Field_double::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:4851: virtual double Field_timestamp::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:4857: virtual longlong Field_timestamp::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:4883: virtual String* Field_timestamp::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:5205: virtual String* Field_time::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:5388: virtual longlong Field_year::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:5801: virtual double Field_newdate::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:5808: virtual longlong Field_newdate::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:5818: virtual String* Field_newdate::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:6045: virtual longlong Field_datetime::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:6060: virtual String* Field_datetime::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:6396: virtual double Field_string::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:6445: virtual String* Field_string::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:6842: virtual double Field_varstring::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:6888: virtual String* Field_varstring::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:7461: virtual double Field_blob::val_real(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:7491: virtual String* Field_blob::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:8064: virtual longlong Field_enum::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:8696: virtual longlong Field_bit::val_int(): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
mysqld: ./sql/field.cc:8721: virtual String* Field_bit::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
[27 May 2011 14:16] Paul DuBois
Noted in 5.6.3 changelog.

As a side effect of optimizing "condition AND TRUE" or "condition OR
FALSE", MySQL for certain subqueries forgot that the columns used by
the condition needed to be read, which caused an assertion to be
raised in debug builds. 

CHANGESET - http://lists.mysql.com/commits/138184