[Commits] Rev 3674: merge 5.5 ->10.0-base in file:///home/bell/maria/bzr/work-maria-10.0-base-merge-5.5/

sanja at montyprogram.com sanja at montyprogram.com
Mon Aug 12 21:13:01 EEST 2013


At file:///home/bell/maria/bzr/work-maria-10.0-base-merge-5.5/

------------------------------------------------------------
revno: 3674 [merge]
revision-id: sanja at montyprogram.com-20130812181243-s2fze0jdu3dld4cp
parent: igor at askmonty.org-20130806203318-esxb7kpq9kab0i97
parent: bar at mariadb.org-20130812133308-xugyz8mncfwny89b
committer: sanja at montyprogram.com
branch nick: work-maria-10.0-base-merge-5.5
timestamp: Mon 2013-08-12 21:12:43 +0300
message:
  merge 5.5 ->10.0-base
modified:
  client/mysql.cc                sp1f-mysql.cc-19700101030959-5sipizk7ehvbsi3tywrkdords5qy5zdl
  dbug/dbug.c                    sp1f-dbug.c-19700101030959-dmu3qmh72hbptp5opqnmfgjtfckxi5ug
  mysql-test/r/dyncol.result     dyncol.result-20110505120213-1qdqxaphgsdy4jv4-3
  mysql-test/r/func_group.result sp1f-func_group.result-20001228015633-oe57bieiww3s6erojiyha7p26m5ul5ql
  mysql-test/r/func_set.result   sp1f-func_set.result-20001228015633-j3yzglmi5wadjwgi7ploqj42uqopnhha
  mysql-test/r/insert.result     sp1f-insert.result-20001228015633-woprirxyorm6dftygpzmfwx536gsboz7
  mysql-test/r/join_outer.result sp1f-join_outer.result-20001228015633-vk2jshiracfus3ze2d2bim2csnnrc5us
  mysql-test/r/join_outer_innodb.result sp1f-join_outer_innodb.re-20060522115726-6frdagg4t7yszj2tzsrau6kxyagi5cl5
  mysql-test/r/join_outer_jcl6.result join_outer_jcl6.resu-20091221012858-uiftww98yhc31z02-1
  mysql-test/r/mysql.result      sp1f-mysql.result-20050517191330-5ywsflw7k6pttof273om5l2mb7pyiu22
  mysql-test/r/range.result      sp1f-range.result-20001228015634-6hpoyn74lnc7irf4gop2jbowgpazbbae
  mysql-test/r/range_mrr_icp.result range_mrr_icp.result-20110708144530-oix2pzfbpykksv5t-1
  mysql-test/r/subselect_cache.result subquery_cache.resul-20100710101008-oqtsrd0hav47cxxm-4
  mysql-test/r/timezone2.result  sp1f-timezone2.result-20040618061118-oloxsu6ifqssfckk32qvvnihwiupwfx2
  mysql-test/r/type_time.result  sp1f-type_time.result-20001228015634-5fhqfmu3mjrvucpfewsldtgdm6tk4ajy
  mysql-test/suite/innodb/r/innodb_mysql.result sp1f-innodb_mysql.result-20060426055153-bychbbfnqtvmvrwccwhn24i6yi46uqjv
  mysql-test/suite/storage_engine/alter_table_online.test alter_table_online.t-20120716021708-9eol83hi7mpuph31-11
  mysql-test/suite/storage_engine/type_spatial.result type_spatial.result-20120716021708-9eol83hi7mpuph31-215
  mysql-test/suite/storage_engine/type_spatial_indexes.result type_spatial_indexes-20120716021708-9eol83hi7mpuph31-217
  mysql-test/t/dyncol.test       dyncol.test-20110505120213-1qdqxaphgsdy4jv4-4
  mysql-test/t/func_set.test     sp1f-func_set.test-20001228015636-dyslyfpvjhbni77gcwkikxezsjxv6l3n
  mysql-test/t/join_outer.test   sp1f-join_outer.test-20001228015636-himrcptylaquy6l5d7pl7pawom3ytmtw
  mysql-test/t/mysql.test        sp1f-mysql.test-20050517191330-gc7zxd3q7cgw4g3pdnswpnxwqnvqhwks
  mysql-test/t/timezone2.test    sp1f-timezone2.test-20040618061121-ndnrev6yt3s7dhdkisgelqzy34gkriwz
  mysql-test/t/type_time.test    sp1f-type_time.test-20001228015637-jmlvm4jzrcz4pcv33ocsug2bqgjk74ov
  mysys/ma_dyncol.c              ma_dyncol.c-20110505120213-1qdqxaphgsdy4jv4-5
  mysys/waiting_threads.c        waiting_threads.c-20080623170213-r8baqa2porlpxzq1-2
  sql/item.cc                    sp1f-item.cc-19700101030959-u7hxqopwpfly4kf5ctlyk2dvrq4l3dhn
  sql/item_cmpfunc.cc            sp1f-item_cmpfunc.cc-19700101030959-hrk7pi2n6qpwxauufnkizirsoucdcx2e
  sql/item_func.cc               sp1f-item_func.cc-19700101030959-3wmsx76yvc25sroqpfrx2n77kqdxxn3y
  sql/item_timefunc.cc           sp1f-item_timefunc.cc-19700101030959-rvvlgmw5b4ewpuuxuntrkiqimyrr5sw2
  sql/sql_cache.cc               sp1f-sql_cache.cc-19700101030959-74bsqwcnhboovijsogcenqana5inu6wo
  sql/sql_select.cc              sp1f-sql_select.cc-19700101030959-egb7whpkh76zzvikycs5nsnuviu4fdlb
  sql/sql_union.cc               sp1f-sql_unions.cc-20010613103653-ljpdcuczpligpiljxsifua5riwhxyomz
  sql/sys_vars.h                 set_var_new.h-20090803110931-vmsjdorbe4cavl4e-1
  storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff optimize_table.rdiff-20120716021708-9eol83hi7mpuph31-394
  storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff repair_table.rdiff-20120716021708-9eol83hi7mpuph31-395
  storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff type_spatial_indexes-20120716021708-9eol83hi7mpuph31-328
  storage/maria/ma_range.c       sp1f-ma_range.c-20060411134429-lrowd7ifuztes43ceqjxqzn3cjqlynu4
  storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff type_spatial.rdiff-20120716021708-9eol83hi7mpuph31-389
  storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff type_spatial_indexes-20120716021708-9eol83hi7mpuph31-390
  storage/xtradb/buf/buf0buf.c   buf0buf.c-20081201061010-zymrrwrczns2vrex-49
  storage/xtradb/fil/fil0fil.c   fil0fil.c-20081201061010-zymrrwrczns2vrex-63
  storage/xtradb/include/buf0buf.h buf0buf.h-20081201061010-zymrrwrczns2vrex-88
  storage/xtradb/include/fil0fil.h fil0fil.h-20081201061010-zymrrwrczns2vrex-119
  storage/xtradb/os/os0file.c    os0file.c-20081201061010-zymrrwrczns2vrex-313
  storage/xtradb/srv/srv0start.c srv0start.c-20081201061010-zymrrwrczns2vrex-348
  storage/xtradb/trx/trx0sys.c   trx0sys.c-20081201061010-zymrrwrczns2vrex-358
-------------- next part --------------
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2013-07-17 19:24:29 +0000
+++ b/client/mysql.cc	2013-08-12 18:12:43 +0000
@@ -3510,6 +3510,7 @@ print_table_data(MYSQL_RES *result)
     if (length < 4 && !IS_NOT_NULL(field->flags))
       length=4;					// Room for "NULL"
     field->max_length=length;
+    num_flag[mysql_field_tell(result) - 1]= IS_NUM(field->type);
     separator.fill(separator.length()+length+2,'-');
     separator.append('+');
   }
@@ -3529,7 +3530,6 @@ print_table_data(MYSQL_RES *result)
       tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
                                             MAX_COLUMN_LENGTH),
                   field->name);
-      num_flag[off]= IS_NUM(field->type);
     }
     (void) tee_fputs("\n", PAGER);
     tee_puts((char*) separator.ptr(), PAGER);

=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c	2013-07-16 17:09:54 +0000
+++ b/dbug/dbug.c	2013-07-29 14:03:41 +0000
@@ -1642,6 +1642,7 @@ void _db_end_()
 
   cs->stack= &init_settings;
   FreeState(cs, 0);
+  init_done= 0;
 }
 
 

=== modified file 'mysql-test/r/dyncol.result'
--- a/mysql-test/r/dyncol.result	2013-03-27 22:41:02 +0000
+++ b/mysql-test/r/dyncol.result	2013-08-12 18:12:43 +0000
@@ -1404,6 +1404,27 @@ v1	CREATE ALGORITHM=UNDEFINED DEFINER=`r
 drop view v1;
 drop table t1;
 #
+# MDEV-4811: Assertion `offset < 0x1f' fails in type_and_offset_store 
+# on COLUMN_ADD
+#
+CREATE TABLE t1 (dyn TINYBLOB) ENGINE=MyISAM;
+INSERT INTO t1 SET dyn = COLUMN_CREATE( 40, REPEAT('a', 233), 4, REPEAT('b', 322) );
+Warnings:
+Warning	1265	Data truncated for column 'dyn' at row 1
+SELECT COLUMN_ADD( dyn, 6, REPEAT('x',80), 4, REPEAT('y',215) AS INTEGER ) FROM t1;
+ERROR HY000: Encountered illegal format of dynamic column string
+DROP table t1;
+#
+# MDEV-4812: Valgrind warnings (Invalid write) in
+# dynamic_column_update_many on COLUMN_ADD
+#
+CREATE TABLE t1 (dyncol TINYBLOB) ENGINE=MyISAM;
+INSERT INTO t1 SET dyncol = COLUMN_CREATE( 7, REPEAT('k',487), 209, REPEAT('x',464) );
+Warnings:
+Warning	1265	Data truncated for column 'dyncol' at row 1
+SELECT COLUMN_ADD( dyncol, 7, '22:22:22', 8, REPEAT('x',270) AS CHAR ) FROM t1;
+DROP table t1;
+#
 # end of 5.3 tests
 #
 #

=== modified file 'mysql-test/r/func_group.result'
--- a/mysql-test/r/func_group.result	2013-05-20 10:36:30 +0000
+++ b/mysql-test/r/func_group.result	2013-07-31 13:24:52 +0000
@@ -1971,6 +1971,7 @@ MIN(t2.pk)
 NULL
 Warnings:
 Warning	1292	Truncated incorrect INTEGER value: 'j'
+Warning	1292	Truncated incorrect INTEGER value: 'j'
 
 EXPLAIN
 SELECT MIN(t2.pk)
@@ -1984,6 +1985,7 @@ id	select_type	table	type	possible_keys
 2	MATERIALIZED	t2	ALL	NULL	NULL	NULL	NULL	2	
 Warnings:
 Warning	1292	Truncated incorrect INTEGER value: 'j'
+Warning	1292	Truncated incorrect INTEGER value: 'j'
 
 #
 # 2) Test that subquery materialization is setup for query with

=== modified file 'mysql-test/r/func_set.result'
--- a/mysql-test/r/func_set.result	2011-03-04 14:46:17 +0000
+++ b/mysql-test/r/func_set.result	2013-08-08 07:48:49 +0000
@@ -160,6 +160,25 @@ CONVERT( a USING latin1 )
 
 DROP TABLE t1, t2;
 #
+# Start of 5.3 tests
+#
+#
+# MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY);
+INSERT INTO t1 VALUES (10),(11);
+SELECT INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) FROM t1;
+INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 )
+8
+8
+Warnings:
+Warning	1292	Incorrect datetime value: '10'
+Warning	1292	Incorrect datetime value: '11'
+DROP TABLE t1;
+#
+# End of 5.3 tests
+#
+#
 # BUG#59405: FIND_IN_SET won't work normaly after upgrade from 5.1 to 5.5
 #
 CREATE TABLE t1(days set('1','2','3','4','5','6','7'));

=== modified file 'mysql-test/r/insert.result'
--- a/mysql-test/r/insert.result	2012-09-18 12:14:19 +0000
+++ b/mysql-test/r/insert.result	2013-07-31 13:24:52 +0000
@@ -663,9 +663,10 @@ Warning	1365	Division by 0
 Warning	1048	Column 'data' cannot be null
 update t1 set data='envelope' where 1/0 or 1;
 affected rows: 2
-info: Rows matched: 2  Changed: 2  Warnings: 3
+info: Rows matched: 2  Changed: 2  Warnings: 4
 Warnings:
 Warning	1365	Division by 0
+Warning	1365	Division by 0
 Warning	1265	Data truncated for column 'data' at row 1
 Warning	1265	Data truncated for column 'data' at row 2
 insert t1 (data) values (default), (1/0), ('dead beef');

=== modified file 'mysql-test/r/join_outer.result'
--- a/mysql-test/r/join_outer.result	2013-05-07 11:05:09 +0000
+++ b/mysql-test/r/join_outer.result	2013-07-31 13:24:52 +0000
@@ -2117,4 +2117,25 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a
 WHERE a.modified > b.modified or b.modified IS NULL;
 id	modified
 DROP TABLE t1;
+#
+# MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL
+#
+create table t0 (a int not null);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+alter table t0 add person_id varchar(255) not null;
+create table t1 (pk int not null primary key);
+insert into t1 select A.a + 10*B.a from t0 A, t0 B;
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	Using index
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	Using index
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	Using index
+drop table t0, t1;
 SET optimizer_switch=@save_optimizer_switch;

=== modified file 'mysql-test/r/join_outer_innodb.result'
--- a/mysql-test/r/join_outer_innodb.result	2013-05-03 21:08:20 +0000
+++ b/mysql-test/r/join_outer_innodb.result	2013-07-31 13:24:52 +0000
@@ -14,8 +14,8 @@ EXPLAIN
 SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id 
 WHERE t1.name LIKE 'A%' OR FALSE;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	index	NULL	fkey	5	NULL	5	Using index
-1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.fkey	1	Using where
+1	SIMPLE	t1	index	PRIMARY,name	name	23	NULL	3	Using where; Using index
+1	SIMPLE	t2	ref	fkey	fkey	5	test.t1.id	1	Using index
 DROP TABLE t1,t2;
 #
 # BUG#58456: Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output

=== modified file 'mysql-test/r/join_outer_jcl6.result'
--- a/mysql-test/r/join_outer_jcl6.result	2013-05-07 11:05:09 +0000
+++ b/mysql-test/r/join_outer_jcl6.result	2013-07-31 13:24:52 +0000
@@ -2128,6 +2128,27 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a
 WHERE a.modified > b.modified or b.modified IS NULL;
 id	modified
 DROP TABLE t1;
+#
+# MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL
+#
+create table t0 (a int not null);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+alter table t0 add person_id varchar(255) not null;
+create table t1 (pk int not null primary key);
+insert into t1 select A.a + 10*B.a from t0 A, t0 B;
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	Using index
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	Using index
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t0.a	1	Using index
+drop table t0, t1;
 SET optimizer_switch=@save_optimizer_switch;
 set join_cache_level=default;
 show variables like 'join_cache_level';

=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result	2013-03-27 22:41:02 +0000
+++ b/mysql-test/r/mysql.result	2013-08-12 18:12:43 +0000
@@ -515,5 +515,9 @@ aa`bb``cc
 drop database `aa``bb````cc`;
 a
 >>\ndelimiter\n<<
++-------------------+
+| a                 |
+| aaaaaaaaaaaaaaaaa |
++-------------------+
 
 End of tests

=== modified file 'mysql-test/r/range.result'
--- a/mysql-test/r/range.result	2013-01-28 13:13:39 +0000
+++ b/mysql-test/r/range.result	2013-07-31 13:24:52 +0000
@@ -1590,6 +1590,8 @@ NULL
 Warnings:
 Warning	1411	Incorrect datetime value: '2007-20-00' for function str_to_date
 Warning	1411	Incorrect datetime value: '2007-20-00' for function str_to_date
+Warning	1411	Incorrect datetime value: '2007-20-00' for function str_to_date
+Warning	1411	Incorrect datetime value: '2007-20-00' for function str_to_date
 SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
 str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
 1

=== modified file 'mysql-test/r/range_mrr_icp.result'
--- a/mysql-test/r/range_mrr_icp.result	2013-01-28 13:13:39 +0000
+++ b/mysql-test/r/range_mrr_icp.result	2013-07-31 13:24:52 +0000
@@ -1592,6 +1592,8 @@ NULL
 Warnings:
 Warning	1411	Incorrect datetime value: '2007-20-00' for function str_to_date
 Warning	1411	Incorrect datetime value: '2007-20-00' for function str_to_date
+Warning	1411	Incorrect datetime value: '2007-20-00' for function str_to_date
+Warning	1411	Incorrect datetime value: '2007-20-00' for function str_to_date
 SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
 str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
 1

=== modified file 'mysql-test/r/subselect_cache.result'
--- a/mysql-test/r/subselect_cache.result	2012-05-17 10:46:05 +0000
+++ b/mysql-test/r/subselect_cache.result	2013-07-31 13:24:52 +0000
@@ -3129,6 +3129,7 @@ WHERE table1 .`col_varchar_key` )	field1
 1	NULL	f
 Warnings:
 Warning	1292	Truncated incorrect DOUBLE value: 'f'
+Warning	1292	Truncated incorrect DOUBLE value: 'f'
 SET @@optimizer_switch = 'subquery_cache=on';
 /* cache is on */ SELECT COUNT( DISTINCT table2 .`col_int_key` ) , (
 SELECT SUBQUERY2_t1 .`col_int_key`
@@ -3144,6 +3145,7 @@ WHERE table1 .`col_varchar_key` )	field1
 1	NULL	f
 Warnings:
 Warning	1292	Truncated incorrect DOUBLE value: 'f'
+Warning	1292	Truncated incorrect DOUBLE value: 'f'
 drop table t1,t2,t3,t4;
 set @@optimizer_switch= default;
 #launchpad BUG#611625

=== modified file 'mysql-test/r/timezone2.result'
--- a/mysql-test/r/timezone2.result	2011-06-07 16:13:02 +0000
+++ b/mysql-test/r/timezone2.result	2013-08-08 08:58:28 +0000
@@ -309,3 +309,22 @@ CONVERT_TZ(1, 1, a)
 NULL
 DROP TABLE t1;
 End of 5.1 tests
+#
+# Start of 5.3 tests
+#
+#
+# MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5')
+#
+SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5');
+CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5')
+NULL
+Warnings:
+Warning	1292	Incorrect datetime value: '00:00:00'
+SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5');
+CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5')
+NULL
+Warnings:
+Warning	1292	Incorrect datetime value: '00:00:00'
+#
+# End of 5.3 tests
+#

=== modified file 'mysql-test/r/type_time.result'
--- a/mysql-test/r/type_time.result	2013-06-28 11:20:40 +0000
+++ b/mysql-test/r/type_time.result	2013-08-12 13:33:08 +0000
@@ -183,6 +183,15 @@ NULL
 Warnings:
 Warning	1292	Incorrect datetime value: '0000-00-00 00:00:00'
 #
+# MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')))
+#
+SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')));
+CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')))
+00:00:01.000000
+SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00')));
+CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00')))
+768:00:01.000000
+#
 # End of 5.3 tests
 #
 CREATE TABLE t1 (f1 TIME);

=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result	2013-06-06 15:51:28 +0000
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result	2013-08-12 18:12:43 +0000
@@ -361,8 +361,8 @@ EXPLAIN
 SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
 WHERE t1.name LIKE 'A%' OR FALSE;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	index	NULL	fkey	5	NULL	5	Using index
-1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.fkey	1	Using where
+1	SIMPLE	t1	index	PRIMARY,name	name	23	NULL	3	Using where; Using index
+1	SIMPLE	t2	ref	fkey	fkey	5	test.t1.id	1	Using index
 DROP TABLE t1,t2;
 CREATE TABLE t1 (
 id int NOT NULL,

=== modified file 'mysql-test/suite/storage_engine/alter_table_online.test'
--- a/mysql-test/suite/storage_engine/alter_table_online.test	2012-07-16 02:17:56 +0000
+++ b/mysql-test/suite/storage_engine/alter_table_online.test	2013-08-05 14:42:22 +0000
@@ -112,7 +112,7 @@ if ($mysql_errname!=ER_CANT_DO_ONLINE)
 --let $alter_definition = MODIFY b BIGINT $default_col_opts
 --source alter_table.inc
 
---let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine != '$storage_engine' AND support IN ('YES','DEFAULT')`
+--let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine IN ('MEMORY','MyISAM') AND engine != '$storage_engine' ORDER BY engine LIMIT 1`
 
 --let $error_codes = ER_CANT_DO_ONLINE
 --let $online = 1

=== modified file 'mysql-test/suite/storage_engine/type_spatial.result'
--- a/mysql-test/suite/storage_engine/type_spatial.result	2013-02-02 22:53:57 +0000
+++ b/mysql-test/suite/storage_engine/type_spatial.result	2013-08-05 14:30:12 +0000
@@ -414,20 +414,20 @@ FROM gis_geometrycollection g1, gis_geom
 first	second	w	c	o	e	d	t	i	r
 120	120	1	1	0	1	0	1	1	0
 120	121	0	0	1	0	0	0	1	0
-120	122	0	1	NULL	0	NULL	0	NULL	0
-120	123	0	1	NULL	0	NULL	0	NULL	0
+120	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+120	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 121	120	0	0	1	0	0	0	1	0
 121	121	1	1	0	1	0	1	1	0
-121	122	0	1	NULL	0	NULL	0	NULL	0
-121	123	0	1	NULL	0	NULL	0	NULL	0
-122	120	1	0	NULL	0	NULL	0	NULL	0
-122	121	1	0	NULL	0	NULL	0	NULL	0
-122	122	1	1	NULL	1	NULL	0	NULL	0
-122	123	1	1	NULL	1	NULL	0	NULL	0
-123	120	1	0	NULL	0	NULL	0	NULL	0
-123	121	1	0	NULL	0	NULL	0	NULL	0
-123	122	1	1	NULL	1	NULL	0	NULL	0
-123	123	1	1	NULL	1	NULL	0	NULL	0
+121	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+121	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
 USE gis_ogs;
 # Lakes

=== modified file 'mysql-test/suite/storage_engine/type_spatial_indexes.result'
--- a/mysql-test/suite/storage_engine/type_spatial_indexes.result	2013-02-02 22:53:57 +0000
+++ b/mysql-test/suite/storage_engine/type_spatial_indexes.result	2013-08-05 14:30:12 +0000
@@ -414,20 +414,20 @@ FROM gis_geometrycollection g1, gis_geom
 first	second	w	c	o	e	d	t	i	r
 120	120	1	1	0	1	0	1	1	0
 120	121	0	0	1	0	0	0	1	0
-120	122	0	1	NULL	0	NULL	0	NULL	0
-120	123	0	1	NULL	0	NULL	0	NULL	0
+120	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+120	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 121	120	0	0	1	0	0	0	1	0
 121	121	1	1	0	1	0	1	1	0
-121	122	0	1	NULL	0	NULL	0	NULL	0
-121	123	0	1	NULL	0	NULL	0	NULL	0
-122	120	1	0	NULL	0	NULL	0	NULL	0
-122	121	1	0	NULL	0	NULL	0	NULL	0
-122	122	1	1	NULL	1	NULL	0	NULL	0
-122	123	1	1	NULL	1	NULL	0	NULL	0
-123	120	1	0	NULL	0	NULL	0	NULL	0
-123	121	1	0	NULL	0	NULL	0	NULL	0
-123	122	1	1	NULL	1	NULL	0	NULL	0
-123	123	1	1	NULL	1	NULL	0	NULL	0
+121	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+121	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
 USE gis_ogs;
 # Lakes
@@ -1114,20 +1114,20 @@ FROM gis_geometrycollection g1, gis_geom
 first	second	w	c	o	e	d	t	i	r
 120	120	1	1	0	1	0	1	1	0
 120	121	0	0	1	0	0	0	1	0
-120	122	0	1	NULL	0	NULL	0	NULL	0
-120	123	0	1	NULL	0	NULL	0	NULL	0
+120	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+120	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 121	120	0	0	1	0	0	0	1	0
 121	121	1	1	0	1	0	1	1	0
-121	122	0	1	NULL	0	NULL	0	NULL	0
-121	123	0	1	NULL	0	NULL	0	NULL	0
-122	120	1	0	NULL	0	NULL	0	NULL	0
-122	121	1	0	NULL	0	NULL	0	NULL	0
-122	122	1	1	NULL	1	NULL	0	NULL	0
-122	123	1	1	NULL	1	NULL	0	NULL	0
-123	120	1	0	NULL	0	NULL	0	NULL	0
-123	121	1	0	NULL	0	NULL	0	NULL	0
-123	122	1	1	NULL	1	NULL	0	NULL	0
-123	123	1	1	NULL	1	NULL	0	NULL	0
+121	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+121	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+122	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+123	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
 USE gis_ogs;
 # Lakes

=== modified file 'mysql-test/t/dyncol.test'
--- a/mysql-test/t/dyncol.test	2013-03-27 22:41:02 +0000
+++ b/mysql-test/t/dyncol.test	2013-08-12 18:12:43 +0000
@@ -604,6 +604,29 @@ drop view v1;
 drop table t1;
 
 --echo #
+--echo # MDEV-4811: Assertion `offset < 0x1f' fails in type_and_offset_store 
+--echo # on COLUMN_ADD
+--echo #
+
+CREATE TABLE t1 (dyn TINYBLOB) ENGINE=MyISAM;
+INSERT INTO t1 SET dyn = COLUMN_CREATE( 40, REPEAT('a', 233), 4, REPEAT('b', 322) );
+--error ER_DYN_COL_WRONG_FORMAT
+SELECT COLUMN_ADD( dyn, 6, REPEAT('x',80), 4, REPEAT('y',215) AS INTEGER ) FROM t1;
+
+DROP table t1;
+
+--echo #
+--echo # MDEV-4812: Valgrind warnings (Invalid write) in
+--echo # dynamic_column_update_many on COLUMN_ADD
+--echo #
+CREATE TABLE t1 (dyncol TINYBLOB) ENGINE=MyISAM;
+
+INSERT INTO t1 SET dyncol = COLUMN_CREATE( 7, REPEAT('k',487), 209, REPEAT('x',464) );
+--error 0,ER_DYN_COL_WRONG_FORMAT
+SELECT COLUMN_ADD( dyncol, 7, '22:22:22', 8, REPEAT('x',270) AS CHAR ) FROM t1;
+DROP table t1;
+
+--echo #
 --echo # end of 5.3 tests
 --echo #
 

=== modified file 'mysql-test/t/func_set.test'
--- a/mysql-test/t/func_set.test	2011-03-04 14:46:17 +0000
+++ b/mysql-test/t/func_set.test	2013-08-08 07:48:49 +0000
@@ -99,6 +99,23 @@ SELECT CONVERT( a USING latin1 ) FROM t2
 DROP TABLE t1, t2;
 
 --echo #
+--echo # Start of 5.3 tests
+--echo #
+
+--echo #
+--echo # MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types
+--echo #
+CREATE TABLE t1 (pk INT PRIMARY KEY);
+INSERT INTO t1 VALUES (10),(11);
+SELECT INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 5.3 tests
+--echo #
+
+
+--echo #
 --echo # BUG#59405: FIND_IN_SET won't work normaly after upgrade from 5.1 to 5.5
 --echo #
 

=== modified file 'mysql-test/t/join_outer.test'
--- a/mysql-test/t/join_outer.test	2013-05-07 11:05:09 +0000
+++ b/mysql-test/t/join_outer.test	2013-07-31 13:24:52 +0000
@@ -1670,4 +1670,21 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a
 
 DROP TABLE t1;
 
+--echo #
+--echo # MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL
+--echo #
+create table t0 (a int not null);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+alter table t0 add person_id varchar(255) not null;
+create table t1 (pk int not null primary key);
+insert into t1 select A.a + 10*B.a from t0 A, t0 B;
+
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or 'xyz' IS NULL;
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo';
+explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or t0.person_id='bar';
+
+drop table t0, t1;
+
+
 SET optimizer_switch=@save_optimizer_switch;

=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test	2013-06-06 15:51:28 +0000
+++ b/mysql-test/t/mysql.test	2013-08-12 18:12:43 +0000
@@ -603,5 +603,10 @@ delimiter
 EOF
 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/13639125.sql
 
+#
+# --skip-column-names and alignment
+#
+--exec $MYSQL -t -N -e "SELECT 'a' union select 'aaaaaaaaaaaaaaaaa'"
+
 --echo
 --echo End of tests

=== modified file 'mysql-test/t/timezone2.test'
--- a/mysql-test/t/timezone2.test	2010-08-06 19:29:37 +0000
+++ b/mysql-test/t/timezone2.test	2013-08-08 08:58:28 +0000
@@ -284,3 +284,19 @@ SELECT CONVERT_TZ(1, 1, a) FROM t1;
 DROP TABLE t1;
 
 --echo End of 5.1 tests
+
+
+--echo #
+--echo # Start of 5.3 tests
+--echo #
+
+--echo #
+--echo # MDEV-4653 Wrong result for CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5')
+--echo #
+
+SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5');
+SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5');
+
+--echo #
+--echo # End of 5.3 tests
+--echo #

=== modified file 'mysql-test/t/type_time.test'
--- a/mysql-test/t/type_time.test	2013-06-28 11:20:40 +0000
+++ b/mysql-test/t/type_time.test	2013-08-12 13:33:08 +0000
@@ -129,6 +129,12 @@ drop table t1;
 SELECT CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5');
 
 --echo #
+--echo # MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')))
+--echo #
+SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')));
+SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00')));
+
+--echo #
 --echo # End of 5.3 tests
 --echo #
 

=== modified file 'mysys/ma_dyncol.c'
--- a/mysys/ma_dyncol.c	2013-04-07 12:00:16 +0000
+++ b/mysys/ma_dyncol.c	2013-08-12 18:12:43 +0000
@@ -1895,6 +1895,7 @@ dynamic_column_create(DYNAMIC_COLUMN *st
   @param header_end      Pointer to the header end
   @param offset_size     Size of offset field in bytes
   @param last_offset     Size of the data segment
+  @param error           Set in case of error
 
   @return number of bytes
 */
@@ -1913,12 +1914,12 @@ static size_t get_length_interval(uchar
   if (entry_next >= header_end)
     return (last_offset - offset);
   if (type_and_offset_read_num(&type_next, &offset_next,
-                               entry_next + COLUMN_NUMBER_SIZE, offset_size))
+                               entry_next + COLUMN_NUMBER_SIZE, offset_size) ||
+      (offset_next > last_offset))
     return DYNCOL_OFFSET_ERROR;
   return (offset_next - offset);
 }
 
-
 /**
   Calculate length of data between given hdr->entry and next_entry
 

=== modified file 'mysys/waiting_threads.c'
--- a/mysys/waiting_threads.c	2013-06-24 18:56:55 +0000
+++ b/mysys/waiting_threads.c	2013-08-12 18:12:43 +0000
@@ -476,6 +476,7 @@ void wt_end()
   my_atomic_rwlock_destroy(&cycle_stats_lock);
   my_atomic_rwlock_destroy(&success_stats_lock);
   my_atomic_rwlock_destroy(&wait_stats_lock);
+  reshash.alloc.constructor= NULL;
   wt_init_done= 0;
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2013-07-17 19:24:29 +0000
+++ b/sql/item.cc	2013-08-12 18:12:43 +0000
@@ -297,7 +297,8 @@ String *Item::val_string_from_decimal(St
 String *Item::val_string_from_date(String *str)
 {
   MYSQL_TIME ltime;
-  if (get_date(&ltime, 0) ||
+  if (get_date(&ltime,
+               field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0) ||
       str->alloc(MAX_DATE_STRING_REP_LENGTH))
   {
     null_value= 1;

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2013-07-17 19:24:29 +0000
+++ b/sql/item_cmpfunc.cc	2013-08-12 18:12:43 +0000
@@ -2006,7 +2006,7 @@ void Item_func_interval::fix_length_and_
     for (uint i= 1; not_null_consts && i < rows; i++)
     {
       Item *el= row->element_index(i);
-      not_null_consts&= el->const_item() & !el->is_null();
+      not_null_consts&= el->const_item() && !el->is_null();
     }
 
     if (not_null_consts &&
@@ -4341,12 +4341,40 @@ Item_cond::fix_fields(THD *thd, Item **r
       return TRUE; /* purecov: inspected */
     used_tables_cache|=     item->used_tables();
     if (item->const_item())
-      and_tables_cache= (table_map) 0;
+    {
+      if (!item->is_expensive() && item->val_int() == 0)
+      {
+        /* 
+          This is "... OR false_cond OR ..." 
+          In this case, false_cond has no effect on cond_or->not_null_tables()
+        */
+      }
+      else
+      {
+        /* 
+          This is  "... OR const_cond OR ..."
+          In this case, cond_or->not_null_tables()=0, because the condition
+          some_cond_or might be true regardless of what tables are 
+          NULL-complemented.
+        */
+        and_tables_cache= (table_map) 0;
+      }
+    }
     else
     {
-      table_map tmp_table_map= item->not_null_tables();
-      not_null_tables_cache|= tmp_table_map;
-      and_tables_cache&= tmp_table_map;
+      /*
+        If an item is a 
+         - constant
+         - inexpensive 
+         - its value is 0
+        then we don't need to account it in not_null_tables_cache
+      */
+      //if (!(item->const_item() && !item->is_expensive() ))
+      {
+        table_map tmp_table_map= item->not_null_tables();
+        not_null_tables_cache|= tmp_table_map;
+        and_tables_cache&= tmp_table_map;
+      }
       const_item_cache= FALSE;
     } 
   
@@ -4374,7 +4402,25 @@ Item_cond::eval_not_null_tables(uchar *o
   {
     table_map tmp_table_map;
     if (item->const_item())
-      and_tables_cache= (table_map) 0;
+    {
+      if (!item->is_expensive() && item->val_int() == 0)
+      {
+        /* 
+          This is "... OR false_cond OR ..." 
+          In this case, false_cond has no effect on cond_or->not_null_tables()
+        */
+      }
+      else
+      {
+        /* 
+          This is  "... OR const_cond OR ..."
+          In this case, cond_or->not_null_tables()=0, because the condition
+          some_cond_or might be true regardless of what tables are 
+          NULL-complemented.
+        */
+        and_tables_cache= (table_map) 0;
+      }
+    }
     else
     {
       tmp_table_map= item->not_null_tables();

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2013-07-17 19:24:29 +0000
+++ b/sql/item_func.cc	2013-08-12 18:12:43 +0000
@@ -2791,6 +2791,13 @@ bool Item_func_min_max::get_date(MYSQL_T
     ltime->time_type= MYSQL_TIMESTAMP_DATE;
     ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
   }
+  else if (compare_as_dates->field_type() == MYSQL_TYPE_TIME)
+  {
+    ltime->time_type= MYSQL_TIMESTAMP_TIME;
+    ltime->hour+= (ltime->month * 32 + ltime->day) * 24;
+    ltime->month= ltime->day= 0;
+  }
+
 
   return (null_value= 0);
 }

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2013-07-17 19:24:29 +0000
+++ b/sql/item_timefunc.cc	2013-08-12 18:12:43 +0000
@@ -2032,7 +2032,9 @@ bool Item_date_add_interval::get_date(MY
 {
   INTERVAL interval;
 
-  if (args[0]->get_date(ltime, 0) ||
+  if (args[0]->get_date(ltime,
+                        cached_field_type == MYSQL_TYPE_TIME ?
+                        TIME_TIME_ONLY : 0) ||
       get_interval_value(args[1], int_type, &interval))
     return (null_value=1);
 
@@ -2423,7 +2425,9 @@ bool Item_time_typecast::get_date(MYSQL_
   if (ltime->time_type != MYSQL_TIMESTAMP_TIME)
     ltime->year= ltime->month= ltime->day= 0;
   ltime->time_type= MYSQL_TIMESTAMP_TIME;
-  return 0;
+  return (fuzzy_date & TIME_TIME_ONLY) ? 0 :
+         (null_value= check_date_with_warn(ltime, fuzzy_date,
+                                           MYSQL_TIMESTAMP_ERROR)); 
 }
 
 

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2013-06-06 15:51:28 +0000
+++ b/sql/sql_cache.cc	2013-08-12 18:12:43 +0000
@@ -1312,17 +1312,17 @@ ulong Query_cache::resize(ulong query_ca
     {
       BLOCK_LOCK_WR(block);
       Query_cache_query *query= block->query();
-      if (query && query->writer())
+      if (query->writer())
       {
         /*
-           Drop the writer; this will cancel any attempts to store 
+           Drop the writer; this will cancel any attempts to store
            the processed statement associated with this writer.
          */
         query->writer()->first_query_block= NULL;
         query->writer(0);
         refused++;
       }
-      BLOCK_UNLOCK_WR(block);
+      query->unlock_n_destroy();
       block= block->next;
     } while (block != queries_blocks);
   }
@@ -4247,11 +4247,11 @@ my_bool Query_cache::move_by_type(uchar
     size_t key_length;
     key=query_cache_query_get_key((uchar*) block, &key_length, 0);
     my_hash_first(&queries, (uchar*) key, key_length, &record_idx);
-    // Move table of used tables 
-    memmove((char*) new_block->table(0), (char*) block->table(0),
-	   ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table)));
     block->query()->unlock_n_destroy();
     block->destroy();
+    // Move table of used tables
+    memmove((char*) new_block->table(0), (char*) block->table(0),
+	   ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table)));
     new_block->init(len);
     new_block->type=Query_cache_block::QUERY;
     new_block->used=used;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2013-07-17 19:24:29 +0000
+++ b/sql/sql_select.cc	2013-08-12 18:12:43 +0000
@@ -16171,6 +16171,8 @@ create_internal_tmp_table_from_heap2(THD
   const char *save_proc_info;
   int write_err= 0;
   DBUG_ENTER("create_internal_tmp_table_from_heap2");
+  if (is_duplicate)
+    *is_duplicate= FALSE;
 
   if (table->s->db_type() != heap_hton || 
       error != HA_ERR_RECORD_FILE_FULL)

=== modified file 'sql/sql_union.cc'
--- a/sql/sql_union.cc	2013-07-17 19:24:29 +0000
+++ b/sql/sql_union.cc	2013-08-12 18:12:43 +0000
@@ -83,7 +83,7 @@ int select_union::send_data(List<Item> &
       */
       return -1;
     }
-    bool is_duplicate;
+    bool is_duplicate= FALSE;
     /* create_internal_tmp_table_from_heap will generate error if needed */
     if (table->file->is_fatal_error(write_err, HA_CHECK_DUP) &&
         create_internal_tmp_table_from_heap(thd, table,

=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h	2013-05-22 15:36:48 +0000
+++ b/sql/sys_vars.h	2013-08-12 18:12:43 +0000
@@ -428,7 +428,10 @@ public:
   void cleanup()
   {
     if (flags & ALLOCATED)
+    {
       my_free(global_var(char*));
+      global_var(char *)= NULL;
+    }
     flags&= ~ALLOCATED;
   }
   static bool do_string_check(THD *thd, set_var *var, CHARSET_INFO *charset)

=== modified file 'storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff'
--- a/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff	2012-07-16 02:17:56 +0000
+++ b/storage/innobase/mysql-test/storage_engine/parts/optimize_table.rdiff	2013-08-05 16:31:29 +0000
@@ -1,25 +1,25 @@
---- suite/storage_engine/parts/optimize_table.result	2012-07-12 22:16:39.343572304 +0400
-+++ suite/storage_engine/parts/optimize_table.reject	2012-07-15 20:07:01.632130348 +0400
+--- suite/storage_engine/parts/optimize_table.result	2013-07-18 22:55:38.000000000 +0400
++++ suite/storage_engine/parts/optimize_table.reject	2013-08-05 19:45:19.000000000 +0400
 @@ -9,18 +9,22 @@
  INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
  ALTER TABLE t1 OPTIMIZE PARTITION p1;
  Table	Op	Msg_type	Msg_text
-+test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
++test.t1	optimize	note	Table does not support optimize on partitions. All partitions will be rebuilt and analyzed.
  test.t1	optimize	status	OK
  INSERT INTO t2 (a,b) VALUES (4,'d');
  ALTER TABLE t2 OPTIMIZE PARTITION p0 NO_WRITE_TO_BINLOG;
  Table	Op	Msg_type	Msg_text
-+test.t2	optimize	note	Table does not support optimize, doing recreate + analyze instead
++test.t2	optimize	note	Table does not support optimize on partitions. All partitions will be rebuilt and analyzed.
  test.t2	optimize	status	OK
  INSERT INTO t1 (a,b) VALUES (6,'f');
  ALTER TABLE t1 OPTIMIZE PARTITION ALL LOCAL;
  Table	Op	Msg_type	Msg_text
-+test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
++test.t1	optimize	note	Table does not support optimize on partitions. All partitions will be rebuilt and analyzed.
  test.t1	optimize	status	OK
  INSERT INTO t2 (a,b) VALUES (5,'e');
  ALTER TABLE t2 OPTIMIZE PARTITION p1,p0;
  Table	Op	Msg_type	Msg_text
-+test.t2	optimize	note	Table does not support optimize, doing recreate + analyze instead
++test.t2	optimize	note	Table does not support optimize on partitions. All partitions will be rebuilt and analyzed.
  test.t2	optimize	status	OK
  DROP TABLE t1, t2;
  DROP TABLE IF EXISTS t1,t2;

=== modified file 'storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff'
--- a/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff	2013-02-02 22:53:57 +0000
+++ b/storage/innobase/mysql-test/storage_engine/parts/repair_table.rdiff	2013-08-05 16:31:29 +0000
@@ -1,26 +1,6 @@
---- suite/storage_engine/parts/repair_table.result	2013-01-23 01:35:44.388267080 +0400
-+++ suite/storage_engine/parts/repair_table.reject	2013-01-23 01:44:40.337529283 +0400
-@@ -9,27 +9,27 @@
- INSERT INTO t2 (a,b) SELECT a, b FROM t1;
- ALTER TABLE t1 REPAIR PARTITION p0;
- Table	Op	Msg_type	Msg_text
--test.t1	repair	status	OK
-+test.t1	repair	note	The storage engine for the table doesn't support repair
- INSERT INTO t1 (a,b) VALUES (3,'c');
- ALTER TABLE t1 REPAIR PARTITION NO_WRITE_TO_BINLOG p0, p1;
- Table	Op	Msg_type	Msg_text
--test.t1	repair	status	OK
-+test.t1	repair	note	The storage engine for the table doesn't support repair
- INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
- ALTER TABLE t2 REPAIR PARTITION LOCAL p1;
- Table	Op	Msg_type	Msg_text
--test.t2	repair	status	OK
-+test.t2	repair	note	The storage engine for the table doesn't support repair
- INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
- ALTER TABLE t1 REPAIR PARTITION LOCAL ALL EXTENDED;
- Table	Op	Msg_type	Msg_text
--test.t1	repair	status	OK
-+test.t1	repair	note	The storage engine for the table doesn't support repair
+--- suite/storage_engine/parts/repair_table.result	2013-07-18 22:55:38.000000000 +0400
++++ suite/storage_engine/parts/repair_table.reject	2013-08-05 19:54:09.000000000 +0400
+@@ -25,7 +25,7 @@
  INSERT INTO t1 (a,b) VALUES (10,'j');
  ALTER TABLE t1 REPAIR PARTITION p1 QUICK USE_FRM;
  Table	Op	Msg_type	Msg_text
@@ -29,39 +9,7 @@
  INSERT INTO t2 (a,b) VALUES (12,'l');
  ALTER TABLE t2 REPAIR PARTITION NO_WRITE_TO_BINLOG ALL QUICK EXTENDED USE_FRM;
  Table	Op	Msg_type	Msg_text
--test.t2	repair	status	OK
-+test.t2	repair	note	The storage engine for the table doesn't support repair
- DROP TABLE t1, t2;
- DROP TABLE IF EXISTS t1,t2;
- CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
-@@ -37,35 +37,35 @@
- CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
- REPAIR TABLE t1;
- Table	Op	Msg_type	Msg_text
--test.t1	repair	status	OK
-+test.t1	repair	note	The storage engine for the table doesn't support repair
- INSERT INTO t1 (a,b) VALUES (3,'c');
- INSERT INTO t2 (a,b) VALUES (4,'d');
- REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2;
- Table	Op	Msg_type	Msg_text
--test.t1	repair	status	OK
--test.t2	repair	status	OK
-+test.t1	repair	note	The storage engine for the table doesn't support repair
-+test.t2	repair	note	The storage engine for the table doesn't support repair
- INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
- REPAIR LOCAL TABLE t2;
- Table	Op	Msg_type	Msg_text
--test.t2	repair	status	OK
-+test.t2	repair	note	The storage engine for the table doesn't support repair
- INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
- INSERT INTO t2 (a,b) VALUES (9,'i');
- REPAIR LOCAL TABLE t2, t1 EXTENDED;
- Table	Op	Msg_type	Msg_text
--test.t2	repair	status	OK
--test.t1	repair	status	OK
-+test.t2	repair	note	The storage engine for the table doesn't support repair
-+test.t1	repair	note	The storage engine for the table doesn't support repair
- INSERT INTO t1 (a,b) VALUES (10,'j');
+@@ -58,8 +58,8 @@
  INSERT INTO t2 (a,b) VALUES (11,'k');
  REPAIR TABLE t1, t2 QUICK USE_FRM;
  Table	Op	Msg_type	Msg_text
@@ -72,25 +20,7 @@
  INSERT INTO t1 (a,b) VALUES (12,'l');
  INSERT INTO t2 (a,b) VALUES (13,'m');
  REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2 QUICK EXTENDED USE_FRM;
- Table	Op	Msg_type	Msg_text
--test.t1	repair	status	OK
--test.t2	repair	status	OK
-+test.t1	repair	note	The storage engine for the table doesn't support repair
-+test.t2	repair	note	The storage engine for the table doesn't support repair
- FLUSH TABLE t1;
- INSERT INTO t1 (a,b) VALUES (14,'n');
- ERROR HY000: Failed to read from the .par file
-@@ -93,127 +93,21 @@
- CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
- REPAIR TABLE t1;
- Table	Op	Msg_type	Msg_text
--test.t1	repair	status	OK
-+test.t1	repair	note	The storage engine for the table doesn't support repair
- INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
- REPAIR TABLE t1 EXTENDED;
- Table	Op	Msg_type	Msg_text
--test.t1	repair	status	OK
-+test.t1	repair	note	The storage engine for the table doesn't support repair
+@@ -101,119 +101,13 @@
  INSERT INTO t1 (a,b) VALUES (10,'j');
  REPAIR TABLE t1 USE_FRM;
  Table	Op	Msg_type	Msg_text

=== modified file 'storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff'
--- a/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff	2013-02-02 22:53:57 +0000
+++ b/storage/innobase/mysql-test/storage_engine/type_spatial_indexes.rdiff	2013-08-05 14:30:12 +0000
@@ -1,5 +1,5 @@
---- suite/storage_engine/type_spatial_indexes.result	2013-01-23 01:25:45.367797786 +0400
-+++ suite/storage_engine/type_spatial_indexes.reject	2013-01-23 01:46:17.560307029 +0400
+--- suite/storage_engine/type_spatial_indexes.result	2013-08-05 18:08:49.000000000 +0400
++++ suite/storage_engine/type_spatial_indexes.reject	2013-08-05 18:25:24.000000000 +0400
 @@ -702,699 +702,15 @@
  DROP DATABASE IF EXISTS gis_ogs;
  CREATE DATABASE gis_ogs;
@@ -416,20 +416,20 @@
 -first	second	w	c	o	e	d	t	i	r
 -120	120	1	1	0	1	0	1	1	0
 -120	121	0	0	1	0	0	0	1	0
--120	122	0	1	NULL	0	NULL	0	NULL	0
--120	123	0	1	NULL	0	NULL	0	NULL	0
+-120	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-120	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 -121	120	0	0	1	0	0	0	1	0
 -121	121	1	1	0	1	0	1	1	0
--121	122	0	1	NULL	0	NULL	0	NULL	0
--121	123	0	1	NULL	0	NULL	0	NULL	0
--122	120	1	0	NULL	0	NULL	0	NULL	0
--122	121	1	0	NULL	0	NULL	0	NULL	0
--122	122	1	1	NULL	1	NULL	0	NULL	0
--122	123	1	1	NULL	1	NULL	0	NULL	0
--123	120	1	0	NULL	0	NULL	0	NULL	0
--123	121	1	0	NULL	0	NULL	0	NULL	0
--123	122	1	1	NULL	1	NULL	0	NULL	0
--123	123	1	1	NULL	1	NULL	0	NULL	0
+-121	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-121	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
 -USE gis_ogs;
 -# Lakes

=== modified file 'storage/maria/ma_range.c'
--- a/storage/maria/ma_range.c	2011-07-13 19:10:18 +0000
+++ b/storage/maria/ma_range.c	2013-07-25 18:42:26 +0000
@@ -144,6 +144,10 @@ static ha_rows _ma_record_pos(MARIA_HA *
 		       (HA_KEYSEG**) 0);
   DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE, &key););
   nextflag=maria_read_vec[search_flag];
+  
+  /* Indicate if we're doing a search on a key prefix */
+  if (((((key_part_map)1) << key.keyinfo->keysegs) - 1) != keypart_map)
+    nextflag |= SEARCH_PART_KEY;
 
   /*
     my_handler.c:ha_compare_text() has a flag 'skip_end_space'.

=== modified file 'storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff'
--- a/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff	2013-02-02 22:53:57 +0000
+++ b/storage/myisammrg/mysql-test/storage_engine/type_spatial.rdiff	2013-08-05 14:30:12 +0000
@@ -1,5 +1,5 @@
---- type_spatial.result	2013-01-23 01:25:39.143876032 +0400
-+++ type_spatial.reject	2013-01-23 02:51:14.535315418 +0400
+--- suite/storage_engine/type_spatial.result	2013-08-05 17:52:53.000000000 +0400
++++ suite/storage_engine/type_spatial.reject	2013-08-05 17:56:37.000000000 +0400
 @@ -2,699 +2,15 @@
  DROP DATABASE IF EXISTS gis_ogs;
  CREATE DATABASE gis_ogs;
@@ -416,20 +416,20 @@
 -first	second	w	c	o	e	d	t	i	r
 -120	120	1	1	0	1	0	1	1	0
 -120	121	0	0	1	0	0	0	1	0
--120	122	0	1	NULL	0	NULL	0	NULL	0
--120	123	0	1	NULL	0	NULL	0	NULL	0
+-120	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-120	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 -121	120	0	0	1	0	0	0	1	0
 -121	121	1	1	0	1	0	1	1	0
--121	122	0	1	NULL	0	NULL	0	NULL	0
--121	123	0	1	NULL	0	NULL	0	NULL	0
--122	120	1	0	NULL	0	NULL	0	NULL	0
--122	121	1	0	NULL	0	NULL	0	NULL	0
--122	122	1	1	NULL	1	NULL	0	NULL	0
--122	123	1	1	NULL	1	NULL	0	NULL	0
--123	120	1	0	NULL	0	NULL	0	NULL	0
--123	121	1	0	NULL	0	NULL	0	NULL	0
--123	122	1	1	NULL	1	NULL	0	NULL	0
--123	123	1	1	NULL	1	NULL	0	NULL	0
+-121	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-121	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
 -USE gis_ogs;
 -# Lakes

=== modified file 'storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff'
--- a/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff	2013-02-02 22:53:57 +0000
+++ b/storage/myisammrg/mysql-test/storage_engine/type_spatial_indexes.rdiff	2013-08-05 14:30:12 +0000
@@ -1,5 +1,5 @@
---- type_spatial_indexes.result	2013-01-23 01:25:45.367797786 +0400
-+++ type_spatial_indexes.reject	2013-01-23 02:51:15.247306467 +0400
+--- suite/storage_engine/type_spatial_indexes.result	2013-08-05 18:08:49.000000000 +0400
++++ suite/storage_engine/type_spatial_indexes.reject	2013-08-05 18:27:47.000000000 +0400
 @@ -2,1399 +2,31 @@
  DROP DATABASE IF EXISTS gis_ogs;
  CREATE DATABASE gis_ogs;
@@ -416,20 +416,20 @@
 -first	second	w	c	o	e	d	t	i	r
 -120	120	1	1	0	1	0	1	1	0
 -120	121	0	0	1	0	0	0	1	0
--120	122	0	1	NULL	0	NULL	0	NULL	0
--120	123	0	1	NULL	0	NULL	0	NULL	0
+-120	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-120	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 -121	120	0	0	1	0	0	0	1	0
 -121	121	1	1	0	1	0	1	1	0
--121	122	0	1	NULL	0	NULL	0	NULL	0
--121	123	0	1	NULL	0	NULL	0	NULL	0
--122	120	1	0	NULL	0	NULL	0	NULL	0
--122	121	1	0	NULL	0	NULL	0	NULL	0
--122	122	1	1	NULL	1	NULL	0	NULL	0
--122	123	1	1	NULL	1	NULL	0	NULL	0
--123	120	1	0	NULL	0	NULL	0	NULL	0
--123	121	1	0	NULL	0	NULL	0	NULL	0
--123	122	1	1	NULL	1	NULL	0	NULL	0
--123	123	1	1	NULL	1	NULL	0	NULL	0
+-121	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-121	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
 -USE gis_ogs;
 -# Lakes
@@ -1126,20 +1126,20 @@
 -first	second	w	c	o	e	d	t	i	r
 -120	120	1	1	0	1	0	1	1	0
 -120	121	0	0	1	0	0	0	1	0
--120	122	0	1	NULL	0	NULL	0	NULL	0
--120	123	0	1	NULL	0	NULL	0	NULL	0
+-120	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-120	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 -121	120	0	0	1	0	0	0	1	0
 -121	121	1	1	0	1	0	1	1	0
--121	122	0	1	NULL	0	NULL	0	NULL	0
--121	123	0	1	NULL	0	NULL	0	NULL	0
--122	120	1	0	NULL	0	NULL	0	NULL	0
--122	121	1	0	NULL	0	NULL	0	NULL	0
--122	122	1	1	NULL	1	NULL	0	NULL	0
--122	123	1	1	NULL	1	NULL	0	NULL	0
--123	120	1	0	NULL	0	NULL	0	NULL	0
--123	121	1	0	NULL	0	NULL	0	NULL	0
--123	122	1	1	NULL	1	NULL	0	NULL	0
--123	123	1	1	NULL	1	NULL	0	NULL	0
+-121	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-121	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-122	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	120	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	121	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	122	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+-123	123	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
 -DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
 -USE gis_ogs;
 -# Lakes

=== modified file 'storage/xtradb/buf/buf0buf.c'
--- a/storage/xtradb/buf/buf0buf.c	2013-07-17 14:03:59 +0000
+++ b/storage/xtradb/buf/buf0buf.c	2013-07-19 10:21:23 +0000
@@ -581,6 +581,8 @@ UNIV_INTERN
 ibool
 buf_page_is_corrupted(
 /*==================*/
+	ibool		check_lsn,	/*!< in: TRUE if we need to check
+					and complain about the LSN */
 	const byte*	read_buf,	/*!< in: a database page */
 	ulint		zip_size)	/*!< in: size of compressed page;
 					0 for uncompressed pages */
@@ -600,7 +602,7 @@ buf_page_is_corrupted(
 	}
 
 #ifndef UNIV_HOTBACKUP
-	if (recv_lsn_checks_on) {
+	if (check_lsn && recv_lsn_checks_on) {
 		ib_uint64_t	current_lsn;
 
 		if (log_peek_lsn(&current_lsn)
@@ -3945,7 +3947,7 @@ buf_page_io_complete(
 		/* From version 3.23.38 up we store the page checksum
 		to the 4 first bytes of the page end lsn field */
 
-		if (buf_page_is_corrupted(frame,
+		if (buf_page_is_corrupted(TRUE, frame,
 					  buf_page_get_zip_size(bpage))) {
 corrupt:
 			fprintf(stderr,

=== modified file 'storage/xtradb/fil/fil0fil.c'
--- a/storage/xtradb/fil/fil0fil.c	2013-07-17 14:03:59 +0000
+++ b/storage/xtradb/fil/fil0fil.c	2013-07-19 10:21:23 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -1884,10 +1884,62 @@ fil_write_flushed_lsn_to_data_files(
 }
 
 /*******************************************************************//**
+Checks the consistency of the first data page of a data file
+at database startup.
+ at retval NULL on success, or if innodb_force_recovery is set
+ at return pointer to an error message string */
+static __attribute__((warn_unused_result))
+const char*
+fil_check_first_page(
+/*=================*/
+	const page_t*	page,		/*!< in: data page */
+	ibool		first_page)	/*!< in: TRUE if this is the
+					first page of the tablespace */
+{
+	ulint	space_id;
+	ulint	flags;
+
+	if (srv_force_recovery >= SRV_FORCE_IGNORE_CORRUPT) {
+		return(NULL);
+	}
+
+	space_id = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page);
+	flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page);
+
+	if (first_page && !space_id && !flags) {
+		ulint		nonzero_bytes	= UNIV_PAGE_SIZE;
+		const byte*	b		= page;
+
+		while (!*b && --nonzero_bytes) {
+			b++;
+		}
+
+		if (!nonzero_bytes) {
+			return("space header page consists of zero bytes");
+		}
+	}
+
+	if (buf_page_is_corrupted(
+		    FALSE, page, dict_table_flags_to_zip_size(flags))) {
+		return("checksum mismatch");
+	}
+
+	if (!first_page
+	    || (page_get_space_id(page) == space_id
+		&& page_get_page_no(page) == 0)) {
+		return(NULL);
+	}
+
+	return("inconsistent data in space header");
+}
+
+/*******************************************************************//**
 Reads the flushed lsn, arch no, and tablespace flag fields from a data
-file at database startup. */
+file at database startup.
+ at retval NULL on success, or if innodb_force_recovery is set
+ at return pointer to an error message string */
 UNIV_INTERN
-void
+const char*
 fil_read_first_page(
 /*================*/
 	os_file_t	data_file,		/*!< in: open data file */
@@ -1909,6 +1961,7 @@ fil_read_first_page(
 	byte*		buf;
 	page_t*		page;
 	ib_uint64_t	flushed_lsn;
+	const char*	check_msg;
 
 	buf = ut_malloc(2 * UNIV_PAGE_SIZE);
 	/* Align the memory for a possible read from a raw device */
@@ -1916,13 +1969,18 @@ fil_read_first_page(
 
 	os_file_read(data_file, page, 0, 0, UNIV_PAGE_SIZE);
 
-	*flags = mach_read_from_4(page +
-		FSP_HEADER_OFFSET + FSP_SPACE_FLAGS);
+	*flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page);
 
 	flushed_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN);
 
+	check_msg = fil_check_first_page(page, !one_read_already);
+
 	ut_free(buf);
 
+	if (check_msg) {
+		return(check_msg);
+	}
+
 	if (!one_read_already) {
 		*min_flushed_lsn = flushed_lsn;
 		*max_flushed_lsn = flushed_lsn;
@@ -1930,7 +1988,7 @@ fil_read_first_page(
 		*min_arch_log_no = arch_log_no;
 		*max_arch_log_no = arch_log_no;
 #endif /* UNIV_LOG_ARCHIVE */
-		return;
+		return(NULL);
 	}
 
 	if (*min_flushed_lsn > flushed_lsn) {
@@ -1947,6 +2005,8 @@ fil_read_first_page(
 		*max_arch_log_no = arch_log_no;
 	}
 #endif /* UNIV_LOG_ARCHIVE */
+
+	return(NULL);
 }
 
 /*================ SINGLE-TABLE TABLESPACES ==========================*/
@@ -3271,6 +3331,7 @@ fil_open_single_table_tablespace(
 	os_file_t	file;
 	char*		filepath;
 	ibool		success;
+	const char*	check_msg;
 	byte*		buf2;
 	byte*		page;
 	ulint		space_id;
@@ -3331,6 +3392,8 @@ fil_open_single_table_tablespace(
 
 	success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
 
+	check_msg = fil_check_first_page(page, TRUE);
+
 	/* We have to read the tablespace id and flags from the file. */
 
 	space_id = fsp_header_get_space_id(page);
@@ -3366,7 +3429,7 @@ fil_open_single_table_tablespace(
 		current_lsn = log_get_lsn();
 
 		/* check the header page's consistency */
-		if (buf_page_is_corrupted(page,
+		if (buf_page_is_corrupted(TRUE, page,
 					  dict_table_flags_to_zip_size(space_flags))) {
 			fprintf(stderr, "InnoDB: page 0 of %s seems corrupt.\n", filepath);
 			file_is_corrupt = TRUE;
@@ -3788,8 +3851,20 @@ skip_write:
 
 	ut_free(buf2);
 
-	if (UNIV_UNLIKELY(space_id != id
-			  || space_flags != (flags & ~(~0 << DICT_TF_BITS)))) {
+	if (check_msg) {
+		ut_print_timestamp(stderr);
+		fprintf(stderr, "  InnoDB: Error: %s in file ", check_msg);
+		ut_print_filename(stderr, filepath);
+		fprintf(stderr, " (tablespace id=%lu, flags=%lu)\n"
+			"InnoDB: Please refer to " REFMAN
+			"innodb-troubleshooting-datadict.html\n",
+			(ulong) id, (ulong) flags);
+		success = FALSE;
+		goto func_exit;
+	}
+
+	if (space_id != id
+	    || space_flags != (flags & ~(~0 << DICT_TF_BITS))) {
 		ut_print_timestamp(stderr);
 
 		fputs("  InnoDB: Error: tablespace id and flags in file ",
@@ -4280,11 +4355,21 @@ fil_load_single_table_tablespace(
 	page = ut_align(buf2, UNIV_PAGE_SIZE);
 
 	if (size >= FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
+		const char*	check_msg;
 
 		success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
 
 		/* We have to read the tablespace id from the file */
 
+		check_msg = fil_check_first_page(page, TRUE);
+
+		if (check_msg) {
+			fprintf(stderr,
+				"InnoDB: Error: %s in file %s",
+				check_msg, filepath);
+			goto func_exit;
+		}
+
 		space_id = fsp_header_get_space_id(page);
 		flags = fsp_header_get_flags(page);
 	} else {

=== modified file 'storage/xtradb/include/buf0buf.h'
--- a/storage/xtradb/include/buf0buf.h	2013-07-17 14:03:59 +0000
+++ b/storage/xtradb/include/buf0buf.h	2013-07-19 10:21:23 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -684,9 +684,12 @@ UNIV_INTERN
 ibool
 buf_page_is_corrupted(
 /*==================*/
+	ibool		check_lsn,	/*!< in: TRUE if we need to check
+					and complain about the LSN */
 	const byte*	read_buf,	/*!< in: a database page */
-	ulint		zip_size);	/*!< in: size of compressed page;
+	ulint		zip_size)	/*!< in: size of compressed page;
 					0 for uncompressed pages */
+	__attribute__((warn_unused_result));
 #ifndef UNIV_HOTBACKUP
 /**********************************************************************//**
 Gets the space id, page offset, and byte offset within page of a

=== modified file 'storage/xtradb/include/fil0fil.h'
--- a/storage/xtradb/include/fil0fil.h	2013-07-17 14:03:59 +0000
+++ b/storage/xtradb/include/fil0fil.h	2013-07-19 10:21:23 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -328,10 +328,12 @@ fil_write_flushed_lsn_to_data_files(
 	ulint		arch_log_no);	/*!< in: latest archived log
 					file number */
 /*******************************************************************//**
-Reads the flushed lsn and arch no fields from a data file at database
-startup. */
+Reads the flushed lsn, arch no, and tablespace flag fields from a data
+file at database startup.
+ at retval NULL on success, or if innodb_force_recovery is set
+ at return pointer to an error message string */
 UNIV_INTERN
-void
+const char*
 fil_read_first_page(
 /*================*/
 	os_file_t	data_file,		/*!< in: open data file */
@@ -347,8 +349,9 @@ fil_read_first_page(
 #endif /* UNIV_LOG_ARCHIVE */
 	ib_uint64_t*	min_flushed_lsn,	/*!< out: min of flushed
 						lsn values in data files */
-	ib_uint64_t*	max_flushed_lsn);	/*!< out: max of flushed
+	ib_uint64_t*	max_flushed_lsn)	/*!< out: max of flushed
 						lsn values in data files */
+	__attribute__((warn_unused_result));
 /*******************************************************************//**
 Increments the count of pending operation, if space is not being deleted.
 @return	TRUE if being deleted, and operation should be skipped */

=== modified file 'storage/xtradb/os/os0file.c'
--- a/storage/xtradb/os/os0file.c	2013-07-17 19:24:29 +0000
+++ b/storage/xtradb/os/os0file.c	2013-08-12 18:12:43 +0000
@@ -3773,6 +3773,10 @@ os_aio_free(void)
 	ut_free(os_aio_segment_wait_events);
 	os_aio_segment_wait_events = 0;
 	os_aio_n_segments = 0;
+#ifdef _WIN32
+	completion_port = 0;
+	read_completion_port = 0;
+#endif
 }
 
 #ifdef WIN_ASYNC_IO

=== modified file 'storage/xtradb/srv/srv0start.c'
--- a/storage/xtradb/srv/srv0start.c	2013-07-17 14:03:59 +0000
+++ b/storage/xtradb/srv/srv0start.c	2013-07-19 10:21:23 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
 Copyright (c) 2008, Google Inc.
 Copyright (c) 2009, Percona Inc.
 
@@ -817,6 +817,7 @@ open_or_create_data_files(
 		}
 
 		if (ret == FALSE) {
+			const char* check_msg;
 			/* We open the data file */
 
 			if (one_created) {
@@ -914,13 +915,20 @@ open_or_create_data_files(
 				return(DB_ERROR);
 			}
 skip_size_check:
-			fil_read_first_page(
+			check_msg = fil_read_first_page(
 				files[i], one_opened, &flags,
 #ifdef UNIV_LOG_ARCHIVE
 				min_arch_log_no, max_arch_log_no,
 #endif /* UNIV_LOG_ARCHIVE */
 				min_flushed_lsn, max_flushed_lsn);
 
+			if (check_msg) {
+				fprintf(stderr,
+					"InnoDB: Error: %s in data file %s\n",
+					check_msg, name);
+				return(DB_ERROR);
+			}
+
 			if (!one_opened
 			    && UNIV_PAGE_SIZE
 			       != fsp_flags_get_page_size(flags)) {
@@ -1042,6 +1050,8 @@ skip_size_check:
 
 		if (ret == FALSE) {
 
+			const char* check_msg;
+
 			/* We open the data file */
 
 			files[i] = os_file_create(innodb_file_data_key,
@@ -1078,13 +1088,20 @@ skip_size_check:
 					(ulong) TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9);
 			}
 
-			fil_read_first_page(
+			check_msg = fil_read_first_page(
 				files[i], one_opened, &flags,
 #ifdef UNIV_LOG_ARCHIVE
 				min_arch_log_no, max_arch_log_no,
 #endif /* UNIV_LOG_ARCHIVE */
 				min_flushed_lsn, max_flushed_lsn);
 
+			if (check_msg) {
+				fprintf(stderr,
+					"InnoDB: Error: %s in doublewrite "
+					"buffer file %s\n", check_msg, name);
+				return(DB_ERROR);
+			}
+
 			one_opened = TRUE;
 		} else {
 			/* We created the data file and now write it full of

=== modified file 'storage/xtradb/trx/trx0sys.c'
--- a/storage/xtradb/trx/trx0sys.c	2013-07-17 14:03:59 +0000
+++ b/storage/xtradb/trx/trx0sys.c	2013-07-19 10:21:23 +0000
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -726,7 +726,8 @@ trx_sys_doublewrite_init_or_restore_page
 			/* Check if the page is corrupt */
 
 			if (UNIV_UNLIKELY
-			    (buf_page_is_corrupted(read_buf, zip_size))) {
+			    (buf_page_is_corrupted(
+				    TRUE, read_buf, zip_size))) {
 
 				fprintf(stderr,
 					"InnoDB: Warning: database page"
@@ -737,7 +738,8 @@ trx_sys_doublewrite_init_or_restore_page
 					" the doublewrite buffer.\n",
 					(ulong) space_id, (ulong) page_no);
 
-				if (buf_page_is_corrupted(page, zip_size)) {
+				if (buf_page_is_corrupted(
+					    TRUE, page, zip_size)) {
 					fprintf(stderr,
 						"InnoDB: Dump of the page:\n");
 					buf_page_print(



More information about the commits mailing list