List:Commits« Previous MessageNext Message »
From:kevin.lewis Date:May 15 2012 11:37am
Subject:bzr push into mysql-trunk branch (kevin.lewis:3827)
View as plain text  
 3827 kevin.lewis@stripped	2012-05-15 [merge]
      merge

    added:
      mysql-test/suite/innodb/r/InnoDB-wl5980-Linux.result
      mysql-test/suite/innodb/t/InnoDB-wl5980-Linux.test
      mysql-test/suite/innodb/t/Portability-WL5980-Linux.zip
=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/collections/default.experimental	revid:kevin.lewis@stripped
@@ -12,7 +12,7 @@ main.sp @solaris                        
 
 main.bug33509 @solaris                   # Bug#11753919 2012-02-16 didrik Several test cases fail on Solaris with error Thread stack overrun
 
-main.index_merge_innodb                  # BUG#45727    2012-05-08 jorgen Doing an attempt at reenabling tests disabled by bug. EXPLAIN's row estimates varies for innodb so marked experimental for a while
+main.index_merge_innodb                  # BUG#11754168 2012-05-08 jorgen Doing an attempt at reenabling tests disabled by bug. EXPLAIN's row estimates varies for innodb so marked experimental for a while
 main.kill @freebsd                       # Bug#12619719 2011-08-04 Occasional failure in PB2
 
 innodb.innodb_monitor                    # Bug#12320827 2011-08-04 Occasional failure in PB2

=== modified file 'mysql-test/include/index_merge1.inc'
--- a/mysql-test/include/index_merge1.inc	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/include/index_merge1.inc	revid:kevin.lewis@stripped
@@ -499,6 +499,10 @@ explain select max(A.key1 + B.key1 + A.k
  where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
   and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
 
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+  --replace_column 9 #
+}
 select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
  from t0 as A, t0 as B
  where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)

=== modified file 'mysql-test/include/index_merge_ror.inc'
--- a/mysql-test/include/index_merge_ror.inc	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/include/index_merge_ror.inc	revid:kevin.lewis@stripped
@@ -215,6 +215,10 @@ explain select * from t1 where st_a=1 an
 
 explain select * from t1 where st_b=1 and swt1b=1 and swt2b=1;
 
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+  --replace_column 9 #
+}
 explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
 
 if ($index_merge_random_rows_in_EXPLAIN)
@@ -238,15 +242,31 @@ if ($index_merge_random_rows_in_EXPLAIN)
 explain select * from t1 ignore index (sta_swt21a, sta_swt12a, stb_swt1a_2b, stb_swt1b)
   where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
 
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+  --replace_column 9 #
+}
 explain select * from t1
   where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1;
 
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+  --replace_column 9 #
+}
 explain select * from t1
   where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
 
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+  --replace_column 9 #
+}
 explain select st_a from t1
   where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
 
+if ($index_merge_random_rows_in_EXPLAIN)
+{
+  --replace_column 9 #
+}
 explain select st_a from t1
   where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
 

=== modified file 'mysql-test/r/blackhole.result'
--- a/mysql-test/r/blackhole.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/blackhole.result	revid:kevin.lewis@stripped
@@ -9,3 +9,11 @@ SELECT 1 FROM t1 WHERE a = ANY (SELECT a
 1
 DROP TABLE t1, t2;
 End of 5.5 tests 
+#
+# Bug#13948247 DIVISION BY 0 IN GET_BEST_DISJUNCT_QUICK WITH FORCE INDEX GROUP BY
+#
+CREATE TABLE t1(a INT, b INT, c INT, KEY(c), UNIQUE(a)) ENGINE = BLACKHOLE;
+SELECT 0 FROM t1 FORCE INDEX FOR GROUP BY(a) WHERE a = 0 OR b = 0 AND c = 0;
+0
+DROP TABLE t1;
+End of 5.6 tests

=== modified file 'mysql-test/r/explain_json_all.result'
--- a/mysql-test/r/explain_json_all.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/explain_json_all.result	revid:kevin.lewis@stripped
@@ -266,7 +266,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 7,
       "filtered": 100,
-      "attached_condition": "(<in_optimizer>(`test`.`t1`.`i`,<exists>(select 1 from `test`.`t2` where ((`test`.`t1`.`i` = 10) and (<cache>(`test`.`t1`.`i`) = `test`.`t2`.`i`)))) or <in_optimizer>(`test`.`t1`.`i`,`test`.`t1`.`i` in ( <materialize> (select `test`.`t4`.`i` from `test`.`t4` ), <primary_index_lookup>(`test`.`t1`.`i` in <temporary table> on distinct_key where ((`test`.`t1`.`i` = `materialized subselect`.`i`))))))",
+      "attached_condition": "(<in_optimizer>(`test`.`t1`.`i`,<exists>(select 1 from `test`.`t2` where ((`test`.`t1`.`i` = 10) and (<cache>(`test`.`t1`.`i`) = `test`.`t2`.`i`)))) or <in_optimizer>(`test`.`t1`.`i`,`test`.`t1`.`i` in ( <materialize> (select NULL from `test`.`t4` ), <primary_index_lookup>(`test`.`t1`.`i` in <temporary table> on distinct_key where ((`test`.`t1`.`i` = `materialized subselect`.`i`))))))",
       "attached_subqueries": [
         {
           "using_temporary_table": true,
@@ -899,7 +899,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 1,
       "filtered": 100,
-      "attached_condition": "exists(select `test`.`t2`.`c1` from (`test`.`t2` join `test`.`t3` on((`test`.`t3`.`c1` = `test`.`t2`.`c1`))) where ((`test`.`t2`.`c2` <> `test`.`t1`.`c1`) and (`test`.`t2`.`c2` = (select min(`test`.`t3`.`c1`) from `test`.`t3`))))",
+      "attached_condition": "exists(select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t2`.`c2` = (select min(`test`.`t3`.`c1`) from `test`.`t3`)) and ((select min(`test`.`t3`.`c1`) from `test`.`t3`) <> `test`.`t1`.`c1`)))",
       "attached_subqueries": [
         {
           "dependent": true,

=== modified file 'mysql-test/r/explain_json_none.result'
--- a/mysql-test/r/explain_json_none.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/explain_json_none.result	revid:kevin.lewis@stripped
@@ -267,7 +267,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 7,
       "filtered": 100,
-      "attached_condition": "(<in_optimizer>(`test`.`t1`.`i`,<exists>(select 1 from `test`.`t2` where ((`test`.`t1`.`i` = 10) and (<cache>(`test`.`t1`.`i`) = `test`.`t2`.`i`)))) or <in_optimizer>(`test`.`t1`.`i`,<exists>(select 1 from `test`.`t4` where (<cache>(`test`.`t1`.`i`) = `test`.`t4`.`i`))))",
+      "attached_condition": "(<in_optimizer>(`test`.`t1`.`i`,<exists>(select 1 from `test`.`t2` where ((`test`.`t1`.`i` = 10) and (<cache>(`test`.`t1`.`i`) = `test`.`t2`.`i`)))) or <in_optimizer>(`test`.`t1`.`i`,<exists>(select 1 from `test`.`t4` where 0)))",
       "attached_subqueries": [
         {
           "dependent": true,
@@ -899,7 +899,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 1,
       "filtered": 100,
-      "attached_condition": "exists(select `test`.`t2`.`c1` from (`test`.`t2` join `test`.`t3` on((`test`.`t3`.`c1` = `test`.`t2`.`c1`))) where ((`test`.`t2`.`c2` <> `test`.`t1`.`c1`) and (`test`.`t2`.`c2` = (select min(`test`.`t3`.`c1`) from `test`.`t3`))))",
+      "attached_condition": "exists(select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t2`.`c2` = (select min(`test`.`t3`.`c1`) from `test`.`t3`)) and ((select min(`test`.`t3`.`c1`) from `test`.`t3`) <> `test`.`t1`.`c1`)))",
       "attached_subqueries": [
         {
           "dependent": true,
@@ -1007,7 +1007,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 3,
       "filtered": 100,
-      "attached_condition": "(<in_optimizer>(`test`.`t5`.`c`,<exists>(select 1 from (`test`.`t1` join `test`.`t2` on((`test`.`t2`.`c_key` = `test`.`t1`.`c_key`))) where (<cache>(`test`.`t5`.`c`) = `test`.`t2`.`c`))) and <in_optimizer>(`test`.`t5`.`c`,<exists>(select 1 from (`test`.`t3` join `test`.`t4` on((`test`.`t4`.`c_key` = `test`.`t3`.`c_key`))) where (<cache>(`test`.`t5`.`c`) = `test`.`t4`.`c`))))",
+      "attached_condition": "(<in_optimizer>(`test`.`t5`.`c`,<exists>(select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`c_key` = `test`.`t2`.`c_key`) and (<cache>(`test`.`t5`.`c`) = `test`.`t2`.`c`)))) and <in_optimizer>(`test`.`t5`.`c`,<exists>(select 1 from `test`.`t3` join `test`.`t4` where ((`test`.`t3`.`c_key` = `test`.`t4`.`c_key`) and (<cache>(`test`.`t5`.`c`) = `test`.`t4`.`c`)))))",
       "attached_subqueries": [
         {
           "dependent": true,
@@ -1773,7 +1773,7 @@ EXPLAIN
       "rows": 4,
       "filtered": 100,
       "using_index": true,
-      "attached_condition": "<in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))",
+      "attached_condition": "<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))",
       "attached_subqueries": [
         {
           "dependent": true,

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/func_time.result	revid:kevin.lewis@stripped
@@ -1787,3 +1787,7 @@ DROP TABLE t1;
 DO maketime(~0, 49, 0.123456789);
 Warnings:
 Warning	1292	Truncated incorrect time value: '18446744073709551615:49:00.123456789'
+#
+# Bug#14042545 ASSERTION FAILED: DEC <= 6 IN MY_USECONDS_TO_STR()
+#
+DO is_used_lock(ifnull(now(), CASE 1 WHEN 1 THEN NULL END));

=== modified file 'mysql-test/r/index_merge_innodb.result'
--- a/mysql-test/r/index_merge_innodb.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/index_merge_innodb.result	revid:kevin.lewis@stripped
@@ -759,7 +759,7 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ref	stb_swt1a_2b,stb_swt1b,st_b	stb_swt1a_2b	8	const,const	3999	Using where
 explain select * from t1 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a,stb_swt1a_2b	12,12	NULL	61	Using intersect(sta_swt12a,stb_swt1a_2b); Using where
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a,stb_swt1a_2b	12,12	NULL	#	Using intersect(sta_swt12a,stb_swt1a_2b); Using where
 explain select * from t1 ignore index (sta_swt21a, stb_swt1a_2b)
 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1 and swt2b=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
@@ -775,19 +775,19 @@ id	select_type	table	type	possible_keys	
 explain select * from t1
 where st_a=1 and swt1a=1 and swt2a=1 and st_b=1 and swt1b=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a,stb_swt1a_2b	12,12	NULL	61	Using intersect(sta_swt12a,stb_swt1a_2b); Using where
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt12a,stb_swt1a_2b	12,12	NULL	#	Using intersect(sta_swt12a,stb_swt1a_2b); Using where
 explain select * from t1
 where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt1a,stb_swt1b	8,8	NULL	246	Using intersect(sta_swt1a,stb_swt1b); Using where
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt1a,stb_swt1b	8,8	NULL	#	Using intersect(sta_swt1a,stb_swt1b); Using where
 explain select st_a from t1
 where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt1a,stb_swt1b	8,8	NULL	246	Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt1a,stb_swt1b	8,8	NULL	#	Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
 explain select st_a from t1
 where st_a=1 and swt1a=1 and st_b=1 and swt1b=1 and swt1b=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt1a,stb_swt1b	8,8	NULL	246	Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
+1	SIMPLE	t1	index_merge	sta_swt12a,sta_swt1a,sta_swt2a,sta_swt21a,st_a,stb_swt1a_2b,stb_swt1b,st_b	sta_swt1a,stb_swt1b	8,8	NULL	#	Using intersect(sta_swt1a,stb_swt1b); Using where; Using index
 drop table t0,t1;
 create table t2 (
 a char(10),

=== modified file 'mysql-test/r/information_schema.result'
--- a/mysql-test/r/information_schema.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/information_schema.result	revid:kevin.lewis@stripped
@@ -2088,5 +2088,10 @@ MAX(a)
 1
 DROP TABLE t1;
 #
+# BUG#13463397 - 63562: UNKNOWN DATABASE INFORMATION_SCHEMA 
+#
+CREATE PROCEDURE information_schema.is() BEGIN END;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
+#
 # End of 5.6 tests
 #

=== modified file 'mysql-test/r/innodb_explain_json_non_select_all.result'
--- a/mysql-test/r/innodb_explain_json_non_select_all.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/innodb_explain_json_non_select_all.result	revid:kevin.lewis@stripped
@@ -479,7 +479,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 3,
       "filtered": 100,
-      "attached_condition": "<in_optimizer>(1,<exists>(select 1 from `test`.`t2` where ((`test`.`t2`.`b` < 3) and (<cache>(1) = 1))))",
+      "attached_condition": "<in_optimizer>(1,<exists>(select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3)))",
       "attached_subqueries": [
         {
           "dependent": true,

=== modified file 'mysql-test/r/innodb_explain_json_non_select_none.result'
--- a/mysql-test/r/innodb_explain_json_non_select_none.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/innodb_explain_json_non_select_none.result	revid:kevin.lewis@stripped
@@ -478,7 +478,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 3,
       "filtered": 100,
-      "attached_condition": "<in_optimizer>(1,<exists>(select 1 from `test`.`t2` where ((`test`.`t2`.`b` < 3) and (<cache>(1) = 1))))",
+      "attached_condition": "<in_optimizer>(1,<exists>(select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3)))",
       "attached_subqueries": [
         {
           "dependent": true,
@@ -5949,7 +5949,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 3,
       "filtered": 100,
-      "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+      "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
       "attached_subqueries": [
         {
           "dependent": true,
@@ -6047,7 +6047,7 @@ EXPLAIN
           "access_type": "ALL",
           "rows": 3,
           "filtered": 100,
-          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
           "attached_subqueries": [
             {
               "dependent": true,
@@ -6127,7 +6127,7 @@ EXPLAIN
           "access_type": "ALL",
           "rows": 3,
           "filtered": 100,
-          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
           "attached_subqueries": [
             {
               "dependent": true,
@@ -6237,7 +6237,7 @@ EXPLAIN
           "access_type": "ALL",
           "rows": 3,
           "filtered": 100,
-          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
           "attached_subqueries": [
             {
               "dependent": true,
@@ -6332,7 +6332,7 @@ EXPLAIN
           "access_type": "ALL",
           "rows": 3,
           "filtered": 100,
-          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
           "attached_subqueries": [
             {
               "dependent": true,

=== modified file 'mysql-test/r/myisam_explain_json_non_select_all.result'
--- a/mysql-test/r/myisam_explain_json_non_select_all.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/myisam_explain_json_non_select_all.result	revid:kevin.lewis@stripped
@@ -459,7 +459,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 3,
       "filtered": 100,
-      "attached_condition": "<in_optimizer>(1,<exists>(select 1 from `test`.`t2` where ((`test`.`t2`.`b` < 3) and (<cache>(1) = 1))))",
+      "attached_condition": "<in_optimizer>(1,<exists>(select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3)))",
       "attached_subqueries": [
         {
           "dependent": true,

=== modified file 'mysql-test/r/myisam_explain_json_non_select_none.result'
--- a/mysql-test/r/myisam_explain_json_non_select_none.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/myisam_explain_json_non_select_none.result	revid:kevin.lewis@stripped
@@ -458,7 +458,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 3,
       "filtered": 100,
-      "attached_condition": "<in_optimizer>(1,<exists>(select 1 from `test`.`t2` where ((`test`.`t2`.`b` < 3) and (<cache>(1) = 1))))",
+      "attached_condition": "<in_optimizer>(1,<exists>(select 1 from `test`.`t2` where (`test`.`t2`.`b` < 3)))",
       "attached_subqueries": [
         {
           "dependent": true,
@@ -5818,7 +5818,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 3,
       "filtered": 100,
-      "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+      "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
       "attached_subqueries": [
         {
           "dependent": true,
@@ -5913,7 +5913,7 @@ EXPLAIN
           "access_type": "ALL",
           "rows": 3,
           "filtered": 100,
-          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
           "attached_subqueries": [
             {
               "dependent": true,
@@ -5993,7 +5993,7 @@ EXPLAIN
           "access_type": "ALL",
           "rows": 3,
           "filtered": 100,
-          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
           "attached_subqueries": [
             {
               "dependent": true,
@@ -6101,7 +6101,7 @@ EXPLAIN
           "access_type": "ALL",
           "rows": 3,
           "filtered": 100,
-          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
           "attached_subqueries": [
             {
               "dependent": true,
@@ -6196,7 +6196,7 @@ EXPLAIN
           "access_type": "ALL",
           "rows": 3,
           "filtered": 100,
-          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from (select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` where (<cache>(`test`.`t1`.`a`) = `x`.`b`)))",
+          "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in x on auto_key0)))",
           "attached_subqueries": [
             {
               "dependent": true,

=== modified file 'mysql-test/r/partition_binlog.result'
--- a/mysql-test/r/partition_binlog.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/partition_binlog.result	revid:kevin.lewis@stripped
@@ -8,6 +8,7 @@ PARTITION BY RANGE (id)
 (PARTITION p0 VALUES LESS THAN (100),
 PARTITION pmax VALUES LESS THAN (MAXVALUE));
 INSERT INTO t1 VALUES (1), (10), (100), (1000);
+RESET MASTER;
 ALTER TABLE t1 TRUNCATE PARTITION p1;
 ERROR HY000: Incorrect partition name
 ALTER TABLE t1 DROP PARTITION p1;

=== modified file 'mysql-test/r/subquery_sj_mat_nosj.result'
--- a/mysql-test/r/subquery_sj_mat_nosj.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/subquery_sj_mat_nosj.result	revid:kevin.lewis@stripped
@@ -5566,7 +5566,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 16,
       "filtered": 100,
-      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,`test`.`t2`.`Code` in ( <materialize> (select `test`.`t1`.`Country` from `test`.`t1` where (`test`.`t1`.`Population` > 5000000) ), <primary_index_lookup>(`test`.`t2`.`Code` in <temporary table> on distinct_key where ((`test`.`t2`.`Code` = `materialized subselect`.`Country`))))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t3` where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`)))))",
+      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,`test`.`t2`.`Code` in ( <materialize> (select `test`.`t1`.`Country` from `test`.`t1` where (`test`.`t1`.`Population` > 5000000) ), <primary_index_lookup>(`test`.`t2`.`Code` in <temporary table> on distinct_key where ((`test`.`t2`.`Code` = `materialized subselect`.`Country`))))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`Code`) in t3 on PRIMARY where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`))))))",
       "attached_subqueries": [
         {
           "dependent": true,
@@ -7346,7 +7346,7 @@ EXPLAIN
             ],
             "rows": 11,
             "filtered": 100,
-            "attached_condition": "(<in_optimizer>((`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_key`),(`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_key`) in ( <materialize> (select `test`.`parent1`.`col_int_key` AS `p1`,`test`.`parent1`.`col_int_key` AS `p2` from (`test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent1`.`col_int_nokey` = `test`.`parent2`.`col_int_key`))) ), <primary_index_lookup>(`test`.`grandparent1`.`col_int_nokey` in <temporary table> on distinct_key where ((`test`.`grandparent1`.`col_int_nokey` = `materialized subselect`.`p1`) and (`test`.`grandparent1`.`col_int_key` = `materialized subselect`.`p2`))))) and (`test`.`grandparent1`.`col_int_key` <> 3))",
+            "attached_condition": "(<in_optimizer>((`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_key`),(`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_key`) in ( <materialize> (select `test`.`parent1`.`col_int_key` AS `p1`,`test`.`parent1`.`col_int_key` AS `p2` from `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent1`.`col_int_nokey` = `test`.`parent2`.`col_int_key`)) where 1 ), <primary_index_lookup>(`test`.`grandparent1`.`col_int_nokey` in <temporary table> on distinct_key where ((`test`.`grandparent1`.`col_int_nokey` = `materialized subselect`.`p1`) and (`test`.`grandparent1`.`col_int_key` = `materialized subselect`.`p2`))))) and (`test`.`grandparent1`.`col_int_key` <> 3))",
             "attached_subqueries": [
               {
                 "using_temporary_table": true,

=== modified file 'mysql-test/r/subquery_sj_none.result'
--- a/mysql-test/r/subquery_sj_none.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/subquery_sj_none.result	revid:kevin.lewis@stripped
@@ -5486,7 +5486,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 16,
       "filtered": 100,
-      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`Population` > 5000000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t1`.`Country`)))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t3` where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`)))))",
+      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`Population` > 5000000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t1`.`Country`)))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`Code`) in t3 on PRIMARY where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`))))))",
       "attached_subqueries": [
         {
           "dependent": true,

=== modified file 'mysql-test/r/subquery_sj_none_bka.result'
--- a/mysql-test/r/subquery_sj_none_bka.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/subquery_sj_none_bka.result	revid:kevin.lewis@stripped
@@ -5487,7 +5487,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 16,
       "filtered": 100,
-      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`Population` > 5000000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t1`.`Country`)))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t3` where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`)))))",
+      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`Population` > 5000000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t1`.`Country`)))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`Code`) in t3 on PRIMARY where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`))))))",
       "attached_subqueries": [
         {
           "dependent": true,

=== modified file 'mysql-test/r/subquery_sj_none_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_none_bka_nixbnl.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/subquery_sj_none_bka_nixbnl.result	revid:kevin.lewis@stripped
@@ -5486,7 +5486,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 16,
       "filtered": 100,
-      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`Population` > 5000000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t1`.`Country`)))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t3` where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`)))))",
+      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`Population` > 5000000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t1`.`Country`)))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`Code`) in t3 on PRIMARY where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`))))))",
       "attached_subqueries": [
         {
           "dependent": true,

=== modified file 'mysql-test/r/subquery_sj_none_bkaunique.result'
--- a/mysql-test/r/subquery_sj_none_bkaunique.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/r/subquery_sj_none_bkaunique.result	revid:kevin.lewis@stripped
@@ -5488,7 +5488,7 @@ EXPLAIN
       "access_type": "ALL",
       "rows": 16,
       "filtered": 100,
-      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`Population` > 5000000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t1`.`Country`)))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t3` where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`)))))",
+      "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,<exists>(select 1 from `test`.`t1` where ((`test`.`t1`.`Population` > 5000000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t1`.`Country`)))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`Code`) in t3 on PRIMARY where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`))))))",
       "attached_subqueries": [
         {
           "dependent": true,

=== modified file 'mysql-test/suite/innodb/r/innodb_stats_rename_table_if_exists.result'
--- a/mysql-test/suite/innodb/r/innodb_stats_rename_table_if_exists.result	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/suite/innodb/r/innodb_stats_rename_table_if_exists.result	revid:kevin.lewis@stripped
@@ -57,40 +57,24 @@ index_name	PRIMARY
 stat_name	size
 stat_value	567
 RENAME TABLE stats_rename1 TO stats_rename2;
-Warnings:
-Level	Warning
-Code	1205
-Message	Unable rename statistics from test.stats_rename1 to test.stats_rename2: Duplicate key. They can be renamed later using UPDATE mysql.innodb_index_stats SET database_name = 'test', table_name = 'stats_rename2' WHERE database_name = 'test' AND table_name = 'stats_rename1'; UPDATE mysql.innodb_table_stats SET database_name = 'test', table_name = 'stats_rename2' WHERE database_name = 'test' AND table_name = 'stats_rename1';
 SELECT table_name, n_rows
 FROM mysql.innodb_table_stats
 WHERE table_name IN ('stats_rename1', 'stats_rename2');
 table_name	stats_rename2
-n_rows	123
+n_rows	0
 SELECT table_name, index_name, stat_name, stat_value
 FROM mysql.innodb_index_stats
 WHERE table_name IN ('stats_rename1', 'stats_rename2');
-table_name	stats_rename1
-index_name	PRIMARY
-stat_name	n_diff_pfx01
-stat_value	0
-table_name	stats_rename1
-index_name	PRIMARY
-stat_name	n_leaf_pages
-stat_value	1
-table_name	stats_rename1
-index_name	PRIMARY
-stat_name	size
-stat_value	1
 table_name	stats_rename2
 index_name	PRIMARY
 stat_name	n_diff_pfx01
-stat_value	567
+stat_value	0
 table_name	stats_rename2
 index_name	PRIMARY
 stat_name	n_leaf_pages
-stat_value	567
+stat_value	1
 table_name	stats_rename2
 index_name	PRIMARY
 stat_name	size
-stat_value	567
+stat_value	1
 DROP TABLE stats_rename2;

=== modified file 'mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test'
--- a/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test	revid:kevin.lewis@stripped
@@ -3,8 +3,7 @@
 # tables for the new table. This cannot happen normally, one have to insert
 # manually like what we do here.
 #
-# The RENAME should succeed, but emit a warning and not overwrite the
-# existing rows.
+# The RENAME should succeed and existent rows should be overwritten.
 #
 
 -- source include/have_innodb.inc

=== modified file 'mysql-test/t/blackhole.test'
--- a/mysql-test/t/blackhole.test	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/t/blackhole.test	revid:kevin.lewis@stripped
@@ -19,3 +19,12 @@ DROP TABLE t1, t2;
 
 --echo End of 5.5 tests 
 
+--echo #
+--echo # Bug#13948247 DIVISION BY 0 IN GET_BEST_DISJUNCT_QUICK WITH FORCE INDEX GROUP BY
+--echo #
+
+CREATE TABLE t1(a INT, b INT, c INT, KEY(c), UNIQUE(a)) ENGINE = BLACKHOLE;
+SELECT 0 FROM t1 FORCE INDEX FOR GROUP BY(a) WHERE a = 0 OR b = 0 AND c = 0;
+DROP TABLE t1;
+
+--echo End of 5.6 tests

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/t/func_time.test	revid:kevin.lewis@stripped
@@ -1115,3 +1115,8 @@ DROP TABLE t1;
 
 DO maketime(~0, 49, 0.123456789);
 
+--echo #
+--echo # Bug#14042545 ASSERTION FAILED: DEC <= 6 IN MY_USECONDS_TO_STR()
+--echo #
+
+DO is_used_lock(ifnull(now(), CASE 1 WHEN 1 THEN NULL END));

=== modified file 'mysql-test/t/information_schema.test'
--- a/mysql-test/t/information_schema.test	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/t/information_schema.test	revid:kevin.lewis@stripped
@@ -1854,6 +1854,12 @@ INSERT INTO t1 VALUES (1);
 SELECT MAX(a) FROM information_schema.engines RIGHT JOIN t1 ON 1;
 DROP TABLE t1;
 
+--echo #
+--echo # BUG#13463397 - 63562: UNKNOWN DATABASE INFORMATION_SCHEMA 
+--echo #
+
+--error ER_DBACCESS_DENIED_ERROR
+CREATE PROCEDURE information_schema.is() BEGIN END;
 
 --echo #
 --echo # End of 5.6 tests

=== modified file 'mysql-test/t/partition_binlog.test'
--- a/mysql-test/t/partition_binlog.test	revid:viswanatham.gudipati@stripped
+++ b/mysql-test/t/partition_binlog.test	revid:kevin.lewis@stripped
@@ -17,6 +17,8 @@ PARTITION BY RANGE (id)
 
 INSERT INTO t1 VALUES (1), (10), (100), (1000);
 
+RESET MASTER;
+
 --let $binlog_file=query_get_value(SHOW MASTER STATUS, File, 1)
 --let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1)
 

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	revid:viswanatham.gudipati@stripped
+++ b/sql/item_cmpfunc.cc	revid:kevin.lewis@stripped
@@ -2750,6 +2750,7 @@ Item_func_ifnull::fix_length_and_dec()
 {
   uint32 char_length;
   agg_result_type(&hybrid_type, args, 2);
+  cached_field_type= agg_field_type(args, 2);
   maybe_null=args[1]->maybe_null;
   decimals= max(args[0]->decimals, args[1]->decimals);
   unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
@@ -2769,7 +2770,7 @@ Item_func_ifnull::fix_length_and_dec()
 
   switch (hybrid_type) {
   case STRING_RESULT:
-    if (agg_arg_charsets_for_comparison(collation, args, arg_count))
+    if (count_string_result_length(cached_field_type, args, arg_count))
       return;
     break;
   case DECIMAL_RESULT:
@@ -2783,7 +2784,6 @@ Item_func_ifnull::fix_length_and_dec()
     DBUG_ASSERT(0);
   }
   fix_char_length(char_length);
-  cached_field_type= agg_field_type(args, 2);
 }
 
 

=== modified file 'sql/opt_explain.cc'
--- a/sql/opt_explain.cc	revid:viswanatham.gudipati@stripped
+++ b/sql/opt_explain.cc	revid:kevin.lewis@stripped
@@ -59,6 +59,20 @@ protected:
   JOIN::ORDER_with_src group_list; //< GROUP BY item tee list
 
 protected:
+  class Lazy_condition: public Lazy
+  {
+    Item *const condition;
+  public:
+    Lazy_condition(Item *condition_arg): condition(condition_arg) {}
+    virtual bool eval(String *ret)
+    {
+      ret->length(0);
+      if (condition)
+        condition->print(ret, QT_ORDINARY);
+      return false;
+    }
+  };
+
   explicit Explain(Explain_context_enum context_type_arg,
                    THD *thd_arg, JOIN *join_arg= NULL)
   : thd(thd_arg),
@@ -945,15 +959,11 @@ bool Explain_table_base::explain_extra_c
       {
         if (fmt->is_hierarchical())
         {
-          StringBuffer<160> buff(cs);
-          if (tab)
-          {
-            if (tab->condition())
-              tab->condition()->print(&buff, QT_ORDINARY);
-          }
-          else
-            select->cond->print(&buff, QT_ORDINARY);
-          fmt->entry()->col_attached_condition.set(buff);
+          Lazy_condition *c= new Lazy_condition(tab ? tab->condition()
+                                                    : select->cond);
+          if (c == NULL)
+            return true;
+          fmt->entry()->col_attached_condition.set(c);
         }
         else if (push_extra(ET_USING_WHERE))
           return true;
@@ -1304,10 +1314,10 @@ bool Explain_join::explain_extra()
     {
       if (fmt->is_hierarchical())
       {
-        StringBuffer<160> buff(cs);
-        if (tab &&  tab->condition())
-          tab->condition()->print(&buff, QT_ORDINARY);
-        fmt->entry()->col_attached_condition.set(buff);
+        Lazy_condition *c= new Lazy_condition(tab->condition());
+        if (c == NULL)
+          return true;
+        fmt->entry()->col_attached_condition.set(c);
       }
       else if (push_extra(ET_USING_WHERE))
         return true;

=== modified file 'sql/opt_explain_format.h'
--- a/sql/opt_explain_format.h	revid:viswanatham.gudipati@stripped
+++ b/sql/opt_explain_format.h	revid:kevin.lewis@stripped
@@ -104,6 +104,25 @@ enum Extra_tag
 
 
 /**
+  Emulate lazy computation
+*/
+class Lazy: public Sql_alloc
+{
+public:
+  virtual ~Lazy() {}
+
+  /**
+    Deferred evaluation of encapsulated expression
+
+    @param [out] ret    Return string value
+
+    @retval false       Success
+    @retval true        Failure (OOM)
+  */
+  virtual bool eval(String *ret)= 0;
+};
+
+/**
   Base class for all EXPLAIN context descriptor classes
 
   In structured EXPLAIN implementation Explain_context is a base class for
@@ -173,20 +192,38 @@ public:
     in the most cases, those input strings must have the same lifetime as
     Item_string objects, i.e. lifetime of MEM_ROOT.
     This class allocates input parameters for Item_string objects in MEM_ROOT.
+
+    @note Call to is_empty() is necessary before the access to "str" and
+          "length" fields, since is_empty() may trigger an evaluation of
+          an associated expression that updates these fields.
   */
   struct mem_root_str
   {
     const char *str;
     size_t length;
+    Lazy *deferred; //< encapsulated expression to evaluate it later (on demand)
     
     mem_root_str() { cleanup(); }
     void cleanup()
     {
       str= NULL;
       length= 0;
+      deferred= NULL;
+    }
+    bool is_empty()
+    {
+      if (deferred)
+      {
+        StringBuffer<128> buff(system_charset_info);
+        if (deferred->eval(&buff) || set(buff))
+        {
+          DBUG_ASSERT(!"OOM!");
+          return true; // ignore OOM
+        }
+        deferred= NULL; // prevent double evaluation, if any
+      }
+      return str == NULL;
     }
-    bool is_empty() const { return str == NULL; }
-
     bool set(const char *str_arg)
     {
       return set(str_arg, strlen(str_arg));
@@ -205,12 +242,24 @@ public:
     */
     bool set(const char *str_arg, size_t length_arg)
     {
+      deferred= NULL;
       if (!(str= strndup_root(current_thd->mem_root, str_arg, length_arg)))
         return true; /* purecov: inspected */
       length= length_arg;
       return false;
     }
     /**
+      Save expression for further evaluation
+
+      @param x  Expression
+    */
+    void set(Lazy *x)
+    {
+      deferred= x;
+      str= NULL;
+      length= 0;
+    }
+    /**
       Make a copy of string constant
 
       Variant of set() usable when the str_arg argument lives longer
@@ -222,6 +271,7 @@ public:
     }
     void set_const(const char *str_arg, size_t length_arg)
     {
+      deferred= NULL;
       str= str_arg;
       length= length_arg;
     }

=== modified file 'sql/opt_explain_traditional.cc'
--- a/sql/opt_explain_traditional.cc	revid:viswanatham.gudipati@stripped
+++ b/sql/opt_explain_traditional.cc	revid:kevin.lewis@stripped
@@ -63,7 +63,7 @@ bool Explain_format_traditional::send_he
           current_thd->send_explain_fields(output));
 }
 
-static bool push(List<Item> *items, const qep_row::mem_root_str &s,
+static bool push(List<Item> *items, qep_row::mem_root_str &s,
                  Item_null *nil)
 {
   if (s.is_empty())

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	revid:viswanatham.gudipati@stripped
+++ b/sql/opt_range.cc	revid:kevin.lewis@stripped
@@ -2817,7 +2817,8 @@ int SQL_SELECT::test_quick_select(THD *t
       {
         // Cannot return rows in descending order.
         if (thd->optimizer_switch_flag(OPTIMIZER_SWITCH_INDEX_MERGE) &&
-            interesting_order != ORDER::ORDER_DESC)
+            interesting_order != ORDER::ORDER_DESC &&
+            param.table->file->stats.records)
         {
           /* Try creating index_merge/ROR-union scan. */
           SEL_IMERGE *imerge;
@@ -4218,6 +4219,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick
   DBUG_ENTER("get_best_disjunct_quick");
   DBUG_PRINT("info", ("Full table scan cost: %g", read_time));
 
+  DBUG_ASSERT(param->table->file->stats.records);
+
   Opt_trace_context * const trace= &param->thd->opt_trace;
   Opt_trace_object trace_best_disjunct(trace);
   if (!(range_scans= (TRP_RANGE**)alloc_root(param->mem_root,

=== modified file 'storage/innobase/btr/btr0cur.cc'
--- a/storage/innobase/btr/btr0cur.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/btr/btr0cur.cc	revid:kevin.lewis@stripped
@@ -713,6 +713,7 @@ retry_page_get:
 			? SYNC_IBUF_TREE_NODE : SYNC_TREE_NODE);
 	}
 
+	ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX);
 	ut_ad(index->id == btr_page_get_index_id(page));
 
 	if (UNIV_UNLIKELY(height == ULINT_UNDEFINED)) {
@@ -911,6 +912,7 @@ btr_cur_open_at_index_side_func(
 					 RW_NO_LATCH, NULL, BUF_GET,
 					 file, line, mtr);
 		page = buf_block_get_frame(block);
+		ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX);
 		ut_ad(index->id == btr_page_get_index_id(page));
 
 		block->check_index_page_at_flush = TRUE;
@@ -1040,6 +1042,7 @@ btr_cur_open_at_rnd_pos_func(
 					 RW_NO_LATCH, NULL, BUF_GET,
 					 file, line, mtr);
 		page = buf_block_get_frame(block);
+		ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX);
 		ut_ad(index->id == btr_page_get_index_id(page));
 
 		if (height == ULINT_UNDEFINED) {
@@ -1915,6 +1918,8 @@ btr_cur_update_in_place(
 	ut_ad(!thr || thr_get_trx(thr)->id == trx_id);
 	ut_ad(thr || flags == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG
 			       | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG));
+	ut_ad(fil_page_get_type(btr_cur_get_page(cursor)) == FIL_PAGE_INDEX);
+	ut_ad(btr_page_get_index_id(btr_cur_get_page(cursor)) == index->id);
 
 	offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
 #ifdef UNIV_DEBUG
@@ -2062,6 +2067,8 @@ btr_cur_optimistic_update(
 	ut_ad(!thr || thr_get_trx(thr)->id == trx_id);
 	ut_ad(thr || flags == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG
 			       | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG));
+	ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX);
+	ut_ad(btr_page_get_index_id(page) == index->id);
 
 	heap = mem_heap_create(1024);
 	offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);

=== modified file 'storage/innobase/dict/dict0crea.cc'
--- a/storage/innobase/dict/dict0crea.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/dict/dict0crea.cc	revid:kevin.lewis@stripped
@@ -262,7 +262,8 @@ dict_build_table_def_step(
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
 	table = node->table;
-	use_tablespace = !!(table->flags2 & DICT_TF2_USE_TABLESPACE);
+	use_tablespace =
+		DICT_TF2_FLAG_IS_SET(table, DICT_TF2_USE_TABLESPACE);
 
 	dict_hdr_get_new_id(&table->id, NULL, NULL);
 

=== modified file 'storage/innobase/dict/dict0load.cc'
--- a/storage/innobase/dict/dict0load.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/dict/dict0load.cc	revid:kevin.lewis@stripped
@@ -783,78 +783,6 @@ dict_sys_tables_get_flags(
 }
 
 /********************************************************************//**
-Look up a tablename in SYS_TABLES and return the space ID.
-@return TRUE if tablename was found and space ID is set, FALSE if not. */
-UNIV_INTERN
-bool
-dict_get_space_from_sys_tables(
-/*===========================*/
-	const char*	name,		/*!< in: table name */
-	ulint*		space)		/*!< out: space ID */
-{
-	bool		found;
-	mem_heap_t*	heap;
-	mtr_t		mtr;
-	dict_table_t*	sys_tables;
-	dict_index_t*	sys_index;
-	dtuple_t*	tuple;
-	dfield_t*	dfield;
-	btr_pcur_t	pcur;
-	const rec_t*	rec;
-	const byte*	field;
-	ulint		len;
-
-	ut_ad(mutex_own(&(dict_sys->mutex)));
-
-	heap = mem_heap_create(1024);
-
-	mtr_start(&mtr);
-
-	ut_ad(mutex_own(&(dict_sys->mutex)));
-
-	mtr_start(&mtr);
-
-	sys_tables = dict_table_get_low("SYS_TABLES");
-	sys_index = UT_LIST_GET_FIRST(sys_tables->indexes);
-
-	ut_ad(!dict_table_is_comp(sys_tables));
-	ut_ad(name_of_col_is(sys_tables, sys_index,
-			     DICT_FLD__SYS_TABLES__TYPE, "TYPE"));
-	ut_ad(name_of_col_is(sys_tables, sys_index,
-			     DICT_FLD__SYS_TABLES__SPACE, "SPACE"));
-
-	tuple = dtuple_create(heap, 1);
-	dfield = dtuple_get_nth_field(tuple, 0);
-
-	dfield_set_data(dfield, name, ut_strlen(name));
-	dict_index_copy_types(tuple, sys_index, 1);
-
-	btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
-				  BTR_SEARCH_LEAF, &pcur, &mtr);
-	rec = btr_pcur_get_rec(&pcur);
-
-	if (!btr_pcur_is_on_user_rec(&pcur)
-	    || rec_get_deleted_flag(rec, 0)) {
-		found = false;
-		goto exit_func;
-	}
-
-	field = rec_get_nth_field_old(
-		rec, DICT_FLD__SYS_TABLES__SPACE, &len);
-	ut_a(len == 4);
-
-	*space = mach_read_from_4(field);
-	found = true;
-
-exit_func:
-	btr_pcur_close(&pcur);
-	mtr_commit(&mtr);
-	mem_heap_free(heap);
-
-	return(found);
-}
-
-/********************************************************************//**
 Gets the filepath for a spaceid from SYS_DATAFILES and checks it against
 the contents of a link file. This function is called when there is no
 fil_node_t entry for this space ID so both durable locations on  disk

=== modified file 'storage/innobase/dict/dict0stats.cc'
--- a/storage/innobase/dict/dict0stats.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/dict/dict0stats.cc	revid:kevin.lewis@stripped
@@ -2788,6 +2788,116 @@ dict_stats_drop_index(
 /* @} */
 
 /*********************************************************************//**
+Executes
+DELETE FROM mysql.innodb_table_stats
+WHERE database_name = '...' AND table_name = '...';
+Creates its own transaction and commits it.
+mysql.innodb_table_stats should be protected from DDL with dict_stats_open().
+dict_stats_delete_from_table_stats() @{
+@return DB_SUCCESS or error code */
+UNIV_INLINE
+dberr_t
+dict_stats_delete_from_table_stats(
+/*===============================*/
+	const char*	database_name,	/*!< in: database name, e.g. 'db' */
+	const char*	table_name)	/*!< in: table name, e.g. 'table' */
+{
+	pars_info_t*	pinfo;
+	trx_t*		trx;
+	dberr_t		ret;
+
+	ut_ad(!mutex_own(&dict_sys->mutex));
+
+	pinfo = pars_info_create();
+
+	pars_info_add_str_literal(pinfo, "database_name", database_name);
+	pars_info_add_str_literal(pinfo, "table_name", table_name);
+
+	trx = trx_allocate_for_background();
+	trx_start_if_not_started(trx);
+
+	ret = que_eval_sql(
+		pinfo,
+		"PROCEDURE DELETE_FROM_TABLE_STATS () IS\n"
+		"BEGIN\n"
+		"DELETE FROM \"" TABLE_STATS_NAME "\" WHERE\n"
+		"database_name = :database_name AND\n"
+		"table_name = :table_name;\n"
+		"END;\n",
+		TRUE, trx);
+	/* pinfo is freed by que_eval_sql() */
+
+	if (ret == DB_SUCCESS) {
+		trx_commit_for_mysql(trx);
+	} else {
+		trx->op_info = "rollback of internal trx on stats tables";
+		trx_rollback_to_savepoint(trx, NULL);
+		trx->op_info = "";
+		ut_a(trx->error_state == DB_SUCCESS);
+	}
+
+	trx_free_for_background(trx);
+
+	return(ret);
+}
+/* @} */
+
+/*********************************************************************//**
+Executes
+DELETE FROM mysql.innodb_index_stats
+WHERE database_name = '...' AND table_name = '...';
+Creates its own transaction and commits it.
+mysql.innodb_index_stats should be protected from DDL with dict_stats_open().
+dict_stats_delete_from_index_stats() @{
+@return DB_SUCCESS or error code */
+UNIV_INLINE
+dberr_t
+dict_stats_delete_from_index_stats(
+/*===============================*/
+	const char*	database_name,	/*!< in: database name, e.g. 'db' */
+	const char*	table_name)	/*!< in: table name, e.g. 'table' */
+{
+	pars_info_t*	pinfo;
+	trx_t*		trx;
+	dberr_t		ret;
+
+	ut_ad(!mutex_own(&dict_sys->mutex));
+
+	pinfo = pars_info_create();
+
+	pars_info_add_str_literal(pinfo, "database_name", database_name);
+	pars_info_add_str_literal(pinfo, "table_name", table_name);
+
+	trx = trx_allocate_for_background();
+	trx_start_if_not_started(trx);
+
+	ret = que_eval_sql(
+		pinfo,
+		"PROCEDURE DELETE_FROM_INDEX_STATS () IS\n"
+		"BEGIN\n"
+		"DELETE FROM \"" INDEX_STATS_NAME "\" WHERE\n"
+		"database_name = :database_name AND\n"
+		"table_name = :table_name;\n"
+		"END;\n",
+		TRUE, trx);
+	/* pinfo is freed by que_eval_sql() */
+
+	if (ret == DB_SUCCESS) {
+		trx_commit_for_mysql(trx);
+	} else {
+		trx->op_info = "rollback of internal trx on stats tables";
+		trx_rollback_to_savepoint(trx, NULL);
+		trx->op_info = "";
+		ut_a(trx->error_state == DB_SUCCESS);
+	}
+
+	trx_free_for_background(trx);
+
+	return(ret);
+}
+/* @} */
+
+/*********************************************************************//**
 Removes the statistics for a table and all of its indexes from the
 persistent statistics storage if it exists and if there is data stored for
 the table. This function creates its own transaction and commits it.
@@ -2804,9 +2914,7 @@ dict_stats_drop_table(
 {
 	char		database_name[MAX_DATABASE_NAME_LEN + 1];
 	const char*	table_name_strip; /* without leading db name */
-	trx_t*		trx;
-	pars_info_t*	pinfo;
-	dberr_t		ret = DB_ERROR;
+	dberr_t		ret;
 	dict_stats_t*	dict_stats;
 
 	ut_ad(!mutex_own(&dict_sys->mutex));
@@ -2840,44 +2948,12 @@ dict_stats_drop_table(
 
 	table_name_strip = dict_remove_db_name(table_name);
 
-	pinfo = pars_info_create();
-	pars_info_add_str_literal(pinfo, "database_name", database_name);
-	pars_info_add_str_literal(pinfo, "table_name", table_name_strip);
-
-	trx = trx_allocate_for_background();
-	trx_start_if_not_started(trx);
-	ret = que_eval_sql(
-		pinfo,
-		"PROCEDURE DROP_TABLE_STATS_TABLE () IS\n"
-		"BEGIN\n"
-		"DELETE FROM \"" TABLE_STATS_NAME "\" WHERE\n"
-		"database_name = :database_name AND\n"
-		"table_name = :table_name;\n"
-		"END;\n",
-		TRUE, trx);
-	/* pinfo is freed by que_eval_sql() */
-	trx_commit_for_mysql(trx);
-	trx_free_for_background(trx);
+	ret = dict_stats_delete_from_table_stats(database_name,
+						 table_name_strip);
 
 	if (ret == DB_SUCCESS) {
-		pinfo = pars_info_create();
-		pars_info_add_str_literal(pinfo, "database_name", database_name);
-		pars_info_add_str_literal(pinfo, "table_name", table_name_strip);
-
-		trx = trx_allocate_for_background();
-		trx_start_if_not_started(trx);
-		ret = que_eval_sql(
-			pinfo,
-			"PROCEDURE DROP_TABLE_STATS_INDEX () IS\n"
-			"BEGIN\n"
-			"DELETE FROM \"" INDEX_STATS_NAME "\" WHERE\n"
-			"database_name = :database_name AND\n"
-			"table_name = :table_name;\n"
-			"END;\n",
-			TRUE, trx);
-		/* pinfo is freed by que_eval_sql() */
-		trx_commit_for_mysql(trx);
-		trx_free_for_background(trx);
+		ret = dict_stats_delete_from_index_stats(database_name,
+							 table_name_strip);
 	}
 
 	if (ret != DB_SUCCESS) {
@@ -2911,6 +2987,132 @@ dict_stats_drop_table(
 /* @} */
 
 /*********************************************************************//**
+Executes
+UPDATE mysql.innodb_table_stats SET
+database_name = '...', table_name = '...'
+WHERE database_name = '...' AND table_name = '...';
+Creates its own transaction and commits it.
+mysql.innodb_table_stats should be protected from DDL with dict_stats_open().
+dict_stats_rename_in_table_stats() @{
+@return DB_SUCCESS or error code */
+UNIV_INLINE
+dberr_t
+dict_stats_rename_in_table_stats(
+/*=============================*/
+	const char*	old_database_name,/*!< in: database name, e.g. 'olddb' */
+	const char*	old_table_name,	/*!< in: table name, e.g. 'oldtable' */
+	const char*	new_database_name,/*!< in: database name, e.g. 'newdb' */
+	const char*	new_table_name)	/*!< in: table name, e.g. 'newtable' */
+{
+	pars_info_t*	pinfo;
+	trx_t*		trx;
+	dberr_t		ret;
+
+	ut_ad(!mutex_own(&dict_sys->mutex));
+
+	pinfo = pars_info_create();
+
+	pars_info_add_str_literal(pinfo, "old_database_name", old_database_name);
+	pars_info_add_str_literal(pinfo, "old_table_name", old_table_name);
+	pars_info_add_str_literal(pinfo, "new_database_name", new_database_name);
+	pars_info_add_str_literal(pinfo, "new_table_name", new_table_name);
+
+	trx = trx_allocate_for_background();
+	trx_start_if_not_started(trx);
+
+	ret = que_eval_sql(
+		pinfo,
+		"PROCEDURE RENAME_IN_TABLE_STATS () IS\n"
+		"BEGIN\n"
+		"UPDATE \"" TABLE_STATS_NAME "\" SET\n"
+		"database_name = :new_database_name,\n"
+		"table_name = :new_table_name\n"
+		"WHERE\n"
+		"database_name = :old_database_name AND\n"
+		"table_name = :old_table_name;\n"
+		"END;\n",
+		TRUE, trx);
+	/* pinfo is freed by que_eval_sql() */
+
+	if (ret == DB_SUCCESS) {
+		trx_commit_for_mysql(trx);
+	} else {
+		trx->op_info = "rollback of internal trx on stats tables";
+		trx_rollback_to_savepoint(trx, NULL);
+		trx->op_info = "";
+		ut_a(trx->error_state == DB_SUCCESS);
+	}
+
+	trx_free_for_background(trx);
+
+	return(ret);
+}
+/* @} */
+
+/*********************************************************************//**
+Executes
+UPDATE mysql.innodb_index_stats SET
+database_name = '...', table_name = '...'
+WHERE database_name = '...' AND table_name = '...';
+Creates its own transaction and commits it.
+mysql.innodb_index_stats should be protected from DDL with dict_stats_open().
+dict_stats_rename_in_index_stats() @{
+@return DB_SUCCESS or error code */
+UNIV_INLINE
+dberr_t
+dict_stats_rename_in_index_stats(
+/*=============================*/
+	const char*	old_database_name,/*!< in: database name, e.g. 'olddb' */
+	const char*	old_table_name,	/*!< in: table name, e.g. 'oldtable' */
+	const char*	new_database_name,/*!< in: database name, e.g. 'newdb' */
+	const char*	new_table_name)	/*!< in: table name, e.g. 'newtable' */
+{
+	pars_info_t*	pinfo;
+	trx_t*		trx;
+	dberr_t		ret;
+
+	ut_ad(!mutex_own(&dict_sys->mutex));
+
+	pinfo = pars_info_create();
+
+	pars_info_add_str_literal(pinfo, "old_database_name", old_database_name);
+	pars_info_add_str_literal(pinfo, "old_table_name", old_table_name);
+	pars_info_add_str_literal(pinfo, "new_database_name", new_database_name);
+	pars_info_add_str_literal(pinfo, "new_table_name", new_table_name);
+
+	trx = trx_allocate_for_background();
+	trx_start_if_not_started(trx);
+
+	ret = que_eval_sql(
+		pinfo,
+		"PROCEDURE RENAME_IN_INDEX_STATS () IS\n"
+		"BEGIN\n"
+		"UPDATE \"" INDEX_STATS_NAME "\" SET\n"
+		"database_name = :new_database_name,\n"
+		"table_name = :new_table_name\n"
+		"WHERE\n"
+		"database_name = :old_database_name AND\n"
+		"table_name = :old_table_name;\n"
+		"END;\n",
+		TRUE, trx);
+	/* pinfo is freed by que_eval_sql() */
+
+	if (ret == DB_SUCCESS) {
+		trx_commit_for_mysql(trx);
+	} else {
+		trx->op_info = "rollback of internal trx on stats tables";
+		trx_rollback_to_savepoint(trx, NULL);
+		trx->op_info = "";
+		ut_a(trx->error_state == DB_SUCCESS);
+	}
+
+	trx_free_for_background(trx);
+
+	return(ret);
+}
+/* @} */
+
+/*********************************************************************//**
 Renames a table in InnoDB persistent stats storage.
 This function creates its own transaction and commits it.
 dict_stats_rename_table() @{
@@ -2931,9 +3133,7 @@ dict_stats_rename_table(
 	char		new_database_name[MAX_DATABASE_NAME_LEN + 1];
 	const char*	old_table_name; /* without leading db name */
 	const char*	new_table_name; /* without leading db name */
-	trx_t*		trx;
-	pars_info_t*	pinfo;
-	dberr_t		ret = DB_ERROR;
+	dberr_t		ret;
 	dict_stats_t*	dict_stats;
 
 	/* skip innodb_table_stats and innodb_index_stats themselves */
@@ -2964,69 +3164,29 @@ dict_stats_rename_table(
 
 	new_table_name = dict_remove_db_name(new_name);
 
-	pinfo = pars_info_create();
-	pars_info_add_str_literal(
-		pinfo, "old_database_name", old_database_name);
-	pars_info_add_str_literal(
-		pinfo, "old_table_name", old_table_name);
-	pars_info_add_str_literal(
-		pinfo, "new_database_name", new_database_name);
-	pars_info_add_str_literal(
-		pinfo, "new_table_name", new_table_name);
-
-	trx = trx_allocate_for_background();
-	trx_start_if_not_started(trx);
-	ret = que_eval_sql(
-		pinfo,
-		"PROCEDURE RENAME_TABLE_STATS_TABLE () IS\n"
-		"BEGIN\n"
-		"UPDATE \"" TABLE_STATS_NAME "\" SET\n"
-		"database_name = :new_database_name,\n"
-		"table_name = :new_table_name\n"
-		"WHERE\n"
-		"database_name = :old_database_name AND\n"
-		"table_name = :old_table_name;\n"
-		"END;\n",
-		TRUE, trx);
-	/* pinfo is freed by que_eval_sql() */
-	trx_commit_for_mysql(trx);
-	trx_free_for_background(trx);
-
-	if (ret == DB_SUCCESS) {
-		pinfo = pars_info_create();
-		pars_info_add_str_literal(
-			pinfo, "old_database_name", old_database_name);
-		pars_info_add_str_literal(
-			pinfo, "old_table_name", old_table_name);
-		pars_info_add_str_literal(
-			pinfo, "new_database_name", new_database_name);
-		pars_info_add_str_literal(
-			pinfo, "new_table_name", new_table_name);
-
-		trx = trx_allocate_for_background();
-		trx_start_if_not_started(trx);
-		ret = que_eval_sql(
-			pinfo,
-			"PROCEDURE RENAME_TABLE_STATS_INDEX () IS\n"
-			"BEGIN\n"
-			"UPDATE \"" INDEX_STATS_NAME "\" SET\n"
-			"database_name = :new_database_name,\n"
-			"table_name = :new_table_name\n"
-			"WHERE\n"
-			"database_name = :old_database_name AND\n"
-			"table_name = :old_table_name;\n"
-			"END;\n",
-			TRUE, trx);
-		/* pinfo is freed by que_eval_sql() */
-		trx_commit_for_mysql(trx);
-		trx_free_for_background(trx);
-	}
+	ulint	n_attempts = 0;
+	do {
+		n_attempts++;
+
+		ret = dict_stats_rename_in_table_stats(
+			old_database_name, old_table_name,
+			new_database_name, new_table_name);
+
+		if (ret == DB_DUPLICATE_KEY) {
+			dict_stats_delete_from_table_stats(
+				new_database_name, new_table_name);
+		}
+
+		if (ret != DB_SUCCESS) {
+			os_thread_sleep(200000 /* 0.2 sec */);
+		}
+	} while ((ret == DB_DUPLICATE_KEY || ret == DB_LOCK_WAIT_TIMEOUT)
+		 && n_attempts < 5);
 
 	if (ret != DB_SUCCESS) {
-
 		ut_snprintf(errstr, errstr_sz,
 			    "Unable rename statistics from "
-			    "%s.%s to %s.%s: %s. "
+			    "%s.%s to %s.%s in %s: %s. "
 			    "They can be renamed later using "
 
 			    "UPDATE %s SET "
@@ -3034,7 +3194,45 @@ dict_stats_rename_table(
 			    "table_name = '%s' "
 			    "WHERE "
 			    "database_name = '%s' AND "
-			    "table_name = '%s'; "
+			    "table_name = '%s';",
+
+			    old_database_name, old_table_name,
+			    new_database_name, new_table_name,
+			    TABLE_STATS_NAME_PRINT,
+			    ut_strerr(ret),
+
+			    TABLE_STATS_NAME_PRINT,
+			    new_database_name, new_table_name,
+			    old_database_name, old_table_name);
+		dict_stats_close(dict_stats);
+		return(ret);
+	}
+	/* else */
+
+	n_attempts = 0;
+	do {
+		n_attempts++;
+
+		ret = dict_stats_rename_in_index_stats(
+			old_database_name, old_table_name,
+			new_database_name, new_table_name);
+
+		if (ret == DB_DUPLICATE_KEY) {
+			dict_stats_delete_from_index_stats(
+				new_database_name, new_table_name);
+		}
+
+		if (ret != DB_SUCCESS) {
+			os_thread_sleep(200000 /* 0.2 sec */);
+		}
+	} while ((ret == DB_DUPLICATE_KEY || ret == DB_LOCK_WAIT_TIMEOUT)
+		 && n_attempts < 5);
+
+	if (ret != DB_SUCCESS) {
+		ut_snprintf(errstr, errstr_sz,
+			    "Unable rename statistics from "
+			    "%s.%s to %s.%s in %s: %s. "
+			    "They can be renamed later using "
 
 			    "UPDATE %s SET "
 			    "database_name = '%s', "
@@ -3045,18 +3243,12 @@ dict_stats_rename_table(
 
 			    old_database_name, old_table_name,
 			    new_database_name, new_table_name,
+			    INDEX_STATS_NAME_PRINT,
 			    ut_strerr(ret),
 
 			    INDEX_STATS_NAME_PRINT,
 			    new_database_name, new_table_name,
-			    old_database_name, old_table_name,
-
-			    TABLE_STATS_NAME_PRINT,
-			    new_database_name, new_table_name,
 			    old_database_name, old_table_name);
-
-		ut_print_timestamp(stderr);
-		fprintf(stderr, " InnoDB: %s\n", errstr);
 	}
 
 	dict_stats_close(dict_stats);

=== modified file 'storage/innobase/fil/fil0fil.cc'
--- a/storage/innobase/fil/fil0fil.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/fil/fil0fil.cc	revid:kevin.lewis@stripped
@@ -381,16 +381,6 @@ fil_node_complete_io(
 				the node as modified if
 				type == OS_FILE_WRITE */
 /*******************************************************************//**
-Checks if a single-table tablespace for a given table name exists in the
-tablespace memory cache.
-@return	space id, ULINT_UNDEFINED if not found */
-static
-ulint
-fil_get_space_id_for_table(
-/*=======================*/
-	const char*	name);	/*!< in: table name in the standard
-				'databasename/tablename' format */
-/*******************************************************************//**
 Frees a space object from the tablespace memory cache. Closes the files in
 the chain but does not delete them. There must not be any pending i/o's or
 flushes on the files.
@@ -3043,29 +3033,28 @@ fil_create_new_single_table_tablespace(
 	ibool		success;
 	/* TRUE if a table is created with CREATE TEMPORARY TABLE */
 	bool		is_temp = !!(flags2 & DICT_TF2_TEMPORARY);
-	bool		has_data_dir = (dir_path && !is_temp);
+	bool		has_data_dir = FSP_FLAGS_HAS_DATA_DIR(flags);
 
 	ut_a(space_id > 0);
 	ut_a(space_id < SRV_LOG_SPACE_FIRST_ID);
 	ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
 	fsp_flags_validate(flags);
 
-	if (dir_path) {
-		/* Create a link file if needed. */
-		if (has_data_dir) {
-			path = os_file_make_remote_pathname(dir_path, tablename);
-
-			/* Since this tablespace file will be created in a
-			remote directory, let's create the subdirectories
-			in the path, if they are not there already. */
-			success = os_file_create_subdirs_if_needed(path);
-			if (!success) {
-				err = DB_ERROR;
-				goto error_exit_3;
-			}
-		} else {
-			/* Temporary table filepath */
-			path = fil_make_ibd_name(dir_path, TRUE);
+	if (is_temp) {
+		/* Temporary table filepath */
+		ut_a(dir_path);
+		path = fil_make_ibd_name(dir_path, TRUE);
+	} else if (has_data_dir) {
+		ut_a(dir_path);
+		path = os_file_make_remote_pathname(dir_path, tablename);
+
+		/* Since this tablespace file will be created in a
+		remote directory, let's create the subdirectories
+		in the path, if they are not there already. */
+		success = os_file_create_subdirs_if_needed(path);
+		if (!success) {
+			err = DB_ERROR;
+			goto error_exit_3;
 		}
 	} else {
 		path = fil_make_ibd_name(tablename, FALSE);
@@ -3479,19 +3468,19 @@ fil_open_single_table_tablespace(
 	bool		dict_filepath_same_as_default = false;
 	bool		link_file_found = false;
 	bool		link_file_is_bad = false;
-	os_file_t	def_file;
+	os_file_t	def_file = 0;
 	char*		def_filepath;
 	ibool		def_success = FALSE;
 	lsn_t		def_lsn;
 	ulint		def_id;
 	ulint		def_flags;
-	os_file_t	dict_file;
+	os_file_t	dict_file = 0;
 	char*		dict_filepath = NULL;
 	ibool		dict_success = FALSE;
 	lsn_t		dict_lsn;
 	ulint		dict_id;
 	ulint		dict_flags;
-	os_file_t	remote_file;
+	os_file_t	remote_file = 0;
 	char*		remote_filepath = NULL;
 	ibool		remote_success = FALSE;
 	lsn_t		remote_lsn;
@@ -4550,7 +4539,7 @@ error_exit:
 Checks if a single-table tablespace for a given table name exists in the
 tablespace memory cache.
 @return	space id, ULINT_UNDEFINED if not found */
-static
+UNIV_INTERN
 ulint
 fil_get_space_id_for_table(
 /*=======================*/

=== modified file 'storage/innobase/fts/fts0que.cc'
--- a/storage/innobase/fts/fts0que.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/fts/fts0que.cc	revid:kevin.lewis@stripped
@@ -2874,7 +2874,7 @@ fts_query_calculate_idf(
 	fts_query_t*	query)	/*!< in: Query state */
 {
 	const ib_rbt_node_t* node;
-	double		total_docs = query->total_docs;
+	double		total_docs = (double) query->total_docs;
 
 	/* We need to free any instances of fts_doc_freq_t that we
 	may have allocated. */

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/handler/ha_innodb.cc	revid:kevin.lewis@stripped
@@ -8126,7 +8126,7 @@ create_table_def(
 					an .ibd file for it (no .ibd extension
 					in the path, though). Otherwise this
 					is a zero length-string */
-	const char*	remote_path,	/*!< in: Remote path or zero length-string */
+	const char*	remote_path,	/*!< in: Remote path or NULL */
 	ulint		flags,		/*!< in: table flags */
 	ulint		flags2)		/*!< in: table flags2 */
 {
@@ -8215,10 +8215,12 @@ create_table_def(
 			mem_heap_strdup(table->heap, temp_path);
 	}
 
-	table->data_dir_path =
-		strlen(remote_path) == 0 ? NULL
-		: mem_heap_strdup(table->heap, remote_path);
-
+	if (DICT_TF_HAS_DATA_DIR(flags)) {
+		ut_a(strlen(remote_path));
+		table->data_dir_path = mem_heap_strdup(table->heap, remote_path);
+	} else {
+		table->data_dir_path = NULL;
+	}
 	heap = mem_heap_create(1000);
 
 	for (i = 0; i < n_cols; i++) {
@@ -8330,8 +8332,6 @@ err_col:
 		my_error(err == DB_DUPLICATE_KEY
 			 ? ER_TABLE_EXISTS_ERROR
 			 : ER_TABLESPACE_EXISTS, MYF(0), display_name);
-
-		mem_free(display_name);
 	}
 
 	if (flags2 & DICT_TF2_FTS) {
@@ -8794,12 +8794,14 @@ ha_innobase::parse_table_name(
 	HA_CREATE_INFO*	create_info,	/*!< in: more information of the
 					created table, contains also the
 					create statement string */
-	bool		use_tablespace,	/*!< in: srv_file_per_table */
+	ulint		flags,		/*!< in: flags*/
+	ulint		flags2,		/*!< in: flags2*/
 	char*		norm_name,	/*!< out: normalized table name */
 	char*		temp_path,	/*!< out: absolute path of table */
 	char*		remote_path)	/*!< out: remote path of table */
 {
 	THD*		thd = ha_thd();
+	bool		use_tablespace = flags2 & DICT_TF2_USE_TABLESPACE;
 	DBUG_ENTER("ha_innobase::parse_table_name");
 
 #ifdef __WIN__
@@ -8868,7 +8870,7 @@ ha_innobase::parse_table_name(
 				ER_DEFAULT(WARN_OPTION_IGNORED),
 				"DATA DIRECTORY");
 		} else {
-			strncpy(remote_path, create_info->data_file_name,
+			strncpy(remote_path , create_info->data_file_name,
 				FN_REFLEN - 1);
 		}
 	}
@@ -9089,9 +9091,9 @@ innobase_table_flags(
 		zip_ssize = 0;
 	}
 
-	use_data_dir =
-		((create_info->data_file_name != NULL)
-		&& !(create_info->options & HA_LEX_CREATE_TMP_TABLE));
+	use_data_dir = use_tablespace
+		       && ((create_info->data_file_name != NULL)
+		       && !(create_info->options & HA_LEX_CREATE_TMP_TABLE));
 
 	dict_tf_set(flags, innodb_row_format, zip_ssize, use_data_dir);
 
@@ -9127,7 +9129,7 @@ ha_innobase::create(
 	uint		i;
 	char		norm_name[FN_REFLEN];	/* {database}/{tablename} */
 	char		temp_path[FN_REFLEN];	/* absolute path of temp frm */
-	char		remote_path[FN_REFLEN];	/* absolute path of table */
+	char		remote_path[FN_REFLEN];		/* absolute path of table */
 	THD*		thd = ha_thd();
 	ib_int64_t	auto_inc_value;
 
@@ -9173,7 +9175,7 @@ ha_innobase::create(
 		DBUG_RETURN(-1);
 	}
 
-	error = parse_table_name(name, create_info, use_tablespace,
+	error = parse_table_name(name, create_info, flags, flags2,
 				 norm_name, temp_path, remote_path);
 	if (error) {
 		DBUG_RETURN(error);
@@ -9219,7 +9221,6 @@ ha_innobase::create(
 
 	error = create_table_def(trx, form, norm_name, temp_path,
 				 remote_path, flags, flags2);
-
 	if (error) {
 		goto cleanup;
 	}
@@ -9888,6 +9889,9 @@ ha_innobase::rename_table(
 					      errstr, sizeof(errstr));
 
 		if (ret != DB_SUCCESS) {
+			ut_print_timestamp(stderr);
+			fprintf(stderr, " InnoDB: %s\n", errstr);
+
 			push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
 				     ER_LOCK_WAIT_TIMEOUT, errstr);
 		}

=== modified file 'storage/innobase/handler/ha_innodb.h'
--- a/storage/innobase/handler/ha_innodb.h	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/handler/ha_innodb.h	revid:kevin.lewis@stripped
@@ -191,8 +191,9 @@ class ha_innobase: public handler
 
 	void update_create_info(HA_CREATE_INFO* create_info);
 	int parse_table_name(const char*name,
-			     HA_CREATE_INFO*create_info,
-			     bool use_tablespace,
+			     HA_CREATE_INFO* create_info,
+			     ulint flags,
+			     ulint flags2,
 			     char* norm_name,
 			     char* temp_path,
 			     char* remote_path);

=== modified file 'storage/innobase/handler/i_s.cc'
--- a/storage/innobase/handler/i_s.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/handler/i_s.cc	revid:kevin.lewis@stripped
@@ -5918,7 +5918,7 @@ i_s_dict_fill_sys_tablestats(
 				table->stat_sum_of_other_index_sizes));
 
 		OK(fields[SYS_TABLESTATS_MODIFIED]->store(
-				table->stat_modified_counter));
+				(double) table->stat_modified_counter));
 	} else {
 		OK(field_store_string(fields[SYS_TABLESTATS_INIT],
 				      "Uninitialized"));

=== modified file 'storage/innobase/include/dict0dict.ic'
--- a/storage/innobase/include/dict0dict.ic	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/include/dict0dict.ic	revid:kevin.lewis@stripped
@@ -745,14 +745,16 @@ dict_tf_to_fsp_flags(
 	/* Adjust bit zero. */
 	fsp_flags = DICT_TF_HAS_ATOMIC_BLOBS(table_flags) ? 1 : 0;
 
-	/* ZIP_SSIZE and ATOMIC_BLOBS are the same. */
+	/* ZIP_SSIZE and ATOMIC_BLOBS are at the same position. */
 	fsp_flags |= table_flags & DICT_TF_MASK_ZIP_SSIZE;
 	fsp_flags |= table_flags & DICT_TF_MASK_ATOMIC_BLOBS;
 
 	/* In addition, tablespace flags also contain the page size. */
 	fsp_flags |= fsp_flags_set_page_size(fsp_flags, UNIV_PAGE_SIZE);
 
-	/* Table flags contain the DATA_DIR flag but fsp_flags do not */
+	/* The DATA_DIR flag is in a different position in fsp_flag */
+	fsp_flags |= DICT_TF_HAS_DATA_DIR(table_flags)
+		     ? FSP_FLAGS_MASK_DATA_DIR : 0;
 
 	return(fsp_flags_validate(fsp_flags));
 }

=== modified file 'storage/innobase/include/dict0load.h'
--- a/storage/innobase/include/dict0load.h	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/include/dict0load.h	revid:kevin.lewis@stripped
@@ -365,15 +365,6 @@ dict_process_sys_datafiles(
 	ulint*		space,		/*!< out: pace id */
 	const char**	path);		/*!< out: datafile path */
 /********************************************************************//**
-Look up a tablename in SYS_TABLES and return the space ID.
-@return TRUE if tablename was found and space is set, FALSE if not */
-UNIV_INTERN
-bool
-dict_get_space_from_sys_tables(
-/*===========================*/
-	const char*	name,		/*!< in: table name */
-	ulint*		space);		/*!< out: space ID */
-/********************************************************************//**
 Get the filepath for a spaceid from SYS_DATAFILES. This function provides
 a temporary heap which is used for the table lookup, but not for the path.
 The caller must free the memory for the path returned. This function can

=== modified file 'storage/innobase/include/fil0fil.h'
--- a/storage/innobase/include/fil0fil.h	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/include/fil0fil.h	revid:kevin.lewis@stripped
@@ -811,6 +811,17 @@ fil_tablespace_is_being_deleted(
 /*============================*/
 	ulint		id);	/*!< in: space id */
 
+/*******************************************************************//**
+Checks if a single-table tablespace for a given table name exists in the
+tablespace memory cache.
+@return	space id, ULINT_UNDEFINED if not found */
+UNIV_INTERN
+ulint
+fil_get_space_id_for_table(
+/*=======================*/
+	const char*	name);	/*!< in: table name in the standard
+				'databasename/tablename' format */
+
 typedef	struct fil_space_struct	fil_space_t;
 
 #endif /* !UNIV_INNOCHECKSUM */

=== modified file 'storage/innobase/include/fsp0fsp.h'
--- a/storage/innobase/include/fsp0fsp.h	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/include/fsp0fsp.h	revid:kevin.lewis@stripped
@@ -50,11 +50,15 @@ to the two Barracuda row formats COMPRES
 #define FSP_FLAGS_WIDTH_ATOMIC_BLOBS	1
 /** Number of flag bits used to indicate the tablespace page size */
 #define FSP_FLAGS_WIDTH_PAGE_SSIZE	4
+/** Width of the DATA_DIR flag.  This flag indicates that the tablespace
+is found in a remote location, not the default data directory. */
+#define FSP_FLAGS_WIDTH_DATA_DIR	1
 /** Width of all the currently known tablespace flags */
 #define FSP_FLAGS_WIDTH		(FSP_FLAGS_WIDTH_POST_ANTELOPE	\
 				+ FSP_FLAGS_WIDTH_ZIP_SSIZE	\
 				+ FSP_FLAGS_WIDTH_ATOMIC_BLOBS	\
-				+ FSP_FLAGS_WIDTH_PAGE_SSIZE)
+				+ FSP_FLAGS_WIDTH_PAGE_SSIZE	\
+				+ FSP_FLAGS_WIDTH_DATA_DIR)
 
 /** A mask of all the known/used bits in tablespace flags */
 #define FSP_FLAGS_MASK		(~(~0 << FSP_FLAGS_WIDTH))
@@ -71,8 +75,11 @@ to the two Barracuda row formats COMPRES
 #define FSP_FLAGS_POS_PAGE_SSIZE	(FSP_FLAGS_POS_ATOMIC_BLOBS	\
 					+ FSP_FLAGS_WIDTH_ATOMIC_BLOBS)
 /** Zero relative shift position of the start of the UNUSED bits */
-#define FSP_FLAGS_POS_UNUSED		(FSP_FLAGS_POS_PAGE_SSIZE	\
+#define FSP_FLAGS_POS_DATA_DIR		(FSP_FLAGS_POS_PAGE_SSIZE	\
 					+ FSP_FLAGS_WIDTH_PAGE_SSIZE)
+/** Zero relative shift position of the start of the UNUSED bits */
+#define FSP_FLAGS_POS_UNUSED		(FSP_FLAGS_POS_DATA_DIR	\
+					+ FSP_FLAGS_WIDTH_DATA_DIR)
 
 /** Bit mask of the POST_ANTELOPE field */
 #define FSP_FLAGS_MASK_POST_ANTELOPE				\
@@ -90,6 +97,10 @@ to the two Barracuda row formats COMPRES
 #define FSP_FLAGS_MASK_PAGE_SSIZE				\
 		((~(~0 << FSP_FLAGS_WIDTH_PAGE_SSIZE))		\
 		<< FSP_FLAGS_POS_PAGE_SSIZE)
+/** Bit mask of the DATA_DIR field */
+#define FSP_FLAGS_MASK_DATA_DIR					\
+		((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR))		\
+		<< FSP_FLAGS_POS_DATA_DIR)
 
 /** Return the value of the POST_ANTELOPE field */
 #define FSP_FLAGS_GET_POST_ANTELOPE(flags)			\
@@ -107,6 +118,9 @@ to the two Barracuda row formats COMPRES
 #define FSP_FLAGS_GET_PAGE_SSIZE(flags)				\
 		((flags & FSP_FLAGS_MASK_PAGE_SSIZE)		\
 		>> FSP_FLAGS_POS_PAGE_SSIZE)
+/** Return the value of the DATA_DIR field */
+#define FSP_FLAGS_HAS_DATA_DIR(flags)				\
+		(flags >> FSP_FLAGS_POS_DATA_DIR)
 /** Return the contents of the UNUSED bits */
 #define FSP_FLAGS_GET_UNUSED(flags)				\
 		(flags >> FSP_FLAGS_POS_UNUSED)

=== modified file 'storage/innobase/include/fsp0fsp.ic'
--- a/storage/innobase/include/fsp0fsp.ic	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/include/fsp0fsp.ic	revid:kevin.lewis@stripped
@@ -101,6 +101,9 @@ fsp_flags_validate(
 # error "UNIV_FORMAT_MAX != UNIV_FORMAT_B, Add more validations."
 #endif
 
+	/* The DATA_DIR field can be used for any row type so there is
+	nothing here to validate. */
+
 	/* Return the flags sent in if we did not fail an assert. */
 	return(flags);
 }

=== modified file 'storage/innobase/page/page0cur.cc'
--- a/storage/innobase/page/page0cur.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/page/page0cur.cc	revid:kevin.lewis@stripped
@@ -973,6 +973,9 @@ page_cur_insert_rec_low(
 	page = page_align(current_rec);
 	ut_ad(dict_table_is_comp(index->table)
 	      == (ibool) !!page_is_comp(page));
+	ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX);
+	ut_ad(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID)
+	      == index->id || mtr->inside_ibuf || recv_recovery_is_on());
 
 	ut_ad(!page_rec_is_supremum(current_rec));
 
@@ -1246,6 +1249,9 @@ page_cur_insert_rec_zip(
 	page = page_align(*current_rec);
 	ut_ad(dict_table_is_comp(index->table));
 	ut_ad(page_is_comp(page));
+	ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX);
+	ut_ad(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID)
+	      == index->id || mtr->inside_ibuf || recv_recovery_is_on());
 
 	ut_ad(!page_rec_is_supremum(*current_rec));
 #ifdef UNIV_ZIP_DEBUG
@@ -1897,6 +1903,9 @@ page_cur_delete_rec(
 	current_rec = cursor->rec;
 	ut_ad(rec_offs_validate(current_rec, index, offsets));
 	ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
+	ut_ad(fil_page_get_type(page) == FIL_PAGE_INDEX);
+	ut_ad(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID)
+	      == index->id || mtr->inside_ibuf || recv_recovery_is_on());
 
 	/* The record must not be the supremum or infimum record. */
 	ut_ad(page_rec_is_user_rec(current_rec));

=== modified file 'storage/innobase/row/row0mysql.cc'
--- a/storage/innobase/row/row0mysql.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/row/row0mysql.cc	revid:kevin.lewis@stripped
@@ -1371,7 +1371,7 @@ error_exit:
 
 	que_thr_stop_for_mysql_no_error(thr, trx);
 
-	srv_stats.n_rows_inserted.add(trx->id, 1);
+	srv_stats.n_rows_inserted.add((size_t)trx->id, 1);
 
 	/* Not protected by dict_table_stats_lock() for performance
 	reasons, we would rather get garbage in stat_n_rows (which is
@@ -1743,9 +1743,9 @@ run_again:
 		with a latch. */
 		dict_table_n_rows_dec(prebuilt->table);
 
-		srv_stats.n_rows_deleted.add(trx->id, 1);
+		srv_stats.n_rows_deleted.add((size_t)trx->id, 1);
 	} else {
-		srv_stats.n_rows_updated.add(trx->id, 1);
+		srv_stats.n_rows_updated.add((size_t)trx->id, 1);
 	}
 
 	/* We update table statistics only if it is a DELETE or UPDATE
@@ -1967,9 +1967,9 @@ run_again:
 		with a latch. */
 		dict_table_n_rows_dec(table);
 
-		srv_stats.n_rows_deleted.add(trx->id, 1);
+		srv_stats.n_rows_deleted.add((size_t)trx->id, 1);
 	} else {
-		srv_stats.n_rows_updated.add(trx->id, 1);
+		srv_stats.n_rows_updated.add((size_t)trx->id, 1);
 	}
 
 	row_update_statistics_if_needed(table);
@@ -2205,7 +2205,7 @@ err_exit:
 	err = trx->error_state;
 
 	if (table->space) {
-		ut_a(table->flags2 & DICT_TF2_USE_TABLESPACE);
+		ut_a(DICT_TF2_FLAG_IS_SET(table, DICT_TF2_USE_TABLESPACE));
 
 		/* Update SYS_TABLESPACES and SYS_DATAFILES if a new
 		tablespace was created. */
@@ -2878,7 +2878,7 @@ row_import_tablespace_for_mysql(
 	trx_t*		trx)	/*!< in: transaction handle */
 {
 	dict_table_t*	table = NULL;
-	ulint		space;
+	ulint		space_id;
 	char*		filepath	= NULL;
 	ibool		success;
 	lsn_t		current_lsn;
@@ -2898,11 +2898,9 @@ row_import_tablespace_for_mysql(
 	/* If the table is stored in a remote tablespace, we need to
 	determine that filepath from the link file and system tables.
 	Find the space ID in SYS_TABLES since this is an ALTER TABLE. */
-	if (!dict_get_space_from_sys_tables(name, &space)) {
-		goto table_not_found;
-	}
-	if (space > 0) {
-		filepath = dict_get_first_path(space, name);
+	space_id = fil_get_space_id_for_table(name);
+	if (space_id > 0) {
+		filepath = fil_space_get_first_path(space_id);
 	}
 	if (!filepath) {
 		filepath = fil_make_ibd_name(name, FALSE);
@@ -2945,7 +2943,6 @@ row_import_tablespace_for_mysql(
 					DICT_ERR_IGNORE_NONE);
 
 	if (!table) {
-table_not_found:
 		ut_print_timestamp(stderr);
 		fputs("  InnoDB: table ", stderr);
 		ut_print_name(stderr, trx, TRUE, name);

=== modified file 'storage/innobase/row/row0sel.cc'
--- a/storage/innobase/row/row0sel.cc	revid:viswanatham.gudipati@stripped
+++ b/storage/innobase/row/row0sel.cc	revid:kevin.lewis@stripped
@@ -4330,6 +4330,9 @@ wrong_offs:
 
 	/* Calculate the 'offsets' associated with 'rec' */
 
+	ut_ad(fil_page_get_type(btr_pcur_get_page(pcur)) == FIL_PAGE_INDEX);
+	ut_ad(btr_page_get_index_id(btr_pcur_get_page(pcur)) == index->id);
+
 	offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
 
 	if (UNIV_UNLIKELY(srv_force_recovery > 0)) {

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (kevin.lewis:3827) kevin.lewis16 May