List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:January 14 2009 9:32am
Subject:bzr commit into mysql-5.1-bugteam branch (zhenxing.he:2748) Bug#31177
Bug#36312 Bug#36875 Bug#37016 Bug#40377 Bug#40972 Bug#41111 Bug#41348
Bug#4143...
View as plain text  
#At file:///media/sdb2/hezx/work/mysql/bzrwork/b41986/5.1-bugteam/

 2748 He Zhenxing	2009-01-14 [merge]
      Auto merge
added:
  mysql-test/include/check_events_off.inc
  mysql-test/include/no_running_event_scheduler.inc
  mysql-test/include/no_running_events.inc
  mysql-test/include/running_event_scheduler.inc
  mysql-test/r/innodb_mysql_rbk.result
  mysql-test/t/innodb_mysql_rbk-master.opt
  mysql-test/t/innodb_mysql_rbk.test
renamed:
  mysql-test/suite/funcs_1/r/is_collation_character_set_applicability.result => mysql-test/suite/funcs_1/r/is_coll_char_set_appl.result
  mysql-test/suite/funcs_1/t/is_collation_character_set_applicability.test => mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test
modified:
  client/mysqltest.c
  mysql-test/extra/binlog_tests/database.test
  mysql-test/include/commit.inc
  mysql-test/include/have_32bit.inc
  mysql-test/include/have_64bit.inc
  mysql-test/r/commit_1innodb.result
  mysql-test/r/date_formats.result
  mysql-test/r/events_bugs.result
  mysql-test/r/innodb_mysql.result
  mysql-test/r/log_state.result
  mysql-test/r/mysql.result
  mysql-test/r/partition_pruning.result
  mysql-test/r/read_buffer_size_basic.result
  mysql-test/r/read_rnd_buffer_size_basic.result
  mysql-test/r/temp_table.result
  mysql-test/r/type_date.result
  mysql-test/suite/binlog/r/binlog_database.result
  mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc
  mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result
  mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result
  mysql-test/t/date_formats.test
  mysql-test/t/events_bugs.test
  mysql-test/t/innodb_bug38231.test
  mysql-test/t/innodb_mysql.test
  mysql-test/t/log_state.test
  mysql-test/t/mysql.test
  mysql-test/t/partition_pruning.test
  mysql-test/t/temp_table.test
  mysql-test/t/type_date.test
  mysys/my_getopt.c
  sql-common/my_time.c
  sql/filesort.cc
  sql/ha_partition.cc
  sql/item_strfunc.cc
  sql/log_event.cc
  sql/log_event.h
  sql/mysqld.cc
  sql/repl_failsafe.cc
  sql/slave.cc
  sql/sql_base.cc
  sql/sql_binlog.cc
  sql/sql_delete.cc
  sql/sql_lex.h
  sql/sql_partition.cc
  sql/sql_profile.cc
  sql/sql_repl.cc
  storage/innobase/handler/ha_innodb.cc
  mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test

=== modified file 'client/mysqltest.c'
--- a/client/mysqltest.c	2009-01-05 22:25:03 +0000
+++ b/client/mysqltest.c	2009-01-09 18:35:02 +0000
@@ -1342,7 +1342,7 @@ int diff_check()
 {
  char buf[512]= {0};
  FILE *res_file;
- char *cmd = "diff -v";
+ const char *cmd = "diff -v";
  int have_diff = 0;
 
   if (!(res_file= popen(cmd, "r")))

=== modified file 'mysql-test/extra/binlog_tests/database.test'
--- a/mysql-test/extra/binlog_tests/database.test	2008-08-27 08:40:11 +0000
+++ b/mysql-test/extra/binlog_tests/database.test	2009-01-12 23:45:35 +0000
@@ -28,3 +28,5 @@ enable_warnings;
 insert into t1 values (1);
 drop table tt1, t1;
 source include/show_binlog_events.inc;
+
+FLUSH STATUS;

=== added file 'mysql-test/include/check_events_off.inc'
--- a/mysql-test/include/check_events_off.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/check_events_off.inc	2009-01-09 14:10:03 +0000
@@ -0,0 +1,31 @@
+##########   include/check_events_off.inc   ####################################
+#                                                                              #
+# Purpose:                                                                     #
+# Wait till we can expect that we have no event activity till the scheduler is #
+# switched on again.                                                           #
+# = There will be no modifications of user tables by existing events           #
+#   except they use "INSERT DELAYED" or the server system variable             #
+#   "concurrent_inserts" is not switched off.                                  #
+#   Only some storage engines support concurrent_inserts" or "INSERT DELAYED". #
+#                                                                              #
+# Creation:                                                                    #
+# 2008-12-19 mleich Implement this check needed for bug fixes in tests         #
+#                                                                              #
+################################################################################
+
+# 1. Check that the server system variable shows the state needed
+if (`SELECT @@global.event_scheduler <> 'OFF'`)
+{
+   --echo # Error: We expect here that the event scheduler is switched off.
+   SELECT @@global.event_scheduler;
+   --echo #        Thinkable reasons:
+   --echo #        1. SET GLOBAL event_scheduler = OFF had not the expected effect.
+   --echo #        2. Use of the current routine (include/check_events_off.inc)
+   --echo #           within the wrong situation
+   --die
+}
+# 2. Wait till we have no event_scheduler session within the processlist
+--source include/no_running_event_scheduler.inc
+# 3. Wait till we have no event executor sessions within the processlist
+--source include/no_running_events.inc
+

=== modified file 'mysql-test/include/commit.inc'
--- a/mysql-test/include/commit.inc	2008-12-12 12:52:20 +0000
+++ b/mysql-test/include/commit.inc	2009-01-12 12:48:33 +0000
@@ -617,10 +617,10 @@ call p_verify_status_increment(0, 0, 0, 
 --echo
 --echo # No test because of Bug#8729 "rename table fails on temporary table"
 
---echo # 24. DDL: TRUNCATE TEMPORARY TABLE, does not start a transaction
+--echo # 24. DDL: TRUNCATE TEMPORARY TABLE
 --echo
 truncate table t2;
-call p_verify_status_increment(2, 0, 2, 0);
+call p_verify_status_increment(4, 0, 4, 0);
 commit;
 --echo # There is nothing left to commit
 call p_verify_status_increment(0, 0, 0, 0);
@@ -733,7 +733,7 @@ call p_verify_status_increment(1, 0, 1, 
 rename table t4 to t3;
 call p_verify_status_increment(1, 0, 1, 0);
 truncate table t3;
-call p_verify_status_increment(2, 2, 2, 2);
+call p_verify_status_increment(4, 4, 4, 4);
 create view v1 as select * from t2;
 call p_verify_status_increment(1, 0, 1, 0);
 check table t1;

=== modified file 'mysql-test/include/have_32bit.inc'
--- a/mysql-test/include/have_32bit.inc	2008-05-08 18:13:39 +0000
+++ b/mysql-test/include/have_32bit.inc	2009-01-08 18:13:57 +0000
@@ -11,6 +11,6 @@ eval SET @@global.sort_buffer_size = $sa
 --enable_query_log
 if (!$mach32)
 {
-  skip Need a 32 bit machine;
+  skip Need a 32 bit machine/binary;
 }
 

=== modified file 'mysql-test/include/have_64bit.inc'
--- a/mysql-test/include/have_64bit.inc	2008-05-08 18:13:39 +0000
+++ b/mysql-test/include/have_64bit.inc	2009-01-08 18:13:57 +0000
@@ -9,6 +9,6 @@ eval SET @@session.sort_buffer_size = $s
 --enable_query_log
 if (!$mach64)
 {
-  skip Need a 64 bit machine;
+  skip Need a 64 binary ;
 }
 

=== added file 'mysql-test/include/no_running_event_scheduler.inc'
--- a/mysql-test/include/no_running_event_scheduler.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/no_running_event_scheduler.inc	2009-01-09 14:10:03 +0000
@@ -0,0 +1,23 @@
+##########   include/no_running_event_scheduler.inc   ##########################
+#                                                                              #
+# Wait till the event scheduler disappeared from processlist.                  #
+#                                                                              #
+# The characteristics of the event_scheduler entry within the processlist is   #
+# user = 'event_scheduler' and command = 'Daemon'. I am not 100% sure if       #
+# ther is no short phase with command <> 'Daemon'.                             #
+# A query with WHERE user = 'event_scheduler' only will also catch events in   #
+# startup phase. This is no problem since this phase is very short.            #
+#                                                                              #
+# A wait_timeout of >= 3 seconds was within experiments sufficient even on a   #
+# testing box with heavy parallel load. Therefore 5 seconds should be enough.  #
+#                                                                              #
+# Creation:                                                                    #
+# 2008-12-19 mleich Implement this check needed for test bug fixes             #
+#                                                                              #
+################################################################################
+
+let $wait_timeout= 5;
+let $wait_condition=
+  SELECT COUNT(*) = 0 FROM information_schema.processlist
+  WHERE user = 'event_scheduler';
+--source include/wait_condition.inc

=== added file 'mysql-test/include/no_running_events.inc'
--- a/mysql-test/include/no_running_events.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/no_running_events.inc	2009-01-09 14:10:03 +0000
@@ -0,0 +1,25 @@
+##########   include/no_running_events.inc   ###################################
+#                                                                              #
+# Wait till all event executors have finished their work.                      #
+#                                                                              #
+# Different event executors share the characteristics that their entry within  #
+# processlist contains command = 'Connect'.                                    #
+# Of course the corresponding query will also catch other connections being    #
+# within the connect phase. This is no problem since the connect phase is      #
+# usually very short.                                                          #
+#                                                                              #
+# A wait_timeout of >= 3 seconds was during experiments in case of "simple"    #
+# SQL commands sufficient even on a testing box with heavy parallel load.      #
+# "simple" = no sleeps, no long running commands, no waiting for lock ...      #
+# We use here the default of 30 seconds because this wastes some time only in  #
+# case of unexpected situations.                                               #
+#                                                                              #
+# Creation:                                                                    #
+# 2008-12-19 mleich Implement this check needed for test bug fixes             #
+#                                                                              #
+################################################################################
+
+let $wait_condition=
+  SELECT COUNT(*) = 0 FROM information_schema.processlist
+  WHERE command = 'Connect';
+--source include/wait_condition.inc

=== added file 'mysql-test/include/running_event_scheduler.inc'
--- a/mysql-test/include/running_event_scheduler.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/running_event_scheduler.inc	2009-01-09 14:10:03 +0000
@@ -0,0 +1,30 @@
+#############   include/running_event_scheduler.inc   ##########################
+#                                                                              #
+# Wait till the event scheduler reached its final state within the processlist.#
+#                                                                              #
+# The characteristics of the event_scheduler entry within the processlist is   #
+# user = 'event_scheduler' and command = 'Daemon'. I am not 100% sure if       #
+# ther is no short phase with command <> 'Daemon'.                             #
+# A query with WHERE user = 'event_scheduler' only will also catch events in   #
+# startup phase.                                                               #
+#                                                                              #
+# Creation:                                                                    #
+# 2008-12-19 mleich Implement this check needed for test bug fixes             #
+#                                                                              #
+################################################################################
+
+# 1. Check that the server system variable shows the state needed
+if (`SELECT @@global.event_scheduler <> 'ON'`)
+{
+   --echo # Error: We expect here that the event scheduler is switched on.
+   SELECT @@global.event_scheduler;
+   --echo #        Thinkable reasons:
+   --echo #        1. SET GLOBAL event_scheduler = ON had not the expected effect.
+   --echo #        2. Use of the current routine (include/running_event_scheduler.inc)
+   --echo #           within the wrong situation
+   --die
+}
+let $wait_condition=
+  SELECT COUNT(*) = 1 FROM information_schema.processlist
+  WHERE user = 'event_scheduler' AND command = 'Daemon';
+--source include/wait_condition.inc

=== modified file 'mysql-test/r/commit_1innodb.result'
--- a/mysql-test/r/commit_1innodb.result	2008-12-12 12:52:20 +0000
+++ b/mysql-test/r/commit_1innodb.result	2009-01-12 12:48:33 +0000
@@ -683,10 +683,10 @@ SUCCESS
 # 23. DDL: RENAME TEMPORARY TABLE, does not start a transaction
 
 # No test because of Bug#8729 "rename table fails on temporary table"
-# 24. DDL: TRUNCATE TEMPORARY TABLE, does not start a transaction
+# 24. DDL: TRUNCATE TEMPORARY TABLE
 
 truncate table t2;
-call p_verify_status_increment(2, 0, 2, 0);
+call p_verify_status_increment(4, 0, 4, 0);
 SUCCESS
 
 commit;
@@ -853,7 +853,7 @@ call p_verify_status_increment(1, 0, 1, 
 SUCCESS
 
 truncate table t3;
-call p_verify_status_increment(2, 2, 2, 2);
+call p_verify_status_increment(4, 4, 4, 4);
 SUCCESS
 
 create view v1 as select * from t2;

=== modified file 'mysql-test/r/date_formats.result'
--- a/mysql-test/r/date_formats.result	2008-02-12 19:09:16 +0000
+++ b/mysql-test/r/date_formats.result	2009-01-09 13:22:15 +0000
@@ -590,3 +590,13 @@ select str_to_date('04/30/2004 ', '%m/%d
 str_to_date('04/30/2004 ', '%m/%d/%Y ')
 2004-04-30
 "End of 4.1 tests"
+SELECT DATE_FORMAT("0000-01-01",'%W %d %M %Y') as valid_date;
+valid_date
+Sunday 01 January 0000
+SELECT DATE_FORMAT("0000-02-28",'%W %d %M %Y') as valid_date;
+valid_date
+Tuesday 28 February 0000
+SELECT DATE_FORMAT("2009-01-01",'%W %d %M %Y') as valid_date;
+valid_date
+Thursday 01 January 2009
+"End of 5.0 tests"

=== modified file 'mysql-test/r/events_bugs.result'
--- a/mysql-test/r/events_bugs.result	2008-11-04 11:27:21 +0000
+++ b/mysql-test/r/events_bugs.result	2009-01-09 14:10:03 +0000
@@ -3,6 +3,8 @@ drop database if exists mysqltest_db1;
 drop database if exists mysqltest_db2;
 create database events_test;
 use events_test;
+set @concurrent_insert= @@global.concurrent_insert;
+set @@global.concurrent_insert = 0;
 select * from information_schema.global_variables where variable_name like 'event_scheduler';
 VARIABLE_NAME	VARIABLE_VALUE
 EVENT_SCHEDULER	ON
@@ -60,7 +62,7 @@ select get_lock('test_bug16407', 60);
 end|
 "Now if everything is fine the event has compiled and is locked"
 select /*1*/ user, host, db, info from information_schema.processlist
-where info = 'select get_lock(\'test_bug16407\', 60)';
+where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)';
 user	host	db	info
 root	localhost	events_test	select get_lock('test_bug16407', 60)
 select release_lock('test_bug16407');
@@ -84,7 +86,7 @@ get_lock('ee_16407_2', 60)
 set global event_scheduler= 1;
 "Another sql_mode test"
 set sql_mode="traditional";
-create table events_smode_test(ev_name char(10), a date) engine=myisam;
+create table events_smode_test(ev_name char(10), a date);
 "This should never insert something"
 create event ee_16407_2 on schedule every 60 second do
 begin
@@ -92,7 +94,7 @@ select get_lock('ee_16407_2', 60) /*ee_1
 select release_lock('ee_16407_2');
 insert into events_test.events_smode_test values('ee_16407_2','1980-19-02');
 end|
-insert into events_smode_test values ('test','1980-19-02')|
+insert into events_test.events_smode_test values ('test','1980-19-02')|
 ERROR 22007: Incorrect date value: '1980-19-02' for column 'a' at row 1
 "This is ok"
 create event ee_16407_3 on schedule every 60 second do
@@ -116,7 +118,7 @@ events_test	ee_16407_2	STRICT_TRANS_TABL
 events_test	ee_16407_3	STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
 events_test	ee_16407_4	
 select /*2*/ user, host, db, info from information_schema.processlist
-where info = 'select get_lock(\'ee_16407_2\', 60)';
+where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)';
 user	host	db	info
 root	localhost	events_test	select get_lock('ee_16407_2', 60)
 root	localhost	events_test	select get_lock('ee_16407_2', 60)
@@ -125,10 +127,10 @@ select release_lock('ee_16407_2');
 release_lock('ee_16407_2')
 1
 select /*3*/ user, host, db, info from information_schema.processlist
-where info = 'select get_lock(\'ee_16407_2\', 60)';
+where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)';
 user	host	db	info
 set global event_scheduler= off;
-select * from events_smode_test order by ev_name, a;
+select * from events_test.events_smode_test order by ev_name, a;
 ev_name	a
 ee_16407_3	1980-02-19
 ee_16407_3	1980-02-29
@@ -143,7 +145,7 @@ drop event ee_16407_2;
 drop event ee_16407_3;
 drop event ee_16407_4;
 "And now one last test regarding sql_mode and call of SP from an event"
-delete from events_smode_test;
+delete from events_test.events_smode_test;
 set sql_mode='ansi';
 select get_lock('ee_16407_5', 60);
 get_lock('ee_16407_5', 60)
@@ -166,10 +168,8 @@ call events_test.ee_16407_6_pendant();
 end|
 "Should have 2 locked processes"
 select /*4*/ user, host, db, info from information_schema.processlist
-where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%')
-order by info;
+where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)';
 user	host	db	info
-event_scheduler	localhost	NULL	NULL
 root	localhost	events_test	select get_lock('ee_16407_5', 60)
 root	localhost	events_test	select get_lock('ee_16407_5', 60)
 select release_lock('ee_16407_5');
@@ -177,11 +177,9 @@ release_lock('ee_16407_5')
 1
 "Should have 0 processes locked"
 select /*5*/ user, host, db, info from information_schema.processlist
-where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%')
-order by info;
+where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)';
 user	host	db	info
-event_scheduler	localhost	NULL	NULL
-select * from events_smode_test order by ev_name, a;
+select * from events_test.events_smode_test order by ev_name, a;
 ev_name	a
 ee_16407_6	2004-02-29
 "And here we check one more time before we drop the events"
@@ -740,3 +738,4 @@ name
 drop event e1;
 DROP DATABASE events_test;
 SET GLOBAL event_scheduler = 'ON';
+SET @@global.concurrent_insert = @concurrent_insert;

=== modified file 'mysql-test/r/innodb_mysql.result'
--- a/mysql-test/r/innodb_mysql.result	2008-12-08 10:23:33 +0000
+++ b/mysql-test/r/innodb_mysql.result	2009-01-09 10:20:32 +0000
@@ -1767,4 +1767,83 @@ ref	NULL
 rows	6
 Extra	Using where; Using index
 DROP TABLE foo, bar, foo2;
+DROP TABLE IF EXISTS t1,t3,t2;
+DROP FUNCTION IF EXISTS f1;
+CREATE FUNCTION f1() RETURNS VARCHAR(250)
+BEGIN
+return 'hhhhhhh' ;
+END|
+CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB;
+BEGIN WORK;
+CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB;
+CREATE TEMPORARY TABLE t3 LIKE t2;
+INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL);
+SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl');
+PREPARE stmt1 FROM @stmt;
+SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2');
+PREPARE stmt3 FROM @stmt;
+EXECUTE stmt1;
+COMMIT;
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt3;
+DROP TABLE t1,t3,t2;
+DROP FUNCTION f1;
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
+CREATE TABLE t2 (id INT PRIMARY KEY,
+t1_id INT, INDEX par_ind (t1_id),
+FOREIGN KEY (t1_id) REFERENCES t1(id)) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1),(2);
+INSERT INTO t2 VALUES (3,2);
+SET AUTOCOMMIT = 0;
+START TRANSACTION;
+TRUNCATE TABLE t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`))
+SELECT * FROM t1;
+id
+1
+2
+COMMIT;
+SELECT * FROM t1;
+id
+1
+2
+START TRANSACTION;
+TRUNCATE TABLE t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`))
+SELECT * FROM t1;
+id
+1
+2
+ROLLBACK;
+SELECT * FROM t1;
+id
+1
+2
+SET AUTOCOMMIT = 1;
+START TRANSACTION;
+SELECT * FROM t1;
+id
+1
+2
+COMMIT;
+TRUNCATE TABLE t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`))
+SELECT * FROM t1;
+id
+1
+2
+DELETE FROM t2 WHERE id = 3;
+START TRANSACTION;
+SELECT * FROM t1;
+id
+1
+2
+TRUNCATE TABLE t1;
+ROLLBACK;
+SELECT * FROM t1;
+id
+TRUNCATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
 End of 5.1 tests

=== added file 'mysql-test/r/innodb_mysql_rbk.result'
--- a/mysql-test/r/innodb_mysql_rbk.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_mysql_rbk.result	2009-01-09 12:04:47 +0000
@@ -0,0 +1,21 @@
+CREATE TABLE t1(a INT, b INT NOT NULL, PRIMARY KEY (a)) ENGINE=innodb
+DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
+START TRANSACTION;
+SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE;
+a	b
+3	3
+START TRANSACTION;
+UPDATE t1 SET b=b+12 WHERE a > 2 ORDER BY a;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+ROLLBACK;
+START TRANSACTION;
+SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE;
+a	b
+3	3
+START TRANSACTION;
+UPDATE t1 SET b=10 WHERE a > 1 ORDER BY a;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+SELECT * FROM t1 WHERE b = 10;
+a	b
+DROP TABLE t1;

=== modified file 'mysql-test/r/log_state.result'
--- a/mysql-test/r/log_state.result	2008-10-06 09:29:42 +0000
+++ b/mysql-test/r/log_state.result	2009-01-13 13:09:24 +0000
@@ -1,3 +1,7 @@
+SET @old_general_log= @@global.general_log;
+SET @old_general_log_file= @@global.general_log_file;
+SET @old_slow_query_log= @@global.slow_query_log;
+SET @old_slow_query_log_file= @@global.slow_query_log_file;
 set global general_log= OFF;
 truncate table mysql.general_log;
 truncate table mysql.slow_log;
@@ -33,20 +37,26 @@ general_log	ON
 log	ON
 log_slow_queries	OFF
 slow_query_log	OFF
-set session long_query_time=1;
-select sleep(2);
-sleep(2)
+# Establish connection con1 (user=root)
+# Switch to connection con1
+set @long_query_time = <long_query_time>;
+set session long_query_time = @long_query_time;
+select sleep(@long_query_time + 1);
+sleep(@long_query_time + 1)
 0
 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
 start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
+# Switch to connection default
 set global slow_query_log= ON;
-set session long_query_time=1;
-select sleep(2);
-sleep(2)
+# Switch to connection con1
+set session long_query_time = @long_query_time;
+select sleep(@long_query_time + 1);
+sleep(@long_query_time + 1)
 0
 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
 start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
-TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	select sleep(2)
+TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	select sleep(@long_query_time + 1)
+# Switch to connection default
 show global variables
 where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
 Variable_name = 'general_log' or Variable_name = 'slow_query_log';
@@ -92,8 +102,8 @@ slow_query_log_file	#
 show variables like 'log_output';
 Variable_name	Value
 log_output	FILE,TABLE
-set global general_log_file='/not exiting path/log.master';
-ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not exiting path/log.master'
+set global general_log_file='/not existing path/log.master';
+ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not existing path/log.master'
 set global general_log_file='MYSQLTEST_VARDIR';
 ERROR 42000: Variable 'general_log_file' can't be set to the value of 'MYSQLTEST_VARDIR'
 set global general_log_file='';
@@ -153,8 +163,10 @@ select * from mysql.general_log;
 event_time	user_host	thread_id	server_id	command_type	argument
 TIMESTAMP	USER_HOST	#	1	Query	drop table t1
 TIMESTAMP	USER_HOST	#	1	Query	select * from mysql.general_log
-SET @old_general_log_state = @@global.general_log;
-SET @old_slow_log_state = @@global.slow_query_log;
+SET @@global.general_log = @old_general_log;
+SET @@global.general_log_file = @old_general_log_file;
+SET @@global.slow_query_log = @old_slow_query_log;
+SET @@global.slow_query_log_file = @old_slow_query_log_file;
 SET GLOBAL general_log = ON;
 SET GLOBAL slow_query_log = ON;
 FLUSH TABLES WITH READ LOCK;
@@ -173,10 +185,9 @@ SET GLOBAL READ_ONLY = ON;
 SET GLOBAL general_log = ON;
 SET GLOBAL slow_query_log = ON;
 SET GLOBAL READ_ONLY = OFF;
-SET GLOBAL general_log = @old_general_log_state;
-SET GLOBAL slow_query_log = @old_slow_log_state;
-SET @old_general_log_state = @@global.general_log;
-SET @old_slow_log_state = @@global.slow_query_log;
+SET GLOBAL general_log = @old_general_log;
+SET GLOBAL slow_query_log = @old_slow_query_log;
+SET GLOBAL general_log = ON;
 SHOW VARIABLES LIKE 'general_log';
 Variable_name	Value
 general_log	ON
@@ -239,29 +250,24 @@ log_slow_queries	ON
 SELECT @@slow_query_log, @@log_slow_queries;
 @@slow_query_log	@@log_slow_queries
 1	1
-SET GLOBAL general_log = @old_general_log_state;
-SET GLOBAL slow_query_log = @old_slow_log_state;
-set @old_general_log_file= @@global.general_log_file;
-set @old_slow_query_log_file= @@global.slow_query_log_file;
-set global general_log_file= concat('/not exiting path/log.maste', 'r');
-ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not exiting path/log.master'
-set global general_log_file= NULL;
+SET GLOBAL general_log = @old_general_log;
+SET GLOBAL slow_query_log = @old_slow_query_log;
+SET GLOBAL general_log_file= CONCAT('/not existing path/log.maste', 'r');
+ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not existing path/log.master'
+SET GLOBAL general_log_file= NULL;
 ERROR 42000: Variable 'general_log_file' can't be set to the value of 'NULL'
-set global slow_query_log_file= concat('/not exiting path/log.maste', 'r');
-ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/not exiting path/log.master'
-set global slow_query_log_file= NULL;
+SET GLOBAL slow_query_log_file= CONCAT('/not existing path/log.maste', 'r');
+ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/not existing path/log.master'
+SET GLOBAL slow_query_log_file= NULL;
 ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'NULL'
-set global general_log_file= @old_general_log_file;
-set global slow_query_log_file= @old_slow_query_log_file;
+SET GLOBAL general_log_file= @old_general_log_file;
+SET GLOBAL slow_query_log_file= @old_slow_query_log_file;
 
 # --
 # -- Bug#32748: Inconsistent handling of assignments to
-# -- general_log_file/slow_query_log_file.
+# --            general_log_file/slow_query_log_file.
 # --
 
-SET @general_log_file_saved = @@global.general_log_file;
-SET @slow_query_log_file_saved = @@global.slow_query_log_file;
-
 SET GLOBAL general_log_file = 'bug32748.query.log';
 SET GLOBAL slow_query_log_file = 'bug32748.slow.log';
 
@@ -270,8 +276,8 @@ Variable_name	Value
 general_log_file	bug32748.query.log
 slow_query_log_file	bug32748.slow.log
 
-SET GLOBAL general_log_file = @general_log_file_saved;
-SET GLOBAL slow_query_log_file = @slow_query_log_file_saved;
+SET GLOBAL general_log_file = @old_general_log_file;
+SET GLOBAL slow_query_log_file = @old_slow_query_log_file;
 
 # -- End of Bug#32748.
 deprecated:
@@ -298,4 +304,13 @@ SET GLOBAL general_log_file = @my_glf;
 SET GLOBAL slow_query_log_file = @my_sqlf;
 SET GLOBAL general_log = DEFAULT;
 SET GLOBAL slow_query_log = DEFAULT;
+SET @@global.general_log = @old_general_log;
+SET @@global.general_log_file = @old_general_log_file;
+SET @@global.slow_query_log = @old_slow_query_log;
+SET @@global.slow_query_log_file = @old_slow_query_log_file;
 End of 5.1 tests
+# Close connection con1
+SET global general_log = @old_general_log;
+SET global general_log_file = @old_general_log_file;
+SET global slow_query_log = @old_slow_query_log;
+SET global slow_query_log_file = @old_slow_query_log_file;

=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result	2008-12-11 17:46:20 +0000
+++ b/mysql-test/r/mysql.result	2009-01-09 17:51:52 +0000
@@ -186,6 +186,8 @@ delimiter
 2
 2
 2
+@z:='1'	@z=database()
+1	NULL
 End of 5.0 tests
 WARNING: --server-arg option not supported in this configuration.
 Warning (Code 1286): Unknown table engine 'nonexistent'

=== modified file 'mysql-test/r/partition_pruning.result'
--- a/mysql-test/r/partition_pruning.result	2008-07-07 20:42:19 +0000
+++ b/mysql-test/r/partition_pruning.result	2008-12-28 11:33:49 +0000
@@ -1,4 +1,16 @@
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+CREATE TABLE t1
+(a INT NOT NULL AUTO_INCREMENT,
+b DATETIME,
+PRIMARY KEY (a,b),
+KEY (b))
+PARTITION BY RANGE (to_days(b))
+(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01',
+PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01',
+PARTITION pX VALUES LESS THAN MAXVALUE);
+SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00';
+a	b
+DROP TABLE t1;
 create table t1 ( a int not null) partition by hash(a) partitions 2;
 insert into t1 values (1),(2),(3);
 explain select * from t1 where a=5 and a=6;

=== modified file 'mysql-test/r/read_buffer_size_basic.result'
--- a/mysql-test/r/read_buffer_size_basic.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/read_buffer_size_basic.result	2009-01-12 05:32:49 +0000
@@ -86,6 +86,8 @@ SELECT @@global.read_buffer_size= 8200 O
 @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228
 1
 SET @@global.read_buffer_size = 2147479553;
+Warnings:
+Warning	1292	Truncated incorrect read_buffer_size value: '2147479553'
 SELECT @@global.read_buffer_size;
 @@global.read_buffer_size
 2147479552
@@ -114,6 +116,8 @@ SELECT @@session.read_buffer_size= 8200 
 SET @@session.read_buffer_size = 65530.34.;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
 SET @@session.read_buffer_size = 2147479553;
+Warnings:
+Warning	1292	Truncated incorrect read_buffer_size value: '2147479553'
 SELECT @@session.read_buffer_size;
 @@session.read_buffer_size
 2147479552

=== modified file 'mysql-test/r/read_rnd_buffer_size_basic.result'
--- a/mysql-test/r/read_rnd_buffer_size_basic.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/read_rnd_buffer_size_basic.result	2009-01-12 05:32:49 +0000
@@ -88,6 +88,8 @@ SELECT @@global.read_rnd_buffer_size= 82
 @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 8228
 1
 SET @@global.read_rnd_buffer_size = 2147479553;
+Warnings:
+Warning	1292	Truncated incorrect read_rnd_buffer_size value: '2147479553'
 SELECT @@global.read_rnd_buffer_size;
 @@global.read_rnd_buffer_size
 2147479552
@@ -116,6 +118,8 @@ SELECT @@session.read_rnd_buffer_size= 8
 SET @@session.read_rnd_buffer_size = 65530.34.;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
 SET @@session.read_rnd_buffer_size = 2147479553;
+Warnings:
+Warning	1292	Truncated incorrect read_rnd_buffer_size value: '2147479553'
 SELECT @@session.read_rnd_buffer_size;
 @@session.read_rnd_buffer_size
 2147479552

=== modified file 'mysql-test/r/temp_table.result'
--- a/mysql-test/r/temp_table.result	2008-03-28 15:16:52 +0000
+++ b/mysql-test/r/temp_table.result	2009-01-07 12:11:37 +0000
@@ -194,4 +194,20 @@ DELETE FROM t1;
 SELECT * FROM t1;
 a	b
 DROP TABLE t1;
+DROP TABLE IF EXISTS t1,t2;
+DROP FUNCTION IF EXISTS f1;
+CREATE TEMPORARY TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 LIKE t1;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+return 1;
+END|
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t1 SELECT f1();
+CREATE TABLE t3 SELECT * FROM t1;
+INSERT INTO t1 SELECT f1();
+UPDATE t1,t2 SET t1.a = t2.a;
+INSERT INTO t2 SELECT f1();
+DROP TABLE t1,t2,t3;
+DROP FUNCTION f1;
 End of 5.1 tests

=== modified file 'mysql-test/r/type_date.result'
--- a/mysql-test/r/type_date.result	2008-01-10 10:37:54 +0000
+++ b/mysql-test/r/type_date.result	2009-01-13 14:04:28 +0000
@@ -65,12 +65,15 @@ CREATE TABLE t1(AFIELD INT);
 INSERT INTO t1 VALUES(1);
 CREATE TABLE t2(GMT  VARCHAR(32));
 INSERT INTO t2 VALUES('GMT-0800');
-SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT)) FROM t1, t2 GROUP BY t1.AFIELD;
-DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT))
+SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT))
+FROM t1, t2 GROUP BY t1.AFIELD;
+DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT))
 Wed, 06 March 2002 10:11:12 GMT-0800
 INSERT INTO t1 VALUES(1);
-SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT)), DATE_FORMAT("2002-03-06 10:11:12",  CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT)) FROM t1,t2 GROUP BY t1.AFIELD;
-DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT))	DATE_FORMAT("2002-03-06 10:11:12",  CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT))
+SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)),
+DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT))
+FROM t1,t2 GROUP BY t1.AFIELD;
+DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT))	DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT))
 Wed, 06 March 2002 10:11:12 GMT-0800	Wed, 06 March 2002 10:11:12 GMT-0800
 drop table t1,t2;
 CREATE TABLE t1 (f1 time default NULL, f2 time default NULL);
@@ -155,7 +158,7 @@ str_to_date( '', a )
 0000-00-00 00:00:00
 NULL
 DROP TABLE t1;
-CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b));
+CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b));
 INSERT INTO t1 VALUES (DATE(NOW()), 1);
 SELECT COUNT(*) FROM t1 WHERE a = NOW();
 COUNT(*)

=== modified file 'mysql-test/suite/binlog/r/binlog_database.result'
--- a/mysql-test/suite/binlog/r/binlog_database.result	2008-08-27 08:40:11 +0000
+++ b/mysql-test/suite/binlog/r/binlog_database.result	2009-01-12 23:45:35 +0000
@@ -33,6 +33,7 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1)
 master-bin.000001	#	Query	#	#	use `test`; drop table tt1, t1
+FLUSH STATUS;
 set binlog_format=mixed;
 reset master;
 create database testing_1;
@@ -68,6 +69,7 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1)
 master-bin.000001	#	Query	#	#	use `test`; drop table tt1, t1
+FLUSH STATUS;
 set binlog_format=row;
 reset master;
 create database testing_1;
@@ -108,6 +110,7 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
+FLUSH STATUS;
 show databases;
 Database
 information_schema

=== renamed file 'mysql-test/suite/funcs_1/r/is_collation_character_set_applicability.result' => 'mysql-test/suite/funcs_1/r/is_coll_char_set_appl.result'
=== renamed file 'mysql-test/suite/funcs_1/t/is_collation_character_set_applicability.test' => 'mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test'
--- a/mysql-test/suite/funcs_1/t/is_collation_character_set_applicability.test	2008-06-18 17:23:55 +0000
+++ b/mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test	2009-01-13 13:26:24 +0000
@@ -1,7 +1,7 @@
-# suite/funcs_1/t/is_collation_character_set_applicability.test
+# suite/funcs_1/t/is_coll_char_set_appl.test
 #
 # Check the layout of information_schema.collation_character_set_applicability
-# and some functionality realted tests.
+# and some functionality related tests.
 #
 # Author:
 # 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of

=== modified file 'mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc'
--- a/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc	2008-12-01 08:32:07 +0000
+++ b/mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc	2009-01-08 18:13:57 +0000
@@ -40,9 +40,12 @@
 #                 Save initial value                        #
 #############################################################
 
-# due to differences when running on Windows (bug filed)
+# due to differences when running on Windows (Bug#36695)
 --source include/not_windows.inc
 
+let $kbrange32 = BETWEEN 32776 AND 32999;
+let $mbrange2 = BETWEEN 2097116 AND 2100000;
+
 --disable_warnings
 
 SET @start_global_value = @@global.sort_buffer_size;
@@ -55,11 +58,13 @@ SET @start_session_value = @@session.sor
 
 SET @@global.sort_buffer_size = 1000;
 SET @@global.sort_buffer_size = DEFAULT;
-SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000;
+eval
+SELECT @@global.sort_buffer_size $mbrange2;
 
 SET @@session.sort_buffer_size = 2000;
 SET @@session.sort_buffer_size = DEFAULT;
-SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000;
+eval 
+SELECT @@session.sort_buffer_size $mbrange2;
 
 
 --echo '#--------------------FN_DYNVARS_151_02-------------------------#'
@@ -68,10 +73,12 @@ SELECT @@session.sort_buffer_size >= 209
 ######################################################################
 
 SET @@global.sort_buffer_size = DEFAULT;
-SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000;
+eval 
+SELECT @@global.sort_buffer_size $mbrange2;
 
 SET @@session.sort_buffer_size = DEFAULT;
-SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000;
+eval 
+SELECT @@session.sort_buffer_size $mbrange2;
 
 
 --echo '#--------------------FN_DYNVARS_151_03-------------------------#'
@@ -80,9 +87,11 @@ SELECT @@session.sort_buffer_size >= 209
 ################################################################################
 
 SET @@global.sort_buffer_size = 32776;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
+eval 
+SELECT @@global.sort_buffer_size $kbrange32;
 SET @@global.sort_buffer_size = 32777;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
+eval 
+SELECT @@global.sort_buffer_size $kbrange32;
 SET @@global.sort_buffer_size = 4294967295;
 SELECT @@global.sort_buffer_size;
 SET @@global.sort_buffer_size = 4294967294;
@@ -94,9 +103,11 @@ SELECT @@global.sort_buffer_size;
 ###################################################################################
  
 SET @@session.sort_buffer_size = 32776;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
+eval 
+SELECT @@session.sort_buffer_size $kbrange32;
 SET @@session.sort_buffer_size = 32777;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
+eval 
+SELECT @@session.sort_buffer_size $kbrange32;
 SET @@session.sort_buffer_size = 4294967295;
 SELECT @@session.sort_buffer_size;
 SET @@session.sort_buffer_size = 4294967294;
@@ -109,9 +120,11 @@ SELECT @@session.sort_buffer_size;
 ##################################################################
 
 SET @@global.sort_buffer_size = 32775;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
+eval 
+SELECT @@global.sort_buffer_size $kbrange32;
 SET @@global.sort_buffer_size = -1024;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
+eval 
+SELECT @@global.sort_buffer_size $kbrange32;
 SET @@global.sort_buffer_size = 4294967296;
 SELECT @@global.sort_buffer_size;
 --Error ER_PARSE_ERROR
@@ -122,9 +135,11 @@ SET @@global.sort_buffer_size = test;
 SELECT @@global.sort_buffer_size;
 
 SET @@session.sort_buffer_size = 32775;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
+eval 
+SELECT @@session.sort_buffer_size $kbrange32;
 SET @@session.sort_buffer_size = -2;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
+eval 
+SELECT @@session.sort_buffer_size $kbrange32;
 --Error ER_PARSE_ERROR
 SET @@session.sort_buffer_size = 65530.34.;
 SET @@session.sort_buffer_size = 4294967296;
@@ -148,7 +163,7 @@ SELECT @@global.sort_buffer_size = VARIA
 ####################################################################
 
 SELECT @@session.sort_buffer_size = VARIABLE_VALUE FROM
-       INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size';
+INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='sort_buffer_size';
 
 
 --echo '#------------------FN_DYNVARS_151_08-----------------------#'
@@ -157,9 +172,11 @@ SELECT @@session.sort_buffer_size = VARI
 ####################################################################
 
 SET @@global.sort_buffer_size = TRUE;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
+eval 
+SELECT @@global.sort_buffer_size $kbrange32;
 SET @@global.sort_buffer_size = FALSE;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
+eval 
+SELECT @@global.sort_buffer_size $kbrange32;
 
 --echo '#---------------------FN_DYNVARS_151_09----------------------#'
 #################################################################################### 
@@ -185,7 +202,8 @@ SELECT @@local.sort_buffer_size = @@sess
 ###################################################################################
 
 SET sort_buffer_size = 9100;
-SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000;
+eval 
+SELECT @@sort_buffer_size $kbrange32;
 --Error ER_UNKNOWN_TABLE
 SELECT local.sort_buffer_size;
 --Error ER_UNKNOWN_TABLE

=== modified file 'mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result'
--- a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result	2008-12-01 08:32:07 +0000
+++ b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result	2009-01-08 18:13:57 +0000
@@ -3,31 +3,31 @@ SET @start_session_value = @@session.sor
 '#--------------------FN_DYNVARS_151_01-------------------------#'
 SET @@global.sort_buffer_size = 1000;
 SET @@global.sort_buffer_size = DEFAULT;
-SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000;
-@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000
+SELECT @@global.sort_buffer_size BETWEEN 2097116 AND 2100000;
+@@global.sort_buffer_size BETWEEN 2097116 AND 2100000
 1
 SET @@session.sort_buffer_size = 2000;
 SET @@session.sort_buffer_size = DEFAULT;
-SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000;
-@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000
+SELECT @@session.sort_buffer_size BETWEEN 2097116 AND 2100000;
+@@session.sort_buffer_size BETWEEN 2097116 AND 2100000
 1
 '#--------------------FN_DYNVARS_151_02-------------------------#'
 SET @@global.sort_buffer_size = DEFAULT;
-SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000;
-@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000
+SELECT @@global.sort_buffer_size BETWEEN 2097116 AND 2100000;
+@@global.sort_buffer_size BETWEEN 2097116 AND 2100000
 1
 SET @@session.sort_buffer_size = DEFAULT;
-SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000;
-@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000
+SELECT @@session.sort_buffer_size BETWEEN 2097116 AND 2100000;
+@@session.sort_buffer_size BETWEEN 2097116 AND 2100000
 1
 '#--------------------FN_DYNVARS_151_03-------------------------#'
 SET @@global.sort_buffer_size = 32776;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = 32777;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = 4294967295;
 SELECT @@global.sort_buffer_size;
@@ -39,12 +39,12 @@ SELECT @@global.sort_buffer_size;
 4294967294
 '#--------------------FN_DYNVARS_151_04-------------------------#'
 SET @@session.sort_buffer_size = 32776;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
-@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000
+SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999;
+@@session.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@session.sort_buffer_size = 32777;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
-@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000
+SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999;
+@@session.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@session.sort_buffer_size = 4294967295;
 SELECT @@session.sort_buffer_size;
@@ -56,12 +56,12 @@ SELECT @@session.sort_buffer_size;
 4294967294
 '#------------------FN_DYNVARS_151_05-----------------------#'
 SET @@global.sort_buffer_size = 32775;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = -1024;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = 4294967296;
 SELECT @@global.sort_buffer_size;
@@ -78,12 +78,12 @@ SELECT @@global.sort_buffer_size;
 @@global.sort_buffer_size
 4294967295
 SET @@session.sort_buffer_size = 32775;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
-@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000
+SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999;
+@@session.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@session.sort_buffer_size = -2;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
-@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000
+SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999;
+@@session.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@session.sort_buffer_size = 65530.34.;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
@@ -105,12 +105,12 @@ INFORMATION_SCHEMA.SESSION_VARIABLES WHE
 1
 '#------------------FN_DYNVARS_151_08-----------------------#'
 SET @@global.sort_buffer_size = TRUE;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = FALSE;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 '#---------------------FN_DYNVARS_151_09----------------------#'
 SET @@global.sort_buffer_size = 9000;
@@ -127,8 +127,8 @@ SELECT @@local.sort_buffer_size = @@sess
 1
 '#---------------------FN_DYNVARS_151_11----------------------#'
 SET sort_buffer_size = 9100;
-SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000;
-@@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000
+SELECT @@sort_buffer_size BETWEEN 32776 AND 32999;
+@@sort_buffer_size BETWEEN 32776 AND 32999
 1
 SELECT local.sort_buffer_size;
 ERROR 42S02: Unknown table 'local' in field list

=== modified file 'mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result'
--- a/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result	2008-12-01 08:32:07 +0000
+++ b/mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result	2009-01-08 18:13:57 +0000
@@ -3,31 +3,31 @@ SET @start_session_value = @@session.sor
 '#--------------------FN_DYNVARS_151_01-------------------------#'
 SET @@global.sort_buffer_size = 1000;
 SET @@global.sort_buffer_size = DEFAULT;
-SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000;
-@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000
+SELECT @@global.sort_buffer_size BETWEEN 2097116 AND 2100000;
+@@global.sort_buffer_size BETWEEN 2097116 AND 2100000
 1
 SET @@session.sort_buffer_size = 2000;
 SET @@session.sort_buffer_size = DEFAULT;
-SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000;
-@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000
+SELECT @@session.sort_buffer_size BETWEEN 2097116 AND 2100000;
+@@session.sort_buffer_size BETWEEN 2097116 AND 2100000
 1
 '#--------------------FN_DYNVARS_151_02-------------------------#'
 SET @@global.sort_buffer_size = DEFAULT;
-SELECT @@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000;
-@@global.sort_buffer_size >= 2097116 AND @@global.sort_buffer_size < 3000000
+SELECT @@global.sort_buffer_size BETWEEN 2097116 AND 2100000;
+@@global.sort_buffer_size BETWEEN 2097116 AND 2100000
 1
 SET @@session.sort_buffer_size = DEFAULT;
-SELECT @@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000;
-@@session.sort_buffer_size >= 2097116 AND @@session.sort_buffer_size < 3000000
+SELECT @@session.sort_buffer_size BETWEEN 2097116 AND 2100000;
+@@session.sort_buffer_size BETWEEN 2097116 AND 2100000
 1
 '#--------------------FN_DYNVARS_151_03-------------------------#'
 SET @@global.sort_buffer_size = 32776;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = 32777;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = 4294967295;
 SELECT @@global.sort_buffer_size;
@@ -39,12 +39,12 @@ SELECT @@global.sort_buffer_size;
 4294967294
 '#--------------------FN_DYNVARS_151_04-------------------------#'
 SET @@session.sort_buffer_size = 32776;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
-@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000
+SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999;
+@@session.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@session.sort_buffer_size = 32777;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
-@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000
+SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999;
+@@session.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@session.sort_buffer_size = 4294967295;
 SELECT @@session.sort_buffer_size;
@@ -56,12 +56,12 @@ SELECT @@session.sort_buffer_size;
 4294967294
 '#------------------FN_DYNVARS_151_05-----------------------#'
 SET @@global.sort_buffer_size = 32775;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = -1024;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = 4294967296;
 SELECT @@global.sort_buffer_size;
@@ -78,12 +78,12 @@ SELECT @@global.sort_buffer_size;
 @@global.sort_buffer_size
 4294967296
 SET @@session.sort_buffer_size = 32775;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
-@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000
+SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999;
+@@session.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@session.sort_buffer_size = -2;
-SELECT @@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000;
-@@session.sort_buffer_size >= 32776 AND @@session.sort_buffer_size < 33000
+SELECT @@session.sort_buffer_size BETWEEN 32776 AND 32999;
+@@session.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@session.sort_buffer_size = 65530.34.;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
@@ -105,12 +105,12 @@ INFORMATION_SCHEMA.SESSION_VARIABLES WHE
 1
 '#------------------FN_DYNVARS_151_08-----------------------#'
 SET @@global.sort_buffer_size = TRUE;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 SET @@global.sort_buffer_size = FALSE;
-SELECT @@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000;
-@@global.sort_buffer_size >= 32776 AND @@global.sort_buffer_size < 33000
+SELECT @@global.sort_buffer_size BETWEEN 32776 AND 32999;
+@@global.sort_buffer_size BETWEEN 32776 AND 32999
 1
 '#---------------------FN_DYNVARS_151_09----------------------#'
 SET @@global.sort_buffer_size = 9000;
@@ -127,8 +127,8 @@ SELECT @@local.sort_buffer_size = @@sess
 1
 '#---------------------FN_DYNVARS_151_11----------------------#'
 SET sort_buffer_size = 9100;
-SELECT @@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000;
-@@sort_buffer_size >= 32776 AND @@sort_buffer_size < 33000
+SELECT @@sort_buffer_size BETWEEN 32776 AND 32999;
+@@sort_buffer_size BETWEEN 32776 AND 32999
 1
 SELECT local.sort_buffer_size;
 ERROR 42S02: Unknown table 'local' in field list

=== modified file 'mysql-test/t/date_formats.test'
--- a/mysql-test/t/date_formats.test	2007-06-14 23:57:33 +0000
+++ b/mysql-test/t/date_formats.test	2009-01-09 13:22:15 +0000
@@ -340,3 +340,15 @@ select str_to_date('04/30 /2004', '%m /%
 select str_to_date('04/30/2004 ', '%m/%d/%Y ');
 
 --echo "End of 4.1 tests"
+
+#
+# Bug #41470: DATE_FORMAT() crashes the complete server with a valid date
+#
+
+# show that these two do not crash the server:
+SELECT DATE_FORMAT("0000-01-01",'%W %d %M %Y') as valid_date;
+SELECT DATE_FORMAT("0000-02-28",'%W %d %M %Y') as valid_date;
+# show that date within the Gregorian range render correct results: (THU)
+SELECT DATE_FORMAT("2009-01-01",'%W %d %M %Y') as valid_date;
+
+--echo "End of 5.0 tests"

=== modified file 'mysql-test/t/events_bugs.test'
--- a/mysql-test/t/events_bugs.test	2008-11-04 11:27:21 +0000
+++ b/mysql-test/t/events_bugs.test	2009-01-09 14:10:03 +0000
@@ -1,40 +1,133 @@
 #### t/events_bugs.test
 #
 # Last change:
-# 2008-10-16 mleich
+# 2009-01-08 mleich
 #     - Fix for
-#       Bug#39848 events_bugs fails sporadically on pushbuild
-#              (missing rows in table event_log)
-#       Bug#39863 events_bugs fails sporadically on pushbuild (extra processes
-#                 in I_S.PROCESSLIST)
-#       Bug#39978 main.events_bugs does not clean up
-#       Bug#39569 events_bugs fails sporadically on pushbuild (should have
-#                 failed with errno 1539)
-#     - Minor improvements of formatting
+#       Bug#41111 events_bugs fails sporadically on pushbuild
+#     - Avoid effects of
+#       Bug#41925 Warning 1366 Incorrect string value: ...  for column processlist.info
+#
+# Please set $
+let $fixed_bug41925= 0;
+#     
+# Dear maintainer of this test. Please do NOT remove the next big comment.
+# The tests for events were quite unstable over a significant time because the
+# effects of events in general and their representation within the processlist
+# were partially not known. Therefore I had to make excessive experiments.
+# The comment with the outcome of these experiments will be moved into a README
+# file as soon as the tests for events get their own testsuite.
+#
+# Outcome of some experiments (mleich, mysql-5.1 2008-12):
+# --------------------------------------------------------
+# 0. Most time used setup:
+#    High parallel I/O load
+#    set global event_scheduler= off;
+#    sleep 3;
+#    use events_test;
+#    create event e_16407 on schedule every 2 second do
+#    begin
+#      select 'FIRST COMMAND', sleep(0.5);
+#      select 'SECOND COMMAND';
+#    end|
+#    set global event_scheduler= on;
+#    Start observation of the processlist
+#  
+#
+# 1. SET GLOBAL event_scheduler = 'ON' and immediate observation of the processlist.
+# 1.1 Effects around event scheduler:
+# 1.1.1 First phase (very short)
+#       No user 'event_scheduler' within information_schema.processlist.
+# 1.1.2 Second phase observed (independend of probably existing events and very short) was
+#       USER            HOST       DB   COMMAND TIME STATE        INFO
+#       event_scheduler localhost  NULL Daemon     0 Initialized  NULL
+# 1.1.3 Third phase observed:
+# 1.1.3.1 Case we do not have existing events (rather long)
+#         USER            HOST       DB   COMMAND TIME STATE                  INFO
+#         event_scheduler localhost  NULL Daemon     0 Waiting on empty queue NULL
+# 1.1.3.2 Case there exists already an event
+# 1.1.3.2.1 Event executor is not visible in processlist but comes up soon
+#           USER            HOST       DB    COMMAND TIME STATE  INFO
+#           event_scheduler localhost  NULL  Daemon     0 NULL
+#                   or
+#           event_scheduler localhost  NULL  Daemon     0  NULL  NULL
+# 1.1.3.2.2 A bit later, at least one event executor is or was visible in processlist
+#           The states mentioned in 3.2.1 or a bit later
+#           USER            HOST       DB    COMMAND TIME STATE                        INFO
+#           event_scheduler localhost  NULL  Daemon     0 Waiting for next activation  NULL
+# 1.2 Effects around event executor:
+#     Typical processlist content:
+#     USER    evtest1      -- Definer of event
+#     DB      events_test  -- DB during time of event creation (use DB is not allowed in events)
+#     COMMAND Connect
+#     STATE   NULL
+#     INFO    SET @evname = 'ev_sched_1823' -- Part of the event code
+#
+#     State before "User sleep select 'FIRST COMMAND', sleep(0.5);"
+#     ID  USER            HOST       DB    COMMAND TIME  STATE  INFO
+#     7   event_scheduler localhost  NULL  Connect    0  NULL   NULL
+#     !! The user is not the event creator and the DB is different.  !!
+#     !! This means that we must get later a change of the identity. !!
+#     or
+#     USER  HOST       DB           COMMAND  TIME  STATE                 INFO
+#     root  localhost  events_test  Connect     0  checking permissions
+#     or
+#     USER  HOST       DB           COMMAND  TIME  STATE                 INFO
+#     root  localhost  events_test  Connect     0  checking permissions  CREATE PROCEDURE ....
+#     or
+#     USER  HOST       DB           COMMAND  TIME  STATE  INFO
+#     root  localhost  events_test  Connect     0  NULL   select 'FIRST COMMAND', sleep(0.5)
+#     or
+#     USER  HOST       DB           COMMAND  TIME  STATE                 INFO
+#     root  localhost  events_test  Connect     0  checking permissions  select 'FIRST COMMAND'...
+#     or
+#     USER  HOST       DB           COMMAND  TIME  STATE          INFO
+#     root  localhost  events_test  Connect     0  Opening table  select 'FIRST COMMAND', sleep(0.5)
+#     or
+#     USER  HOST       DB           COMMAND  TIME  STATE   INFO
+#     root  localhost  events_test  Connect     0  Locked  select 'FIRST COMMAND', sleep(0.5)
+#     or
+#     USER  HOST       DB           COMMAND  TIME  STATE      INFO
+#     root  localhost  events_test  Connect     0  executing  select 'FIRST COMMAND', sleep(0.5)
+#
+#     State "User sleep select 'FIRST COMMAND', sleep(0.5);" reached
+#     USER  HOST       DB           COMMAND  TIME  STATE       INFO
+#     root  localhost  events_test  Connect     0  User sleep  select 'FIRST COMMAND', sleep(0.5)
+#
+#     State at end (! It looks like a slow CREATE PROC !) of event code execution was sometimes
+#     USER  HOST       DB           COMMAND  TIME  STATE               INFO
+#     root  localhost  events_test  Connect     0  logging slow query  CREATE PROCEDURE `e_16407`...
+#
+#     State after running some event code was sometimes
+#     USER  HOST       DB           COMMAND  TIME  STATE               INFO
+#     root  localhost  events_test  Connect  0     logging slow query  select 'SECOND COMMAND'
+#
+#     State somewhere (I guess just before the event executor disappears)
+#     USER              HOST     DB           COMMAND  TIME  STATE     INFO
+#     Event thread fin  <empty>  events_test  Connect  0     Clearing  NULL
 #
 #
-# Outcome of some experiments (mleich):
-# 1. SET GLOBAL event_scheduler = 'ON';
-#    Immediate observation of the processlist.
-#    Effects:
-#    1. There is no guarantee to find immediate the user 'event_scheduler'
-#       within information_schema.processlist.
-#    2. Some states of the user 'event_scheduler' found in PROCESSLIST:
-#       USER            HOST       DB   COMMAND TIME STATE                  INFO
-#       event_scheduler localhost  NULL Daemon  0    Waiting on empty queue NULL
-#       event_scheduler localhost  NULL Daemon  0    Initialized            NULL
 # 2. SET GLOBAL event_scheduler = 'OFF';
 #    Immediate observation of the processlist.
 #    Effects:
 #    1. I never found the user 'event_scheduler' within the processlist.
 #    2. Events just during execution could be found within the processlist
 #       = It does not look like "SET GLOBAL event_scheduler = 'OFF'" stops them.
-# 3. An event gets executed
-#    USER evtest1     (Definer of event)
-#    DB   events_test (DB during time of event creation)
-#    COMMAND Connect
-#    STATE   NULL
-#    INFO    SET @evname = 'ev_sched_1823' (Part of the event code)
+#         ==> Everything mentioned in 1.2 above could be observed.
+#
+# Several subtests were weak because they showed random result set differences after issuing
+# "SET GLOBAL EVENT_SCHEDULER= off;".
+#    1. Reason one: There were already event executors
+#       Fix: Wait till there is no event executor active ==> no session WHERE
+#            - command IN ('Connect')
+#              There must be no parallel session being just in "Connect" phase!
+#            or
+#            - user = <who created the maybe current running events>
+#                 There must be no parallel session of this person.
+#              or user = 'event_scheduler' with command = 'Connect'
+#                 The session which will soon change its identity to event creator.
+#
+#    2. Reason two: If an event modifies a MyISAM table than a delayed visibilty of changes
+#                   might occur (concurrent_inserts=on or delayed inserts ...).
 #
 
 # Can't test with embedded server that doesn't support grants
@@ -47,6 +140,10 @@ drop database if exists mysqltest_db2;
 --enable_warnings
 create database events_test;
 use events_test;
+# We use MyISAM tables and must avoid effects (visibility of changes might be
+# delayed) caused by concurrent_insert on (default).
+set @concurrent_insert= @@global.concurrent_insert;
+set @@global.concurrent_insert = 0;
 
 #
 # START:  Bug #31332 --event-scheduler option misbehaving
@@ -56,8 +153,11 @@ use events_test;
 # option with no argument in events_bugs-master.opt turns the scheduler on.
 
 select * from information_schema.global_variables where variable_name like 'event_scheduler';
+# Check that the event_scheduler is really running
+--source include/running_event_scheduler.inc
 
 SET GLOBAL event_scheduler = 'OFF';
+--source include/check_events_off.inc
 
 #
 # END: Bug #31332
@@ -132,8 +232,10 @@ create event e_55 on schedule every 10 h
 # Start - 16407: Events: Changes in sql_mode won't be taken into account
 #
 set global event_scheduler=off;
+--source include/check_events_off.inc
 delete from mysql.event;
 set global event_scheduler= on;
+--source include/running_event_scheduler.inc
 set @old_sql_mode:=@@sql_mode;
 set sql_mode=ansi;
 select get_lock('test_bug16407', 60);
@@ -148,13 +250,13 @@ delimiter ;|
 # We wait till one event runs and hangs when trying to get the user lock.
 let $wait_condition=
   select count(*) > 0 from information_schema.processlist
-  where info = 'select get_lock(\'test_bug16407\', 60)';
+  where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)';
 --source include/wait_condition.inc
 
 --echo "Now if everything is fine the event has compiled and is locked"
 # Expect to see one session in events_test waiting for the user lock.
 select /*1*/ user, host, db, info from information_schema.processlist
-where info = 'select get_lock(\'test_bug16407\', 60)';
+where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)';
 select release_lock('test_bug16407');
 # Try to avoid
 #    Bug#39863 events_bugs fails sporadically on pushbuild (extra processes in I_S.PROCESSLIST)
@@ -162,23 +264,27 @@ select release_lock('test_bug16407');
 #    Bug#32782 User lock hash fails to find lock
 #    "various issues related to missing or incorrect return results
 #     from release_lock()."
-# Therefore we check here if the event executing session disappeared or
+# Therefore we check here if the event executor is no more locked or
 # we waited >= 5 seconds for this to happen.
 let $wait_timeout= 5;
 let $wait_condition=
   select count(*) = 0 from information_schema.processlist
-  where info = 'select get_lock(\'test_bug16407\', 60)';
+  where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)';
 --source include/wait_condition.inc
 if (!`$wait_condition`)
 {
-   --echo ERROR: There must be no session with info = 'select get_lock('test_bug16407', 60) within the processlist.
+   --echo ERROR: There must be no session with
+   --echo        state = 'User lock' and info = 'select get_lock('test_bug16407', 60)
+   --echo        within the processlist.
    --echo        We probably hit Bug#32782 User lock hash fails to find lock
-   eval select * from information_schema.processlist;
+   SELECT * FROM information_schema.processlist;
    --echo Abort
    exit;
 }
 
 set global event_scheduler= off;
+# Wait till the event scheduler and all event executors have finished their work.
+--source include/check_events_off.inc
 
 select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
 --echo "Let's check whether we change the sql_mode on ALTER EVENT"
@@ -191,9 +297,10 @@ set sql_mode="ansi";
 select get_lock('ee_16407_2', 60);
 
 set global event_scheduler= 1;
+--source include/running_event_scheduler.inc
 --echo "Another sql_mode test"
 set sql_mode="traditional";
-create table events_smode_test(ev_name char(10), a date) engine=myisam;
+create table events_smode_test(ev_name char(10), a date);
 --echo "This should never insert something"
 delimiter |;
 create event ee_16407_2 on schedule every 60 second do
@@ -203,7 +310,7 @@ begin
   insert into events_test.events_smode_test values('ee_16407_2','1980-19-02');
 end|
 --error ER_TRUNCATED_WRONG_VALUE
-insert into events_smode_test values ('test','1980-19-02')|
+insert into events_test.events_smode_test values ('test','1980-19-02')|
 --echo "This is ok"
 create event ee_16407_3 on schedule every 60 second do
 begin
@@ -223,13 +330,20 @@ end|
 delimiter ;|
 select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
 
+# We wait till we have three event executors waiting for the removal of the lock.
 let $wait_condition=
   select count(*) = 3 from information_schema.processlist
-  where info = 'select get_lock(\'ee_16407_2\', 60)';
+  where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)';
 --source include/wait_condition.inc
 
+# There is an extreme low risk that an additional event execution is just coming
+# up because
+# - the events have to be started every 60 seconds.
+# - we are just after event creation + waiting for seeing 3 locked
+# We expect to see three event executors in state 'User lock'.
 select /*2*/ user, host, db, info from information_schema.processlist
-where info = 'select get_lock(\'ee_16407_2\', 60)';
+where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)';
+
 select release_lock('ee_16407_2');
 
 # Try to avoid
@@ -244,13 +358,37 @@ let $wait_timeout= 5;
 let $wait_condition=
   select count(*) = 0
   from information_schema.processlist
-  where info = 'select get_lock(\'ee_16407_2\', 60)';
+  where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)';
 --source include/wait_condition.inc
+if (!`$wait_condition`)
+{
+   --echo ERROR: There must be no session with
+   --echo        state = 'User lock' and info = 'select get_lock('test_bug16407_2', 60)
+   --echo        within the processlist.
+   --echo        We probably hit Bug#32782 User lock hash fails to find lock
+   SELECT * FROM information_schema.processlist;
+   --echo Abort
+   exit;
+}
 
+# We expect to see no event executors in state 'User lock'.
+if(!$fixed_bug41925)
+{
+   --disable_warnings
+}
 select /*3*/ user, host, db, info from information_schema.processlist
-where info = 'select get_lock(\'ee_16407_2\', 60)';
+where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)';
+if(!$fixed_bug41925)
+{
+   --enable_warnings
+}
+
 set global event_scheduler= off;
-select * from events_smode_test order by ev_name, a;
+# Wait till the event scheduler and all event executors have finished their work.
+# Without this the next queries will give unstable results.
+--source include/check_events_off.inc
+
+select * from events_test.events_smode_test order by ev_name, a;
 --echo "OK, last check before we drop them"
 select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
 drop event ee_16407_2;
@@ -259,11 +397,12 @@ drop event ee_16407_4;
 
 
 --echo "And now one last test regarding sql_mode and call of SP from an event"
-delete from events_smode_test;
+delete from events_test.events_smode_test;
 set sql_mode='ansi';
 select get_lock('ee_16407_5', 60);
 
 set global event_scheduler= on;
+--source include/running_event_scheduler.inc
 
 set sql_mode='traditional';
 delimiter |;
@@ -286,34 +425,46 @@ delimiter ;|
 
 let $wait_condition=
   select count(*) = 2 from information_schema.processlist
-  where info = 'select get_lock(\'ee_16407_5\', 60)';
+  where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)';
 --source include/wait_condition.inc
 
 --echo "Should have 2 locked processes"
 select /*4*/ user, host, db, info from information_schema.processlist
-where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%')
-order by info;
+where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)';
+
 select release_lock('ee_16407_5');
 
 let $wait_condition=
-  select count(*) = 1 and user = 'event_scheduler' and info is null
-  from information_schema.processlist
-  where (command!='Daemon' || user='event_scheduler')
-  and (info is null or info not like '%processlist%');
+  select count(*) = 0 from information_schema.processlist
+  where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)';
 --source include/wait_condition.inc
 
 --echo "Should have 0 processes locked"
+if(!$fixed_bug41925)
+{
+   --disable_warnings
+}
 select /*5*/ user, host, db, info from information_schema.processlist
-where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%')
-order by info;
-select * from events_smode_test order by ev_name, a;
+where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)';
+if(!$fixed_bug41925)
+{
+   --enable_warnings
+}
+
+# Wait till all event executors have finished their work, so that we can be sure
+# that their changes to events_smode_test are done.
+--source include/no_running_events.inc
+
+select * from events_test.events_smode_test order by ev_name, a;
 --echo "And here we check one more time before we drop the events"
 select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
+
 drop event ee_16407_5;
 drop event ee_16407_6;
 drop procedure ee_16407_5_pendant;
 drop procedure ee_16407_6_pendant;
 set global event_scheduler= off;
+--source include/check_events_off.inc
 drop table events_smode_test;
 set sql_mode=@old_sql_mode;
 #
@@ -324,6 +475,7 @@ set sql_mode=@old_sql_mode;
 # START - 18897: Events: unauthorized action possible with alter event rename
 #
 set global event_scheduler=off;
+--source include/check_events_off.inc
 --disable_warnings
 delete from mysql.user where User like 'mysqltest_%';
 delete from mysql.db where User like 'mysqltest_%';
@@ -409,6 +561,7 @@ create function f22830 () returns int re
 
 select get_lock('ee_22830', 60);
 set global event_scheduler=on;
+--source include/running_event_scheduler.inc
 
 delimiter |;
 create procedure p22830_wait()
@@ -456,6 +609,7 @@ let $wait_condition=
 --source include/wait_condition.inc
 
 set global event_scheduler=off;
+--source include/check_events_off.inc
 select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name;
 drop procedure p22830_wait;
 drop function f22830;
@@ -537,6 +691,7 @@ DROP USER mysqltest_u1@localhost;
 # For the actual tests of time zones please see events_time_zone.test
 #
 SET GLOBAL EVENT_SCHEDULER= OFF;
+--source include/check_events_off.inc
 SET @save_time_zone= @@TIME_ZONE;
 
 #----------------------------------------------------------------------
@@ -749,6 +904,7 @@ let $engine=MyISAM;
 USE test;
 SHOW GRANTS FOR CURRENT_USER;
 SET GLOBAL event_scheduler = ON;
+--source include/running_event_scheduler.inc
 eval
 CREATE TABLE events_test.event_log
 (id int KEY AUTO_INCREMENT, ev_nm char(40), ev_cnt int, ev_tm timestamp)
@@ -817,12 +973,14 @@ disconnect e1;
 DROP EVENT events_test.ev_sched_1823;
 DROP TABLE events_test.event_log;
 SET GLOBAL event_scheduler = OFF;
+--source include/check_events_off.inc
 
 
 #
 # Bug#28641 CREATE EVENT with '2038.01.18 03:00:00' let server crash.
 #
 SET GLOBAL event_scheduler= ON;
+--source include/running_event_scheduler.inc
 DELIMITER |;
 CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00'
 DO BEGIN
@@ -831,6 +989,7 @@ END;|
 
 DELIMITER ;|
 SET GLOBAL event_scheduler= OFF;
+--source include/check_events_off.inc
 DROP EVENT bug28641;
 
 ###########################################################################
@@ -955,6 +1114,7 @@ SET GLOBAL READ_ONLY = 1;
 --echo
 
 SET GLOBAL EVENT_SCHEDULER = ON;
+--source include/running_event_scheduler.inc
 
 --echo
 
@@ -980,6 +1140,7 @@ let $wait_condition =
 --echo
 
 SET GLOBAL EVENT_SCHEDULER = OFF;
+--source include/check_events_off.inc
 
 --echo
 
@@ -1056,14 +1217,15 @@ drop event e1;
 #
 ###########################################################################
 
-let $wait_condition=
-  select count(*) = 0 from information_schema.processlist
-  where db='events_test' and command = 'Connect' and user=current_user();
---source include/wait_condition.inc
+# Ensure that all event executors have finished their work and cannot harm
+# the next test.
+--source include/no_running_events.inc
 
 DROP DATABASE events_test;
 # Restore the original state (option with no argument in events_bugs-master.opt
 # turns the scheduler on).
 SET GLOBAL event_scheduler = 'ON';
+--source include/running_event_scheduler.inc
+SET @@global.concurrent_insert = @concurrent_insert;
 
 # THIS MUST BE THE LAST LINE in this file.

=== modified file 'mysql-test/t/innodb_bug38231.test'
--- a/mysql-test/t/innodb_bug38231.test	2008-12-14 21:26:31 +0000
+++ b/mysql-test/t/innodb_bug38231.test	2009-01-08 12:31:34 +0000
@@ -16,7 +16,6 @@ CREATE TABLE bug38231 (a INT);
 
 -- connect (con1,localhost,root,,)
 -- connect (con2,localhost,root,,)
--- connect (con3,localhost,root,,)
 
 -- connection con1
 SET autocommit=0;
@@ -27,11 +26,6 @@ SET autocommit=0;
 -- send
 LOCK TABLE bug38231 WRITE;
 
--- connection con3
-SET autocommit=0;
--- send
-LOCK TABLE bug38231 WRITE;
-
 -- connection default
 -- send
 TRUNCATE TABLE bug38231;
@@ -39,6 +33,7 @@ TRUNCATE TABLE bug38231;
 -- connection con1
 # give time to TRUNCATE and others to be executed; without sleep, sometimes
 # UNLOCK executes before TRUNCATE
+# TODO: Replace with wait_condition once possible under embedded server.
 -- sleep 0.2
 # this crashes the server if the bug is present
 UNLOCK TABLES;
@@ -46,16 +41,13 @@ UNLOCK TABLES;
 # clean up
 
 -- connection con2
-UNLOCK TABLES;
-
--- connection con3
+-- reap
 UNLOCK TABLES;
 
 -- connection default
-
+-- reap
 -- disconnect con1
 -- disconnect con2
--- disconnect con3
 
 # test that TRUNCATE works with with row-level locks
 

=== modified file 'mysql-test/t/innodb_mysql.test'
--- a/mysql-test/t/innodb_mysql.test	2008-12-08 10:23:33 +0000
+++ b/mysql-test/t/innodb_mysql.test	2009-01-09 10:20:32 +0000
@@ -91,4 +91,97 @@ INSERT INTO foo2 SELECT * FROM foo;
 
 DROP TABLE foo, bar, foo2;
 
+#
+# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t3,t2;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS VARCHAR(250)
+ BEGIN
+     return 'hhhhhhh' ;
+ END|
+DELIMITER ;|
+
+CREATE TABLE t1 (a VARCHAR(20), b VARCHAR(20), c VARCHAR(20)) ENGINE=INNODB;
+
+BEGIN WORK;
+
+CREATE TEMPORARY TABLE t2 (a VARCHAR(20), b VARCHAR(20), c varchar(20)) ENGINE=INNODB;
+CREATE TEMPORARY TABLE t3 LIKE t2;
+
+INSERT INTO t1 VALUES ('a','b',NULL),('c','d',NULL),('e','f',NULL);
+
+SET @stmt := CONCAT('INSERT INTO t2 SELECT tbl.a, tbl.b, f1()',' FROM t1 tbl');
+PREPARE stmt1 FROM @stmt;
+
+SET @stmt := CONCAT('INSERT INTO t3', ' SELECT * FROM t2');
+PREPARE stmt3 FROM @stmt;
+
+EXECUTE stmt1;
+
+COMMIT;
+
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt3;
+
+DROP TABLE t1,t3,t2;
+DROP FUNCTION f1;
+
+#
+# Bug#37016: TRUNCATE TABLE removes some rows but not all
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
+CREATE TABLE t2 (id INT PRIMARY KEY,
+                 t1_id INT, INDEX par_ind (t1_id),
+                 FOREIGN KEY (t1_id) REFERENCES t1(id)) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1),(2);
+INSERT INTO t2 VALUES (3,2);
+
+SET AUTOCOMMIT = 0;
+
+START TRANSACTION;
+--error ER_ROW_IS_REFERENCED_2
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+COMMIT;
+SELECT * FROM t1;
+
+START TRANSACTION;
+--error ER_ROW_IS_REFERENCED_2
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+ROLLBACK;
+SELECT * FROM t1;
+
+SET AUTOCOMMIT = 1;
+
+START TRANSACTION;
+SELECT * FROM t1;
+COMMIT;
+
+--error ER_ROW_IS_REFERENCED_2
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+DELETE FROM t2 WHERE id = 3;
+
+START TRANSACTION;
+SELECT * FROM t1;
+TRUNCATE TABLE t1;
+ROLLBACK;
+SELECT * FROM t1;
+TRUNCATE TABLE t2;
+
+DROP TABLE t2;
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== added file 'mysql-test/t/innodb_mysql_rbk-master.opt'
--- a/mysql-test/t/innodb_mysql_rbk-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_mysql_rbk-master.opt	2009-01-09 12:04:47 +0000
@@ -0,0 +1 @@
+--innodb_lock_wait_timeout=1 --innodb_rollback_on_timeout=1

=== added file 'mysql-test/t/innodb_mysql_rbk.test'
--- a/mysql-test/t/innodb_mysql_rbk.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_mysql_rbk.test	2009-01-09 12:04:47 +0000
@@ -0,0 +1,35 @@
+-- source include/have_innodb.inc
+
+#
+# Bug #41453: Assertion `m_status == DA_ERROR' failed in
+# Diagnostics_area::sql_errno
+#
+
+CREATE TABLE t1(a INT, b INT NOT NULL, PRIMARY KEY (a)) ENGINE=innodb
+DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
+CONNECT (con1,localhost,root,,);
+CONNECT (con2,localhost,root,,);
+
+CONNECTION con1;
+START TRANSACTION;
+SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE;
+CONNECTION con2;
+START TRANSACTION;
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET b=b+12 WHERE a > 2 ORDER BY a;
+ROLLBACK;
+
+CONNECTION con1;
+START TRANSACTION;
+SELECT * FROM t1 WHERE b=3 LIMIT 1 FOR UPDATE;
+CONNECTION con2;
+START TRANSACTION;
+--error ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET b=10 WHERE a > 1 ORDER BY a;
+SELECT * FROM t1 WHERE b = 10;
+
+CONNECTION default;
+DISCONNECT con1;
+DISCONNECT con2;
+DROP TABLE t1;

=== modified file 'mysql-test/t/log_state.test'
--- a/mysql-test/t/log_state.test	2008-10-06 09:29:42 +0000
+++ b/mysql-test/t/log_state.test	2009-01-13 13:09:24 +0000
@@ -1,6 +1,28 @@
--- source include/not_embedded.inc
+### t/log_state.test ###
+#
+# This test suffers from server
+# Bug#38124 "general_log_file" variable silently unset when using expression
+# In short:
+#    SET GLOBAL general_log_file = @<whatever>
+#    SET GLOBAL slow_query_log = @<whatever>
+# cause that the value of these server system variables is set to default
+# instead of the assigned values. There comes no error message or warning.
+# If this bug is fixed please
+# 1. try this test with "let $fixed_bug38124 = 0;"
+# 2. remove all workarounds if 1. was successful.
+let $fixed_bug38124 = 0;
+
+--source include/not_embedded.inc
 --source include/have_csv.inc
 
+# Several subtests modify global variables. Save the initial values only here,
+# but reset to the initial values per subtest.
+SET @old_general_log= @@global.general_log;
+SET @old_general_log_file= @@global.general_log_file;
+SET @old_slow_query_log= @@global.slow_query_log;
+SET @old_slow_query_log_file= @@global.slow_query_log_file;
+
+
 --disable_ps_protocol
 set global general_log= OFF;
 truncate table mysql.general_log;
@@ -23,20 +45,32 @@ show global variables
 where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
 Variable_name = 'general_log' or Variable_name = 'slow_query_log';
 
+--echo # Establish connection con1 (user=root)
 connect (con1,localhost,root,,);
+--echo # Switch to connection con1
 connection con1;
-set session long_query_time=1;
-select sleep(2);
+# Please increase @long_query_time if the corresponding selects show an
+# additional unexpected entry like
+#    start_time ... sql_text
+#    TIMESTAMP  ... set session long_query_time=...
+# (Bug#40377 sporadic pushbuild failure in log_state: result mismatch)
+--replace_result 2 <long_query_time>
+set @long_query_time = 2;
+set session long_query_time = @long_query_time;
+select sleep(@long_query_time + 1);
 --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME
 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
+--echo # Switch to connection default
 connection default;
 
 set global slow_query_log= ON;
+--echo # Switch to connection con1
 connection con1;
-set session long_query_time=1;
-select sleep(2);
+set session long_query_time = @long_query_time;
+select sleep(@long_query_time + 1);
 --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME
 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
+--echo # Switch to connection default
 connection default;
 show global variables
 where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
@@ -71,16 +105,16 @@ show variables like 'slow_query_log_file
 show variables like 'log_output';
 
 # Can't set general_log_file to a non existing file
---error 1231
-set global general_log_file='/not exiting path/log.master';
+--error ER_WRONG_VALUE_FOR_VAR
+set global general_log_file='/not existing path/log.master';
 
 # Can't set general_log_file to a directory
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---error 1231
+--error ER_WRONG_VALUE_FOR_VAR
 eval set global general_log_file='$MYSQLTEST_VARDIR';
 
 # Can't set general_log_file to empty string
---error 1231
+--error ER_WRONG_VALUE_FOR_VAR
 set global general_log_file='';
 
 --replace_column 2 #
@@ -126,17 +160,30 @@ drop table t1;
 --replace_column 1 TIMESTAMP 2 USER_HOST 3 #
 select * from mysql.general_log;
 
-#
-# Bug#29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
-# a deadlock)
+# Reset to initial values
+SET @@global.general_log = @old_general_log;
+SET @@global.general_log_file = @old_general_log_file;
+SET @@global.slow_query_log = @old_slow_query_log;
+SET @@global.slow_query_log_file = @old_slow_query_log_file;
+if(!$fixed_bug38124)
+{
+   --disable_query_log
+   let $my_var = `SELECT @old_general_log_file`;
+   eval SET @@global.general_log_file = '$my_var';
+   let $my_var = `SELECT @old_slow_query_log_file`;
+   eval SET @@global.slow_query_log_file = '$my_var';
+   --enable_query_log
+}
 
-# save state
 
-SET @old_general_log_state = @@global.general_log;
-SET @old_slow_log_state = @@global.slow_query_log;
+###########################################################################
 
-# Test ON->OFF transition under a GLOBAL READ LOCK
+#
+# Bug#29129 (Resetting general_log while the GLOBAL READ LOCK is set causes
+#            a deadlock)
+#
 
+# Test ON->OFF transition under a GLOBAL READ LOCK
 SET GLOBAL general_log = ON;
 SET GLOBAL slow_query_log = ON;
 
@@ -148,7 +195,6 @@ SET GLOBAL slow_query_log = OFF;
 UNLOCK TABLES;
 
 # Test OFF->ON transition under a GLOBAL READ LOCK
-
 FLUSH TABLES WITH READ LOCK;
 
 SET GLOBAL general_log = ON;
@@ -157,7 +203,6 @@ SET GLOBAL slow_query_log = ON;
 UNLOCK TABLES;
 
 # Test ON->OFF transition under a GLOBAL READ_ONLY
-
 SET GLOBAL READ_ONLY = ON;
 
 SET GLOBAL general_log = OFF;
@@ -166,7 +211,6 @@ SET GLOBAL slow_query_log = OFF;
 SET GLOBAL READ_ONLY = OFF;
 
 # Test OFF->ON transition under a GLOBAL READ_ONLY
-
 SET GLOBAL READ_ONLY = ON;
 
 SET GLOBAL general_log = ON;
@@ -174,17 +218,18 @@ SET GLOBAL slow_query_log = ON;
 
 SET GLOBAL READ_ONLY = OFF;
 
-# Restore state
+# Reset to initial values
+SET GLOBAL general_log = @old_general_log;
+SET GLOBAL slow_query_log = @old_slow_query_log;
 
-SET GLOBAL general_log = @old_general_log_state;
-SET GLOBAL slow_query_log = @old_slow_log_state;
+
+###########################################################################
 
 #
-# Bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it
+# Bug#29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it
 #
 
-SET @old_general_log_state = @@global.general_log;
-SET @old_slow_log_state = @@global.slow_query_log;
+SET GLOBAL general_log = ON;
 
 SHOW VARIABLES LIKE 'general_log';
 SHOW VARIABLES LIKE 'log';
@@ -210,67 +255,85 @@ SHOW VARIABLES LIKE 'slow_query_log';
 SHOW VARIABLES LIKE 'log_slow_queries';
 SELECT @@slow_query_log, @@log_slow_queries;
 
-SET GLOBAL general_log = @old_general_log_state;
-SET GLOBAL slow_query_log = @old_slow_log_state;
+SET GLOBAL general_log = @old_general_log;
+SET GLOBAL slow_query_log = @old_slow_query_log;
+
+
+###########################################################################
 
 #
-# Bug #31604: server crash when setting slow_query_log_file/general_log_file
+# Bug#31604: server crash when setting slow_query_log_file/general_log_file
 #
-set @old_general_log_file= @@global.general_log_file;
-set @old_slow_query_log_file= @@global.slow_query_log_file;
 
---error 1231
-set global general_log_file= concat('/not exiting path/log.maste', 'r');
---error 1231
-set global general_log_file= NULL;
---error 1231
-set global slow_query_log_file= concat('/not exiting path/log.maste', 'r');
---error 1231
-set global slow_query_log_file= NULL;
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL general_log_file= CONCAT('/not existing path/log.maste', 'r');
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL general_log_file= NULL;
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL slow_query_log_file= CONCAT('/not existing path/log.maste', 'r');
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL slow_query_log_file= NULL;
+
+# Reset to initial values in case a setting above was successful.
+SET GLOBAL general_log_file= @old_general_log_file;
+SET GLOBAL slow_query_log_file= @old_slow_query_log_file;
+if(!$fixed_bug38124)
+{
+   --disable_query_log
+   let $my_var = `SELECT @old_general_log_file`;
+   eval SET @@global.general_log_file = '$my_var';
+   let $my_var = `SELECT @old_slow_query_log_file`;
+   eval SET @@global.slow_query_log_file = '$my_var';
+   --enable_query_log
+}
 
-set global general_log_file= @old_general_log_file;
-set global slow_query_log_file= @old_slow_query_log_file;
 
 ###########################################################################
 
 --echo
 --echo # --
 --echo # -- Bug#32748: Inconsistent handling of assignments to
---echo # -- general_log_file/slow_query_log_file.
+--echo # --            general_log_file/slow_query_log_file.
 --echo # --
 
 --echo
-SET @general_log_file_saved = @@global.general_log_file;
-SET @slow_query_log_file_saved = @@global.slow_query_log_file;
-
---echo
 SET GLOBAL general_log_file = 'bug32748.query.log';
 SET GLOBAL slow_query_log_file = 'bug32748.slow.log';
 
 --echo
 SHOW VARIABLES LIKE '%log_file';
 
+# Reset to initial values
 --echo
-SET GLOBAL general_log_file = @general_log_file_saved;
-SET GLOBAL slow_query_log_file = @slow_query_log_file_saved;
+SET GLOBAL general_log_file = @old_general_log_file;
+SET GLOBAL slow_query_log_file = @old_slow_query_log_file;
+if(!$fixed_bug38124)
+{
+   --disable_query_log
+   let $my_var = `SELECT @old_general_log_file`;
+   eval SET @@global.general_log_file = '$my_var';
+   let $my_var = `SELECT @old_slow_query_log_file`;
+   eval SET @@global.slow_query_log_file = '$my_var';
+   --enable_query_log
+}
 
 --echo
 --echo # -- End of Bug#32748.
 
-###########################################################################
-
 
+###########################################################################
 
-## WL#4403 - deprecate @log and @slow_log_queries variables
+# WL#4403 - deprecate @log and @slow_log_queries variables
 
-## these are all deprecated -- show for command-line as well!
+# These server system variables are all deprecated
+# -- show for command-line as well!
 --echo deprecated:
 SET GLOBAL log = 0;
 SET GLOBAL log_slow_queries = 0;
 SET GLOBAL log = DEFAULT;
 SET GLOBAL log_slow_queries = DEFAULT;
 
-## these are NOT deprecated
+# These server system variables are NOT deprecated.
 --echo not deprecated:
 SELECT @@global.general_log_file INTO @my_glf;
 SELECT @@global.slow_query_log_file INTO @my_sqlf;
@@ -283,6 +346,20 @@ SET GLOBAL slow_query_log_file = @my_sql
 SET GLOBAL general_log = DEFAULT;
 SET GLOBAL slow_query_log = DEFAULT;
 
+## Reset to initial values
+SET @@global.general_log = @old_general_log;
+SET @@global.general_log_file = @old_general_log_file;
+SET @@global.slow_query_log = @old_slow_query_log;
+SET @@global.slow_query_log_file = @old_slow_query_log_file;
+if(!$fixed_bug38124)
+{
+   --disable_query_log
+   let $my_var = `SELECT @old_general_log_file`;
+   eval SET @@global.general_log_file = '$my_var';
+   let $my_var = `SELECT @old_slow_query_log_file`;
+   eval SET @@global.slow_query_log_file = '$my_var';
+   --enable_query_log
+}
 
 
 --echo End of 5.1 tests
@@ -290,10 +367,27 @@ SET GLOBAL slow_query_log = DEFAULT;
 --enable_ps_protocol
 
 #
-# Cleanup (must be done last to avoid delayed 'Quit' message in general log)
+# Cleanup
 #
+# Disconnect must be done last to avoid delayed 'Quit' message in general log
+--echo # Close connection con1
 disconnect con1;
+# Reset global system variables to initial values if forgotten somewhere above.
+SET global general_log = @old_general_log;
+SET global general_log_file = @old_general_log_file;
+SET global slow_query_log = @old_slow_query_log;
+SET global slow_query_log_file = @old_slow_query_log_file;
+if(!$fixed_bug38124)
+{
+   --disable_query_log
+   let $my_var = `SELECT @old_general_log_file`;
+   eval SET @@global.general_log_file = '$my_var';
+   let $my_var = `SELECT @old_slow_query_log_file`;
+   eval SET @@global.slow_query_log_file = '$my_var';
+   --enable_query_log
+}
 
 # Remove the log files that was created in the "default location"
 # i.e var/run
 --remove_file $MYSQLTEST_VARDIR/run/master.log
+--remove_file $MYSQLTEST_VARDIR/tmp/log.master

=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test	2008-12-11 17:46:20 +0000
+++ b/mysql-test/t/mysql.test	2009-01-09 17:51:52 +0000
@@ -310,6 +310,11 @@ EOF
 --exec $MYSQL -c < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1
 remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql;
 
+#
+# Bug #41437: Value stored in 'case' lacks charset, causees segfault
+#
+--exec $MYSQL -e "select @z:='1',@z=database()"
+
 --echo End of 5.0 tests
 
 #

=== modified file 'mysql-test/t/partition_pruning.test'
--- a/mysql-test/t/partition_pruning.test	2007-09-14 10:18:42 +0000
+++ b/mysql-test/t/partition_pruning.test	2008-12-28 11:33:49 +0000
@@ -8,6 +8,22 @@
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 --enable_warnings
 
+#
+# Bug#40972: some sql execution lead the whole database crashing
+#
+# Setup so the start is at partition pX and end is at p1
+# Pruning does handle 'bad' dates differently.
+CREATE TABLE t1
+(a INT NOT NULL AUTO_INCREMENT,
+ b DATETIME,
+ PRIMARY KEY (a,b),
+ KEY (b))
+PARTITION BY RANGE (to_days(b))
+(PARTITION p0 VALUES LESS THAN (733681) COMMENT = 'LESS THAN 2008-10-01',
+ PARTITION p1 VALUES LESS THAN (733712) COMMENT = 'LESS THAN 2008-11-01',
+ PARTITION pX VALUES LESS THAN MAXVALUE);
+SELECT a,b FROM t1 WHERE b >= '2008-12-01' AND b < '2009-12-00';
+DROP TABLE t1;
 
 # Check if we can infer from condition on partition fields that 
 # no records will match.

=== modified file 'mysql-test/t/temp_table.test'
--- a/mysql-test/t/temp_table.test	2008-03-28 15:16:52 +0000
+++ b/mysql-test/t/temp_table.test	2009-01-07 12:11:37 +0000
@@ -204,4 +204,35 @@ DELETE FROM t1;
 SELECT * FROM t1;
 DROP TABLE t1;
 
+#
+# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE TEMPORARY TABLE t1 (a INT);
+CREATE TEMPORARY TABLE t2 LIKE t1;
+
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS INT
+ BEGIN
+     return 1;
+ END|
+DELIMITER ;|
+
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t1 SELECT f1();
+
+CREATE TABLE t3 SELECT * FROM t1;
+INSERT INTO t1 SELECT f1();
+
+UPDATE t1,t2 SET t1.a = t2.a;
+INSERT INTO t2 SELECT f1();
+
+DROP TABLE t1,t2,t3;
+DROP FUNCTION f1;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/type_date.test'
--- a/mysql-test/t/type_date.test	2008-01-10 10:37:54 +0000
+++ b/mysql-test/t/type_date.test	2009-01-13 14:04:28 +0000
@@ -62,7 +62,7 @@ drop table t1;
 # Test of date and not null
 #
 
-create table t1 (date date);  
+create table t1 (date date);
 insert into t1 values ("2000-08-10"),("2000-08-11");
 select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1;
 drop table t1;
@@ -75,9 +75,12 @@ CREATE TABLE t1(AFIELD INT);
 INSERT INTO t1 VALUES(1);
 CREATE TABLE t2(GMT  VARCHAR(32));
 INSERT INTO t2 VALUES('GMT-0800');
-SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT)) FROM t1, t2 GROUP BY t1.AFIELD;
+SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT))
+FROM t1, t2 GROUP BY t1.AFIELD;
 INSERT INTO t1 VALUES(1);
-SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT)), DATE_FORMAT("2002-03-06 10:11:12",  CONCAT('%a, %d %M %Y %H:%i:%s ' ,  t2.GMT)) FROM t1,t2 GROUP BY t1.AFIELD;
+SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT)),
+       DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ', t2.GMT))
+FROM t1,t2 GROUP BY t1.AFIELD;
 drop table t1,t2;
 
 #
@@ -90,7 +93,7 @@ SELECT DATE_FORMAT(f1, "%l.%i %p") , DAT
 DROP TABLE t1;
 
 #
-# Bug 4937: different date -> string conversion when using SELECT ... UNION
+# Bug#4937: different date -> string conversion when using SELECT ... UNION
 # and INSERT ... SELECT ... UNION
 #
 
@@ -141,7 +144,7 @@ select * from t1;
 drop table t1;
 
 #
-# Bug #30942: select str_to_date from derived table returns varying results
+# Bug#30942: select str_to_date from derived table returns varying results
 #
 CREATE TABLE t1 (
   a INT
@@ -155,10 +158,22 @@ DROP TABLE t1;
 
 
 #
-# Bug #31221: Optimizer incorrectly identifies impossible WHERE clause
+# Bug#31221: Optimizer incorrectly identifies impossible WHERE clause
 #
 
-CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b));
+CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b));
+## The current sub test could fail (difference to expected result) if we
+## have just reached midnight.
+## (Bug#41776 type_date.test may fail if run around midnight)
+## Therefore we sleep a bit if we are too close to midnight.
+## The complete test itself needs in average less than 1 second.
+## Therefore a time_distance to midnight of 5 seconds should be sufficient.
+if (`SELECT CURTIME() > SEC_TO_TIME(24 * 3600 - 5)`)
+{
+   # We are here when CURTIME() is between '23:59:56' and '23:59:59'.
+   # So a sleep time of 5 seconds brings us between '00:00:01' and '00:00:04'.
+   --real_sleep 5
+}
 INSERT INTO t1 VALUES (DATE(NOW()), 1);
 SELECT COUNT(*) FROM t1 WHERE a = NOW();
 EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
@@ -174,7 +189,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 WHERE a 
 DROP TABLE t1;
 
 #
-# Bug #28687: Search fails on '0000-00-00' date after sql_mode change
+# Bug#28687: Search fails on '0000-00-00' date after sql_mode change
 #
 
 CREATE TABLE t1 (a DATE);

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2008-11-19 09:57:23 +0000
+++ b/mysys/my_getopt.c	2009-01-12 05:32:49 +0000
@@ -976,24 +976,26 @@ static void init_one_value(const struct 
     *((my_bool*) variable)= (my_bool) value;
     break;
   case GET_INT:
-    *((int*) variable)= (int) value;
+    *((int*) variable)= (int) getopt_ll_limit_value((int) value, option, NULL);
     break;
-  case GET_UINT:
   case GET_ENUM:
     *((uint*) variable)= (uint) value;
     break;
+  case GET_UINT:
+    *((uint*) variable)= (uint) getopt_ull_limit_value((uint) value, option, NULL);
+    break;
   case GET_LONG:
-    *((long*) variable)= (long) value;
+    *((long*) variable)= (long) getopt_ll_limit_value((long) value, option, NULL);
     break;
   case GET_ULONG:
-    *((ulong*) variable)= (ulong) value;
+    *((ulong*) variable)= (ulong) getopt_ull_limit_value((ulong) value, option, NULL);
     break;
   case GET_LL:
-    *((longlong*) variable)= (longlong) value;
+    *((longlong*) variable)= (longlong) getopt_ll_limit_value((longlong) value, option, NULL);
     break;
   case GET_ULL:
   case GET_SET:
-    *((ulonglong*) variable)=  (ulonglong) value;
+    *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value((ulonglong) value, option, NULL);
     break;
   case GET_DOUBLE:
     *((double*) variable)=  (double) value;

=== modified file 'sql-common/my_time.c'
--- a/sql-common/my_time.c	2008-04-03 17:14:57 +0000
+++ b/sql-common/my_time.c	2009-01-09 13:22:15 +0000
@@ -762,19 +762,20 @@ long calc_daynr(uint year,uint month,uin
 {
   long delsum;
   int temp;
+  int y= year;                                  /* may be < 0 temporarily */
   DBUG_ENTER("calc_daynr");
 
-  if (year == 0 && month == 0 && day == 0)
+  if (y == 0 && month == 0 && day == 0)
     DBUG_RETURN(0);				/* Skip errors */
-  delsum= (long) (365L * year+ 31*(month-1) +day);
+  delsum= (long) (365L * y+ 31*(month-1) +day);
   if (month <= 2)
-      year--;
+      y--;
   else
     delsum-= (long) (month*4+23)/10;
-  temp=(int) ((year/100+1)*3)/4;
+  temp=(int) ((y/100+1)*3)/4;
   DBUG_PRINT("exit",("year: %d  month: %d  day: %d -> daynr: %ld",
-		     year+(month <= 2),month,day,delsum+year/4-temp));
-  DBUG_RETURN(delsum+(int) year/4-temp);
+		     y+(month <= 2),month,day,delsum+y/4-temp));
+  DBUG_RETURN(delsum+(int) y/4-temp);
 } /* calc_daynr */
 
 

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2008-07-17 18:26:55 +0000
+++ b/sql/filesort.cc	2009-01-09 12:04:47 +0000
@@ -562,10 +562,7 @@ static ha_rows find_all_keys(SORTPARAM *
     if (quick_select)
     {
       if ((error= select->quick->get_next()))
-      {
-        error= HA_ERR_END_OF_FILE;
         break;
-      }
       file->position(sort_form->record[0]);
       DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE););
     }

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2009-01-05 16:10:20 +0000
+++ b/sql/ha_partition.cc	2009-01-07 22:30:10 +0000
@@ -4815,7 +4815,7 @@ int ha_partition::info(uint flag)
     /*
       Calculates statistical variables
       records:           Estimate of number records in table
-      We report sum (always at least 2)
+      We report sum (always at least 2 if not empty)
       deleted:           Estimate of number holes in the table due to
       deletes
       We report sum
@@ -4854,13 +4854,13 @@ int ha_partition::info(uint flag)
           stats.check_time= file->stats.check_time;
       }
     } while (*(++file_array));
-    if (stats.records < 2 &&
+    if (stats.records && stats.records < 2 &&
         !(m_file[0]->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT))
       stats.records= 2;
     if (stats.records > 0)
       stats.mean_rec_length= (ulong) (stats.data_file_length / stats.records);
     else
-      stats.mean_rec_length= 1; //? What should we set here 
+      stats.mean_rec_length= 0;
   }
   if (flag & HA_STATUS_CONST)
   {

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2008-12-09 11:16:39 +0000
+++ b/sql/item_strfunc.cc	2009-01-09 17:51:52 +0000
@@ -1782,6 +1782,12 @@ Item *Item_func_sysconst::safe_charset_c
   Item_string *conv;
   uint conv_errors;
   String tmp, cstr, *ostr= val_str(&tmp);
+  if (null_value)
+  {
+    Item *null_item= new Item_null((char *) fully_qualified_func_name());
+    null_item->collation.set (tocs);
+    return null_item;
+  }
   cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
   if (conv_errors ||
       !(conv= new Item_static_string_func(fully_qualified_func_name(),

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2009-01-14 08:27:32 +0000
+++ b/sql/log_event.cc	2009-01-14 09:32:25 +0000
@@ -3425,7 +3425,8 @@ Format_description_log_event(uint8 binlo
     number_of_event_types= LOG_EVENT_TYPES;
     /* we'll catch my_malloc() error in is_valid() */
     post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8),
-                                       MYF(MY_ZEROFILL));
+                                       MYF(0));
+
     /*
       This long list of assignments is not beautiful, but I see no way to
       make it nicer, as the right members are #defines, not array members, so
@@ -3433,16 +3434,40 @@ Format_description_log_event(uint8 binlo
     */
     if (post_header_len)
     {
+      // Allows us to sanity-check that all events initialized their
+      // events (see the end of this 'if' block).
+      IF_DBUG(memset(post_header_len, 255,
+                     number_of_event_types*sizeof(uint8)););
+
+      /* Note: all event types must explicitly fill in their lengths here. */
       post_header_len[START_EVENT_V3-1]= START_V3_HEADER_LEN;
       post_header_len[QUERY_EVENT-1]= QUERY_HEADER_LEN;
+      post_header_len[STOP_EVENT-1]= STOP_HEADER_LEN;
       post_header_len[ROTATE_EVENT-1]= ROTATE_HEADER_LEN;
+      post_header_len[INTVAR_EVENT-1]= INTVAR_HEADER_LEN;
       post_header_len[LOAD_EVENT-1]= LOAD_HEADER_LEN;
+      post_header_len[SLAVE_EVENT-1]= SLAVE_HEADER_LEN;
       post_header_len[CREATE_FILE_EVENT-1]= CREATE_FILE_HEADER_LEN;
       post_header_len[APPEND_BLOCK_EVENT-1]= APPEND_BLOCK_HEADER_LEN;
       post_header_len[EXEC_LOAD_EVENT-1]= EXEC_LOAD_HEADER_LEN;
       post_header_len[DELETE_FILE_EVENT-1]= DELETE_FILE_HEADER_LEN;
-      post_header_len[NEW_LOAD_EVENT-1]= post_header_len[LOAD_EVENT-1];
+      post_header_len[NEW_LOAD_EVENT-1]= NEW_LOAD_HEADER_LEN;
+      post_header_len[RAND_EVENT-1]= RAND_HEADER_LEN;
+      post_header_len[USER_VAR_EVENT-1]= USER_VAR_HEADER_LEN;
       post_header_len[FORMAT_DESCRIPTION_EVENT-1]= FORMAT_DESCRIPTION_HEADER_LEN;
+      post_header_len[XID_EVENT-1]= XID_HEADER_LEN;
+      post_header_len[BEGIN_LOAD_QUERY_EVENT-1]= BEGIN_LOAD_QUERY_HEADER_LEN;
+      post_header_len[EXECUTE_LOAD_QUERY_EVENT-1]= EXECUTE_LOAD_QUERY_HEADER_LEN;
+      /*
+        The PRE_GA events are never be written to any binlog, but
+        their lengths are included in Format_description_log_event.
+        Hence, we need to be assign some value here, to avoid reading
+        uninitialized memory when the array is written to disk.
+      */
+      post_header_len[PRE_GA_WRITE_ROWS_EVENT-1] = 0;
+      post_header_len[PRE_GA_UPDATE_ROWS_EVENT-1] = 0;
+      post_header_len[PRE_GA_DELETE_ROWS_EVENT-1] = 0;
+
       post_header_len[TABLE_MAP_EVENT-1]=    TABLE_MAP_HEADER_LEN;
       post_header_len[WRITE_ROWS_EVENT-1]=   ROWS_HEADER_LEN;
       post_header_len[UPDATE_ROWS_EVENT-1]=  ROWS_HEADER_LEN;
@@ -3462,9 +3487,14 @@ Format_description_log_event(uint8 binlo
                       post_header_len[WRITE_ROWS_EVENT-1]=
                       post_header_len[UPDATE_ROWS_EVENT-1]=
                       post_header_len[DELETE_ROWS_EVENT-1]= 6;);
-      post_header_len[BEGIN_LOAD_QUERY_EVENT-1]= post_header_len[APPEND_BLOCK_EVENT-1];
-      post_header_len[EXECUTE_LOAD_QUERY_EVENT-1]= EXECUTE_LOAD_QUERY_HEADER_LEN;
       post_header_len[INCIDENT_EVENT-1]= INCIDENT_HEADER_LEN;
+
+      // Sanity-check that all post header lengths are initialized.
+      IF_DBUG({
+          int i;
+          for (i=0; i<number_of_event_types; i++)
+            assert(post_header_len[i] != 255);
+        });
     }
     break;
 
@@ -4813,7 +4843,9 @@ Intvar_log_event::Intvar_log_event(const
                                    const Format_description_log_event* description_event)
   :Log_event(buf, description_event)
 {
-  buf+= description_event->common_header_len;
+  /* The Post-Header is empty. The Varible Data part begins immediately. */
+  buf+= description_event->common_header_len +
+    description_event->post_header_len[INTVAR_EVENT-1];
   type= buf[I_TYPE_OFFSET];
   val= uint8korr(buf+I_VAL_OFFSET);
 }
@@ -4957,7 +4989,9 @@ Rand_log_event::Rand_log_event(const cha
                                const Format_description_log_event* description_event)
   :Log_event(buf, description_event)
 {
-  buf+= description_event->common_header_len;
+  /* The Post-Header is empty. The Variable Data part begins immediately. */
+  buf+= description_event->common_header_len +
+    description_event->post_header_len[RAND_EVENT-1];
   seed1= uint8korr(buf+RAND_SEED1_OFFSET);
   seed2= uint8korr(buf+RAND_SEED2_OFFSET);
 }
@@ -5061,7 +5095,9 @@ Xid_log_event(const char* buf,
               const Format_description_log_event *description_event)
   :Log_event(buf, description_event)
 {
-  buf+= description_event->common_header_len;
+  /* The Post-Header is empty. The Variable Data part begins immediately. */
+  buf+= description_event->common_header_len +
+    description_event->post_header_len[XID_EVENT-1];
   memcpy((char*) &xid, buf, sizeof(xid));
 }
 
@@ -5207,7 +5243,9 @@ User_var_log_event(const char* buf,
                    const Format_description_log_event* description_event)
   :Log_event(buf, description_event)
 {
-  buf+= description_event->common_header_len;
+  /* The Post-Header is empty. The Variable Data part begins immediately. */
+  buf+= description_event->common_header_len +
+    description_event->post_header_len[USER_VAR_EVENT-1];
   name_len= uint4korr(buf);
   name= (char *) buf + UV_NAME_LEN_SIZE;
   buf+= UV_NAME_LEN_SIZE + name_len;

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2008-12-29 16:04:10 +0000
+++ b/sql/log_event.h	2009-01-09 12:49:24 +0000
@@ -227,14 +227,22 @@ struct sql_ex_info
 #define QUERY_HEADER_MINIMAL_LEN     (4 + 4 + 1 + 2)
 // where 5.0 differs: 2 for len of N-bytes vars.
 #define QUERY_HEADER_LEN     (QUERY_HEADER_MINIMAL_LEN + 2)
+#define STOP_HEADER_LEN      0
 #define LOAD_HEADER_LEN      (4 + 4 + 4 + 1 +1 + 4)
+#define SLAVE_HEADER_LEN     0
 #define START_V3_HEADER_LEN     (2 + ST_SERVER_VER_LEN + 4)
 #define ROTATE_HEADER_LEN    8 // this is FROZEN (the Rotate post-header is frozen)
+#define INTVAR_HEADER_LEN      0
 #define CREATE_FILE_HEADER_LEN 4
 #define APPEND_BLOCK_HEADER_LEN 4
 #define EXEC_LOAD_HEADER_LEN   4
 #define DELETE_FILE_HEADER_LEN 4
+#define NEW_LOAD_HEADER_LEN    LOAD_HEADER_LEN
+#define RAND_HEADER_LEN        0
+#define USER_VAR_HEADER_LEN    0
 #define FORMAT_DESCRIPTION_HEADER_LEN (START_V3_HEADER_LEN+1+LOG_EVENT_TYPES)
+#define XID_HEADER_LEN         0
+#define BEGIN_LOAD_QUERY_HEADER_LEN APPEND_BLOCK_HEADER_LEN
 #define ROWS_HEADER_LEN        8
 #define TABLE_MAP_HEADER_LEN   8
 #define EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN (4 + 4 + 4 + 1)
@@ -319,18 +327,16 @@ struct sql_ex_info
 #define Q_CHARSET_DATABASE_CODE 8
 
 #define Q_TABLE_MAP_FOR_UPDATE_CODE 9
-/* Intvar event post-header */
 
+/* Intvar event data */
 #define I_TYPE_OFFSET        0
 #define I_VAL_OFFSET         1
 
-/* Rand event post-header */
-
+/* Rand event data */
 #define RAND_SEED1_OFFSET 0
 #define RAND_SEED2_OFFSET 8
 
-/* User_var event post-header */
-
+/* User_var event data */
 #define UV_VAL_LEN_SIZE        4
 #define UV_VAL_IS_NULL         1
 #define UV_VAL_TYPE_SIZE       1
@@ -338,7 +344,6 @@ struct sql_ex_info
 #define UV_CHARSET_NUMBER_SIZE 4
 
 /* Load event post-header */
-
 #define L_THREAD_ID_OFFSET   0
 #define L_EXEC_TIME_OFFSET   4
 #define L_SKIP_LINES_OFFSET  8
@@ -349,7 +354,6 @@ struct sql_ex_info
 #define L_DATA_OFFSET        LOAD_HEADER_LEN
 
 /* Rotate event post-header */
-
 #define R_POS_OFFSET       0
 #define R_IDENT_OFFSET     8
 
@@ -2206,10 +2210,11 @@ protected:
 
   @section Intvar_log_event_binary_format Binary Format
 
-  The Post-Header has two components:
+  The Post-Header for this event type is empty.  The Body has two
+  components:
 
   <table>
-  <caption>Post-Header for Intvar_log_event</caption>
+  <caption>Body for Intvar_log_event</caption>
 
   <tr>
     <th>Name</th>
@@ -2283,11 +2288,12 @@ private:
   which are stored internally as two 64-bit numbers.
 
   @section Rand_log_event_binary_format Binary Format  
-  This event type has no Post-Header. The Body of this event type has
-  two components:
+
+  The Post-Header for this event type is empty.  The Body has two
+  components:
 
   <table>
-  <caption>Post-Header for Intvar_log_event</caption>
+  <caption>Body for Rand_log_event</caption>
 
   <tr>
     <th>Name</th>

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-01-07 12:44:32 +0000
+++ b/sql/mysqld.cc	2009-01-12 05:32:49 +0000
@@ -6611,7 +6611,7 @@ The minimum value for this variable is 4
   {"max_user_connections", OPT_MAX_USER_CONNECTIONS,
    "The maximum number of active connections for a single user (0 = no limit).",
    (uchar**) &max_user_connections, (uchar**) &max_user_connections, 0, GET_UINT,
-   REQUIRED_ARG, 0, 1, UINT_MAX, 0, 1, 0},
+   REQUIRED_ARG, 0, 0, UINT_MAX, 0, 1, 0},
   {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
    "After this many write locks, allow some read locks to run in between.",
    (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG,

=== modified file 'sql/repl_failsafe.cc'
--- a/sql/repl_failsafe.cc	2008-03-20 11:22:02 +0000
+++ b/sql/repl_failsafe.cc	2009-01-09 12:49:24 +0000
@@ -644,6 +644,16 @@ err:
 }
 #endif
 
+
+/**
+  Execute a SHOW SLAVE HOSTS statement.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @retval FALSE success
+  @retval TRUE failure
+*/
 bool show_slave_hosts(THD* thd)
 {
   List<Item> field_list;

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2008-11-28 11:38:49 +0000
+++ b/sql/slave.cc	2009-01-09 12:49:24 +0000
@@ -1357,6 +1357,17 @@ int register_slave_on_master(MYSQL* mysq
 }
 
 
+/**
+  Execute a SHOW SLAVE STATUS statement.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @param mi Pointer to Master_info object for the IO thread.
+
+  @retval FALSE success
+  @retval TRUE failure
+*/
 bool show_master_info(THD* thd, Master_info* mi)
 {
   // TODO: fix this for multi-master
@@ -2062,7 +2073,7 @@ int apply_event_and_update_pos(Log_event
      fewer times, 0 is returned.
 
    - init_master_info or init_relay_log_pos failed. (These are called
-     if a failure occurs when applying the event.)</li>
+     if a failure occurs when applying the event.)
 
    - An error occurred when updating the binlog position.
 
@@ -2307,8 +2318,14 @@ static int try_to_reconnect(THD *thd, MY
 }
 
 
-/* Slave I/O Thread entry point */
+/**
+  Slave IO thread entry point.
+
+  @param arg Pointer to Master_info struct that holds information for
+  the IO thread.
 
+  @return Always 0.
+*/
 pthread_handler_t handle_slave_io(void *arg)
 {
   THD *thd; // needs to be first for thread_stack
@@ -2616,8 +2633,14 @@ err:
 }
 
 
-/* Slave SQL Thread entry point */
+/**
+  Slave SQL thread entry point.
+
+  @param arg Pointer to Relay_log_info object that holds information
+  for the SQL thread.
 
+  @return Always 0.
+*/
 pthread_handler_t handle_slave_sql(void *arg)
 {
   THD *thd;                     /* needs to be first for thread_stack */
@@ -3710,6 +3733,16 @@ static IO_CACHE *reopen_relay_log(Relay_
 }
 
 
+/**
+  Reads next event from the relay log.  Should be called from the
+  slave IO thread.
+
+  @param rli Relay_log_info structure for the slave IO thread.
+
+  @return The event read, or NULL on error.  If an error occurs, the
+  error is reported through the sql_print_information() or
+  sql_print_error() functions.
+*/
 static Log_event* next_event(Relay_log_info* rli)
 {
   Log_event* ev;

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2008-12-10 20:14:50 +0000
+++ b/sql/sql_base.cc	2009-01-07 12:11:37 +0000
@@ -1111,6 +1111,27 @@ static void mark_temp_tables_as_free_for
       */
       if (table->child_l || table->parent)
         detach_merge_children(table, TRUE);
+      /*
+        Reset temporary table lock type to it's default value (TL_WRITE).
+
+        Statements such as INSERT INTO .. SELECT FROM tmp, CREATE TABLE
+        .. SELECT FROM tmp and UPDATE may under some circumstances modify
+        the lock type of the tables participating in the statement. This
+        isn't a problem for non-temporary tables since their lock type is
+        reset at every open, but the same does not occur for temporary
+        tables for historical reasons.
+
+        Furthermore, the lock type of temporary tables is not really that
+        important because they can only be used by one query at a time and
+        not even twice in a query -- a temporary table is represented by
+        only one TABLE object. Nonetheless, it's safer from a maintenance
+        point of view to reset the lock type of this singleton TABLE object
+        as to not cause problems when the table is reused.
+
+        Even under LOCK TABLES mode its okay to reset the lock type as
+        LOCK TABLES is allowed (but ignored) for a temporary table.
+      */
+      table->reginfo.lock_type= TL_WRITE;
     }
   }
 }
@@ -4681,7 +4702,7 @@ int open_tables(THD *thd, TABLE_LIST **s
       else if (tables->lock_type == TL_READ_DEFAULT)
         tables->table->reginfo.lock_type=
           read_lock_type_for_table(thd, tables->table);
-      else if (tables->table->s->tmp_table == NO_TMP_TABLE)
+      else
         tables->table->reginfo.lock_type= tables->lock_type;
     }
     tables->table->grant= tables->grant;

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2008-08-14 02:42:10 +0000
+++ b/sql/sql_binlog.cc	2009-01-09 12:49:24 +0000
@@ -18,7 +18,7 @@
 #include "base64.h"
 
 /**
-  Execute a BINLOG statement
+  Execute a BINLOG statement.
 
   To execute the BINLOG command properly the server needs to know
   which format the BINLOG command's event is in.  Therefore, the first
@@ -26,6 +26,9 @@
   Format_description_log_event, as outputted by mysqlbinlog.  This
   Format_description_log_event is cached in
   rli->description_event_for_exec.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
 */
 
 void mysql_client_binlog_statement(THD* thd)

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2008-11-03 13:08:42 +0000
+++ b/sql/sql_delete.cc	2009-01-09 10:20:32 +0000
@@ -951,6 +951,26 @@ bool multi_delete::send_eof()
 ****************************************************************************/
 
 /*
+  Row-by-row truncation if the engine does not support table recreation.
+  Probably a InnoDB table.
+*/
+
+static bool mysql_truncate_by_delete(THD *thd, TABLE_LIST *table_list)
+{
+  bool error, save_binlog_row_based= thd->current_stmt_binlog_row_based;
+  DBUG_ENTER("mysql_truncate_by_delete");
+  table_list->lock_type= TL_WRITE;
+  mysql_init_select(thd->lex);
+  thd->clear_current_stmt_binlog_row_based();
+  error= mysql_delete(thd, table_list, NULL, NULL, HA_POS_ERROR, LL(0), TRUE);
+  ha_autocommit_or_rollback(thd, error);
+  end_trans(thd, error ? ROLLBACK : COMMIT);
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
+  DBUG_RETURN(error);
+}
+
+
+/*
   Optimize delete of all rows by doing a full generate of the table
   This will work even if the .ISM and .ISD tables are destroyed
 
@@ -1055,24 +1075,6 @@ end:
   DBUG_RETURN(error);
 
 trunc_by_del:
-  /* Probably InnoDB table */
-  ulonglong save_options= thd->options;
-  table_list->lock_type= TL_WRITE;
-  thd->options&= ~(OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
-  ha_enable_transaction(thd, FALSE);
-  mysql_init_select(thd->lex);
-  bool save_binlog_row_based= thd->current_stmt_binlog_row_based;
-  thd->clear_current_stmt_binlog_row_based();
-  error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
-                      HA_POS_ERROR, LL(0), TRUE);
-  ha_enable_transaction(thd, TRUE);
-  /*
-    Safety, in case the engine ignored ha_enable_transaction(FALSE)
-    above. Also clears thd->transaction.*.
-  */
-  error= ha_autocommit_or_rollback(thd, error);
-  ha_commit(thd);
-  thd->options= save_options;
-  thd->current_stmt_binlog_row_based= save_binlog_row_based;
+  error= mysql_truncate_by_delete(thd, table_list);
   DBUG_RETURN(error);
 }

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2008-11-26 23:02:10 +0000
+++ b/sql/sql_lex.h	2009-01-09 12:49:24 +0000
@@ -190,6 +190,15 @@ typedef struct st_lex_server_options
   char *server_name, *host, *db, *username, *password, *scheme, *socket, *owner;
 } LEX_SERVER_OPTIONS;
 
+
+/**
+  Structure to hold parameters for CHANGE MASTER or START/STOP SLAVE
+  or SHOW NEW MASTER.
+
+  Remark: this should not be confused with Master_info (and perhaps
+  would better be renamed to st_lex_replication_info).  Some fields,
+  e.g., delay, are saved in Relay_log_info, not in Master_info.
+*/
 typedef struct st_lex_master_info
 {
   char *host, *user, *password, *log_file_name;

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2009-01-05 16:10:20 +0000
+++ b/sql/sql_partition.cc	2009-01-09 13:18:08 +0000
@@ -6678,6 +6678,7 @@ int get_part_iter_for_interval_via_mappi
   uint32             max_endpoint_val;
   get_endpoint_func  get_endpoint;
   uint field_len= field->pack_length_in_rec();
+  part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE;
 
   if (part_info->part_type == RANGE_PARTITION)
   {
@@ -6698,7 +6699,6 @@ int get_part_iter_for_interval_via_mappi
     max_endpoint_val=    part_info->no_list_values;
     part_iter->get_next= get_next_partition_id_list;
     part_iter->part_info= part_info;
-    part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE;
     if (max_endpoint_val == 0)
     {
       /*
@@ -6760,7 +6760,7 @@ int get_part_iter_for_interval_via_mappi
     store_key_image_to_rec(field, max_value, field_len);
     bool include_endp= !test(flags & NEAR_MAX);
     part_iter->part_nums.end= get_endpoint(part_info, 0, include_endp);
-    if (part_iter->part_nums.start == part_iter->part_nums.end &&
+    if (part_iter->part_nums.start >= part_iter->part_nums.end &&
         !part_iter->ret_null_part)
       return 0; /* No partitions */
   }
@@ -6938,7 +6938,7 @@ int get_part_iter_for_interval_via_walki
 
 uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter)
 {
-  if (part_iter->part_nums.cur == part_iter->part_nums.end)
+  if (part_iter->part_nums.cur >= part_iter->part_nums.end)
   {
     part_iter->part_nums.cur= part_iter->part_nums.start;
     return NOT_A_PARTITION_ID;

=== modified file 'sql/sql_profile.cc'
--- a/sql/sql_profile.cc	2008-02-19 20:47:15 +0000
+++ b/sql/sql_profile.cc	2009-01-12 16:17:15 +0000
@@ -552,8 +552,8 @@ int PROFILING::fill_statistics_info(THD 
         The order of these fields is set by the  query_profile_statistics_info
         array.
       */
-      table->field[0]->store((ulonglong) query->profiling_query_id);
-      table->field[1]->store((ulonglong) seq); /* the step in the sequence */
+      table->field[0]->store((ulonglong) query->profiling_query_id, TRUE);
+      table->field[1]->store((ulonglong) seq, TRUE); /* the step in the sequence */
       /*
         This entry, n, has a point in time, T(n), and a status phrase, S(n).
         The status phrase S(n) describes the period of time that begins at

=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc	2008-11-21 23:22:21 +0000
+++ b/sql/sql_repl.cc	2009-01-09 12:49:24 +0000
@@ -257,6 +257,17 @@ bool purge_error_message(THD* thd, int r
 }
 
 
+/**
+  Execute a PURGE BINARY LOGS TO <log> command.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @param to_log Name of the last log to purge.
+
+  @retval FALSE success
+  @retval TRUE failure
+*/
 bool purge_master_logs(THD* thd, const char* to_log)
 {
   char search_file_name[FN_REFLEN];
@@ -273,6 +284,17 @@ bool purge_master_logs(THD* thd, const c
 }
 
 
+/**
+  Execute a PURGE BINARY LOGS BEFORE <date> command.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @param purge_time Date before which logs should be purged.
+
+  @retval FALSE success
+  @retval TRUE failure
+*/
 bool purge_master_logs_before_date(THD* thd, time_t purge_time)
 {
   if (!mysql_bin_log.is_open())
@@ -765,6 +787,20 @@ err:
   DBUG_VOID_RETURN;
 }
 
+
+/**
+  Execute a START SLAVE statement.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @param mi Pointer to Master_info object for the slave's IO thread.
+
+  @param net_report If true, saves the exit status into thd->main_da.
+
+  @retval 0 success
+  @retval 1 error
+*/
 int start_slave(THD* thd , Master_info* mi,  bool net_report)
 {
   int slave_errno= 0;
@@ -890,6 +926,19 @@ int start_slave(THD* thd , Master_info* 
 }
 
 
+/**
+  Execute a STOP SLAVE statement.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @param mi Pointer to Master_info object for the slave's IO thread.
+
+  @param net_report If true, saves the exit status into thd->main_da.
+
+  @retval 0 success
+  @retval 1 error
+*/
 int stop_slave(THD* thd, Master_info* mi, bool net_report )
 {
   DBUG_ENTER("stop_slave");
@@ -942,20 +991,17 @@ int stop_slave(THD* thd, Master_info* mi
 }
 
 
-/*
-  Remove all relay logs and start replication from the start
+/**
+  Execute a RESET SLAVE statement.
 
-  SYNOPSIS
-    reset_slave()
-    thd			Thread handler
-    mi			Master info for the slave
-
-  RETURN
-    0	ok
-    1	error
-*/
+  @param thd Pointer to THD object of the client thread executing the
+  statement.
 
+  @param mi Pointer to Master_info object for the slave.
 
+  @retval 0 success
+  @retval 1 error
+*/
 int reset_slave(THD *thd, Master_info* mi)
 {
   MY_STAT stat_area;
@@ -1070,6 +1116,18 @@ void kill_zombie_dump_threads(uint32 sla
 }
 
 
+/**
+  Execute a CHANGE MASTER statement.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @param mi Pointer to Master_info object belonging to the slave's IO
+  thread.
+
+  @retval FALSE success
+  @retval TRUE error
+*/
 bool change_master(THD* thd, Master_info* mi)
 {
   int thread_mask;
@@ -1283,6 +1341,16 @@ bool change_master(THD* thd, Master_info
   DBUG_RETURN(FALSE);
 }
 
+
+/**
+  Execute a RESET MASTER statement.
+
+  @param thd Pointer to THD object of the client thread executing the
+  statement.
+
+  @retval 0 success
+  @retval 1 error
+*/
 int reset_master(THD* thd)
 {
   if (!mysql_bin_log.is_open())
@@ -1312,6 +1380,15 @@ int cmp_master_pos(const char* log_file_
 }
 
 
+/**
+  Execute a SHOW BINLOG EVENTS statement.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @retval FALSE success
+  @retval TRUE failure
+*/
 bool mysql_show_binlog_events(THD* thd)
 {
   Protocol *protocol= thd->protocol;
@@ -1462,6 +1539,15 @@ err:
 }
 
 
+/**
+  Execute a SHOW MASTER STATUS statement.
+
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
+
+  @retval FALSE success
+  @retval TRUE failure
+*/
 bool show_binlog_info(THD* thd)
 {
   Protocol *protocol= thd->protocol;
@@ -1495,18 +1581,15 @@ bool show_binlog_info(THD* thd)
 }
 
 
-/*
-  Send a list of all binary logs to client
+/**
+  Execute a SHOW BINARY LOGS statement.
 
-  SYNOPSIS
-    show_binlogs()
-    thd		Thread specific variable
+  @param thd Pointer to THD object for the client thread executing the
+  statement.
 
-  RETURN VALUES
-    FALSE OK
-    TRUE  error
+  @retval FALSE success
+  @retval TRUE failure
 */
-
 bool show_binlogs(THD* thd)
 {
   IO_CACHE *index_file;

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2008-12-14 20:59:50 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2009-01-12 05:32:49 +0000
@@ -8249,7 +8249,7 @@ static MYSQL_SYSVAR_BOOL(adaptive_hash_i
 static MYSQL_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
   "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
-  NULL, NULL, 1*1024*1024L, 512*1024L, ~0L, 1024);
+  NULL, NULL, 1*1024*1024L, 512*1024L, LONG_MAX, 1024);
 
 static MYSQL_SYSVAR_ULONG(autoextend_increment, srv_auto_extend_increment,
   PLUGIN_VAR_RQCMDARG,
@@ -8289,7 +8289,7 @@ static MYSQL_SYSVAR_LONG(lock_wait_timeo
 static MYSQL_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
   "The size of the buffer which InnoDB uses to write log to the log files on disk.",
-  NULL, NULL, 1024*1024L, 256*1024L, ~0L, 1024);
+  NULL, NULL, 1024*1024L, 256*1024L, LONG_MAX, 1024);
 
 static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
@@ -8309,7 +8309,7 @@ static MYSQL_SYSVAR_LONG(mirrored_log_gr
 static MYSQL_SYSVAR_LONG(open_files, innobase_open_files,
   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
   "How many files at the maximum InnoDB keeps open at the same time.",
-  NULL, NULL, 300L, 10L, ~0L, 0);
+  NULL, NULL, 300L, 10L, LONG_MAX, 0);
 
 static MYSQL_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
   PLUGIN_VAR_RQCMDARG,

Thread
bzr commit into mysql-5.1-bugteam branch (zhenxing.he:2748) Bug#31177Bug#36312 Bug#36875 Bug#37016 Bug#40377 Bug#40972 Bug#41111 Bug#41348Bug#41437 Bu...He Zhenxing14 Jan