List:Commits« Previous MessageNext Message »
From:marko.makela Date:April 18 2012 6:54am
Subject:bzr push into mysql-trunk-wl5545 branch (marko.makela:3895 to 3896)
View as plain text  
 3896 Marko Mäkelä	2012-04-18 [merge]
      Merge mysql-trunk to mysql-trunk-wl5545.

    added:
      mysql-test/r/mysql_embedded_client_test.result
      mysql-test/suite/innodb/r/innodb-alter-discard.result
      mysql-test/suite/innodb/t/innodb-alter-discard.test
      mysql-test/t/mysql_embedded_client_test.test
    modified:
      mysql-test/suite/engines/funcs/t/crash_manytables_number.test
      mysql-test/suite/engines/funcs/t/ld_all_number_string_calendar_types.test
      mysql-test/suite/engines/funcs/t/se_join_cross.test
      mysql-test/suite/engines/funcs/t/se_join_default.test
      mysql-test/suite/engines/funcs/t/se_join_inner.test
      mysql-test/suite/engines/funcs/t/se_join_left.test
      mysql-test/suite/engines/funcs/t/se_join_natural_left.test
      mysql-test/suite/engines/funcs/t/se_join_natural_left_outer.test
      mysql-test/suite/engines/funcs/t/se_join_natural_right.test
      mysql-test/suite/engines/funcs/t/se_join_natural_right_outer.test
      mysql-test/suite/engines/funcs/t/se_join_right.test
      mysql-test/suite/engines/funcs/t/se_join_right_outer.test
      mysql-test/suite/engines/funcs/t/se_join_straight.test
      mysql-test/suite/engines/funcs/t/se_string_limit.test
      mysql-test/suite/engines/iuds/t/update_delete_number.test
      mysql-test/suite/innodb/r/innodb-index-online.result
      mysql-test/suite/innodb/t/innodb-index-online.test
      mysql-test/suite/innodb/t/innodb_bug30423.test
      mysql-test/suite/innodb/t/innodb_bug53290.test
      mysql-test/suite/parts/t/partition_float_myisam.test
      mysql-test/suite/rpl/r/rpl_binlog_index.result
      mysql-test/suite/rpl/t/rpl_binlog_index.test
      mysql-test/suite/rpl/t/rpl_innodb_bug28430.test
      mysql-test/suite/rpl/t/rpl_parallel_innodb.test
      mysql-test/suite/rpl/t/rpl_rotate_purge_deadlock.test
      mysql-test/suite/rpl/t/rpl_row_img_blobs.test
      mysql-test/suite/rpl/t/rpl_row_img_eng_full.test
      mysql-test/suite/rpl/t/rpl_row_img_idx_full.test
      mysql-test/suite/rpl/t/rpl_stop_slave.test
      mysql-test/suite/rpl/t/rpl_typeconv.test
      mysql-test/t/disabled.def
      mysql-test/t/index_merge_innodb.test
      mysql-test/t/innodb_explain_json_non_select_all.test
      mysql-test/t/innodb_explain_non_select_all.test
      mysql-test/t/innodb_explain_non_select_none.test
      mysql-test/t/mysql_client_test_embedded.test
      sql/handler.cc
      sql/item.cc
      sql/item.h
      sql/item_create.cc
      sql/item_strfunc.cc
      sql/item_strfunc.h
      sql/item_subselect.cc
      sql/item_xmlfunc.cc
      sql/sp_head.cc
      sql/sql_base.cc
      sql/sql_class.cc
      sql/sql_optimizer.cc
      sql/sql_parse.cc
      sql/sql_show.cc
      sql/sql_string.h
      sql/sql_table.cc
      sql/sql_yacc.yy
      storage/innobase/buf/buf0flu.cc
      storage/innobase/handler/handler0alter.cc
 3895 Marko Mäkelä	2012-04-17
      Bug#13972248 ORPHAN HIDDEN FTS_DOC_ID_INDEX LEFT AFTER DROPPING FULLTEXT INDEX
      
      ha_innobase::prepare_inplace_alter_table(): When the table would
      contain fulltext indexes before dropping indexes, and no fulltext
      indexes thereafter, drop the FTS_DOC_ID_INDEX if it does not exist
      in the MySQL table definition (it had been created internally in InnoDB).

    modified:
      mysql-test/suite/innodb/r/innodb-alter.result
      mysql-test/suite/innodb/t/innodb-alter.test
      storage/innobase/handler/handler0alter.cc
=== added file 'mysql-test/r/mysql_embedded_client_test.result'
--- a/mysql-test/r/mysql_embedded_client_test.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/mysql_embedded_client_test.result	revid:marko.makela@stripped-wfy0yktq5jxv7dgf
@@ -0,0 +1,5 @@
+#
+# Bug#13541194 : MTR TEST TO RUN EMBEDDED SERVER CLIENT TESTS IN MYSQL_CLIENT_TEST.C.
+#
+stopped the current server
+# 7. Restart the server and cleanup

=== modified file 'mysql-test/suite/engines/funcs/t/crash_manytables_number.test'
--- a/mysql-test/suite/engines/funcs/t/crash_manytables_number.test	revid:marko.makela@strippedxb3oc
+++ b/mysql-test/suite/engines/funcs/t/crash_manytables_number.test	revid:marko.makela@stripped5318-wfy0yktq5jxv7dgf
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/ld_all_number_string_calendar_types.test'
--- a/mysql-test/suite/engines/funcs/t/ld_all_number_string_calendar_types.test	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/engines/funcs/t/ld_all_number_string_calendar_types.test	revid:marko.makela@strippedy0yktq5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_cross.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_cross.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/engines/funcs/t/se_join_cross.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_default.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_default.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/engines/funcs/t/se_join_default.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_inner.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_inner.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/engines/funcs/t/se_join_inner.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_left.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_left.test	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/engines/funcs/t/se_join_left.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_natural_left.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_natural_left.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/engines/funcs/t/se_join_natural_left.test	revid:marko.makela@stripped5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_natural_left_outer.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_natural_left_outer.test	revid:marko.makela@stripped17200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/engines/funcs/t/se_join_natural_left_outer.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_natural_right.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_natural_right.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/engines/funcs/t/se_join_natural_right.test	revid:marko.makela@stripped5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_natural_right_outer.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_natural_right_outer.test	revid:marko.makela@stripped0417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/engines/funcs/t/se_join_natural_right_outer.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_right.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_right.test	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/engines/funcs/t/se_join_right.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_right_outer.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_right_outer.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/engines/funcs/t/se_join_right_outer.test	revid:marko.makela@strippedgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_join_straight.test'
--- a/mysql-test/suite/engines/funcs/t/se_join_straight.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/engines/funcs/t/se_join_straight.test	revid:marko.makela@stripped5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/funcs/t/se_string_limit.test'
--- a/mysql-test/suite/engines/funcs/t/se_string_limit.test	revid:marko.makela@stripped3oc
+++ b/mysql-test/suite/engines/funcs/t/se_string_limit.test	revid:marko.makela@strippedktq5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 --enable_warnings

=== modified file 'mysql-test/suite/engines/iuds/t/update_delete_number.test'
--- a/mysql-test/suite/engines/iuds/t/update_delete_number.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/engines/iuds/t/update_delete_number.test	revid:marko.makela@strippedktq5jxv7dgf
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 --disable_warnings
 DROP TABLE IF EXISTS t1,t2;
 --enable_warnings

=== added file 'mysql-test/suite/innodb/r/innodb-alter-discard.result'
--- a/mysql-test/suite/innodb/r/innodb-alter-discard.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb-alter-discard.result	revid:marko.makela@stripped65318-wfy0yktq5jxv7dgf
@@ -0,0 +1,15 @@
+SET GLOBAL innodb_file_per_table=1;
+CREATE TABLE t(a INT)ENGINE=InnoDB;
+call mtr.add_suppression("InnoDB: Error: trying to open a table, but could not$");
+call mtr.add_suppression("MySQL is trying to open a table handle but the \.ibd file for$");
+call mtr.add_suppression("InnoDB: Error: table 'test/t'$");
+SELECT * FROM t;
+ERROR 42S02: Table 'test.t' doesn't exist
+ALTER TABLE t ADD INDEX (a), ALGORITHM=INPLACE;
+ERROR 42S02: Table 'test.t' doesn't exist
+ALTER TABLE t1 ADD INDEX (a), ALGORITHM=COPY;
+ERROR 42S02: Table 'test.t1' doesn't exist
+call mtr.add_suppression("InnoDB: (Error|Warning): cannot delete tablespace ");
+ALTER TABLE t DISCARD TABLESPACE;
+ERROR HY000: Got error -1 from storage engine
+DROP TABLE t;

=== modified file 'mysql-test/suite/innodb/r/innodb-index-online.result'
--- a/mysql-test/suite/innodb/r/innodb-index-online.result	revid:marko.makela@stripped
+++ b/mysql-test/suite/innodb/r/innodb-index-online.result	revid:marko.makela@strippedxv7dgf
@@ -4,6 +4,9 @@ SET DEBUG='d,query,debug_sync_exec:i:t:A
 call mtr.add_suppression("InnoDB: Warning: Small buffer pool size");
 call mtr.add_suppression("Cannot find index .*c2 in InnoDB index translation table");
 call mtr.add_suppression("Find index .*c2 in InnoDB index list but not its MySQL index number");
+call mtr.add_suppression("InnoDB: Error: table 'test/t1'$");
+call mtr.add_suppression("MySQL is trying to open a table handle but the .ibd file for$");
+SET GLOBAL innodb_file_per_table=on;
 CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, c3 INT) ENGINE=InnoDB;
 INSERT INTO t1 VALUES (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
 SET GLOBAL innodb_monitor_enable=module_ddl;
@@ -261,6 +264,35 @@ COUNT(c2)
 CHECK TABLE t1;
 Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
+SET DEBUG_SYNC='row_log_apply_before SIGNAL c2g_created WAIT_FOR dml4_done';
+SET lock_wait_timeout=1;
+ALTER TABLE t1 DROP INDEX c2f, ADD INDEX c2g(c2);
+SET DEBUG_SYNC='now WAIT_FOR c2g_created';
+SET lock_wait_timeout=10;
+ALTER TABLE t1 DISCARD TABLESPACE;
+SELECT state FROM information_schema.processlist
+WHERE info='ALTER TABLE t1 DISCARD TABLESPACE';
+state
+Waiting for table level lock
+SET DEBUG_SYNC='now SIGNAL dml4_done';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `c1` int(11) NOT NULL,
+  `c2` int(11) DEFAULT NULL,
+  `c3` int(11) DEFAULT NULL,
+  PRIMARY KEY (`c1`),
+  KEY `c2d` (`c2`),
+  KEY `c2f` (`c2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='testing if c2e will be dropped'
+ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f;
+ERROR 42S02: Table 'test.t1' doesn't exist
+ALTER TABLE t1 ADD INDEX c2h(c2), ALGORITHM=INPLACE;
+ERROR 42S02: Table 'test.t1' doesn't exist
+ALTER TABLE t1 ADD INDEX c2h(c2), ALGORITHM=COPY;
+ERROR 42S02: Table 'test.t1' doesn't exist
+SET GLOBAL innodb_file_per_table=0;
 SET DEBUG_SYNC='RESET';
 SET DEBUG='-d,debug_sync_abort_on_timeout';
 SET DEBUG='';

=== added file 'mysql-test/suite/innodb/t/innodb-alter-discard.test'
--- a/mysql-test/suite/innodb/t/innodb-alter-discard.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb-alter-discard.test	revid:marko.makela@stripped
@@ -0,0 +1,42 @@
+#Bug#13955083 ALLOW IN-PLACE DDL OPERATIONS ON MISSING OR DISCARDED TABLESPACES
+
+--source include/have_innodb.inc
+
+let $MYSQLD_DATADIR=`select @@datadir`;
+SET GLOBAL innodb_file_per_table=1;
+CREATE TABLE t(a INT)ENGINE=InnoDB;
+
+# Shut down the server
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- shutdown_server
+-- source include/wait_until_disconnected.inc
+
+# Remove the tablespace file.
+let IBD=$MYSQLD_DATADIR/test/t.ibd;
+perl;
+unlink "$ENV{IBD}" || die "Unable to unlink $ENV{IBD}\n";
+EOF
+
+# Restart the server.
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
+
+call mtr.add_suppression("InnoDB: Error: trying to open a table, but could not$");
+call mtr.add_suppression("MySQL is trying to open a table handle but the \.ibd file for$");
+call mtr.add_suppression("InnoDB: Error: table 'test/t'$");
+
+# The ER_NO_SUCH_TABLE is being thrown by ha_innobase::open().
+# The table does exist, only the tablespace does not exist.
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t;
+
+--error ER_NO_SUCH_TABLE
+ALTER TABLE t ADD INDEX (a), ALGORITHM=INPLACE;
+--error ER_NO_SUCH_TABLE
+ALTER TABLE t1 ADD INDEX (a), ALGORITHM=COPY;
+
+call mtr.add_suppression("InnoDB: (Error|Warning): cannot delete tablespace ");
+--error ER_GET_ERRNO
+ALTER TABLE t DISCARD TABLESPACE;
+DROP TABLE t;

=== modified file 'mysql-test/suite/innodb/t/innodb-index-online.test'
--- a/mysql-test/suite/innodb/t/innodb-index-online.test	revid:marko.makela@strippeddf7zgqt1xb3oc
+++ b/mysql-test/suite/innodb/t/innodb-index-online.test	revid:marko.makela@stripped8-wfy0yktq5jxv7dgf
@@ -9,6 +9,13 @@ call mtr.add_suppression("InnoDB: Warnin
 # These will be triggered by INSERT INTO t1 VALUES(6,3,1);
 call mtr.add_suppression("Cannot find index .*c2 in InnoDB index translation table");
 call mtr.add_suppression("Find index .*c2 in InnoDB index list but not its MySQL index number");
+# these will be triggered by DISCARD TABLESPACE
+call mtr.add_suppression("InnoDB: Error: table 'test/t1'$");
+call mtr.add_suppression("MySQL is trying to open a table handle but the .ibd file for$");
+
+# DISCARD TABLESPACE needs file-per-table
+let $per_table=`select @@innodb_file_per_table`;
+SET GLOBAL innodb_file_per_table=on;
 
 # Save the initial number of concurrent sessions.
 --source include/count_sessions.inc
@@ -263,10 +270,49 @@ SELECT name,count FROM INFORMATION_SCHEM
 SELECT COUNT(c2) FROM t1;
 CHECK TABLE t1;
 
-disconnect con1;
+connection default;
+SET DEBUG_SYNC='row_log_apply_before SIGNAL c2g_created WAIT_FOR dml4_done';
+# The lock upgrade at the end of the ALTER will conflict with the DISCARD.
+SET lock_wait_timeout=1;
+--send
+ALTER TABLE t1 DROP INDEX c2f, ADD INDEX c2g(c2);
+
+connection con1;
+SET DEBUG_SYNC='now WAIT_FOR c2g_created';
+
+connect (con2,localhost,root,,);
+connection con2;
+
+# This will conflict with the ALTER in connection default, above.
+SET lock_wait_timeout=10;
+--send
+ALTER TABLE t1 DISCARD TABLESPACE;
 
+connection con1;
+SELECT state FROM information_schema.processlist
+WHERE info='ALTER TABLE t1 DISCARD TABLESPACE';
+
+SET DEBUG_SYNC='now SIGNAL dml4_done';
+disconnect con1;
 connection default;
+--error ER_LOCK_WAIT_TIMEOUT
+reap;
+connection con2;
+reap;
+disconnect con2;
+connection default;
+
+SHOW CREATE TABLE t1;
+# The ER_NO_SUCH_TABLE is being thrown by ha_innobase::open().
+# The table does exist, only the tablespace does not exist.
+--error ER_NO_SUCH_TABLE
+ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f;
+--error ER_NO_SUCH_TABLE
+ALTER TABLE t1 ADD INDEX c2h(c2), ALGORITHM=INPLACE;
+--error ER_NO_SUCH_TABLE
+ALTER TABLE t1 ADD INDEX c2h(c2), ALGORITHM=COPY;
 
+eval SET GLOBAL innodb_file_per_table=$per_table;
 SET DEBUG_SYNC='RESET';
 SET DEBUG='-d,debug_sync_abort_on_timeout';
 SET DEBUG='';

=== modified file 'mysql-test/suite/innodb/t/innodb_bug30423.test'
--- a/mysql-test/suite/innodb/t/innodb_bug30423.test	revid:marko.makela@strippedc
+++ b/mysql-test/suite/innodb/t/innodb_bug30423.test	revid:marko.makela@strippedgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 # Test for Bug #30423, InnoDBs treatment of NULL in index stats causes
 # bad "rows examined" estimates.
 # Implemented InnoDB system variable "innodb_stats_method" with

=== modified file 'mysql-test/suite/innodb/t/innodb_bug53290.test'
--- a/mysql-test/suite/innodb/t/innodb_bug53290.test	revid:marko.makela@stripped-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/innodb/t/innodb_bug53290.test	revid:marko.makela@stripped8-wfy0yktq5jxv7dgf
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 -- source include/have_innodb.inc
 
 create table bug53290 (x bigint) engine=innodb;

=== modified file 'mysql-test/suite/parts/t/partition_float_myisam.test'
--- a/mysql-test/suite/parts/t/partition_float_myisam.test	revid:marko.makela@stripped39-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/parts/t/partition_float_myisam.test	revid:marko.makela@stripped418065318-wfy0yktq5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 ################################################################################
 # t/partition_float_myisam.test                                                #
 #                                                                              #

=== modified file 'mysql-test/suite/rpl/r/rpl_binlog_index.result'
--- a/mysql-test/suite/rpl/r/rpl_binlog_index.result	revid:marko.makela@strippedoc
+++ b/mysql-test/suite/rpl/r/rpl_binlog_index.result	revid:marko.makela@strippeddgf
@@ -6,20 +6,22 @@ Note	####	Storing MySQL user name or pas
 CREATE TABLE t1 (a INT);
 FLUSH BINARY LOGS;
 INSERT INTO t1 VALUES (1);
+include/stop_slave.inc
 # Shutdown master
 include/rpl_stop_server.inc [server_number=1]
 # Move the master binlog files and the index file to a new place
 # Restart master with log-bin option set to the new path
 # Master has restarted successfully
+include/start_slave.inc
 # Create the master-bin.index file with the old format
+include/stop_slave.inc
 # Shutdown master
 include/rpl_stop_server.inc [server_number=1]
 # Move back the master binlog files
 # Remove the unneeded master-bin.index file
 # Restart master with log-bin option set to default
 # Master has restarted successfully
-# stop slave
-include/stop_slave.inc
+include/start_slave.inc
 include/rpl_stop_server.inc [server_number=2]
 # relocate  binlogs
 # relocate  relay logs

=== modified file 'mysql-test/suite/rpl/t/rpl_binlog_index.test'
--- a/mysql-test/suite/rpl/t/rpl_binlog_index.test	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/rpl/t/rpl_binlog_index.test	revid:marko.makela@oracle.com-20120418065318-wfy0yktq5jxv7dgf
@@ -43,7 +43,7 @@ FLUSH BINARY LOGS;
 INSERT INTO t1 VALUES (1);
 
 sync_slave_with_master;
-
+--source include/stop_slave.inc
 #
 # Test on master
 #
@@ -64,7 +64,9 @@ source include/rpl_start_server.inc;
 --let $include_silent=0
 
 --echo # Master has restarted successfully
-
+--connection slave
+--source include/start_slave.inc
+--connection master
 #
 # Test master can handle old format with directory path in index file
 #
@@ -85,6 +87,9 @@ if (!$is_windows)
 --disable_query_log
 source include/write_var_to_file.inc;
 --enable_query_log
+--sync_slave_with_master
+--source include/stop_slave.inc
+--connection master
 
 --echo # Shutdown master
 --let $rpl_server_number=1
@@ -106,9 +111,10 @@ source include/rpl_start_server.inc;
 
 --echo # Master has restarted successfully
 
-connection slave;
---echo # stop slave
---source include/stop_slave.inc
+--connection slave
+--source include/start_slave.inc
+--sync_with_master
+--connection master
 --let $rpl_server_number= 2
 --source include/rpl_stop_server.inc
 

=== modified file 'mysql-test/suite/rpl/t/rpl_innodb_bug28430.test'
--- a/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test	revid:marko.makela@stripped
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 --source include/have_innodb.inc
 --source include/have_partition.inc
 --source include/have_binlog_format_mixed_or_row.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_parallel_innodb.test'
--- a/mysql-test/suite/rpl/t/rpl_parallel_innodb.test	revid:marko.makela@stripped417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/rpl/t/rpl_parallel_innodb.test	revid:marko.makela@stripped20418065318-wfy0yktq5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 #
 # WL#5569 MTS
 #

=== modified file 'mysql-test/suite/rpl/t/rpl_rotate_purge_deadlock.test'
--- a/mysql-test/suite/rpl/t/rpl_rotate_purge_deadlock.test	revid:marko.makela@stripped0539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/rpl/t/rpl_rotate_purge_deadlock.test	revid:marko.makela@stripped120418065318-wfy0yktq5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 #
 # Bug#11763573 - 56299: MUTEX DEADLOCK WITH COM_BINLOG_DUMP, BINLOG PURGE, AND PROCESSLIST/KILL
 #

=== modified file 'mysql-test/suite/rpl/t/rpl_row_img_blobs.test'
--- a/mysql-test/suite/rpl/t/rpl_row_img_blobs.test	revid:marko.makela@stripped20120417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/rpl/t/rpl_row_img_blobs.test	revid:marko.makela@stripped20120418065318-wfy0yktq5jxv7dgf
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 #
 # This file contains tests for WL#5096.
 #

=== modified file 'mysql-test/suite/rpl/t/rpl_row_img_eng_full.test'
--- a/mysql-test/suite/rpl/t/rpl_row_img_eng_full.test	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/suite/rpl/t/rpl_row_img_eng_full.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 #
 # This file contains tests for WL#5096 and bug fixes. 
 #

=== modified file 'mysql-test/suite/rpl/t/rpl_row_img_idx_full.test'
--- a/mysql-test/suite/rpl/t/rpl_row_img_idx_full.test	revid:marko.makela@strippedf7zgqt1xb3oc
+++ b/mysql-test/suite/rpl/t/rpl_row_img_idx_full.test	revid:marko.makela@strippedfy0yktq5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 #
 # This file contains tests for WL#5096.
 #

=== modified file 'mysql-test/suite/rpl/t/rpl_stop_slave.test'
--- a/mysql-test/suite/rpl/t/rpl_stop_slave.test	revid:marko.makela@strippedf7zgqt1xb3oc
+++ b/mysql-test/suite/rpl/t/rpl_stop_slave.test	revid:marko.makela@strippedq5jxv7dgf
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 source include/master-slave.inc;
 source include/have_innodb.inc;
 source include/have_debug.inc;

=== modified file 'mysql-test/suite/rpl/t/rpl_typeconv.test'
--- a/mysql-test/suite/rpl/t/rpl_typeconv.test	revid:marko.makela@stripped
+++ b/mysql-test/suite/rpl/t/rpl_typeconv.test	revid:marko.makela@stripped
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 --source include/have_binlog_format_row.inc
 --source include/master-slave.inc
 

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	revid:marko.makela@stripped
+++ b/mysql-test/t/disabled.def	revid:marko.makela@stripped20120418065318-wfy0yktq5jxv7dgf
@@ -16,3 +16,4 @@ archive-big              : Bug#11817185
 log_tables-big           : Bug#11756699 2010-11-15 mattiasj report already exists
 ds_mrr-big @solaris      : Hemant disabled since this leads to timeout on Solaris on slow sparc servers
 partition_locking_4	 : Bug#13924750 2012-04-04 lost connection.
+mysql_embedded_client_test	: Bug#13964673 2012-04-16 amitbha since most of the test cases are failing

=== modified file 'mysql-test/t/index_merge_innodb.test'
--- a/mysql-test/t/index_merge_innodb.test	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/t/index_merge_innodb.test	revid:marko.makela@stripped120418065318-wfy0yktq5jxv7dgf
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 # t/index_merge_innodb.test
 #
 # Index merge tests

=== modified file 'mysql-test/t/innodb_explain_json_non_select_all.test'
--- a/mysql-test/t/innodb_explain_json_non_select_all.test	revid:marko.makela@stripped
+++ b/mysql-test/t/innodb_explain_json_non_select_all.test	revid:marko.makela@strippedgf
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 # 
 # Run explain_non_select.inc on InnoDB with all of the so-called 6.0 features.
 #

=== modified file 'mysql-test/t/innodb_explain_non_select_all.test'
--- a/mysql-test/t/innodb_explain_non_select_all.test	revid:marko.makela@stripped
+++ b/mysql-test/t/innodb_explain_non_select_all.test	revid:marko.makela@stripped
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 # 
 # Run explain_non_select.inc on InnoDB with all of the so-called 6.0 features.
 #

=== modified file 'mysql-test/t/innodb_explain_non_select_none.test'
--- a/mysql-test/t/innodb_explain_non_select_none.test	revid:marko.makela@stripped
+++ b/mysql-test/t/innodb_explain_non_select_none.test	revid:marko.makela@stripped
@@ -1,3 +1,5 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
 # 
 # Run explain_non_select.inc on InnoDB without any of the socalled 6.0 features.
 #

=== modified file 'mysql-test/t/mysql_client_test_embedded.test'
--- a/mysql-test/t/mysql_client_test_embedded.test	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/mysql-test/t/mysql_client_test_embedded.test	revid:marko.makela@oracle.com-20120418065318-wfy0yktq5jxv7dgf
@@ -1,3 +1,6 @@
+#Want to skip this test from daily Valgrind execution
+--source include/no_valgrind_without_big.inc
+
 --source include/is_embedded.inc
 
 --echo # Run the start/stop test 17 times (* 64 = 1088 restarts)

=== added file 'mysql-test/t/mysql_embedded_client_test.test'
--- a/mysql-test/t/mysql_embedded_client_test.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysql_embedded_client_test.test	revid:marko.makela@stripped
@@ -0,0 +1,50 @@
+-- source include/not_embedded.inc
+
+--echo #
+--echo # Bug#13541194 : MTR TEST TO RUN EMBEDDED SERVER CLIENT TESTS IN MYSQL_CLIENT_TEST.C.
+--echo #
+
+# Stop the server
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--shutdown_server 10
+--source include/wait_until_disconnected.inc
+--echo stopped the current server
+
+perl;
+my $cli_string = $ENV{'MYSQL_CLIENT_TEST'};
+my $filestring = 'file';
+$cli_string =~ s/mysql_client_test/mysql_client_test_embedded/;
+if ($cli_string =~ /(.+?)\s/) {
+$filestring = $1;
+}
+my $emb_cli = 0;
+if (-e $filestring){
+  open (ISLINK, ">" . $ENV{'MYSQL_TMP_DIR'} . "/embedded_cli");
+  $emb_cli = 1;
+  print ISLINK "let \$emb_client = $cli_string;\n";
+  print ISLINK "let \$emb_cli_exists = $emb_cli;\n";
+  close ISLINK;
+}
+else {
+  open (ISLINK, ">" . $ENV{'MYSQL_TMP_DIR'} . "/embedded_cli");
+  print ISLINK "let \$emb_client = $cli_string;\n";
+  close ISLINK;
+}
+
+EOF
+
+--source $MYSQL_TMP_DIR/embedded_cli
+--remove_file $MYSQL_TMP_DIR/embedded_cli
+
+if (! $emb_cli_exists){
+  --skip Test only works with embedded server
+}
+
+--exec $emb_client --silent >> $MYSQLTEST_VARDIR/log/mysql_embedded_client_test.out.log 2>&1
+
+--echo # 7. Restart the server and cleanup
+#-----------------------------------------
+--enable_reconnect
+--exec echo "restart" > $restart_file
+--source include/wait_until_connected_again.inc

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	revid:marko.makela@stripped539-oy8df7zgqt1xb3oc
+++ b/sql/handler.cc	revid:marko.makela@stripped
@@ -1826,9 +1826,9 @@ bool mysql_xa_recover(THD *thd)
   XID_STATE *xs;
   DBUG_ENTER("mysql_xa_recover");
 
-  field_list.push_back(new Item_int("formatID", 0, MY_INT32_NUM_DECIMAL_DIGITS));
-  field_list.push_back(new Item_int("gtrid_length", 0, MY_INT32_NUM_DECIMAL_DIGITS));
-  field_list.push_back(new Item_int("bqual_length", 0, MY_INT32_NUM_DECIMAL_DIGITS));
+  field_list.push_back(new Item_int(NAME_STRING("formatID"), 0, MY_INT32_NUM_DECIMAL_DIGITS));
+  field_list.push_back(new Item_int(NAME_STRING("gtrid_length"), 0, MY_INT32_NUM_DECIMAL_DIGITS));
+  field_list.push_back(new Item_int(NAME_STRING("bqual_length"), 0, MY_INT32_NUM_DECIMAL_DIGITS));
   field_list.push_back(new Item_empty_string("data",XIDDATASIZE));
 
   if (protocol->send_result_set_metadata(&field_list,

=== modified file 'sql/item.cc'
--- a/sql/item.cc	revid:marko.makela@strippedom-20120417200539-oy8df7zgqt1xb3oc
+++ b/sql/item.cc	revid:marko.makela@stripped
@@ -958,7 +958,7 @@ bool Item::check_cols(uint c)
 }
 
 
-NameString null_name_string(NULL, 0);
+const NameString null_name_string(NULL, 0);
 
 
 void NameString::copy(const char *str, uint length, const CHARSET_INFO *cs)
@@ -2997,20 +2997,6 @@ void Item_int::print(String *str, enum_q
 }
 
 
-Item_uint::Item_uint(const char *str_arg, uint length):
-  Item_int(str_arg, length)
-{
-  unsigned_flag= 1;
-}
-
-
-Item_uint::Item_uint(const char *str_arg, longlong i, uint length):
-  Item_int(str_arg, i, length)
-{
-  unsigned_flag= 1;
-}
-
-
 String *Item_uint::val_str(String *str)
 {
   // following assert is redundant, because fixed=1 assigned in constructor
@@ -3065,11 +3051,12 @@ Item_decimal::Item_decimal(double val, i
 }
 
 
-Item_decimal::Item_decimal(const char *str, const my_decimal *val_arg,
+Item_decimal::Item_decimal(const NameString &name_arg,
+                           const my_decimal *val_arg,
                            uint decimal_par, uint length)
 {
   my_decimal2decimal(val_arg, &decimal_value);
-  item_name.set(str);
+  item_name= name_arg;
   decimals= (uint8) decimal_par;
   max_length= length;
   fixed= 1;
@@ -3996,13 +3983,13 @@ Item_param::clone_item()
   /* see comments in the header file */
   switch (state) {
   case NULL_VALUE:
-    return new Item_null(item_name.ptr());
+    return new Item_null(item_name);
   case INT_VALUE:
     return (unsigned_flag ?
-            new Item_uint(item_name.ptr(), value.integer, max_length) :
-            new Item_int(item_name.ptr(), value.integer, max_length));
+            new Item_uint(item_name, value.integer, max_length) :
+            new Item_int(item_name, value.integer, max_length));
   case REAL_VALUE:
-    return new Item_float(item_name.ptr(), value.real, decimals, max_length);
+    return new Item_float(item_name, value.real, decimals, max_length);
   case STRING_VALUE:
   case LONG_DATA_VALUE:
     return new Item_string(item_name, str_value.c_ptr_quick(), str_value.length(),
@@ -6253,8 +6240,8 @@ Item *Item_int_with_ref::clone_item()
     parameter markers.
   */
   return (ref->unsigned_flag ?
-          new Item_uint(ref->item_name.ptr(), ref->val_int(), ref->max_length) :
-          new Item_int(ref->item_name.ptr(), ref->val_int(), ref->max_length));
+          new Item_uint(ref->item_name, ref->val_int(), ref->max_length) :
+          new Item_int(ref->item_name, ref->val_int(), ref->max_length));
 }
 
 
@@ -6265,7 +6252,7 @@ Item *Item_time_with_ref::clone_item()
     We need to evaluate the constant to make sure it works with
     parameter markers.
   */
-  return new Item_temporal(MYSQL_TYPE_TIME, ref->item_name.ptr(),
+  return new Item_temporal(MYSQL_TYPE_TIME, ref->item_name,
                            ref->val_time_temporal(), ref->max_length);
 }
 
@@ -6277,7 +6264,7 @@ Item *Item_datetime_with_ref::clone_item
     We need to evaluate the constant to make sure it works with
     parameter markers.
   */
-  return new Item_temporal(MYSQL_TYPE_DATETIME, ref->item_name.ptr(),
+  return new Item_temporal(MYSQL_TYPE_DATETIME, ref->item_name,
                            ref->val_date_temporal(), ref->max_length);
 }
 
@@ -8163,8 +8150,6 @@ void resolve_const_item(THD *thd, Item *
     return;                                     // Can't be better
   Item_result res_type=item_cmp_type(comp_item->result_type(),
 				     item->result_type());
-  const char *name= item->item_name.ptr(); // Alloced by sql_alloc
-
   switch (res_type) {
   case STRING_RESULT:
   {
@@ -8172,7 +8157,7 @@ void resolve_const_item(THD *thd, Item *
     String tmp(buff,sizeof(buff),&my_charset_bin),*result;
     result=item->val_str(&tmp);
     if (item->null_value)
-      new_item= new Item_null(name);
+      new_item= new Item_null(item->item_name);
     else if (item->is_temporal())
     {
       enum_field_types type= item->field_type() == MYSQL_TYPE_TIMESTAMP ?
@@ -8193,8 +8178,8 @@ void resolve_const_item(THD *thd, Item *
     longlong result=item->val_int();
     uint length=item->max_length;
     bool null_value=item->null_value;
-    new_item= (null_value ? (Item*) new Item_null(name) :
-               (Item*) new Item_int(name, result, length));
+    new_item= (null_value ? (Item*) new Item_null(item->item_name) :
+               (Item*) new Item_int(item->item_name, result, length));
     break;
   }
   case ROW_RESULT:
@@ -8232,19 +8217,19 @@ void resolve_const_item(THD *thd, Item *
     double result= item->val_real();
     uint length=item->max_length,decimals=item->decimals;
     bool null_value=item->null_value;
-    new_item= (null_value ? (Item*) new Item_null(name) : (Item*)
-               new Item_float(name, result, decimals, length));
+    new_item= (null_value ? (Item*) new Item_null(item->item_name) : (Item*)
+               new Item_float(item->item_name, result, decimals, length));
     break;
   }
   case DECIMAL_RESULT:
   {
     my_decimal decimal_value;
     my_decimal *result= item->val_decimal(&decimal_value);
-    uint length= item->max_length, decimals= item->decimals;
     bool null_value= item->null_value;
     new_item= (null_value ?
-               (Item*) new Item_null(name) :
-               (Item*) new Item_decimal(name, result, length, decimals));
+               (Item*) new Item_null(item->item_name) :
+               (Item*) new Item_decimal(item->item_name, result,
+                                        item->max_length, item->decimals));
     break;
   }
   default:

=== modified file 'sql/item.h'
--- a/sql/item.h	revid:marko.makela@stripped
+++ b/sql/item.h	revid:marko.makela@stripped65318-wfy0yktq5jxv7dgf
@@ -147,6 +147,11 @@ public:
 /**
   Storage for name strings.
   Enpowers SimpleCString with allocation routines from the sql_strmake family.
+
+  This class must stay as small as possible as we often 
+  pass it into functions using call-by-value evaluation.
+
+  Don't add new members or virual methods into this class!
 */
 class NameString: public SimpleCString
 {
@@ -160,6 +165,11 @@ private:
   }
 public:
   NameString(): SimpleCString() {}
+  /*
+    Please do NOT add constructor NameString(const char *str) !
+    It will involve hidden strlen() call, which can affect
+    performance negatively. Use NameString(str, len) instead.
+  */
   NameString(const char *str, uint length):
     SimpleCString(str, length) {}
   NameString(const LEX_STRING str): SimpleCString(str) {}
@@ -226,7 +236,10 @@ public:
 };
 
 
-extern NameString null_name_string;
+#define NAME_STRING(x)  NameString(C_STRING_WITH_LEN(x))
+
+
+extern const NameString null_name_string;
 
 
 /**
@@ -2211,15 +2224,24 @@ public:
 
 class Item_null :public Item_basic_constant
 {
-public:
-  Item_null(const char *name_par=0)
+  void init()
   {
     maybe_null= null_value= TRUE;
     max_length= 0;
-    item_name.copy(name_par ? name_par : (char*) "NULL");
     fixed= 1;
     collation.set(&my_charset_bin, DERIVATION_IGNORABLE);
   }
+public:
+  Item_null()
+  {
+    init();
+    item_name= NAME_STRING("NULL");
+  }
+  Item_null(const NameString &name_par)
+  {
+    init();
+    item_name= name_par;
+  }
   enum Type type() const { return NULL_ITEM; }
   bool eq(const Item *item, bool binary_cmp) const;
   double val_real();
@@ -2242,7 +2264,7 @@ public:
   enum Item_result result_type () const { return STRING_RESULT; }
   enum_field_types field_type() const   { return MYSQL_TYPE_NULL; }
   bool basic_const_item() const { return 1; }
-  Item *clone_item() { return new Item_null(item_name.ptr()); }
+  Item *clone_item() { return new Item_null(item_name); }
   bool is_null() { return 1; }
 
   virtual inline void print(String *str, enum_query_type query_type)
@@ -2450,10 +2472,10 @@ public:
     max_length= item_arg->max_length;
     fixed= 1;
   }
-  Item_int(const char *str_arg,longlong i,uint length) :value(i)
+  Item_int(const NameString &name_arg, longlong i, uint length) :value(i)
   {
     max_length= length;
-    item_name.set(str_arg);
+    item_name= name_arg;
     fixed= 1;
   }
   Item_int(const char *str_arg, uint length);
@@ -2484,6 +2506,16 @@ public:
 };
 
 
+/**
+  Item_int with value==0 and length==1
+*/
+class Item_int_0 :public Item_int
+{
+public:
+  Item_int_0() :Item_int(NAME_STRING("0"), 0, 1) {}
+};
+
+
 /*
   Item_temporal is used to store numeric representation
   of time/date/datetime values for queries like:
@@ -2503,13 +2535,13 @@ public:
   {
     DBUG_ASSERT(is_temporal_type(field_type_arg));
   }
-  Item_temporal(enum_field_types field_type_arg,
-                const char *str_arg, longlong i, uint length): Item_int(i),
+  Item_temporal(enum_field_types field_type_arg, const NameString &name_arg,
+                longlong i, uint length): Item_int(i),
     cached_field_type(field_type_arg)
   {
     DBUG_ASSERT(is_temporal_type(field_type_arg));
     max_length= length;
-    item_name.set(str_arg);
+    item_name= name_arg;
     fixed= 1;
   }
   Item *clone_item() { return new Item_temporal(field_type(), value); }
@@ -2536,13 +2568,15 @@ public:
 class Item_uint :public Item_int
 {
 public:
-  Item_uint(const char *str_arg, uint length);
+  Item_uint(const char *str_arg, uint length)
+    :Item_int(str_arg, length) { unsigned_flag= 1; }
   Item_uint(ulonglong i) :Item_int((ulonglong) i, 10) {}
-  Item_uint(const char *str_arg, longlong i, uint length);
+  Item_uint(const NameString &name_arg, longlong i, uint length)
+    :Item_int(name_arg, i, length) { unsigned_flag= 1; }
   double val_real()
     { DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); }
   String *val_str(String*);
-  Item *clone_item() { return new Item_uint(item_name.ptr(), value, max_length); }
+  Item *clone_item() { return new Item_uint(item_name, value, max_length); }
   int save_in_field(Field *field, bool no_conversions);
   virtual void print(String *str, enum_query_type query_type);
   Item_num *neg ();
@@ -2558,8 +2592,8 @@ protected:
   my_decimal decimal_value;
 public:
   Item_decimal(const char *str_arg, uint length, const CHARSET_INFO *charset);
-  Item_decimal(const char *str, const my_decimal *val_arg,
-               uint decimal_par, uint length);
+  Item_decimal(const NameString &name_arg,
+               const my_decimal *val_arg, uint decimal_par, uint length);
   Item_decimal(my_decimal *value_par);
   Item_decimal(longlong val, bool unsig);
   Item_decimal(double val, int precision, int scale);
@@ -2584,7 +2618,7 @@ public:
   bool basic_const_item() const { return 1; }
   Item *clone_item()
   {
-    return new Item_decimal(item_name.ptr(), &decimal_value, decimals, max_length);
+    return new Item_decimal(item_name, &decimal_value, decimals, max_length);
   }
   virtual void print(String *str, enum_query_type query_type);
   Item_num *neg()
@@ -2607,13 +2641,14 @@ public:
   double value;
   // Item_real() :value(0) {}
   Item_float(const char *str_arg, uint length);
-  Item_float(const char *str,double val_arg,uint decimal_par,uint length)
+  Item_float(const NameString name_arg,
+             double val_arg, uint decimal_par, uint length)
     :value(val_arg)
   {
-    presentation.set(str);
-    item_name.set(str);
-    decimals=(uint8) decimal_par;
-    max_length=length;
+    presentation= name_arg;
+    item_name= name_arg;
+    decimals= (uint8) decimal_par;
+    max_length= length;
     fixed= 1;
   }
   Item_float(double value_par, uint decimal_par) :value(value_par)
@@ -2650,7 +2685,7 @@ public:
   }
   bool basic_const_item() const { return 1; }
   Item *clone_item()
-  { return new Item_float(item_name.ptr(), value, decimals, max_length); }
+  { return new Item_float(item_name, value, decimals, max_length); }
   Item_num *neg() { value= -value; return this; }
   virtual void print(String *str, enum_query_type query_type);
   bool eq(const Item *, bool binary_cmp) const;
@@ -2659,11 +2694,12 @@ public:
 
 class Item_static_float_func :public Item_float
 {
-  const char *func_name;
+  const NameString func_name;
 public:
-  Item_static_float_func(const char *str, double val_arg, uint decimal_par,
-                        uint length)
-    :Item_float(NullS, val_arg, decimal_par, length), func_name(str)
+  Item_static_float_func(const NameString &name_arg,
+                         double val_arg, uint decimal_par, uint length)
+    :Item_float(null_name_string,
+                val_arg, decimal_par, length), func_name(name_arg)
   {}
 
   virtual inline void print(String *str, enum_query_type query_type)
@@ -2827,10 +2863,10 @@ double_from_string_with_check (const CHA
 
 class Item_static_string_func :public Item_string
 {
-  const char *func_name;
+  const NameString func_name;
 public:
-  Item_static_string_func(const char *name_par, const char *str, uint length,
-                          const CHARSET_INFO *cs,
+  Item_static_string_func(const NameString &name_par,
+                          const char *str, uint length, const CHARSET_INFO *cs,
                           Derivation dv= DERIVATION_COERCIBLE)
     :Item_string(null_name_string, str, length, cs, dv), func_name(name_par)
   {}
@@ -2909,7 +2945,8 @@ class Item_return_int :public Item_int
 public:
   Item_return_int(const char *name_arg, uint length,
 		  enum_field_types field_type_arg, longlong value= 0)
-    :Item_int(name_arg, value, length), int_field_type(field_type_arg)
+    :Item_int(NameString(name_arg, name_arg ? strlen(name_arg) : 0),
+              value, length), int_field_type(field_type_arg)
   {
     unsigned_flag=1;
   }

=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/sql/item_create.cc	revid:marko.makela@strippedtq5jxv7dgf
@@ -4700,7 +4700,8 @@ Create_func_pi Create_func_pi::s_singlet
 Item*
 Create_func_pi::create(THD *thd)
 {
-  return new (thd->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
+  return new (thd->mem_root) Item_static_float_func(NAME_STRING("pi()"),
+                                                    M_PI, 6, 8);
 }
 
 
@@ -4827,7 +4828,7 @@ Create_func_round::create_native(THD *th
   case 1:
   {
     Item *param_1= item_list->pop();
-    Item *i0 = new (thd->mem_root) Item_int((char*)"0", 0, 1);
+    Item *i0 = new (thd->mem_root) Item_int_0();
     func= new (thd->mem_root) Item_func_round(param_1, i0, 0);
     break;
   }
@@ -5186,7 +5187,7 @@ Item*
 Create_func_version::create(THD *thd)
 {
   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
-  return new (thd->mem_root) Item_static_string_func("version()",
+  return new (thd->mem_root) Item_static_string_func(NAME_STRING("version()"),
                                                      server_version,
                                                      (uint) strlen(server_version),
                                                      system_charset_info,
@@ -5208,7 +5209,7 @@ Create_func_weekofyear Create_func_weeko
 Item*
 Create_func_weekofyear::create(THD *thd, Item *arg1)
 {
-  Item *i1= new (thd->mem_root) Item_int((char*) "0", 3, 1);
+  Item *i1= new (thd->mem_root) Item_int(NAME_STRING("0"), 3, 1);
   return new (thd->mem_root) Item_func_week(arg1, i1);
 }
 
@@ -5291,7 +5292,7 @@ Create_func_year_week::create_native(THD
   case 1:
   {
     Item *param_1= item_list->pop();
-    Item *i0= new (thd->mem_root) Item_int((char*) "0", 0, 1);
+    Item *i0= new (thd->mem_root) Item_int_0();
     func= new (thd->mem_root) Item_func_yearweek(param_1, i0);
     break;
   }

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	revid:marko.makela@stripped
+++ b/sql/item_strfunc.cc	revid:marko.makela@stripped8-wfy0yktq5jxv7dgf
@@ -2081,7 +2081,7 @@ Item *Item_func_sysconst::safe_charset_c
   String tmp, cstr, *ostr= val_str(&tmp);
   if (null_value)
   {
-    Item *null_item= new Item_null((char *) fully_qualified_func_name());
+    Item *null_item= new Item_null(fully_qualified_func_name());
     null_item->collation.set (tocs);
     return null_item;
   }

=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h	revid:marko.makela@stripped417200539-oy8df7zgqt1xb3oc
+++ b/sql/item_strfunc.h	revid:marko.makela@stripped
@@ -464,7 +464,7 @@ public:
     safe_charset_converter, return string representation of this function
     call
   */
-  virtual const char *fully_qualified_func_name() const = 0;
+  virtual const NameString fully_qualified_func_name() const = 0;
 };
 
 
@@ -479,7 +479,8 @@ public:
     maybe_null=1;
   }
   const char *func_name() const { return "database"; }
-  const char *fully_qualified_func_name() const { return "database()"; }
+  const NameString fully_qualified_func_name() const
+  { return NAME_STRING("database()"); }
 };
 
 
@@ -505,7 +506,8 @@ public:
                  (HOSTNAME_LENGTH + 1) * SYSTEM_CHARSET_MBMAXLEN);
   }
   const char *func_name() const { return "user"; }
-  const char *fully_qualified_func_name() const { return "user()"; }
+  const NameString fully_qualified_func_name() const
+  { return NAME_STRING("user()"); }
   int save_in_field(Field *field, bool no_conversions)
   {
     return save_str_value_in_field(field, &str_value);
@@ -522,7 +524,8 @@ public:
     : context(context_arg) {}
   bool fix_fields(THD *thd, Item **ref);
   const char *func_name() const { return "current_user"; }
-  const char *fully_qualified_func_name() const { return "current_user()"; }
+  const NameString fully_qualified_func_name() const
+  { return NAME_STRING("current_user()"); }
 };
 
 

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	revid:marko.makela@stripped17200539-oy8df7zgqt1xb3oc
+++ b/sql/item_subselect.cc	revid:marko.makela@strippedf
@@ -1495,7 +1495,7 @@ Item_in_subselect::single_value_in_to_ex
       bool tmp;
       Item *having= item, *orig_item= item;
       select_lex->item_list.empty();
-      select_lex->item_list.push_back(new Item_int("Not_used",
+      select_lex->item_list.push_back(new Item_int(NAME_STRING("Not_used"),
                                                    (longlong) 1,
                                                    MY_INT64_NUM_DECIMAL_DIGITS));
       join->ref_ptrs[0]= select_lex->item_list.head();

=== modified file 'sql/item_xmlfunc.cc'
--- a/sql/item_xmlfunc.cc	revid:marko.makela@strippedf7zgqt1xb3oc
+++ b/sql/item_xmlfunc.cc	revid:marko.makela@oracle.com-20120418065318-wfy0yktq5jxv7dgf
@@ -1167,7 +1167,7 @@ static Item *create_func_string_length(M
 
 static Item *create_func_round(MY_XPATH *xpath, Item **args, uint nargs)
 {
-  return new Item_func_round(args[0], new Item_int((char*)"0",0,1),0);
+  return new Item_func_round(args[0], new Item_int_0(), 0);
 }
 
 

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	revid:marko.makela@stripped
+++ b/sql/sp_head.cc	revid:marko.makela@strippedy0yktq5jxv7dgf
@@ -2815,7 +2815,7 @@ sp_head::show_routine_code(THD *thd)
   if (check_show_routine_access(thd, this, &full_access) || !full_access)
     DBUG_RETURN(1);
 
-  field_list.push_back(new Item_uint("Pos", 0, 9));
+  field_list.push_back(new Item_uint(NAME_STRING("Pos"), 0, 9));
   // 1024 is for not to confuse old clients
   field_list.push_back(new Item_empty_string("Instruction",
                                              max(buffer.length(), 1024U)));

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	revid:marko.makela@stripped7200539-oy8df7zgqt1xb3oc
+++ b/sql/sql_base.cc	revid:marko.makela@stripped
@@ -8162,7 +8162,7 @@ int setup_wild(THD *thd, TABLE_LIST *tab
 
           Item_int do not need fix_fields() because it is basic constant.
         */
-        it.replace(new Item_int("Not_used", (longlong) 1,
+        it.replace(new Item_int(NAME_STRING("Not_used"), (longlong) 1,
                                 MY_INT64_NUM_DECIMAL_DIGITS));
       }
       else if (insert_fields(thd, ((Item_field*) item)->context,

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	revid:marko.makela@stripped417200539-oy8df7zgqt1xb3oc
+++ b/sql/sql_class.cc	revid:marko.makela@stripped
@@ -2084,7 +2084,8 @@ int THD::send_explain_fields(select_resu
   item->maybe_null= 1;
   if (lex->describe & DESCRIBE_EXTENDED)
   {
-    field_list.push_back(item= new Item_float("filtered", 0.1234, 2, 4));
+    field_list.push_back(item= new Item_float(NAME_STRING("filtered"),
+                                              0.1234, 2, 4));
     item->maybe_null=1;
   }
   field_list.push_back(new Item_empty_string("Extra", 255, cs));

=== modified file 'sql/sql_optimizer.cc'
--- a/sql/sql_optimizer.cc	revid:marko.makela@stripped
+++ b/sql/sql_optimizer.cc	revid:marko.makela@stripped0120418065318-wfy0yktq5jxv7dgf
@@ -8299,7 +8299,7 @@ remove_eq_conds(THD *thd, Item *cond, It
 #endif
 	Item *new_cond;
 	if ((new_cond= new Item_func_eq(args[0],
-					new Item_int("last_insert_id()",
+					new Item_int(NAME_STRING("last_insert_id()"),
                                                      thd->read_first_successful_insert_id_in_prev_stmt(),
                                                      MY_INT64_NUM_DECIMAL_DIGITS))))
 	{

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	revid:marko.makela@stripped3oc
+++ b/sql/sql_parse.cc	revid:marko.makela@stripped20120418065318-wfy0yktq5jxv7dgf
@@ -7621,7 +7621,7 @@ Item *negate_expression(THD *thd, Item *
       if it is not boolean function then we have to emulate value of
       not(not(a)), it will be a != 0
     */
-    return new Item_func_ne(arg, new Item_int((char*) "0", 0, 1));
+    return new Item_func_ne(arg, new Item_int_0());
   }
 
   if ((negated= expr->neg_transformer(thd)) != 0)

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	revid:marko.makela@stripped
+++ b/sql/sql_show.cc	revid:marko.makela@stripped8065318-wfy0yktq5jxv7dgf
@@ -2050,7 +2050,7 @@ void mysqld_list_processes(THD *thd,cons
   Protocol *protocol= thd->protocol;
   DBUG_ENTER("mysqld_list_processes");
 
-  field_list.push_back(new Item_int("Id", 0, MY_INT32_NUM_DECIMAL_DIGITS));
+  field_list.push_back(new Item_int(NAME_STRING("Id"), 0, MY_INT32_NUM_DECIMAL_DIGITS));
   field_list.push_back(new Item_empty_string("User",16));
   field_list.push_back(new Item_empty_string("Host",LIST_PROCESS_HOST_LEN));
   field_list.push_back(field=new Item_empty_string("db",NAME_CHAR_LEN));
@@ -6695,10 +6695,14 @@ TABLE *create_schema_table(THD *thd, TAB
       break;
     case MYSQL_TYPE_FLOAT:
     case MYSQL_TYPE_DOUBLE:
-      if ((item= new Item_float(fields_info->field_name, 0.0, NOT_FIXED_DEC, 
-                           fields_info->field_length)) == NULL)
+    {
+      const NameString field_name(fields_info->field_name,
+                                  strlen(fields_info->field_name));
+      if ((item= new Item_float(field_name, 0.0, NOT_FIXED_DEC, 
+                                fields_info->field_length)) == NULL)
         DBUG_RETURN(NULL);
       break;
+    }
     case MYSQL_TYPE_DECIMAL:
     case MYSQL_TYPE_NEWDECIMAL:
       if (!(item= new Item_decimal((longlong) fields_info->value, false)))

=== modified file 'sql/sql_string.h'
--- a/sql/sql_string.h	revid:marko.makela@oracle.com-20120417200539-oy8df7zgqt1xb3oc
+++ b/sql/sql_string.h	revid:marko.makela@strippedktq5jxv7dgf
@@ -27,6 +27,12 @@
   A wrapper class for null-terminated constant strings.
   Constructors make sure that the position of the '\0' terminating byte
   in m_str is always in sync with m_length.
+
+  This class must stay as small as possible as we often 
+  pass it and its descendants (such as NameString) into functions
+  using call-by-value evaluation.
+
+  Don't add new members or virual methods into this class!
 */
 class SimpleCString
 {

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	revid:marko.makela@strippedzgqt1xb3oc
+++ b/sql/sql_table.cc	revid:marko.makela@oracle.com-20120418065318-wfy0yktq5jxv7dgf
@@ -7958,7 +7958,8 @@ bool mysql_checksum_table(THD *thd, TABL
 
   field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2));
   item->maybe_null= 1;
-  field_list.push_back(item= new Item_int("Checksum", (longlong) 1,
+  field_list.push_back(item= new Item_int(NAME_STRING("Checksum"),
+                                          (longlong) 1,
                                           MY_INT64_NUM_DECIMAL_DIGITS));
   item->maybe_null= 1;
   if (protocol->send_result_set_metadata(&field_list,

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	revid:marko.makela@stripped
+++ b/sql/sql_yacc.yy	revid:marko.makela@strippedy0yktq5jxv7dgf
@@ -9396,7 +9396,7 @@ function_call_conflict:
         | WEEK_SYM '(' expr ')'
           {
             THD *thd= YYTHD;
-            Item *i1= new (thd->mem_root) Item_int((char*) "0",
+            Item *i1= new (thd->mem_root) Item_int(NAME_STRING("0"),
                                            thd->variables.default_week_format,
                                                    1);
             if (i1 == NULL)
@@ -12749,13 +12749,13 @@ literal:
           }
         | FALSE_SYM
           {
-            $$= new (YYTHD->mem_root) Item_int((char*) "FALSE",0,1);
+            $$= new (YYTHD->mem_root) Item_int(NAME_STRING("FALSE"), 0, 1);
             if ($$ == NULL)
               MYSQL_YYABORT;
           }
         | TRUE_SYM
           {
-            $$= new (YYTHD->mem_root) Item_int((char*) "TRUE",1,1);
+            $$= new (YYTHD->mem_root) Item_int(NAME_STRING("TRUE"), 1, 1);
             if ($$ == NULL)
               MYSQL_YYABORT;
           }
@@ -12835,7 +12835,7 @@ NUM_literal:
           {
             int error;
             $$= new (YYTHD->mem_root)
-                  Item_int($1.str,
+                  Item_int($1,
                            (longlong) my_strtoll10($1.str, NULL, &error),
                            $1.length);
             if ($$ == NULL)
@@ -12845,7 +12845,7 @@ NUM_literal:
           {
             int error;
             $$= new (YYTHD->mem_root)
-                  Item_int($1.str,
+                  Item_int($1,
                            (longlong) my_strtoll10($1.str, NULL, &error),
                            $1.length);
             if ($$ == NULL)

=== modified file 'storage/innobase/buf/buf0flu.cc'
--- a/storage/innobase/buf/buf0flu.cc	revid:marko.makela@stripped200539-oy8df7zgqt1xb3oc
+++ b/storage/innobase/buf/buf0flu.cc	revid:marko.makela@strippedq5jxv7dgf
@@ -1090,75 +1090,7 @@ buf_flush_page_try(
 }
 # endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
 /***********************************************************//**
-Attempts to flush a given neighbor of a page to disk.
-@return	true if flushed. */
-static
-bool
-buf_flush_try_one_neighbor(
-/*=======================*/
-	ulint		space,		/*!< in: space id */
-	ulint		offset,		/*!< in: page offset */
-	ulint		neighbor_offset,/*!< in: neigbor page offset to try */
-	enum buf_flush	flush_type)	/*!< in: BUF_FLUSH_LRU or
-					BUF_FLUSH_LIST */
-{
-	buf_page_t*	bpage;
-	buf_pool_t*	buf_pool = buf_pool_get(space, neighbor_offset);
-
-	ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
-
-	buf_pool_mutex_enter(buf_pool);
-
-	/* We only want to flush pages from this buffer pool. */
-	bpage = buf_page_hash_get(buf_pool, space, neighbor_offset);
-
-	if (!bpage) {
-
-		buf_pool_mutex_exit(buf_pool);
-		/* not contiguous */
-		return(false);
-	}
-
-	ut_a(buf_page_in_file(bpage));
-
-	/* We avoid flushing 'non-old' blocks in an LRU flush,
-	because the flushed blocks are soon freed */
-
-	if (flush_type != BUF_FLUSH_LRU
-	    || neighbor_offset == offset
-	    || buf_page_is_old(bpage)) {
-		mutex_t* block_mutex = buf_page_get_mutex(bpage);
-
-		mutex_enter(block_mutex);
-
-		if (buf_flush_ready_for_flush(bpage, flush_type)
-		    && (neighbor_offset == offset || !bpage->buf_fix_count)) {
-			/* We only try to flush those
-			neighbors != offset where the buf fix
-			count is zero, as we then know that we
-			probably can latch the page without a
-			semaphore wait. Semaphore waits are
-			expensive because we must flush the
-			doublewrite buffer before we start
-			waiting. */
-
-			buf_flush_page(buf_pool, bpage, flush_type);
-			ut_ad(!mutex_own(block_mutex));
-			ut_ad(!buf_pool_mutex_own(buf_pool));
-			/* contiguous */
-			return(true);
-		} else {
-			mutex_exit(block_mutex);
-		}
-	}
-	buf_pool_mutex_exit(buf_pool);
-
-	/* not contiguous */
-	return(false);
-}
-
-/***********************************************************//**
-Flushes to disk contiguous flushable pages within the flush area.
+Flushes to disk all flushable pages within the flush area.
 @return	number of pages flushed */
 static
 ulint
@@ -1180,7 +1112,6 @@ buf_flush_try_neighbors(
 	buf_pool_t*	buf_pool = buf_pool_get(space, offset);
 
 	ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
-	ut_ad(n_flushed < n_to_flush);
 
 	if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN
 	    || !srv_flush_neighbors) {
@@ -1209,26 +1140,71 @@ buf_flush_try_neighbors(
 		high = fil_space_get_size(space);
 	}
 
-	/* Do a backward scan until one of the following becomes true:
-	(1) We reach the end of the extent
-	(2) We have flushed enough pages requested by the caller
-	(3) We reach the end of contiguously present flushable pages */
-
-	for (i = offset;
-	     i >= low
-	     && (count + n_flushed) < n_to_flush
-	     && buf_flush_try_one_neighbor(space, offset, i, flush_type);
-	     i--) {
-		++count;
-	}
+	for (i = low; i < high; i++) {
+
+		buf_page_t*	bpage;
+
+		if ((count + n_flushed) >= n_to_flush) {
+
+			/* We have already flushed enough pages and
+			should call it a day. There is, however, one
+			exception. If the page whose neighbors we
+			are flushing has not been flushed yet then
+			we'll try to flush the victim that we
+			selected originally. */
+			if (i <= offset) {
+				i = offset;
+			} else {
+				break;
+			}
+		}
+
+		buf_pool = buf_pool_get(space, i);
 
-	/* Do a forward scan in same way, if need */
-	for (i = offset + 1;
-	     i < high
-	     && (count + n_flushed) < n_to_flush
-	     && buf_flush_try_one_neighbor(space, offset, i, flush_type);
-	     i++) {
-		++count;
+		buf_pool_mutex_enter(buf_pool);
+
+		/* We only want to flush pages from this buffer pool. */
+		bpage = buf_page_hash_get(buf_pool, space, i);
+
+		if (!bpage) {
+
+			buf_pool_mutex_exit(buf_pool);
+			continue;
+		}
+
+		ut_a(buf_page_in_file(bpage));
+
+		/* We avoid flushing 'non-old' blocks in an LRU flush,
+		because the flushed blocks are soon freed */
+
+		if (flush_type != BUF_FLUSH_LRU
+		    || i == offset
+		    || buf_page_is_old(bpage)) {
+			mutex_t* block_mutex = buf_page_get_mutex(bpage);
+
+			mutex_enter(block_mutex);
+
+			if (buf_flush_ready_for_flush(bpage, flush_type)
+			    && (i == offset || !bpage->buf_fix_count)) {
+				/* We only try to flush those
+				neighbors != offset where the buf fix
+				count is zero, as we then know that we
+				probably can latch the page without a
+				semaphore wait. Semaphore waits are
+				expensive because we must flush the
+				doublewrite buffer before we start
+				waiting. */
+
+				buf_flush_page(buf_pool, bpage, flush_type);
+				ut_ad(!mutex_own(block_mutex));
+				ut_ad(!buf_pool_mutex_own(buf_pool));
+				count++;
+				continue;
+			} else {
+				mutex_exit(block_mutex);
+			}
+		}
+		buf_pool_mutex_exit(buf_pool);
 	}
 
 	if (count > 0) {

=== modified file 'storage/innobase/handler/handler0alter.cc'
--- a/storage/innobase/handler/handler0alter.cc	revid:marko.makela@stripped-20120417200539-oy8df7zgqt1xb3oc
+++ b/storage/innobase/handler/handler0alter.cc	revid:marko.makela@stripped20418065318-wfy0yktq5jxv7dgf
@@ -157,6 +157,10 @@ ha_innobase::check_if_supported_inplace_
 {
 	DBUG_ENTER("check_if_supported_inplace_alter");
 
+	if (srv_created_new_raw || srv_force_recovery) {
+		DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
+	}
+
 	HA_CREATE_INFO* create_info = ha_alter_info->create_info;
 
 	if (ha_alter_info->handler_flags
@@ -196,6 +200,7 @@ ha_innobase::check_if_supported_inplace_
 	}
 
 	update_thd();
+	trx_search_latch_release_if_reserved(prebuilt->trx);
 
 	/* Fix the key parts. */
 	for (KEY* new_key = ha_alter_info->key_info_buffer;
@@ -1653,7 +1658,9 @@ col_fail:
 		log is unnecessary. */
 		if (!exclusive && !num_fts_index
 		    && !(ha_alter_info->handler_flags
-			 & ~INNOBASE_ONLINE_OPERATIONS)) {
+			 & ~INNOBASE_ONLINE_OPERATIONS)
+		    && !user_table->ibd_file_missing
+		    && !user_table->tablespace_discarded) {
 			DBUG_EXECUTE_IF("innodb_OOM_prepare_inplace_alter",
 					error = DB_OUT_OF_MEMORY;
 					goto error_handling;);
@@ -1897,19 +1904,11 @@ ha_innobase::prepare_inplace_alter_table
 		goto func_exit;
 	}
 
-	if (srv_created_new_raw || srv_force_recovery) {
-		my_error(ER_OPEN_AS_READONLY, MYF(0),
-			 table->s->table_name.str);
-		DBUG_RETURN(true);
-	}
-
 	ut_d(mutex_enter(&dict_sys->mutex));
 	ut_d(dict_table_check_for_dup_indexes(
 		     prebuilt->table, CHECK_ABORTED_OK));
 	ut_d(mutex_exit(&dict_sys->mutex));
 
-	update_thd();
-
 	/* In case MySQL calls this in the middle of a SELECT query, release
 	possible adaptive hash latch to avoid deadlocks of threads. */
 	trx_search_latch_release_if_reserved(prebuilt->trx);
@@ -2344,9 +2343,6 @@ ha_innobase::inplace_alter_table(
 		DBUG_RETURN(false);
 	}
 
-	update_thd();
-	trx_search_latch_release_if_reserved(prebuilt->trx);
-
 	class ha_innobase_inplace_ctx*	ctx
 		= static_cast<class ha_innobase_inplace_ctx*>
 		(ha_alter_info->handler_ctx);
@@ -2354,6 +2350,11 @@ ha_innobase::inplace_alter_table(
 	DBUG_ASSERT(ctx);
 	DBUG_ASSERT(ctx->trx);
 
+	if (prebuilt->table->ibd_file_missing
+	    || prebuilt->table->tablespace_discarded) {
+		goto all_done;
+	}
+
 	/* Read the clustered index of the table and build
 	indexes based on this information using temporary
 	files and merge sort. */
@@ -2373,6 +2374,7 @@ oom:
 
 	switch (error) {
 		KEY*	dup_key;
+	all_done:
 	case DB_SUCCESS:
 		ut_d(mutex_enter(&dict_sys->mutex));
 		ut_d(dict_table_check_for_dup_indexes(

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5545 branch (marko.makela:3895 to 3896) marko.makela20 Apr