Commit 944030ae authored by unknown's avatar unknown
Browse files

Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized

away.

Additional fix for bug#22331. Now Item_field prints its value in the case of
the const field.


mysql-test/r/varbinary.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/union.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/subselect.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/func_test.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/having.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/func_regexp.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/func_str.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/func_default.result:
  Corrected test case after fix for bug#22331.
mysql-test/r/explain.result:
  Corrected test case after fix for bug#22331.
sql/sql_union.cc:
  Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized
  away.
  Cleanup of the SELECT_LEX::order_list list.
sql/item.h:
  Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized
  away.
  Added the print() member function to the Item_field class.
sql/item.cc:
  Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized
  away.
  Added the print() member function to the Item_field class.
parent 1631f65d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ explain extended select * from v1 where f2=1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
Warnings:
Note	1003	select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` where 1
Note	1003	select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
explain extended select * from t1 where 0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE
@@ -74,7 +74,7 @@ explain extended select * from t1 where 1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
Warnings:
Note	1003	select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` where 1
Note	1003	select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
explain extended select * from t1 having 0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible HAVING
@@ -84,6 +84,6 @@ explain extended select * from t1 having 1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
Warnings:
Note	1003	select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` having 1
Note	1003	select '1' AS `f1`,'1' AS `f2` from `test`.`t1` having 1
drop view v1;
drop table t1;
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ explain extended select default(str), default(strnull), default(intg), default(r
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
Warnings:
Note	1003	select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from `test`.`t1`
Note	1003	select default('') AS `default(str)`,default('') AS `default(strnull)`,default('0') AS `default(intg)`,default('0') AS `default(rel)` from `test`.`t1`
select * from t1 where str <> default(str);
str	strnull	intg	rel
		0	0
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ explain extended select * from t1 where xxx regexp('is a test of some long text
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
Warnings:
Note	1003	select `test`.`t1`.`xxx` AS `xxx` from `test`.`t1` where (`test`.`t1`.`xxx` regexp _latin1'is a test of some long text to')
Note	1003	select 'this is a test of some long text to see what happens' AS `xxx` from `test`.`t1` where ('this is a test of some long text to see what happens' regexp _latin1'is a test of some long text to')
select * from t1 where xxx regexp('is a test of some long text to ');
xxx
this is a test of some long text to see what happens
+3 −3
Original line number Diff line number Diff line
@@ -1089,12 +1089,12 @@ explain extended select encode(f1,'zxcv') as 'enc' from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	0	const row not found
Warnings:
Note	1003	select encode(`test`.`t1`.`f1`,'zxcv') AS `enc` from `test`.`t1`
Note	1003	select encode('','zxcv') AS `enc` from `test`.`t1`
explain extended select decode(f1,'zxcv') as 'enc' from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	0	const row not found
Warnings:
Note	1003	select decode(`test`.`t1`.`f1`,'zxcv') AS `enc` from `test`.`t1`
Note	1003	select decode('','zxcv') AS `enc` from `test`.`t1`
drop table t1;
End of 4.1 tests
create table t1 (d decimal default null);
@@ -1158,7 +1158,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1	SIMPLE	t2	const	PRIMARY	PRIMARY	12	const	1	Using index
1	SIMPLE	t1	ref	code	code	13	const	3	Using where; Using index
Warnings:
Note	1003	select `test`.`t1`.`code` AS `code`,`test`.`t2`.`id` AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = _latin1'a12') and (length(`test`.`t1`.`code`) = 5))
Note	1003	select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = _latin1'a12') and (length(`test`.`t1`.`code`) = 5))
DROP TABLE t1,t2;
select locate('he','hello',-2);
locate('he','hello',-2)
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ explain extended select - a from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
Warnings:
Note	1003	select -(`test`.`t1`.`a`) AS `- a` from `test`.`t1`
Note	1003	select -('1') AS `- a` from `test`.`t1`
drop table t1;
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
5 between 0 and 10 between 0 and 1	(5 between 0 and 10) between 0 and 1
Loading