###### heavy modified case derived from client_test.c: test_distinct() --disable_warnings drop table if exists t_many_col_types, t2; --enable_warnings create table t_many_col_types ( c1 tinyint, c25 blob, c32 set('monday', 'tuesday', 'wednesday') ) ; create table t2 like t_many_col_types ; # version 13 set @stmt= ' explain SELECT (SELECT SUM(1 + 1) FROM t2 ) as scalar_s, exists (select 1 from t2) as exists_s, (c1 - 4, c1 - 4) in (select c1 + 4 , c1 + 4 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; # line 4 column c25 <- is necessary c1 will not work # line 4 column c32 <- is necessary c1 will not work # line 2 exists (select 1 from t2 <- subquery table t2 is necessary # line 3 columns could not replaced by constants # line 3 addition or subtraction is necessary # line 1 do not delete SUM it is necessary prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # Let's take the original tables, because some columns will be replaced # and increase the complexity drop table t_many_col_types, t2; create table t_many_col_types ( c1 tinyint, c2 smallint, c3 mediumint, c4 int, c5 integer, c6 bigint, c7 float, c8 double, c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4), c13 date, c14 datetime, c15 timestamp(14), c16 time, c17 year, c18 bit, c19 bool, c20 char, c21 char(10), c22 varchar(30), c23 tinyblob, c24 tinytext, c25 blob, c26 text, c27 mediumblob, c28 mediumtext, c29 longblob, c30 longtext, c31 enum('one', 'two', 'three'), c32 set('monday', 'tuesday', 'wednesday') ) engine = MYISAM ; create table t2 like t_many_col_types; # version 12 set @stmt= ' explain SELECT (SELECT SUM(1 + 1) FROM t2 ) as scalar_s, exists (select 1 from t2) as exists_s, (c1 - 4, c1 - 4) in (select c1 + 4 , c1 + 4 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 11 set @stmt= ' explain SELECT (SELECT SUM(c1 + c1) FROM t2 ) as scalar_s, exists (select 1 from t2) as exists_s, (c1 - 4, c1 - 4) in (select c1 + 4 , c1 + 4 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 10 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12) FROM t2 ) as scalar_s, exists (select 1 from t2 ) as exists_s, (c1 - 4, c1 - 4) in (select c1 + 4 , c1 + 4 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 9 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12) FROM t2 ) as scalar_s, exists (select 1 from t2 ) as exists_s, (c7 - 4, c8 - 4) in (select c9 + 4, c10 + 4 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 8 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12) FROM t2 ) as scalar_s, exists (select 1 from t2 ) as exists_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 7 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12) FROM t2 ) as scalar_s, exists (select 1 from t2 where 1 = c4) as exists_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 6 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12) FROM t2 ) as scalar_s, exists (select 1 from t2 where 1 = t_many_col_types.c4) as exists_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 5 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12) FROM t2 ) as scalar_s, exists (select 1 from t2 where t2.c3 = t_many_col_types.c4) as exists_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 4 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12) FROM t2 ) as scalar_s, exists (select 1 from t2 where t2.c3 = t_many_col_types.c4) as exists_s, FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 3 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12) FROM t2 ) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t_many_col_types.c4) as exists_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 2 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 GROUP BY t_many_col_types.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t_many_col_types.c4) as exists_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # version 1 set @stmt= ' explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 GROUP BY t_many_col_types.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t_many_col_types.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ; # Original version set @stmt= ' explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 where (t_many_col_types.c2 - 0e-3) = t2.c2 GROUP BY t_many_col_types.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t_many_col_types.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t_many_col_types, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25 ' ; prepare stmt1 from @stmt ; execute stmt1 ; # this second execute crashes the server execute stmt1 ;