Commit 8a5940c4 authored by unknown's avatar unknown

Fix for LP BUG#944504

Problem is that subquery execution can't be called during prepare/optimize phase.

Also small fix for subquery test suite.
parent 6f3c39a0
......@@ -267,3 +267,19 @@ drop table t1;
create table t1(a char character set latin1 default _cp1251 0xFF);
ERROR 42000: Invalid default value for 'a'
End of 4.1 tests
SET CHARACTER SET DEFAULT;
#
# LP BUG#944504 Item_func_conv_charset tries to execute subquery constant
#
SET optimizer_switch = 'in_to_exists=on';
SET character_set_connection = utf8;
CREATE TABLE t1 ( a VARCHAR(1) );
INSERT INTO t1 VALUES ('m'),('n');
CREATE VIEW v1 AS SELECT 'w' ;
SELECT * FROM t1 WHERE a < ALL ( SELECT * FROM v1 );
ERROR HY000: Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<='
drop view v1;
drop table t1;
SET character_set_connection = default;
SET optimizer_switch= default;
#End of 5.3 tests
......@@ -5994,6 +5994,7 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
1
NULL
drop table t1,t2,t3;
set optimizer_switch=@subselect_tmp;
#
# LP BUG#905353 Wrong non-empty result with a constant table,
# aggregate function in subquery, MyISAM or Aria
......
......@@ -5993,6 +5993,7 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
1
NULL
drop table t1,t2,t3;
set optimizer_switch=@subselect_tmp;
#
# LP BUG#905353 Wrong non-empty result with a constant table,
# aggregate function in subquery, MyISAM or Aria
......
......@@ -5989,6 +5989,7 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
1
NULL
drop table t1,t2,t3;
set optimizer_switch=@subselect_tmp;
#
# LP BUG#905353 Wrong non-empty result with a constant table,
# aggregate function in subquery, MyISAM or Aria
......
......@@ -6000,6 +6000,7 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
1
NULL
drop table t1,t2,t3;
set optimizer_switch=@subselect_tmp;
#
# LP BUG#905353 Wrong non-empty result with a constant table,
# aggregate function in subquery, MyISAM or Aria
......
......@@ -5989,6 +5989,7 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
1
NULL
drop table t1,t2,t3;
set optimizer_switch=@subselect_tmp;
#
# LP BUG#905353 Wrong non-empty result with a constant table,
# aggregate function in subquery, MyISAM or Aria
......
......@@ -210,3 +210,21 @@ drop table t1;
create table t1(a char character set latin1 default _cp1251 0xFF);
--echo End of 4.1 tests
SET CHARACTER SET DEFAULT;
--echo #
--echo # LP BUG#944504 Item_func_conv_charset tries to execute subquery constant
--echo #
SET optimizer_switch = 'in_to_exists=on';
SET character_set_connection = utf8;
CREATE TABLE t1 ( a VARCHAR(1) );
INSERT INTO t1 VALUES ('m'),('n');
CREATE VIEW v1 AS SELECT 'w' ;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT * FROM t1 WHERE a < ALL ( SELECT * FROM v1 );
drop view v1;
drop table t1;
SET character_set_connection = default;
SET optimizer_switch= default;
--echo #End of 5.3 tests
......@@ -5075,8 +5075,8 @@ SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1;
# example with "random"
SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1;
drop table t1,t2,t3;
set optimizer_switch=@subselect_tmp;
--echo #
--echo # LP BUG#905353 Wrong non-empty result with a constant table,
......@@ -5090,5 +5090,6 @@ SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
drop table t1;
--echo # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
......@@ -747,7 +747,7 @@ class Item_func_conv_charset :public Item_str_func
{
DBUG_ASSERT(args[0]->fixed);
conv_charset= cs;
if (cache_if_const && args[0]->const_item())
if (cache_if_const && args[0]->const_item() && !args[0]->with_subselect)
{
uint errors= 0;
String tmp, *str= args[0]->val_str(&tmp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment