Commit f8791c39 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

Derivation attribute was not processed correctly

by MAX/MIN in some cases:
SELECT coercibility(max(s1)) from t1;

Subselect collation and derivation was not processed
correctly:

create table a select (select s1 from t1);
select * from t1 where s1 = (select s2 from t1);
parent 1f2a95e3
......@@ -612,3 +612,9 @@ select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID =
Case When Count(*) < MAX_REQ Then 1 Else 0 End
1
drop table t1;
create table t1 (a char(10));
insert into t1 values ('a'),('b'),('c');
select coercibility(max(a)) from t1;
coercibility(max(a))
3
drop table t1;
......@@ -1225,3 +1225,16 @@ a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 an
2 2
1 2
drop table t1,t2,t3;
create table t1 (a char(10) character set koi8r collate koi8r_bin);
create table t2 select (select a from t1);
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`(select a from t1)` char(10) character set koi8r collate koi8r_bin default NULL
) TYPE=MyISAM CHARSET=latin1
drop table t1,t2;
CREATE TABLE t1
(s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci);
SELECT * FROM t1 WHERE s1 = (SELECT s2 FROM t1);
ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
......@@ -355,3 +355,8 @@ insert into t1 values (1, 3);
select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
drop table t1;
create table t1 (a char(10));
insert into t1 values ('a'),('b'),('c');
select coercibility(max(a)) from t1;
drop table t1;
......@@ -817,4 +817,15 @@ insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10);
insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1);
insert into t3 values (3,3), (2,2), (1,1);
select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3;
drop table t1,t2,t3;s
drop table t1,t2,t3;
create table t1 (a char(10) character set koi8r collate koi8r_bin);
create table t2 select (select a from t1);
show create table t2;
drop table t1,t2;
CREATE TABLE t1
(s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci);
--error 1265
SELECT * FROM t1 WHERE s1 = (SELECT s2 FROM t1);
......@@ -1442,7 +1442,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
max_length= (*ref)->max_length;
maybe_null= (*ref)->maybe_null;
decimals= (*ref)->decimals;
set_charset((*ref)->charset());
collation.set((*ref)->collation);
with_sum_func= (*ref)->with_sum_func;
fixed= 1;
......
......@@ -759,6 +759,7 @@ static Item_result set_row(SELECT_LEX *select_lex, Item * item,
if (!(row[i]= Item_cache::get_cache(res_type)))
return STRING_RESULT; // we should return something
row[i]->set_len_n_dec(sel_item->max_length, sel_item->decimals);
row[i]->collation.set(sel_item->collation);
}
}
if (select_lex->item_list.elements > 1)
......@@ -770,6 +771,7 @@ void subselect_single_select_engine::fix_length_and_dec(Item_cache **row)
{
DBUG_ASSERT(row || select_lex->item_list.elements==1);
res_type= set_row(select_lex, item, row, &maybe_null);
item->collation.set(row[0]->collation);
if (cols() != 1)
maybe_null= 0;
}
......
......@@ -199,7 +199,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
decimals=item->decimals;
maybe_null=item->maybe_null;
unsigned_flag=item->unsigned_flag;
set_charset(item->charset());
collation.set(item->collation);
result_field=0;
null_value=1;
fix_length_and_dec();
......
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