Bug #60305 prepare causes Assertion failed: !thd->lex->context_analysis_only
Submitted: 2 Mar 2011 14:39 Modified: 31 Jan 2013 15:59
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S1 (Critical)
Version:5.0.92,5.1.55, 5.5.9, 5.6.2 OS:Any
Assigned to: CPU Architecture:Any
Tags: BENCHMARK, prepare

[2 Mar 2011 14:39] Shane Bester
Description:
Version: '5.5.9-debug'  socket: ''  port: 3306  MySQL Community Server - Debug (GPL)
Assertion failed: !thd->lex->context_analysis_only, file ..\..\mysql-5.5.9\sql\item_subselect.cc, line 268
my_sigabrt_handler()[my_thr_init.c:520]
raise()[winsig.c:597]
abort()[abort.c:78]
_wassert()[assert.c:163]
Item_subselect::exec()[item_subselect.cc:268]
Item_singlerow_subselect::val_int()[item_subselect.cc:588]
Item_func_benchmark::val_int()[item_func.cc:4040]
Item_int_func::val_str()[item_func.cc:657]
Item_func_regex::regcomp()[item_cmpfunc.cc:4841]
Item_func_regex::val_int()[item_cmpfunc.cc:4942]
Item::update_null_value()[item.h:930]
Item_func::is_null()[item_func.h:153]
Item_func_isnull::update_used_tables()[item_cmpfunc.h:1342]
Item_func_isnull::fix_length_and_dec()[item_cmpfunc.h:1324]
Item_func::fix_fields()[item_func.cc:227]
setup_fields()[sql_base.cc:7783]
JOIN::prepare()[sql_select.cc:550]
st_select_lex_unit::prepare()[sql_union.cc:265]
mysql_test_select()[sql_prepare.cc:1484]
check_prepared_statement()[sql_prepare.cc:2004]
Prepared_statement::prepare()[sql_prepare.cc:3250]
mysql_sql_stmt_prepare()[sql_prepare.cc:2354]
mysql_execute_command()[sql_parse.cc:2059]
mysql_parse()[sql_parse.cc:5509]
dispatch_command()[sql_parse.cc:1038]
do_command()[sql_parse.cc:772]
do_handle_one_connection()[sql_connect.cc:748]
handle_one_connection()[sql_connect.cc:685]
pthread_start()[my_winthread.c:62]
_callthreadstartex()[threadex.c:348]
_threadstartex()[threadex.c:331]
BaseThreadStart()

How to repeat:
#start debug build, then:

prepare s from "select 1 rlike benchmark(1,(select 1)) is null";
[2 Mar 2011 14:49] Miguel Solorzano
C:\DBS>c:\dbs\5.5\bin\mysql -uroot --port=3540 --prompt="mysql 5.5 >"
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.11-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.5 >prepare s from "select 1 rlike benchmark(1,(select 1)) is null";
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql 5.5 >
[24 Mar 2011 10:36] Shane Bester
another testcase without benchmark:

set names utf8;
drop table if exists g1;
create table g1(a int,b int)engine=myisam;
insert into g1 values (0,1),(2,1);
prepare `stmt` from "(select  char((select 1) using ascii) as `c`  from g1  where `a` <`b` having `c` > '')";
[8 Jun 2011 8:32] Shane Bester
only affects debug builds.
[22 May 2012 14:29] Shane Bester
You don't need benchmark or prepared statements in this next testcase (5.6.6-debug).

drop table if exists `t1`;
create table `t1`(`a` int)engine=innodb;
create or replace view `tv0` as select 1 from `t1` `t1_1`
right join `t1` `t1_2`
on 1 >= some
(	select 
	(select 1) as `d`  
	from `t1` as `t1_3`
	having `d` like `d`
);

Version: '5.6.6-m9-debug'  socket: ''  port: 3306  MySQL Community Server (GPL)
Assertion failed: !thd->lex->context_analysis_only, file item_subselect.cc, line 391
mysqld-debug.exe!my_sigabrt_handler()[my_thr_init.c:495]
mysqld-debug.exe!raise()[winsig.c:586]
mysqld-debug.exe!abort()[abort.c:74]
mysqld-debug.exe!_wassert()[assert.c:153]
mysqld-debug.exe!Item_subselect::exec()[item_subselect.cc:391]
mysqld-debug.exe!Item_singlerow_subselect::val_str()[item_subselect.cc:858]
mysqld-debug.exe!Item::str_result()[item.h:1165]
mysqld-debug.exe!Item_ref::val_str()[item.cc:7550]
mysqld-debug.exe!Item_func_like::fix_fields()[item_cmpfunc.cc:5337]
mysqld-debug.exe!JOIN::prepare()[sql_resolver.cc:184]
mysqld-debug.exe!subselect_single_select_engine::prepare()[item_subselect.cc:2369]
mysqld-debug.exe!Item_subselect::fix_fields()[item_subselect.cc:199]
mysqld-debug.exe!Item_in_subselect::fix_fields()[item_subselect.cc:2084]
mysqld-debug.exe!Item_func::fix_fields()[item_func.cc:203]
mysqld-debug.exe!setup_conds()[sql_base.cc:8866]
mysqld-debug.exe!setup_without_group()[sql_resolver.cc:947]
mysqld-debug.exe!JOIN::prepare()[sql_resolver.cc:170]
mysqld-debug.exe!st_select_lex_unit::prepare()[sql_union.cc:331]
mysqld-debug.exe!mysql_create_view()[sql_view.cc:576]
mysqld-debug.exe!mysql_execute_command()[sql_parse.cc:4640]
mysqld-debug.exe!mysql_parse()[sql_parse.cc:6026]
mysqld-debug.exe!dispatch_command()[sql_parse.cc:1275]
mysqld-debug.exe!do_command()[sql_parse.cc:998]
mysqld-debug.exe!do_handle_one_connection()[sql_connect.cc:942]
mysqld-debug.exe!handle_one_connection()[sql_connect.cc:858]
mysqld-debug.exe!pthread_start()[my_winthread.c:61]
mysqld-debug.exe!_callthreadstartex()[threadex.c:314]
mysqld-debug.exe!_threadstartex()[threadex.c:297]
[31 Jan 2013 15:59] Paul Dubois
Noted in 5.1.69, 5.5.31, 5.6.11, 5.7.1 changelogs.

For debug builds, some queries with SELECT ... FROM DUAL nested 
subqueries raised an assertion.