mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-8723 Wrong result for SELECT..WHERE COLLATION(a)='binary' AND a='a'
This commit is contained in:
@@ -3101,5 +3101,43 @@ Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'a ')
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-8723 Wrong result for SELECT..WHERE COLLATION(a)='binary' AND a='a'
|
||||
#
|
||||
CREATE TABLE t1 (a VARBINARY(10));
|
||||
INSERT INTO t1 VALUES ('a'),('A');
|
||||
SELECT * FROM t1 WHERE COLLATION(a)='binary' AND a='a';
|
||||
a
|
||||
a
|
||||
SELECT * FROM t1 WHERE CHARSET(a)='binary' AND a='a';
|
||||
a
|
||||
a
|
||||
SELECT * FROM t1 WHERE COERCIBILITY(a)=2 AND a='a';
|
||||
a
|
||||
a
|
||||
SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a' AND a='a';
|
||||
a
|
||||
a
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE COLLATION(a)='binary' AND a='a';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'a')
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE CHARSET(a)='binary' AND a='a';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'a')
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE COERCIBILITY(a)=2 AND a='a';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 'a')
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a' AND a='a';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (weight_string(`test`.`t1`.`a`) = 'a'))
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 10.1 tests
|
||||
#
|
||||
|
||||
@@ -56,6 +56,21 @@ SELECT * FROM t1 WHERE a='a ' AND LENGTH(a)=2;
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='a ' AND LENGTH(a)=2;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-8723 Wrong result for SELECT..WHERE COLLATION(a)='binary' AND a='a'
|
||||
--echo #
|
||||
CREATE TABLE t1 (a VARBINARY(10));
|
||||
INSERT INTO t1 VALUES ('a'),('A');
|
||||
SELECT * FROM t1 WHERE COLLATION(a)='binary' AND a='a';
|
||||
SELECT * FROM t1 WHERE CHARSET(a)='binary' AND a='a';
|
||||
SELECT * FROM t1 WHERE COERCIBILITY(a)=2 AND a='a';
|
||||
SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a' AND a='a';
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE COLLATION(a)='binary' AND a='a';
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE CHARSET(a)='binary' AND a='a';
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE COERCIBILITY(a)=2 AND a='a';
|
||||
EXPLAIN EXTENDED SELECT * FROM t1 WHERE WEIGHT_STRING(a)='a' AND a='a';
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.1 tests
|
||||
--echo #
|
||||
|
||||
@@ -1160,6 +1160,9 @@ public:
|
||||
const char *func_name() const { return "coercibility"; }
|
||||
void fix_length_and_dec() { max_length=10; maybe_null= 0; }
|
||||
table_map not_null_tables() const { return 0; }
|
||||
Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
|
||||
{ return this; }
|
||||
bool const_item() const { return true; }
|
||||
};
|
||||
|
||||
class Item_func_locate :public Item_int_func
|
||||
|
||||
@@ -1049,12 +1049,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class Item_func_charset :public Item_str_func
|
||||
|
||||
class Item_func_expr_str_metadata :public Item_str_func
|
||||
{
|
||||
public:
|
||||
Item_func_charset(THD *thd, Item *a): Item_str_func(thd, a) {}
|
||||
String *val_str(String *);
|
||||
const char *func_name() const { return "charset"; }
|
||||
Item_func_expr_str_metadata(THD *thd, Item *a): Item_str_func(thd, a) { }
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(system_charset_info);
|
||||
@@ -1062,23 +1061,32 @@ public:
|
||||
maybe_null= 0;
|
||||
};
|
||||
table_map not_null_tables() const { return 0; }
|
||||
Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
|
||||
{ return this; }
|
||||
bool const_item() const { return true; }
|
||||
};
|
||||
|
||||
class Item_func_collation :public Item_str_func
|
||||
|
||||
class Item_func_charset :public Item_func_expr_str_metadata
|
||||
{
|
||||
public:
|
||||
Item_func_collation(THD *thd, Item *a): Item_str_func(thd, a) {}
|
||||
Item_func_charset(THD *thd, Item *a)
|
||||
:Item_func_expr_str_metadata(thd, a) { }
|
||||
String *val_str(String *);
|
||||
const char *func_name() const { return "charset"; }
|
||||
};
|
||||
|
||||
|
||||
class Item_func_collation :public Item_func_expr_str_metadata
|
||||
{
|
||||
public:
|
||||
Item_func_collation(THD *thd, Item *a)
|
||||
:Item_func_expr_str_metadata(thd, a) {}
|
||||
String *val_str(String *);
|
||||
const char *func_name() const { return "collation"; }
|
||||
void fix_length_and_dec()
|
||||
{
|
||||
collation.set(system_charset_info);
|
||||
max_length= 64 * collation.collation->mbmaxlen; // should be enough
|
||||
maybe_null= 0;
|
||||
};
|
||||
table_map not_null_tables() const { return 0; }
|
||||
};
|
||||
|
||||
|
||||
class Item_func_weight_string :public Item_str_func
|
||||
{
|
||||
String tmp_value;
|
||||
@@ -1106,6 +1114,8 @@ public:
|
||||
this->nweights == that->nweights &&
|
||||
this->result_length == that->result_length;
|
||||
}
|
||||
Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
|
||||
{ return this; }
|
||||
};
|
||||
|
||||
class Item_func_crc32 :public Item_int_func
|
||||
|
||||
Reference in New Issue
Block a user