List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:May 24 2011 9:21am
Subject:bzr commit into mysql-trunk-mtr branch (bjorn.munch:3079)
View as plain text  
#At file:///home/bm136801/my/mtr-tr/ based on revid:bjorn.munch@stripped

 3079 Bjorn Munch	2011-05-24 [merge]
      merge from trunk

    added:
      mysql-test/suite/innodb/r/innodb-bug12552164.result
      mysql-test/suite/innodb/t/innodb-bug12552164.test
    modified:
      include/my_sys.h
      mysql-test/collections/default.experimental
      mysql-test/suite/binlog/t/disabled.def
      mysql-test/suite/federated/disabled.def
      mysql-test/suite/parts/inc/partition_fail_t2.inc
      mysql-test/suite/parts/r/partition_debug.result
      mysql-test/suite/parts/r/partition_debug_innodb.result
      mysql-test/suite/rpl/t/disabled.def
      mysql-test/suite/sys_vars/t/disabled.def
      mysql-test/t/disabled.def
      sql/derror.cc
      sql/events.cc
      sql/field.cc
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_partition.cc
      sql/handler.cc
      sql/item_create.cc
      sql/item_func.cc
      sql/item_strfunc.cc
      sql/log.h
      sql/log_event.cc
      sql/rpl_rli.cc
      sql/rpl_slave.cc
      sql/set_var.cc
      sql/sp_head.cc
      sql/sql_acl.cc
      sql/sql_base.cc
      sql/sql_binlog.cc
      sql/sql_class.cc
      sql/sql_connect.cc
      sql/sql_insert.cc
      sql/sql_parse.cc
      sql/sql_partition.cc
      sql/sql_partition_admin.cc
      sql/sql_plugin.cc
      sql/sql_prepare.cc
      sql/sql_reload.cc
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sql_yacc.yy
      sql/sys_vars.cc
      sql/table.cc
      sql/unireg.cc
      storage/example/ha_example.cc
      storage/innobase/buf/buf0buf.c
      storage/innobase/buf/buf0flu.c
      storage/innobase/dict/dict0crea.c
      storage/innobase/fil/fil0fil.c
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/i_s.cc
      storage/innobase/include/buf0buf.h
      storage/innobase/include/os0file.h
      storage/innobase/include/os0file.ic
      storage/innobase/include/page0page.h
      storage/innobase/include/page0page.ic
      storage/innobase/include/trx0purge.h
      storage/innobase/include/trx0rec.h
      storage/innobase/include/trx0trx.h
      storage/innobase/include/trx0types.h
      storage/innobase/include/ut0ut.h
      storage/innobase/log/log0recv.c
      storage/innobase/os/os0file.c
      storage/innobase/page/page0page.c
      storage/innobase/row/row0merge.c
      storage/innobase/row/row0mysql.c
      storage/innobase/row/row0vers.c
      storage/innobase/srv/srv0start.c
      storage/innobase/trx/trx0purge.c
      storage/innobase/trx/trx0rec.c
      storage/innobase/ut/ut0ut.c
      strings/ctype-uca.c
=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2011-05-04 09:54:04 +0000
+++ b/include/my_sys.h	2011-05-21 09:30:35 +0000
@@ -483,7 +483,8 @@ typedef struct st_io_cache		/* Used when
 
 typedef int (*qsort2_cmp)(const void *, const void *, const void *);
 
-typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...);
+typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
+  ATTRIBUTE_FORMAT_FPTR(printf, 2, 3);
 
 extern my_error_reporter my_charset_error_reporter;
 

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2011-05-16 18:46:22 +0000
+++ b/mysql-test/collections/default.experimental	2011-05-23 11:58:13 +0000
@@ -6,31 +6,30 @@ binlog.binlog_bug23533
 
 funcs_1.charset_collation_1              # depends on compile-time decisions
 
-main.func_math @freebsd                  # Bug#43020 2010-05-04 alik main.func_math fails on FreeBSD in PB2
-main.gis-rtree @freebsd                  # Bug#38965 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server
-main.lock_multi_bug38499                 # Bug#47448 2009-09-19 alik main.lock_multi_bug38499 times out sporadically
-main.mysqlslap @windows                  # Bug#54024 2010-08-10 alik mysqlslap fails sporadically starting from Dahlia
-main.outfile_loaddata @solaris           # Bug#46895 2010-01-20 alik Test "outfile_loaddata" fails (reproducible)
-main.signal_demo3 @solaris               # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
-main.sp @solaris                         # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
-main.subquery_sj_none @solaris           # Bug#47791 2011-01-28 anitha Several test cases fail on Solaris with error Thread stack overrun
-main.type_float @freebsd                 # Bug#38965 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server
-main.wait_timeout @solaris               # Bug#51244 2010-04-26 alik wait_timeout fails on OpenSolaris
+main.func_math @freebsd                  # Bug#11751977 2010-05-04 alik main.func_math fails on FreeBSD in PB2
+main.gis-rtree @freebsd                  # Bug#11749418 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server
+main.lock_multi_bug38499                 # Bug#11755645 2009-09-19 alik main.lock_multi_bug38499 times out sporadically
+main.mysqlslap @windows                  # Bug#11761520 2010-08-10 alik mysqlslap fails sporadically starting from Dahlia
+main.outfile_loaddata @solaris           # Bug#11755168 2010-01-20 alik Test "outfile_loaddata" fails (reproducible)
+main.signal_demo3 @solaris               # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
+main.sp @solaris                         # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
+main.type_float @freebsd                 # Bug#11749418 2010-05-04 alik test cases gis-rtree, type_float, type_newdecimal fail in embedded server
+main.wait_timeout @solaris               # Bug#11758972 2010-04-26 alik wait_timeout fails on OpenSolaris
 
 rpl.rpl_checksum                         # BUG#12370830 2011-04-18 sven rpl_checksum failed on pb2 (server crash)
 rpl.rpl_cross_version                    # BUG#12416611 2011-05-02 sven fails sporadically on pb2, valgrind errors
 rpl.rpl_delayed_slave                    # BUG#57514 rpl_delayed_slave fails sporadically in pb
+rpl.rpl_innodb_bug28430                  # Bug#11754425
 rpl.rpl_heartbeat_basic                  # BUG#12403008 2011-04-27 sven fails sporadically
-rpl.rpl_innodb_bug28430                  # Bug#46029
 rpl.rpl_row_ignorable_event              # BUG#12416768 2011-05-02 sven fails sporadically on pb2, result mistmatch in output from mysqlbinlog
-rpl.rpl_row_sp011  @solaris              # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
-rpl.rpl_seconds_behind_master            # BUG#58053 2010-11-24 luis fails sporadically on pb2
+rpl.rpl_row_sp011  @solaris              # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
+rpl.rpl_seconds_behind_master            # BUG#11765124 2010-11-24 luis fails sporadically on pb2
 rpl.rpl_show_slave_hosts                 # BUG#12416700 2011-05-02 sven fails sporadically
 rpl.rpl_show_slave_running               # BUG#12346048 2011-04-11 sven fails sporadically on pb2
 
-sys_vars.max_sp_recursion_depth_func @solaris # Bug#47791 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
-sys_vars.plugin_dir_basic                     # Bug#52223 2010-11-24 alik Test "plugin_dir_basic" does not support RPM build (test) directory structure
-sys_vars.wait_timeout_func                    # Bug#41255 2010-04-26 alik wait_timeout_func fails
+sys_vars.max_sp_recursion_depth_func @solaris # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
+sys_vars.plugin_dir_basic                     # Bug#11759877 2010-11-24 alik Test "plugin_dir_basic" does not support RPM build (test) directory structure
+sys_vars.wait_timeout_func                    # Bug#11750645 2010-04-26 alik wait_timeout_func fails
 
 # BUG #59055 : All ndb tests should be removed from the repository
 # Leaving the sys_vars tests for now. sys_vars.all_vars.test fails on removing ndb tests
@@ -40,7 +39,6 @@ sys_vars.ndb_log_updated_only_basic
 sys_vars.rpl_init_slave_func		 # Bug#12535301 2011-05-09 andrei sys_vars.rpl_init_slave_func mismatches in daily-5.5
 
 rpl_bhs.*                                # skozlov : WL#5139 - rpl_bhs suite generated "on-the-fly" at testing moment from rpl suite
-main.gis-rtree                           # svoj: due to BUG#38965
-main.type_float                          # svoj: due to BUG#38965
-main.type_newdecimal                     # svoj: due to BUG#38965
-
+main.gis-rtree                           # svoj: due to BUG#11749418
+main.type_float                          # svoj: due to BUG#11749418
+main.type_newdecimal                     # svoj: due to BUG#11749418

=== modified file 'mysql-test/suite/binlog/t/disabled.def'
--- a/mysql-test/suite/binlog/t/disabled.def	2011-03-24 14:41:41 +0000
+++ b/mysql-test/suite/binlog/t/disabled.def	2011-05-23 11:58:13 +0000
@@ -9,5 +9,5 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-binlog_truncate_innodb	: BUG#57291 2010-10-20 anitha Originally disabled due to BUG#42643. Product bug fixed, but test changes needed
-binlog_spurious_ddl_errors  : BUG#54195 2010-06-03 alik binlog_spurious_ddl_errors.test fails, thus disabled
+binlog_truncate_innodb	: BUG#11764459 2010-10-20 anitha Originally disabled due to BUG#42643. Product bug fixed, but test changes needed
+binlog_spurious_ddl_errors  : BUG#11761680 2010-06-03 alik binlog_spurious_ddl_errors.test fails, thus disabled

=== modified file 'mysql-test/suite/federated/disabled.def'
--- a/mysql-test/suite/federated/disabled.def	2007-12-12 17:19:24 +0000
+++ b/mysql-test/suite/federated/disabled.def	2011-05-23 11:33:41 +0000
@@ -9,4 +9,4 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-federated_transactions : Bug#29523 Transactions do not work
+federated_transactions : Bug#11746899 Transactions do not work

=== added file 'mysql-test/suite/innodb/r/innodb-bug12552164.result'
--- a/mysql-test/suite/innodb/r/innodb-bug12552164.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb-bug12552164.result	2011-05-19 09:19:12 +0000
@@ -0,0 +1,57 @@
+CREATE TABLE worklog5743 (col_1_CHAR CHAR(255) , col_2_CHAR CHAR(255) ,
+PRIMARY KEY (col_1_CHAR)) engine = innodb;
+INSERT INTO worklog5743 VALUES(repeat("a", 200) , repeat("o", 200));
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR  = repeat("o", 200) FROM
+worklog5743;
+col_1_CHAR = repeat("a", 200)	col_2_CHAR  = repeat("o", 200)
+1	1
+"In connection 1"
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+col_1_CHAR = repeat("a", 200)	col_2_CHAR = repeat("o", 200)
+1	1
+SELECT COUNT(*) FROM worklog5743;
+COUNT(*)
+1
+"In connection 2"
+START TRANSACTION;
+INSERT INTO worklog5743 VALUES(repeat("b", 200) , repeat("o", 200));
+UPDATE worklog5743 SET col_1_CHAR = repeat("d", 200) WHERE col_1_CHAR =
+repeat("a", 200) AND col_2_CHAR = repeat("o", 200);
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR  = repeat("o", 200) FROM
+worklog5743;
+col_1_CHAR = repeat("a", 200)	col_2_CHAR  = repeat("o", 200)
+0	1
+0	1
+"In connection 1"
+SELECT col_1_CHAR = repeat("b", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+col_1_CHAR = repeat("b", 200)	col_2_CHAR = repeat("o", 200)
+0	1
+START TRANSACTION;
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+col_1_CHAR = repeat("a", 200)	col_2_CHAR = repeat("o", 200)
+1	1
+SELECT COUNT(*) FROM worklog5743;
+COUNT(*)
+1
+"In connection 2"
+COMMIT;
+SELECT sleep(5);
+sleep(5)
+0
+"In connection 1"
+SELECT col_1_CHAR = repeat("b", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+col_1_CHAR = repeat("b", 200)	col_2_CHAR = repeat("o", 200)
+0	1
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+col_1_CHAR = repeat("a", 200)	col_2_CHAR = repeat("o", 200)
+1	1
+SELECT COUNT(*) FROM worklog5743;
+COUNT(*)
+1
+COMMIT;
+DROP TABLE worklog5743;

=== added file 'mysql-test/suite/innodb/t/innodb-bug12552164.test'
--- a/mysql-test/suite/innodb/t/innodb-bug12552164.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb-bug12552164.test	2011-05-19 09:19:12 +0000
@@ -0,0 +1,50 @@
+CREATE TABLE worklog5743 (col_1_CHAR CHAR(255) , col_2_CHAR CHAR(255) ,
+PRIMARY KEY (col_1_CHAR)) engine = innodb;
+INSERT INTO worklog5743 VALUES(repeat("a", 200) , repeat("o", 200));
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR  = repeat("o", 200) FROM
+worklog5743;
+
+--echo "In connection 1"
+--connect (con1,localhost,root,,)
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+SELECT COUNT(*) FROM worklog5743;
+
+
+--echo "In connection 2"
+--connect (con2,localhost,root,,)
+START TRANSACTION;
+INSERT INTO worklog5743 VALUES(repeat("b", 200) , repeat("o", 200));
+UPDATE worklog5743 SET col_1_CHAR = repeat("d", 200) WHERE col_1_CHAR =
+repeat("a", 200) AND col_2_CHAR = repeat("o", 200);
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR  = repeat("o", 200) FROM
+worklog5743;
+
+
+--echo "In connection 1"
+--connection con1
+SELECT col_1_CHAR = repeat("b", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+
+START TRANSACTION;
+
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+SELECT COUNT(*) FROM worklog5743;
+
+--echo "In connection 2"
+--connection con2
+COMMIT;
+SELECT sleep(5);
+
+--echo "In connection 1"
+--connection con1
+SELECT col_1_CHAR = repeat("b", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+SELECT col_1_CHAR = repeat("a", 200) , col_2_CHAR = repeat("o", 200) FROM
+worklog5743;
+SELECT COUNT(*) FROM worklog5743;
+COMMIT;
+
+--connection default
+DROP TABLE worklog5743; 

=== modified file 'mysql-test/suite/parts/inc/partition_fail_t2.inc'
--- a/mysql-test/suite/parts/inc/partition_fail_t2.inc	2010-06-21 14:45:59 +0000
+++ b/mysql-test/suite/parts/inc/partition_fail_t2.inc	2011-05-21 08:25:33 +0000
@@ -15,7 +15,7 @@ SHOW CREATE TABLE t1;
 SELECT * FROM t1;
 # accept all errors
 --disable_abort_on_error
---replace_regex /#sqlx-[0-9a-f_]*/#sqlx-nnnn_nnnn/i /errno: [0-9-]*/errno: n/
+--replace_regex /#sqlx-[0-9a-f_]*/#sqlx-nnnn_nnnn/i
 --eval $fail_statement
 --enable_abort_on_error
 --echo # State after failure

=== modified file 'mysql-test/suite/parts/r/partition_debug.result'
--- a/mysql-test/suite/parts/r/partition_debug.result	2010-05-19 20:10:44 +0000
+++ b/mysql-test/suite/parts/r/partition_debug.result	2011-05-21 08:25:33 +0000
@@ -1268,7 +1268,7 @@ a	b
 3	Original from partition p0
 4	Original from partition p0
 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
-ERROR HY000: Error on rename of './test/t2' to './test/#sqlx-nnnn_nnnn' (errno: n)
+ERROR HY000: Error on rename of './test/t2' to './test/#sqlx-nnnn_nnnn' (errno: 0)
 # State after failure
 t1#P#p0.MYD
 t1#P#p0.MYI
@@ -1472,7 +1472,7 @@ a	b
 3	Original from partition p0
 4	Original from partition p0
 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
-ERROR HY000: Error on rename of './test/t1#P#p0' to './test/t2' (errno: n)
+ERROR HY000: Error on rename of './test/t1#P#p0' to './test/t2' (errno: 0)
 # State after failure
 t1#P#p0.MYD
 t1#P#p0.MYI
@@ -1676,7 +1676,7 @@ a	b
 3	Original from partition p0
 4	Original from partition p0
 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
-ERROR HY000: Error on rename of './test/#sqlx-nnnn_nnnn' to './test/t1#P#p0' (errno: n)
+ERROR HY000: Error on rename of './test/#sqlx-nnnn_nnnn' to './test/t1#P#p0' (errno: 0)
 # State after failure
 t1#P#p0.MYD
 t1#P#p0.MYI

=== modified file 'mysql-test/suite/parts/r/partition_debug_innodb.result'
--- a/mysql-test/suite/parts/r/partition_debug_innodb.result	2010-10-01 16:11:50 +0000
+++ b/mysql-test/suite/parts/r/partition_debug_innodb.result	2011-05-21 08:25:33 +0000
@@ -7000,7 +7000,7 @@ a	b
 3	Original from partition p0
 4	Original from partition p0
 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
-ERROR HY000: Error on rename of './test/t2' to './test/#sqlx-nnnn_nnnn' (errno: n)
+ERROR HY000: Error on rename of './test/t2' to './test/#sqlx-nnnn_nnnn' (errno: 0)
 # State after failure
 t1#P#p0.ibd
 t1#P#p1.ibd
@@ -7196,7 +7196,7 @@ a	b
 3	Original from partition p0
 4	Original from partition p0
 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
-ERROR HY000: Error on rename of './test/t1#P#p0' to './test/t2' (errno: n)
+ERROR HY000: Error on rename of './test/t1#P#p0' to './test/t2' (errno: 0)
 # State after failure
 t1#P#p0.ibd
 t1#P#p1.ibd
@@ -7392,7 +7392,7 @@ a	b
 3	Original from partition p0
 4	Original from partition p0
 ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
-ERROR HY000: Error on rename of './test/#sqlx-nnnn_nnnn' to './test/t1#P#p0' (errno: n)
+ERROR HY000: Error on rename of './test/#sqlx-nnnn_nnnn' to './test/t1#P#p0' (errno: 0)
 # State after failure
 t1#P#p0.ibd
 t1#P#p1.ibd

=== modified file 'mysql-test/suite/rpl/t/disabled.def'
--- a/mysql-test/suite/rpl/t/disabled.def	2011-02-15 12:12:30 +0000
+++ b/mysql-test/suite/rpl/t/disabled.def	2011-05-23 11:58:13 +0000
@@ -10,8 +10,8 @@
 #
 ##############################################################################
 
-rpl_row_create_table      : Bug#51574 2010-02-27 andrei failed different way than earlier with bug#45576
-rpl_spec_variables        : BUG#47661 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux
-rpl_delayed_slave         : Bug#57514 2010-11-09 andrei rpl_delayed_slave fails sporadically in pb
-rpl_row_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
-rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
+rpl_row_create_table      : Bug#11759274 2010-02-27 andrei failed different way than earlier with bug#45576
+rpl_spec_variables        : BUG#11755836 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux
+rpl_delayed_slave         : Bug#11764654 2010-11-09 andrei rpl_delayed_slave fails sporadically in pb
+rpl_row_until             : BUG#12359942 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
+rpl_stm_until             : BUG#12359942 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out

=== modified file 'mysql-test/suite/sys_vars/t/disabled.def'
--- a/mysql-test/suite/sys_vars/t/disabled.def	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/t/disabled.def	2011-05-23 11:33:41 +0000
@@ -9,9 +9,9 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-query_cache_size_basic_32           : Bug#36747: Allocating a large query cache is not deterministic
-query_cache_size_basic_64           : Bug#36747: Allocating a large query cache is not deterministic
-transaction_prealloc_size_basic_32  : Bug#36747
-transaction_prealloc_size_basic_64  : Bug#36747
-#thread_cache_size_func             : Bug#40575: 2008-11-07 joro main.thread_cache_size_func fails in pushbuild when run with pool of threads
+query_cache_size_basic_32           : Bug#11748572: Allocating a large query cache is not deterministic
+query_cache_size_basic_64           : Bug#11748572: Allocating a large query cache is not deterministic
+transaction_prealloc_size_basic_32  : Bug#11748572
+transaction_prealloc_size_basic_64  : Bug#11748572
+#thread_cache_size_func             : Bug#11750172: 2008-11-07 joro main.thread_cache_size_func fails in pushbuild when run with pool of threads
 

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2011-03-11 09:58:45 +0000
+++ b/mysql-test/t/disabled.def	2011-05-23 11:58:13 +0000
@@ -9,11 +9,11 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-lowercase_table3         : Bug#54845 2010-06-30 alik main.lowercase_table3 on Mac OSX
+lowercase_table3         : Bug#11762269 2010-06-30 alik main.lowercase_table3 on Mac OSX
 query_cache_28249        : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
-log_tables-big           : Bug#48646 2010-11-15 mattiasj report already exists
-read_many_rows_innodb    : Bug#37635 2010-11-15 mattiasj report already exists
-sum_distinct-big         : Bug#56927 2010-11-15 mattiasj was not tested
-alter_table-big          : Bug#37248 2010-11-15 mattiasj was not tested
-create-big               : Bug#37248 2010-11-15 mattiasj was not tested
+log_tables-big           : Bug#11756699 2010-11-15 mattiasj report already exists
+read_many_rows_innodb    : Bug#11748886 2010-11-15 mattiasj report already exists
+sum_distinct-big         : Bug#11764126 2010-11-15 mattiasj was not tested
+alter_table-big          : Bug#11748731 2010-11-15 mattiasj was not tested
+create-big               : Bug#11748731 2010-11-15 mattiasj was not tested
 archive-big              : Bug#11817185 2011-03-10 Anitha Disabled since this leads to timeout on Solaris Sparc

=== modified file 'sql/derror.cc'
--- a/sql/derror.cc	2010-09-08 07:09:13 +0000
+++ b/sql/derror.cc	2011-05-21 08:25:33 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, 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
@@ -108,7 +108,6 @@ bool read_texts(const char *file_name, c
   char lang_path[FN_REFLEN];
   uchar *buff;
   uchar head[32],*pos;
-  const char *errmsg;
   DBUG_ENTER("read_texts");
 
   LINT_INIT(buff);
@@ -185,18 +184,9 @@ Check that the above file is the right v
   DBUG_RETURN(0);
 
 err:
-  switch (funktpos) {
-  case 2:
-    errmsg= "Not enough memory for messagefile '%s'";
-    break;
-  case 1:
-    errmsg= "Can't read from messagefile '%s'";
-    break;
-  default:
-    errmsg= "Can't find messagefile '%s'";
-    break;
-  }
-  sql_print_error(errmsg, name);
+  sql_print_error((funktpos == 2) ? "Not enough memory for messagefile '%s'" :
+                  ((funktpos == 1) ? "Can't read from messagefile '%s'" :
+                   "Can't find messagefile '%s'"), name);
   if (file != FERR)
     (void) mysql_file_close(file, MYF(MY_WME));
   DBUG_RETURN(1);

=== modified file 'sql/events.cc'
--- a/sql/events.cc	2011-04-19 03:29:06 +0000
+++ b/sql/events.cc	2011-05-21 08:25:33 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2004, 2011, 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
@@ -445,7 +445,7 @@ Events::update_event(THD *thd, Event_par
          !sortcmp_lex_string(parse_data->name, *new_name,
                              system_charset_info))
     {
-      my_error(ER_EVENT_SAME_NAME, MYF(0), parse_data->name.str);
+      my_error(ER_EVENT_SAME_NAME, MYF(0));
       DBUG_RETURN(TRUE);
     }
 

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2011-05-12 12:50:11 +0000
+++ b/sql/field.cc	2011-05-21 08:25:33 +0000
@@ -9296,7 +9296,7 @@ bool Create_field::init(THD *thd, char *
   if (decimals >= NOT_FIXED_DEC)
   {
     my_error(ER_TOO_BIG_SCALE, MYF(0), decimals, fld_name,
-             NOT_FIXED_DEC-1);
+             static_cast<ulong>(NOT_FIXED_DEC - 1));
     DBUG_RETURN(TRUE);
   }
 
@@ -9366,8 +9366,8 @@ bool Create_field::init(THD *thd, char *
     my_decimal_trim(&length, &decimals);
     if (length > DECIMAL_MAX_PRECISION)
     {
-      my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name,
-               DECIMAL_MAX_PRECISION);
+      my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<int>(length),
+               fld_name, static_cast<ulong>(DECIMAL_MAX_PRECISION));
       DBUG_RETURN(TRUE);
     }
     if (length < decimals)
@@ -9591,7 +9591,7 @@ bool Create_field::init(THD *thd, char *
       if (length > MAX_BIT_FIELD_LENGTH)
       {
         my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), fld_name,
-                 MAX_BIT_FIELD_LENGTH);
+                 static_cast<ulong>(MAX_BIT_FIELD_LENGTH));
         DBUG_RETURN(TRUE);
       }
       pack_length= (length + 7) / 8;

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-05-18 10:43:46 +0000
+++ b/sql/ha_ndbcluster.cc	2011-05-21 09:30:35 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, 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
@@ -8699,7 +8699,7 @@ NDB_SHARE *ndbcluster_get_share(const ch
       DBUG_PRINT("error", ("get_share: failed to alloc share"));
       if (!have_lock)
         mysql_mutex_unlock(&ndbcluster_mutex);
-      my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*share));
+      my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(*share)));
       DBUG_RETURN(0);
     }
   }

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-01-05 05:21:07 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-05-21 08:25:33 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, 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
@@ -1224,12 +1224,14 @@ ndbcluster_update_slock(THD *thd,
   }
 
   if (ndb_error)
+  {
+    char buf[1024];
+    my_snprintf(buf, sizeof(buf), "Could not release lock on '%s.%s'",
+                db, table_name);
     push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                         ER_GET_ERRMSG, ER(ER_GET_ERRMSG),
-                        ndb_error->code,
-                        ndb_error->message,
-                        "Could not release lock on '%s.%s'",
-                        db, table_name);
+                        ndb_error->code, ndb_error->message, buf);
+  }
   if (trans)
     ndb->closeTransaction(trans);
   ndb->setDatabaseName(save_db);

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2011-05-16 11:32:07 +0000
+++ b/sql/ha_partition.cc	2011-05-21 08:25:33 +0000
@@ -1136,6 +1136,10 @@ static int handle_opt_part(THD *thd, HA_
 static bool print_admin_msg(THD* thd, const char* msg_type,
                             const char* db_name, const char* table_name,
                             const char* op_name, const char *fmt, ...)
+  ATTRIBUTE_FORMAT(printf, 6, 7);
+static bool print_admin_msg(THD* thd, const char* msg_type,
+                            const char* db_name, const char* table_name,
+                            const char* op_name, const char *fmt, ...)
 {
   va_list args;
   Protocol *protocol= thd->protocol;

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-05-18 10:43:46 +0000
+++ b/sql/handler.cc	2011-05-21 09:30:35 +0000
@@ -287,7 +287,7 @@ handler *get_ha_partition(partition_info
   }
   else
   {
-    my_error(ER_OUTOFMEMORY, MYF(0), sizeof(ha_partition));
+    my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(ha_partition)));
   }
   DBUG_RETURN(((handler*) partition));
 }
@@ -1645,7 +1645,8 @@ int ha_recover(HASH *commit_list)
   }
   if (!info.list)
   {
-    sql_print_error(ER(ER_OUTOFMEMORY), info.len*sizeof(XID));
+    sql_print_error(ER(ER_OUTOFMEMORY),
+                    static_cast<int>(info.len*sizeof(XID)));
     DBUG_RETURN(1);
   }
 

=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc	2011-05-03 13:03:00 +0000
+++ b/sql/item_create.cc	2011-05-21 08:25:33 +0000
@@ -5733,8 +5733,8 @@ create_func_cast(THD *thd, Item *a, Cast
       decoded_size= strtoul(c_len, NULL, 10);
       if (errno != 0)
       {
-        my_error(ER_TOO_BIG_PRECISION, MYF(0), c_len, a->name,
-                 DECIMAL_MAX_PRECISION);
+        my_error(ER_TOO_BIG_PRECISION, MYF(0), INT_MAX, a->name,
+                 static_cast<ulong>(DECIMAL_MAX_PRECISION));
         return NULL;
       }
       len= decoded_size;
@@ -5747,8 +5747,8 @@ create_func_cast(THD *thd, Item *a, Cast
       decoded_size= strtoul(c_dec, NULL, 10);
       if ((errno != 0) || (decoded_size > UINT_MAX))
       {
-        my_error(ER_TOO_BIG_SCALE, MYF(0), c_dec, a->name,
-                 DECIMAL_MAX_SCALE);
+        my_error(ER_TOO_BIG_SCALE, MYF(0), INT_MAX, a->name,
+                 static_cast<ulong>(DECIMAL_MAX_SCALE));
         return NULL;
       }
       dec= decoded_size;
@@ -5761,14 +5761,14 @@ create_func_cast(THD *thd, Item *a, Cast
     }
     if (len > DECIMAL_MAX_PRECISION)
     {
-      my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
-               DECIMAL_MAX_PRECISION);
+      my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<int>(len), a->name,
+               static_cast<ulong>(DECIMAL_MAX_PRECISION));
       return 0;
     }
     if (dec > DECIMAL_MAX_SCALE)
     {
       my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
-               DECIMAL_MAX_SCALE);
+               static_cast<ulong>(DECIMAL_MAX_SCALE));
       return 0;
     }
     res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-05-12 18:44:56 +0000
+++ b/sql/item_func.cc	2011-05-21 09:31:19 +0000
@@ -1109,7 +1109,7 @@ err:
   push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                       ER_WARN_DATA_OUT_OF_RANGE,
                       ER(ER_WARN_DATA_OUT_OF_RANGE),
-                      name, 1);
+                      name, 1L);
   return dec;
 }
 
@@ -3167,7 +3167,7 @@ udf_handler::fix_fields(THD *thd, Item_r
 
   if (!tmp_udf)
   {
-    my_error(ER_CANT_FIND_UDF, MYF(0), u_d->name.str, errno);
+    my_error(ER_CANT_FIND_UDF, MYF(0), u_d->name.str);
     DBUG_RETURN(TRUE);
   }
   u_d=tmp_udf;

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2011-05-06 13:32:53 +0000
+++ b/sql/item_strfunc.cc	2011-05-21 08:25:33 +0000
@@ -3814,7 +3814,8 @@ String *Item_func_uncompress::val_str(St
     push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_WARN,
 			ER_TOO_BIG_FOR_UNCOMPRESS,
 			ER(ER_TOO_BIG_FOR_UNCOMPRESS),
-                        current_thd->variables.max_allowed_packet);
+                        static_cast<int>(current_thd->variables.
+                                         max_allowed_packet));
     goto err;
   }
   if (buffer.realloc((uint32)new_size))

=== modified file 'sql/log.h'
--- a/sql/log.h	2011-05-04 09:54:04 +0000
+++ b/sql/log.h	2011-05-21 09:31:19 +0000
@@ -473,7 +473,7 @@ void sql_print_warning(const char *forma
 void sql_print_information(const char *format, ...)
   ATTRIBUTE_FORMAT(printf, 1, 2);
 typedef void (*sql_print_message_func)(const char *format, ...)
-  ATTRIBUTE_FORMAT(printf, 1, 2);
+  ATTRIBUTE_FORMAT_FPTR(printf, 1, 2);
 extern sql_print_message_func sql_print_message_handlers[];
 
 int error_log_print(enum loglevel level, const char *format,

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2011-05-16 11:10:48 +0000
+++ b/sql/log_event.cc	2011-05-23 23:34:47 +0000
@@ -8797,6 +8797,7 @@ int Table_map_log_event::do_apply_event(
                 m_field_metadata, m_field_metadata_size,
                 m_null_bits, m_flags);
     table_list->m_tabledef_valid= TRUE;
+    table_list->m_conv_table= NULL;
     table_list->open_type= OT_BASE_ONLY;
 
     /*

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2011-05-19 08:48:55 +0000
+++ b/sql/rpl_rli.cc	2011-05-23 23:34:47 +0000
@@ -984,6 +984,16 @@ void Relay_log_info::clear_tables_to_loc
       tables_to_lock->m_tabledef.table_def::~table_def();
       tables_to_lock->m_tabledef_valid= FALSE;
     }
+
+    /*
+      If blob fields were used during conversion of field values 
+      from the master table into the slave table, then we need to 
+      free the memory used temporarily to store their values before
+      copying into the slave's table.
+    */
+    if (tables_to_lock->m_conv_table)
+      free_blobs(tables_to_lock->m_conv_table);
+
     tables_to_lock=
       static_cast<RPL_TABLE_LIST*>(tables_to_lock->next_global);
     tables_to_lock_count--;

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-05-16 14:30:54 +0000
+++ b/sql/rpl_slave.cc	2011-05-21 08:25:33 +0000
@@ -5864,7 +5864,7 @@ bool change_master(THD* thd, Master_info
     get_dynamic(&lex_mi->repl_ignore_server_ids, (uchar*) &s_id, i);
     if (s_id == ::server_id && replicate_same_server_id)
     {
-      my_error(ER_SLAVE_IGNORE_SERVER_IDS, MYF(0), s_id);
+      my_error(ER_SLAVE_IGNORE_SERVER_IDS, MYF(0), static_cast<int>(s_id));
       ret= TRUE;
       goto err;
     }

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2011-03-25 14:35:13 +0000
+++ b/sql/set_var.cc	2011-05-21 08:25:33 +0000
@@ -113,7 +113,8 @@ void sys_var_end()
   sys_var constructor
 
   @param chain     variables are linked into chain for mysql_add_sys_var_chain()
-  @param name_arg  the name of the variable. @sa my_option::name
+  @param name_arg  the name of the variable. Must be 0-terminated and exist
+                   for the liftime of the sys_var object. @sa my_option::name
   @param comment   shown in mysqld --help, @sa my_option::comment
   @param flags_arg or'ed flag_enum values
   @param off       offset of the global variable value from the
@@ -158,8 +159,8 @@ sys_var::sys_var(sys_var_chain *chain, c
   */
   DBUG_ASSERT(parse_flag == PARSE_NORMAL || getopt_id <= 0 || getopt_id >= 255);
 
-  name.str= name_arg;
-  name.length= strlen(name_arg);
+  name.str= name_arg;     // ER_NO_DEFAULT relies on 0-termination of name_arg
+  name.length= strlen(name_arg);                // and so does this.
   DBUG_ASSERT(name.length <= NAME_CHAR_LEN);
 
   bzero(&option, sizeof(option));

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2011-05-12 18:42:28 +0000
+++ b/sql/sp_head.cc	2011-05-21 09:31:19 +0000
@@ -1063,7 +1063,7 @@ void sp_head::recursion_level_error(THD
   if (m_type == TYPE_ENUM_PROCEDURE)
   {
     my_error(ER_SP_RECURSION_LIMIT, MYF(0),
-             thd->variables.max_sp_recursion_depth,
+             static_cast<int>(thd->variables.max_sp_recursion_depth),
              m_name.str);
   }
   else

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2011-05-16 08:52:10 +0000
+++ b/sql/sql_acl.cc	2011-05-21 08:25:33 +0000
@@ -2275,13 +2275,12 @@ static int replace_user_table(THD *thd,
     */
     else if (!password_len && !combo.plugin.length && no_auto_create)
     {
-      my_error(ER_PASSWORD_NO_MATCH, MYF(0), combo.user.str, combo.host.str);
+      my_error(ER_PASSWORD_NO_MATCH, MYF(0));
       goto end;
     }
     else if (!can_create_user)
     {
-      my_error(ER_CANT_CREATE_USER_WITH_GRANT, MYF(0),
-               thd->security_ctx->user, thd->security_ctx->host_or_ip);
+      my_error(ER_CANT_CREATE_USER_WITH_GRANT, MYF(0));
       goto end;
     }
     else if (combo.plugin.str[0])
@@ -2309,8 +2308,8 @@ static int replace_user_table(THD *thd,
     /* what == 'N' means revoke */
     if (combo.plugin.length && what != 'N')
     {
-        my_error(ER_GRANT_PLUGIN_USER_EXISTS, MYF(0), combo.user.length, 
-                 combo.user.str);
+        my_error(ER_GRANT_PLUGIN_USER_EXISTS, MYF(0),
+                 static_cast<int>(combo.user.length), combo.user.str);
         goto end;
     }
     if (combo.password.str)                             // If password given
@@ -8982,7 +8981,7 @@ err:
   if (mpvio->status == MPVIO_EXT::FAILURE)
   {
     inc_host_errors(mpvio->ip);
-    my_error(ER_HANDSHAKE_ERROR, MYF(0), mpvio->auth_info.host_or_ip);
+    my_error(ER_HANDSHAKE_ERROR, MYF(0));
   }
   DBUG_RETURN(-1);
 }
@@ -9578,7 +9577,7 @@ static int native_password_authenticate(
   }
 
   inc_host_errors(mpvio->ip);
-  my_error(ER_HANDSHAKE_ERROR, MYF(0), mpvio->auth_info.host_or_ip);
+  my_error(ER_HANDSHAKE_ERROR, MYF(0));
   DBUG_RETURN(CR_ERROR);
 }
 
@@ -9632,7 +9631,7 @@ static int old_password_authenticate(MYS
   }
 
   inc_host_errors(mpvio->ip);
-  my_error(ER_HANDSHAKE_ERROR, MYF(0), mpvio->auth_info.host_or_ip);
+  my_error(ER_HANDSHAKE_ERROR, MYF(0));
   return CR_ERROR;
 }
 

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2011-05-10 13:37:37 +0000
+++ b/sql/sql_base.cc	2011-05-21 08:25:33 +0000
@@ -3849,7 +3849,7 @@ static bool auto_repair_table(THD *thd,
   {
     /* Give right error message */
     thd->clear_error();
-    my_error(ER_NOT_KEYFILE, MYF(0), share->table_name.str, my_errno);
+    my_error(ER_NOT_KEYFILE, MYF(0), share->table_name.str);
     sql_print_error("Couldn't repair table: %s.%s", share->db.str,
                     share->table_name.str);
     if (entry->file)
@@ -8179,7 +8179,7 @@ bool setup_tables(THD *thd, Name_resolut
   }
   if (tablenr > MAX_TABLES)
   {
-    my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES);
+    my_error(ER_TOO_MANY_TABLES,MYF(0), static_cast<int>(MAX_TABLES));
     DBUG_RETURN(1);
   }
   for (table_list= tables;

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2011-03-23 23:28:49 +0000
+++ b/sql/sql_binlog.cc	2011-05-21 08:25:33 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005, 2011, 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
@@ -301,7 +301,7 @@ void mysql_client_binlog_statement(THD*
           TODO: Maybe a better error message since the BINLOG statement
           now contains several events.
         */
-        my_error(ER_UNKNOWN_ERROR, MYF(0), "Error executing BINLOG statement");
+        my_error(ER_UNKNOWN_ERROR, MYF(0));
         goto end;
       }
     }

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-05-20 11:08:29 +0000
+++ b/sql/sql_class.cc	2011-05-24 09:21:24 +0000
@@ -2490,7 +2490,7 @@ bool select_export::send_data(List<Item>
                             ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
                             ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
                             "string", printable_buff,
-                            item->name, row_count);
+                            item->name, static_cast<long>(row_count));
       }
       else if (from_end_pos < res->ptr() + res->length())
       { 
@@ -2499,7 +2499,7 @@ bool select_export::send_data(List<Item>
         */
         push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                             WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED),
-                            item->full_name(), row_count);
+                            item->full_name(), static_cast<long>(row_count));
       }
       cvt_str.length(bytes);
       res= &cvt_str;

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2011-05-12 18:44:56 +0000
+++ b/sql/sql_connect.cc	2011-05-21 09:31:19 +0000
@@ -463,7 +463,7 @@ static int check_connection(THD *thd)
 
     if (vio_peer_addr(net->vio, ip, &thd->peer_port, NI_MAXHOST))
     {
-      my_error(ER_BAD_HOST_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);
+      my_error(ER_BAD_HOST_ERROR, MYF(0));
       return 1;
     }
     if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(MY_WME))))
@@ -474,7 +474,7 @@ static int check_connection(THD *thd)
       if (ip_to_hostname(&net->vio->remote, thd->main_security_ctx.ip,
                          &thd->main_security_ctx.host, &connect_errors))
       {
-        my_error(ER_BAD_HOST_ERROR, MYF(0), ip);
+        my_error(ER_BAD_HOST_ERROR, MYF(0));
         return 1;
       }
 

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2011-05-12 17:29:19 +0000
+++ b/sql/sql_insert.cc	2011-05-21 08:25:33 +0000
@@ -3932,7 +3932,7 @@ select_create::prepare(List<Item> &value
 
   if (table->s->fields < values.elements)
   {
-    my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1);
+    my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L);
     DBUG_RETURN(-1);
   }
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-05-12 17:29:19 +0000
+++ b/sql/sql_parse.cc	2011-05-21 08:25:33 +0000
@@ -3576,8 +3576,7 @@ end_with_restore_list:
             hostname_requires_resolving(user->host.str))
           push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                               ER_WARN_HOSTNAME_WONT_WORK,
-                              ER(ER_WARN_HOSTNAME_WONT_WORK),
-                              user->host.str);
+                              ER(ER_WARN_HOSTNAME_WONT_WORK));
         // Are we trying to change a password of another user
         DBUG_ASSERT(user->host.str != 0);
 
@@ -5470,7 +5469,7 @@ mysql_new_select(LEX *lex, bool move_dow
   lex->nest_level++;
   if (lex->nest_level > (int) MAX_SELECT_NESTING)
   {
-    my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT,MYF(0),MAX_SELECT_NESTING);
+    my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT, MYF(0));
     DBUG_RETURN(1);
   }
   select_lex->nest_level= lex->nest_level;

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2011-05-06 13:21:38 +0000
+++ b/sql/sql_partition.cc	2011-05-21 08:25:33 +0000
@@ -7143,7 +7143,7 @@ void set_key_field_ptr(KEY *key_info, co
 
 void mem_alloc_error(size_t size)
 {
-  my_error(ER_OUTOFMEMORY, MYF(0), size);
+  my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(size));
 }
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE

=== modified file 'sql/sql_partition_admin.cc'
--- a/sql/sql_partition_admin.cc	2011-05-04 07:51:15 +0000
+++ b/sql/sql_partition_admin.cc	2011-05-21 08:25:33 +0000
@@ -361,14 +361,14 @@ static bool exchange_name_with_ddl_log(T
   /* call rename table from table to tmp-name */
   DBUG_EXECUTE_IF("exchange_partition_fail_3",
                   my_error(ER_ERROR_ON_RENAME, MYF(0),
-                           name, tmp_name);
+                           name, tmp_name, 0);
                   error_set= TRUE;
                   goto err_rename;);
   DBUG_EXECUTE_IF("exchange_partition_abort_3", abort(););
   if (file->ha_rename_table(name, tmp_name))
   {
     my_error(ER_ERROR_ON_RENAME, MYF(0),
-             name, tmp_name);
+             name, tmp_name, my_errno);
     error_set= TRUE;
     goto err_rename;
   }
@@ -380,14 +380,14 @@ static bool exchange_name_with_ddl_log(T
   /* call rename table from partition to table */
   DBUG_EXECUTE_IF("exchange_partition_fail_5",
                   my_error(ER_ERROR_ON_RENAME, MYF(0),
-                           from_name, name);
+                           from_name, name, 0);
                   error_set= TRUE;
                   goto err_rename;);
   DBUG_EXECUTE_IF("exchange_partition_abort_5", abort(););
   if (file->ha_rename_table(from_name, name))
   {
     my_error(ER_ERROR_ON_RENAME, MYF(0),
-             from_name, name);
+             from_name, name, my_errno);
     error_set= TRUE;
     goto err_rename;
   }
@@ -399,14 +399,14 @@ static bool exchange_name_with_ddl_log(T
   /* call rename table from tmp-nam to partition */
   DBUG_EXECUTE_IF("exchange_partition_fail_7",
                   my_error(ER_ERROR_ON_RENAME, MYF(0),
-                           tmp_name, from_name);
+                           tmp_name, from_name, 0);
                   error_set= TRUE;
                   goto err_rename;);
   DBUG_EXECUTE_IF("exchange_partition_abort_7", abort(););
   if (file->ha_rename_table(tmp_name, from_name))
   {
     my_error(ER_ERROR_ON_RENAME, MYF(0),
-             tmp_name, from_name);
+             tmp_name, from_name, my_errno);
     error_set= TRUE;
     goto err_rename;
   }

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2011-04-19 03:29:06 +0000
+++ b/sql/sql_plugin.cc	2011-05-21 08:25:33 +0000
@@ -548,7 +548,8 @@ static st_plugin_dl *plugin_dl_add(const
     if (!cur)
     {
       free_plugin_mem(&plugin_dl);
-      report_error(report, ER_OUTOFMEMORY, plugin_dl.dl.length);
+      report_error(report, ER_OUTOFMEMORY,
+                   static_cast<int>(plugin_dl.dl.length));
       DBUG_RETURN(0);
     }
     /*
@@ -570,7 +571,8 @@ static st_plugin_dl *plugin_dl_add(const
   if (! (plugin_dl.dl.str= (char*) my_malloc(plugin_dl.dl.length, MYF(0))))
   {
     free_plugin_mem(&plugin_dl);
-    report_error(report, ER_OUTOFMEMORY, plugin_dl.dl.length);
+    report_error(report, ER_OUTOFMEMORY,
+                 static_cast<int>(plugin_dl.dl.length));
     DBUG_RETURN(0);
   }
   plugin_dl.dl.length= copy_and_convert(plugin_dl.dl.str, plugin_dl.dl.length,
@@ -581,7 +583,8 @@ static st_plugin_dl *plugin_dl_add(const
   if (! (tmp= plugin_dl_insert_or_reuse(&plugin_dl)))
   {
     free_plugin_mem(&plugin_dl);
-    report_error(report, ER_OUTOFMEMORY, sizeof(struct st_plugin_dl));
+    report_error(report, ER_OUTOFMEMORY,
+                 static_cast<int>(sizeof(struct st_plugin_dl)));
     DBUG_RETURN(0);
   }
   DBUG_RETURN(tmp);

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2011-05-12 18:42:28 +0000
+++ b/sql/sql_prepare.cc	2011-05-21 09:31:19 +0000
@@ -1462,7 +1462,7 @@ static int mysql_test_select(Prepared_st
 
   if (!lex->result && !(lex->result= new (stmt->mem_root) select_send))
   {
-    my_error(ER_OUTOFMEMORY, MYF(0), sizeof(select_send));
+    my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(select_send)));
     goto error;
   }
 
@@ -2552,7 +2552,7 @@ void mysqld_stmt_execute(THD *thd, char
   if (!(stmt= find_prepared_statement(thd, stmt_id)))
   {
     char llbuf[22];
-    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf),
+    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), static_cast<int>(sizeof(llbuf)),
              llstr(stmt_id, llbuf), "mysqld_stmt_execute");
     DBUG_VOID_RETURN;
   }
@@ -2606,7 +2606,7 @@ void mysql_sql_stmt_execute(THD *thd)
   if (!(stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
   {
     my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0),
-             name->length, name->str, "EXECUTE");
+             static_cast<int>(name->length), name->str, "EXECUTE");
     DBUG_VOID_RETURN;
   }
 
@@ -2648,7 +2648,7 @@ void mysqld_stmt_fetch(THD *thd, char *p
   if (!(stmt= find_prepared_statement(thd, stmt_id)))
   {
     char llbuf[22];
-    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf),
+    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), static_cast<int>(sizeof(llbuf)),
              llstr(stmt_id, llbuf), "mysqld_stmt_fetch");
     DBUG_VOID_RETURN;
   }
@@ -2708,7 +2708,7 @@ void mysqld_stmt_reset(THD *thd, char *p
   if (!(stmt= find_prepared_statement(thd, stmt_id)))
   {
     char llbuf[22];
-    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf),
+    my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), static_cast<int>(sizeof(llbuf)),
              llstr(stmt_id, llbuf), "mysqld_stmt_reset");
     DBUG_VOID_RETURN;
   }
@@ -2783,7 +2783,7 @@ void mysql_sql_stmt_close(THD *thd)
 
   if (! (stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
     my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0),
-             name->length, name->str, "DEALLOCATE PREPARE");
+             static_cast<int>(name->length), name->str, "DEALLOCATE PREPARE");
   else if (stmt->is_in_use())
     my_error(ER_PS_NO_RECURSION, MYF(0));
   else

=== modified file 'sql/sql_reload.cc'
--- a/sql/sql_reload.cc	2011-03-07 09:23:36 +0000
+++ b/sql/sql_reload.cc	2011-05-21 08:25:33 +0000
@@ -87,7 +87,7 @@ bool reload_acl_and_cache(THD *thd, unsi
           When an error is returned, my_message may have not been called and
           the client will hang waiting for a response.
         */
-        my_error(ER_UNKNOWN_ERROR, MYF(0), "FLUSH PRIVILEGES failed");
+        my_error(ER_UNKNOWN_ERROR, MYF(0));
       }
     }
 

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-05-04 07:51:15 +0000
+++ b/sql/sql_show.cc	2011-05-21 09:31:19 +0000
@@ -2408,12 +2408,11 @@ bool schema_table_store_record(THD *thd,
 }
 
 
-int make_table_list(THD *thd, SELECT_LEX *sel,
-                    LEX_STRING *db_name, LEX_STRING *table_name)
+static int make_table_list(THD *thd, SELECT_LEX *sel,
+                           LEX_STRING *db_name, LEX_STRING *table_name)
 {
   Table_ident *table_ident;
   table_ident= new Table_ident(thd, *db_name, *table_name, 1);
-  sel->init_query();
   if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ, MDL_SHARED_READ))
     return 1;
   return 0;
@@ -2983,98 +2982,196 @@ make_table_name_list(THD *thd, List<LEX_
 
 
 /**
-  @brief          Fill I_S table for SHOW COLUMNS|INDEX commands
+  Fill I_S table with data obtained by performing full-blown table open.
 
-  @param[in]      thd                      thread handler
-  @param[in]      tables                   TABLE_LIST for I_S table
-  @param[in]      schema_table             pointer to I_S structure
-  @param[in]      can_deadlock             Indicates that deadlocks are possible
-                                           due to metadata locks, so to avoid
-                                           them we should not wait in case if
-                                           conflicting lock is present.
-  @param[in]      open_tables_state_backup pointer to Open_tables_backup object
-                                           which is used to save|restore original
-                                           status of variables related to
-                                           open tables state
+  @param  thd                       Thread handler.
+  @param  is_show_fields_or_keys    Indicates whether it is a legacy SHOW
+                                    COLUMNS or SHOW KEYS statement.
+  @param  table                     TABLE object for I_S table to be filled.
+  @param  schema_table              I_S table description structure.
+  @param  orig_db_name              Database name.
+  @param  orig_table_name           Table name.
+  @param  open_tables_state_backup  Open_tables_state object which is used
+                                    to save/restore original status of
+                                    variables related to open tables state.
+  @param  can_deadlock              Indicates that deadlocks are possible
+                                    due to metadata locks, so to avoid
+                                    them we should not wait in case if
+                                    conflicting lock is present.
 
-  @return         Operation status
-    @retval       0           success
-    @retval       1           error
+  @retval FALSE - Success.
+  @retval TRUE  - Failure.
 */
-
-static int 
-fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
-                              ST_SCHEMA_TABLE *schema_table,
-                              bool can_deadlock,
-                              Open_tables_backup *open_tables_state_backup)
+static bool
+fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
+                          TABLE *table, ST_SCHEMA_TABLE *schema_table,
+                          LEX_STRING *orig_db_name,
+                          LEX_STRING *orig_table_name,
+                          Open_tables_backup *open_tables_state_backup,
+                          bool can_deadlock)
 {
-  LEX *lex= thd->lex;
-  bool res;
-  LEX_STRING tmp_lex_string, tmp_lex_string1, *db_name, *table_name;
-  enum_sql_command save_sql_command= lex->sql_command;
-  TABLE_LIST *show_table_list= tables->schema_select_lex->table_list.first;
-  TABLE *table= tables->table;
-  int error= 1;
-  DBUG_ENTER("fill_schema_show");
+  Query_arena i_s_arena(thd->mem_root,
+                        Query_arena::STMT_CONVENTIONAL_EXECUTION),
+              backup_arena, *old_arena;
+  LEX *old_lex= thd->lex, temp_lex, *lex;
+  LEX_STRING db_name, table_name;
+  TABLE_LIST *table_list;
+  bool result= true;
+
+  DBUG_ENTER("fill_schema_table_by_open");
+  /*
+    When a view is opened its structures are allocated on a permanent
+    statement arena and linked into the LEX tree for the current statement
+    (this happens even in cases when view is handled through TEMPTABLE
+    algorithm).
+
+    To prevent this process from unnecessary hogging of memory in the permanent
+    arena of our I_S query and to avoid damaging its LEX we use temporary
+    arena and LEX for table/view opening.
+
+    Use temporary arena instead of statement permanent arena. Also make
+    it active arena and save original one for successive restoring.
+  */
+  old_arena= thd->stmt_arena;
+  thd->stmt_arena= &i_s_arena;
+  thd->set_n_backup_active_arena(&i_s_arena, &backup_arena);
+
+  /* Prepare temporary LEX. */
+  thd->lex= lex= &temp_lex;
+  lex_start(thd);
+
+  /* Disable constant subquery evaluation as we won't be locking tables. */
+  lex->context_analysis_only= CONTEXT_ANALYSIS_ONLY_VIEW;
 
-  lex->all_selects_list= tables->schema_select_lex;
   /*
-    Restore thd->temporary_tables to be able to process
-    temporary tables(only for 'show index' & 'show columns').
-    This should be changed when processing of temporary tables for
-    I_S tables will be done.
+    Some of process_table() functions rely on wildcard being passed from
+    old LEX (or at least being initialized).
   */
-  thd->temporary_tables= open_tables_state_backup->temporary_tables;
+  lex->wild= old_lex->wild;
+
+  /*
+    Since make_table_list() might change database and table name passed
+    to it we create copies of orig_db_name and orig_table_name here.
+    These copies are used for make_table_list() while unaltered values
+    are passed to process_table() functions.
+  */
+  if (!thd->make_lex_string(&db_name, orig_db_name->str,
+                            orig_db_name->length, FALSE) ||
+      !thd->make_lex_string(&table_name, orig_table_name->str,
+                            orig_table_name->length, FALSE))
+    goto end;
+
+  /*
+    Create table list element for table to be open. Link it with the
+    temporary LEX. The latter is required to correctly open views and
+    produce table describing their structure.
+  */
+  if (make_table_list(thd, &lex->select_lex, &db_name, &table_name))
+    goto end;
+
+  table_list= lex->select_lex.table_list.first;
+
+  if (is_show_fields_or_keys)
+  {
+    /*
+      Restore thd->temporary_tables to be able to process
+      temporary tables (only for 'show index' & 'show columns').
+      This should be changed when processing of temporary tables for
+      I_S tables will be done.
+    */
+    thd->temporary_tables= open_tables_state_backup->temporary_tables;
+  }
+  else
+  {
+    /*
+      Apply optimization flags for table opening which are relevant for
+      this I_S table. We can't do this for SHOW COLUMNS/KEYS because of
+      backward compatibility.
+    */
+    table_list->i_s_requested_object= schema_table->i_s_requested_object;
+  }
+
   /*
     Let us set fake sql_command so views won't try to merge
     themselves into main statement. If we don't do this,
     SELECT * from information_schema.xxxx will cause problems.
-    SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()' 
+    SQLCOM_SHOW_FIELDS is used because it satisfies
+    'only_view_structure()'.
   */
   lex->sql_command= SQLCOM_SHOW_FIELDS;
 
-  res= open_temporary_tables(thd, show_table_list);
+  result= open_temporary_tables(thd, table_list);
 
-  if (!res)
+  if (!result)
   {
-    res= open_normal_and_derived_tables(thd, show_table_list,
-                                        (MYSQL_OPEN_IGNORE_FLUSH |
-                                         MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL |
-                                         (can_deadlock ?
-                                          MYSQL_OPEN_FAIL_ON_MDL_CONFLICT : 0)));
+    result= open_normal_and_derived_tables(thd, table_list,
+                                           (MYSQL_OPEN_IGNORE_FLUSH |
+                                            MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL |
+                                            (can_deadlock ?
+                                             MYSQL_OPEN_FAIL_ON_MDL_CONFLICT : 0)));
   }
-
-  lex->sql_command= save_sql_command;
+  /*
+    Restore old value of sql_command back as it is being looked at in
+    process_table() function.
+  */
+  lex->sql_command= old_lex->sql_command;
 
   DEBUG_SYNC(thd, "after_open_table_ignore_flush");
 
   /*
-    get_all_tables() returns 1 on failure and 0 on success thus
-    return only these and not the result code of ::process_table()
+    XXX:  show_table_list has a flag i_is_requested,
+    and when it's set, open_normal_and_derived_tables()
+    can return an error without setting an error message
+    in THD, which is a hack. This is why we have to
+    check for res, then for thd->is_error() and only then
+    for thd->main_da.sql_errno().
 
-    We should use show_table_list->alias instead of 
-    show_table_list->table_name because table_name
-    could be changed during opening of I_S tables. It's safe
-    to use alias because alias contains original table name 
-    in this case(this part of code is used only for 
-    'show columns' & 'show statistics' commands).
+    Again we don't do this for SHOW COLUMNS/KEYS because
+    of backward compatibility.
   */
-   table_name= thd->make_lex_string(&tmp_lex_string1, show_table_list->alias,
-                                    strlen(show_table_list->alias), FALSE);
-   if (!show_table_list->view)
-     db_name= thd->make_lex_string(&tmp_lex_string, show_table_list->db,
-                                   show_table_list->db_length, FALSE);
-   else
-     db_name= &show_table_list->view_db;
-      
-
-   error= test(schema_table->process_table(thd, show_table_list,
-                                           table, res, db_name,
-                                           table_name));
-   thd->temporary_tables= 0;
-   close_tables_for_reopen(thd, &show_table_list,
-                           open_tables_state_backup->mdl_system_tables_svp);
-   DBUG_RETURN(error);
+  if (!is_show_fields_or_keys && result && thd->is_error() &&
+      thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE)
+  {
+    /*
+      Hide error for a non-existing table.
+      For example, this error can occur when we use a where condition
+      with a db name and table, but the table does not exist.
+    */
+    result= false;
+    thd->clear_error();
+  }
+  else
+  {
+    result= schema_table->process_table(thd, table_list,
+                                        table, result,
+                                        orig_db_name,
+                                        orig_table_name);
+  }
+
+
+end:
+  lex->unit.cleanup();
+
+  /* Restore original LEX value, statement's arena and THD arena values. */
+  lex_end(thd->lex);
+
+  if (i_s_arena.free_list)
+    i_s_arena.free_items();
+
+  /*
+    For safety reset list of open temporary tables before closing
+    all tables open within this Open_tables_state.
+  */
+  thd->temporary_tables= NULL;
+  close_thread_tables(thd);
+  thd->mdl_context.rollback_to_savepoint(open_tables_state_backup->mdl_system_tables_svp);
+
+  thd->lex= old_lex;
+
+  thd->stmt_arena= old_arena;
+  thd->restore_active_arena(&i_s_arena, &backup_arena);
+
+  DBUG_RETURN(result);
 }
 
 
@@ -3485,10 +3582,8 @@ int get_all_tables(THD *thd, TABLE_LIST
 {
   LEX *lex= thd->lex;
   TABLE *table= tables->table;
-  SELECT_LEX *old_all_select_lex= lex->all_selects_list;
   SELECT_LEX *lsel= tables->schema_select_lex;
   ST_SCHEMA_TABLE *schema_table= tables->schema_table;
-  SELECT_LEX sel;
   LOOKUP_FIELD_VALUES lookup_field_vals;
   LEX_STRING *db_name, *table_name;
   bool with_i_schema;
@@ -3496,11 +3591,8 @@ int get_all_tables(THD *thd, TABLE_LIST
   List<LEX_STRING> db_names;
   List_iterator_fast<LEX_STRING> it(db_names);
   Item *partial_cond= 0;
-  uint derived_tables= lex->derived_tables; 
   int error= 1;
   Open_tables_backup open_tables_state_backup;
-  uint8 save_context_analysis_only= lex->context_analysis_only;
-  Query_tables_list query_tables_list_backup;
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   Security_context *sctx= thd->security_ctx;
 #endif
@@ -3519,15 +3611,6 @@ int get_all_tables(THD *thd, TABLE_LIST
   */
   can_deadlock= thd->mdl_context.has_locks();
 
-  lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
-  lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
-  /*
-    Restore Query_tables_list::sql_command value, which was reset
-    above, as ST_SCHEMA_TABLE::process_table() functions often rely
-    that this value reflects which SHOW statement is executed.
-  */
-  lex->sql_command= query_tables_list_backup.sql_command;
-
   /*
     We should not introduce deadlocks even if we already have some
     tables open and locked, since we won't lock tables which we will
@@ -3547,9 +3630,19 @@ int get_all_tables(THD *thd, TABLE_LIST
   */
   if (lsel && lsel->table_list.first)
   {
-    error= fill_schema_show_cols_or_idxs(thd, tables, schema_table,
-                                         can_deadlock,
-                                         &open_tables_state_backup);
+    LEX_STRING db_name, table_name;
+
+    db_name.str= lsel->table_list.first->db;
+    db_name.length= lsel->table_list.first->db_length;
+
+    table_name.str= lsel->table_list.first->table_name;
+    table_name.length= lsel->table_list.first->table_name_length;
+
+    error= fill_schema_table_by_open(thd, TRUE,
+                                     table, schema_table,
+                                     &db_name, &table_name,
+                                     &open_tables_state_backup,
+                                     can_deadlock);
     goto err;
   }
 
@@ -3603,12 +3696,6 @@ int get_all_tables(THD *thd, TABLE_LIST
   it.rewind(); /* To get access to new elements in basis list */
   while ((db_name= it++))
   {
-    LEX_STRING orig_db_name;
-
-    /* db_name can be changed in make_table_list() func */
-    if (!thd->make_lex_string(&orig_db_name, db_name->str,
-                              db_name->length, FALSE))
-      goto err;
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
     if (!(check_access(thd, SELECT_ACL, db_name->str,
                        &thd->col_access, NULL, 0, 1) ||
@@ -3686,66 +3773,11 @@ int get_all_tables(THD *thd, TABLE_LIST
                 continue;
             }
 
-            int res;
-            LEX_STRING tmp_lex_string;
-            /*
-              Set the parent lex of 'sel' because it is needed by
-              sel.init_query() which is called inside make_table_list.
-            */
-            sel.parent_lex= lex;
-            if (make_table_list(thd, &sel, db_name, table_name))
-              goto err;
-            TABLE_LIST *show_table_list= sel.table_list.first;
-            lex->all_selects_list= &sel;
-            lex->derived_tables= 0;
-            lex->sql_command= SQLCOM_SHOW_FIELDS;
-            show_table_list->i_s_requested_object=
-              schema_table->i_s_requested_object;
-            DEBUG_SYNC(thd, "before_open_in_get_all_tables");
-            res= open_normal_and_derived_tables(thd, show_table_list,
-                   (MYSQL_OPEN_IGNORE_FLUSH |
-                    MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL |
-                    (can_deadlock ? MYSQL_OPEN_FAIL_ON_MDL_CONFLICT : 0)));
-            lex->sql_command= query_tables_list_backup.sql_command;
-            /*
-              XXX:  show_table_list has a flag i_is_requested,
-              and when it's set, open_normal_and_derived_tables()
-              can return an error without setting an error message
-              in THD, which is a hack. This is why we have to
-              check for res, then for thd->is_error() only then
-              for thd->stmt_da->sql_errno().
-            */
-            if (res && thd->is_error() &&
-                thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE)
-            {
-              /*
-                Hide error for not existing table.
-                This error can occur for example when we use
-                where condition with db name and table name and this
-                table does not exist.
-              */
-              res= 0;
-              thd->clear_error();
-            }
-            else
-            {
-              /*
-                We should use show_table_list->alias instead of 
-                show_table_list->table_name because table_name
-                could be changed during opening of I_S tables. It's safe
-                to use alias because alias contains original table name 
-                in this case.
-              */
-              thd->make_lex_string(&tmp_lex_string, show_table_list->alias,
-                                   strlen(show_table_list->alias), FALSE);
-              res= schema_table->process_table(thd, show_table_list, table,
-                                               res, &orig_db_name,
-                                               &tmp_lex_string);
-              close_tables_for_reopen(thd, &show_table_list,
-                                      open_tables_state_backup.mdl_system_tables_svp);
-            }
-            DBUG_ASSERT(!lex->query_tables_own_last);
-            if (res)
+            if (fill_schema_table_by_open(thd, FALSE,
+                                          table, schema_table,
+                                          db_name, table_name,
+                                          &open_tables_state_backup,
+                                          can_deadlock))
               goto err;
           }
         }
@@ -3761,10 +3793,7 @@ int get_all_tables(THD *thd, TABLE_LIST
   error= 0;
 err:
   thd->restore_backup_open_tables_state(&open_tables_state_backup);
-  lex->restore_backup_query_tables_list(&query_tables_list_backup);
-  lex->derived_tables= derived_tables;
-  lex->all_selects_list= old_all_select_lex;
-  lex->context_analysis_only= save_context_analysis_only;
+
   DBUG_RETURN(error);
 }
 

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-05-19 12:43:26 +0000
+++ b/sql/sql_table.cc	2011-05-21 09:30:35 +0000
@@ -2812,7 +2812,8 @@ int prepare_create_field(Create_field *s
           MAX_FIELD_CHARLENGTH)
       {
         my_printf_error(ER_TOO_BIG_FIELDLENGTH, ER(ER_TOO_BIG_FIELDLENGTH),
-                        MYF(0), sql_field->field_name, MAX_FIELD_CHARLENGTH);
+                        MYF(0), sql_field->field_name,
+                        static_cast<ulong>(MAX_FIELD_CHARLENGTH));
         DBUG_RETURN(1);
       }
     }
@@ -3808,12 +3809,12 @@ mysql_prepare_create_table(THD *thd, HA_
            (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
       {
         my_error(ER_TOO_LONG_INDEX_COMMENT, MYF(0),
-                 key_info->name, (uint) INDEX_COMMENT_MAXLEN);
+                 key_info->name, static_cast<ulong>(INDEX_COMMENT_MAXLEN));
         DBUG_RETURN(-1);
       }
       char warn_buff[MYSQL_ERRMSG_SIZE];
       my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_INDEX_COMMENT),
-                  key_info->name, (uint) INDEX_COMMENT_MAXLEN);
+                  key_info->name, static_cast<ulong>(INDEX_COMMENT_MAXLEN));
       /* do not push duplicate warnings */
       if (!check_duplicate_warning(thd, warn_buff, strlen(warn_buff)))
         push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -3941,7 +3942,8 @@ static bool prepare_blob_field(THD *thd,
                                                       MODE_STRICT_ALL_TABLES)))
     {
       my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), sql_field->field_name,
-               MAX_FIELD_VARCHARLENGTH / sql_field->charset->mbmaxlen);
+               static_cast<ulong>(MAX_FIELD_VARCHARLENGTH /
+                                  sql_field->charset->mbmaxlen));
       DBUG_RETURN(1);
     }
     sql_field->sql_type= MYSQL_TYPE_BLOB;

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2011-05-12 05:52:39 +0000
+++ b/sql/sql_yacc.yy	2011-05-21 08:25:33 +0000
@@ -1929,7 +1929,7 @@ master_def:
             if ($3 > MASTER_DELAY_MAX)
             {
               my_error(ER_MASTER_DELAY_VALUE_OUT_OF_RANGE, MYF(0),
-                       $3, MASTER_DELAY_MAX);
+                       static_cast<uint>($3), MASTER_DELAY_MAX);
             }
             else
               Lex->mi.sql_delay = $3;

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-05-12 17:29:19 +0000
+++ b/sql/sys_vars.cc	2011-05-21 08:25:33 +0000
@@ -912,7 +912,7 @@ static bool event_scheduler_update(sys_v
             : Events::stop();
   mysql_mutex_lock(&LOCK_global_system_variables);
   if (ret)
-    my_error(ER_EVENT_SET_VAR_ERROR, MYF(0));
+    my_error(ER_EVENT_SET_VAR_ERROR, MYF(0), 0);
   return ret;
 }
 
@@ -2728,7 +2728,7 @@ static bool update_last_insert_id(THD *t
 {
   if (!var->value)
   {
-    my_error(ER_NO_DEFAULT, MYF(0), var->var->name);
+    my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
     return true;
   }
   thd->first_successful_insert_id_in_prev_stmt=
@@ -2777,7 +2777,7 @@ static bool update_insert_id(THD *thd, s
 {
   if (!var->value)
   {
-    my_error(ER_NO_DEFAULT, MYF(0), var->var->name);
+    my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
     return true;
   }
   thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
@@ -2800,7 +2800,7 @@ static bool update_rand_seed1(THD *thd,
 {
   if (!var->value)
   {
-    my_error(ER_NO_DEFAULT, MYF(0), var->var->name);
+    my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
     return true;
   }
   thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
@@ -2822,7 +2822,7 @@ static bool update_rand_seed2(THD *thd,
 {
   if (!var->value)
   {
-    my_error(ER_NO_DEFAULT, MYF(0), var->var->name);
+    my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
     return true;
   }
   thd->rand.seed2= (ulong) var->save_result.ulonglong_value;

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-05-12 18:42:28 +0000
+++ b/sql/table.cc	2011-05-23 23:34:47 +0000
@@ -2225,7 +2225,15 @@ void free_blobs(register TABLE *table)
   for (ptr= table->s->blob_field, end=ptr + table->s->blob_fields ;
        ptr != end ;
        ptr++)
-    ((Field_blob*) table->field[*ptr])->free();
+  {
+    /*
+      Reduced TABLE objects which are used by row-based replication for
+      type conversion might have some fields missing. Skip freeing BLOB
+      buffers for such missing fields.
+    */
+    if (table->field[*ptr])
+      ((Field_blob*) table->field[*ptr])->free();
+  }
 }
 
 
@@ -2459,7 +2467,7 @@ void open_table_error(TABLE_SHARE *share
   default:				/* Better wrong error than none */
   case 4:
     strxmov(buff, share->normalized_path.str, reg_ext, NullS);
-    my_error(ER_NOT_FORM_FILE, errortype, buff, 0);
+    my_error(ER_NOT_FORM_FILE, errortype, buff);
     break;
   }
   DBUG_VOID_RETURN;
@@ -3048,7 +3056,8 @@ Table_check_intact::check(TABLE *table,
       report_error(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE,
                    ER(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE),
                    table->alias, table_def->count, table->s->fields,
-                   table->s->mysql_version, MYSQL_VERSION_ID);
+                   static_cast<int>(table->s->mysql_version),
+                   MYSQL_VERSION_ID);
       DBUG_RETURN(TRUE);
     }
     else if (MYSQL_VERSION_ID == table->s->mysql_version)

=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc	2011-03-25 13:28:19 +0000
+++ b/sql/unireg.cc	2011-05-21 08:25:33 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, 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
@@ -230,13 +230,13 @@ bool mysql_create_frm(THD *thd, const ch
          (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
     {
       my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0),
-               real_table_name, (uint) TABLE_COMMENT_MAXLEN);
+               real_table_name, static_cast<ulong>(TABLE_COMMENT_MAXLEN));
       my_free(screen_buff);
       DBUG_RETURN(1);
     }
     char warn_buff[MYSQL_ERRMSG_SIZE];
     my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_TABLE_COMMENT),
-                real_table_name, (uint) TABLE_COMMENT_MAXLEN);
+                real_table_name, static_cast<ulong>(TABLE_COMMENT_MAXLEN));
     /* do not push duplicate warnings */
     if (!check_duplicate_warning(current_thd, warn_buff, strlen(warn_buff)))
       push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -737,13 +737,14 @@ static bool pack_header(uchar *forminfo,
       if ((current_thd->variables.sql_mode &
 	   (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
       {
-        my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0),
-                 field->field_name, (uint) COLUMN_COMMENT_MAXLEN);
+        my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name,
+                 static_cast<ulong>(COLUMN_COMMENT_MAXLEN));
 	DBUG_RETURN(1);
       }
       char warn_buff[MYSQL_ERRMSG_SIZE];
       my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_LONG_FIELD_COMMENT),
-                  field->field_name, (uint) COLUMN_COMMENT_MAXLEN);
+                  field->field_name,
+                  static_cast<ulong>(COLUMN_COMMENT_MAXLEN));
       /* do not push duplicate warnings */
       if (!check_duplicate_warning(current_thd, warn_buff, strlen(warn_buff)))
         push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -831,7 +832,7 @@ static bool pack_header(uchar *forminfo,
 
   if (reclength > (ulong) file->max_record_length())
   {
-    my_error(ER_TOO_BIG_ROWSIZE, MYF(0), (uint) file->max_record_length());
+    my_error(ER_TOO_BIG_ROWSIZE, MYF(0), static_cast<long>(file->max_record_length()));
     DBUG_RETURN(1);
   }
   /* Hack to avoid bugs with small static rows in MySQL */

=== modified file 'storage/example/ha_example.cc'
--- a/storage/example/ha_example.cc	2011-04-19 03:29:06 +0000
+++ b/storage/example/ha_example.cc	2011-05-21 08:25:33 +0000
@@ -977,7 +977,7 @@ static int show_func_example(MYSQL_THD t
   var->type= SHOW_CHAR;
   var->value= buf; // it's of SHOW_VAR_FUNC_BUFF_SIZE bytes
   my_snprintf(buf, SHOW_VAR_FUNC_BUFF_SIZE,
-              "enum_var is %u, ulong_var is %lu, %.6b", // %b is MySQL extension
+              "enum_var is %lu, ulong_var is %lu, %.6b", // %b is MySQL extension
               srv_enum_var, srv_ulong_var, "really");
   return 0;
 }

=== modified file 'storage/innobase/buf/buf0buf.c'
--- a/storage/innobase/buf/buf0buf.c	2011-05-04 09:54:04 +0000
+++ b/storage/innobase/buf/buf0buf.c	2011-05-24 08:42:51 +0000
@@ -5136,25 +5136,18 @@ buf_get_latched_pages_number(void)
 #endif /* UNIV_DEBUG */
 
 /*********************************************************************//**
-Returns the number of pending buf pool ios.
-@return	number of pending I/O operations */
+Returns the number of pending buf pool read ios.
+@return	number of pending read I/O operations */
 UNIV_INTERN
 ulint
-buf_get_n_pending_ios(void)
-/*=======================*/
+buf_get_n_pending_read_ios(void)
+/*============================*/
 {
 	ulint	i;
 	ulint	pend_ios = 0;
 
 	for (i = 0; i < srv_buf_pool_instances; i++) {
-		buf_pool_t*	buf_pool;
-
-		buf_pool = buf_pool_from_array(i);
-
-		pend_ios +=
-			buf_pool->n_pend_reads
-			+ buf_pool->n_flush[BUF_FLUSH_LRU]
-			+ buf_pool->n_flush[BUF_FLUSH_LIST];
+		pend_ios += buf_pool_from_array(i)->n_pend_reads;
 	}
 
 	return(pend_ios);

=== modified file 'storage/innobase/buf/buf0flu.c'
--- a/storage/innobase/buf/buf0flu.c	2011-04-05 11:12:48 +0000
+++ b/storage/innobase/buf/buf0flu.c	2011-05-12 13:54:33 +0000
@@ -2393,8 +2393,10 @@ buf_flush_page_cleaner_thread(
 	while (srv_shutdown_state == SRV_SHUTDOWN_NONE) {
 
 		/* The page_cleaner skips sleep if the server is
-		idle and there is work to do. */
+		idle and there are no pending IOs in the buffer pool
+		and there is work to do. */
 		if (srv_check_activity(last_activity)
+		    || buf_get_n_pending_read_ios()
 		    || n_flushed == 0) {
 			page_cleaner_sleep_if_needed(next_loop_time);
 		}

=== modified file 'storage/innobase/dict/dict0crea.c'
--- a/storage/innobase/dict/dict0crea.c	2011-04-27 21:49:19 +0000
+++ b/storage/innobase/dict/dict0crea.c	2011-05-09 08:48:47 +0000
@@ -677,9 +677,9 @@ dict_create_index_tree_step(
 	/* printf("Created a new index tree in space %lu root page %lu\n",
 	index->space, index->page_no); */
 
-	page_rec_write_index_page_no(btr_pcur_get_rec(&pcur),
-				     DICT_SYS_INDEXES_PAGE_NO_FIELD,
-				     node->page_no, &mtr);
+	page_rec_write_field(btr_pcur_get_rec(&pcur),
+			     DICT_SYS_INDEXES_PAGE_NO_FIELD,
+			     node->page_no, &mtr);
 	btr_pcur_close(&pcur);
 	mtr_commit(&mtr);
 
@@ -749,9 +749,8 @@ dict_drop_index_tree(
 	root_page_no); */
 	btr_free_root(space, zip_size, root_page_no, mtr);
 
-	page_rec_write_index_page_no(rec,
-				     DICT_SYS_INDEXES_PAGE_NO_FIELD,
-				     FIL_NULL, mtr);
+	page_rec_write_field(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
+			     FIL_NULL, mtr);
 }
 
 /*******************************************************************//**
@@ -854,8 +853,8 @@ create:
 	in SYS_INDEXES, so that the database will not get into an
 	inconsistent state in case it crashes between the mtr_commit()
 	below and the following mtr_commit() call. */
-	page_rec_write_index_page_no(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
-				     FIL_NULL, mtr);
+	page_rec_write_field(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
+			     FIL_NULL, mtr);
 
 	/* We will need to commit the mini-transaction in order to avoid
 	deadlocks in the btr_create() call, because otherwise we would

=== modified file 'storage/innobase/fil/fil0fil.c'
--- a/storage/innobase/fil/fil0fil.c	2011-05-04 09:54:04 +0000
+++ b/storage/innobase/fil/fil0fil.c	2011-05-22 20:19:06 +0000
@@ -154,6 +154,9 @@ struct fil_node_struct {
 				/*!< count of pending flushes on this file;
 				closing of the file is not allowed if
 				this is > 0 */
+	ibool		being_extended;
+				/*!< TRUE if the node is currently
+				being extended. */
 	ib_int64_t	modification_counter;/*!< when we write to the file we
 				increment this by one */
 	ib_int64_t	flush_counter;/*!< up to what
@@ -612,21 +615,15 @@ fil_node_create(
 
 	mutex_enter(&fil_system->mutex);
 
-	node = mem_alloc(sizeof(fil_node_t));
+	node = mem_zalloc(sizeof(fil_node_t));
 
 	node->name = mem_strdup(name);
-	node->open = FALSE;
 
 	ut_a(!is_raw || srv_start_raw_disk_in_use);
 
 	node->is_raw_disk = is_raw;
 	node->size = size;
 	node->magic_n = FIL_NODE_MAGIC_N;
-	node->n_pending = 0;
-	node->n_pending_flushes = 0;
-
-	node->modification_counter = 0;
-	node->flush_counter = 0;
 
 	space = fil_space_get_by_id(id);
 
@@ -671,9 +668,7 @@ fil_node_open_file(
 	fil_system_t*	system,	/*!< in: tablespace memory cache */
 	fil_space_t*	space)	/*!< in: space */
 {
-	ib_int64_t	size_bytes;
-	ulint		size_low;
-	ulint		size_high;
+	os_offset_t	size_bytes;
 	ibool		ret;
 	ibool		success;
 	byte*		buf2;
@@ -711,10 +706,8 @@ fil_node_open_file(
 			ut_a(0);
 		}
 
-		os_file_get_size(node->handle, &size_low, &size_high);
-
-		size_bytes = (((ib_int64_t)size_high) << 32)
-			+ (ib_int64_t)size_low;
+		size_bytes = os_file_get_size(node->handle);
+		ut_a(size_bytes != (os_offset_t) -1);
 #ifdef UNIV_HOTBACKUP
 		if (space->id == 0) {
 			node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
@@ -729,11 +722,10 @@ fil_node_open_file(
 			fprintf(stderr,
 				"InnoDB: Error: the size of single-table"
 				" tablespace file %s\n"
-				"InnoDB: is only %lu %lu,"
+				"InnoDB: is only %llu,"
 				" should be at least %lu!\n",
 				node->name,
-				(ulong) size_high,
-				(ulong) size_low,
+				size_bytes,
 				(ulong) (FIL_IBD_FILE_INITIAL_SIZE
 					 * UNIV_PAGE_SIZE));
 
@@ -747,8 +739,7 @@ fil_node_open_file(
 		set */
 		page = ut_align(buf2, UNIV_PAGE_SIZE);
 
-		success = os_file_read(node->handle, page, 0, 0,
-				       UNIV_PAGE_SIZE);
+		success = os_file_read(node->handle, page, 0, UNIV_PAGE_SIZE);
 		space_id = fsp_header_get_space_id(page);
 		flags = fsp_header_get_flags(page);
 
@@ -860,7 +851,9 @@ fil_node_close_file(
 	ut_a(node->open);
 	ut_a(node->n_pending == 0);
 	ut_a(node->n_pending_flushes == 0);
-	ut_a(node->modification_counter == node->flush_counter);
+	ut_a(!node->being_extended);
+	ut_a(node->modification_counter == node->flush_counter
+	     || srv_fast_shutdown == 2);
 
 	ret = os_file_close(node->handle);
 	ut_a(ret);
@@ -899,32 +892,37 @@ fil_try_to_close_file_in_LRU(
 
 	ut_ad(mutex_own(&fil_system->mutex));
 
-	node = UT_LIST_GET_LAST(fil_system->LRU);
-
 	if (print_info) {
 		fprintf(stderr,
 			"InnoDB: fil_sys open file LRU len %lu\n",
 			(ulong) UT_LIST_GET_LEN(fil_system->LRU));
 	}
 
-	while (node != NULL) {
+	for (node = UT_LIST_GET_LAST(fil_system->LRU);
+	     node != NULL;
+	     node = UT_LIST_GET_PREV(LRU, node)) {
+
 		if (node->modification_counter == node->flush_counter
-		    && node->n_pending_flushes == 0) {
+		    && node->n_pending_flushes == 0
+		    && !node->being_extended) {
 
 			fil_node_close_file(node, fil_system);
 
 			return(TRUE);
 		}
 
-		if (print_info && node->n_pending_flushes > 0) {
+		if (!print_info) {
+			continue;
+		}
+
+		if (node->n_pending_flushes > 0) {
 			fputs("InnoDB: cannot close file ", stderr);
 			ut_print_filename(stderr, node->name);
 			fprintf(stderr, ", because n_pending_flushes %lu\n",
 				(ulong) node->n_pending_flushes);
 		}
 
-		if (print_info
-		    && node->modification_counter != node->flush_counter) {
+		if (node->modification_counter != node->flush_counter) {
 			fputs("InnoDB: cannot close file ", stderr);
 			ut_print_filename(stderr, node->name);
 			fprintf(stderr,
@@ -933,7 +931,11 @@ fil_try_to_close_file_in_LRU(
 				(long) node->flush_counter);
 		}
 
-		node = UT_LIST_GET_PREV(LRU, node);
+		if (node->being_extended) {
+			fputs("InnoDB: cannot close file ", stderr);
+			ut_print_filename(stderr, node->name);
+			fprintf(stderr, ", because it is being extended\n");
+		}
 	}
 
 	return(FALSE);
@@ -1072,6 +1074,7 @@ fil_node_free(
 	ut_ad(mutex_own(&(system->mutex)));
 	ut_a(node->magic_n == FIL_NODE_MAGIC_N);
 	ut_a(node->n_pending == 0);
+	ut_a(!node->being_extended);
 
 	if (node->open) {
 		/* We fool the assertion in fil_node_close_file() to think
@@ -1829,7 +1832,7 @@ fil_read_flushed_lsn_and_arch_log_no(
 	/* Align the memory for a possible read from a raw device */
 	buf = ut_align(buf2, UNIV_PAGE_SIZE);
 
-	os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE);
+	os_file_read(data_file, buf, 0, UNIV_PAGE_SIZE);
 
 	flushed_lsn = mach_read_from_8(buf + FIL_PAGE_FILE_FLUSH_LSN);
 
@@ -2278,7 +2281,8 @@ try_again:
 	ut_a(UT_LIST_GET_LEN(space->chain) == 1);
 	node = UT_LIST_GET_FIRST(space->chain);
 
-	if (space->n_pending_flushes > 0 || node->n_pending > 0) {
+	if (space->n_pending_flushes > 0 || node->n_pending > 0
+	    || node->being_extended) {
 		if (count > 1000) {
 			ut_print_timestamp(stderr);
 			fputs("  InnoDB: Warning: trying to"
@@ -2287,6 +2291,7 @@ try_again:
 			fprintf(stderr, ",\n"
 				"InnoDB: but there are %lu flushes"
 				" and %lu pending i/o's on it\n"
+				"InnoDB: Or it is being extended\n"
 				"InnoDB: Loop %lu.\n",
 				(ulong) space->n_pending_flushes,
 				(ulong) node->n_pending,
@@ -2585,8 +2590,10 @@ retry:
 	ut_a(UT_LIST_GET_LEN(space->chain) == 1);
 	node = UT_LIST_GET_FIRST(space->chain);
 
-	if (node->n_pending > 0 || node->n_pending_flushes > 0) {
-		/* There are pending i/o's or flushes, sleep for a while and
+	if (node->n_pending > 0 || node->n_pending_flushes > 0
+	    || node->being_extended) {
+		/* There are pending i/o's or flushes or the file is
+		currently being extended, sleep for a while and
 		retry */
 
 		mutex_exit(&fil_system->mutex);
@@ -2748,7 +2755,7 @@ fil_create_new_single_table_tablespace(
 		return(DB_ERROR);
 	}
 
-	ret = os_file_set_size(path, file, size * UNIV_PAGE_SIZE, 0);
+	ret = os_file_set_size(path, file, size * UNIV_PAGE_SIZE);
 
 	if (!ret) {
 		err = DB_OUT_OF_FILE_SPACE;
@@ -2783,7 +2790,7 @@ error_exit2:
 
 	if (!(flags & DICT_TF_ZSSIZE_MASK)) {
 		buf_flush_init_for_writing(page, NULL, 0);
-		ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
+		ret = os_file_write(path, file, page, 0, UNIV_PAGE_SIZE);
 	} else {
 		page_zip_des_t	page_zip;
 		ulint		zip_size;
@@ -2800,7 +2807,7 @@ error_exit2:
 			page_zip.m_end = page_zip.m_nonempty =
 			page_zip.n_blobs = 0;
 		buf_flush_init_for_writing(page, &page_zip, 0);
-		ret = os_file_write(path, file, page_zip.data, 0, 0, zip_size);
+		ret = os_file_write(path, file, page_zip.data, 0, zip_size);
 	}
 
 	ut_free(buf2);
@@ -2883,8 +2890,8 @@ fil_reset_too_high_lsns(
 	byte*		buf2;
 	lsn_t		flush_lsn;
 	ulint		space_id;
-	ib_int64_t	file_size;
-	ib_int64_t	offset;
+	os_offset_t	file_size;
+	os_offset_t	offset;
 	ulint		zip_size;
 	ibool		success;
 	page_zip_des_t	page_zip;
@@ -2916,7 +2923,7 @@ fil_reset_too_high_lsns(
 	/* Align the memory for file i/o if we might have O_DIRECT set */
 	page = ut_align(buf2, UNIV_PAGE_SIZE);
 
-	success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
+	success = os_file_read(file, page, 0, UNIV_PAGE_SIZE);
 	if (!success) {
 
 		goto func_exit;
@@ -2960,13 +2967,12 @@ fil_reset_too_high_lsns(
 	/* Loop through all the pages in the tablespace and reset the lsn and
 	the page checksum if necessary */
 
-	file_size = os_file_get_size_as_iblonglong(file);
+	file_size = os_file_get_size(file);
+	ut_a(file_size != (os_offset_t) -1);
 
 	for (offset = 0; offset < file_size;
 	     offset += zip_size ? zip_size : UNIV_PAGE_SIZE) {
-		success = os_file_read(file, page,
-				       (ulint)(offset & 0xFFFFFFFFUL),
-				       (ulint)(offset >> 32),
+		success = os_file_read(file, page, offset,
 				       zip_size ? zip_size : UNIV_PAGE_SIZE);
 		if (!success) {
 
@@ -2981,16 +2987,13 @@ fil_reset_too_high_lsns(
 					page, &page_zip, current_lsn);
 				success = os_file_write(
 					filepath, file, page_zip.data,
-					(ulint) offset & 0xFFFFFFFFUL,
-					(ulint) (offset >> 32), zip_size);
+					offset, zip_size);
 			} else {
 				buf_flush_init_for_writing(
 					page, NULL, current_lsn);
 				success = os_file_write(
 					filepath, file, page,
-					(ulint)(offset & 0xFFFFFFFFUL),
-					(ulint)(offset >> 32),
-					UNIV_PAGE_SIZE);
+					offset, UNIV_PAGE_SIZE);
 			}
 
 			if (!success) {
@@ -3007,7 +3010,7 @@ fil_reset_too_high_lsns(
 	}
 
 	/* We now update the flush_lsn stamp at the start of the file */
-	success = os_file_read(file, page, 0, 0,
+	success = os_file_read(file, page, 0,
 			       zip_size ? zip_size : UNIV_PAGE_SIZE);
 	if (!success) {
 
@@ -3016,7 +3019,7 @@ fil_reset_too_high_lsns(
 
 	mach_write_to_8(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
 
-	success = os_file_write(filepath, file, page, 0, 0,
+	success = os_file_write(filepath, file, page, 0,
 				zip_size ? zip_size : UNIV_PAGE_SIZE);
 	if (!success) {
 
@@ -3116,7 +3119,7 @@ fil_open_single_table_tablespace(
 	/* Align the memory for file i/o if we might have O_DIRECT set */
 	page = ut_align(buf2, UNIV_PAGE_SIZE);
 
-	success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
+	success = os_file_read(file, page, 0, UNIV_PAGE_SIZE);
 
 	/* We have to read the tablespace id and flags from the file. */
 
@@ -3207,9 +3210,7 @@ fil_load_single_table_tablespace(
 	byte*		page;
 	ulint		space_id;
 	ulint		flags;
-	ulint		size_low;
-	ulint		size_high;
-	ib_int64_t	size;
+	os_offset_t	size;
 #ifdef UNIV_HOTBACKUP
 	fil_space_t*	space;
 #endif
@@ -3277,9 +3278,9 @@ fil_load_single_table_tablespace(
 		exit(1);
 	}
 
-	success = os_file_get_size(file, &size_low, &size_high);
+	size = os_file_get_size(file);
 
-	if (!success) {
+	if (UNIV_UNLIKELY(size == (os_offset_t) -1)) {
 		/* The following call prints an error message */
 		os_file_get_last_error(TRUE);
 
@@ -3330,16 +3331,14 @@ fil_load_single_table_tablespace(
 	/* Every .ibd file is created >= 4 pages in size. Smaller files
 	cannot be ok. */
 
-	size = (((ib_int64_t)size_high) << 32) + (ib_int64_t)size_low;
 #ifndef UNIV_HOTBACKUP
 	if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
 		fprintf(stderr,
 			"InnoDB: Error: the size of single-table tablespace"
 			" file %s\n"
-			"InnoDB: is only %lu %lu, should be at least %lu!",
+			"InnoDB: is only %llu, should be at least %lu!",
 			filepath,
-			(ulong) size_high,
-			(ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE));
+			size, (ulong) (4 * UNIV_PAGE_SIZE));
 		os_file_close(file);
 		mem_free(filepath);
 
@@ -3353,7 +3352,7 @@ fil_load_single_table_tablespace(
 	page = ut_align(buf2, UNIV_PAGE_SIZE);
 
 	if (size >= FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
-		success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
+		success = os_file_read(file, page, 0, UNIV_PAGE_SIZE);
 
 		/* We have to read the tablespace id from the file */
 
@@ -3897,10 +3896,13 @@ fil_extend_space_to_desired_size(
 	ulint		buf_size;
 	ulint		start_page_no;
 	ulint		file_start_page_no;
-	ulint		offset_high;
-	ulint		offset_low;
 	ulint		page_size;
-	ibool		success		= TRUE;
+	ulint		pages_added;
+	ibool		success;
+
+retry:
+	pages_added = 0;
+	success = TRUE;
 
 	fil_mutex_enter_and_prepare_for_io(space_id);
 
@@ -3924,8 +3926,28 @@ fil_extend_space_to_desired_size(
 
 	node = UT_LIST_GET_LAST(space->chain);
 
+	if (!node->being_extended) {
+		/* Mark this node as undergoing extension. This flag
+		is used by other threads to wait for the extension
+		opereation to finish. */
+		node->being_extended = TRUE;
+	} else {
+		/* Another thread is currently extending the file. Wait
+		for it to finish.
+		It'd have been better to use event driven mechanism but
+		the entire module is peppered with polling stuff. */
+		mutex_exit(&fil_system->mutex);
+		os_thread_sleep(100000);
+		goto retry;
+	}
+
 	fil_node_prepare_for_io(node, fil_system, space);
 
+	/* At this point it is safe to release fil_system mutex. No
+	other thread can rename, delete or close the file because
+	we have set the node->being_extended flag. */
+	mutex_exit(&fil_system->mutex);
+
 	start_page_no = space->size;
 	file_start_page_no = space->size - node->size;
 
@@ -3937,50 +3959,53 @@ fil_extend_space_to_desired_size(
 	memset(buf, 0, buf_size);
 
 	while (start_page_no < size_after_extend) {
-		ulint	n_pages = ut_min(buf_size / page_size,
-					 size_after_extend - start_page_no);
+		ulint		n_pages
+			= ut_min(buf_size / page_size,
+				 size_after_extend - start_page_no);
 
-		offset_high = (start_page_no - file_start_page_no)
-			/ (4096 * ((1024 * 1024) / page_size));
-		offset_low  = ((start_page_no - file_start_page_no)
-			       % (4096 * ((1024 * 1024) / page_size)))
+		os_offset_t	offset
+			= ((os_offset_t) (start_page_no - file_start_page_no))
 			* page_size;
 #ifdef UNIV_HOTBACKUP
 		success = os_file_write(node->name, node->handle, buf,
-					offset_low, offset_high,
-					page_size * n_pages);
+					offset, page_size * n_pages);
 #else
 		success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC,
 				 node->name, node->handle, buf,
-				 offset_low, offset_high,
-				 page_size * n_pages,
+				 offset, page_size * n_pages,
 				 NULL, NULL);
 #endif
 		if (success) {
-			node->size += n_pages;
-			space->size += n_pages;
-
 			os_has_said_disk_full = FALSE;
 		} else {
 			/* Let us measure the size of the file to determine
 			how much we were able to extend it */
+			os_offset_t	size;
 
-			n_pages = ((ulint)
-				   (os_file_get_size_as_iblonglong(
-					   node->handle)
-				    / page_size)) - node->size;
+			size = os_file_get_size(node->handle);
+			ut_a(size != (os_offset_t) -1);
 
-			node->size += n_pages;
-			space->size += n_pages;
+			n_pages = ((ulint) (size / page_size))
+				- node->size - pages_added;
 
+			pages_added += n_pages;
 			break;
 		}
 
 		start_page_no += n_pages;
+		pages_added += n_pages;
 	}
 
 	mem_free(buf2);
 
+	mutex_enter(&fil_system->mutex);
+
+	ut_a(node->being_extended);
+
+	space->size += pages_added;
+	node->size += pages_added;
+	node->being_extended = FALSE;
+
 	fil_node_complete_io(node, fil_system, OS_FILE_WRITE);
 
 	*actual_size = space->size;
@@ -4190,7 +4215,6 @@ fil_node_prepare_for_io(
 	if (node->open == FALSE) {
 		/* File is closed: open it */
 		ut_a(node->n_pending == 0);
-
 		fil_node_open_file(node, system, space);
 	}
 
@@ -4312,11 +4336,10 @@ fil_io(
 	ulint		mode;
 	fil_space_t*	space;
 	fil_node_t*	node;
-	ulint		offset_high;
-	ulint		offset_low;
 	ibool		ret;
 	ulint		is_log;
 	ulint		wake_later;
+	os_offset_t	offset;
 
 	is_log = type & OS_FILE_LOG;
 	type = type & ~OS_FILE_LOG;
@@ -4434,9 +4457,8 @@ fil_io(
 	/* Calculate the low 32 bits and the high 32 bits of the file offset */
 
 	if (!zip_size) {
-		offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
-		offset_low  = ((block_offset << UNIV_PAGE_SIZE_SHIFT)
-			       & 0xFFFFFFFFUL) + byte_offset;
+		offset = ((os_offset_t) block_offset << UNIV_PAGE_SIZE_SHIFT)
+			+ byte_offset;
 
 		ut_a(node->size - block_offset
 		     >= ((byte_offset + len + (UNIV_PAGE_SIZE - 1))
@@ -4451,8 +4473,7 @@ fil_io(
 		case 16384: zip_size_shift = 14; break;
 		default: ut_error;
 		}
-		offset_high = block_offset >> (32 - zip_size_shift);
-		offset_low = (block_offset << zip_size_shift & 0xFFFFFFFFUL)
+		offset = ((os_offset_t) block_offset << zip_size_shift)
 			+ byte_offset;
 		ut_a(node->size - block_offset
 		     >= (len + (zip_size - 1)) / zip_size);
@@ -4466,16 +4487,15 @@ fil_io(
 #ifdef UNIV_HOTBACKUP
 	/* In ibbackup do normal i/o, not aio */
 	if (type == OS_FILE_READ) {
-		ret = os_file_read(node->handle, buf, offset_low, offset_high,
-				   len);
+		ret = os_file_read(node->handle, buf, offset, len);
 	} else {
 		ret = os_file_write(node->name, node->handle, buf,
-				    offset_low, offset_high, len);
+				    offset, len);
 	}
 #else
 	/* Queue the aio request */
 	ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-		     offset_low, offset_high, len, node, message);
+		     offset, len, node, message);
 #endif
 	ut_a(ret);
 
@@ -4784,6 +4804,7 @@ fil_validate(void)
 
 	while (fil_node != NULL) {
 		ut_a(fil_node->n_pending == 0);
+		ut_a(!fil_node->being_extended);
 		ut_a(fil_node->open);
 		ut_a(fil_node->space->purpose == FIL_TABLESPACE);
 		ut_a(fil_node->space->id != 0);

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2011-05-12 18:44:56 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2011-05-22 20:17:42 +0000
@@ -12099,9 +12099,9 @@ static MYSQL_SYSVAR_ULONG(purge_threads,
 
 static MYSQL_SYSVAR_ULONG(sync_array_size, srv_sync_array_size,
   PLUGIN_VAR_OPCMDARG,
-  "Size of the mutex/lock wait array. Default is 32.",
+  "Size of the mutex/lock wait array.",
   NULL, NULL,
-  32,			/* Default setting */
+  1,			/* Default setting */
   1,			/* Minimum value */
   1024, 0);		/* Maximum value */
 

=== modified file 'storage/innobase/handler/i_s.cc'
--- a/storage/innobase/handler/i_s.cc	2011-05-16 14:30:54 +0000
+++ b/storage/innobase/handler/i_s.cc	2011-05-21 08:25:33 +0000
@@ -4272,7 +4272,7 @@ i_s_sys_tables_fill_table(
 			i_s_dict_fill_sys_tables(thd, table_rec, tables->table);
 		} else {
 			push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-					    ER_CANT_FIND_SYSTEM_REC,
+					    ER_CANT_FIND_SYSTEM_REC, "%s",
 					    err_msg);
 		}
 
@@ -4554,7 +4554,7 @@ i_s_sys_tables_fill_table_stats(
 						     tables->table);
 		} else {
 			push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-					    ER_CANT_FIND_SYSTEM_REC,
+					    ER_CANT_FIND_SYSTEM_REC, "%s",
 					    err_msg);
 		}
 
@@ -4810,7 +4810,7 @@ i_s_sys_indexes_fill_table(
 						 tables->table);
 		} else {
 			push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-					    ER_CANT_FIND_SYSTEM_REC,
+					    ER_CANT_FIND_SYSTEM_REC, "%s",
 					    err_msg);
 		}
 
@@ -5045,7 +5045,7 @@ i_s_sys_columns_fill_table(
 						 tables->table);
 		} else {
 			push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-					    ER_CANT_FIND_SYSTEM_REC,
+					    ER_CANT_FIND_SYSTEM_REC, "%s",
 					    err_msg);
 		}
 
@@ -5252,7 +5252,7 @@ i_s_sys_fields_fill_table(
 			last_id = index_id;
 		} else {
 			push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-					    ER_CANT_FIND_SYSTEM_REC,
+					    ER_CANT_FIND_SYSTEM_REC, "%s",
 					    err_msg);
 		}
 
@@ -5473,7 +5473,7 @@ i_s_sys_foreign_fill_table(
 						 tables->table);
 		} else {
 			push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-					    ER_CANT_FIND_SYSTEM_REC,
+					    ER_CANT_FIND_SYSTEM_REC, "%s",
 					    err_msg);
 		}
 
@@ -5687,7 +5687,7 @@ i_s_sys_foreign_cols_fill_table(
 				tables->table);
 		} else {
 			push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-					    ER_CANT_FIND_SYSTEM_REC,
+					    ER_CANT_FIND_SYSTEM_REC, "%s",
 					    err_msg);
 		}
 

=== modified file 'storage/innobase/include/buf0buf.h'
--- a/storage/innobase/include/buf0buf.h	2011-04-13 08:22:11 +0000
+++ b/storage/innobase/include/buf0buf.h	2011-05-24 08:42:51 +0000
@@ -700,12 +700,12 @@ buf_get_latched_pages_number(void);
 /*==============================*/
 #endif /* UNIV_DEBUG */
 /*********************************************************************//**
-Returns the number of pending buf pool ios.
-@return	number of pending I/O operations */
+Returns the number of pending buf pool read ios.
+@return	number of pending read I/O operations */
 UNIV_INTERN
 ulint
-buf_get_n_pending_ios(void);
-/*=======================*/
+buf_get_n_pending_read_ios(void);
+/*============================*/
 /*********************************************************************//**
 Prints info of the buffer i/o. */
 UNIV_INTERN

=== modified file 'storage/innobase/include/os0file.h'
--- a/storage/innobase/include/os0file.h	2011-04-13 08:34:16 +0000
+++ b/storage/innobase/include/os0file.h	2011-05-17 11:42:10 +0000
@@ -74,6 +74,8 @@ extern ulint	os_n_pending_writes;
 
 #endif
 
+/** File offset in bytes */
+typedef ib_uint64_t os_offset_t;
 #ifdef __WIN__
 /** File handle */
 # define os_file_t	HANDLE
@@ -276,24 +278,20 @@ The wrapper functions have the prefix of
 # define os_file_close(file)						\
 	pfs_os_file_close_func(file, __FILE__, __LINE__)
 
-# define os_aio(type, mode, name, file, buf, offset, offset_high,	\
+# define os_aio(type, mode, name, file, buf, offset,			\
 		n, message1, message2)					\
 	pfs_os_aio_func(type, mode, name, file, buf, offset,		\
-			offset_high, n, message1, message2,		\
-			__FILE__, __LINE__)
+			n, message1, message2, __FILE__, __LINE__)
 
-# define os_file_read(file, buf, offset, offset_high, n)		\
-	pfs_os_file_read_func(file, buf, offset, offset_high, n,	\
-			      __FILE__, __LINE__)
-
-# define os_file_read_no_error_handling(file, buf, offset,		\
-					offset_high, n)			\
-	pfs_os_file_read_no_error_handling_func(file, buf, offset,	\
-						offset_high, n,		\
+# define os_file_read(file, buf, offset, n)				\
+	pfs_os_file_read_func(file, buf, offset, n, __FILE__, __LINE__)
+
+# define os_file_read_no_error_handling(file, buf, offset, n)		\
+	pfs_os_file_read_no_error_handling_func(file, buf, offset, n,	\
 						__FILE__, __LINE__)
 
-# define os_file_write(name, file, buf, offset, offset_high, n)		\
-	pfs_os_file_write_func(name, file, buf, offset, offset_high,	\
+# define os_file_write(name, file, buf, offset, n)	\
+	pfs_os_file_write_func(name, file, buf, offset,	\
 			       n, __FILE__, __LINE__)
 
 # define os_file_flush(file)						\
@@ -318,20 +316,18 @@ to original un-instrumented file I/O API
 
 # define os_file_close(file)	os_file_close_func(file)
 
-# define os_aio(type, mode, name, file, buf, offset, offset_high,	\
-	       n, message1, message2)					\
-	os_aio_func(type, mode, name, file, buf, offset, offset_high, n,\
+# define os_aio(type, mode, name, file, buf, offset, n, message1, message2) \
+	os_aio_func(type, mode, name, file, buf, offset, n,		\
 		    message1, message2)
 
-# define os_file_read(file, buf, offset, offset_high, n)		\
-	os_file_read_func(file, buf, offset, offset_high, n)
+# define os_file_read(file, buf, offset, n)	\
+	os_file_read_func(file, buf, offset, n)
 
-# define os_file_read_no_error_handling(file, buf, offset,		\
-				       offset_high, n)			\
-	os_file_read_no_error_handling_func(file, buf, offset, offset_high, n)
+# define os_file_read_no_error_handling(file, buf, offset, n)		\
+	os_file_read_no_error_handling_func(file, buf, offset, n)
 
-# define os_file_write(name, file, buf, offset, offset_high, n)		\
-	os_file_write_func(name, file, buf, offset, offset_high, n)
+# define os_file_write(name, file, buf, offset, n)			\
+	os_file_write_func(name, file, buf, offset, n)
 
 # define os_file_flush(file)	os_file_flush_func(file)
 
@@ -687,10 +683,7 @@ pfs_os_file_read_func(
 /*==================*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read */
 	ulint		n,	/*!< in: number of bytes to read */
 	const char*	src_file,/*!< in: file name where func invoked */
 	ulint		src_line);/*!< in: line where the func invoked */
@@ -708,10 +701,7 @@ pfs_os_file_read_no_error_handling_func(
 /*====================================*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read */
 	ulint		n,	/*!< in: number of bytes to read */
 	const char*	src_file,/*!< in: file name where func invoked */
 	ulint		src_line);/*!< in: line where the func invoked */
@@ -733,10 +723,7 @@ pfs_os_aio_func(
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read or from which
 				to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read or write */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read or write */
 	ulint		n,	/*!< in: number of bytes to read or write */
 	fil_node_t*	message1,/*!< in: message for the aio handler
 				(can be used to identify a completed
@@ -762,10 +749,7 @@ pfs_os_file_write_func(
 				null-terminated string */
 	os_file_t	file,	/*!< in: handle to a file */
 	const void*	buf,	/*!< in: buffer from which to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to write */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to write */
 	ulint		n,	/*!< in: number of bytes to write */
 	const char*	src_file,/*!< in: file name where func invoked */
 	ulint		src_line);/*!< in: line where the func invoked */
@@ -814,23 +798,13 @@ os_file_close_no_error_handling(
 #endif /* UNIV_HOTBACKUP */
 /***********************************************************************//**
 Gets a file size.
-@return	TRUE if success */
+@return	file size, or (os_offset_t) -1 on failure */
 UNIV_INTERN
-ibool
+os_offset_t
 os_file_get_size(
 /*=============*/
-	os_file_t	file,	/*!< in: handle to a file */
-	ulint*		size,	/*!< out: least significant 32 bits of file
-				size */
-	ulint*		size_high);/*!< out: most significant 32 bits of size */
-/***********************************************************************//**
-Gets file size as a 64-bit integer ib_int64_t.
-@return	size in bytes, -1 if error */
-UNIV_INTERN
-ib_int64_t
-os_file_get_size_as_iblonglong(
-/*===========================*/
-	os_file_t	file);	/*!< in: handle to a file */
+	os_file_t	file)	/*!< in: handle to a file */
+	__attribute__((warn_unused_result));
 /***********************************************************************//**
 Write the specified number of zeros to a newly created file.
 @return	TRUE if success */
@@ -841,9 +815,8 @@ os_file_set_size(
 	const char*	name,	/*!< in: name of the file or path as a
 				null-terminated string */
 	os_file_t	file,	/*!< in: handle to a file */
-	ulint		size,	/*!< in: least significant 32 bits of file
-				size */
-	ulint		size_high);/*!< in: most significant 32 bits of size */
+	os_offset_t	size)	/*!< in: file size */
+	__attribute__((nonnull, warn_unused_result));
 /***********************************************************************//**
 Truncates a file at its current position.
 @return	TRUE if success */
@@ -883,10 +856,7 @@ os_file_read_func(
 /*==============*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read */
 	ulint		n);	/*!< in: number of bytes to read */
 /*******************************************************************//**
 Rewind file to its start, read at most size - 1 bytes from it to str, and
@@ -911,10 +881,7 @@ os_file_read_no_error_handling_func(
 /*================================*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read */
 	ulint		n);	/*!< in: number of bytes to read */
 
 /*******************************************************************//**
@@ -930,10 +897,7 @@ os_file_write_func(
 				null-terminated string */
 	os_file_t	file,	/*!< in: handle to a file */
 	const void*	buf,	/*!< in: buffer from which to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to write */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to write */
 	ulint		n);	/*!< in: number of bytes to write */
 /*******************************************************************//**
 Check the existence and type of the given file.
@@ -1037,10 +1001,7 @@ os_aio_func(
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read or from which
 				to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read or write */
-	ulint		offset_high, /*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read or write */
 	ulint		n,	/*!< in: number of bytes to read or write */
 	fil_node_t*	message1,/*!< in: message for the aio handler
 				(can be used to identify a completed

=== modified file 'storage/innobase/include/os0file.ic'
--- a/storage/innobase/include/os0file.ic	2010-07-14 16:23:21 +0000
+++ b/storage/innobase/include/os0file.ic	2011-05-17 11:42:10 +0000
@@ -216,10 +216,7 @@ pfs_os_aio_func(
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read or from which
 				to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read or write */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read or write */
 	ulint		n,	/*!< in: number of bytes to read or write */
 	fil_node_t*	message1,/*!< in: message for the aio handler
 				(can be used to identify a completed
@@ -243,7 +240,7 @@ pfs_os_aio_func(
 					: PSI_FILE_READ,
 				   src_file, src_line);
 
-	result = os_aio_func(type, mode, name, file, buf, offset, offset_high,
+	result = os_aio_func(type, mode, name, file, buf, offset,
 			     n, message1, message2);
 
 	register_pfs_file_io_end(locker, n);
@@ -263,10 +260,7 @@ pfs_os_file_read_func(
 /*==================*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read */
 	ulint		n,	/*!< in: number of bytes to read */
 	const char*	src_file,/*!< in: file name where func invoked */
 	ulint		src_line)/*!< in: line where the func invoked */
@@ -278,7 +272,7 @@ pfs_os_file_read_func(
 	register_pfs_file_io_begin(&state, locker, file, n, PSI_FILE_READ,
 				   src_file, src_line);
 
-	result = os_file_read_func(file, buf, offset, offset_high, n);
+	result = os_file_read_func(file, buf, offset, n);
 
 	register_pfs_file_io_end(locker, n);
 
@@ -299,10 +293,7 @@ pfs_os_file_read_no_error_handling_func(
 /*====================================*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read */
 	ulint		n,	/*!< in: number of bytes to read */
 	const char*	src_file,/*!< in: file name where func invoked */
 	ulint		src_line)/*!< in: line where the func invoked */
@@ -314,8 +305,7 @@ pfs_os_file_read_no_error_handling_func(
 	register_pfs_file_io_begin(&state, locker, file, n, PSI_FILE_READ,
 				   src_file, src_line);
 
-	result = os_file_read_no_error_handling_func(file, buf, offset,
-						     offset_high, n);
+	result = os_file_read_no_error_handling_func(file, buf, offset, n);
 
 	register_pfs_file_io_end(locker, n);
 
@@ -336,10 +326,7 @@ pfs_os_file_write_func(
 				null-terminated string */
 	os_file_t	file,	/*!< in: handle to a file */
 	const void*	buf,	/*!< in: buffer from which to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to write */
-	ulint		offset_high,/*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to write */
 	ulint		n,	/*!< in: number of bytes to write */
 	const char*	src_file,/*!< in: file name where func invoked */
 	ulint		src_line)/*!< in: line where the func invoked */
@@ -351,7 +338,7 @@ pfs_os_file_write_func(
 	register_pfs_file_io_begin(&state, locker, file, n, PSI_FILE_WRITE,
 				   src_file, src_line);
 
-	result = os_file_write_func(name, file, buf, offset, offset_high, n);
+	result = os_file_write_func(name, file, buf, offset, n);
 
 	register_pfs_file_io_end(locker, n);
 

=== modified file 'storage/innobase/include/page0page.h'
--- a/storage/innobase/include/page0page.h	2011-03-22 12:34:16 +0000
+++ b/storage/innobase/include/page0page.h	2011-05-09 08:48:47 +0000
@@ -619,17 +619,16 @@ page_rec_find_owner_rec(
 /*====================*/
 	rec_t*	rec);	/*!< in: the physical record */
 /***********************************************************************//**
-This is a low-level operation which is used in a database index creation
-to update the page number of a created B-tree to a data dictionary
-record. */
-UNIV_INTERN
+Write a 32-bit field in a data dictionary record. */
+UNIV_INLINE
 void
-page_rec_write_index_page_no(
-/*=========================*/
-	rec_t*	rec,	/*!< in: record to update */
+page_rec_write_field(
+/*=================*/
+	rec_t*	rec,	/*!< in/out: record to update */
 	ulint	i,	/*!< in: index of the field to update */
 	ulint	page_no,/*!< in: value to write */
-	mtr_t*	mtr);	/*!< in: mtr */
+	mtr_t*	mtr)	/*!< in/out: mini-transaction */
+	__attribute__((nonnull));
 /************************************************************//**
 Returns the maximum combined size of records which can be inserted on top
 of record heap.

=== modified file 'storage/innobase/include/page0page.ic'
--- a/storage/innobase/include/page0page.ic	2010-07-29 10:44:35 +0000
+++ b/storage/innobase/include/page0page.ic	2011-05-09 08:48:47 +0000
@@ -959,6 +959,27 @@ page_get_free_space_of_empty(
 		       - 2 * PAGE_DIR_SLOT_SIZE));
 }
 
+/***********************************************************************//**
+Write a 32-bit field in a data dictionary record. */
+UNIV_INLINE
+void
+page_rec_write_field(
+/*=================*/
+	rec_t*	rec,	/*!< in/out: record to update */
+	ulint	i,	/*!< in: index of the field to update */
+	ulint	val,	/*!< in: value to write */
+	mtr_t*	mtr)	/*!< in/out: mini-transaction */
+{
+	byte*	data;
+	ulint	len;
+
+	data = rec_get_nth_field_old(rec, i, &len);
+
+	ut_ad(len == 4);
+
+	mlog_write_ulint(data, val, MLOG_4BYTES, mtr);
+}
+
 /************************************************************//**
 Each user record on a page, and also the deleted user records in the heap
 takes its size plus the fraction of the dir cell size /

=== modified file 'storage/innobase/include/trx0purge.h'
--- a/storage/innobase/include/trx0purge.h	2011-04-28 07:33:49 +0000
+++ b/storage/innobase/include/trx0purge.h	2011-05-18 12:16:34 +0000
@@ -52,17 +52,6 @@ trx_purge_get_log_from_hist(
 /*========================*/
 	fil_addr_t	node_addr);	/*!< in: file address of the history
 					list node of the log */
-/*****************************************************************//**
-Checks if trx_id is >= purge_view: then it is guaranteed that its update
-undo log still exists in the system.
-@return TRUE if is sure that it is preserved, also if the function
-returns FALSE, it is possible that the undo log still exists in the
-system */
-UNIV_INTERN
-ibool
-trx_purge_update_undo_must_exist(
-/*=============================*/
-	trx_id_t	trx_id);/*!< in: transaction id */
 /********************************************************************//**
 Creates the global purge system control structure and inits the history
 mutex. */
@@ -115,9 +104,9 @@ struct trx_purge_struct{
 	sess_t*		sess;		/*!< System session running the purge
 					query */
 	trx_t*		trx;		/*!< System transaction running the
-				       	purge query: this trx is not in the
-				       	trx list of the trx system and it
-				       	never ends */
+					purge query: this trx is not in the
+					trx list of the trx system and it
+					never ends */
 	que_t*		query;		/*!< The query graph which will do the
 					parallelized purge operation */
 	rw_lock_t	latch;		/*!< The latch protecting the purge
@@ -129,7 +118,7 @@ struct trx_purge_struct{
 	read_view_t*	view;		/*!< The purge will not remove undo logs
 					which are >= this view (purge view) */
 	ulint		n_submitted;	/*!< Count of total tasks submitted
-				       	to the task queue */
+					to the task queue */
 	ulint		n_executing;	/*!< Count of currently executing purge
 					worker threads */
 	ulint		n_completed;	/*!< Count of total tasks completed */
@@ -146,7 +135,7 @@ struct trx_purge_struct{
 					invariant in trx0purge.c */
 	purge_iter_t	limit;		/* The 'purge pointer' which advances
 					during a purge, and which is used in
-				       	history list truncation */
+					history list truncation */
 	/*-----------------------------*/
 	ibool		next_stored;	/*!< TRUE if the info of the next record
 					to purge is stored below: if yes, then

=== modified file 'storage/innobase/include/trx0rec.h'
--- a/storage/innobase/include/trx0rec.h	2011-04-28 07:33:49 +0000
+++ b/storage/innobase/include/trx0rec.h	2011-05-04 11:29:29 +0000
@@ -240,10 +240,10 @@ trx_undo_get_undo_rec_low(
 	roll_ptr_t	roll_ptr,	/*!< in: roll pointer to record */
 	mem_heap_t*	heap);		/*!< in: memory heap where copied */
 /*******************************************************************//**
-Build a previous version of a clustered index record. This function checks
-that the caller has a latch on the index page of the clustered index record
-and an s-latch on the purge_view. This guarantees that the stack of versions
-is locked.
+Build a previous version of a clustered index record. The caller must
+hold a latch on the index page of the clustered index record, to
+guarantee that the stack of versions is locked all the way down to the
+purge_sys->view.
 @return DB_SUCCESS, or DB_MISSING_HISTORY if the previous version is
 earlier than purge_view, which means that it may have been removed */
 UNIV_INTERN

=== modified file 'storage/innobase/include/trx0trx.h'
--- a/storage/innobase/include/trx0trx.h	2011-04-14 07:10:14 +0000
+++ b/storage/innobase/include/trx0trx.h	2011-05-11 00:39:50 +0000
@@ -455,10 +455,10 @@ struct trx_lock_struct {
 					wait_lock==NULL */
 	ib_uint64_t	deadlock_mark;	/*!< A mark field that is initialized
 					to and checked against lock_mark_counter
-				       	by lock_deadlock_recursive(). */
+					by lock_deadlock_recursive(). */
 	ibool		was_chosen_as_deadlock_victim;
 					/*!< when the transaction decides to
-				       	wait for a lock, it sets this to FALSE;
+					wait for a lock, it sets this to FALSE;
 					if another transaction chooses this
 					transaction as a victim in deadlock
 					resolution, it sets this to TRUE.
@@ -468,7 +468,7 @@ struct trx_lock_struct {
 
 	que_thr_t*	wait_thr;	/*!< query thread belonging to this
 					trx that is in QUE_THR_LOCK_WAIT
-				       	state. For threads suspended in a
+					state. For threads suspended in a
 					lock wait, this is protected by
 					lock_sys->mutex. Otherwise, this may
 					only be modified by the thread that is
@@ -537,7 +537,7 @@ struct trx_struct{
 	ulint		magic_n;
 
 	mutex_t		mutex;		/*!< Mutex protecting the fields
-				       	state and lock
+					state and lock
 					(except some fields of lock, which
 					are protected by lock_sys->mutex) */
 
@@ -584,13 +584,13 @@ struct trx_struct{
 					set this FALSE */
 	/*------------------------------*/
 	/* MySQL has a transaction coordinator to coordinate two phase
-       	commit between multiple storage engines and the binary log. When
-       	an engine participates in a transaction, it's responsible for
-       	registering itself using the trans_register_ha() API. */
+	commit between multiple storage engines and the binary log. When
+	an engine participates in a transaction, it's responsible for
+	registering itself using the trans_register_ha() API. */
 	unsigned	is_registered:1;/* This flag is set to 1 after the
-				       	transaction has been registered with
-				       	the coordinator using the XA API, and
-				       	is set to 0 after commit or rollback. */
+					transaction has been registered with
+					the coordinator using the XA API, and
+					is set to 0 after commit or rollback. */
 	unsigned	owns_prepare_mutex:1;/* 1 if owns prepare mutex, if
 					this is set to 1 then registered should
 					also be set to 1. This is used in the
@@ -616,10 +616,10 @@ struct trx_struct{
 					mutex. */
 	ulint		must_flush_log_later;/*!< this flag is set to TRUE in
 					trx_commit() if flush_log_later was
-				       	TRUE, and there were modifications by
-				       	the transaction; in that case we must
-				       	flush the log in
-				       	trx_commit_complete_for_mysql() */
+					TRUE, and there were modifications by
+					the transaction; in that case we must
+					flush the log in
+					trx_commit_complete_for_mysql() */
 	ulint		duplicates;	/*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
 	ulint		has_search_latch;
 					/*!< TRUE if this trx has latched the

=== modified file 'storage/innobase/include/trx0types.h'
--- a/storage/innobase/include/trx0types.h	2011-01-18 10:55:35 +0000
+++ b/storage/innobase/include/trx0types.h	2011-05-11 04:51:01 +0000
@@ -39,8 +39,8 @@ the terminating NUL character. */
 enum trx_que_enum {
 	TRX_QUE_RUNNING,		/*!< transaction is running */
 	TRX_QUE_LOCK_WAIT,		/*!< transaction is waiting for
-				       	a lock */
-	TRX_QUE_ROLLING_BACK, 		/*!< transaction is rolling back */
+					a lock */
+	TRX_QUE_ROLLING_BACK,		/*!< transaction is rolling back */
 	TRX_QUE_COMMITTING		/*!< transaction is committing */
 };
 

=== modified file 'storage/innobase/include/ut0ut.h'
--- a/storage/innobase/include/ut0ut.h	2011-04-06 06:35:25 +0000
+++ b/storage/innobase/include/ut0ut.h	2011-05-17 11:42:10 +0000
@@ -98,16 +98,6 @@ do {								\
 #define UT_MIN(a, b)	((a) < (b) ? (a) : (b))
 #define UT_MAX(a, b)	((a) > (b) ? (a) : (b))
 
-/********************************************************//**
-Gets the high 32 bits in a ulint. That is makes a shift >> 32,
-but since there seem to be compiler bugs in both gcc and Visual C++,
-we do this by a special conversion.
-@return	a >> 32 */
-UNIV_INTERN
-ulint
-ut_get_high32(
-/*==========*/
-	ulint	a);	/*!< in: ulint */
 /******************************************************//**
 Calculates the minimum of two ulints.
 @return	minimum */

=== modified file 'storage/innobase/log/log0recv.c'
--- a/storage/innobase/log/log0recv.c	2011-04-21 09:24:45 +0000
+++ b/storage/innobase/log/log0recv.c	2011-05-17 11:42:10 +0000
@@ -3443,19 +3443,15 @@ recv_reset_log_files_for_backup(
 		}
 
 		fprintf(stderr,
-			"Setting log file size to %lu %lu\n",
-			(ulong) ut_get_high32(log_file_size),
-			(ulong) log_file_size & 0xFFFFFFFFUL);
-
-		success = os_file_set_size(name, log_file,
-					   log_file_size & 0xFFFFFFFFUL,
-					   ut_get_high32(log_file_size));
+			"Setting log file size to %llu\n",
+			log_file_size);
+
+		success = os_file_set_size(name, log_file, log_file_size);
 
 		if (!success) {
 			fprintf(stderr,
-				"InnoDB: Cannot set %s size to %lu %lu\n",
-				name, (ulong) ut_get_high32(log_file_size),
-				(ulong) (log_file_size & 0xFFFFFFFFUL));
+				"InnoDB: Cannot set %s size to %llu\n",
+				name, log_file_size);
 			exit(1);
 		}
 
@@ -3509,9 +3505,8 @@ log_group_recover_from_archive_file(
 	ulint		len;
 	ibool		ret;
 	byte*		buf;
-	ulint		read_offset;
-	ulint		file_size;
-	ulint		file_size_high;
+	os_offset_t	read_offset;
+	os_offset_t	file_size;
 	int		input_char;
 	char		name[10000];
 
@@ -3553,10 +3548,8 @@ ask_again:
 		}
 	}
 
-	ret = os_file_get_size(file_handle, &file_size, &file_size_high);
-	ut_a(ret);
-
-	ut_a(file_size_high == 0);
+	file_size = os_file_get_size(file_handle);
+	ut_a(file_size != (os_offset_t) -1);
 
 	fprintf(stderr, "InnoDB: Opened archived log file %s\n", name);
 

=== modified file 'storage/innobase/os/os0file.c'
--- a/storage/innobase/os/os0file.c	2011-04-21 09:24:45 +0000
+++ b/storage/innobase/os/os0file.c	2011-05-18 10:05:38 +0000
@@ -168,9 +168,7 @@ struct os_aio_slot_struct{
 					write */
 	byte*		buf;		/*!< buffer used in i/o */
 	ulint		type;		/*!< OS_FILE_READ or OS_FILE_WRITE */
-	ulint		offset;		/*!< 32 low bits of file offset in
-					bytes */
-	ulint		offset_high;	/*!< 32 high bits of file offset */
+	os_offset_t	offset;		/*!< file offset in bytes */
 	os_file_t	file;		/*!< file where to read or write */
 	const char*	name;		/*!< file name or path */
 	ibool		io_already_done;/*!< used only in simulated aio:
@@ -1863,76 +1861,33 @@ os_file_close_no_error_handling(
 
 /***********************************************************************//**
 Gets a file size.
-@return	TRUE if success */
+@return	file size, or (os_offset_t) -1 on failure */
 UNIV_INTERN
-ibool
+os_offset_t
 os_file_get_size(
 /*=============*/
-	os_file_t	file,	/*!< in: handle to a file */
-	ulint*		size,	/*!< out: least significant 32 bits of file
-				size */
-	ulint*		size_high)/*!< out: most significant 32 bits of size */
+	os_file_t	file)	/*!< in: handle to a file */
 {
 #ifdef __WIN__
-	DWORD	high;
-	DWORD	low;
+	os_offset_t	offset;
+	DWORD		high;
+	DWORD		low;
 
 	low = GetFileSize(file, &high);
 
 	if ((low == 0xFFFFFFFF) && (GetLastError() != NO_ERROR)) {
-		return(FALSE);
+		return((os_offset_t) -1);
 	}
 
-	*size = low;
-	*size_high = high;
+	offset = (os_offset_t) low | ((os_offset_t) high << 32);
 
-	return(TRUE);
+	return(offset);
 #else
-	off_t	offs;
-
-	offs = lseek(file, 0, SEEK_END);
-
-	if (offs == ((off_t)-1)) {
-
-		return(FALSE);
-	}
-
-	if (sizeof(off_t) > 4) {
-		*size = (ulint)(offs & 0xFFFFFFFFUL);
-		*size_high = (ulint)(offs >> 32);
-	} else {
-		*size = (ulint) offs;
-		*size_high = 0;
-	}
-
-	return(TRUE);
+	return((os_offset_t) lseek(file, 0, SEEK_END));
 #endif
 }
 
 /***********************************************************************//**
-Gets file size as a 64-bit integer ib_int64_t.
-@return	size in bytes, -1 if error */
-UNIV_INTERN
-ib_int64_t
-os_file_get_size_as_iblonglong(
-/*===========================*/
-	os_file_t	file)	/*!< in: handle to a file */
-{
-	ulint	size;
-	ulint	size_high;
-	ibool	success;
-
-	success = os_file_get_size(file, &size, &size_high);
-
-	if (!success) {
-
-		return(-1);
-	}
-
-	return((((ib_int64_t)size_high) << 32) + (ib_int64_t)size);
-}
-
-/***********************************************************************//**
 Write the specified number of zeros to a newly created file.
 @return	TRUE if success */
 UNIV_INTERN
@@ -1942,24 +1897,18 @@ os_file_set_size(
 	const char*	name,	/*!< in: name of the file or path as a
 				null-terminated string */
 	os_file_t	file,	/*!< in: handle to a file */
-	ulint		size,	/*!< in: least significant 32 bits of file
-				size */
-	ulint		size_high)/*!< in: most significant 32 bits of size */
+	os_offset_t	size)	/*!< in: file size */
 {
-	ib_int64_t	current_size;
-	ib_int64_t	desired_size;
+	os_offset_t	current_size;
 	ibool		ret;
 	byte*		buf;
 	byte*		buf2;
 	ulint		buf_size;
 
-	ut_a(size == (size & 0xFFFFFFFF));
-
 	current_size = 0;
-	desired_size = (ib_int64_t)size + (((ib_int64_t)size_high) << 32);
 
 	/* Write up to 1 megabyte at a time. */
-	buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE))
+	buf_size = ut_min(64, (ulint) (size / UNIV_PAGE_SIZE))
 		* UNIV_PAGE_SIZE;
 	buf2 = ut_malloc(buf_size + UNIV_PAGE_SIZE);
 
@@ -1969,42 +1918,39 @@ os_file_set_size(
 	/* Write buffer full of zeros */
 	memset(buf, 0, buf_size);
 
-	if (desired_size >= (ib_int64_t)(100 * 1024 * 1024)) {
+	if (size >= (os_offset_t) 100 << 20) {
 
 		fprintf(stderr, "InnoDB: Progress in MB:");
 	}
 
-	while (current_size < desired_size) {
+	while (current_size < size) {
 		ulint	n_bytes;
 
-		if (desired_size - current_size < (ib_int64_t) buf_size) {
-			n_bytes = (ulint) (desired_size - current_size);
+		if (size - current_size < (os_offset_t) buf_size) {
+			n_bytes = (ulint) (size - current_size);
 		} else {
 			n_bytes = buf_size;
 		}
 
-		ret = os_file_write(name, file, buf,
-				    (ulint)(current_size & 0xFFFFFFFF),
-				    (ulint)(current_size >> 32),
-				    n_bytes);
+		ret = os_file_write(name, file, buf, current_size, n_bytes);
 		if (!ret) {
 			ut_free(buf2);
 			goto error_handling;
 		}
 
 		/* Print about progress for each 100 MB written */
-		if ((ib_int64_t) (current_size + n_bytes) / (ib_int64_t)(100 * 1024 * 1024)
-		    != current_size / (ib_int64_t)(100 * 1024 * 1024)) {
+		if ((current_size + n_bytes) / (100 << 20)
+		    != current_size / (100 << 20)) {
 
 			fprintf(stderr, " %lu00",
 				(ulong) ((current_size + n_bytes)
-					 / (ib_int64_t)(100 * 1024 * 1024)));
+					 / (100 << 20)));
 		}
 
 		current_size += n_bytes;
 	}
 
-	if (desired_size >= (ib_int64_t)(100 * 1024 * 1024)) {
+	if (size >= (os_offset_t) 100 << 20) {
 
 		fprintf(stderr, "\n");
 	}
@@ -2190,35 +2136,28 @@ os_file_flush_func(
 /*******************************************************************//**
 Does a synchronous read operation in Posix.
 @return	number of bytes read, -1 if error */
-static
+static __attribute__((nonnull, warn_unused_result))
 ssize_t
 os_file_pread(
 /*==========*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
 	ulint		n,	/*!< in: number of bytes to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset from where to read */
-	ulint		offset_high) /*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset)	/*!< in: file offset from where to read */
 {
 	off_t	offs;
 #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
 	ssize_t	n_bytes;
 #endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */
 
-	ut_a((offset & 0xFFFFFFFFUL) == offset);
+	ut_ad(n);
 
 	/* If off_t is > 4 bytes in size, then we assume we can pass a
 	64-bit address */
+	offs = (off_t) offset;
 
-	if (sizeof(off_t) > 4) {
-		offs = (off_t)offset + (((off_t)offset_high) << 32);
-
-	} else {
-		offs = (off_t)offset;
-
-		if (offset_high > 0) {
+	if (sizeof(off_t) <= 4) {
+		if (UNIV_UNLIKELY(offset != (os_offset_t) offs)) {
 			fprintf(stderr,
 				"InnoDB: Error: file read at offset > 4 GB\n");
 		}
@@ -2287,32 +2226,26 @@ os_file_pread(
 /*******************************************************************//**
 Does a synchronous write operation in Posix.
 @return	number of bytes written, -1 if error */
-static
+static __attribute__((nonnull, warn_unused_result))
 ssize_t
 os_file_pwrite(
 /*===========*/
 	os_file_t	file,	/*!< in: handle to a file */
 	const void*	buf,	/*!< in: buffer from where to write */
 	ulint		n,	/*!< in: number of bytes to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to write */
-	ulint		offset_high) /*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset)	/*!< in: file offset where to write */
 {
 	ssize_t	ret;
 	off_t	offs;
 
-	ut_a((offset & 0xFFFFFFFFUL) == offset);
+	ut_ad(n);
 
 	/* If off_t is > 4 bytes in size, then we assume we can pass a
 	64-bit address */
+	offs = (off_t) offset;
 
-	if (sizeof(off_t) > 4) {
-		offs = (off_t)offset + (((off_t)offset_high) << 32);
-	} else {
-		offs = (off_t)offset;
-
-		if (offset_high > 0) {
+	if (sizeof(off_t) <= 4) {
+		if (UNIV_UNLIKELY(offset != (os_offset_t) offs)) {
 			fprintf(stderr,
 				"InnoDB: Error: file write"
 				" at offset > 4 GB\n");
@@ -2419,10 +2352,7 @@ os_file_read_func(
 /*==============*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read */
-	ulint		offset_high, /*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read */
 	ulint		n)	/*!< in: number of bytes to read */
 {
 #ifdef __WIN__
@@ -2438,7 +2368,6 @@ os_file_read_func(
 
 	/* On 64-bit Windows, ulint is 64 bits. But offset and n should be
 	no more than 32 bits. */
-	ut_a((offset & 0xFFFFFFFFUL) == offset);
 	ut_a((n & 0xFFFFFFFFUL) == n);
 
 	os_n_file_reads++;
@@ -2449,8 +2378,8 @@ try_again:
 	ut_ad(buf);
 	ut_ad(n > 0);
 
-	low = (DWORD) offset;
-	high = (DWORD) offset_high;
+	low = (DWORD) offset & 0xFFFFFFFF;
+	high = (DWORD) (offset >> 32);
 
 	os_mutex_enter(os_file_count_mutex);
 	os_n_pending_reads++;
@@ -2501,7 +2430,7 @@ try_again:
 	os_bytes_read_since_printout += n;
 
 try_again:
-	ret = os_file_pread(file, buf, n, offset, offset_high);
+	ret = os_file_pread(file, buf, n, offset);
 
 	if ((ulint)ret == n) {
 
@@ -2509,10 +2438,9 @@ try_again:
 	}
 
 	fprintf(stderr,
-		"InnoDB: Error: tried to read %lu bytes at offset %lu %lu.\n"
+		"InnoDB: Error: tried to read %lu bytes at offset %llu.\n"
 		"InnoDB: Was only able to read %ld.\n",
-		(ulong)n, (ulong)offset_high,
-		(ulong)offset, (long)ret);
+		(ulong)n, offset, (long)ret);
 #endif /* __WIN__ */
 #ifdef __WIN__
 error_handling:
@@ -2551,10 +2479,7 @@ os_file_read_no_error_handling_func(
 /*================================*/
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read */
-	ulint		offset_high, /*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read */
 	ulint		n)	/*!< in: number of bytes to read */
 {
 #ifdef __WIN__
@@ -2570,7 +2495,6 @@ os_file_read_no_error_handling_func(
 
 	/* On 64-bit Windows, ulint is 64 bits. But offset and n should be
 	no more than 32 bits. */
-	ut_a((offset & 0xFFFFFFFFUL) == offset);
 	ut_a((n & 0xFFFFFFFFUL) == n);
 
 	os_n_file_reads++;
@@ -2581,8 +2505,8 @@ try_again:
 	ut_ad(buf);
 	ut_ad(n > 0);
 
-	low = (DWORD) offset;
-	high = (DWORD) offset_high;
+	low = (DWORD) offset & 0xFFFFFFFF;
+	high = (DWORD) (offset >> 32);
 
 	os_mutex_enter(os_file_count_mutex);
 	os_n_pending_reads++;
@@ -2633,7 +2557,7 @@ try_again:
 	os_bytes_read_since_printout += n;
 
 try_again:
-	ret = os_file_pread(file, buf, n, offset, offset_high);
+	ret = os_file_pread(file, buf, n, offset);
 
 	if ((ulint)ret == n) {
 
@@ -2688,10 +2612,7 @@ os_file_write_func(
 				null-terminated string */
 	os_file_t	file,	/*!< in: handle to a file */
 	const void*	buf,	/*!< in: buffer from which to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to write */
-	ulint		offset_high, /*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to write */
 	ulint		n)	/*!< in: number of bytes to write */
 {
 #ifdef __WIN__
@@ -2708,7 +2629,6 @@ os_file_write_func(
 
 	/* On 64-bit Windows, ulint is 64 bits. But offset and n should be
 	no more than 32 bits. */
-	ut_a((offset & 0xFFFFFFFFUL) == offset);
 	ut_a((n & 0xFFFFFFFFUL) == n);
 
 	os_n_file_writes++;
@@ -2717,8 +2637,8 @@ os_file_write_func(
 	ut_ad(buf);
 	ut_ad(n > 0);
 retry:
-	low = (DWORD) offset;
-	high = (DWORD) offset_high;
+	low = (DWORD) offset & 0xFFFFFFFF;
+	high = (DWORD) (offset >> 32);
 
 	os_mutex_enter(os_file_count_mutex);
 	os_n_pending_writes++;
@@ -2750,14 +2670,13 @@ retry:
 		fprintf(stderr,
 			"  InnoDB: Error: File pointer positioning to"
 			" file %s failed at\n"
-			"InnoDB: offset %lu %lu. Operating system"
+			"InnoDB: offset %llu. Operating system"
 			" error number %lu.\n"
 			"InnoDB: Some operating system error numbers"
 			" are described at\n"
 			"InnoDB: "
 			REFMAN "operating-system-error-codes.html\n",
-			name, (ulong) offset_high, (ulong) offset,
-			(ulong) GetLastError());
+			name, offset, (ulong) GetLastError());
 
 		return(FALSE);
 	}
@@ -2808,7 +2727,7 @@ retry:
 
 		fprintf(stderr,
 			"  InnoDB: Error: Write to file %s failed"
-			" at offset %lu %lu.\n"
+			" at offset %llu.\n"
 			"InnoDB: %lu bytes should have been written,"
 			" only %lu were written.\n"
 			"InnoDB: Operating system error number %lu.\n"
@@ -2816,7 +2735,7 @@ retry:
 			" support files of this size.\n"
 			"InnoDB: Check also that the disk is not full"
 			" or a disk quota exceeded.\n",
-			name, (ulong) offset_high, (ulong) offset,
+			name, offset,
 			(ulong) n, (ulong) len, (ulong) err);
 
 		if (strerror((int)err) != NULL) {
@@ -2838,7 +2757,7 @@ retry:
 #else
 	ssize_t	ret;
 
-	ret = os_file_pwrite(file, buf, n, offset, offset_high);
+	ret = os_file_pwrite(file, buf, n, offset);
 
 	if ((ulint)ret == n) {
 
@@ -2851,7 +2770,7 @@ retry:
 
 		fprintf(stderr,
 			"  InnoDB: Error: Write to file %s failed"
-			" at offset %lu %lu.\n"
+			" at offset %llu.\n"
 			"InnoDB: %lu bytes should have been written,"
 			" only %ld were written.\n"
 			"InnoDB: Operating system error number %lu.\n"
@@ -2859,7 +2778,7 @@ retry:
 			" support files of this size.\n"
 			"InnoDB: Check also that the disk is not full"
 			" or a disk quota exceeded.\n",
-			name, offset_high, offset, n, (long int)ret,
+			name, offset, n, (long int)ret,
 			(ulint)errno);
 		if (strerror(errno) != NULL) {
 			fprintf(stderr,
@@ -3654,10 +3573,7 @@ os_aio_array_reserve_slot(
 				null-terminated string */
 	void*		buf,	/*!< in: buffer where to read or from which
 				to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset */
-	ulint		offset_high, /*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset */
 	ulint		len)	/*!< in: length of the block to read or write */
 {
 	os_aio_slot_t*	slot = NULL;
@@ -3745,13 +3661,12 @@ found:
 	slot->type     = type;
 	slot->buf      = buf;
 	slot->offset   = offset;
-	slot->offset_high = offset_high;
 	slot->io_already_done = FALSE;
 
 #ifdef WIN_ASYNC_IO
 	control = &(slot->control);
-	control->Offset = (DWORD)offset;
-	control->OffsetHigh = (DWORD)offset_high;
+	control->Offset = (DWORD) offset & 0xFFFFFFFF;
+	control->OffsetHigh = (DWORD) (offset >> 32);
 	ResetEvent(slot->handle);
 
 #elif defined(LINUX_NATIVE_AIO)
@@ -3763,14 +3678,10 @@ found:
 
 	/* Check if we are dealing with 64 bit arch.
 	If not then make sure that offset fits in 32 bits. */
-	if (sizeof(aio_offset) == 8) {
-		aio_offset = offset_high;
-		aio_offset <<= 32;
-		aio_offset += offset;
-	} else {
-		ut_a(offset_high == 0);
-		aio_offset = offset;
-	}
+	aio_offset = (off_t) offset;
+
+	ut_a(sizeof(aio_offset) >= sizeof(offset)
+	     || ((os_offset_t) aio_offset) == offset);
 
 	iocb = &slot->control;
 
@@ -3785,7 +3696,6 @@ found:
 	slot->n_bytes = 0;
 	slot->ret = 0;
 	/*fprintf(stderr, "Filled up Linux native iocb.\n");*/
-	
 
 skip_native_aio:
 #endif /* LINUX_NATIVE_AIO */
@@ -4021,10 +3931,7 @@ os_aio_func(
 	os_file_t	file,	/*!< in: handle to a file */
 	void*		buf,	/*!< in: buffer where to read or from which
 				to write */
-	ulint		offset,	/*!< in: least significant 32 bits of file
-				offset where to read or write */
-	ulint		offset_high, /*!< in: most significant 32 bits of
-				offset */
+	os_offset_t	offset,	/*!< in: file offset where to read or write */
 	ulint		n,	/*!< in: number of bytes to read or write */
 	fil_node_t*	message1,/*!< in: message for the aio handler
 				(can be used to identify a completed
@@ -4071,16 +3978,21 @@ os_aio_func(
 		Windows async i/o, Windows does not allow us to use
 		ordinary synchronous os_file_read etc. on the same file,
 		therefore we have built a special mechanism for synchronous
-		wait in the Windows case. */
+		wait in the Windows case.
+		Also note that the Performance Schema instrumentation has
+		been performed by current os_aio_func()'s wrapper function
+		pfs_os_aio_func(). So we would no longer need to call
+		Performance Schema instrumented os_file_read() and
+		os_file_write(). Instead, we should use os_file_read_func()
+		and os_file_write_func() */
 
 		if (type == OS_FILE_READ) {
-			return(os_file_read(file, buf, offset,
-					    offset_high, n));
+			return(os_file_read_func(file, buf, offset, n));
 		}
 
 		ut_a(type == OS_FILE_WRITE);
 
-		return(os_file_write(name, file, buf, offset, offset_high, n));
+		return(os_file_write_func(name, file, buf, offset, n));
 	}
 
 try_again:
@@ -4116,7 +4028,7 @@ try_again:
 	}
 
 	slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-					 name, buf, offset, offset_high, n);
+					 name, buf, offset, n);
 	if (type == OS_FILE_READ) {
 		if (srv_use_native_aio) {
 			os_n_file_reads++;
@@ -4666,7 +4578,7 @@ os_aio_simulated_handle(
 	ulint		n_consecutive;
 	ulint		total_len;
 	ulint		offs;
-	ulint		lowest_offset;
+	os_offset_t	lowest_offset;
 	ulint		biggest_age;
 	ulint		age;
 	byte*		combined_buf;
@@ -4753,7 +4665,7 @@ restart:
 	then pick the one at the lowest offset. */
 
 	biggest_age = 0;
-	lowest_offset = ULINT_MAX;
+	lowest_offset = IB_UINT64_MAX;
 
 	for (i = 0; i < n; i++) {
 		slot = os_aio_array_get_nth_slot(array, i + segment * n);
@@ -4782,7 +4694,7 @@ restart:
 		lowest offset in the array (we ignore the high 32 bits of the
 		offset in these heuristics) */
 
-		lowest_offset = ULINT_MAX;
+		lowest_offset = IB_UINT64_MAX;
 
 		for (i = 0; i < n; i++) {
 			slot = os_aio_array_get_nth_slot(array,
@@ -4822,9 +4734,6 @@ consecutive_loop:
 
 		if (slot2->reserved && slot2 != slot
 		    && slot2->offset == slot->offset + slot->len
-		    /* check that sum does not wrap over */
-		    && slot->offset + slot->len > slot->offset
-		    && slot2->offset_high == slot->offset_high
 		    && slot2->type == slot->type
 		    && slot2->file == slot->file) {
 
@@ -4891,20 +4800,18 @@ consecutive_loop:
 
 	if (os_aio_print_debug) {
 		fprintf(stderr,
-			"InnoDB: doing i/o of type %lu at offset %lu %lu,"
+			"InnoDB: doing i/o of type %lu at offset %llu,"
 			" length %lu\n",
-			(ulong) slot->type, (ulong) slot->offset_high,
-			(ulong) slot->offset, (ulong) total_len);
+			(ulong) slot->type, slot->offset, (ulong) total_len);
 	}
 
 	/* Do the i/o with ordinary, synchronous i/o functions: */
 	if (slot->type == OS_FILE_WRITE) {
 		ret = os_file_write(slot->name, slot->file, combined_buf,
-				    slot->offset, slot->offset_high,
-				    total_len);
+				    slot->offset, total_len);
 	} else {
 		ret = os_file_read(slot->file, combined_buf,
-				   slot->offset, slot->offset_high, total_len);
+				   slot->offset, total_len);
 	}
 
 	ut_a(ret);

=== modified file 'storage/innobase/page/page0page.c'
--- a/storage/innobase/page/page0page.c	2011-03-22 12:34:16 +0000
+++ b/storage/innobase/page/page0page.c	2011-05-09 08:48:47 +0000
@@ -1253,28 +1253,6 @@ page_move_rec_list_start(
 
 	return(TRUE);
 }
-
-/***********************************************************************//**
-This is a low-level operation which is used in a database index creation
-to update the page number of a created B-tree to a data dictionary record. */
-UNIV_INTERN
-void
-page_rec_write_index_page_no(
-/*=========================*/
-	rec_t*	rec,	/*!< in: record to update */
-	ulint	i,	/*!< in: index of the field to update */
-	ulint	page_no,/*!< in: value to write */
-	mtr_t*	mtr)	/*!< in: mtr */
-{
-	byte*	data;
-	ulint	len;
-
-	data = rec_get_nth_field_old(rec, i, &len);
-
-	ut_ad(len == 4);
-
-	mlog_write_ulint(data, page_no, MLOG_4BYTES, mtr);
-}
 #endif /* !UNIV_HOTBACKUP */
 
 /**************************************************************//**

=== modified file 'storage/innobase/row/row0merge.c'
--- a/storage/innobase/row/row0merge.c	2011-05-04 09:54:04 +0000
+++ b/storage/innobase/row/row0merge.c	2011-05-22 20:17:42 +0000
@@ -701,7 +701,7 @@ row_merge_read(
 					elements */
 	row_merge_block_t*	buf)	/*!< out: data */
 {
-	ib_uint64_t	ofs = ((ib_uint64_t) offset) * sizeof *buf;
+	os_offset_t	ofs = ((os_offset_t) offset) * sizeof *buf;
 	ibool		success;
 
 #ifdef UNIV_DEBUG
@@ -712,9 +712,7 @@ row_merge_read(
 #endif /* UNIV_DEBUG */
 
 	success = os_file_read_no_error_handling(OS_FILE_FROM_FD(fd), buf,
-						 (ulint) (ofs & 0xFFFFFFFF),
-						 (ulint) (ofs >> 32),
-						 sizeof *buf);
+						 ofs, sizeof *buf);
 #ifdef POSIX_FADV_DONTNEED
 	/* Each block is read exactly once.  Free up the file cache. */
 	posix_fadvise(fd, ofs, sizeof *buf, POSIX_FADV_DONTNEED);
@@ -742,13 +740,10 @@ row_merge_write(
 	const void*	buf)	/*!< in: data */
 {
 	size_t		buf_len = sizeof(row_merge_block_t);
-	ib_uint64_t	ofs = buf_len * (ib_uint64_t) offset;
+	os_offset_t	ofs = buf_len * (os_offset_t) offset;
 	ibool		ret;
 
-	ret = os_file_write("(merge)", OS_FILE_FROM_FD(fd), buf,
-			    (ulint) (ofs & 0xFFFFFFFF),
-			    (ulint) (ofs >> 32),
-			    buf_len);
+	ret = os_file_write("(merge)", OS_FILE_FROM_FD(fd), buf, ofs, buf_len);
 
 #ifdef UNIV_DEBUG
 	if (row_merge_print_block_write) {

=== modified file 'storage/innobase/row/row0mysql.c'
--- a/storage/innobase/row/row0mysql.c	2011-05-04 09:54:04 +0000
+++ b/storage/innobase/row/row0mysql.c	2011-05-22 20:19:06 +0000
@@ -2966,7 +2966,7 @@ row_truncate_table_for_mysql(
 		rec = btr_pcur_get_rec(&pcur);
 
 		if (root_page_no != FIL_NULL) {
-			page_rec_write_index_page_no(
+			page_rec_write_field(
 				rec, DICT_SYS_INDEXES_PAGE_NO_FIELD,
 				root_page_no, &mtr);
 			/* We will need to commit and restart the

=== modified file 'storage/innobase/row/row0vers.c'
--- a/storage/innobase/row/row0vers.c	2011-01-25 10:51:35 +0000
+++ b/storage/innobase/row/row0vers.c	2011-05-04 11:29:29 +0000
@@ -113,8 +113,6 @@ row_vers_impl_x_locked_low(
 	modify rec, and does not necessarily have an implicit x-lock
 	on rec. */
 
-	mtr_s_lock(&purge_sys->latch, mtr);
-
 	for (version = clust_rec;; version = prev_version) {
 		ulint		err;
 		row_ext_t*	ext;
@@ -189,9 +187,9 @@ row_vers_impl_x_locked_low(
 		would require rec to be in a different state. */
 
 		/* The previous version of clust_rec must be
-		accessible, because clust_rec was not a fresh insert
-		and we are holding purge_sys->latch. There is no
-		guarantee that the transaction is still active. */
+		accessible, because clust_rec was not a fresh insert.
+		There is no guarantee that the transaction is still
+		active. */
 
 		ut_ad(err == DB_SUCCESS);
 
@@ -285,8 +283,10 @@ row_vers_impl_x_locked(
 
 	/* Search for the clustered index record. The latch on the
 	page of clust_rec locks the top of the stack of versions. The
-	bottom of the version stack will be locked by
-	purge_sys->latch. */
+	bottom of the version stack is not locked; oldest versions may
+	disappear by the fact that transactions may be committed and
+	collected by the purge. This is not a problem, because we are
+	only interested in active transactions. */
 
 	clust_rec = row_get_clust_rec(
 		BTR_SEARCH_LEAF, rec, index, &clust_index, &mtr);
@@ -334,15 +334,7 @@ row_vers_must_preserve_del_marked(
 
 	mtr_s_lock(&(purge_sys->latch), mtr);
 
-	if (trx_purge_update_undo_must_exist(trx_id)) {
-
-		/* A purge operation is not yet allowed to remove this
-		delete marked record */
-
-		return(TRUE);
-	}
-
-	return(FALSE);
+	return(!read_view_sees_trx_id(purge_sys->view, trx_id));
 }
 
 /*****************************************************************//**
@@ -382,7 +374,6 @@ row_vers_old_has_index_entry(
 #ifdef UNIV_SYNC_DEBUG
 	ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
 #endif /* UNIV_SYNC_DEBUG */
-	mtr_s_lock(&(purge_sys->latch), mtr);
 
 	clust_index = dict_table_get_first_index(index->table);
 
@@ -395,7 +386,11 @@ row_vers_old_has_index_entry(
 	if (also_curr && !rec_get_deleted_flag(rec, comp)) {
 		row_ext_t*	ext;
 
-		/* The stack of versions is locked by mtr.
+		/* The top of the stack of versions is locked by the
+		mtr holding a latch on the page containing the
+		clustered index record. The bottom of the stack is
+		locked by the fact that the purge_sys->view must
+		'overtake' any read view of an active transaction.
 		Thus, it is safe to fetch the prefixes for
 		externally stored columns. */
 		row = row_build(ROW_COPY_POINTERS, clust_index,
@@ -535,7 +530,6 @@ row_vers_build_for_consistent_read(
 
 	ut_ad(!read_view_sees_trx_id(view, trx_id));
 
-	rw_lock_s_lock(&(purge_sys->latch));
 	version = rec;
 
 	for (;;) {
@@ -615,7 +609,6 @@ row_vers_build_for_consistent_read(
 	}/* for (;;) */
 
 	mem_heap_free(heap);
-	rw_lock_s_unlock(&(purge_sys->latch));
 
 	return(err);
 }
@@ -661,12 +654,6 @@ row_vers_build_for_semi_consistent_read(
 
 	ut_ad(rec_offs_validate(rec, index, *offsets));
 
-	rw_lock_s_lock(&(purge_sys->latch));
-	/* The S-latch on purge_sys prevents the purge view from
-	changing.  Thus, if we have an uncommitted transaction at
-	this point, then purge cannot remove its undo log even if
-	the transaction could commit now. */
-
 	version = rec;
 
 	for (;;) {
@@ -759,7 +746,6 @@ row_vers_build_for_semi_consistent_read(
 	if (heap) {
 		mem_heap_free(heap);
 	}
-	rw_lock_s_unlock(&(purge_sys->latch));
 
 	return(err);
 }

=== modified file 'storage/innobase/srv/srv0start.c'
--- a/storage/innobase/srv/srv0start.c	2011-04-19 04:17:07 +0000
+++ b/storage/innobase/srv/srv0start.c	2011-05-17 11:42:10 +0000
@@ -520,32 +520,6 @@ srv_normalize_path_for_win(
 
 #ifndef UNIV_HOTBACKUP
 /*********************************************************************//**
-Calculates the low 32 bits when a file size which is given as a number
-database pages is converted to the number of bytes.
-@return	low 32 bytes of file size when expressed in bytes */
-static
-ulint
-srv_calc_low32(
-/*===========*/
-	ib_uint64_t	file_size)	/*!< in: file size in database pages */
-{
-	return((ulint) (0xFFFFFFFFUL & (file_size << UNIV_PAGE_SIZE_SHIFT)));
-}
-
-/*********************************************************************//**
-Calculates the high 32 bits when a file size which is given as a number
-of database pages is converted to the number of bytes.
-@return	high 32 bytes of file size when expressed in bytes */
-static
-ulint
-srv_calc_high32(
-/*============*/
-	ib_uint64_t	file_size)	/*!< in: file size in database pages */
-{
-	return((ulint) (file_size >> (32 - UNIV_PAGE_SIZE_SHIFT)));
-}
-
-/*********************************************************************//**
 Creates or opens the log files and closes them.
 @return	DB_SUCCESS or error code */
 static
@@ -562,11 +536,10 @@ open_or_create_log_file(
 	ulint	k,			/*!< in: log group number */
 	ulint	i)			/*!< in: log file number in group */
 {
-	ibool	ret;
-	ulint	size;
-	ulint	size_high;
-	char	name[10000];
-	ulint	dirnamelen;
+	ibool		ret;
+	os_offset_t	size;
+	char		name[10000];
+	ulint		dirnamelen;
 
 	UT_NOT_USED(create_new_db);
 
@@ -614,20 +587,20 @@ open_or_create_log_file(
 			return(DB_ERROR);
 		}
 
-		ret = os_file_get_size(files[i], &size, &size_high);
-		ut_a(ret);
+		size = os_file_get_size(files[i]);
+		ut_a(size != (os_offset_t) -1);
 
-		if (size != srv_calc_low32(srv_log_file_size)
-		    || size_high != srv_calc_high32(srv_log_file_size)) {
+		if (UNIV_UNLIKELY(size != (os_offset_t) srv_log_file_size
+				  << UNIV_PAGE_SIZE_SHIFT)) {
 
 			fprintf(stderr,
 				"InnoDB: Error: log file %s is"
-				" of different size %lu %lu bytes\n"
+				" of different size %llu bytes\n"
 				"InnoDB: than specified in the .cnf"
-				" file %lu %lu bytes!\n",
-				name, (ulong) size_high, (ulong) size,
-				(ulong) srv_calc_high32(srv_log_file_size),
-				(ulong) srv_calc_low32(srv_log_file_size));
+				" file %llu bytes!\n",
+				name, size,
+				(os_offset_t) srv_log_file_size
+				<< UNIV_PAGE_SIZE_SHIFT);
 
 			return(DB_ERROR);
 		}
@@ -654,8 +627,8 @@ open_or_create_log_file(
 			" full: wait...\n");
 
 		ret = os_file_set_size(name, files[i],
-				       srv_calc_low32(srv_log_file_size),
-				       srv_calc_high32(srv_log_file_size));
+				       (os_offset_t) srv_log_file_size
+				       << UNIV_PAGE_SIZE_SHIFT);
 		if (!ret) {
 			fprintf(stderr,
 				"InnoDB: Error in creating %s:"
@@ -731,14 +704,13 @@ open_or_create_data_files(
 	ulint*		sum_of_new_sizes)/*!< out: sum of sizes of the
 					new files added */
 {
-	ibool	ret;
-	ulint	i;
-	ibool	one_opened	= FALSE;
-	ibool	one_created	= FALSE;
-	ulint	size;
-	ulint	size_high;
-	ulint	rounded_size_pages;
-	char	name[10000];
+	ibool		ret;
+	ulint		i;
+	ibool		one_opened	= FALSE;
+	ibool		one_created	= FALSE;
+	os_offset_t	size;
+	ulint		rounded_size_pages;
+	char		name[10000];
 
 	if (srv_n_data_files >= 1000) {
 		fprintf(stderr, "InnoDB: can only have < 1000 data files\n"
@@ -864,13 +836,11 @@ open_or_create_data_files(
 				goto skip_size_check;
 			}
 
-			ret = os_file_get_size(files[i], &size, &size_high);
-			ut_a(ret);
+			size = os_file_get_size(files[i]);
+			ut_a(size != (os_offset_t) -1);
 			/* Round size downward to megabytes */
 
-			rounded_size_pages
-				= (size / (1024 * 1024) + 4096 * size_high)
-					<< (20 - UNIV_PAGE_SIZE_SHIFT);
+			rounded_size_pages = size >> UNIV_PAGE_SIZE_SHIFT;
 
 			if (i == srv_n_data_files - 1
 			    && srv_auto_extend_last_data_file) {
@@ -959,8 +929,8 @@ skip_size_check:
 
 			ret = os_file_set_size(
 				name, files[i],
-				srv_calc_low32(srv_data_file_sizes[i]),
-				srv_calc_high32(srv_data_file_sizes[i]));
+				(os_offset_t) srv_data_file_sizes[i]
+				<< UNIV_PAGE_SIZE_SHIFT);
 
 			if (!ret) {
 				fprintf(stderr,
@@ -970,8 +940,7 @@ skip_size_check:
 				return(DB_ERROR);
 			}
 
-			*sum_of_new_sizes = *sum_of_new_sizes
-				+ srv_data_file_sizes[i];
+			*sum_of_new_sizes += srv_data_file_sizes[i];
 		}
 
 		ret = os_file_close(files[i]);
@@ -1464,7 +1433,7 @@ innobase_start_or_create_for_mysql(void)
 	if (sum_of_new_sizes < 10485760 / UNIV_PAGE_SIZE) {
 		ut_print_timestamp(stderr);
 		fprintf(stderr,
-			" InnoDB: Error: tablespace size must be"
+			" InnoDB: Error: tablesapce size must be"
 			" at least 10 MB\n");
 
 		return(DB_ERROR);

=== modified file 'storage/innobase/trx/trx0purge.c'
--- a/storage/innobase/trx/trx0purge.c	2011-04-28 07:33:49 +0000
+++ b/storage/innobase/trx/trx0purge.c	2011-05-19 09:19:12 +0000
@@ -80,25 +80,6 @@ trx_purge_fetch_next_rec(
 					handled */
 	mem_heap_t*	heap);		/*!< in: memory heap where copied */
 
-/*****************************************************************//**
-Checks if trx_id is >= purge_view: then it is guaranteed that its update
-undo log still exists in the system.
-@return TRUE if is sure that it is preserved, also if the function
-returns FALSE, it is possible that the undo log still exists in the
-system */
-UNIV_INTERN
-ibool
-trx_purge_update_undo_must_exist(
-/*=============================*/
-	trx_id_t	trx_id)	/*!< in: transaction id */
-{
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
-
-	return(!read_view_sees_trx_id(purge_sys->view, trx_id));
-}
-
 /****************************************************************//**
 Builds a purge 'query' graph. The actual purge is performed by executing
 this query graph.
@@ -837,6 +818,7 @@ trx_purge_get_next_rec(
 	mtr_t		mtr;
 
 	ut_ad(purge_sys->next_stored);
+	ut_ad(purge_sys->iter.trx_no < purge_sys->view->low_limit_no);
 
 	space = purge_sys->rseg->space;
 	zip_size = purge_sys->rseg->zip_size;
@@ -954,9 +936,6 @@ trx_purge_fetch_next_rec(
 					handled */
 	mem_heap_t*	heap)		/*!< in: memory heap where copied */
 {
-	const read_view_t*	view = purge_sys->view;
-	const purge_iter_t	iter = purge_sys->iter;
-
 	if (!purge_sys->next_stored) {
 		trx_purge_choose_next_log();
 
@@ -972,7 +951,7 @@ trx_purge_fetch_next_rec(
 		}
 	}
 
-	if (iter.trx_no >= view->low_limit_no) {
+	if (purge_sys->iter.trx_no >= purge_sys->view->low_limit_no) {
 
 		return(NULL);
 	}
@@ -984,8 +963,6 @@ trx_purge_fetch_next_rec(
 		FALSE, purge_sys->rseg->id,
 		purge_sys->page_no, purge_sys->offset);
 
-	ut_ad(iter.trx_no < view->low_limit_no);
-
 	/* The following call will advance the stored values of the
 	purge iterator. */
 

=== modified file 'storage/innobase/trx/trx0rec.c'
--- a/storage/innobase/trx/trx0rec.c	2011-05-02 16:18:01 +0000
+++ b/storage/innobase/trx/trx0rec.c	2011-05-04 11:29:29 +0000
@@ -36,6 +36,7 @@ Created 3/26/1996 Heikki Tuuri
 #ifndef UNIV_HOTBACKUP
 #include "dict0dict.h"
 #include "ut0mem.h"
+#include "read0read.h"
 #include "row0ext.h"
 #include "row0upd.h"
 #include "que0que.h"
@@ -1383,11 +1384,13 @@ trx_undo_get_undo_rec(
 	trx_undo_rec_t** undo_rec,	/*!< out, own: copy of the record */
 	mem_heap_t*	heap)		/*!< in: memory heap where copied */
 {
-#ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
-#endif /* UNIV_SYNC_DEBUG */
+	ibool		missing_history;
+
+	rw_lock_s_lock(&purge_sys->latch);
+	missing_history = read_view_sees_trx_id(purge_sys->view, trx_id);
+	rw_lock_s_unlock(&purge_sys->latch);
 
-	if (!trx_purge_update_undo_must_exist(trx_id)) {
+	if (UNIV_UNLIKELY(missing_history)) {
 
 		/* It may be that the necessary undo log has already been
 		deleted */
@@ -1407,10 +1410,10 @@ trx_undo_get_undo_rec(
 #endif /* UNIV_DEBUG */
 
 /*******************************************************************//**
-Build a previous version of a clustered index record. This function checks
-that the caller has a latch on the index page of the clustered index record
-and an s-latch on the purge_view. This guarantees that the stack of versions
-is locked all the way down to the purge_view.
+Build a previous version of a clustered index record. The caller must
+hold a latch on the index page of the clustered index record, to
+guarantee that the stack of versions is locked all the way down to the
+purge_sys->view.
 @return DB_SUCCESS, or DB_MISSING_HISTORY if the previous version is
 earlier than purge_view, which means that it may have been removed */
 UNIV_INTERN
@@ -1451,7 +1454,7 @@ trx_undo_prev_version_build(
 	byte*		buf;
 	ulint		err;
 #ifdef UNIV_SYNC_DEBUG
-	ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
+	ut_ad(!rw_lock_own(&purge_sys->latch, RW_LOCK_SHARED));
 #endif /* UNIV_SYNC_DEBUG */
 	ut_ad(mtr_memo_contains_page(index_mtr, index_rec, MTR_MEMO_PAGE_S_FIX)
 	      || mtr_memo_contains_page(index_mtr, index_rec,

=== modified file 'storage/innobase/ut/ut0ut.c'
--- a/storage/innobase/ut/ut0ut.c	2011-04-27 21:49:19 +0000
+++ b/storage/innobase/ut/ut0ut.c	2011-05-17 11:42:10 +0000
@@ -93,26 +93,6 @@ reimplement this function. */
 #define	ut_gettimeofday		gettimeofday
 #endif
 
-/********************************************************//**
-Gets the high 32 bits in a ulint. That is makes a shift >> 32,
-but since there seem to be compiler bugs in both gcc and Visual C++,
-we do this by a special conversion.
-@return	a >> 32 */
-UNIV_INTERN
-ulint
-ut_get_high32(
-/*==========*/
-	ulint	a)	/*!< in: ulint */
-{
-	ib_int64_t	i;
-
-	i = (ib_int64_t)a;
-
-	i = i >> 32;
-
-	return((ulint)i);
-}
-
 /**********************************************************//**
 Returns system time. We do not specify the format of the time returned:
 the only way to manipulate it is to use the function ut_difftime.

=== modified file 'strings/ctype-uca.c'
--- a/strings/ctype-uca.c	2011-03-09 20:54:55 +0000
+++ b/strings/ctype-uca.c	2011-05-21 08:25:33 +0000
@@ -21974,7 +21974,7 @@ create_tailoring(CHARSET_INFO *cs, MY_CH
         {
           my_snprintf(loader->error, sizeof(loader->error),
                       "Can't reset before "
-                      "a primary ignorable character U+%04X", r->base[0]);
+                      "a primary ignorable character U+%04lX", r->base[0]);
           rc= 1;
           goto ex;
         }

No bundle (reason: revision is a merge).
Thread
bzr commit into mysql-trunk-mtr branch (bjorn.munch:3079) Bjorn Munch24 May