Commit 05265d57 authored by unknown's avatar unknown

Merge jlindstrom@build.mysql.com:/home/bk/mysql-4.1

into hundin.mysql.fi:/home/jan/mysql-4.1

parents 0ee9e4d7 0ceb4ddc
......@@ -18,7 +18,7 @@ explain extended select grp,group_concat(c) from t1 group by grp;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
Warnings:
Note 1003 select test.t1.grp AS `grp`,group_concat(test.t1.c seperator ',') AS `group_concat(c)` from test.t1 group by test.t1.grp
Note 1003 select test.t1.grp AS `grp`,group_concat(test.t1.c separator ',') AS `group_concat(c)` from test.t1 group by test.t1.grp
select grp,group_concat(a,c) from t1 group by grp;
grp group_concat(a,c)
1 1a
......@@ -93,7 +93,7 @@ explain extended select grp,group_concat(distinct c order by c desc) from t1 gro
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
Warnings:
Note 1003 select test.t1.grp AS `grp`,group_concat(distinct test.t1.c order by test.t1.c seperator ',') AS `group_concat(distinct c order by c desc)` from test.t1 group by test.t1.grp
Note 1003 select test.t1.grp AS `grp`,group_concat(distinct test.t1.c order by test.t1.c separator ',') AS `group_concat(distinct c order by c desc)` from test.t1 group by test.t1.grp
select grp,group_concat(c order by c separator ",") from t1 group by grp;
grp group_concat(c order by c separator ",")
1 a
......@@ -113,7 +113,7 @@ explain extended select grp,group_concat(distinct c order by c separator ",") fr
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
Warnings:
Note 1003 select test.t1.grp AS `grp`,group_concat(distinct test.t1.c order by test.t1.c seperator ',') AS `group_concat(distinct c order by c separator ",")` from test.t1 group by test.t1.grp
Note 1003 select test.t1.grp AS `grp`,group_concat(distinct test.t1.c order by test.t1.c separator ',') AS `group_concat(distinct c order by c separator ",")` from test.t1 group by test.t1.grp
select grp,group_concat(distinct c order by c desc separator ",") from t1 group by grp;
grp group_concat(distinct c order by c desc separator ",")
1 a
......
......@@ -148,6 +148,16 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 select test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c` from test.t1 where (_latin1'a' in (test.t1.a,test.t1.b,(test.t1.c collate _latin1'latin1_bin')))
drop table t1;
set names utf8;
create table t1 (a char(10) character set utf8 not null);
insert into t1 values ('bbbb'),(_koi8r'ÃÃÃÃ'),(_latin1'ÄÄÄÄ');
select a from t1 where a in ('bbbb',_koi8r'ÃÃÃÃ',_latin1'ÄÄÄÄ') order by a;
a
ÄÄÄÄ
bbbb
цццц
drop table t1;
set names latin1;
select '1.0' in (1,2);
'1.0' in (1,2)
1
......
......@@ -75,6 +75,13 @@ select * from t1 where 'a' in (a,b,c collate latin1_bin);
explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
drop table t1;
set names utf8;
create table t1 (a char(10) character set utf8 not null);
insert into t1 values ('bbbb'),(_koi8r'ÃÃÃÃ'),(_latin1'ÄÄÄÄ');
select a from t1 where a in ('bbbb',_koi8r'ÃÃÃÃ',_latin1'ÄÄÄÄ') order by a;
drop table t1;
set names latin1;
select '1.0' in (1,2);
select 1 in ('1.0',2);
select 1 in (1,'2.0');
......
......@@ -265,8 +265,9 @@ CHARSET_INFO *Item::default_charset()
return current_thd->variables.collation_connection;
}
bool DTCollation::aggregate(DTCollation &dt)
bool DTCollation::aggregate(DTCollation &dt, bool superset_conversion)
{
nagg++;
if (!my_charset_same(collation, dt.collation))
{
/*
......@@ -280,15 +281,39 @@ bool DTCollation::aggregate(DTCollation &dt)
if (derivation <= dt.derivation)
; // Do nothing
else
set(dt);
{
set(dt);
strong= nagg;
}
}
else if (dt.collation == &my_charset_bin)
{
if (dt.derivation <= derivation)
{
set(dt);
strong= nagg;
}
else
; // Do nothing
}
else if (superset_conversion)
{
if (derivation < dt.derivation &&
collation->state & MY_CS_UNICODE)
; // Do nothing
else if (dt.derivation < derivation &&
dt.collation->state & MY_CS_UNICODE)
{
set(dt);
strong= nagg;
}
else
{
// Cannot convert to superset
set(0, DERIVATION_NONE);
return 1;
}
}
else
{
set(0, DERIVATION_NONE);
......@@ -302,6 +327,7 @@ bool DTCollation::aggregate(DTCollation &dt)
else if (dt.derivation < derivation)
{
set(dt);
strong= nagg;
}
else
{
......
......@@ -41,16 +41,22 @@ class DTCollation {
public:
CHARSET_INFO *collation;
enum Derivation derivation;
uint nagg; // Total number of aggregated collations.
uint strong; // Number of the strongest collation.
DTCollation()
{
collation= &my_charset_bin;
derivation= DERIVATION_NONE;
nagg= 0;
strong= 0;
}
DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg)
{
collation= collation_arg;
derivation= derivation_arg;
nagg= 0;
strong= 0;
}
void set(DTCollation &dt)
{
......@@ -66,9 +72,9 @@ public:
{ collation= collation_arg; }
void set(Derivation derivation_arg)
{ derivation= derivation_arg; }
bool aggregate(DTCollation &dt);
bool set(DTCollation &dt1, DTCollation &dt2)
{ set(dt1); return aggregate(dt2); }
bool aggregate(DTCollation &dt, bool superset_conversion= FALSE);
bool set(DTCollation &dt1, DTCollation &dt2, bool superset_conversion= FALSE)
{ set(dt1); return aggregate(dt2, superset_conversion); }
const char *derivation_name() const
{
switch(derivation)
......
......@@ -188,25 +188,17 @@ void Item_bool_func2::fix_length_and_dec()
{
uint strong= 0;
uint weak= 0;
DTCollation coll;
if ((args[0]->collation.derivation < args[1]->collation.derivation) &&
!my_charset_same(args[0]->collation.collation,
args[1]->collation.collation) &&
(args[0]->collation.collation->state & MY_CS_UNICODE))
{
weak= 1;
}
else if ((args[1]->collation.derivation < args[0]->collation.derivation) &&
!my_charset_same(args[0]->collation.collation,
args[1]->collation.collation) &&
(args[1]->collation.collation->state & MY_CS_UNICODE))
{
strong= 1;
}
if (strong || weak)
if (args[0]->result_type() == STRING_RESULT &&
args[1]->result_type() == STRING_RESULT &&
!my_charset_same(args[0]->collation.collation,
args[1]->collation.collation) &&
!coll.set(args[0]->collation, args[1]->collation, TRUE))
{
Item* conv= 0;
strong= coll.strong;
weak= strong ? 0 : 1;
if (args[weak]->type() == STRING_ITEM)
{
String tmp, cstr;
......@@ -1743,12 +1735,58 @@ void Item_func_in::fix_length_and_dec()
uint const_itm= 1;
agg_cmp_type(&cmp_type, args, arg_count);
if ((cmp_type == STRING_RESULT) &&
(agg_arg_collations_for_comparison(cmp_collation, args, arg_count)))
return;
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
const_itm&= arg[0]->const_item();
if (cmp_type == STRING_RESULT)
{
/*
We allow consts character set conversion for
item IN (const1, const2, const3, ...)
if item is in a superset for all arguments,
and if it is a stong side according to coercibility rules.
TODO: add covnersion for non-constant IN values
via creating Item_func_conv_charset().
*/
if (agg_arg_collations_for_comparison(cmp_collation,
args, arg_count, TRUE))
return;
if ((!my_charset_same(args[0]->collation.collation,
cmp_collation.collation) || !const_itm))
{
if (agg_arg_collations_for_comparison(cmp_collation,
args, arg_count, FALSE))
return;
}
else
{
/*
Conversion is possible:
All IN arguments are constants.
*/
for (arg= args+1, arg_end= args+arg_count; arg < arg_end; arg++)
{
if (!my_charset_same(cmp_collation.collation,
arg[0]->collation.collation))
{
Item_string *conv;
String tmp, cstr, *ostr= arg[0]->val_str(&tmp);
cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(),
cmp_collation.collation);
conv= new Item_string(cstr.ptr(),cstr.length(), cstr.charset(),
arg[0]->collation.derivation);
conv->str_value.copy();
arg[0]= conv;
}
}
}
}
/*
Row item with NULLs inside can return NULL or FALSE =>
......
......@@ -75,13 +75,16 @@ static void my_coll_agg_error(Item** args, uint count, const char *fname)
}
bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count)
bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count,
bool allow_superset_conversion)
{
uint i;
c.nagg= 0;
c.strong= 0;
c.set(av[0]->collation);
for (i= 1; i < count; i++)
{
if (c.aggregate(av[i]->collation))
if (c.aggregate(av[i]->collation, allow_superset_conversion))
{
my_coll_agg_error(av, count, func_name());
return TRUE;
......@@ -92,9 +95,10 @@ bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count)
bool Item_func::agg_arg_collations_for_comparison(DTCollation &c,
Item **av, uint count)
Item **av, uint count,
bool allow_superset_conv)
{
if (agg_arg_collations(c, av, count))
if (agg_arg_collations(c, av, count, allow_superset_conv))
return TRUE;
if (c.derivation == DERIVATION_NONE)
......
......@@ -140,8 +140,11 @@ public:
Field *tmp_table_field(TABLE *t_arg);
Item *get_tmp_table_item(THD *thd);
bool agg_arg_collations(DTCollation &c, Item **items, uint nitems);
bool agg_arg_collations_for_comparison(DTCollation &c, Item **items, uint nitems);
bool agg_arg_collations(DTCollation &c, Item **items, uint nitems,
bool allow_superset_conversion= FALSE);
bool agg_arg_collations_for_comparison(DTCollation &c,
Item **items, uint nitems,
bool allow_superset_comversion= FALSE);
bool walk(Item_processor processor, byte *arg);
};
......
......@@ -2157,7 +2157,7 @@ void Item_func_group_concat::print(String *str)
(*order[i]->item)->print(str);
}
}
str->append(" seperator \'", 12);
str->append(" separator \'", 12);
str->append(*separator);
str->append("\')", 2);
}
......@@ -1790,7 +1790,7 @@ static void test_ps_conj_select()
MYSQL_STMT *stmt;
int rc;
MYSQL_BIND bind[2];
long int int_data;
int32 int_data;
char str_data[32];
unsigned long str_length;
myheader("test_ps_conj_select");
......@@ -3227,7 +3227,7 @@ static void bind_fetch(int row_count)
{
MYSQL_STMT *stmt;
int rc, i, count= row_count;
long data[10];
int32 data[10];
int8 i8_data;
int16 i16_data;
int32 i32_data;
......@@ -4546,7 +4546,7 @@ static void test_multi_stmt()
MYSQL_STMT *stmt, *stmt1, *stmt2;
int rc;
ulong id;
uint32 id;
char name[50];
MYSQL_BIND bind[2];
ulong length[2];
......@@ -4605,7 +4605,7 @@ static void test_multi_stmt()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n int_data: %lu(%lu)", id, length[0]);
fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]);
fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]);
assert(id == 10);
assert(strcmp(name, "mysql") == 0);
......@@ -4634,7 +4634,7 @@ static void test_multi_stmt()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n int_data: %lu(%lu)", id, length[0]);
fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]);
fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]);
assert(id == 10);
assert(strcmp(name, "updated") == 0);
......@@ -5042,7 +5042,7 @@ static void test_store_result()
{
MYSQL_STMT *stmt;
int rc;
long nData;
int32 nData;
char szData[100];
MYSQL_BIND bind[2];
ulong length, length1;
......@@ -5094,7 +5094,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %ld, %s(%lu)", nData, szData, length1);
fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1);
assert(nData == 10);
assert(strcmp(szData, "venu") == 0);
assert(length1 == 4);
......@@ -5102,7 +5102,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n row 2: %ld, %s(%lu)", nData, szData, length1);
fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1);
assert(nData == 20);
assert(strcmp(szData, "mysql") == 0);
assert(length1 == 5);
......@@ -5129,7 +5129,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %ld, %s(%lu)", nData, szData, length1);
fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1);
assert(nData == 10);
assert(strcmp(szData, "venu") == 0);
assert(length1 == 4);
......@@ -5137,7 +5137,7 @@ static void test_store_result()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n row 2: %ld, %s(%lu)", nData, szData, length1);
fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1);
assert(nData == 20);
assert(strcmp(szData, "mysql") == 0);
assert(length1 == 5);
......@@ -5984,7 +5984,7 @@ static void test_ushort_bug()
MYSQL_STMT *stmt;
MYSQL_BIND bind[4];
ushort short_value;
ulong long_value;
uint32 long_value;
ulong s_length, l_length, ll_length, t_length;
ulonglong longlong_value;
int rc;
......@@ -6038,7 +6038,7 @@ static void test_ushort_bug()
check_execute(stmt, rc);
fprintf(stdout, "\n ushort : %d (%ld)", short_value, s_length);
fprintf(stdout, "\n ulong : %ld (%ld)", long_value, l_length);
fprintf(stdout, "\n ulong : %lu (%ld)", (ulong) long_value, l_length);
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
......@@ -6068,7 +6068,7 @@ static void test_sshort_bug()
MYSQL_STMT *stmt;
MYSQL_BIND bind[4];
short short_value;
long long_value;
int32 long_value;
ulong s_length, l_length, ll_length, t_length;
ulonglong longlong_value;
int rc;
......@@ -6122,7 +6122,7 @@ static void test_sshort_bug()
check_execute(stmt, rc);
fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length);
fprintf(stdout, "\n slong : %ld (%ld)", long_value, l_length);
fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length);
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
......@@ -6152,7 +6152,7 @@ static void test_stiny_bug()
MYSQL_STMT *stmt;
MYSQL_BIND bind[4];
short short_value;
long long_value;
int32 long_value;
ulong s_length, l_length, ll_length, t_length;
ulonglong longlong_value;
int rc;
......@@ -6206,7 +6206,7 @@ static void test_stiny_bug()
check_execute(stmt, rc);
fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length);
fprintf(stdout, "\n slong : %ld (%ld)", long_value, l_length);
fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length);
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
......@@ -7251,7 +7251,7 @@ static void test_fetch_seek()
MYSQL_BIND bind[3];
MYSQL_ROW_OFFSET row;
int rc;
long c1;
int32 c1;
char c2[11], c3[20];
myheader("test_fetch_seek");
......@@ -7296,7 +7296,7 @@ static void test_fetch_seek()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n row 0: %ld, %s, %s", c1, c2, c3);
fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3);
row= mysql_stmt_row_tell(stmt);
......@@ -7305,21 +7305,21 @@ static void test_fetch_seek()
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n row 2: %ld, %s, %s", c1, c2, c3);
fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3);
row= mysql_stmt_row_seek(stmt, row);
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n row 2: %ld, %s, %s", c1, c2, c3);
fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3);
mysql_stmt_data_seek(stmt, 0);
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
fprintf(stdout, "\n row 0: %ld, %s, %s", c1, c2, c3);
fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3);
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
......@@ -8050,7 +8050,7 @@ static void test_bug1500()
MYSQL_STMT *stmt;
MYSQL_BIND bind[3];
int rc;
long int_data[3]= {2, 3, 4};
int32 int_data[3]= {2, 3, 4};
const char *data;
myheader("test_bug1500");
......@@ -8836,7 +8836,7 @@ static void test_multi()
char *query;
MYSQL_BIND bind[1];
int rc, i;
long param= 1;
int32 param= 1;
ulong length= 1;
myheader("test_multi");
......@@ -8888,11 +8888,11 @@ static void test_multi()
rc= mysql_stmt_execute(stmt_update);
check_execute(stmt_update, rc);
fprintf(stdout, "update %ld\n", param);
fprintf(stdout, "update %ld\n", (long) param);
rc= mysql_stmt_execute(stmt_delete);
check_execute(stmt_delete, rc);
fprintf(stdout, "delete %ld\n", param);
fprintf(stdout, "delete %ld\n", (long) param);
rc= mysql_stmt_execute(stmt_select1);
check_execute(stmt_select1, rc);
......@@ -8966,9 +8966,9 @@ static void test_bind_nagative()
char *query;
int rc;
MYSQL_BIND bind[1];
long my_val= 0L;
int32 my_val= 0;
ulong my_length= 0L;
long my_null= 0L;
my_bool my_null= FALSE;
myheader("test_insert_select");
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
......@@ -9010,9 +9010,9 @@ static void test_derived()
MYSQL_STMT *stmt;
int rc, i;
MYSQL_BIND bind[1];
long my_val= 0L;
int32 my_val= 0;
ulong my_length= 0L;
long my_null= 0L;
my_bool my_null= FALSE;
const char *query=
"select count(1) from (select f.id from t1 f where f.id=?) as x";
......@@ -9520,7 +9520,7 @@ static void test_union_param()
MYSQL_BIND bind[2];
char my_val[4];
ulong my_length= 3L;
long my_null= 0L;
my_bool my_null= FALSE;
myheader("test_union_param");
strcpy(my_val, "abc");
......@@ -9904,7 +9904,7 @@ static void test_bug4079()
MYSQL_STMT *stmt;
MYSQL_BIND bind[1];
const char *stmt_text;
unsigned long res;
uint32 res;
int rc;
myheader("test_bug4079");
......@@ -10048,7 +10048,7 @@ static void test_bug5126()
{
MYSQL_STMT *stmt;
MYSQL_BIND bind[2];
long c1, c2;
int32 c1, c2;
const char *stmt_text;
int rc;
......@@ -10086,7 +10086,7 @@ static void test_bug5126()
rc= mysql_stmt_fetch(stmt);
assert(rc == 0);
assert(c1 == 8386608 && c2 == 1);
printf("%ld, %ld\n", c1, c2);
printf("%ld, %ld\n", (long) c1, (long) c2);
mysql_stmt_close(stmt);
}
......
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