mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-25 18:38:00 +03:00 
			
		
		
		
	EXPLAIN EXTENDED warning.
Query optimizer searches for the constant tables and optimizes them away. This
means that fields of such tables are substituted for their values and on later
phases they are treated as constants. After this constant tables are removed
from the query execution plan. Nevertheless constant tables were shown in 
the EXPLAIN EXTENDED warning thus producing query that might be not an
equivalent of the original query.
        
Now the print_join function skips all tables that were optimized away from
printing to the EXPLAIN EXTENDED warning. If all tables were optimized away it
produces the 'FROM dual' clause.
mysql-test/r/explain.result:
  A test case added for the bug#30302.
mysql-test/r/func_default.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/func_regexp.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/func_test.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/having.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/select.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/subselect.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/subselect3.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/r/type_datetime.result:
  Adjusted test case result after fix for the bug#30302.
mysql-test/t/explain.test:
  A test case added for the bug#30302.
sql/sql_select.cc:
  Bug#30302: Tables that were optimized away are printed in the
  EXPLAIN EXTENDED warning.
  Now the print_join function skips all tables that were optimized away from
  printing to the EXPLAIN EXTENDED warning. If all tables were optimized away it
  produces the 'FROM dual' clause.
sql/table.h:
  Adjusted test case result after fix for the bug#30302.
  The optimized_away flag is added to the TABLE_LIST struct.
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| drop table if exists t1,t2;
 | |
| create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
 | |
| insert into t1 values ('','',0,0.0);
 | |
| select default(str), default(strnull), default(intg), default(rel) from t1;
 | |
| default(str)	default(strnull)	default(intg)	default(rel)
 | |
| def	NULL	10	3.14
 | |
| explain extended select default(str), default(strnull), default(intg), default(rel) from t1;
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 | |
| 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	100.00	
 | |
| Warnings:
 | |
| Note	1003	select default('') AS `default(str)`,default('') AS `default(strnull)`,default('0') AS `default(intg)`,default('0') AS `default(rel)` from dual
 | |
| select * from t1 where str <> default(str);
 | |
| str	strnull	intg	rel
 | |
| 		0	0
 | |
| explain select * from t1 where str <> default(str);
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 | |
| 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
 | |
| drop table t1;
 | |
| CREATE TABLE t1 (id int(11), s varchar(20));
 | |
| INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
 | |
| SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL;
 | |
| ERROR HY000: Field 'mi' doesn't have a default value
 | |
| DROP TABLE t1;
 |