mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
3915c3d94c
Disable const propagation for Item_hex_string. This must be done because Item_hex_string->val_int() is not the same as (Item_hex_string->val_str() in BINARY column)->val_int(). We cannot simply disable the replacement in a particular context ( e.g. <bin_col> = <int_col> AND <bin_col> = <hex_string>) since Items don't know the context they are in and there are functions like IF (<hex_string>, 'yes', 'no'). Note that this will disable some valid cases as well (e.g. : <bin_col> = <hex_string> AND <bin_col2> = <bin_col>) but there's no way to distinguish the valid cases without having the Item's parent say something like : Item->set_context(Item::STRING_RESULT) and have all the Items that contain other Items do that consistently. mysql-test/r/compare.result: Bug #21159: Optimizer: wrong result after AND with different data types - test case mysql-test/t/compare.test: Bug #21159: Optimizer: wrong result after AND with different data types - test case sql/sql_select.cc: Bug #21159: Optimizer: wrong result after AND with different data types - disable const propagation for Item_hex_string.
48 lines
1.1 KiB
Text
48 lines
1.1 KiB
Text
#
|
|
# Bug when using comparions of strings and integers.
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
|
|
CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
|
|
insert into t1 values ('000000000001'),('000000000002');
|
|
explain select * from t1 where id=000000000001;
|
|
select * from t1 where id=000000000001;
|
|
delete from t1 where id=000000000002;
|
|
select * from t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# Check the following:
|
|
# "a" == "a "
|
|
# "a\0" < "a"
|
|
# "a\0" < "a "
|
|
|
|
SELECT 'a' = 'a ';
|
|
SELECT 'a\0' < 'a';
|
|
SELECT 'a\0' < 'a ';
|
|
SELECT 'a\t' < 'a';
|
|
SELECT 'a\t' < 'a ';
|
|
|
|
CREATE TABLE t1 (a char(10) not null);
|
|
INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
|
|
SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
|
|
DROP TABLE t1;
|
|
|
|
# Bug #8134: Comparison against CHAR(31) at end of string
|
|
SELECT CHAR(31) = '', '' = CHAR(31);
|
|
# Extra test
|
|
SELECT CHAR(30) = '', '' = CHAR(30);
|
|
|
|
# End of 4.1 tests
|
|
|
|
#
|
|
#Bug #21159: Optimizer: wrong result after AND with different data types
|
|
#
|
|
create table t1 (a tinyint(1),b binary(1));
|
|
insert into t1 values (0x01,0x01);
|
|
select * from t1 where a=b;
|
|
select * from t1 where a=b and b=0x01;
|
|
drop table if exists t1;
|