mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-30 04:26:45 +03:00 
			
		
		
		
	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.
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| drop table if exists t1;
 | |
| CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
 | |
| insert into t1 values ('000000000001'),('000000000002');
 | |
| explain select * from t1 where id=000000000001;
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 | |
| 1	SIMPLE	t1	index	PRIMARY	PRIMARY	12	NULL	2	Using where; Using index
 | |
| select * from t1 where id=000000000001;
 | |
| id
 | |
| 000000000001
 | |
| delete from t1 where id=000000000002;
 | |
| select * from t1;
 | |
| id
 | |
| 000000000001
 | |
| drop table t1;
 | |
| SELECT 'a' = 'a ';
 | |
| 'a' = 'a '
 | |
| 1
 | |
| SELECT 'a\0' < 'a';
 | |
| 'a\0' < 'a'
 | |
| 1
 | |
| SELECT 'a\0' < 'a ';
 | |
| 'a\0' < 'a '
 | |
| 1
 | |
| SELECT 'a\t' < 'a';
 | |
| 'a\t' < 'a'
 | |
| 1
 | |
| SELECT 'a\t' < 'a ';
 | |
| 'a\t' < 'a '
 | |
| 1
 | |
| 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;
 | |
| hex(a)	STRCMP(a,'a')	STRCMP(a,'a ')
 | |
| 61	0	0
 | |
| 6100	-1	-1
 | |
| 6109	-1	-1
 | |
| 61	0	0
 | |
| DROP TABLE t1;
 | |
| SELECT CHAR(31) = '', '' = CHAR(31);
 | |
| CHAR(31) = ''	'' = CHAR(31)
 | |
| 0	0
 | |
| SELECT CHAR(30) = '', '' = CHAR(30);
 | |
| CHAR(30) = ''	'' = CHAR(30)
 | |
| 0	0
 | |
| create table t1 (a tinyint(1),b binary(1));
 | |
| insert into t1 values (0x01,0x01);
 | |
| select * from t1 where a=b;
 | |
| a	b
 | |
| select * from t1 where a=b and b=0x01;
 | |
| a	b
 | |
| drop table if exists t1;
 |