[Commits] Rev 3385: Merge in file:///home/igor/maria/maria-5.3-trunk/

Igor Babaev igor at askmonty.org
Thu Jan 19 00:19:29 EET 2012


At file:///home/igor/maria/maria-5.3-trunk/

------------------------------------------------------------
revno: 3385 [merge]
revision-id: igor at askmonty.org-20120118221928-tp5sdhflode98sot
parent: timour at askmonty.org-20120118105350-47hlgw7goy1nqn5v
parent: igor at askmonty.org-20120118113120-h49k42kfnfccob7v
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.3-trunk
timestamp: Wed 2012-01-18 14:19:28 -0800
message:
  Merge
modified:
  mysql-test/r/derived_view.result derived_view.result-20100429210222-m2cev70na5t81kgl-1
  mysql-test/r/view.result       sp1f-view.result-20040715221517-nqk3l34grrhprjiitidhfjyjqlgh6a5v
  mysql-test/suite/vcol/r/vcol_view_innodb.result vcol_view_innodb.res-20091016212105-1lx2muao9vwbl1c1-48
  mysql-test/suite/vcol/r/vcol_view_myisam.result vcol_view_myisam.res-20091016212105-1lx2muao9vwbl1c1-49
  mysql-test/t/derived_view.test derived_view.test-20100429210209-ex88ainrb3oc2d4n-1
  sql/sql_derived.cc             sp1f-sql_derived.cc-20020326130604-4qz6ovo2xa6w5eslbmcx76agmnyyvsfh
  sql/sql_select.cc              sp1f-sql_select.cc-19700101030959-egb7whpkh76zzvikycs5nsnuviu4fdlb
-------------- next part --------------
=== modified file 'mysql-test/r/derived_view.result'
--- a/mysql-test/r/derived_view.result	2012-01-13 12:35:49 +0000
+++ b/mysql-test/r/derived_view.result	2012-01-18 22:19:28 +0000
@@ -1889,5 +1889,22 @@
 col_varchar_key	pk	col_varchar_key	col_varchar_nokey
 set max_heap_table_size= @tmp_882994;
 drop table t1,t2,t3;
+#
+# LP bug #917990: Bad estimate of #rows for derived table with LIMIT
+#
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES
+(8), (3), (4), (7), (9), (5), (1), (2);
+SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
+a
+8
+3
+4
+EXPLAIN
+SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	3	
+2	DERIVED	t1	ALL	NULL	NULL	NULL	NULL	8	
+DROP TABLE t1;
 set optimizer_switch=@exit_optimizer_switch;
 set join_cache_level=@exit_join_cache_level;

=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2012-01-18 10:53:50 +0000
+++ b/mysql-test/r/view.result	2012-01-18 22:19:28 +0000
@@ -304,7 +304,7 @@
 4
 explain select * from v1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	4	
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	2	
 2	DERIVED	t1	ALL	NULL	NULL	NULL	NULL	4	Using filesort
 drop view v1;
 drop table t1;

=== modified file 'mysql-test/suite/vcol/r/vcol_view_innodb.result'
--- a/mysql-test/suite/vcol/r/vcol_view_innodb.result	2011-12-15 08:21:15 +0000
+++ b/mysql-test/suite/vcol/r/vcol_view_innodb.result	2012-01-18 11:31:20 +0000
@@ -107,7 +107,7 @@
 MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
 explain select * from v1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	4	
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	2	
 2	DERIVED	t1	ALL	NULL	NULL	NULL	NULL	4	Using filesort
 drop view v1;
 create view v1 as select c+1 from t1 order by 1 desc limit 2;
@@ -119,7 +119,7 @@
 MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
 explain select * from v1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	4	
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	2	
 2	DERIVED	t1	ALL	NULL	NULL	NULL	NULL	4	Using filesort
 drop view v1;
 drop table t1;

=== modified file 'mysql-test/suite/vcol/r/vcol_view_myisam.result'
--- a/mysql-test/suite/vcol/r/vcol_view_myisam.result	2011-12-15 08:21:15 +0000
+++ b/mysql-test/suite/vcol/r/vcol_view_myisam.result	2012-01-18 11:31:20 +0000
@@ -107,7 +107,7 @@
 MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
 explain select * from v1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	4	
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	2	
 2	DERIVED	t1	ALL	NULL	NULL	NULL	NULL	4	Using filesort
 drop view v1;
 create view v1 as select c+1 from t1 order by 1 desc limit 2;
@@ -119,7 +119,7 @@
 MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
 explain select * from v1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	4	
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	2	
 2	DERIVED	t1	ALL	NULL	NULL	NULL	NULL	4	Using filesort
 drop view v1;
 drop table t1;

=== modified file 'mysql-test/t/derived_view.test'
--- a/mysql-test/t/derived_view.test	2011-12-24 16:55:10 +0000
+++ b/mysql-test/t/derived_view.test	2012-01-18 11:31:20 +0000
@@ -1277,6 +1277,20 @@
 set max_heap_table_size= @tmp_882994;
 drop table t1,t2,t3;
 
+--echo #
+--echo # LP bug #917990: Bad estimate of #rows for derived table with LIMIT
+--echo #
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES
+  (8), (3), (4), (7), (9), (5), (1), (2);
+
+SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
+EXPLAIN
+SELECT * FROM (SELECT * FROM t1 LIMIT 3) t;
+
+DROP TABLE t1;
+
 # The following command must be the last one the file 
 set optimizer_switch=@exit_optimizer_switch;
 set join_cache_level=@exit_join_cache_level;

=== modified file 'sql/sql_derived.cc'
--- a/sql/sql_derived.cc	2011-12-14 18:36:51 +0000
+++ b/sql/sql_derived.cc	2012-01-18 11:31:20 +0000
@@ -753,6 +753,7 @@
     if (!derived->is_merged_derived())
     {
       JOIN *join= first_select->join;
+      unit->set_limit(first_select);
       unit->optimized= TRUE;
       if ((res= join->optimize()))
         goto err;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2012-01-11 08:35:16 +0000
+++ b/sql/sql_select.cc	2012-01-18 11:31:20 +0000
@@ -3581,6 +3581,7 @@
       for (i= 0; i < join->table_count ; i++)
         records*= join->best_positions[i].records_read ?
                   (ha_rows)join->best_positions[i].records_read : 1;
+      set_if_smaller(records, unit->select_limit_cnt);
       join->select_lex->increase_derived_records(records);
     }
   }



More information about the commits mailing list