Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
Description
When executing the query below with subquery cache enabled, mysqld asserts as follows:
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 0x00897de8 in __assert_fail () from /lib/libc.so.6
#9 0x0824d8cb in Field_long::val_int (this=0xb5ea3e10) at field.cc:3730
#10 0x081bd969 in Item_field::val_int_result (this=0xb5ea3d78) at item.cc:2189
#11 0x081c7afd in Item_ref::val_int (this=0xb5e58e90) at item.cc:6447
#12 0x081c805c in Item_direct_ref::val_int (this=0xb5e58d48) at item.cc:6569
#13 0x0831dc3e in evaluate_join_record (join=0xb5e62e10, join_tab=0xb5ea3348, error=0) at sql_select.cc:13197
#14 0x0831d8af in sub_select (join=0xb5e62e10, join_tab=0xb5ea3348, end_of_records=false) at sql_select.cc:13103
#15 0x0831ccae in do_select (join=0xb5e62e10, fields=0xb5e67bb0, table=0x0, procedure=0x0) at sql_select.cc:12649
#16 0x083030cf in JOIN::exec (this=0xb5e62e10) at sql_select.cc:2355
#17 0x082352b1 in subselect_single_select_engine::exec (this=0xb5e2e8b0) at item_subselect.cc:2716
#18 0x0822f9e3 in Item_subselect::exec (this=0xb5e2e7f0) at item_subselect.cc:481
#19 0x082308cd in Item_singlerow_subselect::val_int (this=0xb5e2e7f0) at item_subselect.cc:918
#20 0x081cf2fc in Item::val_int_result (this=0xb5e2e7f0) at item.h:779
#21 0x081cb196 in Item_cache_int::cache_value (this=0xb5e68528) at item.cc:7712
#22 0x081d2f4c in Item_cache_wrapper::cache (this=0xb5e684c8) at item.cc:6725
#23 0x081c8812 in Item_cache_wrapper::val_int (this=0xb5e684c8) at item.cc:6779
#24 0x081cf2fc in Item::val_int_result (this=0xb5e684c8) at item.h:779
#25 0x083c2cbc in make_sortkey (param=0xb619ec18,
to=0xb5ea7f64 "\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245"...,
ref_pos=0xb5e5b890 "\270P쵥\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245\245"...) at filesort.cc:852
#26 0x083c2318 in find_all_keys (param=0xb619ec18, select=0x0, sort_keys=0xb5ea79e8, buffpek_pointers=0xb619ea50, tempfile=0xb619eb34, indexfile=0x0)
at filesort.cc:625
#27 0x083c0ed1 in filesort (thd=0xa617fd0, table=0xb5e5aa40, sortorder=0xb5ea4b68, s_length=1, select=0x0, max_rows=18446744073709551615,
sort_positions=false, examined_rows=0xb619ed80) at filesort.cc:246
#28 0x08324a74 in create_sort_index (thd=0xa617fd0, join=0xb5e5dfa0, order=0xb5e2f980, filesort_limit=18446744073709551615,
select_limit=18446744073709551615, is_order_by=true) at sql_select.cc:15849
#29 0x08302dd4 in JOIN::exec (this=0xb5e5dfa0) at sql_select.cc:2298
#30 0x08303802 in mysql_select (thd=0xa617fd0, rref_pointer_array=0xa619a44, tables=0xb5e2e920, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0,
group=0xb5e2f980, having=0x0, proc_param=0x0, select_options=2147764736, result=0xb5e58a78, unit=0xa6196a8, select_lex=0xa619940) at sql_select.cc:2556
#31 0x082fbecf in handle_select (thd=0xa617fd0, lex=0xa61964c, result=0xb5e58a78, setup_tables_done_option=0) at sql_select.cc:276
#32 0x0829a5f0 in execute_sqlcom_select (thd=0xa617fd0, all_tables=0xb5e2e920) at sql_parse.cc:5081
#33 0x08290fd0 in mysql_execute_command (thd=0xa617fd0) at sql_parse.cc:2265
#34 0x0829c7d1 in mysql_parse (thd=0xa617fd0,
inBuf=0xb5e2d9b0 "/* cache is on */ SELECT SUM( DISTINCT table1 .`pk` ) , (\nSELECT MAX( `col_int_nokey` )\nFROM C\nWHERE table1 .`pk` ) field3\nFROM C table1\nJOIN (\nC table2\nJOIN CC table3\nON table3 .`col_varchar_k"..., length=311, found_semicolon=0xb61a0230) at sql_parse.cc:6027
#35 0x0828ea02 in dispatch_command (command=COM_QUERY, thd=0xa617fd0,
packet=0xa630329 "/* cache is on */ SELECT SUM( DISTINCT table1 .`pk` ) , (\nSELECT MAX( `col_int_nokey` )\nFROM C\nWHERE table1 .`pk` ) field3\nFROM C table1\nJOIN (\nC table2\nJOIN CC table3\nON table3 .`col_varchar_k"..., packet_length=314) at sql_parse.cc:1184
#36 0x0828dea8 in do_command (thd=0xa617fd0) at sql_parse.cc:890
#37 0x0828b008 in handle_one_connection (arg=0xa617fd0) at sql_connect.cc:1153
#38 0x00a08919 in start_thread () from /lib/libpthread.so.0
#39 0x00951e5e in clone () from /lib/libc.so.6
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Re: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed with subquery cache
Test case:
--disable_warnings
DROP TABLE /*! IF EXISTS */ CC;
DROP TABLE /*! IF EXISTS */ C;
--enable_warnings
CREATE TABLE `CC` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`col_int_nokey` int(11) DEFAULT NULL,
`col_int_key` int(11) DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `col_int_key` (`col_int_key`),
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MyISAM AUTO_INCREMENT=30 DEFAULT CHARSET=latin1;
INSERT INTO `CC` VALUES (10,7,8,'v','v');
INSERT INTO `CC` VALUES (11,1,9,'r','r');
INSERT INTO `CC` VALUES (12,5,9,'a','a');
INSERT INTO `CC` VALUES (13,3,186,'m','m');
INSERT INTO `CC` VALUES (14,6,NULL,'y','y');
INSERT INTO `CC` VALUES (15,92,2,'j','j');
INSERT INTO `CC` VALUES (16,7,3,'d','d');
INSERT INTO `CC` VALUES (17,NULL,0,'z','z');
INSERT INTO `CC` VALUES (18,3,133,'e','e');
INSERT INTO `CC` VALUES (19,5,1,'h','h');
INSERT INTO `CC` VALUES (20,1,8,'b','b');
INSERT INTO `CC` VALUES (21,2,5,'s','s');
INSERT INTO `CC` VALUES (22,NULL,5,'e','e');
INSERT INTO `CC` VALUES (23,1,8,'j','j');
INSERT INTO `CC` VALUES (24,0,6,'e','e');
INSERT INTO `CC` VALUES (25,210,51,'f','f');
INSERT INTO `CC` VALUES (26,8,4,'v','v');
INSERT INTO `CC` VALUES (27,7,7,'x','x');
INSERT INTO `CC` VALUES (28,5,6,'m','m');
INSERT INTO `CC` VALUES (29,NULL,4,'c','c');
CREATE TABLE `C` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`col_int_nokey` int(11) DEFAULT NULL,
`col_int_key` int(11) DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
`col_varchar_nokey` varchar(1) DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `col_int_key` (`col_int_key`),
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
INSERT INTO `C` VALUES (1,NULL,2,'w','w');
INSERT INTO `C` VALUES (2,7,9,'m','m');
INSERT INTO `C` VALUES (3,9,3,'m','m');
INSERT INTO `C` VALUES (4,7,9,'k','k');
INSERT INTO `C` VALUES (5,4,NULL,'r','r');
INSERT INTO `C` VALUES (6,2,9,'t','t');
INSERT INTO `C` VALUES (7,6,3,'j','j');
INSERT INTO `C` VALUES (8,8,8,'u','u');
INSERT INTO `C` VALUES (9,NULL,8,'h','h');
INSERT INTO `C` VALUES (10,5,53,'o','o');
INSERT INTO `C` VALUES (11,NULL,0,NULL,NULL);
INSERT INTO `C` VALUES (12,6,5,'k','k');
INSERT INTO `C` VALUES (13,188,166,'e','e');
INSERT INTO `C` VALUES (14,2,3,'n','n');
INSERT INTO `C` VALUES (15,1,0,'t','t');
INSERT INTO `C` VALUES (16,1,1,'c','c');
INSERT INTO `C` VALUES (17,0,9,'m','m');
INSERT INTO `C` VALUES (18,9,5,'y','y');
INSERT INTO `C` VALUES (19,NULL,6,'f','f');
INSERT INTO `C` VALUES (20,4,2,'d','d');
SET @@optimizer_switch = 'subquery_cache=off';
/* cache is off */ SELECT SUM( DISTINCT table1 .`pk` ) , (
SELECT MAX( `col_int_nokey` )
FROM C
WHERE table1 .`pk` ) field3
FROM C table1
JOIN (
C table2
JOIN CC table3
ON table3 .`col_varchar_key` = table2 .`col_varchar_key`
)
ON table3 .`col_varchar_key` = table2 .`col_varchar_nokey`
GROUP BY field3 ;
SET @@optimizer_switch = 'subquery_cache=on';
/* cache is on */ SELECT SUM( DISTINCT table1 .`pk` ) , (
SELECT MAX( `col_int_nokey` )
FROM C
WHERE table1 .`pk` ) field3
FROM C table1
JOIN (
C table2
JOIN CC table3
ON table3 .`col_varchar_key` = table2 .`col_varchar_key`
)
ON table3 .`col_varchar_key` = table2 .`col_varchar_nokey`
GROUP BY field3 ;