MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:July 8 2009 1:30pm
Subject:bzr push into mysql-5.1 branch (joro:2968 to 3015)
View as plain text  
 3015 Georgi Kodinov	2009-07-08 [merge]
      automerge

    modified:
      .bzr-mysql/default.conf
 3014 Georgi Kodinov	2009-07-08
      Addendum to the fix for bug 45807 : initialize a member needed in
      Item_field::fix_fields()

    modified:
      sql/sql_partition.cc
 3013 Georgi Kodinov	2009-07-08
      Bug#38998, Bug#46029, Bug#45243, Bug#46030 making tests experimental

    modified:
      mysql-test/collections/default.experimental
 3012 Georgi Kodinov	2009-07-07 [merge]
      automerge

    modified:
      mysql-test/suite/funcs_1/t/storedproc.test
      mysql-test/suite/rpl/t/disabled.def
      mysql-test/suite/rpl/t/rpl_init_slave.test
      mysql-test/t/disabled.def
      mysql-test/t/init_connect.test
 3011 Georgi Kodinov	2009-07-07
      Bug #40796 : adding the tests to the experimental pb2 set.

    modified:
      mysql-test/collections/default.experimental
 3010 Georgi Kodinov	2009-07-07
      revert of hiding of the error exposed by this suite.

    modified:
      mysql-test/r/ctype_gbk_binlog.result
      mysql-test/t/ctype_gbk_binlog.test
 3009 Georgi Kodinov	2009-07-07
      merge of making bug 45578, 46010 and 45576 experimental in pb2.

    modified:
      mysql-test/collections/default.experimental
 3008 Georgi Kodinov	2009-07-07 [merge]
      atuomerge

    added:
      mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result
      mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test
    modified:
      storage/ibmdb2i/db2i_conversion.cc
      storage/ibmdb2i/db2i_myconv.h
      storage/ibmdb2i/db2i_rir.cc
      storage/ibmdb2i/ha_ibmdb2i.h
 3007 Georgi Kodinov	2009-07-07
      fixed compilation warnings on macosx

    modified:
      client/mysqldump.c
 3006 Georgi Kodinov	2009-07-07
      fixed a failing test ctype_gbk_binlog : Table 't2' already exists

    modified:
      mysql-test/r/ctype_gbk_binlog.result
      mysql-test/t/ctype_gbk_binlog.test
 3005 Georgi Kodinov	2009-07-06 [merge]
      null merged the disablement : problem is not present in 5.1

 3004 Georgi Kodinov	2009-07-06
      Bug #45974: disable test case in 5.1-bugteam

    modified:
      mysql-test/suite/rpl_ndb/t/disabled.def
 3003 Georgi Kodinov	2009-07-06 [merge]
      null-merged the test case disablement in bug 45972  to 5.1

 3002 Georgi Kodinov	2009-07-06 [merge]
      null-merged the disabled test cases.

 3001 Georgi Kodinov	2009-07-06 [merge]
      null-merge the mark of bug #38499 to big_test : it's running faster on 5.1

 3000 Georgi Kodinov	2009-07-06 [merge]
      automerge

    added:
      mysql-test/suite/rpl/r/rpl_concurrency_error.result
      mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt
      mysql-test/suite/rpl/t/rpl_concurrency_error.test
    modified:
      sql/log_event.cc
      sql/slave.cc
      sql/slave.h
 2999 Georgi Kodinov	2009-07-06 [merge]
      null-merged test cases disablement

 2998 Ramil Kalimullin	2009-07-06
      Fix for bug#42364 reverted.

    modified:
      mysql-test/r/warnings.result
      mysql-test/t/warnings.test
      sql/sql_table.cc
      tests/mysql_client_test.c
 2997 Kristofer Pettersson	2009-07-03 [merge]
      5.0-bugteam -> 5.1-bugteam

    modified:
      client/mysql.cc
 2996 Alexey Kopytov	2009-07-03 [merge]
      Automerge.

    modified:
      mysql-test/r/type_newdecimal.result
      mysql-test/t/type_newdecimal.test
      sql/item.cc
      sql/item_cmpfunc.cc
      sql/item_func.cc
      sql/item_func.h
      sql/item_sum.cc
      sql/my_decimal.h
      sql/sql_select.cc
 2995 Sergey Glukhov	2009-07-03 [merge]
      5.0-bugteam->5.1-bugteam merge
     @ mysql-test/r/view.result
        5.0-bugteam->5.1-bugteam merge
     @ mysql-test/t/view.test
        5.0-bugteam->5.1-bugteam merge
     @ sql/sql_insert.cc
        5.0-bugteam->5.1-bugteam merge

    modified:
      mysql-test/r/view.result
      mysql-test/t/view.test
      sql/sql_insert.cc
 2994 Sergey Glukhov	2009-07-03
      Bug#42364 SHOW ERRORS returns empty resultset after dropping non existent table
      enabled message storing into error message list
      for 'drop table' command
     @ mysql-test/r/warnings.result
        test result
     @ mysql-test/t/warnings.test
        test case
     @ sql/sql_table.cc
        We should skip error sending then we should return
        warnings to client as some functions may send its
        own errors, so we should set no_warnings_for_error= 0
        only in case of warning.
        The fix is to enable message storing into error message
        list for 'drop table' command(only for error case).
     @ tests/mysql_client_test.c
        test fix

    modified:
      mysql-test/r/warnings.result
      mysql-test/t/warnings.test
      sql/sql_table.cc
      tests/mysql_client_test.c
 2993 Bernt M. Johnsen	2009-07-03 [merge]
      automerge

    modified:
      mysql-test/r/partition.result
      mysql-test/suite/rpl/t/rpl_sp.test
      mysql-test/t/partition.test
      sql/item.cc
      sql/sql_partition.cc
 2992 Bernt M. Johnsen	2009-07-03 [merge]
      Prepare for push

    modified:
      mysql-test/r/sp-fib.result
      mysql-test/t/sp-fib.test
 2991 V Narayanan	2009-07-02
      Bug#45793 macce charset causes error with IBMDB2I
      
      Creating an IBMDB2I table with the macce character set
      is successful, but any attempt to insert data into the
      table was failing.
      
      This was happening because the character set name "macce"
      is not a valid iconv descriptor for IBM i PASE. This patch
      adds an override to convertTextDesc to use the equivalent
      valid iconv descriptor "IBM-1282" instead.
     @ mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result
        Bug#45793 macce charset causes error with IBMDB2I
        
        Result file for the test case.
     @ mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test
        Bug#45793 macce charset causes error with IBMDB2I
        
        Add a testcase for the macce charater set.
     @ storage/ibmdb2i/db2i_charsetSupport.cc
        Bug#45793 macce charset causes error with IBMDB2I
        
        The character set name "macce" is not a valid iconv
        descriptor for IBM i PASE. Add an override to convertTextDesc
        to use the equivalent valid iconv descriptor "IBM-1282" 
        instead.

    added:
      mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result
      mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test
    modified:
      storage/ibmdb2i/db2i_charsetSupport.cc
 2990 Staale Smedseng	2009-07-01 [merge]
      Merge from 5.0

    modified:
      sql/sql_parse.cc
 2989 Satya B	2009-07-01 [merge]
      merge to 5.1-bugteam

    added:
      mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result
      mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
    modified:
      client/mysqlbinlog.cc
      sql/log_event.h
      storage/innobase/Makefile.am
 2988 Satya B	2009-07-01
      Fix build failure after applying Innodb snapshot 5.1-ss5282
      
      After applying Innodb snapshot 5.1-ss5282, build was broken
      because of missing header file. 
      
      Adding the header file to Makefile.am after informing the 
      innodb developers.

    modified:
      storage/innobase/Makefile.am
 2987 Staale Smedseng	2009-06-29 [merge]
      Merge from 5.0

    modified:
      client/mysql.cc
      client/mysqlbinlog.cc
      cmd-line-utils/readline/bind.c
      cmd-line-utils/readline/complete.c
      cmd-line-utils/readline/display.c
      cmd-line-utils/readline/histexpand.c
      cmd-line-utils/readline/histfile.c
      cmd-line-utils/readline/history.h
      cmd-line-utils/readline/input.c
      cmd-line-utils/readline/isearch.c
      cmd-line-utils/readline/kill.c
      cmd-line-utils/readline/macro.c
      cmd-line-utils/readline/mbutil.c
      cmd-line-utils/readline/misc.c
      cmd-line-utils/readline/nls.c
      cmd-line-utils/readline/readline.c
      cmd-line-utils/readline/readline.h
      cmd-line-utils/readline/rlprivate.h
      cmd-line-utils/readline/rltty.c
      cmd-line-utils/readline/search.c
      cmd-line-utils/readline/terminal.c
      cmd-line-utils/readline/text.c
      cmd-line-utils/readline/tilde.c
      cmd-line-utils/readline/undo.c
      cmd-line-utils/readline/util.c
      cmd-line-utils/readline/vi_mode.c
      extra/yassl/src/handshake.cpp
      extra/yassl/src/yassl_imp.cpp
      extra/yassl/taocrypt/include/modes.hpp
      extra/yassl/taocrypt/src/asn.cpp
      sql/log_event.cc
      sql/sql_repl.cc
      sql/sql_table.cc
      sql/thr_malloc.cc
      storage/myisam/ha_myisam.cc
      strings/decimal.c
 2986 Satya B	2009-06-29 [merge]
      merge to mysql-5.1-bugteam branch

    modified:
      configure.in
 2985 Satya B	2009-06-29 [merge]
      merge to mysql-5.1-bugteam

    added:
      mysql-test/r/innodb_bug40565.result
      mysql-test/t/innodb_bug40565.test
      storage/innobase/include/fsp0types.h
    modified:
      storage/innobase/include/fsp0fsp.h
      storage/innobase/include/mtr0log.ic
      storage/innobase/include/trx0sys.h
      storage/innobase/trx/trx0sys.c
 2984 Satya B	2009-06-29 [merge]
      Null merge mysql-5.0-bugteam to mysql-5.1-bugteam

 2983 Luis Soares	2009-06-29 [merge]
      merge: 5.1-bt bug branch --> 5.1-bt latest

    added:
      mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
      mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt
      mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
    modified:
      sql/sql_class.cc
 2982 V Narayanan	2009-06-29
      Bug#45196  Some collations do not sort correctly with IBMDB2I
      
      Some collations--including cp1250_czech_cs,latin2_czech_cs,
      ucs2/utf8_czech_ci, ucs2/utf8_danish_ci--are not being
      sorted correctly by the IBMDB2I storage engine. This
      was being caused because the sort order used by DB2 is
      incompatible with the order expected by MySQL.
      
      This patch removes support for the cp1250_czech_cs and
      latin2_czech_cs collations because it has been determined
      that the sort order used by DB2 is incompatible with the
      order expected by MySQL. Users needing a czech collation
      with IBMDB2I are encouraged to use a Unicode-based collation 
      instead of these single-byte collations. This patch also
      modifies the DB2 sort sequence used for ucs2/utf8_czech_ci
      and ucs2/utf8_danish_ci collations to better match the
      sorting expected by MySQL. This will only affect indexes
      or tables that are newly created through the IBMDB2I storage
      engine. Existing IBMDB2I tables will retain the old sort
      sequence until recreated.
     @ mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result
        Bug#45196  Some collations do not sort correctly with IBMDB2I
        
        Result file for the test case.
     @ mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test
        Bug#45196  Some collations do not sort correctly with IBMDB2I
        
        Adding tests for testing the sort order with the modified collations.
     @ storage/ibmdb2i/db2i_collationSupport.cc
        Bug#45196  Some collations do not sort correctly with IBMDB2I
        
        Remove the support for the cp1250_czech_cs and latin2_czech_cs 
        collations because it has been determined that the sort order
        used by DB2 is incompatible with the order expected by MySQL.
        Users needing a czech collation with IBMDB2I are encouraged to
        use a Unicode-based collation instead of these single-byte
        collations. This patch also modifies the DB2 sort sequence
        used for ucs2/utf8_czech_ci and ucs2/utf8_danish_ci collations
        to better match the sorting expected by MySQL. This will only 
        affect indexes or tables that are newly created through the
        IBMDB2I storage engine. Existing IBMDB2I tables will retain
        the old sort sequence until recreated.

    added:
      mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result
      mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test
    modified:
      storage/ibmdb2i/db2i_collationSupport.cc
 2981 Evgeny Potemkin	2009-06-26 [merge]
      Merged bug#45266.

    modified:
      mysql-test/r/select.result
      mysql-test/t/select.test
      sql/sql_base.cc
      sql/sql_select.cc
      sql/structs.h
 2980 Davi Arnaut	2009-06-25
      Bug#45548: XA transaction without access to InnoDB tables crashes the server
      
      The problem is that the one phase commit function failed to
      properly end a empty transaction. The solution is to ensure
      that the transaction cleanup procedure is invoked even for
      empty transactions.
     @ mysql-test/r/xa.result
        Add test case result for Bug#45548
     @ mysql-test/t/xa.test
        Add test case for Bug#45548
     @ sql/handler.cc
        Invoke transaction cleanup function whenever a transaction is ended.

    modified:
      mysql-test/r/xa.result
      mysql-test/t/xa.test
      sql/handler.cc
 2979 Alexey Kopytov	2009-06-26 [merge]
      Automerge.

 2978 Alexey Kopytov	2009-06-26 [merge]
      Automerge.

    modified:
      configure.in
 2977 Luis Soares	2009-06-26 [merge]
      local merge: 5.1-bt bug branch --> 5.1-bt latest

    added:
      mysql-test/include/wait_for_slave_io_error.inc
    modified:
      mysql-test/extra/rpl_tests/rpl_reset_slave.test
 2976 Alexey Kopytov	2009-06-26 [merge]
      Automerge.

    modified:
      sql/sql_parse.cc
 2975 Staale Smedseng	2009-06-26 [merge]
      Merge from 5.1-bugteam

    added:
      mysql-test/r/ctype_gbk_binlog.result
      mysql-test/t/ctype_gbk_binlog.test
    modified:
      mysql-test/extra/rpl_tests/rpl_reset_slave.test
      mysql-test/r/ctype_cp932_binlog_stm.result
      mysql-test/r/trigger_notembedded.result
      mysql-test/suite/rpl/r/rpl_row_reset_slave.result
      mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
      mysql-test/t/ctype_cp932_binlog_stm.test
      mysql-test/t/trigger_notembedded.test
      mysys/my_getopt.c
      sql/item.cc
      sql/slave.cc
      sql/sql_repl.cc
      sql/sql_show.cc
 2974 Staale Smedseng	2009-06-25
      Bug #34002 uninitialized Rows_examined for some admin queries
      such as quit and shutdown
      
      Logging to slow log can produce an undetermined value for
      Rows_examined in special cases. In debug mode this manifests
      itself as any of the various marker values used to mark
      uninitialized memory on various platforms.
      
      If logging happens on a THD object that hasn't performed any
      row reads (on this or any previous connections), the
      THD::examined_row_count may be uninitialized. This patch adds
      initialization for this attribute.
      
      No automated test cases are added, as for this to be
      meaningful, we need to ensure that we're using a THD
      fulfilling the above conditions. This is hard to do in the
      mysql-test-run framework. The patch has been verified
      manually, however, by restarting mysqld and running the test
      included with the bug report.

    modified:
      sql/sql_class.cc
 2973 Bernt M. Johnsen	2009-06-24 [merge]
      Bug#45293 Prepared on 5.1 gca branch

    modified:
      mysql-test/suite/funcs_1/r/storedproc.result
      mysql-test/suite/funcs_1/t/storedproc.test
 2972 Andrei Elkin	2009-06-23
      Bug #38240 Crash in safe_mutex_lock () thr_mutex.c line 97 on rotate_relay_log 
                  
      The reason for the crash was rotate_relay_log (mi=0x0) did not verify
      the passed value of active_mi.  There are more cases where active_mi
      is supposed to be non-zero e.g change_master(), stop_slave(), and it's
      reasonable to protect from a similar crash all of them with common
      fixes.
                  
      Fixed with spliting end_slave() in slave threads release and slave
      data clean-up parts (a new close_active_mi()). The new function is
      invoked at the very end of close_connections() so that all users of
      active_mi are proven to have left.
     @ sql/mysqld.cc
        added the 2nd part (data) of the slave's clean up.
     @ sql/slave.cc
        end_slave() is split in two part to release the slave threads and the remained
        resources separately.
        The new close_active_mi() should be called after all possible users ofactive_mi
        has left, i.e at the very end of close_connections().
     @ sql/slave.h
        interface to the new end_active_mi() function is added.

    modified:
      sql/mysqld.cc
      sql/slave.cc
      sql/slave.h
 2971 Martin Hansson	2009-06-22 [merge]
      Merge

    modified:
      mysql-test/r/trigger.result
      mysql-test/t/trigger.test
      sql/sql_insert.cc
 2970 Georgi Kodinov	2009-06-22 [merge]
      automerge

 2969 Georgi Kodinov	2009-06-22 [merge]
      automerge

    added:
      mysql-test/r/innodb_bug45357.result
      mysql-test/t/innodb_bug45357.test
    modified:
      mysys/hash.c
      storage/innobase/btr/btr0cur.c
      storage/innobase/include/trx0rseg.ic
      storage/innobase/row/row0mysql.c
      storage/innobase/trx/trx0rec.c
 2968 Georgi Kodinov	2009-06-22 [merge]
      automerge

    modified:
      configure.in
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2009-06-15 15:57:06 +0000
+++ b/client/mysql.cc	2009-07-03 11:55:45 +0000
@@ -115,7 +115,7 @@ extern "C" {
 #define PROMPT_CHAR '\\'
 #define DEFAULT_DELIMITER ";"
 
-#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L)
+#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L * 1024L)
 
 typedef struct st_status
 {
@@ -2004,7 +2004,7 @@ static COMMANDS *find_command(char *name
 				     (uchar*)commands[i].name,len) &&
 	  !commands[i].name[len] &&
 	  (!end || (end && commands[i].takes_params))) ||
-	 !name && commands[i].cmd_char == cmd_char))
+	 (!name && commands[i].cmd_char == cmd_char)))
     {
       DBUG_PRINT("exit",("found command: %s", commands[i].name));
       DBUG_RETURN(&commands[i]);
@@ -2163,7 +2163,7 @@ static bool add_line(String &buffer,char
       buffer.length(0);
     }
     else if (!*ml_comment && (!*in_string && (inchar == '#' ||
-			      inchar == '-' && pos[1] == '-' &&
+                                              (inchar == '-' && pos[1] == '-' &&
                               /*
                                 The third byte is either whitespace or is the
                                 end of the line -- which would occur only
@@ -2171,7 +2171,7 @@ static bool add_line(String &buffer,char
                                 itself whitespace and should also match.
                               */
 			      (my_isspace(charset_info,pos[2]) ||
-                               !pos[2]))))
+                               !pos[2])))))
     {
       // Flush previously accepted characters
       if (out != line)
@@ -2732,7 +2732,7 @@ static int com_server_help(String *buffe
 {
   MYSQL_ROW cur;
   const char *server_cmd= buffer->ptr();
-  char cmd_buf[100];
+  char cmd_buf[100 + 1];
   MYSQL_RES *result;
   int error;
   
@@ -4264,41 +4264,36 @@ com_status(String *buffer __attribute__(
   MYSQL_RES *result;
   LINT_INIT(result);
 
+  if (mysql_real_query_for_lazy(
+        C_STRING_WITH_LEN("select DATABASE(), USER() limit 1")))
+    return 0;
+
   tee_puts("--------------", stdout);
   usage(1);					/* Print version */
-  if (connected)
+  tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
+  /*
+    Don't remove "limit 1",
+    it is protection againts SQL_SELECT_LIMIT=0
+  */
+  if (mysql_store_result_for_lazy(&result))
   {
-    tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
-    /* 
-      Don't remove "limit 1", 
-      it is protection againts SQL_SELECT_LIMIT=0
-    */
-    if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") &&
-	(result=mysql_use_result(&mysql)))
+    MYSQL_ROW cur=mysql_fetch_row(result);
+    if (cur)
     {
-      MYSQL_ROW cur=mysql_fetch_row(result);
-      if (cur)
-      {
-        tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
-        tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
-      }
-      mysql_free_result(result);
-    } 
-#ifdef HAVE_OPENSSL
-    if ((status_str= mysql_get_ssl_cipher(&mysql)))
-      tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
-		  status_str);
-    else
-#endif /* HAVE_OPENSSL */
-      tee_puts("SSL:\t\t\tNot in use", stdout);
+      tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
+      tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
+    }
+    mysql_free_result(result);
   }
+
+#ifdef HAVE_OPENSSL
+  if ((status_str= mysql_get_ssl_cipher(&mysql)))
+    tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
+                status_str);
   else
-  {
-    vidattr(A_BOLD);
-    tee_fprintf(stdout, "\nNo connection\n");
-    vidattr(A_NORMAL);
-    return 0;
-  }
+#endif /* HAVE_OPENSSL */
+    tee_puts("SSL:\t\t\tNot in use", stdout);
+
   if (skip_updates)
   {
     vidattr(A_BOLD);
@@ -4317,8 +4312,14 @@ com_status(String *buffer __attribute__(
     tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff));
 
   /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
-  if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1") &&
-      (result=mysql_use_result(&mysql)))
+  if (mysql_real_query_for_lazy(C_STRING_WITH_LEN(
+        "select @@character_set_client, @@character_set_connection, "
+        "@@character_set_server, @@character_set_database limit 1")))
+  {
+    if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
+      return 0;
+  }
+  if (mysql_store_result_for_lazy(&result))
   {
     MYSQL_ROW cur=mysql_fetch_row(result);
     if (cur)

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2009-05-12 21:27:19 +0000
+++ b/client/mysqlbinlog.cc	2009-06-30 18:40:38 +0000
@@ -681,6 +681,7 @@ Exit_status process_event(PRINT_EVENT_IN
 {
   char ll_buff[21];
   Log_event_type ev_type= ev->get_type_code();
+  my_bool destroy_evt= TRUE;
   DBUG_ENTER("process_event");
   print_event_info->short_form= short_form;
   Exit_status retval= OK_CONTINUE;
@@ -689,8 +690,8 @@ Exit_status process_event(PRINT_EVENT_IN
     Format events are not concerned by --offset and such, we always need to
     read them to be able to process the wanted events.
   */
-  if ((rec_count >= offset) &&
-      ((my_time_t)(ev->when) >= start_datetime) ||
+  if (((rec_count >= offset) &&
+       ((my_time_t)(ev->when) >= start_datetime)) ||
       (ev_type == FORMAT_DESCRIPTION_EVENT))
   {
     if (ev_type != FORMAT_DESCRIPTION_EVENT)
@@ -871,12 +872,63 @@ Exit_status process_event(PRINT_EVENT_IN
       break;
     }
     case TABLE_MAP_EVENT:
+    {
+      Table_map_log_event *map= ((Table_map_log_event *)ev);
+      if (shall_skip_database(map->get_db_name()))
+      {
+        print_event_info->m_table_map_ignored.set_table(map->get_table_id(), map);
+        destroy_evt= FALSE;
+        goto end;
+      }
+    }
     case WRITE_ROWS_EVENT:
     case DELETE_ROWS_EVENT:
     case UPDATE_ROWS_EVENT:
     case PRE_GA_WRITE_ROWS_EVENT:
     case PRE_GA_DELETE_ROWS_EVENT:
     case PRE_GA_UPDATE_ROWS_EVENT:
+    {
+      if (ev_type != TABLE_MAP_EVENT)
+      {
+        Rows_log_event *e= (Rows_log_event*) ev;
+        Table_map_log_event *ignored_map= 
+          print_event_info->m_table_map_ignored.get_table(e->get_table_id());
+        bool skip_event= (ignored_map != NULL);
+
+        /* 
+           end of statement check:
+             i) destroy/free ignored maps
+            ii) if skip event, flush cache now
+         */
+        if (e->get_flags(Rows_log_event::STMT_END_F))
+        {
+          /* 
+            Now is safe to clear ignored map (clear_tables will also
+            delete original table map events stored in the map).
+          */
+          if (print_event_info->m_table_map_ignored.count() > 0)
+            print_event_info->m_table_map_ignored.clear_tables();
+
+          /* 
+             One needs to take into account an event that gets
+             filtered but was last event in the statement. If this is
+             the case, previous rows events that were written into
+             IO_CACHEs still need to be copied from cache to
+             result_file (as it would happen in ev->print(...) if
+             event was not skipped).
+          */
+          if (skip_event)
+          {
+            if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file) ||
+                copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file)))
+              goto err;
+          }
+        }
+
+        /* skip the event check */
+        if (skip_event)
+          goto end;
+      }
       /*
         These events must be printed in base64 format, if printed.
         base64 format requires a FD event to be safe, so if no FD
@@ -900,6 +952,7 @@ Exit_status process_event(PRINT_EVENT_IN
         goto err;
       }
       /* FALL THROUGH */
+    }
     default:
       ev->print(result_file, print_event_info);
     }
@@ -919,7 +972,8 @@ end:
   {
     if (remote_opt)
       ev->temp_buf= 0;
-    delete ev;
+    if (destroy_evt) /* destroy it later if not set (ignored table map) */
+      delete ev;
   }
   DBUG_RETURN(retval);
 }

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2009-06-05 16:40:36 +0000
+++ b/client/mysqldump.c	2009-07-07 13:11:46 +0000
@@ -4110,7 +4110,7 @@ static my_bool dump_all_views_in_db(char
     for (numrows= 0 ; (table= getTableName(1)); )
     {
       char *end= strmov(afterdot, table);
-      if (include_table(hash_key,end - hash_key))
+      if (include_table((uchar*) hash_key,end - hash_key))
       {
         numrows++;
         dynstr_append_checked(&query, quote_name(table, table_buff, 1));
@@ -4131,7 +4131,7 @@ static my_bool dump_all_views_in_db(char
   while ((table= getTableName(0)))
   {
     char *end= strmov(afterdot, table);
-    if (include_table(hash_key, end - hash_key))
+    if (include_table((uchar*) hash_key, end - hash_key))
       get_view_structure(table, database);
   }
   if (opt_xml)

=== modified file 'cmd-line-utils/readline/bind.c'
--- a/cmd-line-utils/readline/bind.c	2009-06-06 13:05:44 +0000
+++ b/cmd-line-utils/readline/bind.c	2009-06-29 14:00:47 +0000
@@ -79,7 +79,7 @@ static int _rl_read_init_file PARAMS((co
 static int glean_key_from_name PARAMS((char *));
 static int find_boolean_var PARAMS((const char *));
 
-static char *_rl_get_string_variable_value PARAMS((const char *));
+static const char *_rl_get_string_variable_value PARAMS((const char *));
 static int substring_member_of_array PARAMS((char *, const char **));
 
 static int currently_reading_init_file;
@@ -442,7 +442,7 @@ rl_translate_keyseq (seq, array, len)
 {
   register int i, c, l, temp;
 
-  for (i = l = 0; c = seq[i]; i++)
+  for (i = l = 0; (c = seq[i]); i++)
     {
       if (c == '\\')
 	{
@@ -776,7 +776,8 @@ _rl_read_file (filename, sizep)
   file_size = (size_t)finfo.st_size;
 
   /* check for overflow on very large files */
-  if (file_size != finfo.st_size || file_size + 1 < file_size)
+if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||  
+    file_size + 1 < file_size)
     {
       if (file >= 0)
 	close (file);
@@ -807,7 +808,7 @@ _rl_read_file (filename, sizep)
 /* Re-read the current keybindings file. */
 int
 rl_re_read_init_file (count, ignore)
-     int count, ignore;
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   int r;
   r = rl_read_init_file ((const char *)NULL);
@@ -1031,7 +1032,7 @@ parser_if (args)
 /* Invert the current parser state if there is anything on the stack. */
 static int
 parser_else (args)
-     char *args;
+     char *args __attribute__((unused));
 {
   register int i;
 
@@ -1062,7 +1063,7 @@ parser_else (args)
    _rl_parsing_conditionalized_out from the stack. */
 static int
 parser_endif (args)
-     char *args;
+     char *args __attribute__((unused));
 {
   if (if_stack_depth)
     _rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
@@ -1185,7 +1186,7 @@ rl_parse_and_bind (string)
     {
       int passc = 0;
 
-      for (i = 1; c = string[i]; i++)
+      for (i = 1; (c = string[i]); i++)
 	{
 	  if (passc)
 	    {
@@ -1276,7 +1277,7 @@ rl_parse_and_bind (string)
       int delimiter, passc;
 
       delimiter = string[i++];
-      for (passc = 0; c = string[i]; i++)
+      for (passc = 0; (c = string[i]); i++)
 	{
 	  if (passc)
 	    {
@@ -1436,7 +1437,7 @@ static struct {
 #if defined (VISIBLE_STATS)
   { "visible-stats",		&rl_visible_stats,		0 },
 #endif /* VISIBLE_STATS */
-  { (char *)NULL, (int *)NULL }
+  { (char *)NULL, (int *)NULL, 0 }
 };
 
 static int
@@ -1505,7 +1506,7 @@ static struct {
   { "editing-mode",	V_STRING,	sv_editmode },
   { "isearch-terminators", V_STRING,	sv_isrchterm },
   { "keymap",		V_STRING,	sv_keymap },
-  { (char *)NULL,	0 }
+  { (char *)NULL,	0,              (_rl_sv_func_t*)NULL }
 };
 
 static int
@@ -1532,7 +1533,7 @@ bool_to_int (value)
 		(value[0] == '1' && value[1] == '\0'));
 }
 
-char *
+const char *
 rl_variable_value (name)
      const char *name;
 {
@@ -1799,7 +1800,7 @@ rl_set_keymap_from_edit_mode ()
 #endif /* VI_MODE */
 }
 
-char *
+const char *
 rl_get_keymap_name_from_edit_mode ()
 {
   if (rl_editing_mode == emacs_mode)
@@ -2048,7 +2049,7 @@ rl_function_dumper (print_readably)
 
   fprintf (rl_outstream, "\n");
 
-  for (i = 0; name = names[i]; i++)
+  for (i = 0; (name = names[i]); i++)
     {
       rl_command_func_t *function;
       char **invokers;
@@ -2108,7 +2109,7 @@ rl_function_dumper (print_readably)
    the output in such a way that it can be read back in. */
 int
 rl_dump_functions (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_dispatching)
     fprintf (rl_outstream, "\r\n");
@@ -2188,7 +2189,7 @@ rl_macro_dumper (print_readably)
 
 int
 rl_dump_macros (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_dispatching)
     fprintf (rl_outstream, "\r\n");
@@ -2197,12 +2198,13 @@ rl_dump_macros (count, key)
   return (0);
 }
 
-static char *
+static const char *
 _rl_get_string_variable_value (name)
      const char *name;
 {
   static char numbuf[32];
-  char *ret;
+  const char *ret;
+  char *tmp;
 
   if (_rl_stricmp (name, "bell-style") == 0)
     {
@@ -2230,11 +2232,11 @@ _rl_get_string_variable_value (name)
     {
       if (_rl_isearch_terminators == 0)
 	return 0;
-      ret = _rl_untranslate_macro_value (_rl_isearch_terminators);
-      if (ret)
+      tmp = _rl_untranslate_macro_value (_rl_isearch_terminators);
+      if (tmp)
 	{
-	  strncpy (numbuf, ret, sizeof (numbuf) - 1);
-	  free (ret);
+	  strncpy (numbuf, tmp, sizeof (numbuf) - 1);
+	  free (tmp);
 	  numbuf[sizeof(numbuf) - 1] = '\0';
 	}
       else
@@ -2257,7 +2259,7 @@ rl_variable_dumper (print_readably)
      int print_readably;
 {
   int i;
-  char *v;
+  const char *v;
 
   for (i = 0; boolean_varlist[i].name; i++)
     {
@@ -2286,7 +2288,7 @@ rl_variable_dumper (print_readably)
    the output in such a way that it can be read back in. */
 int
 rl_dump_variables (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_dispatching)
     fprintf (rl_outstream, "\r\n");

=== modified file 'cmd-line-utils/readline/complete.c'
--- a/cmd-line-utils/readline/complete.c	2008-01-23 16:43:46 +0000
+++ b/cmd-line-utils/readline/complete.c	2009-06-29 14:00:47 +0000
@@ -359,14 +359,14 @@ rl_complete (ignore, invoking_key)
 /* List the possible completions.  See description of rl_complete (). */
 int
 rl_possible_completions (ignore, invoking_key)
-     int ignore, invoking_key;
+     int ignore __attribute__((unused)), invoking_key __attribute__((unused));
 {
   return (rl_complete_internal ('?'));
 }
 
 int
 rl_insert_completions (ignore, invoking_key)
-     int ignore, invoking_key;
+     int ignore __attribute__((unused)), invoking_key __attribute__((unused));
 {
   return (rl_complete_internal ('*'));
 }
@@ -696,7 +696,8 @@ print_filename (to_print, full_pathname)
      char *to_print, *full_pathname;
 {
   int printed_len, extension_char, slen, tlen;
-  char *s, c, *new_full_pathname, *dn;
+  char *s, c, *new_full_pathname;
+  const char *dn;
 
   extension_char = 0;
   printed_len = fnprint (to_print);
@@ -783,7 +784,7 @@ print_filename (to_print, full_pathname)
 static char *
 rl_quote_filename (s, rtype, qcp)
      char *s;
-     int rtype;
+     int rtype __attribute__((unused));
      char *qcp;
 {
   char *r;
@@ -884,7 +885,7 @@ _rl_find_completion_word (fp, dp)
       /* We didn't find an unclosed quoted substring upon which to do
          completion, so use the word break characters to find the
          substring on which to complete. */
-      while (rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_ANY))
+      while ((rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_ANY)))
 	{
 	  scan = rl_line_buffer[rl_point];
 
@@ -1803,7 +1804,7 @@ rl_completion_matches (text, entry_funct
   match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *));
   match_list[1] = (char *)NULL;
 
-  while (string = (*entry_function) (text, matches))
+  while ((string = (*entry_function) (text, matches)))
     {
       if (matches + 1 == match_list_size)
 	match_list = (char **)xrealloc
@@ -2111,7 +2112,7 @@ rl_filename_completion_function (text, s
    ring the bell, and reset the counter to zero. */
 int
 rl_menu_complete (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   rl_compentry_func_t *our_func;
   int matching_filenames, found_quote;

=== modified file 'cmd-line-utils/readline/display.c'
--- a/cmd-line-utils/readline/display.c	2009-06-06 13:05:44 +0000
+++ b/cmd-line-utils/readline/display.c	2009-06-29 14:00:47 +0000
@@ -127,7 +127,7 @@ int _rl_want_redisplay = 0;
 
 /* The stuff that gets printed out before the actual text of the line.
    This is usually pointing to rl_prompt. */
-char *rl_display_prompt = (char *)NULL;
+const char *rl_display_prompt = (const char *)NULL;
 
 /* Pseudo-global variables declared here. */
 
@@ -229,7 +229,10 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
      int *lp, *lip, *niflp, *vlp;
 {
   char *r, *ret, *p, *igstart;
-  int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
+  int l, rl, last, ignoring, ninvis, invfl, invflset, physchars;
+#if defined (HANDLE_MULTIBYTE)
+  int ind, pind;
+#endif
 
   /* Short-circuit if we can. */
   if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
@@ -242,7 +245,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
       if (niflp)
 	*niflp = 0;
       if (vlp)
-	*vlp = lp ? *lp : strlen (r);
+	*vlp = lp ? *lp : (int)strlen (r);
       return r;
     }
 
@@ -459,9 +462,10 @@ rl_redisplay ()
   register int in, out, c, linenum, cursor_linenum;
   register char *line;
   int inv_botlin, lb_botlin, lb_linenum, o_cpos;
-  int newlines, lpos, temp, modmark, n0, num;
-  char *prompt_this_line;
+  int newlines, lpos, temp, modmark;
+  const char *prompt_this_line;
 #if defined (HANDLE_MULTIBYTE)
+  int num, n0;
   wchar_t wc;
   size_t wc_bytes;
   int wc_width;
@@ -626,7 +630,6 @@ rl_redisplay ()
      contents of the command line? */
   while (lpos >= _rl_screenwidth)
     {
-      int z;
       /* fix from Darin Johnson <darin@stripped> for prompt string with
          invisible characters that is longer than the screen width.  The
          prompt_invis_chars_first_line variable could be made into an array
@@ -635,6 +638,7 @@ rl_redisplay ()
          prompts that exceed two physical lines?
          Additional logic fix from Edward Catmur <ed@stripped> */
 #if defined (HANDLE_MULTIBYTE)
+      int z;
       if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
 	{
 	  n0 = num;
@@ -878,6 +882,7 @@ rl_redisplay ()
   if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
     {
       int nleft, pos, changed_screen_line, tx;
+      char empty_str[1] = { 0 };
 
       if (!rl_display_fixed || forced_display)
 	{
@@ -902,7 +907,7 @@ rl_redisplay ()
 #define VIS_LLEN(l)	((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
 #define INV_LLEN(l)	(inv_lbreaks[l+1] - inv_lbreaks[l])
 #define VIS_CHARS(line) (visible_line + vis_lbreaks[line])
-#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
+#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? empty_str : VIS_CHARS(line)
 #define INV_LINE(line) (invisible_line + inv_lbreaks[line])
 
 	  /* For each line in the buffer, do the updating display. */
@@ -969,7 +974,7 @@ rl_redisplay ()
 		  _rl_move_vert (linenum);
 		  _rl_move_cursor_relative (0, tt);
 		  _rl_clear_to_eol
-		    ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth);
+		    ((linenum == _rl_vis_botlin) ? (int)strlen (tt) : _rl_screenwidth);
 		}
 	    }
 	  _rl_vis_botlin = inv_botlin;
@@ -2261,7 +2266,7 @@ static void
 redraw_prompt (t)
      char *t;
 {
-  char *oldp;
+  const char *oldp;
 
   oldp = rl_display_prompt;
   rl_save_prompt ();

=== modified file 'cmd-line-utils/readline/histexpand.c'
--- a/cmd-line-utils/readline/histexpand.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/histexpand.c	2009-06-29 13:17:01 +0000
@@ -87,14 +87,14 @@ char history_comment_char = '\0';
 
 /* The list of characters which inhibit the expansion of text if found
    immediately following history_expansion_char. */
-char *history_no_expand_chars = " \t\n\r=";
+const char *history_no_expand_chars = " \t\n\r=";
 
 /* If set to a non-zero value, single quotes inhibit history expansion.
    The default is 0. */
 int history_quotes_inhibit_expansion = 0;
 
 /* Used to split words by history_tokenize_internal. */
-char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
+const char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
 
 /* If set, this points to a function that is called to verify that a
    particular history expansion should be performed. */
@@ -203,7 +203,7 @@ get_history_event (string, caller_index,
     }
 
   /* Only a closing `?' or a newline delimit a substring search string. */
-  for (local_index = i; c = string[i]; i++)
+  for (local_index = i; (c = string[i]); i++)
     {
 #if defined (HANDLE_MULTIBYTE)
       if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)

=== modified file 'cmd-line-utils/readline/histfile.c'
--- a/cmd-line-utils/readline/histfile.c	2008-01-23 16:43:46 +0000
+++ b/cmd-line-utils/readline/histfile.c	2009-06-29 14:00:47 +0000
@@ -186,7 +186,8 @@ read_history_range (filename, from, to)
   file_size = (size_t)finfo.st_size;
 
   /* check for overflow on very large files */
-  if (file_size != finfo.st_size || file_size + 1 < file_size)
+if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||  
+    file_size + 1 < file_size)
     {
       errno = overflow_errno;
       goto error_and_exit;
@@ -339,7 +340,8 @@ history_truncate_file (fname, lines)
   file_size = (size_t)finfo.st_size;
 
   /* check for overflow on very large files */
-  if (file_size != finfo.st_size || file_size + 1 < file_size)
+if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||  
+    file_size + 1 < file_size)
     {
       close (file);
 #if defined (EFBIG)

=== modified file 'cmd-line-utils/readline/history.h'
--- a/cmd-line-utils/readline/history.h	2005-07-19 00:22:38 +0000
+++ b/cmd-line-utils/readline/history.h	2009-06-29 13:17:01 +0000
@@ -243,9 +243,9 @@ extern int history_length;
 extern int history_max_entries;
 extern char history_expansion_char;
 extern char history_subst_char;
-extern char *history_word_delimiters;
+extern const char *history_word_delimiters;
 extern char history_comment_char;
-extern char *history_no_expand_chars;
+extern const char *history_no_expand_chars;
 extern char *history_search_delimiter_chars;
 extern int history_quotes_inhibit_expansion;
 

=== modified file 'cmd-line-utils/readline/input.c'
--- a/cmd-line-utils/readline/input.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/input.c	2009-06-29 13:17:01 +0000
@@ -420,7 +420,7 @@ rl_read_key ()
   else
     {
       /* If input is coming from a macro, then use that. */
-      if (c = _rl_next_macro_key ())
+      if ((c = _rl_next_macro_key ()))
 	return (c);
 
       /* If the user has an event function, then call it periodically. */

=== modified file 'cmd-line-utils/readline/isearch.c'
--- a/cmd-line-utils/readline/isearch.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/isearch.c	2009-06-29 13:17:01 +0000
@@ -75,7 +75,7 @@ static int _rl_isearch_cleanup PARAMS((_
 static char *last_isearch_string;
 static int last_isearch_string_len;
 
-static char *default_isearch_terminators = "\033\012";
+static const char *default_isearch_terminators = "\033\012";
 
 _rl_search_cxt *
 _rl_scxt_alloc (type, flags)
@@ -119,7 +119,7 @@ _rl_scxt_alloc (type, flags)
 void
 _rl_scxt_dispose (cxt, flags)
      _rl_search_cxt *cxt;
-     int flags;
+     int flags __attribute__((unused));
 {
   FREE (cxt->search_string);
   FREE (cxt->allocated_line);
@@ -154,7 +154,7 @@ rl_forward_search_history (sign, key)
 static void
 rl_display_search (search_string, reverse_p, where)
      char *search_string;
-     int reverse_p, where;
+     int reverse_p, where __attribute__((unused));
 {
   char *message;
   int msglen, searchlen;
@@ -614,7 +614,7 @@ _rl_isearch_cleanup (cxt, r)
    backwards. */
 static int
 rl_search_history (direction, invoking_key)
-     int direction, invoking_key;
+     int direction, invoking_key __attribute__((unused));
 {
   _rl_search_cxt *cxt;		/* local for now, but saved globally */
   int c, r;

=== modified file 'cmd-line-utils/readline/kill.c'
--- a/cmd-line-utils/readline/kill.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/kill.c	2009-06-29 13:17:01 +0000
@@ -79,7 +79,7 @@ static int rl_yank_nth_arg_internal PARA
    of kill material. */
 int
 rl_set_retained_kills (num)
-     int num;
+     int num __attribute__((unused));
 {
   return 0;
 }
@@ -296,7 +296,7 @@ rl_backward_kill_line (direction, ignore
 /* Kill the whole line, no matter where point is. */
 int
 rl_kill_full_line (count, ignore)
-     int count, ignore;
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   rl_begin_undo_group ();
   rl_point = 0;
@@ -314,7 +314,7 @@ rl_kill_full_line (count, ignore)
    using behaviour that they expect. */
 int
 rl_unix_word_rubout (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   int orig_point;
 
@@ -347,7 +347,7 @@ rl_unix_word_rubout (count, key)
    deletes backward to directory separator (`/') or whitespace.  */
 int
 rl_unix_filename_rubout (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   int orig_point, c;
 
@@ -391,7 +391,7 @@ rl_unix_filename_rubout (count, key)
    doing. */
 int
 rl_unix_line_discard (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_point == 0)
     rl_ding ();
@@ -428,7 +428,7 @@ region_kill_internal (delete)
 /* Copy the text in the region to the kill ring. */
 int
 rl_copy_region_to_kill (count, ignore)
-     int count, ignore;
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   return (region_kill_internal (0));
 }
@@ -436,7 +436,7 @@ rl_copy_region_to_kill (count, ignore)
 /* Kill the text between the point and mark. */
 int
 rl_kill_region (count, ignore)
-     int count, ignore;
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   int r, npoint;
 
@@ -501,7 +501,7 @@ rl_copy_backward_word (count, key)
 /* Yank back the last killed text.  This ignores arguments. */
 int
 rl_yank (count, ignore)
-     int count, ignore;
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   if (rl_kill_ring == 0)
     {
@@ -520,7 +520,7 @@ rl_yank (count, ignore)
    yank back some other text. */
 int
 rl_yank_pop (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   int l, n;
 

=== modified file 'cmd-line-utils/readline/macro.c'
--- a/cmd-line-utils/readline/macro.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/macro.c	2009-06-29 13:17:01 +0000
@@ -201,7 +201,7 @@ _rl_kill_kbd_macro ()
    re-executing the existing macro. */
 int
 rl_start_kbd_macro (ignore1, ignore2)
-     int ignore1, ignore2;
+     int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
 {
   if (RL_ISSTATE (RL_STATE_MACRODEF))
     {
@@ -226,7 +226,7 @@ rl_start_kbd_macro (ignore1, ignore2)
    that many times, counting the definition as the first time. */
 int
 rl_end_kbd_macro (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
     {
@@ -246,7 +246,7 @@ rl_end_kbd_macro (count, ignore)
    COUNT says how many times to execute it. */
 int
 rl_call_last_kbd_macro (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   if (current_macro == 0)
     _rl_abort_internal ();

=== modified file 'cmd-line-utils/readline/mbutil.c'
--- a/cmd-line-utils/readline/mbutil.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/mbutil.c	2009-06-29 13:17:01 +0000
@@ -346,8 +346,8 @@ _rl_char_value (buf, ind)
 #undef _rl_find_next_mbchar
 int
 _rl_find_next_mbchar (string, seed, count, flags)
-     char *string;
-     int seed, count, flags;
+     char *string __attribute__((unused));
+     int seed, count, flags __attribute__((unused));
 {
 #if defined (HANDLE_MULTIBYTE)
   return _rl_find_next_mbchar_internal (string, seed, count, flags);
@@ -362,8 +362,8 @@ _rl_find_next_mbchar (string, seed, coun
 #undef _rl_find_prev_mbchar
 int
 _rl_find_prev_mbchar (string, seed, flags)
-     char *string;
-     int seed, flags;
+     char *string __attribute__((unused));
+     int seed, flags __attribute__((unused));
 {
 #if defined (HANDLE_MULTIBYTE)
   return _rl_find_prev_mbchar_internal (string, seed, flags);

=== modified file 'cmd-line-utils/readline/misc.c'
--- a/cmd-line-utils/readline/misc.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/misc.c	2009-06-29 13:17:01 +0000
@@ -228,7 +228,7 @@ _rl_reset_argument ()
 /* Start a numeric argument with initial value KEY */
 int
 rl_digit_argument (ignore, key)
-     int ignore, key;
+     int ignore __attribute__((unused)), key;
 {
   _rl_arg_init ();
   if (RL_ISSTATE (RL_STATE_CALLBACK))
@@ -249,7 +249,7 @@ rl_digit_argument (ignore, key)
    dispatch on it.  If the key is the abort character then abort. */
 int
 rl_universal_argument (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   _rl_arg_init ();
   rl_numeric_arg *= 4;
@@ -413,7 +413,7 @@ _rl_history_set_point ()
 void
 rl_replace_from_history (entry, flags)
      HIST_ENTRY *entry;
-     int flags;			/* currently unused */
+     int flags __attribute__((unused));	/* currently unused */
 {
   /* Can't call with `1' because rl_undo_list might point to an undo list
      from a history entry, just like we're setting up here. */
@@ -440,7 +440,7 @@ rl_replace_from_history (entry, flags)
 /* Meta-< goes to the start of the history. */
 int
 rl_beginning_of_history (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   return (rl_get_previous_history (1 + where_history (), key));
 }
@@ -448,7 +448,7 @@ rl_beginning_of_history (count, key)
 /* Meta-> goes to the end of the history.  (The current line). */
 int
 rl_end_of_history (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   rl_maybe_replace_line ();
   using_history ();
@@ -553,7 +553,7 @@ rl_get_previous_history (count, key)
 /* How to toggle back and forth between editing modes. */
 int
 rl_vi_editing_mode (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
 #if defined (VI_MODE)
   _rl_set_insert_mode (RL_IM_INSERT, 1);	/* vi mode ignores insert mode */
@@ -566,7 +566,7 @@ rl_vi_editing_mode (count, key)
 
 int
 rl_emacs_editing_mode (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   rl_editing_mode = emacs_mode;
   _rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
@@ -577,7 +577,7 @@ rl_emacs_editing_mode (count, key)
 /* Function for the rest of the library to use to set insert/overwrite mode. */
 void
 _rl_set_insert_mode (im, force)
-     int im, force;
+     int im, force __attribute__((unused));
 {
 #ifdef CURSOR_MODE
   _rl_set_cursor (im, force);
@@ -590,7 +590,7 @@ _rl_set_insert_mode (im, force)
    mode.  A negative or zero explicit argument selects insert mode. */
 int
 rl_overwrite_mode (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   if (rl_explicit_arg == 0)
     _rl_set_insert_mode (rl_insert_mode ^ 1, 0);

=== modified file 'cmd-line-utils/readline/nls.c'
--- a/cmd-line-utils/readline/nls.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/nls.c	2009-06-29 13:17:01 +0000
@@ -101,7 +101,8 @@ _rl_init_eightbit ()
 /* If we have setlocale(3), just check the current LC_CTYPE category
    value, and go into eight-bit mode if it's not C or POSIX. */
 #if defined (HAVE_SETLOCALE)
-  char *lspec, *t;
+  const char *lspec;
+  char *t;
 
   /* Set the LC_CTYPE locale category from environment variables. */
   lspec = _rl_get_locale_var ("LC_CTYPE");
@@ -127,7 +128,8 @@ _rl_init_eightbit ()
     return (0);
 
 #else /* !HAVE_SETLOCALE */
-  char *lspec, *t;
+  const char *lspec;
+  char *t;
   int i;
 
   /* We don't have setlocale.  Finesse it.  Check the environment for the

=== modified file 'cmd-line-utils/readline/readline.c'
--- a/cmd-line-utils/readline/readline.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/readline.c	2009-06-29 13:17:01 +0000
@@ -90,7 +90,7 @@ static void bind_arrow_keys_internal PAR
 static void bind_arrow_keys PARAMS((void));
 
 static void readline_default_bindings PARAMS((void));
-static void reset_default_bindings PARAMS((void));
+static void reset_default_bindings PARAMS((void)) __attribute__((unused));
 
 static int _rl_subseq_result PARAMS((int, Keymap, int, int));
 static int _rl_subseq_getchar PARAMS((int));

=== modified file 'cmd-line-utils/readline/readline.h'
--- a/cmd-line-utils/readline/readline.h	2007-11-19 13:38:08 +0000
+++ b/cmd-line-utils/readline/readline.h	2009-06-29 13:17:01 +0000
@@ -304,7 +304,7 @@ extern int rl_bind_keyseq_if_unbound PAR
 extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
 extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
 
-extern char *rl_variable_value PARAMS((const char *));
+extern const char *rl_variable_value PARAMS((const char *));
 extern int rl_variable_bind PARAMS((const char *, const char *));
 
 /* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
@@ -343,7 +343,7 @@ extern void rl_set_keymap PARAMS((Keymap
 extern Keymap rl_get_keymap PARAMS((void));
 /* Undocumented; used internally only. */
 extern void rl_set_keymap_from_edit_mode PARAMS((void));
-extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
+extern const char *rl_get_keymap_name_from_edit_mode PARAMS((void));
 
 /* Functions for manipulating the funmap, which maps command names to functions. */
 extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
@@ -406,7 +406,7 @@ extern void rl_set_screen_size PARAMS((i
 extern void rl_get_screen_size PARAMS((int *, int *));
 extern void rl_reset_screen_size PARAMS((void));
 
-extern char *rl_get_termcap PARAMS((const char *));
+extern const char *rl_get_termcap PARAMS((const char *));
 
 /* Functions for character input. */
 extern int rl_stuff_char PARAMS((int));

=== modified file 'cmd-line-utils/readline/rlprivate.h'
--- a/cmd-line-utils/readline/rlprivate.h	2007-11-19 13:38:08 +0000
+++ b/cmd-line-utils/readline/rlprivate.h	2009-06-29 13:17:01 +0000
@@ -77,7 +77,7 @@ typedef struct  __rl_search_context
   int sline_len;
   int sline_index;
 
-  char  *search_terminators;
+  const char  *search_terminators;
 } _rl_search_cxt;
 
 /* Callback data for reading numeric arguments */
@@ -164,7 +164,7 @@ extern int rl_set_retained_kills PARAMS(
 extern void _rl_set_screen_size PARAMS((int, int));
 
 /* undo.c */
-extern int _rl_fix_last_undo_of_type PARAMS((int, int, int));
+extern int _rl_fix_last_undo_of_type PARAMS((enum undo_code, int, int));
 
 /* util.c */
 extern char *_rl_savestring PARAMS((const char *));
@@ -359,7 +359,7 @@ extern int _rl_vis_botlin;
 extern int _rl_last_c_pos;
 extern int _rl_suppress_redisplay;
 extern int _rl_want_redisplay;
-extern char *rl_display_prompt;
+extern const char *rl_display_prompt;
 
 /* isearch.c */
 extern char *_rl_isearch_terminators;
@@ -398,17 +398,17 @@ extern _rl_search_cxt *_rl_nscxt;
 /* terminal.c */
 extern int _rl_enable_keypad;
 extern int _rl_enable_meta;
-extern char *_rl_term_clreol;
-extern char *_rl_term_clrpag;
-extern char *_rl_term_im;
-extern char *_rl_term_ic;
-extern char *_rl_term_ei;
-extern char *_rl_term_DC;
-extern char *_rl_term_up;
-extern char *_rl_term_dc;
-extern char *_rl_term_cr;
-extern char *_rl_term_IC;
-extern char *_rl_term_forward_char;
+extern const char *_rl_term_clreol;
+extern const char *_rl_term_clrpag;
+extern const char *_rl_term_im;
+extern const char *_rl_term_ic;
+extern const char *_rl_term_ei;
+extern const char *_rl_term_DC;
+extern const char *_rl_term_up;
+extern const char *_rl_term_dc;
+extern const char *_rl_term_cr;
+extern const char *_rl_term_IC;
+extern const char *_rl_term_forward_char;
 extern int _rl_screenheight;
 extern int _rl_screenwidth;
 extern int _rl_screenchars;

=== modified file 'cmd-line-utils/readline/rltty.c'
--- a/cmd-line-utils/readline/rltty.c	2008-01-23 16:43:46 +0000
+++ b/cmd-line-utils/readline/rltty.c	2009-06-29 14:00:47 +0000
@@ -764,7 +764,7 @@ rl_deprep_terminal ()
 
 int
 rl_restart_output (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
 #if defined (__MINGW32__)
   return 0;
@@ -802,7 +802,7 @@ rl_restart_output (count, key)
 
 int
 rl_stop_output (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
 #if defined (__MINGW32__)
   return 0;

=== modified file 'cmd-line-utils/readline/search.c'
--- a/cmd-line-utils/readline/search.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/search.c	2009-06-29 13:17:01 +0000
@@ -211,7 +211,7 @@ _rl_nsearch_init (dir, pchar)
   rl_end = rl_point = 0;
 
   p = _rl_make_prompt_for_search (pchar ? pchar : ':');
-  rl_message ("%s", p, 0);
+  rl_message ("%s", p);
   free (p);
 
   RL_SETSTATE(RL_STATE_NSEARCH);
@@ -383,7 +383,7 @@ noninc_search (dir, pchar)
    code calls this, KEY will be `?'. */
 int
 rl_noninc_forward_search (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   return noninc_search (1, (key == '?') ? '?' : 0);
 }
@@ -392,7 +392,7 @@ rl_noninc_forward_search (count, key)
    calls this, KEY will be `/'. */
 int
 rl_noninc_reverse_search (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   return noninc_search (-1, (key == '/') ? '/' : 0);
 }
@@ -401,7 +401,7 @@ rl_noninc_reverse_search (count, key)
    for.  If there is no saved search string, abort. */
 int
 rl_noninc_forward_search_again (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   int r;
 
@@ -418,7 +418,7 @@ rl_noninc_forward_search_again (count, k
    for.  If there is no saved search string, abort. */
 int
 rl_noninc_reverse_search_again (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   int r;
 

=== modified file 'cmd-line-utils/readline/terminal.c'
--- a/cmd-line-utils/readline/terminal.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/terminal.c	2009-06-29 13:17:01 +0000
@@ -104,34 +104,36 @@ char PC, *BC, *UP;
 #endif /* __linux__ */
 
 /* Some strings to control terminal actions.  These are output by tputs (). */
-char *_rl_term_clreol;
-char *_rl_term_clrpag;
-char *_rl_term_cr;
-char *_rl_term_backspace;
-char *_rl_term_goto;
-char *_rl_term_pc;
+const char *_rl_term_clreol;
+const char *_rl_term_clrpag;
+const char *_rl_term_cr;
+const char *_rl_term_backspace;
+char _rl_term_backspace_default[2] = { '\b', 0 };
+const char *_rl_term_goto;
+const char *_rl_term_pc;
 
 /* Non-zero if we determine that the terminal can do character insertion. */
 int _rl_terminal_can_insert = 0;
 
 /* How to insert characters. */
-char *_rl_term_im;
-char *_rl_term_ei;
-char *_rl_term_ic;
-char *_rl_term_ip;
-char *_rl_term_IC;
+const char *_rl_term_im;
+const char *_rl_term_ei;
+const char *_rl_term_ic;
+const char *_rl_term_ip;
+const char *_rl_term_IC;
 
 /* How to delete characters. */
-char *_rl_term_dc;
-char *_rl_term_DC;
+const char *_rl_term_dc;
+const char *_rl_term_DC;
 
-char *_rl_term_forward_char;
+const char *_rl_term_forward_char;
 
 /* How to go up a line. */
-char *_rl_term_up;
+const char *_rl_term_up;
+char _rl_term_up_default[2] = { 0, 0 };
 
 /* A visible bell; char if the terminal can be made to flash the screen. */
-static char *_rl_visible_bell;
+static const char *_rl_visible_bell;
 
 /* Non-zero means the terminal can auto-wrap lines. */
 int _rl_term_autowrap = -1;
@@ -141,33 +143,33 @@ static int term_has_meta;
 
 /* The sequences to write to turn on and off the meta key, if this
    terminal has one. */
-static char *_rl_term_mm;
-static char *_rl_term_mo;
+static const char *_rl_term_mm;
+static const char *_rl_term_mo;
 
 /* The key sequences output by the arrow keys, if this terminal has any. */
-static char *_rl_term_ku;
-static char *_rl_term_kd;
-static char *_rl_term_kr;
-static char *_rl_term_kl;
+static const char *_rl_term_ku;
+static const char *_rl_term_kd;
+static const char *_rl_term_kr;
+static const char *_rl_term_kl;
 
 /* How to initialize and reset the arrow keys, if this terminal has any. */
-static char *_rl_term_ks;
-static char *_rl_term_ke;
+static const char *_rl_term_ks;
+static const char *_rl_term_ke;
 
 /* The key sequences sent by the Home and End keys, if any. */
-static char *_rl_term_kh;
-static char *_rl_term_kH;
-static char *_rl_term_at7;	/* @7 */
+static const char *_rl_term_kh;
+static const char *_rl_term_kH;
+static const char *_rl_term_at7;	/* @7 */
 
 /* Delete key */
-static char *_rl_term_kD;
+static const char *_rl_term_kD;
 
 /* Insert key */
-static char *_rl_term_kI;
+static const char *_rl_term_kI;
 
 /* Cursor control */
-static char *_rl_term_vs;	/* very visible */
-static char *_rl_term_ve;	/* normal */
+static const char *_rl_term_vs;	/* very visible */
+static const char *_rl_term_ve;	/* normal */
 
 static void bind_termcap_arrow_keys PARAMS((Keymap));
 
@@ -362,7 +364,7 @@ rl_resize_terminal ()
 
 struct _tc_string {
      const char *tc_var;
-     char **tc_value;
+     const char **tc_value;
 };
 
 /* This should be kept sorted, just in case we decide to change the
@@ -409,7 +411,7 @@ get_term_capabilities (bp)
      char **bp;
 {
 #if !defined (__DJGPP__)	/* XXX - doesn't DJGPP have a termcap library? */
-  register int i;
+  register unsigned int i;
 
   for (i = 0; i < NUM_TC_STRINGS; i++)
     *(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
@@ -496,8 +498,9 @@ _rl_init_terminal_io (terminal_name)
          tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
          change that later... */
       PC = '\0';
-      BC = _rl_term_backspace = "\b";
-      UP = _rl_term_up;
+      _rl_term_backspace = _rl_term_backspace_default;
+      BC = (char*)_rl_term_backspace;
+      UP = (char*)_rl_term_up;
 
       return 0;
     }
@@ -507,8 +510,8 @@ _rl_init_terminal_io (terminal_name)
   /* Set up the variables that the termcap library expects the application
      to provide. */
   PC = _rl_term_pc ? *_rl_term_pc : 0;
-  BC = _rl_term_backspace;
-  UP = _rl_term_up;
+  BC = (char*)_rl_term_backspace;
+  UP = (char*)_rl_term_up;
 
   if (!_rl_term_cr)
     _rl_term_cr = "\r";
@@ -568,11 +571,11 @@ bind_termcap_arrow_keys (map)
   _rl_keymap = xkeymap;
 }
 
-char *
+const char *
 rl_get_termcap (cap)
      const char *cap;
 {
-  register int i;
+  register unsigned int i;
 
   if (tcap_initialized == 0)
     return ((char *)NULL);

=== modified file 'cmd-line-utils/readline/text.c'
--- a/cmd-line-utils/readline/text.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/text.c	2009-06-29 13:17:01 +0000
@@ -410,7 +410,7 @@ rl_backward (count, key)
 /* Move to the beginning of the line. */
 int
 rl_beg_of_line (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   rl_point = 0;
   return 0;
@@ -419,7 +419,7 @@ rl_beg_of_line (count, key)
 /* Move to the end of the line. */
 int
 rl_end_of_line (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   rl_point = rl_end;
   return 0;
@@ -527,7 +527,7 @@ rl_backward_word (count, key)
 /* Clear the current line.  Numeric argument to C-l does this. */
 int
 rl_refresh_line (ignore1, ignore2)
-     int ignore1, ignore2;
+     int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
 {
   int curr_line;
 
@@ -566,7 +566,7 @@ rl_clear_screen (count, key)
 
 int
 rl_arrow_keys (count, c)
-     int count, c;
+     int count, c __attribute__((unused));
 {
   int ch;
 
@@ -884,7 +884,7 @@ _rl_insert_next_callback (data)
   
 int
 rl_quoted_insert (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   /* Let's see...should the callback interface futz with signal handling? */
 #if defined (HANDLE_SIGNALS)
@@ -907,7 +907,7 @@ rl_quoted_insert (count, key)
 /* Insert a tab character. */
 int
 rl_tab_insert (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   return (_rl_insert_char (count, '\t'));
 }
@@ -917,7 +917,7 @@ rl_tab_insert (count, key)
    meaning in the future. */
 int
 rl_newline (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   rl_done = 1;
 
@@ -951,7 +951,7 @@ rl_newline (count, key)
    is special cased. */
 int
 rl_do_lowercase_version (ignore1, ignore2)
-     int ignore1, ignore2;
+     int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
 {
   return 0;
 }
@@ -1118,7 +1118,7 @@ rl_rubout_or_delete (count, key)
 /* Delete all spaces and tabs around point. */
 int
 rl_delete_horizontal_space (count, ignore)
-     int count, ignore;
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   int start = rl_point;
 
@@ -1163,9 +1163,9 @@ rl_delete_or_show_completions (count, ke
    A K*rn shell style function. */
 int
 rl_insert_comment (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
-  char *rl_comment_text;
+  const char *rl_comment_text;
   int rl_comment_len;
 
   rl_beg_of_line (1, key);
@@ -1202,7 +1202,7 @@ rl_insert_comment (count, key)
 /* Uppercase the word at point. */
 int
 rl_upcase_word (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   return (rl_change_case (count, UpCase));
 }
@@ -1210,7 +1210,7 @@ rl_upcase_word (count, key)
 /* Lowercase the word at point. */
 int
 rl_downcase_word (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   return (rl_change_case (count, DownCase));
 }
@@ -1218,7 +1218,7 @@ rl_downcase_word (count, key)
 /* Upcase the first letter, downcase the rest. */
 int
 rl_capitalize_word (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
  return (rl_change_case (count, CapCase));
 }
@@ -1381,7 +1381,7 @@ rl_transpose_words (count, key)
    then transpose the characters before point. */
 int
 rl_transpose_chars (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
 #if defined (HANDLE_MULTIBYTE)
   char *dummy;
@@ -1557,7 +1557,7 @@ _rl_char_search_callback (data)
 
 int
 rl_char_search (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
 #if defined (READLINE_CALLBACKS)
   if (RL_ISSTATE (RL_STATE_CALLBACK))
@@ -1575,7 +1575,7 @@ rl_char_search (count, key)
 
 int
 rl_backward_char_search (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
 #if defined (READLINE_CALLBACKS)
   if (RL_ISSTATE (RL_STATE_CALLBACK))
@@ -1612,7 +1612,7 @@ _rl_set_mark_at_pos (position)
 /* A bindable command to set the mark. */
 int
 rl_set_mark (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point));
 }
@@ -1620,7 +1620,7 @@ rl_set_mark (count, key)
 /* Exchange the position of mark and point. */
 int
 rl_exchange_point_and_mark (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_mark > rl_end)
     rl_mark = -1;

=== modified file 'cmd-line-utils/readline/tilde.c'
--- a/cmd-line-utils/readline/tilde.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/tilde.c	2009-06-29 13:17:01 +0000
@@ -196,7 +196,7 @@ tilde_expand (string)
   int result_size, result_index;
 
   result_index = result_size = 0;
-  if (result = strchr (string, '~'))
+  if ((result = strchr (string, '~')))
     result = (char *)xmalloc (result_size = (strlen (string) + 16));
   else
     result = (char *)xmalloc (result_size = (strlen (string) + 1));

=== modified file 'cmd-line-utils/readline/undo.c'
--- a/cmd-line-utils/readline/undo.c	2008-01-23 16:43:46 +0000
+++ b/cmd-line-utils/readline/undo.c	2009-06-29 14:00:47 +0000
@@ -231,7 +231,8 @@ rl_do_undo ()
 
 int
 _rl_fix_last_undo_of_type (type, start, end)
-     int type, start, end;
+     enum undo_code type;
+     int start, end;
 {
   UNDO_LIST *rl;
 
@@ -289,7 +290,7 @@ rl_modifying (start, end)
 /* Revert the current line to its previous state. */
 int
 rl_revert_line (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (!rl_undo_list)
     rl_ding ();
@@ -309,7 +310,7 @@ rl_revert_line (count, key)
 /* Do some undoing of things that were done. */
 int
 rl_undo_command (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   if (count < 0)
     return 0;	/* Nothing to do. */

=== modified file 'cmd-line-utils/readline/util.c'
--- a/cmd-line-utils/readline/util.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/util.c	2009-06-29 13:17:01 +0000
@@ -115,14 +115,14 @@ _rl_abort_internal ()
 
 int
 rl_abort (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   return (_rl_abort_internal ());
 }
 
 int
 rl_tty_status (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
 #if defined (TIOCSTAT)
   ioctl (1, TIOCSTAT, (char *)0);
@@ -172,7 +172,7 @@ rl_extend_line_buffer (len)
 /* A function for simple tilde expansion. */
 int
 rl_tilde_expand (ignore, key)
-     int ignore, key;
+     int ignore __attribute__((unused)), key __attribute__((unused));
 {
   register int start, end;
   char *homedir, *temp;

=== modified file 'cmd-line-utils/readline/vi_mode.c'
--- a/cmd-line-utils/readline/vi_mode.c	2008-01-03 13:26:41 +0000
+++ b/cmd-line-utils/readline/vi_mode.c	2009-06-29 13:17:01 +0000
@@ -131,7 +131,7 @@ static int _rl_vi_callback_char_search P
 void
 _rl_vi_initialize_line ()
 {
-  register int i;
+  register size_t i;
 
   for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
     vi_mark_chars[i] = -1;
@@ -190,7 +190,7 @@ _rl_vi_stuff_insert (count)
    puts you back into insert mode. */
 int
 rl_vi_redo (count, c)
-     int count, c;
+     int count, c __attribute__((unused));
 {
   int r;
 
@@ -238,7 +238,7 @@ rl_vi_undo (count, key)
 /* Yank the nth arg from the previous line into this line at point. */
 int
 rl_vi_yank_arg (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   /* Readline thinks that the first word on a line is the 0th, while vi
      thinks the first word on a line is the 1st.  Compensate. */
@@ -321,7 +321,7 @@ rl_vi_search (count, key)
 /* Completion, from vi's point of view. */
 int
 rl_vi_complete (ignore, key)
-     int ignore, key;
+     int ignore __attribute__((unused)), key;
 {
   if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
     {
@@ -348,7 +348,7 @@ rl_vi_complete (ignore, key)
 /* Tilde expansion for vi mode. */
 int
 rl_vi_tilde_expand (ignore, key)
-     int ignore, key;
+     int ignore __attribute__((unused)), key;
 {
   rl_tilde_expand (0, key);
   rl_vi_start_inserting (key, 1, rl_arg_sign);
@@ -419,7 +419,7 @@ rl_vi_end_word (count, key)
 /* Move forward a word the way that 'W' does. */
 int
 rl_vi_fWord (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   while (count-- && rl_point < (rl_end - 1))
     {
@@ -436,7 +436,7 @@ rl_vi_fWord (count, ignore)
 
 int
 rl_vi_bWord (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   while (count-- && rl_point > 0)
     {
@@ -460,7 +460,7 @@ rl_vi_bWord (count, ignore)
 
 int
 rl_vi_eWord (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   while (count-- && rl_point < (rl_end - 1))
     {
@@ -491,7 +491,7 @@ rl_vi_eWord (count, ignore)
 
 int
 rl_vi_fword (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   while (count-- && rl_point < (rl_end - 1))
     {
@@ -517,7 +517,7 @@ rl_vi_fword (count, ignore)
 
 int
 rl_vi_bword (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   while (count-- && rl_point > 0)
     {
@@ -556,7 +556,7 @@ rl_vi_bword (count, ignore)
 
 int
 rl_vi_eword (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   while (count-- && rl_point < rl_end - 1)
     {
@@ -581,7 +581,7 @@ rl_vi_eword (count, ignore)
 
 int
 rl_vi_insert_beg (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   rl_beg_of_line (1, key);
   rl_vi_insertion_mode (1, key);
@@ -610,7 +610,7 @@ _rl_vi_append_forward (key)
 
 int
 rl_vi_append_mode (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   _rl_vi_append_forward (key);
   rl_vi_start_inserting (key, 1, rl_arg_sign);
@@ -619,7 +619,7 @@ rl_vi_append_mode (count, key)
 
 int
 rl_vi_append_eol (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   rl_end_of_line (1, key);
   rl_vi_append_mode (1, key);
@@ -629,7 +629,7 @@ rl_vi_append_eol (count, key)
 /* What to do in the case of C-d. */
 int
 rl_vi_eof_maybe (count, c)
-     int count, c;
+     int count __attribute__((unused)), c __attribute__((unused));
 {
   return (rl_newline (1, '\n'));
 }
@@ -640,7 +640,7 @@ rl_vi_eof_maybe (count, c)
    switching keymaps. */
 int
 rl_vi_insertion_mode (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   _rl_keymap = vi_insertion_keymap;
   _rl_vi_last_key_before_insert = key;
@@ -703,7 +703,7 @@ _rl_vi_done_inserting ()
 
 int
 rl_vi_movement_mode (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   if (rl_point > 0)
     rl_backward_char (1, key);
@@ -783,7 +783,7 @@ _rl_vi_change_mbchar_case (count)
 
 int
 rl_vi_change_case (count, ignore)
-     int count, ignore;
+     int count, ignore __attribute__((unused));
 {
   int c, p;
 
@@ -1031,7 +1031,7 @@ rl_digit_loop1 ()
 
 int
 rl_vi_delete_to (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   int c;
 
@@ -1057,7 +1057,7 @@ rl_vi_delete_to (count, key)
 
 int
 rl_vi_change_to (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   int c, start_pos;
 
@@ -1110,7 +1110,7 @@ rl_vi_change_to (count, key)
 
 int
 rl_vi_yank_to (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   int c, save;
 
@@ -1202,7 +1202,7 @@ rl_vi_delete (count, key)
 
 int
 rl_vi_back_to_indent (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   rl_beg_of_line (1, key);
   while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
@@ -1212,7 +1212,7 @@ rl_vi_back_to_indent (count, key)
 
 int
 rl_vi_first_print (count, key)
-     int count, key;
+     int count __attribute__((unused)), key;
 {
   return (rl_vi_back_to_indent (1, key));
 }
@@ -1319,7 +1319,7 @@ rl_vi_char_search (count, key)
 /* Match brackets */
 int
 rl_vi_match (ignore, key)
-     int ignore, key;
+     int ignore __attribute__((unused)), key;
 {
   int count = 1, brack, pos, tmp, pre;
 
@@ -1426,7 +1426,7 @@ rl_vi_bracktype (c)
 static int
 _rl_vi_change_char (count, c, mb)
      int count, c;
-     char *mb;
+     char *mb __attribute__((unused));
 {
   int p;
 
@@ -1458,8 +1458,8 @@ _rl_vi_change_char (count, c, mb)
 
 static int
 _rl_vi_callback_getchar (mb, mlen)
-     char *mb;
-     int mlen;
+     char *mb __attribute__((unused));
+     int mlen __attribute__((unused));
 {
   int c;
 
@@ -1494,7 +1494,7 @@ _rl_vi_callback_change_char (data)
 
 int
 rl_vi_change_char (count, key)
-     int count, key;
+     int count, key __attribute__((unused));
 {
   int c;
   char mb[MB_LEN_MAX];
@@ -1582,7 +1582,7 @@ rl_vi_overstrike_delete (count, key)
 
 int
 rl_vi_replace (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   int i;
 
@@ -1663,7 +1663,7 @@ _rl_vi_set_mark ()
 #if defined (READLINE_CALLBACKS)
 static int
 _rl_vi_callback_set_mark (data)
-     _rl_callback_generic_arg *data;
+     _rl_callback_generic_arg *data __attribute__((unused));
 {
   _rl_callback_func = 0;
   _rl_want_redisplay = 1;
@@ -1674,7 +1674,7 @@ _rl_vi_callback_set_mark (data)
 
 int
 rl_vi_set_mark (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
 #if defined (READLINE_CALLBACKS)
   if (RL_ISSTATE (RL_STATE_CALLBACK))
@@ -1721,7 +1721,7 @@ _rl_vi_goto_mark ()
 #if defined (READLINE_CALLBACKS)
 static int
 _rl_vi_callback_goto_mark (data)
-     _rl_callback_generic_arg *data;
+     _rl_callback_generic_arg *data __attribute__((unused));
 {
   _rl_callback_func = 0;
   _rl_want_redisplay = 1;
@@ -1732,7 +1732,7 @@ _rl_vi_callback_goto_mark (data)
 
 int
 rl_vi_goto_mark (count, key)
-     int count, key;
+     int count __attribute__((unused)), key __attribute__((unused));
 {
 #if defined (READLINE_CALLBACKS)
   if (RL_ISSTATE (RL_STATE_CALLBACK))

=== modified file 'configure.in'
--- a/configure.in	2009-06-16 12:00:04 +0000
+++ b/configure.in	2009-07-08 13:11:16 +0000
@@ -603,10 +603,11 @@ AC_SUBST(NOINST_LDFLAGS)
 # Check if we are using Linux and a glibc compiled with static nss
 # (this is true on the MySQL build machines to avoid NSS problems)
 #
+AC_CHECK_TOOL([NM], [nm]) 
 
 if test "$TARGET_LINUX" = "true" -a "$static_nss" = ""
 then
-  tmp=`nm /usr/lib*/libc.a  | grep _nss_files_getaliasent_r`
+  tmp=`$NM ${other_libc_lib:-/usr/lib*}/libc.a | grep _nss_files_getaliasent_r1`
   if test -n "$tmp"
   then
      STATIC_NSS_FLAGS="-lc -lnss_files -lnss_dns -lresolv"
@@ -1624,7 +1625,7 @@ esac
 
 # Build optimized or debug version ?
 # First check for gcc and g++
-if test "$ac_cv_prog_gcc" = "yes"
+if test "$GCC" = "yes"
 then
   DEBUG_CFLAGS="-g"
   DEBUG_OPTIMIZE_CC="-O"
@@ -1632,9 +1633,16 @@ then
 else
   DEBUG_CFLAGS="-g"
   DEBUG_OPTIMIZE_CC=""
-  OPTIMIZE_CFLAGS="-O"
+  case $SYSTEM_TYPE in                               
+    *solaris*)
+      OPTIMIZE_CFLAGS="-O1"
+      ;;
+    *)
+      OPTIMIZE_CFLAGS="-O"
+      ;;
+  esac
 fi
-if test "$ac_cv_prog_cxx_g" = "yes"
+if test "$GXX" = "yes"
 then
   DEBUG_CXXFLAGS="-g"
   DEBUG_OPTIMIZE_CXX="-O"
@@ -1642,7 +1650,14 @@ then
 else
   DEBUG_CXXFLAGS="-g"
   DEBUG_OPTIMIZE_CXX=""
-  OPTIMIZE_CXXFLAGS="-O"
+  case $SYSTEM_TYPE in
+    *solaris*)
+      OPTIMIZE_CXXFLAGS="-O1"
+      ;;
+    *)
+      OPTIMIZE_CXXFLAGS="-O"
+      ;;
+  esac
 fi
 
 case $SYSTEM_TYPE in
@@ -2076,6 +2091,25 @@ case "$mysql_cv_sys_os" in
         # unsupported priority values are passed to pthread_setschedprio.
         # Since the only supported value is 1, treat it as inexistent.
     ;;
+ SunOS) # Bug#42599 error: `pthread_setschedprio' was not declared in this scope
+        # In some installations, the pthread.h header used by GCC does not
+        # declare the pthread_setscheprio prototype, but the function is
+        # implemented. Since the function is used in C++ code, ensure that
+        # the function prototype is present.
+     AC_MSG_CHECKING([whether pthread_setschedprio is declared])
+     AC_LANG_PUSH([C++])
+     AC_COMPILE_IFELSE([
+       AC_LANG_PROGRAM([#include <pthread.h>],
+                      [(void)(pthread_setschedprio);])],
+       [ac_cv_func_pthread_setschedprio=yes],
+       [ac_cv_func_pthread_setschedprio=no])
+     AC_LANG_POP([C++])
+     AC_MSG_RESULT([$ac_cv_func_pthread_setschedprio])
+     if test "$ac_cv_func_pthread_setschedprio" = yes; then
+       AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1,
+                 [Define to 1 if you have the `pthread_setschedprio' function.])
+     fi
+    ;;
  *) AC_CHECK_FUNCS(pthread_setschedprio)
     ;;
 esac

=== modified file 'extra/yassl/src/handshake.cpp'
--- a/extra/yassl/src/handshake.cpp	2009-05-15 12:57:51 +0000
+++ b/extra/yassl/src/handshake.cpp	2009-06-29 14:00:47 +0000
@@ -790,15 +790,17 @@ void processReply(SSL& ssl)
     if (ssl.GetError()) return;
 
     if (DoProcessReply(ssl))
+    {
         // didn't complete process
         if (!ssl.getSocket().IsNonBlocking()) {
             // keep trying now, blocking ok
             while (!ssl.GetError())
                 if (DoProcessReply(ssl) == 0) break;
-    }
+        }
         else
             // user will have try again later, non blocking
             ssl.SetError(YasslError(SSL_ERROR_WANT_READ));
+    }
 }
 
 
@@ -873,10 +875,12 @@ void sendServerKeyExchange(SSL& ssl, Buf
 void sendChangeCipher(SSL& ssl, BufferOutput buffer)
 {
     if (ssl.getSecurity().get_parms().entity_ == server_end)
+    {
         if (ssl.getSecurity().get_resuming())
             ssl.verifyState(clientKeyExchangeComplete);
         else
             ssl.verifyState(clientFinishedComplete);
+    }
     if (ssl.GetError()) return;
 
     ChangeCipherSpec ccs;

=== modified file 'extra/yassl/src/yassl_imp.cpp'
--- a/extra/yassl/src/yassl_imp.cpp	2009-05-15 12:57:51 +0000
+++ b/extra/yassl/src/yassl_imp.cpp	2009-06-29 14:00:47 +0000
@@ -1305,6 +1305,7 @@ void ServerHello::Process(input_buffer&,
         ssl.useSecurity().use_connection().sessionID_Set_ = false;
 
     if (ssl.getSecurity().get_resuming())
+    {
         if (memcmp(session_id_, ssl.getSecurity().get_resume().GetID(),
                    ID_LEN) == 0) {
             ssl.set_masterSecret(ssl.getSecurity().get_resume().GetSecret());
@@ -1319,6 +1320,7 @@ void ServerHello::Process(input_buffer&,
             ssl.useSecurity().set_resuming(false);
             ssl.useLog().Trace("server denied resumption");
         }
+    }
 
     if (ssl.CompressionOn() && !compression_method_)
         ssl.UnSetCompression(); // server isn't supporting yaSSL zlib request

=== modified file 'extra/yassl/taocrypt/include/modes.hpp'
--- a/extra/yassl/taocrypt/include/modes.hpp	2007-03-23 12:43:09 +0000
+++ b/extra/yassl/taocrypt/include/modes.hpp	2009-06-29 14:00:47 +0000
@@ -96,10 +96,12 @@ inline void Mode_BASE::Process(byte* out
     if (mode_ == ECB)
         ECB_Process(out, in, sz);
     else if (mode_ == CBC)
+    {
         if (dir_ == ENCRYPTION)
             CBC_Encrypt(out, in, sz);
         else
             CBC_Decrypt(out, in, sz);
+    }
 }
 
 

=== modified file 'extra/yassl/taocrypt/src/asn.cpp'
--- a/extra/yassl/taocrypt/src/asn.cpp	2009-02-13 16:41:47 +0000
+++ b/extra/yassl/taocrypt/src/asn.cpp	2009-06-29 14:00:47 +0000
@@ -781,10 +781,12 @@ void CertDecoder::GetDate(DateType dt)
     source_.advance(length);
 
     if (!ValidateDate(date, b, dt) && verify_)
+    {
         if (dt == BEFORE)
             source_.SetError(BEFORE_DATE_E);
         else
             source_.SetError(AFTER_DATE_E);
+    }
 
     // save for later use
     if (dt == BEFORE) {
@@ -1062,6 +1064,7 @@ word32 DecodeDSA_Signature(byte* decoded
     }
     word32 rLen = GetLength(source);
     if (rLen != 20)
+    {
         if (rLen == 21) {       // zero at front, eat
             source.next();
             --rLen;
@@ -1074,6 +1077,7 @@ word32 DecodeDSA_Signature(byte* decoded
             source.SetError(DSA_SZ_E);
             return 0;
         }
+    }
     memcpy(decoded, source.get_buffer() + source.get_index(), rLen);
     source.advance(rLen);
 
@@ -1084,6 +1088,7 @@ word32 DecodeDSA_Signature(byte* decoded
     }
     word32 sLen = GetLength(source);
     if (sLen != 20)
+    {
         if (sLen == 21) {
             source.next();          // zero at front, eat
             --sLen;
@@ -1096,6 +1101,7 @@ word32 DecodeDSA_Signature(byte* decoded
             source.SetError(DSA_SZ_E);
             return 0;
         }
+    }
     memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen);
     source.advance(sLen);
 

=== modified file 'include/hash.h'
--- a/include/hash.h	2008-11-10 20:21:49 +0000
+++ b/include/hash.h	2009-06-19 12:28:46 +0000
@@ -106,7 +106,7 @@ void my_hash_replace(HASH *hash, HASH_SE
 my_bool my_hash_check(HASH *hash); /* Only in debug library */
 
 #define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
-#define my_hash_inited(H) ((H)->array.buffer != 0)
+#define my_hash_inited(H) ((H)->blength != 0)
 #define my_hash_init_opt(A,B,C,D,E,F,G,H) \
           (!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
 

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2009-02-24 11:53:34 +0000
+++ b/mysql-test/collections/default.experimental	2009-07-08 07:31:49 +0000
@@ -1 +1,13 @@
 funcs_1.charset_collation_1              # depends on compile-time decisions
+binlog.binlog_tmp_table                  # Bug#45578: Test binlog_tmp_table fails ramdonly on PB2: Unknown table 't2'
+main.ctype_gbk_binlog                    # Bug#46010: main.ctype_gbk_binlog fails sporadically : Table 't2' already exists
+rpl.rpl_row_create_table                 # Bug#45576: rpl_row_create_table fails on PB2
+rpl.rpl_extraColmaster_myisam            # Bug#46013: rpl_extraColmaster_myisam fails on pb2
+rpl.rpl_stm_reset_slave                  # Bug#46014: rpl_stm_reset_slave crashes the server sporadically in pb2
+rpl.rpl_extraCol_myisam                  # Bug#40796
+rpl.rpl_extraColmaster_innodb            # Bug#40796
+rpl.rpl_extraCol_innodb                  # Bug#40796
+rpl_ndb.rpl_ndb_log                      # Bug#38998
+rpl.rpl_innodb_bug28430                  # Bug#46029
+rpl.rpl_row_basic_3innodb                # Bug#45243
+rpl.rpl_truncate_3innodb                 # Bug#46030

=== modified file 'mysql-test/extra/rpl_tests/rpl_reset_slave.test'
--- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test	2008-01-14 07:38:02 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test	2009-06-26 11:05:56 +0000
@@ -41,3 +41,57 @@ reset slave;
 start slave;
 sync_with_master;
 show status like 'slave_open_temp_tables';
+
+#
+#Bug#34654  	RESET SLAVE does not clear LAST_IO_Err* 
+#
+
+# clearing the status
+stop slave;
+reset slave;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+echo *** errno must be zero: $last_io_errno ***;
+
+#
+# verifying start slave resets Last_IO_Error and Last_IO_Errno.
+#
+
+change master to master_user='impossible_user_name';
+start slave;
+source include/wait_for_slave_io_error.inc;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+--disable_query_log
+eval SELECT $last_io_errno > 0 as ONE;
+--enable_query_log
+
+source include/stop_slave.inc;
+change master to master_user='root';
+source include/start_slave.inc;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1);
+--echo *** last errno must be  zero: $last_io_errno ***
+--echo *** last error must be blank: $last_io_error ***
+
+#
+# verifying reset slave resets Last_{IO,SQL}_Err{or,no}
+#
+
+source include/stop_slave.inc;
+change master to master_user='impossible_user_name';
+start slave;
+source include/wait_for_slave_io_error.inc;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+--disable_query_log
+eval SELECT $last_io_errno > 0 as ONE;
+--enable_query_log
+
+source include/stop_slave.inc;
+reset slave;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1);
+let $last_sql_errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
+let $last_sql_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
+--echo *** io  last errno must be  zero: $last_io_errno  ***
+--echo *** io  last error must be blank: $last_io_error  ***
+--echo *** sql last errno must be  zero: $last_sql_errno ***
+--echo *** sql last error must be blank: $last_sql_error ***

=== modified file 'mysql-test/include/commit.inc'
--- a/mysql-test/include/commit.inc	2009-01-23 12:22:05 +0000
+++ b/mysql-test/include/commit.inc	2009-06-19 11:27:24 +0000
@@ -669,13 +669,9 @@ call p_verify_status_increment(1, 0, 1, 
 insert t1 set a=3;
 call p_verify_status_increment(2, 2, 2, 2);
 savepoint a;
-call p_verify_status_increment(0, 0, 0, 0);
+call p_verify_status_increment(1, 0, 1, 0);
 insert t1 set a=4;
---echo # Binlog does not register itself this time for other than the 1st
---echo # statement of the transaction with MIXED/STATEMENT binlog_format.
---echo # It needs registering with the ROW format. Therefore 1,0,2,2 are 
---echo # the correct arguments to this test after bug#40221 fixed.
-call p_verify_status_increment(1, 0, 2, 2);
+call p_verify_status_increment(2, 2, 2, 2);
 release savepoint a;
 rollback;
 call p_verify_status_increment(0, 0, 0, 0);

=== added file 'mysql-test/include/wait_for_slave_io_error.inc'
--- a/mysql-test/include/wait_for_slave_io_error.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/wait_for_slave_io_error.inc	2009-06-26 11:05:56 +0000
@@ -0,0 +1,23 @@
+# ==== Purpose ====
+#
+# Waits until the IO thread of the current connection has got an
+# error, or until a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_io_error.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
+
+let $old_slave_param_comparison= $slave_param_comparison;
+
+let $slave_param= Last_IO_Errno;
+let $slave_param_comparison= !=;
+let $slave_param_value= 0;
+let $slave_error_message= Failed while waiting for slave to produce an error in its sql thread;
+source include/wait_for_slave_param.inc;
+let $slave_error_message= ;
+
+let $slave_param_comparison= $old_slave_param_comparison;

=== modified file 'mysql-test/r/commit_1innodb.result'
--- a/mysql-test/r/commit_1innodb.result	2009-02-10 14:44:58 +0000
+++ b/mysql-test/r/commit_1innodb.result	2009-06-19 11:27:24 +0000
@@ -766,15 +766,11 @@ call p_verify_status_increment(2, 2, 2, 
 SUCCESS
 
 savepoint a;
-call p_verify_status_increment(0, 0, 0, 0);
+call p_verify_status_increment(1, 0, 1, 0);
 SUCCESS
 
 insert t1 set a=4;
-# Binlog does not register itself this time for other than the 1st
-# statement of the transaction with MIXED/STATEMENT binlog_format.
-# It needs registering with the ROW format. Therefore 1,0,2,2 are 
-# the correct arguments to this test after bug#40221 fixed.
-call p_verify_status_increment(1, 0, 2, 2);
+call p_verify_status_increment(2, 2, 2, 2);
 SUCCESS
 
 release savepoint a;

=== modified file 'mysql-test/r/ctype_cp932_binlog_stm.result'
--- a/mysql-test/r/ctype_cp932_binlog_stm.result	2009-05-05 06:55:22 +0000
+++ b/mysql-test/r/ctype_cp932_binlog_stm.result	2009-06-25 08:44:50 +0000
@@ -9,7 +9,7 @@ EXECUTE stmt1 USING @var1;
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1(f1 blob)
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES('�\0')
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES(0x8300)
 SELECT HEX(f1) FROM t1;
 HEX(f1)
 8300
@@ -29,22 +29,22 @@ HEX(s1)	HEX(s2)	d
 466F6F2773206120426172	ED40ED41ED42	47.93
 DROP PROCEDURE bug18293|
 DROP TABLE t4|
-SHOW BINLOG EVENTS FROM 369|
+SHOW BINLOG EVENTS FROM 370|
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	369	Query	1	535	use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
+master-bin.000001	370	Query	1	536	use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
 s2 CHAR(50) CHARACTER SET cp932,
 d DECIMAL(10,2))
-master-bin.000001	535	Query	1	784	use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug18293`(IN ins1 CHAR(50),
+master-bin.000001	536	Query	1	785	use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug18293`(IN ins1 CHAR(50),
 IN ins2 CHAR(50) CHARACTER SET cp932,
 IN ind DECIMAL(10,2))
 BEGIN
 INSERT INTO t4 VALUES (ins1, ins2, ind);
 END
-master-bin.000001	784	Query	1	1048	use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172 COLLATE 'latin1_swedish_ci'),  NAME_CONST('ins2',_cp932 0xED40ED41ED42 COLLATE 'cp932_japanese_ci'),  NAME_CONST('ind',47.93))
-master-bin.000001	1048	Query	1	1137	use `test`; DROP PROCEDURE bug18293
-master-bin.000001	1137	Query	1	1216	use `test`; DROP TABLE t4
+master-bin.000001	785	Query	1	1049	use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172 COLLATE 'latin1_swedish_ci'),  NAME_CONST('ins2',_cp932 0xED40ED41ED42 COLLATE 'cp932_japanese_ci'),  NAME_CONST('ind',47.93))
+master-bin.000001	1049	Query	1	1138	use `test`; DROP PROCEDURE bug18293
+master-bin.000001	1138	Query	1	1217	use `test`; DROP TABLE t4
 End of 5.0 tests
-SHOW BINLOG EVENTS FROM 364;
+SHOW BINLOG EVENTS FROM 365;
 ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
 Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
 CREATE TABLE t1 (a varchar(16)) character set cp932;

=== added file 'mysql-test/r/ctype_gbk_binlog.result'
--- a/mysql-test/r/ctype_gbk_binlog.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/ctype_gbk_binlog.result	2009-07-07 14:18:44 +0000
@@ -0,0 +1,26 @@
+SET NAMES gbk;
+CREATE TABLE t1 (
+f1 BLOB
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+CREATE PROCEDURE p1(IN val BLOB)
+BEGIN
+SET @tval = val;
+SET @sql_cmd = CONCAT_WS(' ', 'insert into t1(f1) values(?)');
+PREPARE stmt FROM @sql_cmd;
+EXECUTE stmt USING @tval;
+DEALLOCATE PREPARE stmt;
+END|
+SET @`tcontent`:=_binary 0x50434B000900000000000000E9000000 COLLATE `binary`/*!*/;
+CALL p1(@`tcontent`);
+FLUSH LOGS;
+DROP PROCEDURE p1;
+RENAME TABLE t1 to t2;
+SELECT hex(f1) FROM t2;
+hex(f1)
+50434B000900000000000000E9000000
+SELECT hex(f1) FROM t1;
+hex(f1)
+50434B000900000000000000E9000000
+DROP PROCEDURE p1;
+DROP TABLE t1;
+DROP TABLE t2;

=== modified file 'mysql-test/r/func_set.result'
--- a/mysql-test/r/func_set.result	2009-04-23 07:50:34 +0000
+++ b/mysql-test/r/func_set.result	2009-06-16 14:36:15 +0000
@@ -146,3 +146,16 @@ NULL
 0
 0
 drop table t1;
+CREATE TABLE t1( a SET('a', 'b', 'c') );
+CREATE TABLE t2( a SET('a', 'b', 'c') );
+INSERT INTO t1 VALUES ('d');
+Warnings:
+Warning	1265	Data truncated for column 'a' at row 1
+INSERT INTO t2 VALUES ('');
+SELECT CONVERT( a USING latin1 ) FROM t1;
+CONVERT( a USING latin1 )
+
+SELECT CONVERT( a USING latin1 ) FROM t2;
+CONVERT( a USING latin1 )
+
+DROP TABLE t1, t2;

=== modified file 'mysql-test/r/gis.result'
--- a/mysql-test/r/gis.result	2009-04-29 02:59:10 +0000
+++ b/mysql-test/r/gis.result	2009-06-17 14:58:33 +0000
@@ -984,4 +984,52 @@ f4	geometry	YES		NULL	
 f5	datetime	YES		NULL	
 drop view v1;
 drop table t1;
+SELECT MultiPoint(12345,'');
+MultiPoint(12345,'')
+NULL
+SELECT MultiPoint(123451,'');
+MultiPoint(123451,'')
+NULL
+SELECT MultiPoint(1234512,'');
+MultiPoint(1234512,'')
+NULL
+SELECT MultiPoint(12345123,'');
+MultiPoint(12345123,'')
+NULL
+SELECT MultiLineString(12345,'');
+MultiLineString(12345,'')
+NULL
+SELECT MultiLineString(123451,'');
+MultiLineString(123451,'')
+NULL
+SELECT MultiLineString(1234512,'');
+MultiLineString(1234512,'')
+NULL
+SELECT MultiLineString(12345123,'');
+MultiLineString(12345123,'')
+NULL
+SELECT LineString(12345,'');
+LineString(12345,'')
+NULL
+SELECT LineString(123451,'');
+LineString(123451,'')
+NULL
+SELECT LineString(1234512,'');
+LineString(1234512,'')
+NULL
+SELECT LineString(12345123,'');
+LineString(12345123,'')
+NULL
+SELECT Polygon(12345,'');
+Polygon(12345,'')
+NULL
+SELECT Polygon(123451,'');
+Polygon(123451,'')
+NULL
+SELECT Polygon(1234512,'');
+Polygon(1234512,'')
+NULL
+SELECT Polygon(12345123,'');
+Polygon(12345123,'')
+NULL
 End of 5.1 tests

=== added file 'mysql-test/r/innodb_bug40565.result'
--- a/mysql-test/r/innodb_bug40565.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug40565.result	2009-06-11 13:12:25 +0000
@@ -0,0 +1,9 @@
+create table bug40565(value decimal(4,2)) engine=innodb;
+insert into bug40565 values (1), (null);
+update bug40565 set value=NULL;
+affected rows: 1
+info: Rows matched: 2  Changed: 1  Warnings: 0
+update bug40565 set value=NULL;
+affected rows: 0
+info: Rows matched: 2  Changed: 0  Warnings: 0
+drop table bug40565;

=== added file 'mysql-test/r/innodb_bug45357.result'
--- a/mysql-test/r/innodb_bug45357.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_bug45357.result	2009-06-22 11:28:00 +0000
@@ -0,0 +1,7 @@
+set session transaction isolation level read committed;
+create table bug45357(a int, b int,key(b))engine=innodb;
+insert into bug45357 values (25170,6122);
+update bug45357 set a=1 where b=30131;
+delete from bug45357 where b < 20996;
+delete from bug45357 where b < 7001;
+drop table bug45357;

=== added file 'mysql-test/r/mysql-bug45236.result'
--- a/mysql-test/r/mysql-bug45236.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/mysql-bug45236.result	2009-06-10 07:24:47 +0000
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS t1;
+SET @old_max_allowed_packet= @@global.max_allowed_packet;
+SET @@global.max_allowed_packet = 1024 * 1024 + 1024;
+CREATE TABLE t1(data LONGBLOB);
+INSERT INTO t1 SELECT CONCAT(REPEAT('1', 1024*1024 - 27), 
+"\'\r dummydb dummyhost");
+DROP TABLE t1;
+SET @@global.max_allowed_packet = @old_max_allowed_packet;

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2009-06-16 09:59:57 +0000
+++ b/mysql-test/r/partition.result	2009-07-02 14:42:00 +0000
@@ -1982,5 +1982,14 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	range	bc	bc	10	NULL	7	Using where; Using index for group-by
 DROP TABLE t1;
+#
+# Bug #45807: crash accessing partitioned table and sql_mode 
+#   contains ONLY_FULL_GROUP_BY
+#
+SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY';
+CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM 
+PARTITION BY HASH(id) PARTITIONS 2;
+DROP TABLE t1;
+SET SESSION SQL_MODE=DEFAULT;
 End of 5.1 tests
 SET @@global.general_log= @old_general_log;

=== modified file 'mysql-test/r/query_cache_debug.result'
--- a/mysql-test/r/query_cache_debug.result	2009-06-16 08:34:47 +0000
+++ b/mysql-test/r/query_cache_debug.result	2009-06-17 14:28:11 +0000
@@ -141,9 +141,9 @@ KILL QUERY @flush_thread_id;
 ** and finally release the mutex. The threads will continue to wait
 ** until a broadcast signal reaches them causing both threads to 
 ** come alive and check the condition.
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' LIMIT 1 INTO @thread_id;
+SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id;
 KILL QUERY @thread_id;
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' LIMIT 1 INTO @thread_id;
+SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id;
 KILL QUERY @thread_id;
 **
 ** Finally signal the DELETE statement on THD1 one last time.

=== modified file 'mysql-test/r/select.result'
--- a/mysql-test/r/select.result	2009-04-28 00:27:38 +0000
+++ b/mysql-test/r/select.result	2009-06-26 19:57:42 +0000
@@ -4457,4 +4457,83 @@ id	select_type	table	type	possible_keys	
 Warnings:
 Note	1003	select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1
 DROP TABLE t1;
+#
+# Bug#45266: Uninitialized variable lead to an empty result.
+#
+drop table if exists A,AA,B,BB;
+CREATE TABLE `A` (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`date_key` date NOT NULL,
+`date_nokey` date NOT NULL,
+`datetime_key` datetime NOT NULL,
+`int_nokey` int(11) NOT NULL,
+`time_key` time NOT NULL,
+`time_nokey` time NOT NULL,
+PRIMARY KEY (`pk`),
+KEY `date_key` (`date_key`),
+KEY `time_key` (`time_key`),
+KEY `datetime_key` (`datetime_key`)
+);
+CREATE TABLE `AA` (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`int_nokey` int(11) NOT NULL,
+`time_key` time NOT NULL,
+KEY `time_key` (`time_key`),
+PRIMARY KEY (`pk`)
+);
+CREATE TABLE `B` (
+`date_nokey` date NOT NULL,
+`date_key` date NOT NULL,
+`time_key` time NOT NULL,
+`datetime_nokey` datetime NOT NULL,
+`varchar_key` varchar(1) NOT NULL,
+KEY `date_key` (`date_key`),
+KEY `time_key` (`time_key`),
+KEY `varchar_key` (`varchar_key`)
+);
+INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x');
+CREATE TABLE `BB` (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`int_nokey` int(11) NOT NULL,
+`date_key` date NOT NULL,
+`varchar_nokey` varchar(1) NOT NULL,
+`date_nokey` date NOT NULL,
+PRIMARY KEY (`pk`),
+KEY `date_key` (`date_key`)
+);
+INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18');
+SELECT table1 . `pk` AS field1 
+FROM 
+(BB AS table1 INNER JOIN 
+(AA AS table2 STRAIGHT_JOIN A AS table3 
+ON ( table3 . `date_key` = table2 . `pk` ))
+ON ( table3 . `datetime_key` = table2 . `int_nokey` ))
+WHERE  ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`)
+GROUP BY field1 ;
+field1
+SELECT table3 .`date_key` field1
+FROM
+B table1 LEFT JOIN B table3 JOIN
+(BB table6 JOIN A table7 ON table6 .`varchar_nokey`)
+ON table6 .`int_nokey` ON table6 .`date_key`
+  WHERE  NOT ( table1 .`varchar_key`  AND table7 .`pk`) GROUP  BY field1;
+field1
+NULL
+SELECT table4 . `time_nokey` AS field1 FROM 
+(AA AS table1 CROSS JOIN 
+(AA AS table2 STRAIGHT_JOIN 
+(B AS table3 STRAIGHT_JOIN A AS table4 
+ON ( table4 . `date_key` = table3 . `time_key` ))
+ON ( table4 . `pk` = table3 . `date_nokey` ))
+ON ( table4 . `time_key` = table3 . `datetime_nokey` ))
+WHERE  ( table4 . `time_key` < table1 . `time_key` AND
+table1 . `int_nokey` != 'f')
+GROUP BY field1  ORDER BY field1 , field1;
+field1
+SELECT table1 .`time_key` field2  FROM B table1  LEFT JOIN  BB JOIN A table5 ON table5 .`date_nokey`  ON table5 .`int_nokey` GROUP  BY field2;
+field2
+00:05:48
+15:13:38
+drop table A,AA,B,BB;
+#end of test for bug#45266
 End of 5.1 tests

=== modified file 'mysql-test/r/sp-fib.result'
--- a/mysql-test/r/sp-fib.result	2009-06-04 11:53:15 +0000
+++ b/mysql-test/r/sp-fib.result	2009-07-03 08:23:16 +0000
@@ -10,24 +10,17 @@ declare c cursor for select f from t3 or
 open c;
 fetch c into y;
 fetch c into x;
-close c;
 insert into t3 values (x+y);
 call fib(n-1);
+## Close the cursor AFTER the recursion to ensure that the stack
+## frame is somewhat intact.
+close c;
 end;
 end if;
 end|
 set @@max_sp_recursion_depth= 20|
 insert into t3 values (0), (1)|
-call fib(3)|
-select * from t3 order by f asc|
-f
-0
-1
-1
-2
-truncate table t3|
-insert into t3 values (0), (1)|
-call fib(10)|
+call fib(4)|
 select * from t3 order by f asc|
 f
 0
@@ -35,12 +28,6 @@ f
 1
 2
 3
-5
-8
-13
-21
-34
-55
 drop table t3|
 drop procedure fib|
 set @@max_sp_recursion_depth= 0|

=== modified file 'mysql-test/r/trigger.result'
--- a/mysql-test/r/trigger.result	2009-03-27 12:55:14 +0000
+++ b/mysql-test/r/trigger.result	2009-06-22 12:51:33 +0000
@@ -2073,4 +2073,18 @@ select @a, @b;
 drop trigger trg1;
 drop trigger trg2;
 drop table t1, t2;
+CREATE TABLE t1 ( a INT, b INT );
+CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT );
+INSERT INTO t1 (a) VALUES (1);
+CREATE TRIGGER tr1
+BEFORE INSERT ON t2
+FOR EACH ROW 
+BEGIN 
+UPDATE a_nonextisting_table SET a = 1;
+END//
+CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1;
+ERROR 42S02: Table 'test.a_nonextisting_table' doesn't exist
+SELECT * FROM t2;
+a	b
+DROP TABLE t1, t2;
 End of 5.1 tests.

=== modified file 'mysql-test/r/trigger_notembedded.result'
--- a/mysql-test/r/trigger_notembedded.result	2008-03-22 08:01:31 +0000
+++ b/mysql-test/r/trigger_notembedded.result	2009-06-25 10:52:50 +0000
@@ -462,4 +462,18 @@ unlock tables;
 select * from t1;
 i
 drop table t1;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a char(30)) ENGINE=MEMORY;
+CREATE TRIGGER db1.trg AFTER INSERT ON db1.t1 FOR EACH ROW
+INSERT INTO db1.t1 VALUES('Some very sensitive data goes here');
+CREATE USER 'no_rights'@'localhost';
+REVOKE ALL ON *.* FROM 'no_rights'@'localhost';
+FLUSH PRIVILEGES;
+SELECT trigger_name FROM INFORMATION_SCHEMA.TRIGGERS
+WHERE trigger_schema = 'db1';
+trigger_name
+SHOW CREATE TRIGGER db1.trg;
+ERROR 42000: Access denied; you need the TRIGGER privilege for this operation
+DROP USER 'no_rights'@'localhost';
+DROP DATABASE db1;
 End of 5.1 tests.

=== modified file 'mysql-test/r/type_newdecimal.result'
--- a/mysql-test/r/type_newdecimal.result	2008-11-18 09:52:03 +0000
+++ b/mysql-test/r/type_newdecimal.result	2009-07-03 10:36:04 +0000
@@ -1524,10 +1524,10 @@ Warnings:
 Warning	1264	Out of range value for column 'f1' at row 1
 DESC t1;
 Field	Type	Null	Key	Default	Extra
-f1	decimal(59,30)	NO		0.000000000000000000000000000000	
+f1	decimal(65,30)	NO		0.000000000000000000000000000000	
 SELECT f1 FROM t1;
 f1
-99999999999999999999999999999.999999999999999999999999999999
+99999999999999999999999999999999999.999999999999999999999999999999
 DROP TABLE t1;
 select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 *
 1.01500000 * 1.01500000 * 0.99500000);
@@ -1577,3 +1577,56 @@ Error	1264	Out of range value for column
 select cast(98.6 as decimal(2,0));
 cast(98.6 as decimal(2,0))
 99
+#
+# Bug #45262: Bad effects with CREATE TABLE and DECIMAL
+#
+CREATE TABLE t1 SELECT .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note	1265	Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field	Type	Null	Key	Default	Extra
+my_col	decimal(30,30)	NO		0.000000000000000000000000000000	
+SELECT my_col FROM t1;
+my_col
+0.123456789123456789123456789123
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1 + .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note	1265	Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field	Type	Null	Key	Default	Extra
+my_col	decimal(65,30)	NO		0.000000000000000000000000000000	
+SELECT my_col FROM t1;
+my_col
+1.123456789123456789123456789123
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1 * .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note	1265	Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field	Type	Null	Key	Default	Extra
+my_col	decimal(65,30)	NO		0.000000000000000000000000000000	
+SELECT my_col FROM t1;
+my_col
+0.123456789123456789123456789123
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note	1265	Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field	Type	Null	Key	Default	Extra
+my_col	decimal(65,4)	YES		NULL	
+SELECT my_col FROM t1;
+my_col
+8.1000
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note	1265	Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field	Type	Null	Key	Default	Extra
+my_col	decimal(65,30)	YES		NULL	
+SELECT my_col FROM t1;
+my_col
+0.012345687012345687012345687012
+DROP TABLE t1;

=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2009-05-19 04:25:36 +0000
+++ b/mysql-test/r/view.result	2009-07-03 08:39:22 +0000
@@ -3718,6 +3718,117 @@ DROP TABLE t1;
 
 # -- End of test case for Bug#40825
 
+# 
+# Bug #45806 crash when replacing into a view with a join!
+# 
+CREATE TABLE t1(a INT UNIQUE);
+CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a;
+INSERT INTO t1 VALUES (1), (2);
+REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v1;
+a
+1
+2
+1
+2
+REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v1;
+a
+1
+2
+3
+1
+2
+3
+1
+2
+3
+DELETE FROM t1 WHERE a=3;
+INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v1`.`a`= 1;
+SELECT * FROM v1;
+a
+1
+2
+1
+2
+CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a;
+REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v2;
+a
+1
+2
+1
+2
+1
+2
+1
+2
+REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v2;
+a
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v2`.`a`= 1;
+SELECT * FROM v2;
+a
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+DROP VIEW v1;
+DROP VIEW v2;
+DROP TABLE t1;
+# -- End of test case for Bug#45806
 # -----------------------------------------------------------------
 # -- End of 5.0 tests.
 # -----------------------------------------------------------------

=== modified file 'mysql-test/r/xa.result'
--- a/mysql-test/r/xa.result	2009-06-05 22:16:54 +0000
+++ b/mysql-test/r/xa.result	2009-06-25 15:25:23 +0000
@@ -81,3 +81,11 @@ xa rollback 'a';
 xa start 'a';
 xa end 'a';
 xa rollback 'a';
+xa start 'a';
+xa end 'a';
+xa prepare 'a';
+xa commit 'a';
+xa start 'a';
+xa end 'a';
+xa prepare 'a';
+xa commit 'a';

=== added file 'mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result'
--- a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result	2009-06-07 22:28:08 +0000
@@ -0,0 +1,43 @@
+RESET MASTER;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+CREATE TABLE t3 (txt TEXT);
+CREATE TABLE t4 (a int) ENGINE= InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+INSERT INTO t1 VALUES (3);
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3;
+INSERT INTO t1 VALUES (4);
+CREATE DATABASE b42941;
+use b42941;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+CREATE TABLE t3 (txt TEXT);
+CREATE TABLE t4 (a int) ENGINE= InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+INSERT INTO t1 VALUES (3);
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3;
+INSERT INTO t1 VALUES (4);
+INSERT INTO test.t1 VALUES (5);
+FLUSH LOGS;
+UPDATE test.t1 t11, b42941.t1 t12 SET t11.id=10, t12.id=100;
+BEGIN;
+INSERT INTO test.t4 VALUES (1);
+INSERT INTO b42941.t4 VALUES (1);
+UPDATE test.t4 tn4, b42941.t4 tt4 SET tn4.a= 10, tt4.a= 100;
+COMMIT;
+FLUSH LOGS;
+SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1');
+SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2');
+SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1');
+SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2');
+SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1');
+SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2');
+DROP DATABASE b42941;
+use test;
+DROP TABLE t1, t2, t3, t4;

=== added file 'mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result	2009-06-27 13:18:47 +0000
@@ -0,0 +1,30 @@
+### NOT filtered database => assertion: warnings ARE shown
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+Warnings:
+Note	1592	Statement may not be safe to log in statement format.
+DROP TABLE t1;
+### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
+SET SQL_LOG_BIN= 0;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+SET SQL_LOG_BIN= 1;
+### FILTERED database => assertion: warnings ARE NOT shown
+CREATE DATABASE b42851;
+USE b42851;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+DROP DATABASE b42851;

=== added file 'mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test'
--- a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test	2009-06-07 22:28:08 +0000
@@ -0,0 +1,143 @@
+# BUG#42941: --database parameter to mysqlbinlog fails with RBR
+#
+# WHAT
+# ====
+#
+#  This test aims at checking whether a rows log event is printed or
+#  not when --database parameter is used to filter events from one
+#  given database.
+#
+# HOW
+# ===
+#
+#  The test is implemented as follows: 
+#
+#    i) Some operations are done in two different databases:
+#       'test' and 'b42941';
+#   ii) mysqlbinlog is used to dump the contents of the binlog file
+#       filtering only events from 'b42941'. The result of the dump is
+#       stored in a temporary file. (This is done with and without
+#       --verbose/hexdump flag);
+#  iii) The contents of the dump are loaded into a session variable;
+#   iv) The variable contents are searched for 'test' and 'b42941';
+#    v) Should 'test' be found, an ERROR is reported. Should 'b42941' be
+#       absent, an ERROR is reported.
+
+-- source include/have_log_bin.inc
+-- source include/have_binlog_format_row.inc
+-- source include/have_innodb.inc
+
+RESET MASTER;
+-- let $MYSQLD_DATADIR= `select @@datadir`
+
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+CREATE TABLE t3 (txt TEXT);
+CREATE TABLE t4 (a int) ENGINE= InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+INSERT INTO t1 VALUES (3);
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3
+INSERT INTO t1 VALUES (4);
+
+CREATE DATABASE b42941;
+use b42941;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+CREATE TABLE t3 (txt TEXT);
+CREATE TABLE t4 (a int) ENGINE= InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+INSERT INTO t1 VALUES (3);
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3
+INSERT INTO t1 VALUES (4);
+
+INSERT INTO test.t1 VALUES (5);
+
+FLUSH LOGS;
+
+UPDATE test.t1 t11, b42941.t1 t12 SET t11.id=10, t12.id=100;
+
+BEGIN;
+INSERT INTO test.t4 VALUES (1);
+INSERT INTO b42941.t4 VALUES (1);
+UPDATE test.t4 tn4, b42941.t4 tt4 SET tn4.a= 10, tt4.a= 100;
+COMMIT;
+
+FLUSH LOGS;
+
+-- let $log_file1= $MYSQLD_DATADIR/master-bin.000001
+-- let $log_file2= $MYSQLD_DATADIR/master-bin.000002
+-- let $outfile= $MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog
+-- let $cmd= $MYSQL_BINLOG
+
+let $i= 3;
+while($i)
+{
+  -- let $flags=--database=b42941
+
+  # construct CLI for mysqlbinlog
+  if(`SELECT $i=3`)
+  {
+    -- let $flags= $flags --verbose --hexdump
+  }
+
+  if(`SELECT $i=2`)
+  {
+    -- let $flags= $flags --verbose
+  }
+
+#  if(`SELECT $i=1`)
+#  {
+    # do nothing $flags is already set as it should be
+#  }
+
+  # execute mysqlbinlog on the two available master binlog files
+  -- exec $cmd $flags $log_file1 > $outfile.1
+  -- exec $cmd $flags $log_file2 > $outfile.2
+
+  # load outputs into a variable
+  -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+  -- eval SET @b42941_output.1= LOAD_FILE('$outfile.1')
+
+  -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+  -- eval SET @b42941_output.2= LOAD_FILE('$outfile.2')
+
+  # remove unecessary files
+  -- remove_file $outfile.1
+  -- remove_file $outfile.2
+
+  # assertion: events for database test are filtered
+  if (`SELECT INSTR(@b42941_output.1, 'test')`)
+  {
+    -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1).
+  }
+
+  if (`SELECT INSTR(@b42941_output.2, 'test')`)
+  {
+    -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2).
+  }
+
+  # assertion: events for database b42941 are not filtered
+  if (!`SELECT INSTR(@b42941_output.1, 'b42941')`)
+  {
+    -- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.1).
+  }
+
+  if (!`SELECT INSTR(@b42941_output.2, 'b42941')`)
+  {
+    -- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.2).
+  }
+
+  dec $i;
+}
+
+DROP DATABASE b42941;
+use test;
+DROP TABLE t1, t2, t3, t4;

=== added file 'mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt'
--- a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt	2009-06-27 13:18:47 +0000
@@ -0,0 +1 @@
+--binlog-ignore-db=b42851

=== added file 'mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test'
--- a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test	2009-06-27 13:18:47 +0000
@@ -0,0 +1,73 @@
+# BUG#42851: Spurious "Statement is not safe to log in statement
+#            format." warnings
+#
+# WHY
+# ===
+#   
+#   This test aims at checking that the fix that removes spurious
+#   entries in the error log when the statement is filtered out from
+#   binlog, is working.
+#
+# HOW
+# ===
+#
+#   The test case is split into three assertions when issuing statements
+#   containing LIMIT and ORDER BY:
+#
+#     i) issue statements in database that is not filtered => check
+#        that warnings ARE shown;
+#
+#    ii) issue statements in database that is not filtered, but with
+#        binlog disabled => check that warnings ARE NOT shown;
+#
+#   iii) issue statements in database that is filtered => check that
+#        warnings ARE NOT shown.
+
+-- source include/have_log_bin.inc
+-- source include/have_binlog_format_statement.inc
+
+-- echo ### NOT filtered database => assertion: warnings ARE shown
+
+-- disable_warnings
+DROP TABLE IF EXISTS t1;
+-- enable_warnings
+
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+
+-- echo ### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
+
+SET SQL_LOG_BIN= 0;
+
+-- disable_warnings
+DROP TABLE IF EXISTS t1;
+-- enable_warnings
+
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+
+SET SQL_LOG_BIN= 1;
+
+-- echo ### FILTERED database => assertion: warnings ARE NOT shown
+
+CREATE DATABASE b42851;
+USE b42851;
+
+-- disable_warnings
+DROP TABLE IF EXISTS t1;
+-- enable_warnings
+
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+
+# clean up
+DROP DATABASE b42851;

=== removed file 'mysql-test/suite/funcs_1/datadict/charset_collation.inc'
--- a/mysql-test/suite/funcs_1/datadict/charset_collation.inc	2009-06-09 16:09:16 +0000
+++ b/mysql-test/suite/funcs_1/datadict/charset_collation.inc	1970-01-01 00:00:00 +0000
@@ -1,134 +0,0 @@
-# suite/funcs_1/datadict/charset_collation.inc
-#
-# Tests checking the content of the information_schema tables
-#      character_sets
-#      collations
-#      collation_character_set_applicability
-#
-#
-# The amount and properties of character_sets/collations depend on the
-# build type
-# 2007-12 MySQL 5.0, 2008-06 MySQL 5.1
-# ---------------------------------------------------------------------
-#
-# Variant 1 fits to
-#    version_comment       MySQL Enterprise Server (Commercial)
-#    version_comment       MySQL Enterprise Server (GPL)
-#    version_comment       MySQL Classic Server (Commercial)
-#    version_comment       MySQL Pushbuild Edition, build <number>
-#   (version_comment       Source distribution
-#    and
-#    compile was without "max" - > no collation 'utf8_general_ci')
-#
-# Variant 2 fits to
-#    version_comment       MySQL Enterprise Server (GPL)
-#    version_comment       MySQL Classic Server (Commercial)
-#    version_comment       MySQL Pushbuild Edition, build <number>
-#   (version_comment       Source distribution
-#    and
-#    compile was without "max" - > collation 'utf8_general_ci' exists)
-#
-# Difference between variant 1 and 2 is the collation 'utf8_general_ci'.
-#
-# Variant 3 fits to
-#    version_comment       MySQL Community Server (GPL)
-#    version_comment       MySQL Cluster Server (Commercial)
-#    version_comment       MySQL Advanced Server (GPL)         5.1
-#    version_comment       MySQL Advanced Server (Commercial)  5.1
-#
-# Difference between variant 3 and 2 is within the collation properties
-# IS_COMPILED and SORTLEN.
-#
-# 2008-06 All time excluded variant is "vanilla".
-# How to build "vanilla":
-#    ./BUILD/autorun.sh
-#    ./configure
-#    ./make
-# Some properties of "vanilla"
-#    version_comment       Source distribution
-#    Compared to the variants 1 to 3 a lot of character sets are missing.
-#    Example: "ucs2_bin" is in variant 1 to 3 but not in "vanilla".
-#
-# Created:
-# 2007-12-18 mleich - remove the unstable character_set/collation subtests
-#                     from include/datadict-master.inc
-#                   - create this new test
-#
-
-# Create a low privileged user.
---error 0, ER_CANNOT_USER
-DROP USER dbdict_test@localhost;
-CREATE USER dbdict_test@localhost;
-
---echo # Establish connection con (user=dbdict_test)
---replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
-connect (con,localhost,dbdict_test,,);
-################################################################################
-#
-# The original requirements for the following tests were:
-#
-# 3.2.2.2: Ensure that the table (information_schema.character_sets) shows the
-#          relevant information on every character set for which the current
-#          user or PUBLIC have the USAGE privilege.
-#
-# 3.2.2.3: Ensure that the table (information_schema.character_sets) does not
-#          show any information on any character set for which the current user
-#          or PUBLIC have no USAGE privilege.
-#
-#
-# 3.2.3.2: Ensure that the table (information_schema.collations) shows the
-#          relevant information on every collation for which the current user
-#          or PUBLIC have the USAGE privilege.
-#
-# 3.2.3.3: Ensure that the table (information_schema.collations) does not show
-#          any information on any collations for which the current user and
-#          PUBLIC have no USAGE privilege.
-#
-#
-# 3.2.4.2: Ensure that the table
-#                information_schema.collation_character_set_applicability
-#          shows the relevant information on every collation/character set
-#          combination for which the current user or PUBLIC have the USAGE
-#          privilege.
-#
-# 3.2.4.3: Ensure that the table
-#                information_schema.collation_character_set_applicability
-#          does not show any information on any collation/character set
-#          combinations for which the current user and PUBLIC have no
-#          USAGE privilege.
-#
-# Notes (2007-12-19 mleich):
-# - The requirements are outdated because grant/revoke privilege for using a
-#   characterset/collation were never implemented.
-#   Therefore the tests should simply check the content of these tables.
-#
-# - The amount of collations/character sets grows with new MySQL releases.
-#
-# - Even within the same release the amount of records within these tables
-#   can differ between different build types (community, enterprise, source,...)
-#
-#
-################################################################################
---echo
-SELECT *
-FROM information_schema.character_sets
-ORDER BY character_set_name;
-
---echo
-SELECT *
-FROM information_schema.collations
-ORDER BY collation_name;
-
-echo;
---echo
-SELECT *
-FROM information_schema.collation_character_set_applicability
-ORDER BY collation_name, character_set_name;
-
-
-# Cleanup
---echo # Switch to connection default + disconnect con
-connection default;
-disconnect con;
-DROP USER dbdict_test@localhost;
-

=== added file 'mysql-test/suite/funcs_1/r/charset_collation.result'
--- a/mysql-test/suite/funcs_1/r/charset_collation.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/funcs_1/r/charset_collation.result	2009-06-19 15:04:25 +0000
@@ -0,0 +1,40 @@
+DROP USER dbdict_test@localhost;
+CREATE USER dbdict_test@localhost;
+# Establish connection con (user=dbdict_test)
+
+SELECT *
+FROM information_schema.character_sets
+WHERE character_set_name IN ('utf8','latin1','binary')
+ORDER BY character_set_name;
+CHARACTER_SET_NAME	DEFAULT_COLLATE_NAME	DESCRIPTION	MAXLEN
+binary	binary	Binary pseudo charset	1
+latin1	latin1_swedish_ci	cp1252 West European	1
+utf8	utf8_general_ci	UTF-8 Unicode	3
+
+SELECT *
+FROM information_schema.collations
+WHERE character_set_name IN ('utf8','latin1','binary')
+AND (collation_name LIKE CONCAT(character_set_name,'_general_ci')
+OR
+collation_name LIKE CONCAT(character_set_name,'_bin'))
+ORDER BY collation_name;
+COLLATION_NAME	CHARACTER_SET_NAME	ID	IS_DEFAULT	IS_COMPILED	SORTLEN
+latin1_bin	latin1	47		Yes	1
+latin1_general_ci	latin1	48		Yes	1
+utf8_bin	utf8	83		Yes	1
+utf8_general_ci	utf8	33	Yes	Yes	1
+
+SELECT *
+FROM information_schema.collation_character_set_applicability
+WHERE character_set_name IN ('utf8','latin1','binary')
+AND (collation_name LIKE CONCAT(character_set_name,'_general_ci')
+OR
+collation_name LIKE CONCAT(character_set_name,'_bin'))
+ORDER BY collation_name, character_set_name;
+COLLATION_NAME	CHARACTER_SET_NAME
+latin1_bin	latin1
+latin1_general_ci	latin1
+utf8_bin	utf8
+utf8_general_ci	utf8
+# Switch to connection default + disconnect con
+DROP USER dbdict_test@localhost;

=== removed file 'mysql-test/suite/funcs_1/r/charset_collation_1.result'
--- a/mysql-test/suite/funcs_1/r/charset_collation_1.result	2008-03-07 19:18:14 +0000
+++ b/mysql-test/suite/funcs_1/r/charset_collation_1.result	1970-01-01 00:00:00 +0000
@@ -1,312 +0,0 @@
-DROP USER dbdict_test@localhost;
-CREATE USER dbdict_test@localhost;
-# Establish connection con (user=dbdict_test)
-
-SELECT *
-FROM information_schema.character_sets
-ORDER BY character_set_name;
-CHARACTER_SET_NAME	DEFAULT_COLLATE_NAME	DESCRIPTION	MAXLEN
-armscii8	armscii8_general_ci	ARMSCII-8 Armenian	1
-ascii	ascii_general_ci	US ASCII	1
-big5	big5_chinese_ci	Big5 Traditional Chinese	2
-binary	binary	Binary pseudo charset	1
-cp1250	cp1250_general_ci	Windows Central European	1
-cp1251	cp1251_general_ci	Windows Cyrillic	1
-cp1256	cp1256_general_ci	Windows Arabic	1
-cp1257	cp1257_general_ci	Windows Baltic	1
-cp850	cp850_general_ci	DOS West European	1
-cp852	cp852_general_ci	DOS Central European	1
-cp866	cp866_general_ci	DOS Russian	1
-cp932	cp932_japanese_ci	SJIS for Windows Japanese	2
-dec8	dec8_swedish_ci	DEC West European	1
-eucjpms	eucjpms_japanese_ci	UJIS for Windows Japanese	3
-euckr	euckr_korean_ci	EUC-KR Korean	2
-gb2312	gb2312_chinese_ci	GB2312 Simplified Chinese	2
-gbk	gbk_chinese_ci	GBK Simplified Chinese	2
-geostd8	geostd8_general_ci	GEOSTD8 Georgian	1
-greek	greek_general_ci	ISO 8859-7 Greek	1
-hebrew	hebrew_general_ci	ISO 8859-8 Hebrew	1
-hp8	hp8_english_ci	HP West European	1
-keybcs2	keybcs2_general_ci	DOS Kamenicky Czech-Slovak	1
-koi8r	koi8r_general_ci	KOI8-R Relcom Russian	1
-koi8u	koi8u_general_ci	KOI8-U Ukrainian	1
-latin1	latin1_swedish_ci	cp1252 West European	1
-latin2	latin2_general_ci	ISO 8859-2 Central European	1
-latin5	latin5_turkish_ci	ISO 8859-9 Turkish	1
-latin7	latin7_general_ci	ISO 8859-13 Baltic	1
-macce	macce_general_ci	Mac Central European	1
-macroman	macroman_general_ci	Mac West European	1
-sjis	sjis_japanese_ci	Shift-JIS Japanese	2
-swe7	swe7_swedish_ci	7bit Swedish	1
-tis620	tis620_thai_ci	TIS620 Thai	1
-ucs2	ucs2_general_ci	UCS-2 Unicode	2
-ujis	ujis_japanese_ci	EUC-JP Japanese	3
-utf8	utf8_general_ci	UTF-8 Unicode	3
-
-SELECT *
-FROM information_schema.collations
-ORDER BY collation_name;
-COLLATION_NAME	CHARACTER_SET_NAME	ID	IS_DEFAULT	IS_COMPILED	SORTLEN
-armscii8_bin	armscii8	64			0
-armscii8_general_ci	armscii8	32	Yes		0
-ascii_bin	ascii	65			0
-ascii_general_ci	ascii	11	Yes		0
-big5_bin	big5	84		Yes	1
-big5_chinese_ci	big5	1	Yes	Yes	1
-binary	binary	63	Yes	Yes	1
-cp1250_bin	cp1250	66		Yes	1
-cp1250_croatian_ci	cp1250	44		Yes	1
-cp1250_czech_cs	cp1250	34		Yes	2
-cp1250_general_ci	cp1250	26	Yes	Yes	1
-cp1250_polish_ci	cp1250	99		Yes	1
-cp1251_bin	cp1251	50			0
-cp1251_bulgarian_ci	cp1251	14			0
-cp1251_general_ci	cp1251	51	Yes		0
-cp1251_general_cs	cp1251	52			0
-cp1251_ukrainian_ci	cp1251	23			0
-cp1256_bin	cp1256	67			0
-cp1256_general_ci	cp1256	57	Yes		0
-cp1257_bin	cp1257	58			0
-cp1257_general_ci	cp1257	59	Yes		0
-cp1257_lithuanian_ci	cp1257	29			0
-cp850_bin	cp850	80			0
-cp850_general_ci	cp850	4	Yes		0
-cp852_bin	cp852	81			0
-cp852_general_ci	cp852	40	Yes		0
-cp866_bin	cp866	68			0
-cp866_general_ci	cp866	36	Yes		0
-cp932_bin	cp932	96		Yes	1
-cp932_japanese_ci	cp932	95	Yes	Yes	1
-dec8_bin	dec8	69			0
-dec8_swedish_ci	dec8	3	Yes		0
-eucjpms_bin	eucjpms	98		Yes	1
-eucjpms_japanese_ci	eucjpms	97	Yes	Yes	1
-euckr_bin	euckr	85		Yes	1
-euckr_korean_ci	euckr	19	Yes	Yes	1
-gb2312_bin	gb2312	86		Yes	1
-gb2312_chinese_ci	gb2312	24	Yes	Yes	1
-gbk_bin	gbk	87		Yes	1
-gbk_chinese_ci	gbk	28	Yes	Yes	1
-geostd8_bin	geostd8	93			0
-geostd8_general_ci	geostd8	92	Yes		0
-greek_bin	greek	70			0
-greek_general_ci	greek	25	Yes		0
-hebrew_bin	hebrew	71			0
-hebrew_general_ci	hebrew	16	Yes		0
-hp8_bin	hp8	72			0
-hp8_english_ci	hp8	6	Yes		0
-keybcs2_bin	keybcs2	73			0
-keybcs2_general_ci	keybcs2	37	Yes		0
-koi8r_bin	koi8r	74			0
-koi8r_general_ci	koi8r	7	Yes		0
-koi8u_bin	koi8u	75			0
-koi8u_general_ci	koi8u	22	Yes		0
-latin1_bin	latin1	47		Yes	1
-latin1_danish_ci	latin1	15		Yes	1
-latin1_general_ci	latin1	48		Yes	1
-latin1_general_cs	latin1	49		Yes	1
-latin1_german1_ci	latin1	5		Yes	1
-latin1_german2_ci	latin1	31		Yes	2
-latin1_spanish_ci	latin1	94		Yes	1
-latin1_swedish_ci	latin1	8	Yes	Yes	1
-latin2_bin	latin2	77		Yes	1
-latin2_croatian_ci	latin2	27		Yes	1
-latin2_czech_cs	latin2	2		Yes	4
-latin2_general_ci	latin2	9	Yes	Yes	1
-latin2_hungarian_ci	latin2	21		Yes	1
-latin5_bin	latin5	78			0
-latin5_turkish_ci	latin5	30	Yes		0
-latin7_bin	latin7	79			0
-latin7_estonian_cs	latin7	20			0
-latin7_general_ci	latin7	41	Yes		0
-latin7_general_cs	latin7	42			0
-macce_bin	macce	43			0
-macce_general_ci	macce	38	Yes		0
-macroman_bin	macroman	53			0
-macroman_general_ci	macroman	39	Yes		0
-sjis_bin	sjis	88		Yes	1
-sjis_japanese_ci	sjis	13	Yes	Yes	1
-swe7_bin	swe7	82			0
-swe7_swedish_ci	swe7	10	Yes		0
-tis620_bin	tis620	89		Yes	1
-tis620_thai_ci	tis620	18	Yes	Yes	4
-ucs2_bin	ucs2	90		Yes	1
-ucs2_czech_ci	ucs2	138		Yes	8
-ucs2_danish_ci	ucs2	139		Yes	8
-ucs2_esperanto_ci	ucs2	145		Yes	8
-ucs2_estonian_ci	ucs2	134		Yes	8
-ucs2_general_ci	ucs2	35	Yes	Yes	1
-ucs2_hungarian_ci	ucs2	146		Yes	8
-ucs2_icelandic_ci	ucs2	129		Yes	8
-ucs2_latvian_ci	ucs2	130		Yes	8
-ucs2_lithuanian_ci	ucs2	140		Yes	8
-ucs2_persian_ci	ucs2	144		Yes	8
-ucs2_polish_ci	ucs2	133		Yes	8
-ucs2_romanian_ci	ucs2	131		Yes	8
-ucs2_roman_ci	ucs2	143		Yes	8
-ucs2_slovak_ci	ucs2	141		Yes	8
-ucs2_slovenian_ci	ucs2	132		Yes	8
-ucs2_spanish2_ci	ucs2	142		Yes	8
-ucs2_spanish_ci	ucs2	135		Yes	8
-ucs2_swedish_ci	ucs2	136		Yes	8
-ucs2_turkish_ci	ucs2	137		Yes	8
-ucs2_unicode_ci	ucs2	128		Yes	8
-ujis_bin	ujis	91		Yes	1
-ujis_japanese_ci	ujis	12	Yes	Yes	1
-utf8_bin	utf8	83		Yes	1
-utf8_czech_ci	utf8	202		Yes	8
-utf8_danish_ci	utf8	203		Yes	8
-utf8_esperanto_ci	utf8	209		Yes	8
-utf8_estonian_ci	utf8	198		Yes	8
-utf8_general_ci	utf8	33	Yes	Yes	1
-utf8_hungarian_ci	utf8	210		Yes	8
-utf8_icelandic_ci	utf8	193		Yes	8
-utf8_latvian_ci	utf8	194		Yes	8
-utf8_lithuanian_ci	utf8	204		Yes	8
-utf8_persian_ci	utf8	208		Yes	8
-utf8_polish_ci	utf8	197		Yes	8
-utf8_romanian_ci	utf8	195		Yes	8
-utf8_roman_ci	utf8	207		Yes	8
-utf8_slovak_ci	utf8	205		Yes	8
-utf8_slovenian_ci	utf8	196		Yes	8
-utf8_spanish2_ci	utf8	206		Yes	8
-utf8_spanish_ci	utf8	199		Yes	8
-utf8_swedish_ci	utf8	200		Yes	8
-utf8_turkish_ci	utf8	201		Yes	8
-utf8_unicode_ci	utf8	192		Yes	8
-
-
-SELECT *
-FROM information_schema.collation_character_set_applicability
-ORDER BY collation_name, character_set_name;
-COLLATION_NAME	CHARACTER_SET_NAME
-armscii8_bin	armscii8
-armscii8_general_ci	armscii8
-ascii_bin	ascii
-ascii_general_ci	ascii
-big5_bin	big5
-big5_chinese_ci	big5
-binary	binary
-cp1250_bin	cp1250
-cp1250_croatian_ci	cp1250
-cp1250_czech_cs	cp1250
-cp1250_general_ci	cp1250
-cp1250_polish_ci	cp1250
-cp1251_bin	cp1251
-cp1251_bulgarian_ci	cp1251
-cp1251_general_ci	cp1251
-cp1251_general_cs	cp1251
-cp1251_ukrainian_ci	cp1251
-cp1256_bin	cp1256
-cp1256_general_ci	cp1256
-cp1257_bin	cp1257
-cp1257_general_ci	cp1257
-cp1257_lithuanian_ci	cp1257
-cp850_bin	cp850
-cp850_general_ci	cp850
-cp852_bin	cp852
-cp852_general_ci	cp852
-cp866_bin	cp866
-cp866_general_ci	cp866
-cp932_bin	cp932
-cp932_japanese_ci	cp932
-dec8_bin	dec8
-dec8_swedish_ci	dec8
-eucjpms_bin	eucjpms
-eucjpms_japanese_ci	eucjpms
-euckr_bin	euckr
-euckr_korean_ci	euckr
-filename	filename
-gb2312_bin	gb2312
-gb2312_chinese_ci	gb2312
-gbk_bin	gbk
-gbk_chinese_ci	gbk
-geostd8_bin	geostd8
-geostd8_general_ci	geostd8
-greek_bin	greek
-greek_general_ci	greek
-hebrew_bin	hebrew
-hebrew_general_ci	hebrew
-hp8_bin	hp8
-hp8_english_ci	hp8
-keybcs2_bin	keybcs2
-keybcs2_general_ci	keybcs2
-koi8r_bin	koi8r
-koi8r_general_ci	koi8r
-koi8u_bin	koi8u
-koi8u_general_ci	koi8u
-latin1_bin	latin1
-latin1_danish_ci	latin1
-latin1_general_ci	latin1
-latin1_general_cs	latin1
-latin1_german1_ci	latin1
-latin1_german2_ci	latin1
-latin1_spanish_ci	latin1
-latin1_swedish_ci	latin1
-latin2_bin	latin2
-latin2_croatian_ci	latin2
-latin2_czech_cs	latin2
-latin2_general_ci	latin2
-latin2_hungarian_ci	latin2
-latin5_bin	latin5
-latin5_turkish_ci	latin5
-latin7_bin	latin7
-latin7_estonian_cs	latin7
-latin7_general_ci	latin7
-latin7_general_cs	latin7
-macce_bin	macce
-macce_general_ci	macce
-macroman_bin	macroman
-macroman_general_ci	macroman
-sjis_bin	sjis
-sjis_japanese_ci	sjis
-swe7_bin	swe7
-swe7_swedish_ci	swe7
-tis620_bin	tis620
-tis620_thai_ci	tis620
-ucs2_bin	ucs2
-ucs2_czech_ci	ucs2
-ucs2_danish_ci	ucs2
-ucs2_esperanto_ci	ucs2
-ucs2_estonian_ci	ucs2
-ucs2_general_ci	ucs2
-ucs2_hungarian_ci	ucs2
-ucs2_icelandic_ci	ucs2
-ucs2_latvian_ci	ucs2
-ucs2_lithuanian_ci	ucs2
-ucs2_persian_ci	ucs2
-ucs2_polish_ci	ucs2
-ucs2_romanian_ci	ucs2
-ucs2_roman_ci	ucs2
-ucs2_slovak_ci	ucs2
-ucs2_slovenian_ci	ucs2
-ucs2_spanish2_ci	ucs2
-ucs2_spanish_ci	ucs2
-ucs2_swedish_ci	ucs2
-ucs2_turkish_ci	ucs2
-ucs2_unicode_ci	ucs2
-ujis_bin	ujis
-ujis_japanese_ci	ujis
-utf8_bin	utf8
-utf8_czech_ci	utf8
-utf8_danish_ci	utf8
-utf8_esperanto_ci	utf8
-utf8_estonian_ci	utf8
-utf8_general_ci	utf8
-utf8_hungarian_ci	utf8
-utf8_icelandic_ci	utf8
-utf8_latvian_ci	utf8
-utf8_lithuanian_ci	utf8
-utf8_persian_ci	utf8
-utf8_polish_ci	utf8
-utf8_romanian_ci	utf8
-utf8_roman_ci	utf8
-utf8_slovak_ci	utf8
-utf8_slovenian_ci	utf8
-utf8_spanish2_ci	utf8
-utf8_spanish_ci	utf8
-utf8_swedish_ci	utf8
-utf8_turkish_ci	utf8
-utf8_unicode_ci	utf8
-# Switch to connection default + disconnect con
-DROP USER dbdict_test@localhost;

=== removed file 'mysql-test/suite/funcs_1/r/charset_collation_2.result'
--- a/mysql-test/suite/funcs_1/r/charset_collation_2.result	2008-03-07 19:18:14 +0000
+++ b/mysql-test/suite/funcs_1/r/charset_collation_2.result	1970-01-01 00:00:00 +0000
@@ -1,314 +0,0 @@
-DROP USER dbdict_test@localhost;
-CREATE USER dbdict_test@localhost;
-# Establish connection con (user=dbdict_test)
-
-SELECT *
-FROM information_schema.character_sets
-ORDER BY character_set_name;
-CHARACTER_SET_NAME	DEFAULT_COLLATE_NAME	DESCRIPTION	MAXLEN
-armscii8	armscii8_general_ci	ARMSCII-8 Armenian	1
-ascii	ascii_general_ci	US ASCII	1
-big5	big5_chinese_ci	Big5 Traditional Chinese	2
-binary	binary	Binary pseudo charset	1
-cp1250	cp1250_general_ci	Windows Central European	1
-cp1251	cp1251_general_ci	Windows Cyrillic	1
-cp1256	cp1256_general_ci	Windows Arabic	1
-cp1257	cp1257_general_ci	Windows Baltic	1
-cp850	cp850_general_ci	DOS West European	1
-cp852	cp852_general_ci	DOS Central European	1
-cp866	cp866_general_ci	DOS Russian	1
-cp932	cp932_japanese_ci	SJIS for Windows Japanese	2
-dec8	dec8_swedish_ci	DEC West European	1
-eucjpms	eucjpms_japanese_ci	UJIS for Windows Japanese	3
-euckr	euckr_korean_ci	EUC-KR Korean	2
-gb2312	gb2312_chinese_ci	GB2312 Simplified Chinese	2
-gbk	gbk_chinese_ci	GBK Simplified Chinese	2
-geostd8	geostd8_general_ci	GEOSTD8 Georgian	1
-greek	greek_general_ci	ISO 8859-7 Greek	1
-hebrew	hebrew_general_ci	ISO 8859-8 Hebrew	1
-hp8	hp8_english_ci	HP West European	1
-keybcs2	keybcs2_general_ci	DOS Kamenicky Czech-Slovak	1
-koi8r	koi8r_general_ci	KOI8-R Relcom Russian	1
-koi8u	koi8u_general_ci	KOI8-U Ukrainian	1
-latin1	latin1_swedish_ci	cp1252 West European	1
-latin2	latin2_general_ci	ISO 8859-2 Central European	1
-latin5	latin5_turkish_ci	ISO 8859-9 Turkish	1
-latin7	latin7_general_ci	ISO 8859-13 Baltic	1
-macce	macce_general_ci	Mac Central European	1
-macroman	macroman_general_ci	Mac West European	1
-sjis	sjis_japanese_ci	Shift-JIS Japanese	2
-swe7	swe7_swedish_ci	7bit Swedish	1
-tis620	tis620_thai_ci	TIS620 Thai	1
-ucs2	ucs2_general_ci	UCS-2 Unicode	2
-ujis	ujis_japanese_ci	EUC-JP Japanese	3
-utf8	utf8_general_ci	UTF-8 Unicode	3
-
-SELECT *
-FROM information_schema.collations
-ORDER BY collation_name;
-COLLATION_NAME	CHARACTER_SET_NAME	ID	IS_DEFAULT	IS_COMPILED	SORTLEN
-armscii8_bin	armscii8	64			0
-armscii8_general_ci	armscii8	32	Yes		0
-ascii_bin	ascii	65			0
-ascii_general_ci	ascii	11	Yes		0
-big5_bin	big5	84		Yes	1
-big5_chinese_ci	big5	1	Yes	Yes	1
-binary	binary	63	Yes	Yes	1
-cp1250_bin	cp1250	66		Yes	1
-cp1250_croatian_ci	cp1250	44		Yes	1
-cp1250_czech_cs	cp1250	34		Yes	2
-cp1250_general_ci	cp1250	26	Yes	Yes	1
-cp1250_polish_ci	cp1250	99		Yes	1
-cp1251_bin	cp1251	50			0
-cp1251_bulgarian_ci	cp1251	14			0
-cp1251_general_ci	cp1251	51	Yes		0
-cp1251_general_cs	cp1251	52			0
-cp1251_ukrainian_ci	cp1251	23			0
-cp1256_bin	cp1256	67			0
-cp1256_general_ci	cp1256	57	Yes		0
-cp1257_bin	cp1257	58			0
-cp1257_general_ci	cp1257	59	Yes		0
-cp1257_lithuanian_ci	cp1257	29			0
-cp850_bin	cp850	80			0
-cp850_general_ci	cp850	4	Yes		0
-cp852_bin	cp852	81			0
-cp852_general_ci	cp852	40	Yes		0
-cp866_bin	cp866	68			0
-cp866_general_ci	cp866	36	Yes		0
-cp932_bin	cp932	96		Yes	1
-cp932_japanese_ci	cp932	95	Yes	Yes	1
-dec8_bin	dec8	69			0
-dec8_swedish_ci	dec8	3	Yes		0
-eucjpms_bin	eucjpms	98		Yes	1
-eucjpms_japanese_ci	eucjpms	97	Yes	Yes	1
-euckr_bin	euckr	85		Yes	1
-euckr_korean_ci	euckr	19	Yes	Yes	1
-gb2312_bin	gb2312	86		Yes	1
-gb2312_chinese_ci	gb2312	24	Yes	Yes	1
-gbk_bin	gbk	87		Yes	1
-gbk_chinese_ci	gbk	28	Yes	Yes	1
-geostd8_bin	geostd8	93			0
-geostd8_general_ci	geostd8	92	Yes		0
-greek_bin	greek	70			0
-greek_general_ci	greek	25	Yes		0
-hebrew_bin	hebrew	71			0
-hebrew_general_ci	hebrew	16	Yes		0
-hp8_bin	hp8	72			0
-hp8_english_ci	hp8	6	Yes		0
-keybcs2_bin	keybcs2	73			0
-keybcs2_general_ci	keybcs2	37	Yes		0
-koi8r_bin	koi8r	74			0
-koi8r_general_ci	koi8r	7	Yes		0
-koi8u_bin	koi8u	75			0
-koi8u_general_ci	koi8u	22	Yes		0
-latin1_bin	latin1	47		Yes	1
-latin1_danish_ci	latin1	15		Yes	1
-latin1_general_ci	latin1	48		Yes	1
-latin1_general_cs	latin1	49		Yes	1
-latin1_german1_ci	latin1	5		Yes	1
-latin1_german2_ci	latin1	31		Yes	2
-latin1_spanish_ci	latin1	94		Yes	1
-latin1_swedish_ci	latin1	8	Yes	Yes	1
-latin2_bin	latin2	77		Yes	1
-latin2_croatian_ci	latin2	27		Yes	1
-latin2_czech_cs	latin2	2		Yes	4
-latin2_general_ci	latin2	9	Yes	Yes	1
-latin2_hungarian_ci	latin2	21		Yes	1
-latin5_bin	latin5	78			0
-latin5_turkish_ci	latin5	30	Yes		0
-latin7_bin	latin7	79			0
-latin7_estonian_cs	latin7	20			0
-latin7_general_ci	latin7	41	Yes		0
-latin7_general_cs	latin7	42			0
-macce_bin	macce	43			0
-macce_general_ci	macce	38	Yes		0
-macroman_bin	macroman	53			0
-macroman_general_ci	macroman	39	Yes		0
-sjis_bin	sjis	88		Yes	1
-sjis_japanese_ci	sjis	13	Yes	Yes	1
-swe7_bin	swe7	82			0
-swe7_swedish_ci	swe7	10	Yes		0
-tis620_bin	tis620	89		Yes	1
-tis620_thai_ci	tis620	18	Yes	Yes	4
-ucs2_bin	ucs2	90		Yes	1
-ucs2_czech_ci	ucs2	138		Yes	8
-ucs2_danish_ci	ucs2	139		Yes	8
-ucs2_esperanto_ci	ucs2	145		Yes	8
-ucs2_estonian_ci	ucs2	134		Yes	8
-ucs2_general_ci	ucs2	35	Yes	Yes	1
-ucs2_hungarian_ci	ucs2	146		Yes	8
-ucs2_icelandic_ci	ucs2	129		Yes	8
-ucs2_latvian_ci	ucs2	130		Yes	8
-ucs2_lithuanian_ci	ucs2	140		Yes	8
-ucs2_persian_ci	ucs2	144		Yes	8
-ucs2_polish_ci	ucs2	133		Yes	8
-ucs2_romanian_ci	ucs2	131		Yes	8
-ucs2_roman_ci	ucs2	143		Yes	8
-ucs2_slovak_ci	ucs2	141		Yes	8
-ucs2_slovenian_ci	ucs2	132		Yes	8
-ucs2_spanish2_ci	ucs2	142		Yes	8
-ucs2_spanish_ci	ucs2	135		Yes	8
-ucs2_swedish_ci	ucs2	136		Yes	8
-ucs2_turkish_ci	ucs2	137		Yes	8
-ucs2_unicode_ci	ucs2	128		Yes	8
-ujis_bin	ujis	91		Yes	1
-ujis_japanese_ci	ujis	12	Yes	Yes	1
-utf8_bin	utf8	83		Yes	1
-utf8_czech_ci	utf8	202		Yes	8
-utf8_danish_ci	utf8	203		Yes	8
-utf8_esperanto_ci	utf8	209		Yes	8
-utf8_estonian_ci	utf8	198		Yes	8
-utf8_general_ci	utf8	33	Yes	Yes	1
-utf8_general_cs	utf8	254		Yes	1
-utf8_hungarian_ci	utf8	210		Yes	8
-utf8_icelandic_ci	utf8	193		Yes	8
-utf8_latvian_ci	utf8	194		Yes	8
-utf8_lithuanian_ci	utf8	204		Yes	8
-utf8_persian_ci	utf8	208		Yes	8
-utf8_polish_ci	utf8	197		Yes	8
-utf8_romanian_ci	utf8	195		Yes	8
-utf8_roman_ci	utf8	207		Yes	8
-utf8_slovak_ci	utf8	205		Yes	8
-utf8_slovenian_ci	utf8	196		Yes	8
-utf8_spanish2_ci	utf8	206		Yes	8
-utf8_spanish_ci	utf8	199		Yes	8
-utf8_swedish_ci	utf8	200		Yes	8
-utf8_turkish_ci	utf8	201		Yes	8
-utf8_unicode_ci	utf8	192		Yes	8
-
-
-SELECT *
-FROM information_schema.collation_character_set_applicability
-ORDER BY collation_name, character_set_name;
-COLLATION_NAME	CHARACTER_SET_NAME
-armscii8_bin	armscii8
-armscii8_general_ci	armscii8
-ascii_bin	ascii
-ascii_general_ci	ascii
-big5_bin	big5
-big5_chinese_ci	big5
-binary	binary
-cp1250_bin	cp1250
-cp1250_croatian_ci	cp1250
-cp1250_czech_cs	cp1250
-cp1250_general_ci	cp1250
-cp1250_polish_ci	cp1250
-cp1251_bin	cp1251
-cp1251_bulgarian_ci	cp1251
-cp1251_general_ci	cp1251
-cp1251_general_cs	cp1251
-cp1251_ukrainian_ci	cp1251
-cp1256_bin	cp1256
-cp1256_general_ci	cp1256
-cp1257_bin	cp1257
-cp1257_general_ci	cp1257
-cp1257_lithuanian_ci	cp1257
-cp850_bin	cp850
-cp850_general_ci	cp850
-cp852_bin	cp852
-cp852_general_ci	cp852
-cp866_bin	cp866
-cp866_general_ci	cp866
-cp932_bin	cp932
-cp932_japanese_ci	cp932
-dec8_bin	dec8
-dec8_swedish_ci	dec8
-eucjpms_bin	eucjpms
-eucjpms_japanese_ci	eucjpms
-euckr_bin	euckr
-euckr_korean_ci	euckr
-filename	filename
-gb2312_bin	gb2312
-gb2312_chinese_ci	gb2312
-gbk_bin	gbk
-gbk_chinese_ci	gbk
-geostd8_bin	geostd8
-geostd8_general_ci	geostd8
-greek_bin	greek
-greek_general_ci	greek
-hebrew_bin	hebrew
-hebrew_general_ci	hebrew
-hp8_bin	hp8
-hp8_english_ci	hp8
-keybcs2_bin	keybcs2
-keybcs2_general_ci	keybcs2
-koi8r_bin	koi8r
-koi8r_general_ci	koi8r
-koi8u_bin	koi8u
-koi8u_general_ci	koi8u
-latin1_bin	latin1
-latin1_danish_ci	latin1
-latin1_general_ci	latin1
-latin1_general_cs	latin1
-latin1_german1_ci	latin1
-latin1_german2_ci	latin1
-latin1_spanish_ci	latin1
-latin1_swedish_ci	latin1
-latin2_bin	latin2
-latin2_croatian_ci	latin2
-latin2_czech_cs	latin2
-latin2_general_ci	latin2
-latin2_hungarian_ci	latin2
-latin5_bin	latin5
-latin5_turkish_ci	latin5
-latin7_bin	latin7
-latin7_estonian_cs	latin7
-latin7_general_ci	latin7
-latin7_general_cs	latin7
-macce_bin	macce
-macce_general_ci	macce
-macroman_bin	macroman
-macroman_general_ci	macroman
-sjis_bin	sjis
-sjis_japanese_ci	sjis
-swe7_bin	swe7
-swe7_swedish_ci	swe7
-tis620_bin	tis620
-tis620_thai_ci	tis620
-ucs2_bin	ucs2
-ucs2_czech_ci	ucs2
-ucs2_danish_ci	ucs2
-ucs2_esperanto_ci	ucs2
-ucs2_estonian_ci	ucs2
-ucs2_general_ci	ucs2
-ucs2_hungarian_ci	ucs2
-ucs2_icelandic_ci	ucs2
-ucs2_latvian_ci	ucs2
-ucs2_lithuanian_ci	ucs2
-ucs2_persian_ci	ucs2
-ucs2_polish_ci	ucs2
-ucs2_romanian_ci	ucs2
-ucs2_roman_ci	ucs2
-ucs2_slovak_ci	ucs2
-ucs2_slovenian_ci	ucs2
-ucs2_spanish2_ci	ucs2
-ucs2_spanish_ci	ucs2
-ucs2_swedish_ci	ucs2
-ucs2_turkish_ci	ucs2
-ucs2_unicode_ci	ucs2
-ujis_bin	ujis
-ujis_japanese_ci	ujis
-utf8_bin	utf8
-utf8_czech_ci	utf8
-utf8_danish_ci	utf8
-utf8_esperanto_ci	utf8
-utf8_estonian_ci	utf8
-utf8_general_ci	utf8
-utf8_general_cs	utf8
-utf8_hungarian_ci	utf8
-utf8_icelandic_ci	utf8
-utf8_latvian_ci	utf8
-utf8_lithuanian_ci	utf8
-utf8_persian_ci	utf8
-utf8_polish_ci	utf8
-utf8_romanian_ci	utf8
-utf8_roman_ci	utf8
-utf8_slovak_ci	utf8
-utf8_slovenian_ci	utf8
-utf8_spanish2_ci	utf8
-utf8_spanish_ci	utf8
-utf8_swedish_ci	utf8
-utf8_turkish_ci	utf8
-utf8_unicode_ci	utf8
-# Switch to connection default + disconnect con
-DROP USER dbdict_test@localhost;

=== removed file 'mysql-test/suite/funcs_1/r/charset_collation_3.result'
--- a/mysql-test/suite/funcs_1/r/charset_collation_3.result	2008-04-01 17:22:37 +0000
+++ b/mysql-test/suite/funcs_1/r/charset_collation_3.result	1970-01-01 00:00:00 +0000
@@ -1,312 +0,0 @@
-DROP USER dbdict_test@localhost;
-CREATE USER dbdict_test@localhost;
-# Establish connection con (user=dbdict_test)
-
-SELECT *
-FROM information_schema.character_sets
-ORDER BY character_set_name;
-CHARACTER_SET_NAME	DEFAULT_COLLATE_NAME	DESCRIPTION	MAXLEN
-armscii8	armscii8_general_ci	ARMSCII-8 Armenian	1
-ascii	ascii_general_ci	US ASCII	1
-big5	big5_chinese_ci	Big5 Traditional Chinese	2
-binary	binary	Binary pseudo charset	1
-cp1250	cp1250_general_ci	Windows Central European	1
-cp1251	cp1251_general_ci	Windows Cyrillic	1
-cp1256	cp1256_general_ci	Windows Arabic	1
-cp1257	cp1257_general_ci	Windows Baltic	1
-cp850	cp850_general_ci	DOS West European	1
-cp852	cp852_general_ci	DOS Central European	1
-cp866	cp866_general_ci	DOS Russian	1
-cp932	cp932_japanese_ci	SJIS for Windows Japanese	2
-dec8	dec8_swedish_ci	DEC West European	1
-eucjpms	eucjpms_japanese_ci	UJIS for Windows Japanese	3
-euckr	euckr_korean_ci	EUC-KR Korean	2
-gb2312	gb2312_chinese_ci	GB2312 Simplified Chinese	2
-gbk	gbk_chinese_ci	GBK Simplified Chinese	2
-geostd8	geostd8_general_ci	GEOSTD8 Georgian	1
-greek	greek_general_ci	ISO 8859-7 Greek	1
-hebrew	hebrew_general_ci	ISO 8859-8 Hebrew	1
-hp8	hp8_english_ci	HP West European	1
-keybcs2	keybcs2_general_ci	DOS Kamenicky Czech-Slovak	1
-koi8r	koi8r_general_ci	KOI8-R Relcom Russian	1
-koi8u	koi8u_general_ci	KOI8-U Ukrainian	1
-latin1	latin1_swedish_ci	cp1252 West European	1
-latin2	latin2_general_ci	ISO 8859-2 Central European	1
-latin5	latin5_turkish_ci	ISO 8859-9 Turkish	1
-latin7	latin7_general_ci	ISO 8859-13 Baltic	1
-macce	macce_general_ci	Mac Central European	1
-macroman	macroman_general_ci	Mac West European	1
-sjis	sjis_japanese_ci	Shift-JIS Japanese	2
-swe7	swe7_swedish_ci	7bit Swedish	1
-tis620	tis620_thai_ci	TIS620 Thai	1
-ucs2	ucs2_general_ci	UCS-2 Unicode	2
-ujis	ujis_japanese_ci	EUC-JP Japanese	3
-utf8	utf8_general_ci	UTF-8 Unicode	3
-
-SELECT *
-FROM information_schema.collations
-ORDER BY collation_name;
-COLLATION_NAME	CHARACTER_SET_NAME	ID	IS_DEFAULT	IS_COMPILED	SORTLEN
-armscii8_bin	armscii8	64			0
-armscii8_general_ci	armscii8	32	Yes		0
-ascii_bin	ascii	65			0
-ascii_general_ci	ascii	11	Yes		0
-big5_bin	big5	84		Yes	1
-big5_chinese_ci	big5	1	Yes	Yes	1
-binary	binary	63	Yes	Yes	1
-cp1250_bin	cp1250	66		Yes	1
-cp1250_croatian_ci	cp1250	44		Yes	1
-cp1250_czech_cs	cp1250	34		Yes	2
-cp1250_general_ci	cp1250	26	Yes	Yes	1
-cp1250_polish_ci	cp1250	99		Yes	1
-cp1251_bin	cp1251	50			0
-cp1251_bulgarian_ci	cp1251	14			0
-cp1251_general_ci	cp1251	51	Yes		0
-cp1251_general_cs	cp1251	52			0
-cp1251_ukrainian_ci	cp1251	23			0
-cp1256_bin	cp1256	67			0
-cp1256_general_ci	cp1256	57	Yes		0
-cp1257_bin	cp1257	58			0
-cp1257_general_ci	cp1257	59	Yes		0
-cp1257_lithuanian_ci	cp1257	29			0
-cp850_bin	cp850	80			0
-cp850_general_ci	cp850	4	Yes		0
-cp852_bin	cp852	81			0
-cp852_general_ci	cp852	40	Yes		0
-cp866_bin	cp866	68			0
-cp866_general_ci	cp866	36	Yes		0
-cp932_bin	cp932	96		Yes	1
-cp932_japanese_ci	cp932	95	Yes	Yes	1
-dec8_bin	dec8	69			0
-dec8_swedish_ci	dec8	3	Yes		0
-eucjpms_bin	eucjpms	98		Yes	1
-eucjpms_japanese_ci	eucjpms	97	Yes	Yes	1
-euckr_bin	euckr	85		Yes	1
-euckr_korean_ci	euckr	19	Yes	Yes	1
-gb2312_bin	gb2312	86		Yes	1
-gb2312_chinese_ci	gb2312	24	Yes	Yes	1
-gbk_bin	gbk	87		Yes	1
-gbk_chinese_ci	gbk	28	Yes	Yes	1
-geostd8_bin	geostd8	93			0
-geostd8_general_ci	geostd8	92	Yes		0
-greek_bin	greek	70			0
-greek_general_ci	greek	25	Yes		0
-hebrew_bin	hebrew	71			0
-hebrew_general_ci	hebrew	16	Yes		0
-hp8_bin	hp8	72			0
-hp8_english_ci	hp8	6	Yes		0
-keybcs2_bin	keybcs2	73			0
-keybcs2_general_ci	keybcs2	37	Yes		0
-koi8r_bin	koi8r	74			0
-koi8r_general_ci	koi8r	7	Yes		0
-koi8u_bin	koi8u	75			0
-koi8u_general_ci	koi8u	22	Yes		0
-latin1_bin	latin1	47		Yes	1
-latin1_danish_ci	latin1	15		Yes	1
-latin1_general_ci	latin1	48		Yes	1
-latin1_general_cs	latin1	49		Yes	1
-latin1_german1_ci	latin1	5		Yes	1
-latin1_german2_ci	latin1	31		Yes	2
-latin1_spanish_ci	latin1	94		Yes	1
-latin1_swedish_ci	latin1	8	Yes	Yes	1
-latin2_bin	latin2	77		Yes	1
-latin2_croatian_ci	latin2	27		Yes	1
-latin2_czech_cs	latin2	2		Yes	4
-latin2_general_ci	latin2	9	Yes	Yes	1
-latin2_hungarian_ci	latin2	21		Yes	1
-latin5_bin	latin5	78			0
-latin5_turkish_ci	latin5	30	Yes		0
-latin7_bin	latin7	79			0
-latin7_estonian_cs	latin7	20			0
-latin7_general_ci	latin7	41	Yes		0
-latin7_general_cs	latin7	42			0
-macce_bin	macce	43			0
-macce_general_ci	macce	38	Yes		0
-macroman_bin	macroman	53			0
-macroman_general_ci	macroman	39	Yes		0
-sjis_bin	sjis	88		Yes	1
-sjis_japanese_ci	sjis	13	Yes	Yes	1
-swe7_bin	swe7	82			0
-swe7_swedish_ci	swe7	10	Yes		0
-tis620_bin	tis620	89		Yes	1
-tis620_thai_ci	tis620	18	Yes	Yes	4
-ucs2_bin	ucs2	90		Yes	1
-ucs2_czech_ci	ucs2	138		Yes	8
-ucs2_danish_ci	ucs2	139		Yes	8
-ucs2_esperanto_ci	ucs2	145		Yes	8
-ucs2_estonian_ci	ucs2	134		Yes	8
-ucs2_general_ci	ucs2	35	Yes	Yes	1
-ucs2_hungarian_ci	ucs2	146		Yes	8
-ucs2_icelandic_ci	ucs2	129		Yes	8
-ucs2_latvian_ci	ucs2	130		Yes	8
-ucs2_lithuanian_ci	ucs2	140		Yes	8
-ucs2_persian_ci	ucs2	144		Yes	8
-ucs2_polish_ci	ucs2	133		Yes	8
-ucs2_romanian_ci	ucs2	131		Yes	8
-ucs2_roman_ci	ucs2	143		Yes	8
-ucs2_slovak_ci	ucs2	141		Yes	8
-ucs2_slovenian_ci	ucs2	132		Yes	8
-ucs2_spanish2_ci	ucs2	142		Yes	8
-ucs2_spanish_ci	ucs2	135		Yes	8
-ucs2_swedish_ci	ucs2	136		Yes	8
-ucs2_turkish_ci	ucs2	137		Yes	8
-ucs2_unicode_ci	ucs2	128		Yes	8
-ujis_bin	ujis	91		Yes	1
-ujis_japanese_ci	ujis	12	Yes	Yes	1
-utf8_bin	utf8	83		Yes	1
-utf8_czech_ci	utf8	202		Yes	8
-utf8_danish_ci	utf8	203		Yes	8
-utf8_esperanto_ci	utf8	209		Yes	8
-utf8_estonian_ci	utf8	198		Yes	8
-utf8_general_ci	utf8	33	Yes	Yes	1
-utf8_hungarian_ci	utf8	210		Yes	8
-utf8_icelandic_ci	utf8	193		Yes	8
-utf8_latvian_ci	utf8	194		Yes	8
-utf8_lithuanian_ci	utf8	204		Yes	8
-utf8_persian_ci	utf8	208		Yes	8
-utf8_polish_ci	utf8	197		Yes	8
-utf8_romanian_ci	utf8	195		Yes	8
-utf8_roman_ci	utf8	207		Yes	8
-utf8_slovak_ci	utf8	205		Yes	8
-utf8_slovenian_ci	utf8	196		Yes	8
-utf8_spanish2_ci	utf8	206		Yes	8
-utf8_spanish_ci	utf8	199		Yes	8
-utf8_swedish_ci	utf8	200		Yes	8
-utf8_turkish_ci	utf8	201		Yes	8
-utf8_unicode_ci	utf8	192		Yes	8
-
-
-SELECT *
-FROM information_schema.collation_character_set_applicability
-ORDER BY collation_name, character_set_name;
-COLLATION_NAME	CHARACTER_SET_NAME
-armscii8_bin	armscii8
-armscii8_general_ci	armscii8
-ascii_bin	ascii
-ascii_general_ci	ascii
-big5_bin	big5
-big5_chinese_ci	big5
-binary	binary
-cp1250_bin	cp1250
-cp1250_croatian_ci	cp1250
-cp1250_czech_cs	cp1250
-cp1250_general_ci	cp1250
-cp1250_polish_ci	cp1250
-cp1251_bin	cp1251
-cp1251_bulgarian_ci	cp1251
-cp1251_general_ci	cp1251
-cp1251_general_cs	cp1251
-cp1251_ukrainian_ci	cp1251
-cp1256_bin	cp1256
-cp1256_general_ci	cp1256
-cp1257_bin	cp1257
-cp1257_general_ci	cp1257
-cp1257_lithuanian_ci	cp1257
-cp850_bin	cp850
-cp850_general_ci	cp850
-cp852_bin	cp852
-cp852_general_ci	cp852
-cp866_bin	cp866
-cp866_general_ci	cp866
-cp932_bin	cp932
-cp932_japanese_ci	cp932
-dec8_bin	dec8
-dec8_swedish_ci	dec8
-eucjpms_bin	eucjpms
-eucjpms_japanese_ci	eucjpms
-euckr_bin	euckr
-euckr_korean_ci	euckr
-filename	filename
-gb2312_bin	gb2312
-gb2312_chinese_ci	gb2312
-gbk_bin	gbk
-gbk_chinese_ci	gbk
-geostd8_bin	geostd8
-geostd8_general_ci	geostd8
-greek_bin	greek
-greek_general_ci	greek
-hebrew_bin	hebrew
-hebrew_general_ci	hebrew
-hp8_bin	hp8
-hp8_english_ci	hp8
-keybcs2_bin	keybcs2
-keybcs2_general_ci	keybcs2
-koi8r_bin	koi8r
-koi8r_general_ci	koi8r
-koi8u_bin	koi8u
-koi8u_general_ci	koi8u
-latin1_bin	latin1
-latin1_danish_ci	latin1
-latin1_general_ci	latin1
-latin1_general_cs	latin1
-latin1_german1_ci	latin1
-latin1_german2_ci	latin1
-latin1_spanish_ci	latin1
-latin1_swedish_ci	latin1
-latin2_bin	latin2
-latin2_croatian_ci	latin2
-latin2_czech_cs	latin2
-latin2_general_ci	latin2
-latin2_hungarian_ci	latin2
-latin5_bin	latin5
-latin5_turkish_ci	latin5
-latin7_bin	latin7
-latin7_estonian_cs	latin7
-latin7_general_ci	latin7
-latin7_general_cs	latin7
-macce_bin	macce
-macce_general_ci	macce
-macroman_bin	macroman
-macroman_general_ci	macroman
-sjis_bin	sjis
-sjis_japanese_ci	sjis
-swe7_bin	swe7
-swe7_swedish_ci	swe7
-tis620_bin	tis620
-tis620_thai_ci	tis620
-ucs2_bin	ucs2
-ucs2_czech_ci	ucs2
-ucs2_danish_ci	ucs2
-ucs2_esperanto_ci	ucs2
-ucs2_estonian_ci	ucs2
-ucs2_general_ci	ucs2
-ucs2_hungarian_ci	ucs2
-ucs2_icelandic_ci	ucs2
-ucs2_latvian_ci	ucs2
-ucs2_lithuanian_ci	ucs2
-ucs2_persian_ci	ucs2
-ucs2_polish_ci	ucs2
-ucs2_romanian_ci	ucs2
-ucs2_roman_ci	ucs2
-ucs2_slovak_ci	ucs2
-ucs2_slovenian_ci	ucs2
-ucs2_spanish2_ci	ucs2
-ucs2_spanish_ci	ucs2
-ucs2_swedish_ci	ucs2
-ucs2_turkish_ci	ucs2
-ucs2_unicode_ci	ucs2
-ujis_bin	ujis
-ujis_japanese_ci	ujis
-utf8_bin	utf8
-utf8_czech_ci	utf8
-utf8_danish_ci	utf8
-utf8_esperanto_ci	utf8
-utf8_estonian_ci	utf8
-utf8_general_ci	utf8
-utf8_hungarian_ci	utf8
-utf8_icelandic_ci	utf8
-utf8_latvian_ci	utf8
-utf8_lithuanian_ci	utf8
-utf8_persian_ci	utf8
-utf8_polish_ci	utf8
-utf8_romanian_ci	utf8
-utf8_roman_ci	utf8
-utf8_slovak_ci	utf8
-utf8_slovenian_ci	utf8
-utf8_spanish2_ci	utf8
-utf8_spanish_ci	utf8
-utf8_swedish_ci	utf8
-utf8_turkish_ci	utf8
-utf8_unicode_ci	utf8
-# Switch to connection default + disconnect con
-DROP USER dbdict_test@localhost;

=== modified file 'mysql-test/suite/funcs_1/r/storedproc.result'
--- a/mysql-test/suite/funcs_1/r/storedproc.result	2009-02-13 18:07:56 +0000
+++ b/mysql-test/suite/funcs_1/r/storedproc.result	2009-06-23 12:32:14 +0000
@@ -18241,8 +18241,6 @@ END//
 CALL sp70_n(-1e+40);
 f1
 -10000000000000000000000000000000000000000
-Warnings:
-Note	1265	Data truncated for column 'f1' at row 1
 CALL sp70_n( -10000000000000000000000000000000000000000 );
 f1
 -10000000000000000000000000000000000000000
@@ -18255,8 +18253,6 @@ END//
 CALL sp71_nu(1.00e+40);
 f1
 10000000000000000000000000000000000000000
-Warnings:
-Note	1265	Data truncated for column 'f1' at row 1
 CALL sp71_nu( 10000000000000000000000000000000000000000 );
 f1
 10000000000000000000000000000000000000000
@@ -18269,8 +18265,6 @@ END//
 CALL sp72_nuz(1.00e+40);
 f1
 0000000000000000000000010000000000000000000000000000000000000000
-Warnings:
-Note	1265	Data truncated for column 'f1' at row 1
 CALL sp72_nuz( 10000000000000000000000000000000000000000 );
 f1
 0000000000000000000000010000000000000000000000000000000000000000
@@ -18283,8 +18277,6 @@ END//
 CALL sp73_n_z(1.00e+40);
 f1
 0000000000000000000000010000000000000000000000000000000000000000
-Warnings:
-Note	1265	Data truncated for column 'f1' at row 1
 CALL sp73_n_z( 10000000000000000000000000000000000000000 );
 f1
 0000000000000000000000010000000000000000000000000000000000000000

=== added file 'mysql-test/suite/funcs_1/t/charset_collation.test'
--- a/mysql-test/suite/funcs_1/t/charset_collation.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/funcs_1/t/charset_collation.test	2009-06-19 15:04:25 +0000
@@ -0,0 +1,107 @@
+# suite/funcs_1/t/charset_collation.test
+#
+# Tests checking the content of the information_schema tables
+#      character_sets
+#      collations
+#      collation_character_set_applicability
+#
+# Created:
+# 2009-04-28 mleich Replace the charset_collation_* test which failed too often
+#                   because of changes
+#                   - in general available character sets and collations
+#                   - in build types
+#                   (Bug#40545, Bug#40209, Bug#40618, Bug#38346)
+#
+
+# Create a low privileged user.
+--error 0, ER_CANNOT_USER
+DROP USER dbdict_test@localhost;
+CREATE USER dbdict_test@localhost;
+
+--echo # Establish connection con (user=dbdict_test)
+connect (con,localhost,dbdict_test,,);
+################################################################################
+#
+# The original requirements for the following tests were:
+#
+# 3.2.2.2: Ensure that the table (information_schema.character_sets) shows the
+#          relevant information on every character set for which the current
+#          user or PUBLIC have the USAGE privilege.
+#
+# 3.2.2.3: Ensure that the table (information_schema.character_sets) does not
+#          show any information on any character set for which the current user
+#          or PUBLIC have no USAGE privilege.
+#
+#
+# 3.2.3.2: Ensure that the table (information_schema.collations) shows the
+#          relevant information on every collation for which the current user
+#          or PUBLIC have the USAGE privilege.
+#
+# 3.2.3.3: Ensure that the table (information_schema.collations) does not show
+#          any information on any collations for which the current user and
+#          PUBLIC have no USAGE privilege.
+#
+#
+# 3.2.4.2: Ensure that the table
+#                information_schema.collation_character_set_applicability
+#          shows the relevant information on every collation/character set
+#          combination for which the current user or PUBLIC have the USAGE
+#          privilege.
+#
+# 3.2.4.3: Ensure that the table
+#                information_schema.collation_character_set_applicability
+#          does not show any information on any collation/character set
+#          combinations for which the current user and PUBLIC have no
+#          USAGE privilege.
+#
+# Notes (2009-04-28 mleich):
+# - The requirements are outdated because grant/revoke privilege for using a
+#   characterset/collation were never implemented.
+#   Therefore the tests focus on the completeness and correctness of the
+#   content (rows and columns) of these tables.
+# - The amount of collations/character sets grows with new MySQL releases.
+#   Even within the same release the amount of records within these tables
+#   can differ between different build types (community, enterprise, source,...)
+#   Therefore we limit the queries to character sets and collations which
+#   - exist in all build types
+#   - have in all build types the same "state".
+#   The character set
+#   - utf8 is used for Metadata
+#   - ascii is a quite usual
+#   The collations <character set>_general_ci and <character set>_bin seem
+#   to be available all time.
+#
+################################################################################
+
+let $char_set_condition= character_set_name IN ('utf8','latin1','binary');
+let $collation_condition=
+   (collation_name LIKE CONCAT(character_set_name,'_general_ci')
+    OR
+    collation_name LIKE CONCAT(character_set_name,'_bin'));
+--echo
+eval SELECT *
+FROM information_schema.character_sets
+WHERE $char_set_condition
+ORDER BY character_set_name;
+
+--echo
+eval SELECT *
+FROM information_schema.collations
+WHERE $char_set_condition
+  AND $collation_condition
+ORDER BY collation_name;
+
+--echo
+eval SELECT *
+FROM information_schema.collation_character_set_applicability
+WHERE $char_set_condition
+  AND $collation_condition
+ORDER BY collation_name, character_set_name;
+
+
+# Cleanup
+--echo # Switch to connection default + disconnect con
+connection default;
+disconnect con;
+DROP USER dbdict_test@localhost;
+

=== removed file 'mysql-test/suite/funcs_1/t/charset_collation_1.test'
--- a/mysql-test/suite/funcs_1/t/charset_collation_1.test	2008-06-30 20:16:06 +0000
+++ b/mysql-test/suite/funcs_1/t/charset_collation_1.test	1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
-# Tests checking the content of the information_schema tables
-#      character_sets
-#      collations
-#      collation_character_set_applicability
-#
-# Content variant 1 which should fit to
-#    Enterprise or Classic builds (binaries provided by MySQL)
-#    Pushbuilds
-#    Source builds without "max"
-#
-# Please read suite/funcs_1/datadict/charset_collation.inc for
-# additional information.
-#
-# Created:
-# 2007-12-18 mleich - remove the unstable character_set/collation subtests
-#                     from include/datadict-master.inc
-#                   - create this new test
-#
-
-if (`SELECT EXISTS (SELECT 1 FROM information_schema.collations
-                    WHERE collation_name = 'utf8_general_cs')
-       OR (    @@version_comment NOT LIKE '%Source%'
-           AND @@version_comment NOT LIKE '%Enterprise%'
-           AND @@version_comment NOT LIKE '%Classic%'
-           AND @@version_comment NOT LIKE '%Pushbuild%')
-       OR (SELECT count(*) = 0 FROM information_schema.collations
-                    WHERE collation_name = 'ucs2_bin')`)
-{
-  skip Test needs Enterprise, Classic , regular Pushbuild or Source-without-max build;
-}
-
---source suite/funcs_1/datadict/charset_collation.inc

=== removed file 'mysql-test/suite/funcs_1/t/charset_collation_2.test'
--- a/mysql-test/suite/funcs_1/t/charset_collation_2.test	2008-03-07 16:33:07 +0000
+++ b/mysql-test/suite/funcs_1/t/charset_collation_2.test	1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
-# Tests checking the content of the information_schema tables
-#      character_sets
-#      collations
-#      collation_character_set_applicability
-#
-# Content variant 2 (compile from source with "max")
-#
-# Please read suite/funcs_1/datadict/charset_collation.inc for
-# additional information.
-#
-# Created:
-# 2007-12-18 mleich - remove the unstable character_set/collation subtests
-#                     from include/datadict-master.inc
-#                   - create this new test
-#
-
-if (`SELECT @@version_comment NOT LIKE '%Source%'
-     OR NOT EXISTS (SELECT 1 FROM information_schema.collations
-                    WHERE collation_name = 'utf8_general_cs')`)
-{
-  skip Test needs Source build with "max";
-}
-
---source suite/funcs_1/datadict/charset_collation.inc

=== removed file 'mysql-test/suite/funcs_1/t/charset_collation_3.test'
--- a/mysql-test/suite/funcs_1/t/charset_collation_3.test	2008-06-30 20:16:06 +0000
+++ b/mysql-test/suite/funcs_1/t/charset_collation_3.test	1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
-# Tests checking the content of the information_schema tables
-#      character_sets
-#      collations
-#      collation_character_set_applicability
-#
-# Content variant 3 which should fit to
-#    Community and Cluster builds (binaries provided by MySQL)
-#
-# Please read suite/funcs_1/datadict/charset_collation.inc for
-# additional information.
-#
-# Created:
-# 2007-12-18 mleich - remove the unstable character_set/collation subtests
-#                     from include/datadict-master.inc
-#                   - create this new test
-#
-
-if (`SELECT @@version_comment NOT LIKE '%Community%'
-        AND @@version_comment NOT LIKE '%Cluster%'
-        AND @@version_comment NOT LIKE '%Advanced%'`)
-{
-   skip Test needs Community, Cluster or Advanced build;
-}
-
---source suite/funcs_1/datadict/charset_collation.inc

=== modified file 'mysql-test/suite/funcs_1/t/disabled.def'
--- a/mysql-test/suite/funcs_1/t/disabled.def	2009-03-30 10:03:25 +0000
+++ b/mysql-test/suite/funcs_1/t/disabled.def	2009-06-19 15:44:29 +0000
@@ -11,6 +11,3 @@
 ##############################################################################
 
 ndb_trig_1011ext:  Bug#32656 NDB: Duplicate key error aborts transaction in handler. Doesn't talk back to SQL
-charset_collation_1: Bug#38346, Bug#40209, Bug#40545, Bug#40618
-charset_collation_2: Bug#38346, Bug#40209, Bug#40545, Bug#40618
-charset_collation_3: Bug#38346, Bug#40209, Bug#40545, Bug#40618

=== modified file 'mysql-test/suite/funcs_1/t/storedproc.test'
--- a/mysql-test/suite/funcs_1/t/storedproc.test	2009-06-09 16:09:16 +0000
+++ b/mysql-test/suite/funcs_1/t/storedproc.test	2009-07-07 14:19:38 +0000
@@ -10,6 +10,17 @@
 #                  
 ############################################################################
 
+# Bug#37746 - Arithmetic range ("int") is smaller than expected
+# This code is in place to ensure this test is only skipped
+# for the Win64 platform
+if(`SELECT CONVERT(@@version_compile_os using latin1) IN ("Win64")`)
+{
+--skip Bug#37746 2009-07-07 pcrews Arithmetic range ("int") is smaller than expected
+}
+
+
+
+
 # This test cannot be used for the embedded server because we check here
 # privileges.
 --source include/not_embedded.inc
@@ -22429,7 +22440,9 @@ BEGIN
 END//
 delimiter ;//
 
+--disable_warnings
 CALL sp70_n(-1e+40);
+--enable_warnings
 eval CALL sp70_n( $minus_40 );
 
 
@@ -22445,7 +22458,9 @@ BEGIN
 END//
 delimiter ;//
 
+--disable_warnings
 CALL sp71_nu(1.00e+40);
+--enable_warnings
 eval CALL sp71_nu( $plus_40 );
 
 
@@ -22461,7 +22476,9 @@ BEGIN
 END//
 delimiter ;//
 
+--disable_warnings
 CALL sp72_nuz(1.00e+40);
+--enable_warnings
 eval CALL sp72_nuz( $plus_40 );
 
 
@@ -22477,7 +22494,9 @@ BEGIN
 END//
 delimiter ;//
 
+--disable_warnings
 CALL sp73_n_z(1.00e+40);
+--enable_warnings
 eval CALL sp73_n_z( $plus_40 );
 
 

=== added file 'mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result'
--- a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result	2009-06-29 02:02:17 +0000
@@ -0,0 +1,33 @@
+drop table if exists t1;
+create table t1 (c char(10), index(c)) collate ucs2_czech_ci engine=ibmdb2i;
+insert into t1 values ("ch"),("h"),("i");
+select * from t1 order by c;
+c
+h
+ch
+i
+drop table t1;
+create table t1 (c char(10), index(c)) collate utf8_czech_ci engine=ibmdb2i;
+insert into t1 values ("ch"),("h"),("i");
+select * from t1 order by c;
+c
+h
+ch
+i
+drop table t1;
+create table t1 (c char(10), index(c)) collate ucs2_danish_ci engine=ibmdb2i;
+insert into t1 values("abc"),("abcd"),("aaaa");
+select c from t1 order by c;
+c
+abc
+abcd
+aaaa
+drop table t1;
+create table t1 (c char(10), index(c)) collate utf8_danish_ci engine=ibmdb2i;
+insert into t1 values("abc"),("abcd"),("aaaa");
+select c from t1 order by c;
+c
+abc
+abcd
+aaaa
+drop table t1;

=== added file 'mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result'
--- a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result	2009-07-02 08:04:23 +0000
@@ -0,0 +1,7 @@
+drop table if exists t1;
+create table t1 (c char(10), index(c)) charset macce engine=ibmdb2i;
+insert into t1 values ("test");
+select * from t1 order by c;
+c
+test
+drop table t1;

=== added file 'mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result'
--- a/mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result	2009-07-06 08:49:32 +0000
@@ -0,0 +1,1204 @@
+drop table if exists t1, ffd, fd;
+CREATE TABLE t1 (armscii8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate armscii8_bin engine=ibmdb2i;
+CREATE TABLE t1 (armscii8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate armscii8_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (ascii_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ascii_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (ascii_bin char(10) primary key) collate ascii_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ascii_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ascii_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (ascii_general_ci char(10) primary key) collate ascii_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (big5_bin integer, c char(10), v varchar(20), index(c), index(v)) collate big5_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (big5_bin char(10) primary key) collate big5_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (big5_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate big5_chinese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (big5_chinese_ci char(10) primary key) collate big5_chinese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1250_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1250_bin char(10) primary key) collate cp1250_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1250_croatian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_croatian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1250_croatian_ci char(10) primary key) collate cp1250_croatian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1250_czech_cs integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_czech_cs engine=ibmdb2i;
+CREATE TABLE t1 (cp1250_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1250_general_ci char(10) primary key) collate cp1250_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1250_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_polish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1250_polish_ci char(10) primary key) collate cp1250_polish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1251_bin char(10) primary key) collate cp1251_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_bulgarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_bulgarian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1251_bulgarian_ci char(10) primary key) collate cp1251_bulgarian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1251_general_ci char(10) primary key) collate cp1251_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_general_cs engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1251_general_cs char(10) primary key) collate cp1251_general_cs engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_ukrainian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_ukrainian_ci engine=ibmdb2i;
+CREATE TABLE t1 (cp1256_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1256_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1256_bin char(10) primary key) collate cp1256_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1256_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1256_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp1256_general_ci char(10) primary key) collate cp1256_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1257_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_bin engine=ibmdb2i;
+CREATE TABLE t1 (cp1257_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (cp1257_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_lithuanian_ci engine=ibmdb2i;
+CREATE TABLE t1 (cp850_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp850_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp850_bin char(10) primary key) collate cp850_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp850_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp850_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp850_general_ci char(10) primary key) collate cp850_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp852_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp852_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp852_bin char(10) primary key) collate cp852_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp852_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp852_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (cp852_general_ci char(10) primary key) collate cp852_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp866_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp866_bin engine=ibmdb2i;
+CREATE TABLE t1 (cp866_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp866_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (cp932_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp932_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (cp932_bin char(10) primary key) collate cp932_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp932_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp932_japanese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (cp932_japanese_ci char(10) primary key) collate cp932_japanese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (dec8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate dec8_bin engine=ibmdb2i;
+CREATE TABLE t1 (dec8_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate dec8_swedish_ci engine=ibmdb2i;
+CREATE TABLE t1 (eucjpms_bin integer, c char(10), v varchar(20), index(c), index(v)) collate eucjpms_bin engine=ibmdb2i;
+CREATE TABLE t1 (eucjpms_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate eucjpms_japanese_ci engine=ibmdb2i;
+CREATE TABLE t1 (euckr_bin integer, c char(10), v varchar(20), index(c), index(v)) collate euckr_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (euckr_bin char(10) primary key) collate euckr_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (euckr_korean_ci integer, c char(10), v varchar(20), index(c), index(v)) collate euckr_korean_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (euckr_korean_ci char(10) primary key) collate euckr_korean_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (gb2312_bin integer, c char(10), v varchar(20), index(c), index(v)) collate gb2312_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (gb2312_bin char(10) primary key) collate gb2312_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (gb2312_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate gb2312_chinese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (gb2312_chinese_ci char(10) primary key) collate gb2312_chinese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (gbk_bin integer, c char(10), v varchar(20), index(c), index(v)) collate gbk_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (gbk_bin char(10) primary key) collate gbk_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (gbk_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate gbk_chinese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (gbk_chinese_ci char(10) primary key) collate gbk_chinese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (geostd8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate geostd8_bin engine=ibmdb2i;
+CREATE TABLE t1 (geostd8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate geostd8_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (greek_bin integer, c char(10), v varchar(20), index(c), index(v)) collate greek_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (greek_bin char(10) primary key) collate greek_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (greek_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate greek_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (greek_general_ci char(10) primary key) collate greek_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (hebrew_bin integer, c char(10), v varchar(20), index(c), index(v)) collate hebrew_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (hebrew_bin char(10) primary key) collate hebrew_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (hebrew_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate hebrew_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (hebrew_general_ci char(10) primary key) collate hebrew_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (hp8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate hp8_bin engine=ibmdb2i;
+CREATE TABLE t1 (hp8_english_ci integer, c char(10), v varchar(20), index(c), index(v)) collate hp8_english_ci engine=ibmdb2i;
+CREATE TABLE t1 (keybcs2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate keybcs2_bin engine=ibmdb2i;
+CREATE TABLE t1 (keybcs2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate keybcs2_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (koi8r_bin integer, c char(10), v varchar(20), index(c), index(v)) collate koi8r_bin engine=ibmdb2i;
+CREATE TABLE t1 (koi8r_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate koi8r_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (koi8u_bin integer, c char(10), v varchar(20), index(c), index(v)) collate koi8u_bin engine=ibmdb2i;
+CREATE TABLE t1 (koi8u_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate koi8u_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (latin1_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin1_bin char(10) primary key) collate latin1_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_danish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin1_danish_ci char(10) primary key) collate latin1_danish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin1_general_ci char(10) primary key) collate latin1_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_general_cs engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin1_general_cs char(10) primary key) collate latin1_general_cs engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_german1_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_german1_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin1_german1_ci char(10) primary key) collate latin1_german1_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_german2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_german2_ci engine=ibmdb2i;
+CREATE TABLE t1 (latin1_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_spanish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin1_spanish_ci char(10) primary key) collate latin1_spanish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_swedish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin1_swedish_ci char(10) primary key) collate latin1_swedish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin2_bin char(10) primary key) collate latin2_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin2_croatian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_croatian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin2_croatian_ci char(10) primary key) collate latin2_croatian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin2_czech_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_czech_cs engine=ibmdb2i;
+CREATE TABLE t1 (latin2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin2_general_ci char(10) primary key) collate latin2_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin2_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_hungarian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin2_hungarian_ci char(10) primary key) collate latin2_hungarian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin5_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin5_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin5_bin char(10) primary key) collate latin5_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin5_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin5_turkish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (latin5_turkish_ci char(10) primary key) collate latin5_turkish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin7_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_bin engine=ibmdb2i;
+CREATE TABLE t1 (latin7_estonian_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_estonian_cs engine=ibmdb2i;
+CREATE TABLE t1 (latin7_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (latin7_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_general_cs engine=ibmdb2i;
+CREATE TABLE t1 (macce_bin integer, c char(10), v varchar(20), index(c), index(v)) collate macce_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (macce_bin char(10) primary key) collate macce_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (macce_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate macce_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (macce_general_ci char(10) primary key) collate macce_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (macroman_bin integer, c char(10), v varchar(20), index(c), index(v)) collate macroman_bin engine=ibmdb2i;
+CREATE TABLE t1 (macroman_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate macroman_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (sjis_bin integer, c char(10), v varchar(20), index(c), index(v)) collate sjis_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (sjis_bin char(10) primary key) collate sjis_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (sjis_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate sjis_japanese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (sjis_japanese_ci char(10) primary key) collate sjis_japanese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (swe7_bin integer, c char(10), v varchar(20), index(c), index(v)) collate swe7_bin engine=ibmdb2i;
+CREATE TABLE t1 (swe7_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate swe7_swedish_ci engine=ibmdb2i;
+CREATE TABLE t1 (tis620_bin integer, c char(10), v varchar(20), index(c), index(v)) collate tis620_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (tis620_bin char(10) primary key) collate tis620_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (tis620_thai_ci integer, c char(10), v varchar(20), index(c), index(v)) collate tis620_thai_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	11	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	23	NULL	6	Using where
+drop table t1;
+create table t1 (tis620_thai_ci char(10) primary key) collate tis620_thai_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_bin char(10) primary key) collate ucs2_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_czech_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_czech_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_czech_ci char(10) primary key) collate ucs2_czech_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_danish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_danish_ci char(10) primary key) collate ucs2_danish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_esperanto_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_esperanto_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_esperanto_ci char(10) primary key) collate ucs2_esperanto_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_estonian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_estonian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_estonian_ci char(10) primary key) collate ucs2_estonian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_general_ci char(10) primary key) collate ucs2_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_hungarian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_hungarian_ci char(10) primary key) collate ucs2_hungarian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_icelandic_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_icelandic_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_icelandic_ci char(10) primary key) collate ucs2_icelandic_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_latvian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_latvian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_latvian_ci char(10) primary key) collate ucs2_latvian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_lithuanian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_lithuanian_ci char(10) primary key) collate ucs2_lithuanian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_persian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_persian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_persian_ci char(10) primary key) collate ucs2_persian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_polish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_polish_ci char(10) primary key) collate ucs2_polish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_romanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_romanian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_romanian_ci char(10) primary key) collate ucs2_romanian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_roman_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_roman_ci engine=ibmdb2i;
+CREATE TABLE t1 (ucs2_slovak_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_slovak_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_slovak_ci char(10) primary key) collate ucs2_slovak_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_slovenian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_slovenian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_slovenian_ci char(10) primary key) collate ucs2_slovenian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_spanish2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_spanish2_ci engine=ibmdb2i;
+CREATE TABLE t1 (ucs2_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_spanish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_spanish_ci char(10) primary key) collate ucs2_spanish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_swedish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_swedish_ci char(10) primary key) collate ucs2_swedish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_turkish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_turkish_ci char(10) primary key) collate ucs2_turkish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_unicode_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_unicode_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	21	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	43	NULL	6	Using where
+drop table t1;
+create table t1 (ucs2_unicode_ci char(10) primary key) collate ucs2_unicode_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ujis_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ujis_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (ujis_bin char(10) primary key) collate ujis_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ujis_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ujis_japanese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (ujis_japanese_ci char(10) primary key) collate ujis_japanese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_bin char(10) primary key) collate utf8_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_czech_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_czech_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_czech_ci char(10) primary key) collate utf8_czech_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_danish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_danish_ci char(10) primary key) collate utf8_danish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_esperanto_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_esperanto_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_esperanto_ci char(10) primary key) collate utf8_esperanto_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_estonian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_estonian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_estonian_ci char(10) primary key) collate utf8_estonian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_general_ci char(10) primary key) collate utf8_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_hungarian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_hungarian_ci char(10) primary key) collate utf8_hungarian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_icelandic_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_icelandic_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_icelandic_ci char(10) primary key) collate utf8_icelandic_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_latvian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_latvian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_latvian_ci char(10) primary key) collate utf8_latvian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_lithuanian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_lithuanian_ci char(10) primary key) collate utf8_lithuanian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_persian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_persian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_persian_ci char(10) primary key) collate utf8_persian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_polish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_polish_ci char(10) primary key) collate utf8_polish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_romanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_romanian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_romanian_ci char(10) primary key) collate utf8_romanian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_roman_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_roman_ci engine=ibmdb2i;
+CREATE TABLE t1 (utf8_slovak_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_slovak_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_slovak_ci char(10) primary key) collate utf8_slovak_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_slovenian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_slovenian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_slovenian_ci char(10) primary key) collate utf8_slovenian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_spanish2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_spanish2_ci engine=ibmdb2i;
+CREATE TABLE t1 (utf8_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_spanish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_spanish_ci char(10) primary key) collate utf8_spanish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_swedish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_swedish_ci char(10) primary key) collate utf8_swedish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_turkish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_turkish_ci char(10) primary key) collate utf8_turkish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_unicode_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_unicode_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	c	c	31	NULL	6	Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	v	v	63	NULL	6	Using where
+drop table t1;
+create table t1 (utf8_unicode_ci char(10) primary key) collate utf8_unicode_ci engine=ibmdb2i;
+drop table t1;
+create table ffd (WHCHD1 CHAR(20), WHCSID decimal(5,0)) engine=ibmdb2i;
+create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i;
+create temporary table intermed (row integer key auto_increment, cs char(30), ccsid integer);
+insert into intermed (cs, ccsid) select * from ffd;
+create temporary table intermed2 (row integer key auto_increment, srtseq char(10));
+insert into intermed2 (srtseq) select * from fd;
+select ccsid, cs, srtseq from intermed inner join intermed2 on intermed.row = intermed2.row;
+ccsid	cs	srtseq
+500	"ascii_bin"	QBLA101F4U
+500	"ascii_general_ci"	QALA101F4S
+1200	"big5_bin"	QBCHT04B0U
+1200	"big5_chinese_ci"	QACHT04B0S
+1153	"cp1250_bin"	QELA20481U
+1153	"cp1250_croatian_ci"	QALA20481S
+1153	"cp1250_general_ci"	QCLA20481S
+1153	"cp1250_polish_ci"	QDLA20481S
+1025	"cp1251_bin"	QCCYR0401U
+1025	"cp1251_bulgarian_ci	QACYR0401S
+1025	"cp1251_general_ci"	QBCYR0401S
+1025	"cp1251_general_cs"	QBCYR0401U
+420	"cp1256_bin"	QBARA01A4U
+420	"cp1256_general_ci"	QAARA01A4S
+500	"cp850_bin"	QDLA101F4U
+500	"cp850_general_ci"	QCLA101F4S
+870	"cp852_bin"	QBLA20366U
+870	"cp852_general_ci"	QALA20366S
+1200	"cp932_bin"	QBJPN04B0U
+1200	"cp932_japanese_ci"	QAJPN04B0S
+1200	"euckr_bin"	QBKOR04B0U
+1200	"euckr_korean_ci"	QAKOR04B0S
+1200	"gb2312_bin"	QBCHS04B0U
+1200	"gb2312_chinese_ci"	QACHS04B0S
+1200	"gbk_bin"	QDCHS04B0U
+1200	"gbk_chinese_ci"	QCCHS04B0S
+875	"greek_bin"	QBELL036BU
+875	"greek_general_ci"	QAELL036BS
+424	"hebrew_bin"	QBHEB01A8U
+424	"hebrew_general_ci"	QAHEB01A8S
+1148	"latin1_bin"	QFLA1047CU
+1148	"latin1_danish_ci"	QALA1047CS
+1148	"latin1_general_ci"	QBLA1047CS
+1148	"latin1_general_cs"	QBLA1047CU
+1148	"latin1_german1_ci"	QCLA1047CS
+1148	"latin1_spanish_ci"	QDLA1047CS
+1148	"latin1_swedish_ci"	QELA1047CS
+870	"latin2_bin"	QGLA20366U
+870	"latin2_croatian_ci"	QCLA20366S
+870	"latin2_general_ci"	QELA20366S
+870	"latin2_hungarian_ci	QFLA20366S
+1026	"latin5_bin"	QBTRK0402U
+1026	"latin5_turkish_ci"	QATRK0402S
+870	"macce_bin"	QILA20366U
+870	"macce_general_ci"	QHLA20366S
+1200	"sjis_bin"	QDJPN04B0U
+1200	"sjis_japanese_ci"	QCJPN04B0S
+838	"tis620_bin"	QBTHA0346U
+838	"tis620_thai_ci"	QATHA0346S
+13488	"ucs2_bin"	*HEX
+13488	"ucs2_czech_ci"	I34ACS_CZ
+13488	"ucs2_danish_ci"	I34ADA_DK
+13488	"ucs2_esperanto_ci"	I34AEO
+13488	"ucs2_estonian_ci"	I34AET
+13488	"ucs2_general_ci"	QAUCS04B0S
+13488	"ucs2_hungarian_ci"	I34AHU
+13488	"ucs2_icelandic_ci"	I34AIS
+13488	"ucs2_latvian_ci"	I34ALV
+13488	"ucs2_lithuanian_ci"	I34ALT
+13488	"ucs2_persian_ci"	I34AFA
+13488	"ucs2_polish_ci"	I34APL
+13488	"ucs2_romanian_ci"	I34ARO
+13488	"ucs2_slovak_ci"	I34ASK
+13488	"ucs2_slovenian_ci"	I34ASL
+13488	"ucs2_spanish_ci"	I34AES
+13488	"ucs2_swedish_ci"	I34ASW
+13488	"ucs2_turkish_ci"	I34ATR
+13488	"ucs2_unicode_ci"	I34AEN
+1200	"ujis_bin"	QFJPN04B0U
+1200	"ujis_japanese_ci"	QEJPN04B0S
+1208	"utf8_bin"	*HEX
+1208	"utf8_czech_ci"	I34ACS_CZ
+1208	"utf8_danish_ci"	I34ADA_DK
+1208	"utf8_esperanto_ci"	I34AEO
+1208	"utf8_estonian_ci"	I34AET
+1200	"utf8_general_ci"	QAUCS04B0S
+1208	"utf8_hungarian_ci"	I34AHU
+1208	"utf8_icelandic_ci"	I34AIS
+1208	"utf8_latvian_ci"	I34ALV
+1208	"utf8_lithuanian_ci"	I34ALT
+1208	"utf8_persian_ci"	I34AFA
+1208	"utf8_polish_ci"	I34APL
+1208	"utf8_romanian_ci"	I34ARO
+1208	"utf8_slovak_ci"	I34ASK
+1208	"utf8_slovenian_ci"	I34ASL
+1208	"utf8_spanish_ci"	I34AES
+1208	"utf8_swedish_ci"	I34ASW
+1208	"utf8_turkish_ci"	I34ATR
+1208	"utf8_unicode_ci"	I34AEN
+drop table ffd, fd;

=== added file 'mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test'
--- a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test	2009-06-29 02:02:17 +0000
@@ -0,0 +1,26 @@
+source suite/ibmdb2i/include/have_ibmdb2i.inc;
+source suite/ibmdb2i/include/have_i61.inc;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (c char(10), index(c)) collate ucs2_czech_ci engine=ibmdb2i;
+insert into t1 values ("ch"),("h"),("i");
+select * from t1 order by c;
+drop table t1;
+
+create table t1 (c char(10), index(c)) collate utf8_czech_ci engine=ibmdb2i;
+insert into t1 values ("ch"),("h"),("i");
+select * from t1 order by c;
+drop table t1;
+
+create table t1 (c char(10), index(c)) collate ucs2_danish_ci engine=ibmdb2i;           
+insert into t1 values("abc"),("abcd"),("aaaa"); 
+select c from t1 order by c;
+drop table t1;
+
+create table t1 (c char(10), index(c)) collate utf8_danish_ci engine=ibmdb2i;           
+insert into t1 values("abc"),("abcd"),("aaaa"); 
+select c from t1 order by c;
+drop table t1;

=== added file 'mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test'
--- a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test	2009-07-02 08:04:23 +0000
@@ -0,0 +1,11 @@
+source suite/ibmdb2i/include/have_ibmdb2i.inc;
+source suite/ibmdb2i/include/have_i61.inc;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (c char(10), index(c)) charset macce engine=ibmdb2i;
+insert into t1 values ("test");
+select * from t1 order by c;
+drop table t1;

=== added file 'mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test'
--- a/mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test	2009-07-06 08:49:32 +0000
@@ -0,0 +1,44 @@
+source suite/ibmdb2i/include/have_ibmdb2i.inc;
+source suite/ibmdb2i/include/have_i61.inc;
+--disable_warnings
+drop table if exists t1, ffd, fd;
+--enable_warnings
+
+--disable_abort_on_error
+--error 0,255
+exec system "DLTF QGPL/FFDOUT" > /dev/null;
+--error 0,255
+exec system "DLTF QGPL/FDOUT" > /dev/null;
+--enable_abort_on_error
+let $count= query_get_value(select count(*) from information_schema.COLLATIONS where COLLATION_NAME <> "binary", count(*),1);
+
+while ($count)
+{
+  let $collation = query_get_value(select COLLATION_NAME from information_schema.COLLATIONS where COLLATION_NAME <> "binary" order by COLLATION_NAME desc, COLLATION_NAME, $count);
+  error 0,1005,2504,2028;
+  eval CREATE TABLE t1 ($collation integer, c char(10), v varchar(20), index(c), index(v)) collate $collation engine=ibmdb2i;
+  if (!$mysql_errno)
+  {
+      insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+      insert into t1 select * from t1;
+      explain select c,v from t1 force index(c) where c like "ab%";
+      explain select c,v from t1 force index(v) where v like "de%";
+      drop table t1;
+      eval create table t1 ($collation char(10) primary key) collate $collation engine=ibmdb2i;
+      system system "DSPFFD FILE(\"test\"/\"t1\") OUTPUT(*OUTFILE) OUTFILE(QGPL/FFDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
+      system system "DSPFD FILE(\"test\"/\"t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
+      drop table t1;
+  }
+  dec $count;
+}
+
+create table ffd (WHCHD1 CHAR(20), WHCSID decimal(5,0)) engine=ibmdb2i;
+system system "CPYF FROMFILE(QGPL/FFDOUT) TOFILE(\"test\"/\"ffd\") mbropt(*replace) fmtopt(*drop *map)"  > /dev/null;
+create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i;
+system system "CPYF FROMFILE(QGPL/FDOUT) TOFILE(\"test\"/\"fd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null;
+create temporary table intermed (row integer key auto_increment, cs char(30), ccsid integer);
+insert into intermed (cs, ccsid) select * from ffd;
+create temporary table intermed2 (row integer key auto_increment, srtseq char(10));
+insert into intermed2 (srtseq) select * from fd;
+select ccsid, cs, srtseq from intermed inner join intermed2 on intermed.row = intermed2.row;
+drop table ffd, fd;

=== added file 'mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result	2009-06-18 13:52:46 +0000
@@ -0,0 +1,135 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
+CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
+CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
+########################################################################################
+#                                   1 - SINGLE STATEMENT
+########################################################################################
+*** Single statement on transactional table ***
+Got one of the listed errors
+*** Single statement on non-transactional table ***
+*** After WL#2687 the difference between STATEMENT/MIXED and ROW will not exist. ***
+Got one of the listed errors
+*** Single statement on both transactional and non-transactional tables. ***
+*** After WL#2687 we will be able to change the order of the tables. ***
+Got one of the listed errors
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
+START SLAVE SQL_THREAD;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+source include/diff_master_slave.inc;
+########################################################################################
+#                                     3 - BEGIN - COMMIT
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+COMMIT;
+source include/diff_master_slave.inc;
+########################################################################################
+#                                      4 - BEGIN - ROLLBACK
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+source include/diff_master_slave.inc;
+########################################################################################
+#                                         5 - PROCEDURE 
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+CREATE PROCEDURE p1(pd VARCHAR(30000))
+BEGIN
+INSERT INTO t1 (a, data) VALUES (1, pd);
+INSERT INTO t1 (a, data) VALUES (2, pd);
+INSERT INTO t1 (a, data) VALUES (3, pd);
+INSERT INTO t1 (a, data) VALUES (4, pd);
+INSERT INTO t1 (a, data) VALUES (5, 's');
+END//
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+BEGIN;
+Got one of the listed errors
+COMMIT;
+TRUNCATE TABLE t1;
+BEGIN;
+Got one of the listed errors
+ROLLBACK;
+source include/diff_master_slave.inc;
+########################################################################################
+#                                           6 - XID
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+ROLLBACK TO sv;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+COMMIT;
+source include/diff_master_slave.inc;
+########################################################################################
+#                                        7 - NON-TRANS TABLE
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+COMMIT;
+BEGIN;
+Got one of the listed errors
+COMMIT;
+########################################################################################
+#                                        CLEAN
+########################################################################################
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP TABLE IF EXISTS t6;
+DROP PROCEDURE p1;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP TABLE IF EXISTS t6;
+DROP PROCEDURE p1;

=== added file 'mysql-test/suite/rpl/r/rpl_concurrency_error.result'
--- a/mysql-test/suite/rpl/r/rpl_concurrency_error.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_concurrency_error.result	2009-07-06 08:02:14 +0000
@@ -0,0 +1,119 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+########################################################################
+#                             Environment
+########################################################################
+CREATE TABLE t (i INT, PRIMARY KEY(i), f CHAR(8)) engine = Innodb;
+CREATE TABLE n (d DATETIME, f CHAR(32)) engine = MyIsam;
+CREATE TRIGGER tr AFTER UPDATE ON t FOR EACH ROW 
+BEGIN 
+INSERT INTO n VALUES ( now(), concat( 'updated t: ', old.f, ' -> ', new.f ) ); 
+END |
+INSERT INTO t VALUES (4,'black'), (2,'red'), (3,'yelow'), (1,'cyan');
+########################################################################
+#                     Testing ER_LOCK_WAIT_TIMEOUT
+########################################################################
+SET AUTOCOMMIT = 1;
+BEGIN;
+UPDATE t SET f = 'yellow 2' WHERE i = 3;
+SET AUTOCOMMIT = 1;
+BEGIN;
+UPDATE t SET f = 'magenta 2' WHERE f = 'red';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (5 + (2 * 10),"brown");
+INSERT INTO n VALUES (now(),"brown");
+COMMIT;
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; UPDATE t SET f = 'magenta 2' WHERE f = 'red'
+master-bin.000001	#	Query	#	#	ROLLBACK
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; UPDATE t SET f = 'yellow 2' WHERE i = 3
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t VALUES (5 + (2 * 10),"brown")
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO n VALUES (now(),"brown")
+master-bin.000001	#	Query	#	#	ROLLBACK
+SET AUTOCOMMIT = 1;
+BEGIN;
+UPDATE t SET f = 'gray 2' WHERE i = 3;
+SET AUTOCOMMIT = 1;
+BEGIN;
+UPDATE t SET f = 'dark blue 2' WHERE f = 'red';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (6 + (2 * 10),"brown");
+INSERT INTO n VALUES (now(),"brown");
+COMMIT;
+COMMIT;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; UPDATE t SET f = 'dark blue 2' WHERE f = 'red'
+master-bin.000001	#	Query	#	#	ROLLBACK
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; UPDATE t SET f = 'gray 2' WHERE i = 3
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t VALUES (6 + (2 * 10),"brown")
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO n VALUES (now(),"brown")
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+SET AUTOCOMMIT = 0;
+UPDATE t SET f = 'yellow 1' WHERE i = 3;
+SET AUTOCOMMIT = 0;
+UPDATE t SET f = 'magenta 1' WHERE f = 'red';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (5 + (1 * 10),"brown");
+INSERT INTO n VALUES (now(),"brown");
+COMMIT;
+ROLLBACK;
+Warnings:
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; UPDATE t SET f = 'magenta 1' WHERE f = 'red'
+master-bin.000001	#	Query	#	#	ROLLBACK
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; UPDATE t SET f = 'yellow 1' WHERE i = 3
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t VALUES (5 + (1 * 10),"brown")
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO n VALUES (now(),"brown")
+master-bin.000001	#	Query	#	#	ROLLBACK
+SET AUTOCOMMIT = 0;
+UPDATE t SET f = 'gray 1' WHERE i = 3;
+SET AUTOCOMMIT = 0;
+UPDATE t SET f = 'dark blue 1' WHERE f = 'red';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (6 + (1 * 10),"brown");
+INSERT INTO n VALUES (now(),"brown");
+COMMIT;
+COMMIT;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; UPDATE t SET f = 'dark blue 1' WHERE f = 'red'
+master-bin.000001	#	Query	#	#	ROLLBACK
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; UPDATE t SET f = 'gray 1' WHERE i = 3
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t VALUES (6 + (1 * 10),"brown")
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO n VALUES (now(),"brown")
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+source include/diff_master_slave.inc;
+source include/diff_master_slave.inc;
+########################################################################
+#                                Cleanup
+########################################################################
+DROP TRIGGER tr;
+DROP TABLE t;
+DROP TABLE n;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_reset_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result	2008-01-14 07:38:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result	2009-06-03 14:14:18 +0000
@@ -174,3 +174,26 @@ start slave;
 show status like 'slave_open_temp_tables';
 Variable_name	Value
 Slave_open_temp_tables	0
+stop slave;
+reset slave;
+*** errno must be zero: 0 ***
+change master to master_user='impossible_user_name';
+start slave;
+ONE
+1
+include/stop_slave.inc
+change master to master_user='root';
+include/start_slave.inc
+*** last errno must be  zero: 0 ***
+*** last error must be blank:  ***
+include/stop_slave.inc
+change master to master_user='impossible_user_name';
+start slave;
+ONE
+1
+include/stop_slave.inc
+reset slave;
+*** io  last errno must be  zero: 0  ***
+*** io  last error must be blank:   ***
+*** sql last errno must be  zero: 0 ***
+*** sql last error must be blank:  ***

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_reset_slave.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result	2008-01-14 07:38:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result	2009-06-03 14:14:18 +0000
@@ -174,3 +174,26 @@ start slave;
 show status like 'slave_open_temp_tables';
 Variable_name	Value
 Slave_open_temp_tables	1
+stop slave;
+reset slave;
+*** errno must be zero: 0 ***
+change master to master_user='impossible_user_name';
+start slave;
+ONE
+1
+include/stop_slave.inc
+change master to master_user='root';
+include/start_slave.inc
+*** last errno must be  zero: 0 ***
+*** last error must be blank:  ***
+include/stop_slave.inc
+change master to master_user='impossible_user_name';
+start slave;
+ONE
+1
+include/stop_slave.inc
+reset slave;
+*** io  last errno must be  zero: 0  ***
+*** io  last error must be blank:   ***
+*** sql last errno must be  zero: 0 ***
+*** sql last error must be blank:  ***

=== modified file 'mysql-test/suite/rpl/t/disabled.def'
--- a/mysql-test/suite/rpl/t/disabled.def	2009-06-12 13:40:02 +0000
+++ b/mysql-test/suite/rpl/t/disabled.def	2009-07-06 22:20:17 +0000
@@ -11,3 +11,5 @@
 ##############################################################################
 
 rpl_cross_version      : Bug#42311 2009-03-27 joro rpl_cross_version fails on macosx
+rpl_init_slave         : Bug#44920 2009-07006 pcrews MTR2 is not processing master.opt input properly on Windows.  *Must be done this way due to the nature of the bug*
+

=== added file 'mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt	2009-06-18 13:52:46 +0000
@@ -0,0 +1 @@
+--binlog_cache_size=4096 --max_binlog_cache_size=7680

=== added file 'mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test'
--- a/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test	2009-06-18 13:52:46 +0000
@@ -0,0 +1,395 @@
+########################################################################################
+#    This test verifies if the binlog is not corrupted when the cache buffer is not
+#    big enough to accommodate the changes and is divided in five steps:
+#
+#    1 - Single Statements:
+#    1.1 - Single statement on transactional table.
+#    1.2 - Single statement on non-transactional table. 
+#    1.3 - Single statement on both transactional and non-transactional tables.
+#    In both 1.2 and 1.3, an incident event is logged to notify the user that the
+#    master and slave are diverging.
+#
+#    2 - Transactions ended by an implicit commit.
+#
+#    3 - Transactions ended by a COMMIT.
+#
+#    4 - Transactions ended by a ROLLBACK.
+#
+#    5 - Transactions with a failing statement that updates a non-transactional
+#    table. In this case, a failure means that the statement does not get into
+#    the cache and an incident event is logged to notify the user that the master
+#    and slave are diverging.
+#    
+########################################################################################
+
+########################################################################################
+#                                Configuring the environment
+########################################################################################
+--source include/have_innodb.inc
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_windows.inc
+
+CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
+CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
+CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
+
+let $data = `select concat('"', repeat('a',2000), '"')`;
+
+--echo ########################################################################################
+--echo #                                   1 - SINGLE STATEMENT
+--echo ########################################################################################
+
+connection master;
+
+--echo *** Single statement on transactional table ***
+--disable_query_log
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+eval INSERT INTO t1 (a, data) VALUES (1,
+     CONCAT($data, $data, $data, $data, $data));
+--enable_query_log
+
+--echo *** Single statement on non-transactional table ***
+--echo *** After WL#2687 the difference between STATEMENT/MIXED and ROW will not exist. ***
+--disable_query_log
+--disable_warnings
+if (`SELECT @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
+{
+  eval INSERT INTO t2 (a, data) VALUES (2,
+       CONCAT($data, $data, $data, $data, $data, $data));
+  --echo Got one of the listed errors
+}
+if (`SELECT @@binlog_format = 'ROW'`)
+{
+  --error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+  eval INSERT INTO t2 (a, data) VALUES (2,
+       CONCAT($data, $data, $data, $data, $data, $data));
+
+  connection slave;
+  --source include/wait_for_slave_sql_to_stop.inc
+  SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
+  START SLAVE SQL_THREAD;
+  --source include/wait_for_slave_sql_to_start.inc
+}
+--enable_warnings
+--enable_query_log
+
+connection master;
+
+--disable_query_log
+eval INSERT INTO t1 (a, data) VALUES (3, $data);
+eval INSERT INTO t1 (a, data) VALUES (4, $data);
+eval INSERT INTO t1 (a, data) VALUES (5, $data);
+eval INSERT INTO t2 (a, data) VALUES (3, $data);
+eval INSERT INTO t2 (a, data) VALUES (4, $data);
+eval INSERT INTO t2 (a, data) VALUES (5, $data);
+--enable_query_log
+
+--echo *** Single statement on both transactional and non-transactional tables. ***
+--echo *** After WL#2687 we will be able to change the order of the tables. ***
+--disable_query_log
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+eval UPDATE t2, t1 SET t2.data = CONCAT($data, $data, $data, $data),
+                       t1.data = CONCAT($data, $data, $data, $data);
+--enable_query_log
+
+connection slave;
+--source include/wait_for_slave_sql_to_stop.inc
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
+START SLAVE SQL_THREAD;
+--source include/wait_for_slave_sql_to_start.inc
+
+#--echo ########################################################################################
+#--echo #                             2 - BEGIN - IMPLICIT COMMIT by DDL
+#--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t1 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--eval INSERT INTO t1 (a, data) VALUES (7, 's');
+--eval INSERT INTO t2 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--enable_query_log
+
+--disable_query_log
+ALTER TABLE t3 ADD COLUMN d int;
+--enable_query_log
+
+--disable_query_log
+--eval INSERT INTO t2 (a, data) VALUES (10, $data);
+--eval INSERT INTO t2 (a, data) VALUES (11, $data);
+--eval INSERT INTO t2 (a, data) VALUES (12, $data);
+--eval INSERT INTO t2 (a, data) VALUES (13, $data);
+--enable_query_log
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (14, $data);
+--eval INSERT INTO t1 (a, data) VALUES (15, $data);
+--eval INSERT INTO t1 (a, data) VALUES (16, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (17, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (18, $data);
+--eval INSERT INTO t1 (a, data) VALUES (19, 's');
+--eval INSERT INTO t2 (a, data) VALUES (20, 's');
+--eval INSERT INTO t1 (a, data) VALUES (21, 's');
+--enable_query_log
+
+if (`SELECT @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
+{
+  --disable_query_log
+  CREATE TABLE t4 SELECT * FROM t1;
+  --enable_query_log
+  --echo Got one of the listed errors
+}
+if (`SELECT @@binlog_format = 'ROW'`)
+{
+  --disable_query_log
+  --error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+  CREATE TABLE t4 SELECT * FROM t1;
+  --enable_query_log
+}
+
+--disable_query_log
+--eval INSERT INTO t2 (a, data) VALUES (15, $data);
+--enable_query_log
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (22, $data);
+--eval INSERT INTO t1 (a, data) VALUES (23, $data);
+--eval INSERT INTO t1 (a, data) VALUES (24, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (25, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (26, $data);
+--eval INSERT INTO t1 (a, data) VALUES (27, 's');
+--eval INSERT INTO t2 (a, data) VALUES (28, 's');
+--eval INSERT INTO t1 (a, data) VALUES (29, 's');
+--enable_query_log
+
+--disable_query_log
+CREATE TABLE t5 (a int);
+--enable_query_log
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo #                                     3 - BEGIN - COMMIT
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t1 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--eval INSERT INTO t1 (a, data) VALUES (7, 's');
+--eval INSERT INTO t2 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--enable_query_log
+COMMIT;
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo #                                      4 - BEGIN - ROLLBACK
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t1 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--eval INSERT INTO t1 (a, data) VALUES (7, 's');
+--eval INSERT INTO t2 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--enable_query_log
+ROLLBACK;
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo #                                         5 - PROCEDURE 
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+DELIMITER //;
+
+CREATE PROCEDURE p1(pd VARCHAR(30000))
+BEGIN
+  INSERT INTO t1 (a, data) VALUES (1, pd);
+  INSERT INTO t1 (a, data) VALUES (2, pd);
+  INSERT INTO t1 (a, data) VALUES (3, pd);
+  INSERT INTO t1 (a, data) VALUES (4, pd);
+  INSERT INTO t1 (a, data) VALUES (5, 's');
+END//
+
+DELIMITER ;//
+
+TRUNCATE TABLE t1;
+
+--disable_query_log
+eval CALL p1($data);
+--enable_query_log
+
+TRUNCATE TABLE t1;
+
+BEGIN;
+--disable_query_log
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+eval CALL p1($data);
+--enable_query_log
+COMMIT;
+
+TRUNCATE TABLE t1;
+
+BEGIN;
+--disable_query_log
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+eval CALL p1($data);
+--enable_query_log
+ROLLBACK;
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo #                                           6 - XID
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t1 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+SAVEPOINT sv;
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--eval INSERT INTO t1 (a, data) VALUES (7, 's');
+--eval INSERT INTO t2 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--enable_query_log
+ROLLBACK TO sv;
+COMMIT;
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo #                                        7 - NON-TRANS TABLE
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t2 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (7, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval UPDATE t2 SET data= CONCAT($data, $data);
+--eval INSERT INTO t1 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--eval INSERT INTO t2 (a, data) VALUES (10, 's');
+--eval INSERT INTO t1 (a, data) VALUES (11, 's');
+--enable_query_log
+COMMIT;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (15, $data);
+--eval INSERT INTO t1 (a, data) VALUES (16, $data);
+--eval INSERT INTO t2 (a, data) VALUES (17, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (18, $data);
+--enable_query_log
+COMMIT;
+
+connection slave;
+--source include/wait_for_slave_sql_to_stop.inc
+
+--echo ########################################################################################
+--echo #                                        CLEAN
+--echo ########################################################################################
+
+--disable_warnings
+connection master;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP TABLE IF EXISTS t6;
+DROP PROCEDURE p1;
+connection slave;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP TABLE IF EXISTS t6;
+DROP PROCEDURE p1;
+--enable_warnings

=== added file 'mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt	2009-07-06 08:02:14 +0000
@@ -0,0 +1 @@
+--innodb-lock-wait-timeout=1

=== added file 'mysql-test/suite/rpl/t/rpl_concurrency_error.test'
--- a/mysql-test/suite/rpl/t/rpl_concurrency_error.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_concurrency_error.test	2009-07-06 08:02:14 +0000
@@ -0,0 +1,149 @@
+###############################################################################
+#BUG#44581 Slave stops when transaction with non-transactional table gets
+#lock wait timeout
+#
+# In STMT and MIXED modes, a statement that changes both non-transactional and
+# transactional tables must be written to the binary log whenever there are
+# changes to non-transactional tables. This means that the statement gets into
+# the # binary log even when the changes to the transactional tables fail. In
+# particular, in the presence of a failure such statement is annotated with the
+# error number and wrapped in a begin/rollback. On the slave, while applying
+# the statement, it is expected the same failure and the rollback prevents the
+# transactional changes to be persisted.
+
+# This test aims to verify if a statement that updates both transactional and
+# non-transacitonal tables and fails due to concurrency problems is correctly
+# processed by the slave in the sense that the statements get into the binary
+# log, the error is ignored and only the non-transactional tables are changed.
+###############################################################################
+
+--source include/master-slave.inc
+--source include/have_innodb.inc
+--source include/have_binlog_format_statement.inc
+
+--echo ########################################################################
+--echo #                             Environment
+--echo ########################################################################
+connection master;
+
+CREATE TABLE t (i INT, PRIMARY KEY(i), f CHAR(8)) engine = Innodb;
+CREATE TABLE n (d DATETIME, f CHAR(32)) engine = MyIsam;
+
+DELIMITER |;
+CREATE TRIGGER tr AFTER UPDATE ON t FOR EACH ROW 
+BEGIN 
+  INSERT INTO n VALUES ( now(), concat( 'updated t: ', old.f, ' -> ', new.f ) ); 
+END |
+DELIMITER ;|
+
+INSERT INTO t VALUES (4,'black'), (2,'red'), (3,'yelow'), (1,'cyan');
+
+connect (conn1, 127.0.0.1,root,,);
+connect (conn2, 127.0.0.1,root,,);
+
+--echo ########################################################################
+--echo #                     Testing ER_LOCK_WAIT_TIMEOUT
+--echo ########################################################################
+
+let $type=2;
+
+while ($type)
+{
+  let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
+  connection conn1;
+  if (`select $type = 2`)
+  {
+    SET AUTOCOMMIT = 1;
+    BEGIN;
+  }
+  if (`select $type = 1`)
+  {
+    SET AUTOCOMMIT = 0;
+  }
+  eval UPDATE t SET f = 'yellow $type' WHERE i = 3;
+  
+  connection conn2;
+  if (`select $type = 2`)
+  {
+    SET AUTOCOMMIT = 1;
+    BEGIN;
+  }
+  if (`select $type = 1`)
+  {
+    SET AUTOCOMMIT = 0;
+  }
+  --error ER_LOCK_WAIT_TIMEOUT
+  eval UPDATE t SET f = 'magenta $type' WHERE f = 'red';
+  eval INSERT INTO t VALUES (5 + ($type * 10),"brown");
+  INSERT INTO n VALUES (now(),"brown");
+  
+  connection conn1;
+  COMMIT;
+  
+  connection conn2;
+  ROLLBACK;
+  --source include/show_binlog_events.inc
+
+  let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
+  connection conn1;
+  if (`select $type = 2`)
+  {
+    SET AUTOCOMMIT = 1;
+    BEGIN;
+  }
+  if (`select $type = 1`)
+  {
+    SET AUTOCOMMIT = 0;
+  }
+  eval UPDATE t SET f = 'gray $type' WHERE i = 3;
+  
+  connection conn2;
+  if (`select $type = 2`)
+  {
+    SET AUTOCOMMIT = 1;
+    BEGIN;
+  }
+  if (`select $type = 1`)
+  {
+    SET AUTOCOMMIT = 0;
+  }
+  --error ER_LOCK_WAIT_TIMEOUT
+  eval UPDATE t SET f = 'dark blue $type' WHERE f = 'red';
+  eval INSERT INTO t VALUES (6 + ($type * 10),"brown");
+  INSERT INTO n VALUES (now(),"brown");
+  
+  connection conn1;
+  COMMIT;
+  
+  connection conn2;
+  COMMIT;
+  --source include/show_binlog_events.inc
+  
+  dec $type;
+}
+
+connection master;
+sync_slave_with_master;
+
+connection master;
+let $diff_statement= SELECT * FROM t order by i;
+source include/diff_master_slave.inc;
+
+connection master;
+let $diff_statement= SELECT * FROM n order by d, f;
+source include/diff_master_slave.inc;
+
+--echo ########################################################################
+--echo #                                Cleanup
+--echo ########################################################################
+
+connection master;
+DROP TRIGGER tr;
+DROP TABLE t;
+DROP TABLE n;
+
+sync_slave_with_master;
+
+connection master;
+disconnect conn1;
+disconnect conn2;

=== modified file 'mysql-test/suite/rpl/t/rpl_init_slave.test'
--- a/mysql-test/suite/rpl/t/rpl_init_slave.test	2009-06-12 13:40:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_init_slave.test	2009-07-06 22:20:17 +0000
@@ -1,9 +1,3 @@
-if(`SELECT CONVERT(@@version_compile_os using latin1) IN ("Win32", "Win64", "Windows")`)
-{
---skip Bug#44920 2009-05-18 pcrews MTR2 is not processing master.opt input properly on Windows
-}
-
-
 source include/master-slave.inc;
 
 #

=== modified file 'mysql-test/suite/rpl/t/rpl_sp.test'
--- a/mysql-test/suite/rpl/t/rpl_sp.test	2008-07-10 16:09:39 +0000
+++ b/mysql-test/suite/rpl/t/rpl_sp.test	2009-07-02 13:40:27 +0000
@@ -642,3 +642,6 @@ drop procedure ` mysqltestbug36570_p2`;
 drop function mysqltestbug36570_f1;
 --echo End of 5.0 tests
 --echo End of 5.1 tests
+
+# Cleanup
+sync_slave_with_master;

=== modified file 'mysql-test/suite/rpl_ndb/t/disabled.def'
--- a/mysql-test/suite/rpl_ndb/t/disabled.def	2009-02-04 10:13:54 +0000
+++ b/mysql-test/suite/rpl_ndb/t/disabled.def	2009-07-06 15:17:39 +0000
@@ -11,3 +11,4 @@
 ##############################################################################
 
 # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
+rpl_ndb_2ndb   : Bug#45974: rpl_ndb_2ndb fails sporadically

=== modified file 'mysql-test/t/ctype_cp932_binlog_stm.test'
--- a/mysql-test/t/ctype_cp932_binlog_stm.test	2009-05-05 06:55:22 +0000
+++ b/mysql-test/t/ctype_cp932_binlog_stm.test	2009-06-25 08:44:50 +0000
@@ -22,7 +22,7 @@ CALL bug18293("Foo's a Bar", _cp932 0xED
 SELECT HEX(s1),HEX(s2),d FROM t4|
 DROP PROCEDURE bug18293|
 DROP TABLE t4|
-SHOW BINLOG EVENTS FROM 369|
+SHOW BINLOG EVENTS FROM 370|
 delimiter ;|
 
 --echo End of 5.0 tests
@@ -31,8 +31,9 @@ delimiter ;|
 # #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump 
 # Note: 364 is a magic position (found experimentally, depends on 
 # the log's contents) that caused the server crash.
+
 --error 1220
-SHOW BINLOG EVENTS FROM 364;
+SHOW BINLOG EVENTS FROM 365;
 
 --echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
 CREATE TABLE t1 (a varchar(16)) character set cp932;

=== added file 'mysql-test/t/ctype_gbk_binlog.test'
--- a/mysql-test/t/ctype_gbk_binlog.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/ctype_gbk_binlog.test	2009-07-07 14:18:44 +0000
@@ -0,0 +1,36 @@
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/have_gbk.inc
+
+SET NAMES gbk;
+--character_set gbk
+
+CREATE TABLE t1 (
+  f1 BLOB
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+delimiter |;
+CREATE PROCEDURE p1(IN val BLOB)
+BEGIN
+     SET @tval = val;
+     SET @sql_cmd = CONCAT_WS(' ', 'insert into t1(f1) values(?)');
+     PREPARE stmt FROM @sql_cmd;
+     EXECUTE stmt USING @tval;
+     DEALLOCATE PREPARE stmt;
+END|
+delimiter ;|
+
+SET @`tcontent`:=_binary 0x50434B000900000000000000E9000000 COLLATE `binary`/*!*/;
+CALL p1(@`tcontent`);
+
+FLUSH LOGS;
+DROP PROCEDURE p1;
+RENAME TABLE t1 to t2;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+--exec $MYSQL_BINLOG --force-if-open --short-form $MYSQLD_DATADIR/master-bin.000001 | $MYSQL
+SELECT hex(f1) FROM t2;
+SELECT hex(f1) FROM t1;
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
+DROP TABLE t2;

=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def	2009-06-15 15:27:58 +0000
+++ b/mysql-test/t/disabled.def	2009-07-06 22:20:17 +0000
@@ -12,3 +12,5 @@
 kill                     : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
 innodb_bug39438          : Bug#42383 2009-01-28 lsoares "This fails in embedded and on windows.  Note that this test is not run on windows and on embedded in PB for main trees currently"
 query_cache_28249        : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
+init_connect             : Bug#44920 2009-07-06 pcrews MTR not processing master.opt input properly on Windows.  *Must be done this way due to the nature of the bug*
+

=== modified file 'mysql-test/t/func_set.test'
--- a/mysql-test/t/func_set.test	2009-04-23 07:50:34 +0000
+++ b/mysql-test/t/func_set.test	2009-06-16 14:36:15 +0000
@@ -84,3 +84,16 @@ engine=myisam default charset=latin1;
 insert into t1 values (''),(null),(null),(''),(''),('');
 select find_in_set(f1,f1) as a from t1,(select find_in_set(f1,f1) as b from t1) a;
 drop table t1;
+#
+# Bug#45168: assertion with convert() and empty set value
+#
+CREATE TABLE t1( a SET('a', 'b', 'c') );
+CREATE TABLE t2( a SET('a', 'b', 'c') );
+
+INSERT INTO t1 VALUES ('d');
+INSERT INTO t2 VALUES ('');
+
+SELECT CONVERT( a USING latin1 ) FROM t1;
+SELECT CONVERT( a USING latin1 ) FROM t2;
+
+DROP TABLE t1, t2;

=== modified file 'mysql-test/t/gis.test'
--- a/mysql-test/t/gis.test	2009-04-29 02:59:10 +0000
+++ b/mysql-test/t/gis.test	2009-06-17 14:58:33 +0000
@@ -667,4 +667,28 @@ desc v1;
 drop view v1;
 drop table t1;
 
+#
+# Bug#44684: valgrind reports invalid reads in 
+# Item_func_spatial_collection::val_str
+#
+SELECT MultiPoint(12345,'');
+SELECT MultiPoint(123451,'');
+SELECT MultiPoint(1234512,'');
+SELECT MultiPoint(12345123,'');
+
+SELECT MultiLineString(12345,'');
+SELECT MultiLineString(123451,'');
+SELECT MultiLineString(1234512,'');
+SELECT MultiLineString(12345123,'');
+
+SELECT LineString(12345,'');
+SELECT LineString(123451,'');
+SELECT LineString(1234512,'');
+SELECT LineString(12345123,'');
+
+SELECT Polygon(12345,'');
+SELECT Polygon(123451,'');
+SELECT Polygon(1234512,'');
+SELECT Polygon(12345123,'');
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/init_connect.test'
--- a/mysql-test/t/init_connect.test	2009-06-12 13:40:02 +0000
+++ b/mysql-test/t/init_connect.test	2009-07-06 22:20:17 +0000
@@ -2,11 +2,6 @@
 # Test of init_connect variable
 #
 
-if(`SELECT CONVERT(@@version_compile_os using latin1) IN ("Win32", "Win64", "Windows")`)
-{
---skip Bug#44920 2009-05-18 pcrews MTR2 is not processing master.opt input properly on Windows
-}
-
 # should work with embedded server after mysqltest is fixed
 --source include/not_embedded.inc
 

=== added file 'mysql-test/t/innodb_bug40565.test'
--- a/mysql-test/t/innodb_bug40565.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug40565.test	2009-06-11 13:12:25 +0000
@@ -0,0 +1,10 @@
+# Bug #40565 Update Query Results in "1 Row Affected" But Should Be "Zero Rows"
+-- source include/have_innodb.inc
+
+create table bug40565(value decimal(4,2)) engine=innodb;
+insert into bug40565 values (1), (null);
+--enable_info
+update bug40565 set value=NULL;
+update bug40565 set value=NULL;
+--disable_info
+drop table bug40565;

=== added file 'mysql-test/t/innodb_bug45357.test'
--- a/mysql-test/t/innodb_bug45357.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_bug45357.test	2009-06-22 11:28:00 +0000
@@ -0,0 +1,10 @@
+-- source include/have_innodb.inc
+
+set session transaction isolation level read committed;
+
+create table bug45357(a int, b int,key(b))engine=innodb;
+insert into bug45357 values (25170,6122);
+update bug45357 set a=1 where b=30131;
+delete from bug45357 where b < 20996;
+delete from bug45357 where b < 7001;
+drop table bug45357;

=== added file 'mysql-test/t/mysql-bug45236.test'
--- a/mysql-test/t/mysql-bug45236.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysql-bug45236.test	2009-06-17 16:10:48 +0000
@@ -0,0 +1,45 @@
+#
+# Bug #45236: large blob inserts from mysqldump fail, possible memory issue ?
+#
+# This test consumes a significant amount of resources.
+# Therefore it should be kept separated from other tests.
+# Otherwise we might suffer from problems like
+# Bug#43801 mysql.test takes too long, fails due to expired timeout
+#           on debx86-b in PB
+#
+
+-- source include/not_embedded.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Have to change the global variable as the session variable is
+# read-only.
+SET @old_max_allowed_packet= @@global.max_allowed_packet;
+# ~1 MB blob length + some space for the rest of INSERT query
+SET @@global.max_allowed_packet = 1024 * 1024 + 1024;
+
+# Create a new connection since the global max_allowed_packet
+# has no effect onr the current one
+connect (con1, localhost, root,,);
+
+CREATE TABLE t1(data LONGBLOB);
+INSERT INTO t1 SELECT CONCAT(REPEAT('1', 1024*1024 - 27), 
+                             "\'\r dummydb dummyhost");
+
+let $outfile= $MYSQLTEST_VARDIR/tmp/bug41486.sql;
+--error 0,1
+remove_file $outfile;
+--exec $MYSQL_DUMP --compact -t test t1 > $outfile
+# Check that the mysql client does not interpret the "\r" sequence as a command
+--exec $MYSQL --max_allowed_packet=1M test < $outfile 2>&1
+
+DROP TABLE t1;
+
+# Cleanup
+disconnect con1;
+--source include/wait_until_disconnected.inc
+remove_file $outfile;
+connection default;
+SET @@global.max_allowed_packet = @old_max_allowed_packet;

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2009-06-16 09:59:57 +0000
+++ b/mysql-test/t/partition.test	2009-07-02 14:42:00 +0000
@@ -1976,6 +1976,17 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY
 
 DROP TABLE t1;
 
+--echo #
+--echo # Bug #45807: crash accessing partitioned table and sql_mode 
+--echo #   contains ONLY_FULL_GROUP_BY
+--echo #
+
+SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY';
+CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM 
+  PARTITION BY HASH(id) PARTITIONS 2;
+DROP TABLE t1;
+SET SESSION SQL_MODE=DEFAULT;
+
 --echo End of 5.1 tests
 
 SET @@global.general_log= @old_general_log;

=== modified file 'mysql-test/t/query_cache_debug.test'
--- a/mysql-test/t/query_cache_debug.test	2009-06-16 08:34:47 +0000
+++ b/mysql-test/t/query_cache_debug.test	2009-06-17 14:28:11 +0000
@@ -206,10 +206,11 @@ LET $wait_condition= SELECT SQL_NO_CACHE
 --echo ** and finally release the mutex. The threads will continue to wait
 --echo ** until a broadcast signal reaches them causing both threads to 
 --echo ** come alive and check the condition.
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' LIMIT 1 INTO @thread_id;
+SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id;
 KILL QUERY @thread_id;
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' LIMIT 1 INTO @thread_id;
+SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id;
 KILL QUERY @thread_id;
+
 --echo **
 --echo ** Finally signal the DELETE statement on THD1 one last time.
 --echo ** The stmt will complete the query cache invalidation and return 

=== modified file 'mysql-test/t/select.test'
--- a/mysql-test/t/select.test	2009-04-28 00:27:38 +0000
+++ b/mysql-test/t/select.test	2009-06-26 19:57:42 +0000
@@ -3799,4 +3799,90 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE 
 EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20;
 DROP TABLE t1;
 
+
+--echo #
+--echo # Bug#45266: Uninitialized variable lead to an empty result.
+--echo #
+--disable_warnings
+drop table if exists A,AA,B,BB;
+CREATE TABLE `A` (
+  `pk` int(11) NOT NULL AUTO_INCREMENT,
+  `date_key` date NOT NULL,
+  `date_nokey` date NOT NULL,
+  `datetime_key` datetime NOT NULL,
+  `int_nokey` int(11) NOT NULL,
+  `time_key` time NOT NULL,
+  `time_nokey` time NOT NULL,
+  PRIMARY KEY (`pk`),
+  KEY `date_key` (`date_key`),
+  KEY `time_key` (`time_key`),
+  KEY `datetime_key` (`datetime_key`)
+);
+
+CREATE TABLE `AA` (
+  `pk` int(11) NOT NULL AUTO_INCREMENT,
+  `int_nokey` int(11) NOT NULL,
+  `time_key` time NOT NULL,
+  KEY `time_key` (`time_key`),
+  PRIMARY KEY (`pk`)
+);
+
+CREATE TABLE `B` (
+  `date_nokey` date NOT NULL,
+  `date_key` date NOT NULL,
+  `time_key` time NOT NULL,
+  `datetime_nokey` datetime NOT NULL,
+  `varchar_key` varchar(1) NOT NULL,
+  KEY `date_key` (`date_key`),
+  KEY `time_key` (`time_key`),
+  KEY `varchar_key` (`varchar_key`)
+);
+
+INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x');
+
+CREATE TABLE `BB` (
+  `pk` int(11) NOT NULL AUTO_INCREMENT,
+  `int_nokey` int(11) NOT NULL,
+  `date_key` date NOT NULL,
+  `varchar_nokey` varchar(1) NOT NULL,
+  `date_nokey` date NOT NULL,
+  PRIMARY KEY (`pk`),
+  KEY `date_key` (`date_key`)
+);
+
+INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18');
+# Test #1
+SELECT table1 . `pk` AS field1 
+  FROM 
+    (BB AS table1 INNER JOIN 
+      (AA AS table2 STRAIGHT_JOIN A AS table3 
+        ON ( table3 . `date_key` = table2 . `pk` ))
+       ON ( table3 . `datetime_key` = table2 . `int_nokey` ))
+  WHERE  ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`)
+  GROUP BY field1 ;
+
+SELECT table3 .`date_key` field1
+  FROM
+    B table1 LEFT JOIN B table3 JOIN
+      (BB table6 JOIN A table7 ON table6 .`varchar_nokey`)
+       ON table6 .`int_nokey` ON table6 .`date_key`
+  WHERE  NOT ( table1 .`varchar_key`  AND table7 .`pk`) GROUP  BY field1;
+
+# Test #2
+SELECT table4 . `time_nokey` AS field1 FROM 
+  (AA AS table1 CROSS JOIN 
+    (AA AS table2 STRAIGHT_JOIN 
+      (B AS table3 STRAIGHT_JOIN A AS table4 
+       ON ( table4 . `date_key` = table3 . `time_key` ))
+     ON ( table4 . `pk` = table3 . `date_nokey` ))
+   ON ( table4 . `time_key` = table3 . `datetime_nokey` ))
+  WHERE  ( table4 . `time_key` < table1 . `time_key` AND
+            table1 . `int_nokey` != 'f')
+  GROUP BY field1  ORDER BY field1 , field1;
+
+SELECT table1 .`time_key` field2  FROM B table1  LEFT JOIN  BB JOIN A table5 ON table5 .`date_nokey`  ON table5 .`int_nokey` GROUP  BY field2;
+--enable_warnings
+
+drop table A,AA,B,BB;
+--echo #end of test for bug#45266
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/sp-fib.test'
--- a/mysql-test/t/sp-fib.test	2009-06-04 11:53:15 +0000
+++ b/mysql-test/t/sp-fib.test	2009-07-03 08:23:16 +0000
@@ -22,13 +22,14 @@ begin
     begin
       declare x, y bigint unsigned;
       declare c cursor for select f from t3 order by f desc limit 2;
-
       open c;
       fetch c into y;
       fetch c into x;
-      close c;
       insert into t3 values (x+y);
       call fib(n-1);
+      ## Close the cursor AFTER the recursion to ensure that the stack
+      ## frame is somewhat intact.
+      close c;
     end;
   end if;
 end|
@@ -36,24 +37,17 @@ end|
 # Enable recursion
 set @@max_sp_recursion_depth= 20|
 
-# Minimum test: recursion of 3 levels
-
 insert into t3 values (0), (1)|
 
-call fib(3)|
+# The small number of recursion levels is intentional.
+# We need to avoid
+# Bug#15866 main.sp fails (thread stack limit
+#           insufficient for recursive call "fib(20)")
+# which affects some platforms.
+call fib(4)|
 
 select * from t3 order by f asc|
 
-truncate table t3|
-
-# The original test, 20 levels, ran into memory limits on some machines
-# and builds. Try 10 instead...
-
-insert into t3 values (0), (1)|
-
-call fib(10)|
-
-select * from t3 order by f asc|
 drop table t3|
 drop procedure fib|
 set @@max_sp_recursion_depth= 0|

=== modified file 'mysql-test/t/trigger.test'
--- a/mysql-test/t/trigger.test	2009-03-27 12:55:14 +0000
+++ b/mysql-test/t/trigger.test	2009-06-22 12:51:33 +0000
@@ -2370,4 +2370,30 @@ drop trigger trg1;
 drop trigger trg2;
 drop table t1, t2;
 
+#
+# Bug#44653: Server crash noticed when executing random queries with partitions.
+#
+CREATE TABLE t1 ( a INT, b INT );
+CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT );
+
+INSERT INTO t1 (a) VALUES (1);
+
+delimiter //;
+CREATE TRIGGER tr1
+BEFORE INSERT ON t2
+FOR EACH ROW 
+BEGIN 
+  UPDATE a_nonextisting_table SET a = 1;
+END//
+delimiter ;//
+
+--disable_abort_on_error
+CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1;
+--enable_abort_on_error
+
+# Caused failed assertion
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
 --echo End of 5.1 tests.

=== modified file 'mysql-test/t/trigger_notembedded.test'
--- a/mysql-test/t/trigger_notembedded.test	2008-02-28 11:21:44 +0000
+++ b/mysql-test/t/trigger_notembedded.test	2009-06-25 10:52:50 +0000
@@ -909,4 +909,27 @@ select * from t1;
 drop table t1;
 disconnect flush;
 
+#
+# Bug#45412 SHOW CREATE TRIGGER does not require privileges to disclose trigger data
+#
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a char(30)) ENGINE=MEMORY;
+CREATE TRIGGER db1.trg AFTER INSERT ON db1.t1 FOR EACH ROW
+ INSERT INTO db1.t1 VALUES('Some very sensitive data goes here');
+
+CREATE USER 'no_rights'@'localhost';
+REVOKE ALL ON *.* FROM 'no_rights'@'localhost';
+FLUSH PRIVILEGES;
+
+connect (con1,localhost,no_rights,,);
+SELECT trigger_name FROM INFORMATION_SCHEMA.TRIGGERS
+ WHERE trigger_schema = 'db1';
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+SHOW CREATE TRIGGER db1.trg;
+
+connection default;
+disconnect con1;
+DROP USER 'no_rights'@'localhost';
+DROP DATABASE db1;
+
 --echo End of 5.1 tests.

=== modified file 'mysql-test/t/type_newdecimal.test'
--- a/mysql-test/t/type_newdecimal.test	2008-11-17 15:43:10 +0000
+++ b/mysql-test/t/type_newdecimal.test	2009-07-03 10:36:04 +0000
@@ -1257,3 +1257,32 @@ select cast(-3.4 as decimal(2,1));
 select cast(99.6 as decimal(2,0));
 select cast(-13.4 as decimal(2,1));
 select cast(98.6 as decimal(2,0));
+
+--echo #
+--echo # Bug #45262: Bad effects with CREATE TABLE and DECIMAL
+--echo #
+
+CREATE TABLE t1 SELECT .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 SELECT 1 + .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 SELECT 1 * .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;

=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test	2009-05-19 04:25:36 +0000
+++ b/mysql-test/t/view.test	2009-07-03 08:39:22 +0000
@@ -3703,6 +3703,38 @@ DROP TABLE t1;
 --echo # -- End of test case for Bug#40825
 --echo
 
+--echo # 
+--echo # Bug #45806 crash when replacing into a view with a join!
+--echo # 
+CREATE TABLE t1(a INT UNIQUE);
+CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a;
+INSERT INTO t1 VALUES (1), (2);
+
+REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v1;
+REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v1;
+DELETE FROM t1 WHERE a=3;
+INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v1`.`a`= 1;
+SELECT * FROM v1;
+
+CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a;
+
+REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v2;
+REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v2;
+INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v2`.`a`= 1;
+SELECT * FROM v2;
+
+DROP VIEW v1;
+DROP VIEW v2;
+DROP TABLE t1;
+
+--echo # -- End of test case for Bug#45806
+
 --echo # -----------------------------------------------------------------
 --echo # -- End of 5.0 tests.
 --echo # -----------------------------------------------------------------

=== modified file 'mysql-test/t/xa.test'
--- a/mysql-test/t/xa.test	2009-06-05 22:16:54 +0000
+++ b/mysql-test/t/xa.test	2009-06-25 15:25:23 +0000
@@ -135,6 +135,20 @@ xa start 'a';
 xa end 'a';
 xa rollback 'a';
 
+#
+# Bug#45548: XA transaction without access to InnoDB tables crashes the server
+#
+
+xa start 'a';
+xa end 'a';
+xa prepare 'a';
+xa commit 'a';
+
+xa start 'a';
+xa end 'a';
+xa prepare 'a';
+xa commit 'a';
+
 # Wait till all disconnects are completed
 --source include/wait_until_count_sessions.inc
 

=== modified file 'mysys/hash.c'
--- a/mysys/hash.c	2009-03-20 11:35:00 +0000
+++ b/mysys/hash.c	2009-06-22 11:10:34 +0000
@@ -45,6 +45,32 @@ static uint calc_hash(const HASH *hash, 
   return nr1;
 }
 
+/**
+  @brief Initialize the hash
+  
+  @details
+
+  Initialize the hash, by defining and giving valid values for
+  its elements. The failure to allocate memory for the
+  hash->array element will not result in a fatal failure. The
+  dynamic array that is part of the hash will allocate memory
+  as required during insertion.
+
+  @param[in,out] hash         The hash that is initialized
+  @param[in]     charset      The charater set information
+  @param[in]     size         The hash size
+  @param[in]     key_offest   The key offset for the hash
+  @param[in]     key_length   The length of the key used in
+                              the hash
+  @param[in]     get_key      get the key for the hash
+  @param[in]     free_element pointer to the function that
+                              does cleanup
+  @param[in]     CALLER_INFO_PROTO flag that define the behaviour 
+                                   of the hash
+  @return        inidicates success or failure of initialization
+    @retval 0 success
+    @retval 1 failure
+*/
 my_bool
 _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
               ulong size, size_t key_offset, size_t key_length,
@@ -55,12 +81,6 @@ _my_hash_init(HASH *hash, uint growth_si
   DBUG_PRINT("enter",("hash: 0x%lx  size: %u", (long) hash, (uint) size));
 
   hash->records=0;
-  if (my_init_dynamic_array_ci(&hash->array, sizeof(HASH_LINK), size,
-                               growth_size))
-  {
-    hash->free=0;				/* Allow call to my_hash_free */
-    DBUG_RETURN(1);
-  }
   hash->key_offset=key_offset;
   hash->key_length=key_length;
   hash->blength=1;
@@ -68,7 +88,8 @@ _my_hash_init(HASH *hash, uint growth_si
   hash->free=free_element;
   hash->flags=flags;
   hash->charset=charset;
-  DBUG_RETURN(0);
+  DBUG_RETURN(my_init_dynamic_array_ci(&hash->array, 
+                                       sizeof(HASH_LINK), size, growth_size));
 }
 
 
@@ -114,6 +135,7 @@ void my_hash_free(HASH *hash)
   my_hash_free_elements(hash);
   hash->free= 0;
   delete_dynamic(&hash->array);
+  hash->blength= 0;
   DBUG_VOID_RETURN;
 }
 

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2009-05-14 12:03:33 +0000
+++ b/mysys/my_getopt.c	2009-06-25 13:55:26 +0000
@@ -20,6 +20,7 @@
 #include <mysys_err.h>
 #include <my_getopt.h>
 #include <errno.h>
+#include <m_string.h>
 
 typedef void (*init_func_p)(const struct my_option *option, uchar* *variable,
                             longlong value);
@@ -649,8 +650,18 @@ static int setval(const struct my_option
 	return EXIT_OUT_OF_MEMORY;
       break;
     case GET_ENUM:
-      if (((*(int*)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0)
-        return EXIT_ARGUMENT_INVALID;
+      if (((*(int*)result_pos)=
+             find_type(argument, opts->typelib, 2) - 1) < 0)
+      {
+        /*
+          Accept an integer representation of the enumerated item.
+        */
+        char *endptr;
+        unsigned int arg= (unsigned int) strtol(argument, &endptr, 10);
+        if (*endptr || arg >= opts->typelib->count)
+          return EXIT_ARGUMENT_INVALID;
+        *(int*)result_pos= arg;
+      }
       break;
     case GET_SET:
       *((ulonglong*)result_pos)= find_typeset(argument, opts->typelib, &err);

=== modified file 'scripts/mysqld_multi.sh'
--- a/scripts/mysqld_multi.sh	2009-04-28 18:28:03 +0000
+++ b/scripts/mysqld_multi.sh	2009-06-19 15:32:10 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 use Getopt::Long;
-use POSIX qw(strftime);
+use POSIX qw(strftime getcwd);
 
 $|=1;
 $VER="2.16";
@@ -295,6 +295,7 @@ sub start_mysqlds()
   {
     @options = defaults_for_group($groups[$i]);
 
+    $basedir_found= 0; # The default
     $mysqld_found= 1; # The default
     $mysqld_found= 0 if (!length($mysqld));
     $com= "$mysqld";
@@ -310,6 +311,14 @@ sub start_mysqlds()
 	$com= $options[$j];
         $mysqld_found= 1;
       }
+      elsif ("--basedir=" eq substr($options[$j], 0, 10))
+      {
+        $basedir= $options[$j];
+        $basedir =~ s/^--basedir=//;
+        $basedir_found= 1;
+        $options[$j]= quote_shell_word($options[$j]);
+        $tmp.= " $options[$j]";
+      }
       else
       {
 	$options[$j]= quote_shell_word($options[$j]);
@@ -337,7 +346,16 @@ sub start_mysqlds()
       print "group [$groups[$i]] separately.\n";
       exit(1);
     }
+    if ($basedir_found)
+    {
+      $curdir=getcwd();
+      chdir($basedir) or die "Can't change to datadir $basedir";
+    }
     system($com);
+    if ($basedir_found)
+    {
+      chdir($curdir) or die "Can't change back to original dir $curdir";
+    }
   }
   if (!$i && !$opt_no_log)
   {

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2009-05-15 12:57:51 +0000
+++ b/sql/ha_ndbcluster.cc	2009-06-19 08:24:43 +0000
@@ -1247,7 +1247,7 @@ int ha_ndbcluster::add_index_handle(THD 
   }
   if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX)
   {
-    char unique_index_name[FN_LEN];
+    char unique_index_name[FN_LEN + 1];
     static const char* unique_suffix= "$unique";
     m_has_unique_index= TRUE;
     strxnmov(unique_index_name, FN_LEN, index_name, unique_suffix, NullS);
@@ -5150,7 +5150,7 @@ int ha_ndbcluster::create(const char *na
   uchar *data= NULL, *pack_data= NULL;
   bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
   bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE);
-  char tablespace[FN_LEN];
+  char tablespace[FN_LEN + 1];
   NdbDictionary::Table::SingleUserMode single_user_mode= NdbDictionary::Table::SingleUserModeLocked;
 
   DBUG_ENTER("ha_ndbcluster::create");
@@ -5613,7 +5613,7 @@ int ha_ndbcluster::create_index(const ch
                                 NDB_INDEX_TYPE idx_type, uint idx_no)
 {
   int error= 0;
-  char unique_name[FN_LEN];
+  char unique_name[FN_LEN + 1];
   static const char* unique_suffix= "$unique";
   DBUG_ENTER("ha_ndbcluster::create_ordered_index");
   DBUG_PRINT("info", ("Creating index %u: %s", idx_no, name));  
@@ -6661,7 +6661,7 @@ int ndbcluster_discover(handlerton *hton
   size_t len;
   uchar* data= NULL;
   Ndb* ndb;
-  char key[FN_REFLEN];
+  char key[FN_REFLEN + 1];
   DBUG_ENTER("ndbcluster_discover");
   DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); 
 
@@ -6672,7 +6672,7 @@ int ndbcluster_discover(handlerton *hton
     ERR_RETURN(ndb->getNdbError());
   }
   NDBDICT* dict= ndb->getDictionary();
-  build_table_filename(key, sizeof(key), db, name, "", 0);
+  build_table_filename(key, sizeof(key) - 1, db, name, "", 0);
   /* ndb_share reference temporary */
   NDB_SHARE *share= get_share(key, 0, FALSE);
   if (share)
@@ -6837,9 +6837,9 @@ int ndbcluster_drop_database_impl(const 
     drop_list.push_back(thd->strdup(elmt.name));
   }
   // Drop any tables belonging to database
-  char full_path[FN_REFLEN];
+  char full_path[FN_REFLEN + 1];
   char *tmp= full_path +
-    build_table_filename(full_path, sizeof(full_path), dbname, "", "", 0);
+    build_table_filename(full_path, sizeof(full_path) - 1, dbname, "", "", 0);
   if (ndb->setDatabaseName(dbname))
   {
     ERR_RETURN(ndb->getNdbError());
@@ -6908,7 +6908,7 @@ int ndb_create_table_from_engine(THD *th
 int ndbcluster_find_all_files(THD *thd)
 {
   Ndb* ndb;
-  char key[FN_REFLEN];
+  char key[FN_REFLEN + 1];
   NDBDICT *dict;
   int unhandled, retries= 5, skipped;
   DBUG_ENTER("ndbcluster_find_all_files");
@@ -6966,7 +6966,7 @@ int ndbcluster_find_all_files(THD *thd)
     
       /* check if database exists */
       char *end= key +
-        build_table_filename(key, sizeof(key), elmt.database, "", "", 0);
+        build_table_filename(key, sizeof(key) - 1, elmt.database, "", "", 0);
       if (my_access(key, F_OK))
       {
         /* no such database defined, skip table */
@@ -7047,7 +7047,7 @@ int ndbcluster_find_files(handlerton *ht
   { // extra bracket to avoid gcc 2.95.3 warning
   uint i;
   Ndb* ndb;
-  char name[FN_REFLEN];
+  char name[FN_REFLEN + 1];
   HASH ndb_tables, ok_tables;
   NDBDICT::List list;
 
@@ -7117,7 +7117,8 @@ int ndbcluster_find_files(handlerton *ht
     DBUG_PRINT("info", ("%s", file_name->str));
     if (hash_search(&ndb_tables, (uchar*) file_name->str, file_name->length))
     {
-      build_table_filename(name, sizeof(name), db, file_name->str, reg_ext, 0);
+      build_table_filename(name, sizeof(name) - 1, db,
+                           file_name->str, reg_ext, 0);
       if (my_access(name, F_OK))
       {
         pthread_mutex_lock(&LOCK_open);
@@ -7139,7 +7140,8 @@ int ndbcluster_find_files(handlerton *ht
     }
     
     // Check for .ndb file with this name
-    build_table_filename(name, sizeof(name), db, file_name->str, ha_ndb_ext, 0);
+    build_table_filename(name, sizeof(name) - 1, db,
+                         file_name->str, ha_ndb_ext, 0);
     DBUG_PRINT("info", ("Check access for %s", name));
     if (my_access(name, F_OK))
     {
@@ -7182,7 +7184,7 @@ int ndbcluster_find_files(handlerton *ht
   /* setup logging to binlog for all discovered tables */
   {
     char *end, *end1= name +
-      build_table_filename(name, sizeof(name), db, "", "", 0);
+      build_table_filename(name, sizeof(name) - 1, db, "", "", 0);
     for (i= 0; i < ok_tables.records; i++)
     {
       file_name_str= (char*)hash_element(&ok_tables, i);
@@ -7204,7 +7206,8 @@ int ndbcluster_find_files(handlerton *ht
     file_name_str= (char*) hash_element(&ndb_tables, i);
     if (!hash_search(&ok_tables, (uchar*) file_name_str, strlen(file_name_str)))
     {
-      build_table_filename(name, sizeof(name), db, file_name_str, reg_ext, 0);
+      build_table_filename(name, sizeof(name) - 1,
+                           db, file_name_str, reg_ext, 0);
       if (my_access(name, F_OK))
       {
         DBUG_PRINT("info", ("%s must be discovered", file_name_str));
@@ -7584,7 +7587,7 @@ void ndbcluster_print_error(int error, c
 void ha_ndbcluster::set_dbname(const char *path_name, char *dbname)
 {
   char *end, *ptr, *tmp_name;
-  char tmp_buff[FN_REFLEN];
+  char tmp_buff[FN_REFLEN + 1];
  
   tmp_name= tmp_buff;
   /* Scan name from the end */
@@ -7610,7 +7613,7 @@ void ha_ndbcluster::set_dbname(const cha
     ptr++;
   }
 #endif
-  filename_to_tablename(tmp_name, dbname, FN_REFLEN);
+  filename_to_tablename(tmp_name, dbname, sizeof(tmp_buff) - 1);
 }
 
 /**
@@ -7630,7 +7633,7 @@ void
 ha_ndbcluster::set_tabname(const char *path_name, char * tabname)
 {
   char *end, *ptr, *tmp_name;
-  char tmp_buff[FN_REFLEN];
+  char tmp_buff[FN_REFLEN + 1];
 
   tmp_name= tmp_buff;
   /* Scan name from the end */
@@ -7651,7 +7654,7 @@ ha_ndbcluster::set_tabname(const char *p
     ptr++;
   }
 #endif
-  filename_to_tablename(tmp_name, tabname, FN_REFLEN);
+  filename_to_tablename(tmp_name, tabname, sizeof(tmp_buff) - 1);
 }
 
 /**
@@ -7837,11 +7840,12 @@ uint8 ha_ndbcluster::table_cache_type()
 uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
                          Uint64 *commit_count)
 {
-  char name[FN_REFLEN];
+  char name[FN_REFLEN + 1];
   NDB_SHARE *share;
   DBUG_ENTER("ndb_get_commitcount");
 
-  build_table_filename(name, sizeof(name), dbname, tabname, "", 0);
+  build_table_filename(name, sizeof(name) - 1,
+                       dbname, tabname, "", 0);
   DBUG_PRINT("enter", ("name: %s", name));
   pthread_mutex_lock(&ndbcluster_mutex);
   if (!(share=(NDB_SHARE*) hash_search(&ndbcluster_open_tables,
@@ -9945,7 +9949,7 @@ bool ha_ndbcluster::check_if_incompatibl
       ai=1;
   }
 
-  char tablespace_name[FN_LEN]; 
+  char tablespace_name[FN_LEN + 1]; 
   if (get_tablespace_name(current_thd, tablespace_name, FN_LEN))
   {
     if (create_info->tablespace) 

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2009-05-30 13:32:28 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2009-06-19 08:24:43 +0000
@@ -788,7 +788,7 @@ static int ndbcluster_create_ndb_apply_s
   if (g_ndb_cluster_connection->get_no_ready() <= 0)
     DBUG_RETURN(0);
 
-  char buf[1024], *end;
+  char buf[1024 + 1], *end;
 
   if (ndb_extra_logging)
     sql_print_information("NDB: Creating " NDB_REP_DB "." NDB_APPLY_TABLE);
@@ -798,7 +798,7 @@ static int ndbcluster_create_ndb_apply_s
     if so, remove it since there is none in Ndb
   */
   {
-    build_table_filename(buf, sizeof(buf),
+    build_table_filename(buf, sizeof(buf) - 1,
                          NDB_REP_DB, NDB_APPLY_TABLE, reg_ext, 0);
     my_delete(buf, MYF(0));
   }
@@ -846,7 +846,7 @@ static int ndbcluster_create_schema_tabl
   if (g_ndb_cluster_connection->get_no_ready() <= 0)
     DBUG_RETURN(0);
 
-  char buf[1024], *end;
+  char buf[1024 + 1], *end;
 
   if (ndb_extra_logging)
     sql_print_information("NDB: Creating " NDB_REP_DB "." NDB_SCHEMA_TABLE);
@@ -856,7 +856,7 @@ static int ndbcluster_create_schema_tabl
     if so, remove it since there is none in Ndb
   */
   {
-    build_table_filename(buf, sizeof(buf),
+    build_table_filename(buf, sizeof(buf) - 1,
                          NDB_REP_DB, NDB_SCHEMA_TABLE, reg_ext, 0);
     my_delete(buf, MYF(0));
   }
@@ -1321,8 +1321,8 @@ int ndbcluster_log_schema_op(THD *thd, N
 
   NDB_SCHEMA_OBJECT *ndb_schema_object;
   {
-    char key[FN_REFLEN];
-    build_table_filename(key, sizeof(key), db, table_name, "", 0);
+    char key[FN_REFLEN + 1];
+    build_table_filename(key, sizeof(key) - 1, db, table_name, "", 0);
     ndb_schema_object= ndb_get_schema_object(key, TRUE, FALSE);
   }
 
@@ -1674,7 +1674,7 @@ ndb_handle_schema_change(THD *thd, Ndb *
   if (is_remote_change && is_online_alter_table)
   {
     const char *tabname= table_share->table_name.str;
-    char key[FN_REFLEN];
+    char key[FN_REFLEN + 1];
     uchar *data= 0, *pack_data= 0;
     size_t length, pack_length;
     int error;
@@ -1683,7 +1683,7 @@ ndb_handle_schema_change(THD *thd, Ndb *
     
     DBUG_PRINT("info", ("Detected frm change of table %s.%s",
                         dbname, tabname));
-    build_table_filename(key, FN_LEN-1, dbname, tabname, NullS, 0);
+    build_table_filename(key, FN_LEN - 1, dbname, tabname, NullS, 0);
     /*
       If the there is no local table shadowing the altered table and 
       it has an frm that is different than the one on disk then 
@@ -1926,8 +1926,8 @@ ndb_binlog_thread_handle_schema_event(TH
           break;
 	case SOT_TRUNCATE_TABLE:
         {
-          char key[FN_REFLEN];
-          build_table_filename(key, sizeof(key),
+          char key[FN_REFLEN + 1];
+          build_table_filename(key, sizeof(key) - 1,
                                schema->db, schema->name, "", 0);
           /* ndb_share reference temporary, free below */
           NDB_SHARE *share= get_share(key, 0, FALSE, FALSE);
@@ -2173,8 +2173,8 @@ ndb_binlog_thread_handle_schema_event_po
     int log_query= 0;
     {
       enum SCHEMA_OP_TYPE schema_type= (enum SCHEMA_OP_TYPE)schema->type;
-      char key[FN_REFLEN];
-      build_table_filename(key, sizeof(key), schema->db, schema->name, "", 0);
+      char key[FN_REFLEN + 1];
+      build_table_filename(key, sizeof(key) - 1, schema->db, schema->name, "", 0);
       if (schema_type == SOT_CLEAR_SLOCK)
       {
         pthread_mutex_lock(&ndbcluster_mutex);
@@ -2508,8 +2508,8 @@ ndb_rep_event_name(String *event_name,co
 bool
 ndbcluster_check_if_local_table(const char *dbname, const char *tabname)
 {
-  char key[FN_REFLEN];
-  char ndb_file[FN_REFLEN];
+  char key[FN_REFLEN + 1];
+  char ndb_file[FN_REFLEN + 1];
 
   DBUG_ENTER("ndbcluster_check_if_local_table");
   build_table_filename(key, FN_LEN-1, dbname, tabname, reg_ext, 0);
@@ -2534,9 +2534,9 @@ ndbcluster_check_if_local_tables_in_db(T
   DBUG_PRINT("info", ("Looking for files in directory %s", dbname));
   LEX_STRING *tabname;
   List<LEX_STRING> files;
-  char path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
 
-  build_table_filename(path, sizeof(path), dbname, "", "", 0);
+  build_table_filename(path, sizeof(path) - 1, dbname, "", "", 0);
   if (find_files(thd, &files, dbname, path, NullS, 0) != FIND_FILES_OK)
   {
     DBUG_PRINT("info", ("Failed to find files"));

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2009-06-09 16:44:26 +0000
+++ b/sql/handler.cc	2009-06-25 15:25:23 +0000
@@ -1242,9 +1242,10 @@ int ha_commit_one_phase(THD *thd, bool a
 #endif
       thd->variables.tx_isolation=thd->session_tx_isolation;
     }
-    if (is_real_trans)
-      thd->transaction.cleanup();
   }
+  /* Free resources and perform other cleanup even for 'empty' transactions. */
+  if (is_real_trans)
+    thd->transaction.cleanup();
 #endif /* USING_TRANSACTIONS */
   DBUG_RETURN(error);
 }
@@ -3582,7 +3583,7 @@ int ha_create_table_from_engine(THD* thd
   int error;
   uchar *frmblob;
   size_t frmlen;
-  char path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
   HA_CREATE_INFO create_info;
   TABLE table;
   TABLE_SHARE share;
@@ -3601,7 +3602,7 @@ int ha_create_table_from_engine(THD* thd
     frmblob and frmlen are set, write the frm to disk
   */
 
-  build_table_filename(path, FN_REFLEN-1, db, name, "", 0);
+  build_table_filename(path, sizeof(path) - 1, db, name, "", 0);
   // Save the frm file
   error= writefrm(path, frmblob, frmlen);
   my_free(frmblob, MYF(0));
@@ -4778,7 +4779,7 @@ fl_log_iterator_buffer_init(struct handl
   if ((ptr= (uchar*)my_malloc(ALIGN_SIZE(sizeof(fl_buff)) +
                              ((ALIGN_SIZE(sizeof(LEX_STRING)) +
                                sizeof(enum log_status) +
-                               + FN_REFLEN) *
+                               + FN_REFLEN + 1) *
                               (uint) dirp->number_off_files),
                              MYF(0))) == 0)
   {
@@ -4806,7 +4807,7 @@ fl_log_iterator_buffer_init(struct handl
     name_ptr= strxnmov(buff->names[buff->entries].str= name_ptr,
                        FN_REFLEN, fl_dir, file->name, NullS);
     buff->names[buff->entries].length= (name_ptr -
-                                        buff->names[buff->entries].str) - 1;
+                                        buff->names[buff->entries].str);
     buff->statuses[buff->entries]= st;
     buff->entries++;
   }

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2009-06-15 15:57:06 +0000
+++ b/sql/item.cc	2009-07-03 10:43:54 +0000
@@ -1507,10 +1507,6 @@ bool DTCollation::aggregate(DTCollation 
       {
         set(dt);
       }
-      else
-      {
-        // Do nothing
-      }
     }
     else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) &&
              left_is_superset(this, &dt))
@@ -2264,8 +2260,10 @@ Item_decimal::Item_decimal(const char *s
   name= (char*) str_arg;
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+                                                           decimals,
+                                                           decimals,
+                                                           unsigned_flag);
 }
 
 Item_decimal::Item_decimal(longlong val, bool unsig)
@@ -2273,8 +2271,10 @@ Item_decimal::Item_decimal(longlong val,
   int2my_decimal(E_DEC_FATAL_ERROR, val, unsig, &decimal_value);
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+                                                           decimals,
+                                                           decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -2283,8 +2283,10 @@ Item_decimal::Item_decimal(double val, i
   double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value);
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+                                                           decimals,
+                                                           decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -2304,8 +2306,10 @@ Item_decimal::Item_decimal(my_decimal *v
   my_decimal2decimal(value_par, &decimal_value);
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+                                                           decimals,
+                                                           decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -2315,8 +2319,8 @@ Item_decimal::Item_decimal(const uchar *
                     &decimal_value, precision, scale);
   decimals= (uint8) decimal_value.frac;
   fixed= 1;
-  max_length= my_decimal_precision_to_length(precision, decimals,
-                                             unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -2371,8 +2375,10 @@ void Item_decimal::set_decimal_value(my_
   my_decimal2decimal(value_par, &decimal_value);
   decimals= (uint8) decimal_value.frac;
   unsigned_flag= !decimal_value.sign();
-  max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
-                                             decimals, unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+                                                           decimals,
+                                                           decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -2644,8 +2650,9 @@ void Item_param::set_decimal(const char 
   str2my_decimal(E_DEC_FATAL_ERROR, str, &decimal_value, &end);
   state= DECIMAL_VALUE;
   decimals= decimal_value.frac;
-  max_length= my_decimal_precision_to_length(decimal_value.precision(),
-                                             decimals, unsigned_flag);
+  max_length=
+    my_decimal_precision_to_length_no_truncation(decimal_value.precision(),
+                                                 decimals, unsigned_flag);
   maybe_null= 0;
   DBUG_VOID_RETURN;
 }
@@ -2775,8 +2782,8 @@ bool Item_param::set_from_user_var(THD *
       CHARSET_INFO *tocs= thd->variables.collation_connection;
       uint32 dummy_offset;
 
-      value.cs_info.character_set_of_placeholder= 
-        value.cs_info.character_set_client= fromcs;
+      value.cs_info.character_set_of_placeholder= fromcs;
+      value.cs_info.character_set_client= thd->variables.character_set_client;
       /*
         Setup source and destination character sets so that they
         are different only if conversion is necessary: this will
@@ -2801,8 +2808,9 @@ bool Item_param::set_from_user_var(THD *
       my_decimal2decimal(ent_value, &decimal_value);
       state= DECIMAL_VALUE;
       decimals= ent_value->frac;
-      max_length= my_decimal_precision_to_length(ent_value->precision(),
-                                                 decimals, unsigned_flag);
+      max_length=
+        my_decimal_precision_to_length_no_truncation(ent_value->precision(),
+                                                     decimals, unsigned_flag);
       item_type= Item::DECIMAL_ITEM;
       break;
     }
@@ -4410,16 +4418,22 @@ mark_non_agg_field:
       Fields from outer selects added to the aggregate function
       outer_fields list as its unknown at the moment whether it's
       aggregated or not.
+      We're using either the select lex of the cached table (if present)
+      or the field's resolution context. context->select_lex is 
+      safe for use because it's either the SELECT we want to use 
+      (the current level) or a stub added by non-SELECT queries.
     */
+    SELECT_LEX *select_lex= cached_table ? 
+      cached_table->select_lex : context->select_lex;
     if (!thd->lex->in_sum_func)
-      cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
+      select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
     else
     {
       if (outer_fixed)
         thd->lex->in_sum_func->outer_fields.push_back(this);
       else if (thd->lex->in_sum_func->nest_level !=
           thd->lex->current_select->nest_level)
-        cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
+        select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
     }
   }
   return FALSE;
@@ -7294,8 +7308,9 @@ bool Item_type_holder::join_types(THD *t
     int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
     int precision= min(item_prec, DECIMAL_MAX_PRECISION);
     unsigned_flag&= item->unsigned_flag;
-    max_length= my_decimal_precision_to_length(precision, decimals,
-                                               unsigned_flag);
+    max_length= my_decimal_precision_to_length_no_truncation(precision,
+                                                             decimals,
+                                                             unsigned_flag);
   }
 
   switch (Field::result_merge_type(fld_type))

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2009-06-09 16:44:26 +0000
+++ b/sql/item_cmpfunc.cc	2009-07-03 10:36:04 +0000
@@ -2760,8 +2760,9 @@ void Item_func_case::fix_length_and_dec(
       agg_num_lengths(args[i + 1]);
     if (else_expr_num != -1) 
       agg_num_lengths(args[else_expr_num]);
-    max_length= my_decimal_precision_to_length(max_length + decimals, decimals,
-                                               unsigned_flag);
+    max_length= my_decimal_precision_to_length_no_truncation(max_length +
+                                                             decimals, decimals,
+                                                             unsigned_flag);
   }
 }
 

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2009-06-09 16:44:26 +0000
+++ b/sql/item_func.cc	2009-07-03 10:36:04 +0000
@@ -452,11 +452,45 @@ Field *Item_func::tmp_table_field(TABLE 
     return make_string_field(table);
     break;
   case DECIMAL_RESULT:
-    field= new Field_new_decimal(my_decimal_precision_to_length(decimal_precision(),
-                                                                decimals,
-                                                                unsigned_flag),
-                                 maybe_null, name, decimals, unsigned_flag);
+  {
+    uint8 dec= decimals;
+    uint8 intg= decimal_precision() - dec;
+    uint32 len= max_length;
+
+    /*
+      Trying to put too many digits overall in a DECIMAL(prec,dec)
+      will always throw a warning. We must limit dec to
+      DECIMAL_MAX_SCALE however to prevent an assert() later.
+    */
+
+    if (dec > 0)
+    {
+      int overflow;
+
+      dec= min(dec, DECIMAL_MAX_SCALE);
+
+      /*
+        If the value still overflows the field with the corrected dec,
+        we'll throw out decimals rather than integers. This is still
+        bad and of course throws a truncation warning.
+      */
+
+      const int required_length=
+        my_decimal_precision_to_length(intg + dec, dec,
+                                                     unsigned_flag);
+
+      overflow= required_length - len;
+
+      if (overflow > 0)
+        dec= max(0, dec - overflow);            // too long, discard fract
+      else
+        /* Corrected value fits. */
+        len= required_length;
+    }
+
+    field= new Field_new_decimal(len, maybe_null, name, dec, unsigned_flag);
     break;
+  }
   case ROW_RESULT:
   default:
     // This case should never be chosen
@@ -545,8 +579,8 @@ void Item_func::count_decimal_length()
     set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
   }
   int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-  max_length= my_decimal_precision_to_length(precision, decimals,
-                                             unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -1141,16 +1175,15 @@ void Item_func_additive_op::result_preci
   decimals= max(args[0]->decimals, args[1]->decimals);
   int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
   int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-  int est_prec= max(arg1_int, arg2_int) + 1 + decimals;
-  int precision= min(est_prec, DECIMAL_MAX_PRECISION);
+  int precision= max(arg1_int, arg2_int) + 1 + decimals;
 
   /* Integer operations keep unsigned_flag if one of arguments is unsigned */
   if (result_type() == INT_RESULT)
     unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
   else
     unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-  max_length= my_decimal_precision_to_length(precision, decimals,
-                                             unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -1255,7 +1288,8 @@ void Item_func_mul::result_precision()
   decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
   uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
   uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-  max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -1311,8 +1345,8 @@ void Item_func_div::result_precision()
   else
     unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
   decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-  max_length= my_decimal_precision_to_length(precision, decimals,
-                                             unsigned_flag);
+  max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+                                                           unsigned_flag);
 }
 
 
@@ -1999,8 +2033,9 @@ void Item_func_round::fix_length_and_dec
 
     precision-= decimals_delta - length_increase;
     decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-    max_length= my_decimal_precision_to_length(precision, decimals,
-                                               unsigned_flag);
+    max_length= my_decimal_precision_to_length_no_truncation(precision,
+                                                             decimals,
+                                                             unsigned_flag);
     break;
   }
   default:
@@ -2243,8 +2278,9 @@ void Item_func_min_max::fix_length_and_d
     }
   }
   else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT))
-    max_length= my_decimal_precision_to_length(max_int_part+decimals, decimals,
-                                            unsigned_flag);
+    max_length= my_decimal_precision_to_length_no_truncation(max_int_part +
+                                                             decimals, decimals,
+                                                             unsigned_flag);
   cached_field_type= agg_field_type(args, arg_count);
 }
 

=== modified file 'sql/item_func.h'
--- a/sql/item_func.h	2009-05-21 20:22:46 +0000
+++ b/sql/item_func.h	2009-07-03 10:36:04 +0000
@@ -378,7 +378,8 @@ public:
   Item_decimal_typecast(Item *a, int len, int dec) :Item_func(a)
   {
     decimals= dec;
-    max_length= my_decimal_precision_to_length(len, dec, unsigned_flag);
+    max_length= my_decimal_precision_to_length_no_truncation(len, dec,
+                                                             unsigned_flag);
   }
   String *val_str(String *str);
   double val_real();

=== modified file 'sql/item_geofunc.cc'
--- a/sql/item_geofunc.cc	2009-04-29 02:59:10 +0000
+++ b/sql/item_geofunc.cc	2009-06-17 14:58:33 +0000
@@ -416,7 +416,10 @@ String *Item_func_spatial_collection::va
     else
     {
       enum Geometry::wkbType wkb_type;
-      const char *data= res->ptr() + 4/*SRID*/ + 1;
+      const uint data_offset= 4/*SRID*/ + 1;
+      if (res->length() < data_offset + sizeof(uint32))
+        goto err;
+      const char *data= res->ptr() + data_offset;
 
       /*
 	In the case of named collection we must check that items
@@ -439,7 +442,7 @@ String *Item_func_spatial_collection::va
 	break;
 
       case Geometry::wkb_linestring:
-	if (str->append(data, POINT_DATA_SIZE, 512))
+	if (len < POINT_DATA_SIZE || str->append(data, POINT_DATA_SIZE, 512))
 	  goto err;
 	break;
       case Geometry::wkb_polygon:
@@ -448,11 +451,15 @@ String *Item_func_spatial_collection::va
 	double x1, y1, x2, y2;
 	const char *org_data= data;
 
-	if (len < 4 + 2 * POINT_DATA_SIZE)
+	if (len < 4)
 	  goto err;
 
 	n_points= uint4korr(data);
 	data+= 4;
+
+        if (n_points < 2 || len < 4 + n_points * POINT_DATA_SIZE)
+          goto err;
+        
 	float8get(x1, data);
 	data+= SIZEOF_STORED_DOUBLE;
 	float8get(y1, data);

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2009-06-15 15:57:06 +0000
+++ b/sql/item_strfunc.cc	2009-06-18 07:25:46 +0000
@@ -2710,13 +2710,12 @@ String *Item_func_conv_charset::val_str(
     return null_value ? 0 : &str_value;
   /* 
     Here we don't pass 'str' as a parameter to args[0]->val_str()
-    as 'str' may points to 'str_value' (e.g. see Item::save_in_field()),
+    as 'str' may point to 'str_value' (e.g. see Item::save_in_field()),
     which we use below to convert string. 
     Use argument's 'str_value' instead.
   */
-  String *arg= args[0]->val_str(&args[0]->str_value);;
+  String *arg= args[0]->val_str(&args[0]->str_value);
   uint dummy_errors;
-  arg= args[0]->val_str(&args[0]->str_value);  
   if (!arg)
   {
     null_value=1;

=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc	2009-06-15 15:57:06 +0000
+++ b/sql/item_sum.cc	2009-07-03 10:36:04 +0000
@@ -798,8 +798,9 @@ void Item_sum_sum::fix_length_and_dec()
   {
     /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */
     int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS;
-    max_length= my_decimal_precision_to_length(precision, decimals,
-                                               unsigned_flag);
+    max_length= my_decimal_precision_to_length_no_truncation(precision,
+                                                             decimals,
+                                                             unsigned_flag);
     curr_dec_buff= 0;
     hybrid_type= DECIMAL_RESULT;
     my_decimal_set_zero(dec_buffs);
@@ -1233,8 +1234,9 @@ void Item_sum_avg::fix_length_and_dec()
   {
     int precision= args[0]->decimal_precision() + prec_increment;
     decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-    max_length= my_decimal_precision_to_length(precision, decimals,
-                                               unsigned_flag);
+    max_length= my_decimal_precision_to_length_no_truncation(precision,
+                                                             decimals,
+                                                             unsigned_flag);
     f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
     f_scale=  args[0]->decimals;
     dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
@@ -1439,8 +1441,9 @@ void Item_sum_variance::fix_length_and_d
   {
     int precision= args[0]->decimal_precision()*2 + prec_increment;
     decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-    max_length= my_decimal_precision_to_length(precision, decimals,
-                                               unsigned_flag);
+    max_length= my_decimal_precision_to_length_no_truncation(precision,
+                                                             decimals,
+                                                             unsigned_flag);
 
     break;
   }

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2009-06-12 14:28:10 +0000
+++ b/sql/log.cc	2009-06-19 08:24:43 +0000
@@ -153,7 +153,8 @@ private:
 class binlog_trx_data {
 public:
   binlog_trx_data()
-    : at_least_one_stmt(0), m_pending(0), before_stmt_pos(MY_OFF_T_UNDEF)
+    : at_least_one_stmt(0), incident(FALSE), m_pending(0),
+    before_stmt_pos(MY_OFF_T_UNDEF)
   {
     trans_log.end_of_file= max_binlog_cache_size;
   }
@@ -184,6 +185,7 @@ public:
     delete pending();
     set_pending(0);
     reinit_io_cache(&trans_log, WRITE_CACHE, pos, 0, 0);
+    trans_log.end_of_file= max_binlog_cache_size;
     if (pos < before_stmt_pos)
       before_stmt_pos= MY_OFF_T_UNDEF;
 
@@ -206,6 +208,7 @@ public:
     if (!empty())
       truncate(0);
     before_stmt_pos= MY_OFF_T_UNDEF;
+    incident= FALSE;
     trans_log.end_of_file= max_binlog_cache_size;
     DBUG_ASSERT(empty());
   }
@@ -222,11 +225,22 @@ public:
 
   IO_CACHE trans_log;                         // The transaction cache
 
+  void set_incident(void)
+  {
+    incident= TRUE;
+  }
+  
+  bool has_incident(void)
+  {
+    return(incident);
+  }
+
   /**
     Boolean that is true if there is at least one statement in the
     transaction cache.
   */
   bool at_least_one_stmt;
+  bool incident;
 
 private:
   /*
@@ -942,7 +956,7 @@ bool LOGGER::slow_log_print(THD *thd, co
   bool error= FALSE;
   Log_event_handler **current_handler;
   bool is_command= FALSE;
-  char user_host_buff[MAX_USER_HOST_SIZE];
+  char user_host_buff[MAX_USER_HOST_SIZE + 1];
   Security_context *sctx= thd->security_ctx;
   uint user_host_len= 0;
   ulonglong query_utime, lock_utime;
@@ -1008,7 +1022,7 @@ bool LOGGER::general_log_write(THD *thd,
 {
   bool error= FALSE;
   Log_event_handler **current_handler= general_log_handler_list;
-  char user_host_buff[MAX_USER_HOST_SIZE];
+  char user_host_buff[MAX_USER_HOST_SIZE + 1];
   Security_context *sctx= thd->security_ctx;
   ulong id;
   uint user_host_len= 0;
@@ -1391,7 +1405,8 @@ binlog_end_trans(THD *thd, binlog_trx_da
   */
   if (end_ev != NULL)
   {
-    thd->binlog_flush_pending_rows_event(TRUE);
+    if (thd->binlog_flush_pending_rows_event(TRUE))
+      DBUG_RETURN(1);
     /*
       Doing a commit or a rollback including non-transactional tables,
       i.e., ending a transaction where we might write the transaction
@@ -1402,7 +1417,8 @@ binlog_end_trans(THD *thd, binlog_trx_da
       were, we would have to ensure that we're not ending a statement
       inside a stored function.
      */
-    error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev);
+    error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev,
+                               trx_data->has_incident());
     trx_data->reset();
 
     /*
@@ -1428,7 +1444,11 @@ binlog_end_trans(THD *thd, binlog_trx_da
      */
     thd->binlog_remove_pending_rows_event(TRUE);
     if (all || !(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT)))
+    {
+      if (trx_data->has_incident())
+        mysql_bin_log.write_incident(thd, TRUE);
       trx_data->reset();
+    }
     else                                        // ...statement
       trx_data->truncate(trx_data->before_stmt_pos);
 
@@ -1544,9 +1564,11 @@ static int binlog_rollback(handlerton *h
                        YESNO(all),
                        YESNO(thd->transaction.all.modified_non_trans_table),
                        YESNO(thd->transaction.stmt.modified_non_trans_table)));
-  if (all && thd->transaction.all.modified_non_trans_table ||
-      !all && thd->transaction.stmt.modified_non_trans_table ||
-      (thd->options & OPTION_KEEP_LOG))
+  if ((all && thd->transaction.all.modified_non_trans_table) ||
+      (!all && thd->transaction.stmt.modified_non_trans_table &&
+       !mysql_bin_log.check_write_error(thd)) ||
+      ((thd->options & OPTION_KEEP_LOG) &&
+        !mysql_bin_log.check_write_error(thd)))
   {
     /*
       We write the transaction cache with a rollback last if we have
@@ -1559,14 +1581,22 @@ static int binlog_rollback(handlerton *h
     Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, TRUE, 0);
     error= binlog_end_trans(thd, trx_data, &qev, all);
   }
-  else if (all && !thd->transaction.all.modified_non_trans_table ||
-           !all && !thd->transaction.stmt.modified_non_trans_table)
+  else
   {
     /*
-      If we have modified only transactional tables, we can truncate
-      the transaction cache without writing anything to the binary
-      log.
+      We reach this point if either only transactional tables were modified or
+      the effect of a statement that did not get into the binlog needs to be
+      rolled back. In the latter case, if a statement changed non-transactional
+      tables or had the OPTION_KEEP_LOG associated, we write an incident event
+      to the binlog in order to stop slaves and notify users that some changes
+      on the master did not get into the binlog and slaves will be inconsistent.
+      On the other hand, if a statement is transactional, we just safely roll it
+      back.
      */
+    if ((thd->transaction.stmt.modified_non_trans_table ||
+        (thd->options & OPTION_KEEP_LOG)) &&
+        mysql_bin_log.check_write_error(thd))
+      trx_data->set_incident();
     error= binlog_end_trans(thd, trx_data, 0, all);
   }
   if (!all)
@@ -1574,6 +1604,44 @@ static int binlog_rollback(handlerton *h
   DBUG_RETURN(error);
 }
 
+void MYSQL_BIN_LOG::set_write_error(THD *thd)
+{
+  DBUG_ENTER("MYSQL_BIN_LOG::set_write_error");
+
+  write_error= 1;
+
+  if (check_write_error(thd))
+    DBUG_VOID_RETURN;
+
+  if (my_errno == EFBIG)
+    my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(MY_WME));
+  else
+    my_error(ER_ERROR_ON_WRITE, MYF(MY_WME), name, errno);
+
+  DBUG_VOID_RETURN;
+}
+
+bool MYSQL_BIN_LOG::check_write_error(THD *thd)
+{
+  DBUG_ENTER("MYSQL_BIN_LOG::check_write_error");
+
+  bool checked= FALSE;
+
+  if (!thd->is_error())
+    DBUG_RETURN(checked);
+
+  switch (thd->main_da.sql_errno())
+  {
+    case ER_TRANS_CACHE_FULL:
+    case ER_ERROR_ON_WRITE:
+    case ER_BINLOG_LOGGING_IMPOSSIBLE:
+      checked= TRUE;
+    break;
+  }
+
+  DBUG_RETURN(checked);
+}
+
 /**
   @note
   How do we handle this (unlikely but legal) case:
@@ -3854,6 +3922,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_row
     if (pending->write(file))
     {
       pthread_mutex_unlock(&LOCK_log);
+      set_write_error(thd);
       DBUG_RETURN(1);
     }
 
@@ -3928,7 +3997,8 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
   */
   bool const end_stmt=
     thd->prelocked_mode && thd->lex->requires_prelocking();
-  thd->binlog_flush_pending_rows_event(end_stmt);
+  if (thd->binlog_flush_pending_rows_event(end_stmt))
+    DBUG_RETURN(error);
 
   pthread_mutex_lock(&LOCK_log);
 
@@ -3979,8 +4049,7 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
         DBUG_PRINT("info", ("Using trans_log: cache: %d, trans_log_pos: %lu",
                             event_info->get_cache_stmt(),
                             (ulong) trans_log_pos));
-        if (trans_log_pos == 0)
-          thd->binlog_start_trans_and_stmt();
+        thd->binlog_start_trans_and_stmt();
         file= trans_log;
       }
       /*
@@ -4058,7 +4127,8 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
        Write the SQL command
      */
 
-    if (event_info->write(file))
+    if (event_info->write(file) || 
+        DBUG_EVALUATE_IF("injecting_fault_writing", 1, 0))
       goto err;
 
     if (file == &log_file) // we are writing to the real log (disk)
@@ -4072,13 +4142,7 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
 
 err:
     if (error)
-    {
-      if (my_errno == EFBIG)
-	my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(0));
-      else
-	my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno);
-      write_error=1;
-    }
+      set_write_error(thd);
   }
 
   if (event_info->flags & LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F)
@@ -4359,6 +4423,29 @@ int query_error_code(THD *thd, bool not_
   return error;
 }
 
+bool MYSQL_BIN_LOG::write_incident(THD *thd, bool lock)
+{
+  uint error= 0;
+  DBUG_ENTER("MYSQL_BIN_LOG::write_incident");
+  LEX_STRING const write_error_msg=
+    { C_STRING_WITH_LEN("error writing to the binary log") };
+  Incident incident= INCIDENT_LOST_EVENTS;
+  Incident_log_event ev(thd, incident, write_error_msg);
+  if (lock)
+    pthread_mutex_lock(&LOCK_log);
+  ev.write(&log_file);
+  if (lock)
+  {
+    if (!error && !(error= flush_and_sync()))
+    {
+      signal_update();
+      rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
+    }
+    pthread_mutex_unlock(&LOCK_log);
+  }
+  DBUG_RETURN(error);
+}
+
 /**
   Write a cached log entry to the binary log.
   - To support transaction over replication, we wrap the transaction
@@ -4371,6 +4458,9 @@ int query_error_code(THD *thd, bool not_
   @param cache		The cache to copy to the binlog
   @param commit_event   The commit event to print after writing the
                         contents of the cache.
+  @param incident       Defines if an incident event should be created to
+                        notify that some non-transactional changes did
+                        not get into the binlog.
 
   @note
     We only come here if there is something in the cache.
@@ -4380,7 +4470,8 @@ int query_error_code(THD *thd, bool not_
     'cache' needs to be reinitialized after this functions returns.
 */
 
-bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
+bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event,
+                          bool incident)
 {
   DBUG_ENTER("MYSQL_BIN_LOG::write(THD *, IO_CACHE *, Log_event *)");
   VOID(pthread_mutex_lock(&LOCK_log));
@@ -4429,6 +4520,10 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C
 
       if (commit_event && commit_event->write(&log_file))
         goto err;
+
+      if (incident && write_incident(thd, FALSE))
+        goto err;
+
       if (flush_and_sync())
         goto err;
       DBUG_EXECUTE_IF("half_binlogged_transaction", abort(););

=== modified file 'sql/log.h'
--- a/sql/log.h	2009-05-30 13:32:28 +0000
+++ b/sql/log.h	2009-06-18 13:52:46 +0000
@@ -356,9 +356,12 @@ public:
   void new_file();
 
   bool write(Log_event* event_info); // binary log write
-  bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
+  bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident);
+  bool write_incident(THD *thd, bool lock);
 
   int  write_cache(IO_CACHE *cache, bool lock_log, bool flush_and_sync);
+  void set_write_error(THD *thd);
+  bool check_write_error(THD *thd);
 
   void start_union_events(THD *thd, query_id_t query_id_param);
   void stop_union_events(THD *thd);

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2009-06-09 16:44:26 +0000
+++ b/sql/log_event.cc	2009-07-06 08:02:14 +0000
@@ -369,6 +369,34 @@ int convert_handler_error(int error, THD
   return (actual_error);
 }
 
+inline bool concurrency_error_code(int error)
+{
+  switch (error)
+  {
+  case ER_LOCK_WAIT_TIMEOUT:
+  case ER_LOCK_DEADLOCK:
+  case ER_XA_RBDEADLOCK:
+    return TRUE;
+  default: 
+    return (FALSE);
+  }
+}
+
+inline bool unexpected_error_code(int unexpected_error)
+{
+  switch (unexpected_error) 
+  {
+  case ER_NET_READ_ERROR:
+  case ER_NET_ERROR_ON_WRITE:
+  case ER_QUERY_INTERRUPTED:
+  case ER_SERVER_SHUTDOWN:
+  case ER_NEW_ABORTING_CONNECTION:
+    return(TRUE);
+  default:
+    return(FALSE);
+  }
+}
+
 /*
   pretty_print_str()
 */
@@ -3006,7 +3034,7 @@ int Query_log_event::do_apply_event(Rela
     DBUG_PRINT("query",("%s",thd->query));
 
     if (ignored_error_code((expected_error= error_code)) ||
-	!check_expected_error(thd,rli,expected_error))
+	!unexpected_error_code(expected_error))
     {
       if (flags2_inited)
         /*
@@ -3138,8 +3166,8 @@ compare_errors:
     actual_error= thd->is_error() ? thd->main_da.sql_errno() : 0;
     DBUG_PRINT("info",("expected_error: %d  sql_errno: %d",
  		       expected_error, actual_error));
-    if ((expected_error != actual_error) &&
- 	expected_error &&
+    if ((expected_error && expected_error != actual_error &&
+         !concurrency_error_code(expected_error)) &&
  	!ignored_error_code(actual_error) &&
  	!ignored_error_code(expected_error))
     {
@@ -3158,7 +3186,8 @@ Default database: '%s'. Query: '%s'",
     /*
       If we get the same error code as expected, or they should be ignored. 
     */
-    else if (expected_error == actual_error ||
+    else if ((expected_error == actual_error && 
+              !concurrency_error_code(expected_error)) ||
  	     ignored_error_code(actual_error))
     {
       DBUG_PRINT("info",("error ignored"));
@@ -3330,8 +3359,8 @@ void Start_log_event_v3::print(FILE* fil
       my_b_printf(&cache," at startup");
     my_b_printf(&cache, "\n");
     if (flags & LOG_EVENT_BINLOG_IN_USE_F)
-      my_b_printf(&cache, "# Warning: this binlog was not closed properly. "
-                  "Most probably mysqld crashed writing it.\n");
+      my_b_printf(&cache, "# Warning: this binlog is either in use or was not "
+                  "closed properly.\n");
   }
   if (!is_artificial_event() && created)
   {
@@ -4352,7 +4381,7 @@ void Load_log_event::print(FILE* file_ar
     {
       if (i)
 	my_b_printf(&cache, ",");
-      my_b_printf(&cache, field);
+      my_b_printf(&cache, "%s", field);
 	  
       field += field_lens[i]  + 1;
     }
@@ -6680,7 +6709,7 @@ void Execute_load_query_log_event::print
   {
     my_b_write(&cache, (uchar*) query, fn_pos_start);
     my_b_printf(&cache, " LOCAL INFILE \'");
-    my_b_printf(&cache, local_fname);
+    my_b_printf(&cache, "%s", local_fname);
     my_b_printf(&cache, "\'");
     if (dup_handling == LOAD_DUP_REPLACE)
       my_b_printf(&cache, " REPLACE");

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2009-05-30 13:32:28 +0000
+++ b/sql/log_event.h	2009-06-30 18:40:38 +0000
@@ -676,6 +676,7 @@ typedef struct st_print_event_info
 #ifdef MYSQL_CLIENT
   uint verbose;
   table_mapping m_table_map;
+  table_mapping m_table_map_ignored;
 #endif
 
   /*

=== modified file 'sql/my_decimal.h'
--- a/sql/my_decimal.h	2008-05-20 07:38:17 +0000
+++ b/sql/my_decimal.h	2009-07-03 10:36:04 +0000
@@ -183,6 +183,19 @@ inline uint my_decimal_length_to_precisi
                  (unsigned_flag || !length ? 0:1));
 }
 
+inline uint32 my_decimal_precision_to_length_no_truncation(uint precision,
+                                                           uint8 scale,
+                                                           bool unsigned_flag)
+{
+  /*
+    When precision is 0 it means that original length was also 0. Thus
+    unsigned_flag is ignored in this case.
+  */
+  DBUG_ASSERT(precision || !scale);
+  return (uint32)(precision + (scale > 0 ? 1 : 0) +
+                  (unsigned_flag || !precision ? 0 : 1));
+}
+
 inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale,
                                              bool unsigned_flag)
 {
@@ -192,8 +205,8 @@ inline uint32 my_decimal_precision_to_le
   */
   DBUG_ASSERT(precision || !scale);
   set_if_smaller(precision, DECIMAL_MAX_PRECISION);
-  return (uint32)(precision + (scale>0 ? 1:0) +
-                  (unsigned_flag || !precision ? 0:1));
+  return my_decimal_precision_to_length_no_truncation(precision, scale,
+                                                      unsigned_flag);
 }
 
 inline

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-06-08 22:05:24 +0000
+++ b/sql/mysqld.cc	2009-06-23 09:10:04 +0000
@@ -983,6 +983,7 @@ static void close_connections(void)
   }
   (void) pthread_mutex_unlock(&LOCK_thread_count);
 
+  close_active_mi();
   DBUG_PRINT("quit",("close_connections thread"));
   DBUG_VOID_RETURN;
 }
@@ -1664,7 +1665,6 @@ static void network_init(void)
       opt_enable_named_pipe)
   {
     
-    pipe_name[sizeof(pipe_name)-1]= 0;		/* Safety if too long string */
     strxnmov(pipe_name, sizeof(pipe_name)-1, "\\\\.\\pipe\\",
 	     mysqld_unix_port, NullS);
     bzero((char*) &saPipeSecurity, sizeof(saPipeSecurity));

=== modified file 'sql/parse_file.cc'
--- a/sql/parse_file.cc	2009-05-15 12:57:51 +0000
+++ b/sql/parse_file.cc	2009-06-19 08:24:43 +0000
@@ -231,7 +231,7 @@ sql_create_definition_file(const LEX_STR
       including dir name, file name itself, and an extension,
       and with unpack_filename() executed over it.
     */    
-    path_end= strxnmov(path, FN_REFLEN, file_name->str, NullS) - path;
+    path_end= strxnmov(path, sizeof(path) - 1, file_name->str, NullS) - path;
   }
 
   // temporary file name
@@ -314,7 +314,7 @@ my_bool rename_in_schema_file(THD *thd,
                               const char *schema, const char *old_name, 
                               const char *new_db, const char *new_name)
 {
-  char old_path[FN_REFLEN], new_path[FN_REFLEN], arc_path[FN_REFLEN];
+  char old_path[FN_REFLEN + 1], new_path[FN_REFLEN + 1], arc_path[FN_REFLEN + 1];
 
   build_table_filename(old_path, sizeof(old_path) - 1,
                        schema, old_name, reg_ext, 0);

=== modified file 'sql/rpl_reporting.cc'
--- a/sql/rpl_reporting.cc	2007-06-11 20:15:39 +0000
+++ b/sql/rpl_reporting.cc	2009-06-16 15:04:30 +0000
@@ -13,6 +13,7 @@ Slave_reporting_capability::report(logle
   va_list args;
   va_start(args, msg);
 
+  pthread_mutex_lock(&err_lock);
   switch (level)
   {
   case ERROR_LEVEL:
@@ -38,6 +39,7 @@ Slave_reporting_capability::report(logle
 
   my_vsnprintf(pbuff, pbuffsize, msg, args);
 
+  pthread_mutex_unlock(&err_lock);
   va_end(args);
 
   /* If the msg string ends with '.', do not add a ',' it would be ugly */
@@ -46,3 +48,8 @@ Slave_reporting_capability::report(logle
                   (pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
                   err_code);
 }
+
+Slave_reporting_capability::~Slave_reporting_capability()
+{
+  pthread_mutex_destroy(&err_lock);
+}

=== modified file 'sql/rpl_reporting.h'
--- a/sql/rpl_reporting.h	2007-06-11 20:15:39 +0000
+++ b/sql/rpl_reporting.h	2009-06-16 15:04:30 +0000
@@ -16,6 +16,8 @@
 class Slave_reporting_capability
 {
 public:
+  /** lock used to synchronize m_last_error on 'SHOW SLAVE STATUS' **/
+  mutable pthread_mutex_t err_lock;
   /**
      Constructor.
 
@@ -24,6 +26,7 @@ public:
   Slave_reporting_capability(char const *thread_name)
     : m_thread_name(thread_name)
   {
+      pthread_mutex_init(&err_lock, MY_MUTEX_INIT_FAST);
   }
 
   /**
@@ -44,7 +47,9 @@ public:
      STATUS</code>.
    */
   void clear_error() {
+    pthread_mutex_lock(&err_lock);
     m_last_error.clear();
+    pthread_mutex_unlock(&err_lock);
   }
 
   /**
@@ -72,6 +77,7 @@ public:
 
   Error const& last_error() const { return m_last_error; }
 
+  virtual ~Slave_reporting_capability()= 0;
 private:
   /**
      Last error produced by the I/O or SQL thread respectively.
@@ -79,6 +85,10 @@ private:
   mutable Error m_last_error;
 
   char const *const m_thread_name;
+
+  // not implemented
+  Slave_reporting_capability(const Slave_reporting_capability& rhs);
+  Slave_reporting_capability& operator=(const Slave_reporting_capability& rhs);
 };
 
 #endif // RPL_REPORTING_H

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-06-09 16:44:26 +0000
+++ b/sql/slave.cc	2009-07-06 08:02:14 +0000
@@ -668,7 +668,7 @@ static int end_slave_on_walk(Master_info
 
 
 /*
-  Free all resources used by slave
+  Release slave threads at time of executing shutdown.
 
   SYNOPSIS
     end_slave()
@@ -694,15 +694,32 @@ void end_slave()
       once multi-master code is ready.
     */
     terminate_slave_threads(active_mi,SLAVE_FORCE_ALL);
+  }
+  pthread_mutex_unlock(&LOCK_active_mi);
+  DBUG_VOID_RETURN;
+}
+
+/**
+   Free all resources used by slave threads at time of executing shutdown.
+   The routine must be called after all possible users of @c active_mi
+   have left.
+
+   SYNOPSIS
+     close_active_mi()
+
+*/
+void close_active_mi()
+{
+  pthread_mutex_lock(&LOCK_active_mi);
+  if (active_mi)
+  {
     end_master_info(active_mi);
     delete active_mi;
     active_mi= 0;
   }
   pthread_mutex_unlock(&LOCK_active_mi);
-  DBUG_VOID_RETURN;
 }
 
-
 static bool io_slave_killed(THD* thd, Master_info* mi)
 {
   DBUG_ENTER("io_slave_killed");
@@ -1493,6 +1510,8 @@ bool show_master_info(THD* thd, Master_i
 
     pthread_mutex_lock(&mi->data_lock);
     pthread_mutex_lock(&mi->rli.data_lock);
+    pthread_mutex_lock(&mi->err_lock);
+    pthread_mutex_lock(&mi->rli.err_lock);
     protocol->store(mi->host, &my_charset_bin);
     protocol->store(mi->user, &my_charset_bin);
     protocol->store((uint32) mi->port);
@@ -1592,6 +1611,8 @@ bool show_master_info(THD* thd, Master_i
     // Last_SQL_Error
     protocol->store(mi->rli.last_error().message, &my_charset_bin);
 
+    pthread_mutex_unlock(&mi->rli.err_lock);
+    pthread_mutex_unlock(&mi->err_lock);
     pthread_mutex_unlock(&mi->rli.data_lock);
     pthread_mutex_unlock(&mi->data_lock);
 
@@ -1863,25 +1884,6 @@ static ulong read_event(MYSQL* mysql, Ma
   DBUG_RETURN(len - 1);
 }
 
-
-int check_expected_error(THD* thd, Relay_log_info const *rli,
-                         int expected_error)
-{
-  DBUG_ENTER("check_expected_error");
-
-  switch (expected_error) {
-  case ER_NET_READ_ERROR:
-  case ER_NET_ERROR_ON_WRITE:
-  case ER_QUERY_INTERRUPTED:
-  case ER_SERVER_SHUTDOWN:
-  case ER_NEW_ABORTING_CONNECTION:
-    DBUG_RETURN(1);
-  default:
-    DBUG_RETURN(0);
-  }
-}
-
-
 /*
   Check if the current error is of temporary nature of not.
   Some errors are temporary in nature, such as
@@ -2397,6 +2399,7 @@ pthread_handler_t handle_slave_io(void *
 
   pthread_detach_this_thread();
   thd->thread_stack= (char*) &thd; // remember where our stack is
+  mi->clear_error();
   if (init_slave_thread(thd, SLAVE_THD_IO))
   {
     pthread_cond_broadcast(&mi->start_cond);
@@ -2511,6 +2514,7 @@ requesting master dump") ||
         goto connected;
       });
 
+    DBUG_ASSERT(mi->last_error().number == 0);
     while (!io_slave_killed(thd,mi))
     {
       ulong event_len;
@@ -3710,6 +3714,7 @@ static int connect_to_master(THD* thd, M
 
   if (!slave_was_killed)
   {
+    mi->clear_error(); // clear possible left over reconnect error
     if (reconnect)
     {
       if (!suppress_warnings && global_system_variables.log_warnings)

=== modified file 'sql/slave.h'
--- a/sql/slave.h	2009-04-30 13:17:46 +0000
+++ b/sql/slave.h	2009-07-06 08:02:14 +0000
@@ -171,10 +171,10 @@ bool rpl_master_has_bug(const Relay_log_
 bool rpl_master_erroneous_autoinc(THD* thd);
 
 const char *print_slave_db_safe(const char *db);
-int check_expected_error(THD* thd, Relay_log_info const *rli, int error_code);
 void skip_load_data_infile(NET* net);
 
-void end_slave(); /* clean up */
+void end_slave(); /* release slave threads */
+void close_active_mi(); /* clean up slave threads data */
 void clear_until_condition(Relay_log_info* rli);
 void clear_slave_error(Relay_log_info* rli);
 void end_relay_log_info(Relay_log_info* rli);

=== modified file 'sql/spatial.h'
--- a/sql/spatial.h	2009-02-13 16:41:47 +0000
+++ b/sql/spatial.h	2009-06-17 14:56:44 +0000
@@ -116,12 +116,12 @@ struct MBR
   int touches(const MBR *mbr)
   {
     /* The following should be safe, even if we compare doubles */
-    return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) &&
-	     (((mbr->ymin >= ymin) && (mbr->ymin <= ymax)) ||
-	      ((mbr->ymax >= ymin) && (mbr->ymax <= ymax)))) ||
-	    (((mbr->ymin == ymax) || (mbr->ymax == ymin)) &&
-	     (((mbr->xmin >= xmin) && (mbr->xmin <= xmax)) ||
-	      ((mbr->xmax >= xmin) && (mbr->xmax <= xmax)))));
+    return ((mbr->xmin == xmax || mbr->xmax == xmin) &&
+            ((mbr->ymin >= ymin && mbr->ymin <= ymax) ||
+             (mbr->ymax >= ymin && mbr->ymax <= ymax))) ||
+           ((mbr->ymin == ymax || mbr->ymax == ymin) &&
+            ((mbr->xmin >= xmin && mbr->xmin <= xmax) ||
+             (mbr->xmax >= xmin && mbr->xmax <= xmax)));
   }
 
   int within(const MBR *mbr)

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2009-06-12 21:11:19 +0000
+++ b/sql/sql_acl.cc	2009-06-19 08:24:43 +0000
@@ -1192,12 +1192,12 @@ static void acl_update_user(const char *
   for (uint i=0 ; i < acl_users.elements ; i++)
   {
     ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
-    if (!acl_user->user && !user[0] ||
-	acl_user->user && !strcmp(user,acl_user->user))
+    if ((!acl_user->user && !user[0]) ||
+	(acl_user->user && !strcmp(user,acl_user->user)))
     {
-      if (!acl_user->host.hostname && !host[0] ||
-	  acl_user->host.hostname &&
-	  !my_strcasecmp(system_charset_info, host, acl_user->host.hostname))
+      if ((!acl_user->host.hostname && !host[0]) ||
+	  (acl_user->host.hostname &&
+	  !my_strcasecmp(system_charset_info, host, acl_user->host.hostname)))
       {
 	acl_user->access=privileges;
 	if (mqh->specified_limits & USER_RESOURCES::QUERIES_PER_HOUR)
@@ -1275,16 +1275,16 @@ static void acl_update_db(const char *us
   for (uint i=0 ; i < acl_dbs.elements ; i++)
   {
     ACL_DB *acl_db=dynamic_element(&acl_dbs,i,ACL_DB*);
-    if (!acl_db->user && !user[0] ||
-	acl_db->user &&
-	!strcmp(user,acl_db->user))
-    {
-      if (!acl_db->host.hostname && !host[0] ||
-	  acl_db->host.hostname &&
-          !strcmp(host, acl_db->host.hostname))
+    if ((!acl_db->user && !user[0]) ||
+	(acl_db->user &&
+	!strcmp(user,acl_db->user)))
+    {
+      if ((!acl_db->host.hostname && !host[0]) ||
+	  (acl_db->host.hostname &&
+          !strcmp(host, acl_db->host.hostname)))
       {
-	if (!acl_db->db && !db[0] ||
-	    acl_db->db && !strcmp(db,acl_db->db))
+	if ((!acl_db->db && !db[0]) ||
+	    (acl_db->db && !strcmp(db,acl_db->db)))
 	{
 	  if (privileges)
 	    acl_db->access=privileges;
@@ -1493,8 +1493,8 @@ bool acl_check_host(const char *host, co
     return 0;
   VOID(pthread_mutex_lock(&acl_cache->lock));
 
-  if (host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host)) ||
-      ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip)))
+  if ((host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host))) ||
+      (ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip))))
   {
     VOID(pthread_mutex_unlock(&acl_cache->lock));
     return 0;					// Found host
@@ -1711,8 +1711,8 @@ find_acl_user(const char *host, const ch
                        host,
                        acl_user->host.hostname ? acl_user->host.hostname :
                        ""));
-    if (!acl_user->user && !user[0] ||
-	acl_user->user && !strcmp(user,acl_user->user))
+    if ((!acl_user->user && !user[0]) ||
+	(acl_user->user && !strcmp(user,acl_user->user)))
     {
       if (exact ? !my_strcasecmp(system_charset_info, host,
                                  acl_user->host.hostname ?
@@ -2995,8 +2995,8 @@ int mysql_table_grant(THD *thd, TABLE_LI
     {
       if (!(rights & CREATE_ACL))
       {
-        char buf[FN_REFLEN];
-        build_table_filename(buf, sizeof(buf), table_list->db,
+        char buf[FN_REFLEN + 1];
+        build_table_filename(buf, sizeof(buf) - 1, table_list->db,
                              table_list->table_name, reg_ext, 0);
         fn_format(buf, buf, "", "", MY_UNPACK_FILENAME  | MY_RESOLVE_SYMLINKS |
                                     MY_RETURN_REAL_PATH | MY_APPEND_EXT);
@@ -5319,16 +5319,13 @@ static int handle_grant_struct(uint stru
   uint elements;
   const char *user;
   const char *host;
-  ACL_USER *acl_user;
-  ACL_DB *acl_db;
-  GRANT_NAME *grant_name;
+  ACL_USER *acl_user= NULL;
+  ACL_DB *acl_db= NULL;
+  GRANT_NAME *grant_name= NULL;
   DBUG_ENTER("handle_grant_struct");
   DBUG_PRINT("info",("scan struct: %u  search: '%s'@'%s'",
                      struct_no, user_from->user.str, user_from->host.str));
 
-  LINT_INIT(acl_user);
-  LINT_INIT(acl_db);
-  LINT_INIT(grant_name);
   LINT_INIT(user);
   LINT_INIT(host);
 

=== modified file 'sql/sql_analyse.cc'
--- a/sql/sql_analyse.cc	2008-03-29 15:56:33 +0000
+++ b/sql/sql_analyse.cc	2009-06-17 14:56:44 +0000
@@ -246,7 +246,7 @@ bool test_if_number(NUM_INFO *info, cons
       }
       DBUG_RETURN(0);
     }
-    for (str++; *(end - 1) == '0'; end--);  // jump over zeros at the end
+    for (str++; *(end - 1) == '0'; end--) ; // jump over zeros at the end
     if (str == end)		     // number was something like '123.000'
     {
       char *endpos= (char*) str;

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2009-05-30 13:32:28 +0000
+++ b/sql/sql_base.cc	2009-06-26 19:57:42 +0000
@@ -473,13 +473,14 @@ static TABLE_SHARE
 
     @todo Rework alternative ways to deal with ER_NO_SUCH TABLE.
   */
-  if (share || thd->is_error() && thd->main_da.sql_errno() != ER_NO_SUCH_TABLE)
+  if (share || (thd->is_error() && thd->main_da.sql_errno() != ER_NO_SUCH_TABLE))
 
     DBUG_RETURN(share);
 
   /* Table didn't exist. Check if some engine can provide it */
-  if ((tmp= ha_create_table_from_engine(thd, table_list->db,
-                                        table_list->table_name)) < 0)
+  tmp= ha_create_table_from_engine(thd, table_list->db,
+                                   table_list->table_name);
+  if (tmp < 0)
   {
     /*
       No such table in any engine.
@@ -1431,11 +1432,10 @@ static inline uint  tmpkeyval(THD *thd, 
 void close_temporary_tables(THD *thd)
 {
   TABLE *table;
-  TABLE *next;
+  TABLE *next= NULL;
   TABLE *prev_table;
   /* Assume thd->options has OPTION_QUOTE_SHOW_CREATE */
   bool was_quote_show= TRUE;
-  LINT_INIT(next);
 
   if (!thd->temporary_tables)
     return;
@@ -2432,7 +2432,7 @@ bool lock_table_name_if_not_cached(THD *
 
 bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists)
 {
-  char path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
   int rc;
   DBUG_ENTER("check_if_table_exists");
 
@@ -2617,8 +2617,8 @@ TABLE *open_table(THD *thd, TABLE_LIST *
             distance >  0 - we have lock mode higher then we require
             distance == 0 - we have lock mode exactly which we need
           */
-          if (best_distance < 0 && distance > best_distance ||
-              distance >= 0 && distance < best_distance)
+          if ((best_distance < 0 && distance > best_distance) ||
+              (distance >= 0 && distance < best_distance))
           {
             best_distance= distance;
             best_table= table;
@@ -2649,7 +2649,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *
       real fix will be made after definition cache will be made)
     */
     {
-      char path[FN_REFLEN];
+      char path[FN_REFLEN + 1];
       enum legacy_db_type not_used;
       build_table_filename(path, sizeof(path) - 1,
                            table_list->db, table_list->table_name, reg_ext, 0);
@@ -2963,6 +2963,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *
   table->insert_values= 0;
   table->fulltext_searched= 0;
   table->file->ft_handler= 0;
+  table->reginfo.impossible_range= 0;
   /* Catch wrong handling of the auto_increment_field_not_null. */
   DBUG_ASSERT(!table->auto_increment_field_not_null);
   table->auto_increment_field_not_null= FALSE;
@@ -6340,7 +6341,7 @@ find_field_in_tables(THD *thd, Item_iden
       (report_error == REPORT_ALL_ERRORS ||
        report_error == REPORT_EXCEPT_NON_UNIQUE))
   {
-    char buff[NAME_LEN*2+1];
+    char buff[NAME_LEN*2 + 2];
     if (db && db[0])
     {
       strxnmov(buff,sizeof(buff)-1,db,".",table_name,NullS);
@@ -6413,8 +6414,7 @@ find_item_in_list(Item *find, List<Item>
     (and not an item that happens to have a name).
   */
   bool is_ref_by_name= 0;
-  uint unaliased_counter;
-  LINT_INIT(unaliased_counter);                 // Dependent on found_unaliased
+  uint unaliased_counter= 0;
 
   *resolution= NOT_RESOLVED;
 
@@ -7439,7 +7439,7 @@ bool setup_fields(THD *thd, Item **ref_p
   thd->lex->current_select->cur_pos_in_select_list= 0;
   while ((item= it++))
   {
-    if (!item->fixed && item->fix_fields(thd, it.ref()) ||
+    if ((!item->fixed && item->fix_fields(thd, it.ref())) ||
 	(item= *(it.ref()))->check_cols(1))
     {
       thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
@@ -7753,8 +7753,8 @@ insert_fields(THD *thd, Name_resolution_
 
     DBUG_ASSERT(tables->is_leaf_for_name_resolution());
 
-    if (table_name && my_strcasecmp(table_alias_charset, table_name,
-                                    tables->alias) ||
+    if ((table_name && my_strcasecmp(table_alias_charset, table_name,
+                                    tables->alias)) ||
         (db_name && strcmp(tables->db,db_name)))
       continue;
 
@@ -7785,8 +7785,8 @@ insert_fields(THD *thd, Name_resolution_
        information_schema table, or a nested table reference. See the comment
        for TABLE_LIST.
     */
-    if (!(table && !tables->view && (table->grant.privilege & SELECT_ACL) ||
-          tables->view && (tables->grant.privilege & SELECT_ACL)) &&
+    if (!((table && !tables->view && (table->grant.privilege & SELECT_ACL)) ||
+          (tables->view && (tables->grant.privilege & SELECT_ACL))) &&
         !any_privileges)
     {
       field_iterator.set(tables);
@@ -7840,7 +7840,7 @@ insert_fields(THD *thd, Name_resolution_
       */
       if (any_privileges)
       {
-        DBUG_ASSERT(tables->field_translation == NULL && table ||
+        DBUG_ASSERT((tables->field_translation == NULL && table) ||
                     tables->is_natural_join);
         DBUG_ASSERT(item->type() == Item::FIELD_ITEM);
         Item_field *fld= (Item_field*) item;
@@ -7979,7 +7979,7 @@ int setup_conds(THD *thd, TABLE_LIST *ta
   if (*conds)
   {
     thd->where="where clause";
-    if (!(*conds)->fixed && (*conds)->fix_fields(thd, conds) ||
+    if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) ||
 	(*conds)->check_cols(1))
       goto err_no_arena;
   }
@@ -7999,8 +7999,8 @@ int setup_conds(THD *thd, TABLE_LIST *ta
       {
         /* Make a join an a expression */
         thd->where="on clause";
-        if (!embedded->on_expr->fixed &&
-            embedded->on_expr->fix_fields(thd, &embedded->on_expr) ||
+        if ((!embedded->on_expr->fixed &&
+            embedded->on_expr->fix_fields(thd, &embedded->on_expr)) ||
 	    embedded->on_expr->check_cols(1))
 	  goto err_no_arena;
         select_lex->cond_count++;
@@ -8155,8 +8155,8 @@ fill_record_n_invoke_before_triggers(THD
                                      enum trg_event_type event)
 {
   return (fill_record(thd, fields, values, ignore_errors) ||
-          triggers && triggers->process_triggers(thd, event,
-                                                 TRG_ACTION_BEFORE, TRUE));
+          (triggers && triggers->process_triggers(thd, event,
+                                                 TRG_ACTION_BEFORE, TRUE)));
 }
 
 
@@ -8250,8 +8250,8 @@ fill_record_n_invoke_before_triggers(THD
                                      enum trg_event_type event)
 {
   return (fill_record(thd, ptr, values, ignore_errors) ||
-          triggers && triggers->process_triggers(thd, event,
-                                                 TRG_ACTION_BEFORE, TRUE));
+          (triggers && triggers->process_triggers(thd, event,
+                                                 TRG_ACTION_BEFORE, TRUE)));
 }
 
 

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2009-06-15 15:53:45 +0000
+++ b/sql/sql_class.cc	2009-06-27 13:18:47 +0000
@@ -27,6 +27,7 @@
 
 #include "mysql_priv.h"
 #include "rpl_rli.h"
+#include "rpl_filter.h"
 #include "rpl_record.h"
 #include "slave.h"
 #include <my_bitmap.h>
@@ -546,6 +547,7 @@ THD::THD()
    first_successful_insert_id_in_prev_stmt_for_binlog(0),
    first_successful_insert_id_in_cur_stmt(0),
    stmt_depends_on_first_successful_insert_id_in_prev_stmt(FALSE),
+   examined_row_count(0),
    global_read_lock(0),
    is_fatal_error(0),
    transaction_rollback_request(0),
@@ -3683,7 +3685,8 @@ int THD::binlog_query(THD::enum_binlog_q
     we should print a warning.
   */
   if (sql_log_bin_toplevel && lex->is_stmt_unsafe() &&
-      variables.binlog_format == BINLOG_FORMAT_STMT)
+      variables.binlog_format == BINLOG_FORMAT_STMT && 
+      binlog_filter->db_ok(this->db))
   {
    /*
      A warning can be elevated a error when STRICT sql mode.

=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc	2009-05-30 13:32:28 +0000
+++ b/sql/sql_db.cc	2009-06-19 08:24:43 +0000
@@ -537,13 +537,13 @@ err1:
 bool load_db_opt_by_name(THD *thd, const char *db_name,
                          HA_CREATE_INFO *db_create_info)
 {
-  char db_opt_path[FN_REFLEN];
+  char db_opt_path[FN_REFLEN + 1];
 
   /*
     Pass an empty file name, and the database options file name as extension
     to avoid table name to file name encoding.
   */
-  (void) build_table_filename(db_opt_path, sizeof(db_opt_path),
+  (void) build_table_filename(db_opt_path, sizeof(db_opt_path) - 1,
                               db_name, "", MY_DB_OPT_FILE, 0);
 
   return load_db_opt(thd, db_opt_path, db_create_info);
@@ -645,7 +645,7 @@ int mysql_create_db(THD *thd, char *db, 
   VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
 
   /* Check directory */
-  path_len= build_table_filename(path, sizeof(path), db, "", "", 0);
+  path_len= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
   path[path_len-1]= 0;                    // Remove last '/' from path
 
   if (my_stat(path,&stat_info,MYF(0)))
@@ -791,7 +791,7 @@ bool mysql_alter_db(THD *thd, const char
      We pass MY_DB_OPT_FILE as "extension" to avoid
      "table name to file name" encoding.
   */
-  build_table_filename(path, sizeof(path), db, "", MY_DB_OPT_FILE, 0);
+  build_table_filename(path, sizeof(path) - 1, db, "", MY_DB_OPT_FILE, 0);
   if ((error=write_db_opt(thd, path, create_info)))
     goto exit;
 
@@ -884,7 +884,7 @@ bool mysql_rm_db(THD *thd,char *db,bool 
 
   VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
 
-  length= build_table_filename(path, sizeof(path), db, "", "", 0);
+  length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
   strmov(path+length, MY_DB_OPT_FILE);		// Append db option file name
   del_dbopt(path);				// Remove dboption hash entry
   path[length]= '\0';				// Remove file name
@@ -1841,7 +1841,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRI
     for (uint idx=0 ; idx < nfiles && !thd->killed ; idx++)
     {
       FILEINFO *file= dirp->dir_entry + idx;
-      char *extension, tname[FN_REFLEN];
+      char *extension, tname[FN_REFLEN + 1];
       LEX_STRING table_str;
       DBUG_PRINT("info",("Examining: %s", file->name));
 
@@ -1930,7 +1930,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRI
     for (uint idx=0 ; idx < nfiles ; idx++)
     {
       FILEINFO *file= dirp->dir_entry + idx;
-      char oldname[FN_REFLEN], newname[FN_REFLEN];
+      char oldname[FN_REFLEN + 1], newname[FN_REFLEN + 1];
       DBUG_PRINT("info",("Examining: %s", file->name));
 
       /* skiping . and .. and MY_DB_OPT_FILE */
@@ -2000,10 +2000,10 @@ exit:
 
 bool check_db_dir_existence(const char *db_name)
 {
-  char db_dir_path[FN_REFLEN];
+  char db_dir_path[FN_REFLEN + 1];
   uint db_dir_path_len;
 
-  db_dir_path_len= build_table_filename(db_dir_path, sizeof(db_dir_path),
+  db_dir_path_len= build_table_filename(db_dir_path, sizeof(db_dir_path) - 1,
                                         db_name, "", "", 0);
 
   if (db_dir_path_len && db_dir_path[db_dir_path_len - 1] == FN_LIBCHAR)

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2009-05-30 13:32:28 +0000
+++ b/sql/sql_delete.cc	2009-06-19 08:24:43 +0000
@@ -408,7 +408,7 @@ cleanup:
                                         thd->query, thd->query_length,
                                         is_trans, FALSE, errcode);
 
-      if (log_result && transactional_table)
+      if (log_result)
       {
 	error=1;
       }
@@ -806,7 +806,7 @@ void multi_delete::abort()
 
   /* the error was handled or nothing deleted and no side effects return */
   if (error_handled ||
-      !thd->transaction.stmt.modified_non_trans_table && !deleted)
+      (!thd->transaction.stmt.modified_non_trans_table && !deleted))
     DBUG_VOID_RETURN;
 
   /* Something already deleted so we have to invalidate cache */
@@ -1051,7 +1051,7 @@ static bool mysql_truncate_by_delete(THD
 bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
 {
   HA_CREATE_INFO create_info;
-  char path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
   TABLE *table;
   bool error;
   uint path_length;
@@ -1088,7 +1088,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST
     goto end;
   }
 
-  path_length= build_table_filename(path, sizeof(path), table_list->db,
+  path_length= build_table_filename(path, sizeof(path) - 1, table_list->db,
                                     table_list->table_name, reg_ext, 0);
 
   if (!dont_send_ok)

=== modified file 'sql/sql_help.cc'
--- a/sql/sql_help.cc	2009-02-13 16:41:47 +0000
+++ b/sql/sql_help.cc	2009-06-17 14:56:44 +0000
@@ -526,7 +526,7 @@ int send_variant_2_list(MEM_ROOT *mem_ro
   String **end= pointers + names->elements;
 
   List_iterator<String> it(*names);
-  for (pos= pointers; pos!=end; (*pos++= it++));
+  for (pos= pointers; pos!=end; (*pos++= it++)) ;
 
   my_qsort(pointers,names->elements,sizeof(String*),string_ptr_cmp);
 

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2009-06-04 23:30:08 +0000
+++ b/sql/sql_insert.cc	2009-07-03 08:39:22 +0000
@@ -301,9 +301,7 @@ static int check_update_fields(THD *thd,
                                List<Item> &update_fields, table_map *map)
 {
   TABLE *table= insert_table_list->table;
-  my_bool timestamp_mark;
-
-  LINT_INIT(timestamp_mark);
+  my_bool timestamp_mark= 0;
 
   if (table->timestamp_field)
   {
@@ -393,7 +391,7 @@ void upgrade_lock_type(THD *thd, thr_loc
                        bool is_multi_insert)
 {
   if (duplic == DUP_UPDATE ||
-      duplic == DUP_REPLACE && *lock_type == TL_WRITE_CONCURRENT_INSERT)
+      (duplic == DUP_REPLACE && *lock_type == TL_WRITE_CONCURRENT_INSERT))
   {
     *lock_type= TL_WRITE_DEFAULT;
     return;
@@ -858,8 +856,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
       */
       query_cache_invalidate3(thd, table_list, 1);
     }
-    if (changed && error <= 0 || thd->transaction.stmt.modified_non_trans_table
-	|| was_insert_delayed)
+    if ((changed && error <= 0) ||
+        thd->transaction.stmt.modified_non_trans_table ||
+        was_insert_delayed)
     {
       if (mysql_bin_log.is_open())
       {
@@ -897,8 +896,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
 	if (thd->binlog_query(THD::ROW_QUERY_TYPE,
 			      thd->query, thd->query_length,
 			      transactional_table, FALSE,
-			      errcode) &&
-	    transactional_table)
+			      errcode))
         {
 	  error=1;
 	}
@@ -1118,6 +1116,33 @@ static bool mysql_prepare_insert_check_t
 
 
 /*
+  Get extra info for tables we insert into
+
+  @param table     table(TABLE object) we insert into,
+                   might be NULL in case of view
+  @param           table(TABLE_LIST object) or view we insert into
+*/
+
+static void prepare_for_positional_update(TABLE *table, TABLE_LIST *tables)
+{
+  if (table)
+  {
+    if(table->reginfo.lock_type != TL_WRITE_DELAYED)
+      table->prepare_for_position();
+    return;
+  }
+
+  DBUG_ASSERT(tables->view);
+  List_iterator<TABLE_LIST> it(*tables->view_tables);
+  TABLE_LIST *tbl;
+  while ((tbl= it++))
+    prepare_for_positional_update(tbl->table, tbl);
+
+  return;
+}
+
+
+/*
   Prepare items in INSERT statement
 
   SYNOPSIS
@@ -1266,9 +1291,8 @@ bool mysql_prepare_insert(THD *thd, TABL
     Only call prepare_for_posistion() if we are not performing a DELAYED
     operation. It will instead be executed by delayed insert thread.
   */
-  if ((duplic == DUP_UPDATE || duplic == DUP_REPLACE) &&
-      (table->reginfo.lock_type != TL_WRITE_DELAYED))
-    table->prepare_for_position();
+  if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
+    prepare_for_positional_update(table, table_list);
   DBUG_RETURN(FALSE);
 }
 
@@ -3100,7 +3124,10 @@ bool select_insert::send_data(List<Item>
   store_values(values);
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;
   if (thd->is_error())
+  {
+    table->auto_increment_field_not_null= FALSE;
     DBUG_RETURN(1);
+  }
   if (table_list)                               // Not CREATE ... SELECT
   {
     switch (table_list->view_check_option(thd, info.ignore)) {
@@ -3186,7 +3213,8 @@ bool select_insert::send_eof()
   table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
   table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
 
-  if (changed= (info.copied || info.deleted || info.updated))
+  changed= (info.copied || info.deleted || info.updated);
+  if (changed)
   {
     /*
       We must invalidate the table in the query cache before binlog writing

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2009-05-27 15:19:44 +0000
+++ b/sql/sql_lex.cc	2009-06-17 14:56:44 +0000
@@ -780,7 +780,7 @@ bool consume_comment(Lex_input_stream *l
 
 int MYSQLlex(void *arg, void *yythd)
 {
-  reg1	uchar c;
+  reg1	uchar c= 0;
   bool comment_closed;
   int	tokval, result_state;
   uint length;
@@ -798,7 +798,6 @@ int MYSQLlex(void *arg, void *yythd)
   lip->start_token();
   state=lip->next_state;
   lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
-  LINT_INIT(c);
   for (;;)
   {
     switch (state) {
@@ -927,7 +926,7 @@ int MYSQLlex(void *arg, void *yythd)
       else
 #endif
       {
-        for (result_state= c; ident_map[c= lip->yyGet()]; result_state|= c);
+        for (result_state= c; ident_map[c= lip->yyGet()]; result_state|= c) ;
         /* If there were non-ASCII characters, mark that we must convert */
         result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
       }
@@ -939,7 +938,7 @@ int MYSQLlex(void *arg, void *yythd)
           If we find a space then this can't be an identifier. We notice this
           below by checking start != lex->ptr.
         */
-        for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet());
+        for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet()) ;
       }
       if (start == lip->get_ptr() && c == '.' && ident_map[lip->yyPeek()])
 	lip->next_state=MY_LEX_IDENT_SEP;
@@ -1012,7 +1011,7 @@ int MYSQLlex(void *arg, void *yythd)
         }
         else if (c == 'b')
         {
-          while ((c= lip->yyGet()) == '0' || c == '1');
+          while ((c= lip->yyGet()) == '0' || c == '1') ;
           if ((lip->yyLength() >= 3) && !ident_map[c])
           {
             /* Skip '0b' */
@@ -1071,7 +1070,7 @@ int MYSQLlex(void *arg, void *yythd)
       else
 #endif
       {
-        for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c);
+        for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c) ;
         /* If there were non-ASCII characters, mark that we must convert */
         result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
       }
@@ -1171,7 +1170,7 @@ int MYSQLlex(void *arg, void *yythd)
 
     case MY_LEX_BIN_NUMBER:           // Found b'bin-string'
       lip->yySkip();                  // Accept opening '
-      while ((c= lip->yyGet()) == '0' || c == '1');
+      while ((c= lip->yyGet()) == '0' || c == '1') ;
       if (c != '\'')
         return(ABORT_SYM);            // Illegal hex constant
       lip->yySkip();                  // Accept closing '
@@ -1446,7 +1445,7 @@ int MYSQLlex(void *arg, void *yythd)
 	[(global | local | session) .]variable_name
       */
 
-      for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c);
+      for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c) ;
       /* If there were non-ASCII characters, mark that we must convert */
       result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
 

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2009-05-30 13:32:28 +0000
+++ b/sql/sql_load.cc	2009-06-17 14:56:44 +0000
@@ -750,9 +750,9 @@ read_sep_field(THD *thd, COPY_INFO &info
 
       real_item= item->real_item();
 
-      if (!read_info.enclosed &&
+      if ((!read_info.enclosed &&
 	  (enclosed_length && length == 4 &&
-           !memcmp(pos, STRING_WITH_LEN("NULL"))) ||
+           !memcmp(pos, STRING_WITH_LEN("NULL")))) ||
 	  (length == 1 && read_info.found_null))
       {
 
@@ -1151,8 +1151,8 @@ int READ_INFO::read_field()
 	}
 	// End of enclosed field if followed by field_term or line_term
 	if (chr == my_b_EOF ||
-	    chr == line_term_char && terminator(line_term_ptr,
-						line_term_length))
+	    (chr == line_term_char && terminator(line_term_ptr,
+						line_term_length)))
 	{					// Maybe unexpected linefeed
 	  enclosed=1;
 	  found_end_of_line=1;

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2009-06-15 15:53:45 +0000
+++ b/sql/sql_parse.cc	2009-07-01 12:32:04 +0000
@@ -1350,7 +1350,7 @@ bool dispatch_command(enum enum_server_c
       if (check_access(thd, CREATE_ACL, db.str , 0, 1, 0,
                        is_schema_db(db.str)))
 	break;
-      general_log_print(thd, command, packet);
+      general_log_print(thd, command, "%.*s", db.length, db.str);
       bzero(&create_info, sizeof(create_info));
       mysql_create_db(thd, (lower_case_table_names == 2 ? alias.str : db.str),
                       &create_info, 0);
@@ -1375,7 +1375,7 @@ bool dispatch_command(enum enum_server_c
                    ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
 	break;
       }
-      general_log_write(thd, command, db.str, db.length);
+      general_log_write(thd, command, "%.*s", db.length, db.str);
       mysql_rm_db(thd, db.str, 0, 0);
       break;
     }
@@ -1560,14 +1560,6 @@ bool dispatch_command(enum enum_server_c
     break;
   }
 
-  /* If commit fails, we should be able to reset the OK status. */
-  thd->main_da.can_overwrite_status= TRUE;
-  ha_autocommit_or_rollback(thd, thd->is_error());
-  thd->main_da.can_overwrite_status= FALSE;
-
-  thd->transaction.stmt.reset();
-
-
   /* report error issued during command execution */
   if (thd->killed_errno())
   {
@@ -1580,6 +1572,13 @@ bool dispatch_command(enum enum_server_c
     thd->mysys_var->abort= 0;
   }
 
+  /* If commit fails, we should be able to reset the OK status. */
+  thd->main_da.can_overwrite_status= TRUE;
+  ha_autocommit_or_rollback(thd, thd->is_error());
+  thd->main_da.can_overwrite_status= FALSE;
+
+  thd->transaction.stmt.reset();
+
   net_end_statement(thd);
   query_cache_end_of_result(thd);
 
@@ -5171,7 +5170,7 @@ check_access(THD *thd, ulong want_access
 
   if (schema_db)
   {
-    if (!(sctx->master_access & FILE_ACL) && (want_access & FILE_ACL) ||
+    if ((!(sctx->master_access & FILE_ACL) && (want_access & FILE_ACL)) ||
         (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
     {
       if (!no_errors)
@@ -5205,7 +5204,7 @@ check_access(THD *thd, ulong want_access
     DBUG_RETURN(FALSE);
   }
   if (((want_access & ~sctx->master_access) & ~(DB_ACLS | EXTRA_ACL)) ||
-      ! db && dont_check_global_grants)
+      (! db && dont_check_global_grants))
   {						// We can never grant this
     DBUG_PRINT("error",("No possible access"));
     if (!no_errors)
@@ -5483,7 +5482,7 @@ bool check_some_access(THD *thd, ulong w
       if (!check_access(thd, access, table->db,
                         &table->grant.privilege, 0, 1,
                         test(table->schema_table)) &&
-          !check_grant(thd, access, table, 0, 1, 1))
+           !check_grant(thd, access, table, 0, 1, 1))
         DBUG_RETURN(0);
     }
   }
@@ -7803,7 +7802,7 @@ bool parse_sql(THD *thd,
   /* Check that if MYSQLparse() failed, thd->is_error() is set. */
 
   DBUG_ASSERT(!mysql_parse_status ||
-              mysql_parse_status && thd->is_error());
+              (mysql_parse_status && thd->is_error()));
 
   /* Reset parser state. */
 

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2009-04-01 05:34:59 +0000
+++ b/sql/sql_partition.cc	2009-07-08 10:12:27 +0000
@@ -918,6 +918,9 @@ bool fix_fields_part_func(THD *thd, Item
     Set-up the TABLE_LIST object to be a list with a single table
     Set the object to zero to create NULL pointers and set alias
     and real name to table name and get database name from file name.
+    TODO: Consider generalizing or refactoring Lex::add_table_to_list() so
+    it can be used in all places where we create TABLE_LIST objects.
+    Also consider creating appropriate constructors for TABLE_LIST.
   */
 
   bzero((void*)&tables, sizeof(TABLE_LIST));
@@ -925,6 +928,13 @@ bool fix_fields_part_func(THD *thd, Item
   tables.table= table;
   tables.next_local= 0;
   tables.next_name_resolution_table= 0;
+  /*
+    Cache the table in Item_fields. All the tables can be cached except
+    the trigger pseudo table.
+  */
+  tables.cacheable_table= TRUE;
+  context= thd->lex->current_context();
+  tables.select_lex= context->select_lex;
   strmov(db_name_string, table->s->normalized_path.str);
   dir_length= dirname_length(db_name_string);
   db_name_string[dir_length - 1]= 0;
@@ -932,7 +942,6 @@ bool fix_fields_part_func(THD *thd, Item
   db_name= &db_name_string[home_dir_length];
   tables.db= db_name;
 
-  context= thd->lex->current_context();
   table->map= 1; //To ensure correct calculation of const item
   table->get_fields_in_item_tree= TRUE;
   save_table_list= context->table_list;
@@ -964,8 +973,9 @@ bool fix_fields_part_func(THD *thd, Item
 
   save_use_only_table_context= thd->lex->use_only_table_context;
   thd->lex->use_only_table_context= TRUE;
+  thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
   
-  error= func_expr->fix_fields(thd, (Item**)0);
+  error= func_expr->fix_fields(thd, (Item**)&func_expr);
 
   thd->lex->use_only_table_context= save_use_only_table_context;
 
@@ -5090,7 +5100,7 @@ static bool mysql_change_partitions(ALTE
   handler *file= lpt->table->file;
   DBUG_ENTER("mysql_change_partitions");
 
-  build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0);
+  build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
   if ((error= file->ha_change_partitions(lpt->create_info, path, &lpt->copied,
                                          &lpt->deleted, lpt->pack_frm_data,
                                          lpt->pack_frm_len)))
@@ -5130,7 +5140,7 @@ static bool mysql_rename_partitions(ALTE
   int error;
   DBUG_ENTER("mysql_rename_partitions");
 
-  build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0);
+  build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
   if ((error= lpt->table->file->ha_rename_partitions(path)))
   {
     if (error != 1)
@@ -5171,7 +5181,7 @@ static bool mysql_drop_partitions(ALTER_
   int error;
   DBUG_ENTER("mysql_drop_partitions");
 
-  build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0);
+  build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
   if ((error= lpt->table->file->ha_drop_partitions(path)))
   {
     lpt->table->file->print_error(error, MYF(0));
@@ -5516,10 +5526,10 @@ static bool write_log_drop_shadow_frm(AL
   partition_info *part_info= lpt->part_info;
   DDL_LOG_MEMORY_ENTRY *log_entry;
   DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL;
-  char shadow_path[FN_REFLEN];
+  char shadow_path[FN_REFLEN + 1];
   DBUG_ENTER("write_log_drop_shadow_frm");
 
-  build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
+  build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
   pthread_mutex_lock(&LOCK_gdl);
   if (write_log_replace_delete_frm(lpt, 0UL, NULL,
                                   (const char*)shadow_path, FALSE))
@@ -5559,15 +5569,15 @@ static bool write_log_rename_frm(ALTER_P
   partition_info *part_info= lpt->part_info;
   DDL_LOG_MEMORY_ENTRY *log_entry;
   DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry;
-  char path[FN_REFLEN];
-  char shadow_path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
+  char shadow_path[FN_REFLEN + 1];
   DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry;
   DBUG_ENTER("write_log_rename_frm");
 
   part_info->first_log_entry= NULL;
-  build_table_filename(path, sizeof(path), lpt->db,
+  build_table_filename(path, sizeof(path) - 1, lpt->db,
                        lpt->table_name, "", 0);
-  build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
+  build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
   pthread_mutex_lock(&LOCK_gdl);
   if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE))
     goto error;
@@ -5610,16 +5620,16 @@ static bool write_log_drop_partition(ALT
   partition_info *part_info= lpt->part_info;
   DDL_LOG_MEMORY_ENTRY *log_entry;
   DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry;
-  char tmp_path[FN_REFLEN];
-  char path[FN_REFLEN];
+  char tmp_path[FN_REFLEN + 1];
+  char path[FN_REFLEN + 1];
   uint next_entry= 0;
   DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry;
   DBUG_ENTER("write_log_drop_partition");
 
   part_info->first_log_entry= NULL;
-  build_table_filename(path, sizeof(path), lpt->db,
+  build_table_filename(path, sizeof(path) - 1, lpt->db,
                        lpt->table_name, "", 0);
-  build_table_filename(tmp_path, sizeof(tmp_path), lpt->db,
+  build_table_filename(tmp_path, sizeof(tmp_path) - 1, lpt->db,
                        lpt->table_name, "#", 0);
   pthread_mutex_lock(&LOCK_gdl);
   if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
@@ -5669,14 +5679,14 @@ static bool write_log_add_change_partiti
   partition_info *part_info= lpt->part_info;
   DDL_LOG_MEMORY_ENTRY *log_entry;
   DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL;
-  char tmp_path[FN_REFLEN];
-  char path[FN_REFLEN];
+  char tmp_path[FN_REFLEN + 1];
+  char path[FN_REFLEN + 1];
   uint next_entry= 0;
   DBUG_ENTER("write_log_add_change_partition");
 
-  build_table_filename(path, sizeof(path), lpt->db,
+  build_table_filename(path, sizeof(path) - 1, lpt->db,
                        lpt->table_name, "", 0);
-  build_table_filename(tmp_path, sizeof(tmp_path), lpt->db,
+  build_table_filename(tmp_path, sizeof(tmp_path) - 1, lpt->db,
                        lpt->table_name, "#", 0);
   pthread_mutex_lock(&LOCK_gdl);
   if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
@@ -5723,16 +5733,16 @@ static bool write_log_final_change_parti
   partition_info *part_info= lpt->part_info;
   DDL_LOG_MEMORY_ENTRY *log_entry;
   DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry;
-  char path[FN_REFLEN];
-  char shadow_path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
+  char shadow_path[FN_REFLEN + 1];
   DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry;
   uint next_entry= 0;
   DBUG_ENTER("write_log_final_change_partition");
 
   part_info->first_log_entry= NULL;
-  build_table_filename(path, sizeof(path), lpt->db,
+  build_table_filename(path, sizeof(path) - 1, lpt->db,
                        lpt->table_name, "", 0);
-  build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
+  build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
   pthread_mutex_lock(&LOCK_gdl);
   if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
                       lpt->alter_info->flags & ALTER_REORGANIZE_PARTITION))

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2009-06-05 11:23:58 +0000
+++ b/sql/sql_prepare.cc	2009-06-17 14:56:44 +0000
@@ -1434,8 +1434,8 @@ static bool mysql_test_set_fields(Prepar
   THD *thd= stmt->thd;
   set_var_base *var;
 
-  if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE) ||
-      open_normal_and_derived_tables(thd, tables, 0))
+  if ((tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) 
+      || open_normal_and_derived_tables(thd, tables, 0))
     goto error;
 
   while ((var= it++))
@@ -1470,13 +1470,13 @@ static bool mysql_test_call_fields(Prepa
   THD *thd= stmt->thd;
   Item *item;
 
-  if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE) ||
+  if ((tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) ||
       open_normal_and_derived_tables(thd, tables, 0))
     goto err;
 
   while ((item= it++))
   {
-    if (!item->fixed && item->fix_fields(thd, it.ref()) ||
+    if ((!item->fixed && item->fix_fields(thd, it.ref())) ||
         item->check_cols(1))
       goto err;
   }
@@ -2227,9 +2227,8 @@ void mysql_sql_stmt_prepare(THD *thd)
   LEX_STRING *name= &lex->prepared_stmt_name;
   Prepared_statement *stmt;
   const char *query;
-  uint query_len;
+  uint query_len= 0;
   DBUG_ENTER("mysql_sql_stmt_prepare");
-  LINT_INIT(query_len);
   DBUG_ASSERT(thd->protocol == &thd->protocol_text);
 
   if ((stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
@@ -2846,7 +2845,7 @@ void Prepared_statement::setup_set_param
     Decide if we have to expand the query (because we must write it to logs or
     because we want to look it up in the query cache) or not.
   */
-  if (mysql_bin_log.is_open() && is_update_query(lex->sql_command) ||
+  if ((mysql_bin_log.is_open() && is_update_query(lex->sql_command)) ||
       opt_log || opt_slow_log ||
       query_cache_is_cacheable_query(lex))
   {
@@ -3297,7 +3296,7 @@ Prepared_statement::reprepare()
                           &cur_db_changed))
     return TRUE;
 
-  error= (name.str && copy.set_name(&name) ||
+  error= ((name.str && copy.set_name(&name)) ||
           copy.prepare(query, query_length) ||
           validate_metadata(&copy));
 

=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc	2009-05-19 04:25:36 +0000
+++ b/sql/sql_rename.cc	2009-06-19 08:24:43 +0000
@@ -244,7 +244,7 @@ do_rename(THD *thd, TABLE_LIST *ren_tabl
           char *new_table_alias, bool skip_error)
 {
   int rc= 1;
-  char name[FN_REFLEN];
+  char name[FN_REFLEN + 1];
   const char *new_alias, *old_alias;
   frm_type_enum frm_type;
   enum legacy_db_type table_type;
@@ -263,14 +263,14 @@ do_rename(THD *thd, TABLE_LIST *ren_tabl
   }
   DBUG_ASSERT(new_alias);
 
-  build_table_filename(name, sizeof(name),
+  build_table_filename(name, sizeof(name) - 1,
                        new_db, new_alias, reg_ext, 0);
   if (!access(name,F_OK))
   {
     my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
     DBUG_RETURN(1);			// This can't be skipped
   }
-  build_table_filename(name, sizeof(name),
+  build_table_filename(name, sizeof(name) - 1,
                        ren_table->db, old_alias, reg_ext, 0);
 
   frm_type= mysql_frm_type(thd, name, &table_type);

=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc	2009-05-15 12:57:51 +0000
+++ b/sql/sql_repl.cc	2009-06-29 14:00:47 +0000
@@ -147,7 +147,7 @@ static int send_file(THD *thd)
   if (errmsg)
   {
     sql_print_error("Failed in send_file() %s", errmsg);
-    DBUG_PRINT("error", (errmsg));
+    DBUG_PRINT("error", ("%s", errmsg));
   }
   DBUG_RETURN(error);
 }
@@ -1043,6 +1043,7 @@ int reset_slave(THD *thd, Master_info* m
      Reset errors (the idea is that we forget about the
      old master).
   */
+  mi->clear_error();
   mi->rli.clear_error();
   mi->rli.clear_until_condition();
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-06-15 15:57:06 +0000
+++ b/sql/sql_select.cc	2009-07-03 10:43:54 +0000
@@ -1350,7 +1350,7 @@ JOIN::optimize()
         join_tab[const_tables].type != JT_ALL &&
         join_tab[const_tables].type != JT_FT &&
         join_tab[const_tables].type != JT_REF_OR_NULL &&
-        (order && simple_order || group_list && simple_group))
+        ((order && simple_order) || (group_list && simple_group)))
     {
       if (add_ref_to_table_cond(thd,&join_tab[const_tables])) {
         DBUG_RETURN(1);
@@ -1868,9 +1868,9 @@ JOIN::exec()
       like SEC_TO_TIME(SUM(...)).
     */
 
-    if (curr_join->group_list && (!test_if_subpart(curr_join->group_list,
+    if ((curr_join->group_list && (!test_if_subpart(curr_join->group_list,
 						   curr_join->order) || 
-				  curr_join->select_distinct) ||
+				  curr_join->select_distinct)) ||
 	(curr_join->select_distinct &&
 	 curr_join->tmp_table_param.using_indirect_summary_function))
     {					/* Must copy to another table */
@@ -2344,9 +2344,10 @@ mysql_select(THD *thd, Item ***rref_poin
       }
       else
       {
-        if (err= join->prepare(rref_pointer_array, tables, wild_num,
-                               conds, og_num, order, group, having, proc_param,
-                               select_lex, unit))
+        err= join->prepare(rref_pointer_array, tables, wild_num,
+                           conds, og_num, order, group, having, proc_param,
+                           select_lex, unit);
+        if (err)
 	{
 	  goto err;
 	}
@@ -2361,9 +2362,10 @@ mysql_select(THD *thd, Item ***rref_poin
 	DBUG_RETURN(TRUE);
     thd_proc_info(thd, "init");
     thd->used_tables=0;                         // Updated by setup_fields
-    if (err= join->prepare(rref_pointer_array, tables, wild_num,
-                           conds, og_num, order, group, having, proc_param,
-                           select_lex, unit))
+    err= join->prepare(rref_pointer_array, tables, wild_num,
+                       conds, og_num, order, group, having, proc_param,
+                       select_lex, unit);
+    if (err)
     {
       goto err;
     }
@@ -2430,7 +2432,6 @@ static ha_rows get_quick_record_count(TH
   if (select)
   {
     select->head=table;
-    table->reginfo.impossible_range=0;
     if ((error= select->test_quick_select(thd, *(key_map *)keys,(table_map) 0,
                                           limit, 0)) == 1)
       DBUG_RETURN(select->quick->records);
@@ -3841,7 +3842,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
 	if (use->key == prev->key && use->table == prev->table)
 	{
 	  if (prev->keypart+1 < use->keypart ||
-	      prev->keypart == use->keypart && found_eq_constant)
+	      (prev->keypart == use->keypart && found_eq_constant))
 	    continue;				/* remove */
 	}
 	else if (use->keypart != 0)		// First found must be 0
@@ -5146,8 +5147,8 @@ best_extension_by_limited_search(JOIN   
       {
         if (best_record_count > current_record_count ||
             best_read_time > current_read_time ||
-            idx == join->const_tables &&  // 's' is the first table in the QEP
-            s->table == join->sort_by_table)
+            (idx == join->const_tables &&  // 's' is the first table in the QEP
+            s->table == join->sort_by_table))
         {
           if (best_record_count >= current_record_count &&
               best_read_time >= current_read_time &&
@@ -5273,7 +5274,7 @@ find_best(JOIN *join,table_map rest_tabl
       double current_read_time=read_time+best;
       if (best_record_count > current_record_count ||
 	  best_read_time > current_read_time ||
-	  idx == join->const_tables && s->table == join->sort_by_table)
+	  (idx == join->const_tables && s->table == join->sort_by_table))
       {
 	if (best_record_count >= current_record_count &&
 	    best_read_time >= current_read_time &&
@@ -6220,8 +6221,8 @@ make_join_select(JOIN *join,SQL_SELECT *
 	    the index if we are using limit and this is the first table
 	  */
 
-	  if (cond &&
-              (!tab->keys.is_subset(tab->const_keys) && i > 0) ||
+	  if ((cond &&
+              !tab->keys.is_subset(tab->const_keys) && i > 0) ||
 	      (!tab->const_keys.is_clear_all() && i == join->const_tables &&
 	       join->unit->select_limit_cnt <
 	       join->best_positions[i].records_read &&
@@ -7354,7 +7355,7 @@ static bool check_simple_equality(Item *
         left_item_equal->merge(right_item_equal);
         /* Remove the merged multiple equality from the list */
         List_iterator<Item_equal> li(cond_equal->current_level);
-        while ((li++) != right_item_equal);
+        while ((li++) != right_item_equal) ;
         li.remove();
       }
     }
@@ -9390,13 +9391,17 @@ static Field *create_tmp_field_from_item
         +1: for decimal point
       */
 
-      overflow= my_decimal_precision_to_length(intg + dec, dec,
-                                               item->unsigned_flag) - len;
+      const int required_length=
+        my_decimal_precision_to_length(intg + dec, dec,
+                                                     item->unsigned_flag);
+
+      overflow= required_length - len;
 
       if (overflow > 0)
         dec= max(0, dec - overflow);            // too long, discard fract
       else
-        len -= item->decimals - dec;            // corrected value fits
+        /* Corrected value fits. */
+        len= required_length;
     }
 
     new_field= new Field_new_decimal(len, maybe_null, item->name,
@@ -10032,9 +10037,9 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
     reclength=1;				// Dummy select
   /* Use packed rows if there is blobs or a lot of space to gain */
   if (blob_count ||
-      string_total_length >= STRING_TOTAL_LENGTH_TO_PACK_ROWS &&
+      (string_total_length >= STRING_TOTAL_LENGTH_TO_PACK_ROWS &&
       (reclength / string_total_length <= RATIO_TO_PACK_ROWS ||
-       string_total_length / string_count >= AVG_STRING_LENGTH_TO_PACK_ROWS))
+       string_total_length / string_count >= AVG_STRING_LENGTH_TO_PACK_ROWS)))
     use_packed_rows= 1;
 
   share->reclength= reclength;
@@ -10835,9 +10840,8 @@ do_select(JOIN *join,List<Item> *fields,
 {
   int rc= 0;
   enum_nested_loop_state error= NESTED_LOOP_OK;
-  JOIN_TAB *join_tab;
+  JOIN_TAB *join_tab= NULL;
   DBUG_ENTER("do_select");
-  LINT_INIT(join_tab);
   
   join->procedure=procedure;
   join->tmp_table= table;			/* Save for easy recursion */
@@ -13076,9 +13080,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
     */
     uint nr;
     key_map keys;
-    uint best_key_parts;
-    int best_key_direction;
-    ha_rows best_records;
+    uint best_key_parts= 0;
+    int best_key_direction= 0;
+    ha_rows best_records= 0;
     double read_time;
     int best_key= -1;
     bool is_best_covering= FALSE;
@@ -13088,9 +13092,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
     ha_rows table_records= table->file->stats.records;
     bool group= join->group && order == join->group_list;
     ha_rows ref_key_quick_rows= HA_POS_ERROR;
-    LINT_INIT(best_key_parts);
-    LINT_INIT(best_key_direction);
-    LINT_INIT(best_records); 
 
     /*
       If not used with LIMIT, only use keys if the whole query can be
@@ -13135,8 +13136,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
           (direction= test_if_order_by_key(order, table, nr, &used_key_parts)))
       {
         bool is_covering= table->covering_keys.is_set(nr) ||
-                          nr == table->s->primary_key &&
-	                  table->file->primary_key_is_clustered();
+                          (nr == table->s->primary_key &&
+                          table->file->primary_key_is_clustered());
 	
         /* 
           Don't use an index scan with ORDER BY without limit.
@@ -13149,7 +13150,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
 	*/ 
         if (is_covering ||
             select_limit != HA_POS_ERROR || 
-            ref_key < 0 && (group || table->force_index))
+            (ref_key < 0 && (group || table->force_index)))
         { 
           double rec_per_key;
           double index_scan_time;
@@ -13215,12 +13216,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
           index_scan_time= select_limit/rec_per_key *
 	                   min(rec_per_key, table->file->scan_time());
           if (is_covering || 
-              ref_key < 0 && (group || table->force_index) ||
+              (ref_key < 0 && (group || table->force_index)) ||
               index_scan_time < read_time)
           {
             ha_rows quick_records= table_records;
-            if (is_best_covering && !is_covering ||
-                is_covering && ref_key_quick_rows < select_limit)
+            if ((is_best_covering && !is_covering) ||
+                (is_covering && ref_key_quick_rows < select_limit))
               continue;
             if (table->quick_keys.is_set(nr))
               quick_records= table->quick_rows[nr];
@@ -13428,8 +13429,8 @@ create_sort_index(THD *thd, JOIN *join, 
   */
   if ((order != join->group_list || 
        !(join->select_options & SELECT_BIG_RESULT) ||
-       select && select->quick &&
-       select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) &&
+       (select && select->quick &&
+        select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) &&
       test_if_skip_sort_order(tab,order,select_limit,0, 
                               is_order_by ?  &table->keys_in_use_for_order_by :
                               &table->keys_in_use_for_group_by))
@@ -14270,8 +14271,8 @@ find_order_in_list(THD *thd, Item **ref_
     /* Lookup the current GROUP field in the FROM clause. */
     order_item_type= order_item->type();
     from_field= (Field*) not_found_field;
-    if (is_group_field &&
-        order_item_type == Item::FIELD_ITEM ||
+    if ((is_group_field &&
+        order_item_type == Item::FIELD_ITEM) ||
         order_item_type == Item::REF_ITEM)
     {
       from_field= find_field_in_tables(thd, (Item_ident*) order_item, tables,
@@ -14706,7 +14707,7 @@ get_sort_by_table(ORDER *a,ORDER *b,TABL
   if (!map || (map & (RAND_TABLE_BIT | OUTER_REF_TABLE_BIT)))
     DBUG_RETURN(0);
 
-  for (; !(map & tables->table->map); tables= tables->next_leaf);
+  for (; !(map & tables->table->map); tables= tables->next_leaf) ;
   if (map != tables->table->map)
     DBUG_RETURN(0);				// More than one table
   DBUG_PRINT("exit",("sort by table: %d",tables->table->tablenr));

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2009-05-15 12:57:51 +0000
+++ b/sql/sql_show.cc	2009-06-25 10:52:50 +0000
@@ -601,7 +601,7 @@ mysqld_show_create(THD *thd, TABLE_LIST 
   if (open_normal_and_derived_tables(thd, table_list, 0))
   {
     if (!table_list->view ||
-        thd->is_error() && thd->main_da.sql_errno() != ER_VIEW_INVALID)
+        (thd->is_error() && thd->main_da.sql_errno() != ER_VIEW_INVALID))
       DBUG_RETURN(TRUE);
 
     /*
@@ -2819,8 +2819,8 @@ make_table_name_list(THD *thd, List<LEX_
                      LOOKUP_FIELD_VALUES *lookup_field_vals,
                      bool with_i_schema, LEX_STRING *db_name)
 {
-  char path[FN_REFLEN];
-  build_table_filename(path, sizeof(path), db_name->str, "", "", 0);
+  char path[FN_REFLEN + 1];
+  build_table_filename(path, sizeof(path) - 1, db_name->str, "", "", 0);
   if (!lookup_field_vals->wild_table_value &&
       lookup_field_vals->table_value.str)
   {
@@ -2982,8 +2982,8 @@ static int fill_schema_table_names(THD *
   else
   {
     enum legacy_db_type not_used;
-    char path[FN_REFLEN];
-    (void) build_table_filename(path, sizeof(path), db_name->str, 
+    char path[FN_REFLEN + 1];
+    (void) build_table_filename(path, sizeof(path) - 1, db_name->str, 
                                 table_name->str, reg_ext, 0);
     switch (mysql_frm_type(thd, path, &not_used)) {
     case FRMTYPE_ERROR:
@@ -3238,10 +3238,10 @@ int get_all_tables(THD *thd, TABLE_LIST 
       if lookup value is empty string then
       it's impossible table name or db name
     */
-    if (lookup_field_vals.db_value.str &&
-        !lookup_field_vals.db_value.str[0] ||
-        lookup_field_vals.table_value.str &&
-        !lookup_field_vals.table_value.str[0])
+    if ((lookup_field_vals.db_value.str &&
+         !lookup_field_vals.db_value.str[0]) ||
+        (lookup_field_vals.table_value.str &&
+         !lookup_field_vals.table_value.str[0]))
     {
       error= 0;
       goto err;
@@ -3470,7 +3470,7 @@ int fill_schema_schemata(THD *thd, TABLE
     MY_STAT stat_info;
     if (!lookup_field_vals.db_value.str[0])
       DBUG_RETURN(0);
-    path_len= build_table_filename(path, sizeof(path),
+    path_len= build_table_filename(path, sizeof(path) - 1,
                                    lookup_field_vals.db_value.str, "", "", 0);
     path[path_len-1]= 0;
     if (!my_stat(path,&stat_info,MYF(0)))
@@ -4116,10 +4116,10 @@ bool store_schema_proc(THD *thd, TABLE *
                                                 TYPE_ENUM_PROCEDURE))
     return 0;
 
-  if (lex->sql_command == SQLCOM_SHOW_STATUS_PROC &&
-      proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE ||
-      lex->sql_command == SQLCOM_SHOW_STATUS_FUNC &&
-      proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION ||
+  if ((lex->sql_command == SQLCOM_SHOW_STATUS_PROC &&
+      proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE) ||
+      (lex->sql_command == SQLCOM_SHOW_STATUS_FUNC &&
+      proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION) ||
       (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0)
   {
     restore_record(table, s->default_values);
@@ -7071,6 +7071,12 @@ bool show_create_trigger(THD *thd, const
   if (!lst)
     return TRUE;
 
+  if (check_table_access(thd, TRIGGER_ACL, lst, 1, TRUE))
+  {
+    my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "TRIGGER");
+    return TRUE;
+  }
+
   /*
     Open the table by name in order to load Table_triggers_list object.
 

=== modified file 'sql/sql_string.cc'
--- a/sql/sql_string.cc	2009-05-21 08:06:43 +0000
+++ b/sql/sql_string.cc	2009-06-16 14:36:15 +0000
@@ -322,14 +322,23 @@ bool String::set_or_copy_aligned(const c
   return copy_aligned(str, arg_length, offset, cs);
 }
 
-	/* Copy with charset conversion */
+
+/**
+   Copies the character data into this String, with optional character set
+   conversion.
+
+   @return
+   FALSE ok
+   TRUE  Could not allocate result buffer
+
+*/
 
 bool String::copy(const char *str, uint32 arg_length,
 		  CHARSET_INFO *from_cs, CHARSET_INFO *to_cs, uint *errors)
 {
   uint32 offset;
-  
-  DBUG_ASSERT(str != Ptr);
+
+  DBUG_ASSERT(!str || str != Ptr);
   
   if (!needs_conversion(arg_length, from_cs, to_cs, &offset))
   {

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-06-02 09:07:17 +0000
+++ b/sql/sql_table.cc	2009-07-06 06:55:53 +0000
@@ -1515,7 +1515,7 @@ bool mysql_write_frm(ALTER_PARTITION_PAR
   /*
     Build shadow frm file name
   */
-  build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
+  build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
   strxmov(shadow_frm_name, shadow_path, reg_ext, NullS);
   if (flags & WFRM_WRITE_SHADOW)
   {
@@ -1590,7 +1590,7 @@ bool mysql_write_frm(ALTER_PARTITION_PAR
     /*
       Build frm file name
     */
-    build_table_filename(path, sizeof(path), lpt->db,
+    build_table_filename(path, sizeof(path) - 1, lpt->db,
                          lpt->table_name, "", 0);
     strxmov(frm_name, path, reg_ext, NullS);
     /*
@@ -1792,7 +1792,7 @@ int mysql_rm_table_part2(THD *thd, TABLE
 			 bool dont_log_query)
 {
   TABLE_LIST *table;
-  char path[FN_REFLEN], *alias;
+  char path[FN_REFLEN + 1], *alias;
   uint path_length;
   String wrong_tables;
   int error= 0;
@@ -1922,13 +1922,14 @@ int mysql_rm_table_part2(THD *thd, TABLE
       }
       alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
       /* remove .frm file and engine files */
-      path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext,
+      path_length= build_table_filename(path, sizeof(path) - 1, db, alias,
+                                        reg_ext,
                                         table->internal_tmp_table ?
                                         FN_IS_TMP : 0);
     }
     if (drop_temporary ||
-        (table_type == NULL &&        
-         (access(path, F_OK) &&
+        ((table_type == NULL &&        
+         access(path, F_OK) &&
           ha_create_table_from_engine(thd, db, alias)) ||
          (!drop_view &&
           mysql_frm_type(thd, path, &frm_db_type) != FRMTYPE_TABLE)))
@@ -2010,7 +2011,7 @@ int mysql_rm_table_part2(THD *thd, TABLE
     if (!dont_log_query)
     {
       if (!thd->current_stmt_binlog_row_based ||
-          non_temp_tables_count > 0 && !tmp_table_deleted)
+          (non_temp_tables_count > 0 && !tmp_table_deleted))
       {
         /*
           In this case, we are either using statement-based
@@ -2078,11 +2079,11 @@ err_with_placeholders:
 bool quick_rm_table(handlerton *base,const char *db,
                     const char *table_name, uint flags)
 {
-  char path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
   bool error= 0;
   DBUG_ENTER("quick_rm_table");
 
-  uint path_length= build_table_filename(path, sizeof(path),
+  uint path_length= build_table_filename(path, sizeof(path) - 1,
                                          db, table_name, reg_ext, flags);
   if (my_delete(path,MYF(0)))
     error= 1; /* purecov: inspected */
@@ -2719,8 +2720,8 @@ mysql_prepare_create_table(THD *thd, HA_
     }
     /* Don't pack rows in old tables if the user has requested this */
     if ((sql_field->flags & BLOB_FLAG) ||
-	sql_field->sql_type == MYSQL_TYPE_VARCHAR &&
-	create_info->row_type != ROW_TYPE_FIXED)
+	(sql_field->sql_type == MYSQL_TYPE_VARCHAR &&
+	create_info->row_type != ROW_TYPE_FIXED))
       (*db_options)|= HA_OPTION_PACK_RECORD;
     it2.rewind();
   }
@@ -3189,7 +3190,7 @@ mysql_prepare_create_table(THD *thd, HA_
 	    sql_field->sql_type == MYSQL_TYPE_VARCHAR ||
 	    sql_field->pack_flag & FIELDFLAG_BLOB)))
       {
-	if (column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB) ||
+	if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) ||
             sql_field->sql_type == MYSQL_TYPE_VARCHAR)
 	  key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
 	else
@@ -3471,7 +3472,7 @@ bool mysql_create_table_no_lock(THD *thd
                                 bool internal_tmp_table,
                                 uint select_field_count)
 {
-  char		path[FN_REFLEN];
+  char		path[FN_REFLEN + 1];
   uint          path_length;
   const char	*alias;
   uint		db_options, key_count;
@@ -3679,7 +3680,7 @@ bool mysql_create_table_no_lock(THD *thd
   }
   else  
   {
-    path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext,
+    path_length= build_table_filename(path, sizeof(path) - 1, db, alias, reg_ext,
                                       internal_tmp_table ? FN_IS_TMP : 0);
   }
 
@@ -3993,7 +3994,8 @@ mysql_rename_table(handlerton *base, con
                    const char *new_name, uint flags)
 {
   THD *thd= current_thd;
-  char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN];
+  char from[FN_REFLEN + 1], to[FN_REFLEN + 1],
+    lc_from[FN_REFLEN + 1], lc_to[FN_REFLEN + 1];
   char *from_base= from, *to_base= to;
   char tmp_name[NAME_LEN+1];
   handler *file;
@@ -4005,9 +4007,9 @@ mysql_rename_table(handlerton *base, con
   file= (base == NULL ? 0 :
          get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base));
 
-  build_table_filename(from, sizeof(from), old_db, old_name, "",
+  build_table_filename(from, sizeof(from) - 1, old_db, old_name, "",
                        flags & FN_FROM_IS_TMP);
-  build_table_filename(to, sizeof(to), new_db, new_name, "",
+  build_table_filename(to, sizeof(to) - 1, new_db, new_name, "",
                        flags & FN_TO_IS_TMP);
 
   /*
@@ -4020,13 +4022,13 @@ mysql_rename_table(handlerton *base, con
   {
     strmov(tmp_name, old_name);
     my_casedn_str(files_charset_info, tmp_name);
-    build_table_filename(lc_from, sizeof(lc_from), old_db, tmp_name, "",
+    build_table_filename(lc_from, sizeof(lc_from) - 1, old_db, tmp_name, "",
                          flags & FN_FROM_IS_TMP);
     from_base= lc_from;
 
     strmov(tmp_name, new_name);
     my_casedn_str(files_charset_info, tmp_name);
-    build_table_filename(lc_to, sizeof(lc_to), new_db, tmp_name, "",
+    build_table_filename(lc_to, sizeof(lc_to) - 1, new_db, tmp_name, "",
                          flags & FN_TO_IS_TMP);
     to_base= lc_to;
   }
@@ -4157,16 +4159,16 @@ static int prepare_for_restore(THD* thd,
   else
   {
     char* backup_dir= thd->lex->backup_dir;
-    char src_path[FN_REFLEN], dst_path[FN_REFLEN], uname[FN_REFLEN];
+    char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1], uname[FN_REFLEN];
     char* table_name= table->table_name;
     char* db= table->db;
 
-    VOID(tablename_to_filename(table->table_name, uname, sizeof(uname)));
+    VOID(tablename_to_filename(table->table_name, uname, sizeof(uname) - 1));
 
     if (fn_format_relative_to_data_home(src_path, uname, backup_dir, reg_ext))
       DBUG_RETURN(-1); // protect buffer overflow
 
-    build_table_filename(dst_path, sizeof(dst_path),
+    build_table_filename(dst_path, sizeof(dst_path) - 1,
                          db, table_name, reg_ext, 0);
 
     if (lock_and_wait_for_table_name(thd,table))
@@ -4778,7 +4780,7 @@ send_result_message:
           const char *err_msg= thd->main_da.message();
           if (!thd->vio_ok())
           {
-            sql_print_error(err_msg);
+            sql_print_error("%s", err_msg);
           }
           else
           {
@@ -5088,7 +5090,7 @@ bool mysql_create_like_table(THD* thd, T
                              HA_CREATE_INFO *create_info)
 {
   TABLE *name_lock= 0;
-  char src_path[FN_REFLEN], dst_path[FN_REFLEN];
+  char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1];
   uint dst_path_length;
   char *db= table->db;
   char *table_name= table->table_name;
@@ -5098,7 +5100,7 @@ bool mysql_create_like_table(THD* thd, T
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   char tmp_path[FN_REFLEN];
 #endif
-  char ts_name[FN_LEN];
+  char ts_name[FN_LEN + 1];
   DBUG_ENTER("mysql_create_like_table");
 
 
@@ -5147,7 +5149,7 @@ bool mysql_create_like_table(THD* thd, T
       goto err;
     if (!name_lock)
       goto table_exists;
-    dst_path_length= build_table_filename(dst_path, sizeof(dst_path),
+    dst_path_length= build_table_filename(dst_path, sizeof(dst_path) - 1,
                                           db, table_name, reg_ext, 0);
     if (!access(dst_path, F_OK))
       goto table_exists;
@@ -5589,8 +5591,8 @@ compare_tables(TABLE *table,
     /* Don't pack rows in old tables if the user has requested this. */
     if (create_info->row_type == ROW_TYPE_DYNAMIC ||
 	(tmp_new_field->flags & BLOB_FLAG) ||
-	tmp_new_field->sql_type == MYSQL_TYPE_VARCHAR &&
-	create_info->row_type != ROW_TYPE_FIXED)
+	(tmp_new_field->sql_type == MYSQL_TYPE_VARCHAR &&
+	create_info->row_type != ROW_TYPE_FIXED))
       create_info->table_options|= HA_OPTION_PACK_RECORD;
 
     /* Check if field was renamed */
@@ -5888,7 +5890,7 @@ mysql_prepare_alter_table(THD *thd, TABL
 
   if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY)
   {
-    char *tablespace= static_cast<char *>(thd->alloc(FN_LEN));
+    char *tablespace= static_cast<char *>(thd->alloc(FN_LEN + 1));
     /*
        Regular alter table of disk stored table (no tablespace/storage change)
        Copy tablespace name
@@ -6255,10 +6257,10 @@ bool mysql_alter_table(THD *thd,char *ne
 {
   TABLE *table, *new_table= 0, *name_lock= 0;
   int error= 0;
-  char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN];
+  char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1];
   char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias;
   char index_file[FN_REFLEN], data_file[FN_REFLEN];
-  char path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
   char reg_path[FN_REFLEN+1];
   ha_rows copied,deleted;
   handlerton *old_db_type, *new_db_type, *save_old_db_type;
@@ -6271,21 +6273,15 @@ bool mysql_alter_table(THD *thd,char *ne
 #endif
   bool need_lock_for_indexes= TRUE;
   KEY  *key_info_buffer;
-  uint index_drop_count;
-  uint *index_drop_buffer;
-  uint index_add_count;
-  uint *index_add_buffer;
-  uint candidate_key_count;
+  uint index_drop_count= 0;
+  uint *index_drop_buffer= NULL;
+  uint index_add_count= 0;
+  uint *index_add_buffer= NULL;
+  uint candidate_key_count= 0;
   bool committed= 0;
   bool no_pk;
   DBUG_ENTER("mysql_alter_table");
 
-  LINT_INIT(index_add_count);
-  LINT_INIT(index_drop_count);
-  LINT_INIT(index_add_buffer);
-  LINT_INIT(index_drop_buffer);
-  LINT_INIT(candidate_key_count);
-
   /*
     Check if we attempt to alter mysql.slow_log or
     mysql.general_log table and return an error if
@@ -6339,8 +6335,8 @@ bool mysql_alter_table(THD *thd,char *ne
   db=table_list->db;
   if (!new_db || !my_strcasecmp(table_alias_charset, new_db, db))
     new_db= db;
-  build_table_filename(reg_path, sizeof(reg_path), db, table_name, reg_ext, 0);
-  build_table_filename(path, sizeof(path), db, table_name, "", 0);
+  build_table_filename(reg_path, sizeof(reg_path) - 1, db, table_name, reg_ext, 0);
+  build_table_filename(path, sizeof(path) - 1, db, table_name, "", 0);
 
   mysql_ha_rm_tables(thd, table_list, FALSE);
 
@@ -6487,7 +6483,7 @@ view_err:
 	  DBUG_RETURN(TRUE);
         }
 
-        build_table_filename(new_name_buff, sizeof(new_name_buff),
+        build_table_filename(new_name_buff, sizeof(new_name_buff) - 1,
                              new_db, new_name_buff, reg_ext, 0);
         if (!access(new_name_buff, F_OK))
 	{
@@ -6988,9 +6984,9 @@ view_err:
     }
     else
     {
-      char path[FN_REFLEN];
+      char path[FN_REFLEN + 1];
       /* table is a normal table: Create temporary table in same directory */
-      build_table_filename(path, sizeof(path), new_db, tmp_name, "",
+      build_table_filename(path, sizeof(path) - 1, new_db, tmp_name, "",
                            FN_IS_TMP);
       /* Open our intermediate table */
       new_table=open_temporary_table(thd, path, new_db, tmp_name,0);
@@ -7220,12 +7216,12 @@ view_err:
   }
   else if (mysql_rename_table(new_db_type, new_db, tmp_name, new_db,
                               new_alias, FN_FROM_IS_TMP) ||
-           (new_name != table_name || new_db != db) && // we also do rename
+           ((new_name != table_name || new_db != db) && // we also do rename
            (need_copy_table != ALTER_TABLE_METADATA_ONLY ||
             mysql_rename_table(save_old_db_type, db, table_name, new_db,
                                new_alias, NO_FRM_RENAME)) &&
            Table_triggers_list::change_table_name(thd, db, table_name,
-                                                  new_db, new_alias))
+                                                  new_db, new_alias)))
   {
     /* Try to get everything back. */
     error=1;
@@ -7318,7 +7314,7 @@ view_err:
     */
     char path[FN_REFLEN];
     TABLE *t_table;
-    build_table_filename(path, sizeof(path), new_db, table_name, "", 0);
+    build_table_filename(path + 1, sizeof(path) - 1, new_db, table_name, "", 0);
     t_table= open_temporary_table(thd, path, new_db, tmp_name, 0);
     if (t_table)
     {

=== modified file 'sql/sql_trigger.cc'
--- a/sql/sql_trigger.cc	2009-05-15 12:57:51 +0000
+++ b/sql/sql_trigger.cc	2009-06-17 14:56:44 +0000
@@ -344,7 +344,7 @@ bool mysql_create_or_drop_trigger(THD *t
     need second part of condition below, since check_access() function also
     checks that db is specified.
   */
-  if (!thd->lex->spname->m_db.length || create && !tables->db_length)
+  if (!thd->lex->spname->m_db.length || (create && !tables->db_length))
   {
     my_error(ER_NO_DB_ERROR, MYF(0));
     DBUG_RETURN(TRUE);

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2009-05-30 13:32:28 +0000
+++ b/sql/sql_update.cc	2009-06-18 14:16:14 +0000
@@ -803,8 +803,7 @@ int mysql_update(THD *thd,
 
       if (thd->binlog_query(THD::ROW_QUERY_TYPE,
                             thd->query, thd->query_length,
-                            transactional_table, FALSE, errcode) &&
-          transactional_table)
+                            transactional_table, FALSE, errcode))
       {
         error=1;				// Rollback update
       }
@@ -1814,7 +1813,7 @@ void multi_update::abort()
 {
   /* the error was handled or nothing deleted and no side effects return */
   if (error_handled ||
-      !thd->transaction.stmt.modified_non_trans_table && !updated)
+      (!thd->transaction.stmt.modified_non_trans_table && !updated))
     return;
 
   /* Something already updated so we have to invalidate cache */
@@ -2087,8 +2086,7 @@ bool multi_update::send_eof()
         errcode= query_error_code(thd, killed_status == THD::NOT_KILLED);
       if (thd->binlog_query(THD::ROW_QUERY_TYPE,
                             thd->query, thd->query_length,
-                            transactional_tables, FALSE, errcode) &&
-          trans_safe)
+                            transactional_tables, FALSE, errcode))
       {
 	local_error= 1;				// Rollback update
       }

=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc	2009-05-30 13:32:28 +0000
+++ b/sql/sql_view.cc	2009-06-19 08:24:43 +0000
@@ -801,7 +801,7 @@ static int mysql_register_view(THD *thd,
 
   char md5[MD5_BUFF_LENGTH];
   bool can_be_merged;
-  char dir_buff[FN_REFLEN], path_buff[FN_REFLEN];
+  char dir_buff[FN_REFLEN + 1], path_buff[FN_REFLEN + 1];
   LEX_STRING dir, file, path;
   int error= 0;
   DBUG_ENTER("mysql_register_view");
@@ -878,11 +878,11 @@ static int mysql_register_view(THD *thd,
   }
 loop_out:
   /* print file name */
-  dir.length= build_table_filename(dir_buff, sizeof(dir_buff),
+  dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1,
                                    view->db, "", "", 0);
   dir.str= dir_buff;
 
-  path.length= build_table_filename(path_buff, sizeof(path_buff),
+  path.length= build_table_filename(path_buff, sizeof(path_buff) - 1,
                                     view->db, view->table_name, reg_ext, 0);
   path.str= path_buff;
 
@@ -1569,7 +1569,7 @@ err:
 
 bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
 {
-  char path[FN_REFLEN];
+  char path[FN_REFLEN + 1];
   TABLE_LIST *view;
   String non_existant_views;
   char *wrong_object_db= NULL, *wrong_object_name= NULL;
@@ -1584,7 +1584,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIS
   {
     TABLE_SHARE *share;
     frm_type_enum type= FRMTYPE_ERROR;
-    build_table_filename(path, sizeof(path),
+    build_table_filename(path, sizeof(path) - 1,
                          view->db, view->table_name, reg_ext, 0);
 
     if (access(path, F_OK) || 
@@ -1929,7 +1929,7 @@ mysql_rename_view(THD *thd,
 {
   LEX_STRING pathstr;
   File_parser *parser;
-  char path_buff[FN_REFLEN];
+  char path_buff[FN_REFLEN + 1];
   bool error= TRUE;
   DBUG_ENTER("mysql_rename_view");
 
@@ -1942,7 +1942,7 @@ mysql_rename_view(THD *thd,
        is_equal(&view_type, parser->type()))
   {
     TABLE_LIST view_def;
-    char dir_buff[FN_REFLEN];
+    char dir_buff[FN_REFLEN + 1];
     LEX_STRING dir, file;
 
     /*

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2009-06-01 12:43:16 +0000
+++ b/sql/sql_yacc.yy	2009-06-17 14:56:44 +0000
@@ -5925,7 +5925,7 @@ alter_list_item:
               MYSQL_YYABORT;
             }
             if (check_table_name($3->table.str,$3->table.length) ||
-                $3->db.str && check_db_name(&$3->db))
+                ($3->db.str && check_db_name(&$3->db)))
             {
               my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
               MYSQL_YYABORT;
@@ -6079,8 +6079,8 @@ slave_until:
         | UNTIL_SYM slave_until_opts
           {
             LEX *lex=Lex;
-            if ((lex->mi.log_file_name || lex->mi.pos) &&
-                (lex->mi.relay_log_name || lex->mi.relay_log_pos) ||
+            if (((lex->mi.log_file_name || lex->mi.pos) &&
+                (lex->mi.relay_log_name || lex->mi.relay_log_pos)) ||
                 !((lex->mi.log_file_name && lex->mi.pos) ||
                   (lex->mi.relay_log_name && lex->mi.relay_log_pos)))
             {

=== modified file 'sql/structs.h'
--- a/sql/structs.h	2009-05-15 12:57:51 +0000
+++ b/sql/structs.h	2009-06-26 19:57:42 +0000
@@ -107,6 +107,10 @@ typedef struct st_reginfo {		/* Extra in
   struct st_join_table *join_tab;	/* Used by SELECT() */
   enum thr_lock_type lock_type;		/* How database is used */
   bool not_exists_optimize;
+  /*
+    TRUE <=> range optimizer found that there is no rows satisfying
+    table conditions.
+  */
   bool impossible_range;
 } REGINFO;
 

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2009-05-27 15:19:44 +0000
+++ b/sql/table.cc	2009-06-17 14:56:44 +0000
@@ -464,34 +464,35 @@ inline bool is_system_table_name(const c
   CHARSET_INFO *ci= system_charset_info;
 
   return (
-          /* mysql.proc table */
-          length == 4 &&
-          my_tolower(ci, name[0]) == 'p' && 
-          my_tolower(ci, name[1]) == 'r' &&
-          my_tolower(ci, name[2]) == 'o' &&
-          my_tolower(ci, name[3]) == 'c' ||
-
-          length > 4 &&
-          (
-           /* one of mysql.help* tables */
-           my_tolower(ci, name[0]) == 'h' &&
-           my_tolower(ci, name[1]) == 'e' &&
-           my_tolower(ci, name[2]) == 'l' &&
-           my_tolower(ci, name[3]) == 'p' ||
-
-           /* one of mysql.time_zone* tables */
-           my_tolower(ci, name[0]) == 't' &&
-           my_tolower(ci, name[1]) == 'i' &&
-           my_tolower(ci, name[2]) == 'm' &&
-           my_tolower(ci, name[3]) == 'e' ||
-
-           /* mysql.event table */
-           my_tolower(ci, name[0]) == 'e' &&
-           my_tolower(ci, name[1]) == 'v' &&
-           my_tolower(ci, name[2]) == 'e' &&
-           my_tolower(ci, name[3]) == 'n' &&
-           my_tolower(ci, name[4]) == 't'
-          )
+           /* mysql.proc table */
+           (length == 4 &&
+             my_tolower(ci, name[0]) == 'p' && 
+             my_tolower(ci, name[1]) == 'r' &&
+             my_tolower(ci, name[2]) == 'o' &&
+             my_tolower(ci, name[3]) == 'c') ||
+
+           (length > 4 &&
+             (
+               /* one of mysql.help* tables */
+               (my_tolower(ci, name[0]) == 'h' &&
+                 my_tolower(ci, name[1]) == 'e' &&
+                 my_tolower(ci, name[2]) == 'l' &&
+                 my_tolower(ci, name[3]) == 'p') ||
+
+               /* one of mysql.time_zone* tables */
+               (my_tolower(ci, name[0]) == 't' &&
+                 my_tolower(ci, name[1]) == 'i' &&
+                 my_tolower(ci, name[2]) == 'm' &&
+                 my_tolower(ci, name[3]) == 'e') ||
+
+               /* mysql.event table */
+               (my_tolower(ci, name[0]) == 'e' &&
+                 my_tolower(ci, name[1]) == 'v' &&
+                 my_tolower(ci, name[2]) == 'e' &&
+                 my_tolower(ci, name[3]) == 'n' &&
+                 my_tolower(ci, name[4]) == 't')
+             )
+           )
          );
 }
 
@@ -3314,8 +3315,8 @@ bool TABLE_LIST::prep_check_option(THD *
   {
     const char *save_where= thd->where;
     thd->where= "check option";
-    if (!check_option->fixed &&
-        check_option->fix_fields(thd, &check_option) ||
+    if ((!check_option->fixed &&
+        check_option->fix_fields(thd, &check_option)) ||
         check_option->check_cols(1))
     {
       DBUG_RETURN(TRUE);
@@ -4031,7 +4032,7 @@ void Field_iterator_table_ref::set_field
     /* Necesary, but insufficient conditions. */
     DBUG_ASSERT(table_ref->is_natural_join ||
                 table_ref->nested_join ||
-                table_ref->join_columns &&
+                (table_ref->join_columns &&
                 /* This is a merge view. */
                 ((table_ref->field_translation &&
                   table_ref->join_columns->elements ==
@@ -4040,7 +4041,7 @@ void Field_iterator_table_ref::set_field
                  /* This is stored table or a tmptable view. */
                  (!table_ref->field_translation &&
                   table_ref->join_columns->elements ==
-                  table_ref->table->s->fields)));
+                  table_ref->table->s->fields))));
     field_it= &natural_join_it;
     DBUG_PRINT("info",("field_it for '%s' is Field_iterator_natural_join",
                        table_ref->alias));

=== modified file 'sql/thr_malloc.cc'
--- a/sql/thr_malloc.cc	2009-01-15 18:11:25 +0000
+++ b/sql/thr_malloc.cc	2009-06-29 14:00:47 +0000
@@ -21,7 +21,7 @@
 extern "C" {
   void sql_alloc_error_handler(void)
   {
-    sql_print_error(ER(ER_OUT_OF_RESOURCES));
+    sql_print_error("%s", ER(ER_OUT_OF_RESOURCES));
 
     THD *thd= current_thd;
     if (thd)

=== modified file 'sql/time.cc'
--- a/sql/time.cc	2007-08-28 00:41:29 +0000
+++ b/sql/time.cc	2009-06-17 14:56:44 +0000
@@ -111,8 +111,8 @@ uint calc_week(MYSQL_TIME *l_time, uint 
   if (l_time->month == 1 && l_time->day <= 7-weekday)
   {
     if (!week_year && 
-	(first_weekday && weekday != 0 ||
-	 !first_weekday && weekday >= 4))
+	((first_weekday && weekday != 0) ||
+	 (!first_weekday && weekday >= 4)))
       return 0;
     week_year= 1;
     (*year)--;
@@ -129,8 +129,8 @@ uint calc_week(MYSQL_TIME *l_time, uint 
   if (week_year && days >= 52*7)
   {
     weekday= (weekday + calc_days_in_year(*year)) % 7;
-    if (!first_weekday && weekday < 4 ||
-	first_weekday && weekday == 0)
+    if ((!first_weekday && weekday < 4) ||
+	(first_weekday && weekday == 0))
     {
       (*year)++;
       return 1;

=== modified file 'sql/tztime.cc'
--- a/sql/tztime.cc	2009-05-15 12:57:51 +0000
+++ b/sql/tztime.cc	2009-06-17 14:56:44 +0000
@@ -447,8 +447,8 @@ prepare_tz_info(TIME_ZONE_INFO *sp, MEM_
     }
 
     if (end_t == MY_TIME_T_MAX ||
-        (cur_off_and_corr > 0) &&
-        (end_t >= MY_TIME_T_MAX - cur_off_and_corr))
+        ((cur_off_and_corr > 0) &&
+        (end_t >= MY_TIME_T_MAX - cur_off_and_corr)))
       /* end of t space */
       break;
 

=== modified file 'sql/uniques.cc'
--- a/sql/uniques.cc	2009-02-13 16:41:47 +0000
+++ b/sql/uniques.cc	2009-06-17 14:56:44 +0000
@@ -603,9 +603,9 @@ bool Unique::get(TABLE *table)
   outfile=table->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE),
                                 MYF(MY_ZEROFILL));
 
-  if (!outfile || ! my_b_inited(outfile) &&
+  if (!outfile || (! my_b_inited(outfile) &&
       open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER,
-		       MYF(MY_WME)))
+		       MYF(MY_WME))))
     return 1;
   reinit_io_cache(outfile,WRITE_CACHE,0L,0,0);
 

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2009-05-15 13:03:22 +0000
+++ b/storage/federated/ha_federated.cc	2009-06-17 14:56:44 +0000
@@ -2828,34 +2828,32 @@ int ha_federated::info(uint flag)
     if (!(row= mysql_fetch_row(result)))
       goto error;
 
-    if (flag & (HA_STATUS_VARIABLE | HA_STATUS_CONST))
-    {
-      /*
-        deleted is set in ha_federated::info
-      */
-      /*
-        need to figure out what this means as far as federated is concerned,
-        since we don't have a "file"
-
-        data_file_length = ?
-        index_file_length = ?
-        delete_length = ?
-      */
-      if (row[4] != NULL)
-        stats.records=   (ha_rows) my_strtoll10(row[4], (char**) 0,
+    /*
+      deleted is set in ha_federated::info
+    */
+    /*
+      need to figure out what this means as far as federated is concerned,
+      since we don't have a "file"
+
+      data_file_length = ?
+      index_file_length = ?
+      delete_length = ?
+    */
+    if (row[4] != NULL)
+      stats.records=   (ha_rows) my_strtoll10(row[4], (char**) 0,
                                                        &error);
-      if (row[5] != NULL)
-        stats.mean_rec_length= (ulong) my_strtoll10(row[5], (char**) 0, &error);
+    if (row[5] != NULL)
+      stats.mean_rec_length= (ulong) my_strtoll10(row[5], (char**) 0, &error);
 
-      stats.data_file_length= stats.records * stats.mean_rec_length;
+    stats.data_file_length= stats.records * stats.mean_rec_length;
 
-      if (row[12] != NULL)
-        stats.update_time=     (ulong) my_strtoll10(row[12], (char**) 0,
+    if (row[12] != NULL)
+      stats.update_time=     (ulong) my_strtoll10(row[12], (char**) 0,
                                                       &error);
-      if (row[13] != NULL)
-        stats.check_time=      (ulong) my_strtoll10(row[13], (char**) 0,
+    if (row[13] != NULL)
+      stats.check_time=      (ulong) my_strtoll10(row[13], (char**) 0,
                                                       &error);
-    }
+
     /*
       size of IO operations (This is based on a good guess, no high science
       involved)

=== modified file 'storage/ibmdb2i/db2i_charsetSupport.cc'
--- a/storage/ibmdb2i/db2i_charsetSupport.cc	2009-06-01 07:22:10 +0000
+++ b/storage/ibmdb2i/db2i_charsetSupport.cc	2009-07-02 08:04:23 +0000
@@ -384,6 +384,11 @@ static int32 convertTextDesc(const int32
         strcpy(outDesc,"IBM-1256");
         DBUG_RETURN(0);
       }
+      else if (strcmp("macce", inDescOverride) == 0)
+      {
+        strcpy(outDesc,"IBM-1282");
+        DBUG_RETURN(0);
+      }
     }
     else if (outType == Qlg_TypeAS400CCSID)
     {

=== modified file 'storage/ibmdb2i/db2i_collationSupport.cc'
--- a/storage/ibmdb2i/db2i_collationSupport.cc	2009-04-10 06:26:54 +0000
+++ b/storage/ibmdb2i/db2i_collationSupport.cc	2009-06-29 02:02:17 +0000
@@ -44,7 +44,7 @@ OF SUCH DAMAGE.
   between corresponding array slots but is incomplete without case-sensitivity
   markers dynamically added to the mySqlSortSequence names.
 */
-#define MAX_COLLATION 89
+#define MAX_COLLATION 87
 static const char* mySQLCollation[MAX_COLLATION] = 
 {
     {"ascii_general"},
@@ -52,7 +52,6 @@ static const char* mySQLCollation[MAX_CO
     {"big5_chinese"},
     {"big5"},
     {"cp1250_croatian"},
-    {"cp1250_czech"},
     {"cp1250_general"},
     {"cp1250_polish"},
     {"cp1250"},
@@ -84,7 +83,6 @@ static const char* mySQLCollation[MAX_CO
     {"latin1_swedish"},
     {"latin1"},
     {"latin2_croatian"},
-    {"latin2_czech"},
     {"latin2_general"},
     {"latin2_hungarian"},
     {"latin2"},
@@ -146,7 +144,6 @@ static const char* mySqlSortSequence[MAX
     {"QACHT04B0"},  
     {"QBCHT04B0"},
     {"QALA20481"},  
-    {"QBLA20481"},
     {"QCLA20481"},
     {"QDLA20481"},
     {"QELA20481"},
@@ -178,7 +175,6 @@ static const char* mySqlSortSequence[MAX
     {"QELA1047C"},
     {"QFLA1047C"},
     {"QCLA20366"},  
-    {"QDLA20366"},
     {"QELA20366"},
     {"QFLA20366"},
     {"QGLA20366"},
@@ -190,8 +186,8 @@ static const char* mySqlSortSequence[MAX
     {"QDJPN04B0"},
     {"QATHA0346"},  
     {"QBTHA0346"},  
-    {"ACS"},        
-    {"ADA"},
+    {"ACS_CZ"},        
+    {"ADA_DK"},
     {"AEO"},
     {"AET"},
     {"QAUCS04B0"},  
@@ -211,8 +207,8 @@ static const char* mySqlSortSequence[MAX
     {"*HEX"},
     {"QEJPN04B0"},  
     {"QFJPN04B0"},
-    {"ACS"},        
-    {"ADA"},
+    {"ACS_CZ"},        
+    {"ADA_DK"},
     {"AEO"},
     {"AET"},
     {"QAUCS04B0"},

=== modified file 'storage/ibmdb2i/db2i_conversion.cc'
--- a/storage/ibmdb2i/db2i_conversion.cc	2009-05-29 09:31:00 +0000
+++ b/storage/ibmdb2i/db2i_conversion.cc	2009-07-06 08:49:32 +0000
@@ -137,7 +137,9 @@ int ha_ibmdb2i::convertFieldChars(enum_c
                                   char* output, 
                                   size_t ilen, 
                                   size_t olen, 
-                                  size_t* outDataLen)
+                                  size_t* outDataLen,
+                                  bool tacitErrors,
+                                  size_t* substChars)
 {
   DBUG_PRINT("ha_ibmdb2i::convertFieldChars",("Direction: %d; length = %d", direction, ilen));
   
@@ -157,26 +159,26 @@ int ha_ibmdb2i::convertFieldChars(enum_c
   size_t initOLen= olen;
   size_t substitutedChars = 0;
   int rc = iconv(conversion, (char**)&input, &ilen, &output, &olen, &substitutedChars );
+  if (outDataLen) *outDataLen = initOLen - olen;
+  if (substChars) *substChars = substitutedChars;
   if (unlikely(rc < 0))
   {
     int er = errno;
     if (er == EILSEQ)
     {
-      getErrTxt(DB2I_ERR_ILL_CHAR, table->field[fieldID]->field_name);
+      if (!tacitErrors) getErrTxt(DB2I_ERR_ILL_CHAR, table->field[fieldID]->field_name);
       return (DB2I_ERR_ILL_CHAR);
     }
     else
     {
-      getErrTxt(DB2I_ERR_ICONV,er);
+      if (!tacitErrors) getErrTxt(DB2I_ERR_ICONV,er);
       return (DB2I_ERR_ICONV);
     }
   }
-  if (unlikely(substitutedChars))
+  if (unlikely(substitutedChars) && (!tacitErrors))
   {
     warning(ha_thd(), DB2I_ERR_SUB_CHARS, table->field[fieldID]->field_name);
   }
-    
-  if (outDataLen) *outDataLen = initOLen - olen;
 
   return (0);
 }
@@ -555,12 +557,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Fiel
                 return 1;
               if (fieldCharSet->mbmaxlen > 1)
               {
-                if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+                if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
                 {
                   sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
                   db2Ccsid = 13488;
                 }
-                else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+                else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
                          strcmp(fieldCharSet->name, "utf8_general_ci") != 0) 
                 {
                   sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1)); // Number of bytes
@@ -584,12 +586,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Fiel
               {
                 if (fieldCharSet->mbmaxlen > 1)
                 {
-                  if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+                  if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
                   {
                     sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
                     db2Ccsid = 13488;
                   }
-                  else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+                  else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
                            strcmp(fieldCharSet->name, "utf8_general_ci") != 0) 
                   {
                     sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1)); // Number of bytes
@@ -611,12 +613,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Fiel
               {
                 if (fieldCharSet->mbmaxlen > 1)
                 {
-                  if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+                  if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
                   {
                     sprintf(stringBuildBuffer, "LONG VARGRAPHIC ");
                     db2Ccsid = 13488;
                   }
-                  else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+                  else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
                            strcmp(fieldCharSet->name, "utf8_general_ci") != 0) 
                   {
                     sprintf(stringBuildBuffer, "LONG VARCHAR ");
@@ -639,12 +641,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Fiel
 
                 if (fieldCharSet->mbmaxlen > 1)
                 {
-                  if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+                  if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
                   {
                     sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
                     db2Ccsid = 13488;
                   }
-                  else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+                  else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
                            strcmp(fieldCharSet->name, "utf8_general_ci") != 0) 
                   {
                     sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of bytes
@@ -671,11 +673,15 @@ int ha_ibmdb2i::getFieldTypeMapping(Fiel
                 return rtnCode;
             }
             
-            // Check whether there is a character conversion available.
-            iconv_t temp;
-            int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp);
-            if (unlikely(rc))
-              return rc;
+            if (db2Ccsid != 1208 &&
+                db2Ccsid != 13488)
+            {
+              // Check whether there is a character conversion available.
+              iconv_t temp;
+              int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp);
+              if (unlikely(rc))
+                return rc;
+            }
             
             sprintf(stringBuildBuffer, " CCSID %d ", db2Ccsid);
             mapping.append(stringBuildBuffer);

=== modified file 'storage/ibmdb2i/db2i_myconv.h'
--- a/storage/ibmdb2i/db2i_myconv.h	2009-02-15 02:18:30 +0000
+++ b/storage/ibmdb2i/db2i_myconv.h	2009-07-06 08:49:32 +0000
@@ -220,6 +220,7 @@ INTERN  size_t	        myconv_dmap(mycon
       } else {
         *pOut=dmapS2S[*pIn];
         if (*pOut == 0x00) {
+          errno=EILSEQ;  /* 116 */
           *outBytesLeft-=(*inBytesLeft-inLen);
           *inBytesLeft=inLen;
           *outBuf=pOut;

=== modified file 'storage/ibmdb2i/db2i_rir.cc'
--- a/storage/ibmdb2i/db2i_rir.cc	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_rir.cc	2009-07-06 08:49:32 +0000
@@ -51,7 +51,6 @@ static inline int getKeyCntFromMap(key_p
   return (cnt); 
 }
 
-
 /**
   @brief
   Given a starting key and an ending key, estimate the number of rows that
@@ -270,81 +269,163 @@ ha_rows ha_ibmdb2i::records_in_range(uin
         DB2Field& db2Field = db2Table->db2Field(field->field_index);
         litDefPtr->DataType = db2Field.getType();
         /*
-           Convert the literal to DB2 format.  
-                                                                                   */
-        rc = convertMySQLtoDB2(field,
-                 db2Field,
-                 literalPtr,
-                 (uchar*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
-        if (rc != 0) break;
-        litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr);
-        litDefPtr->Length = db2Field.getByteLengthInRecord();
-        tempLen = litDefPtr->Length;
-        /*
-           Do additional conversion of a character or graphic value.
-                                                                                 */
-        CHARSET_INFO* fieldCharSet = field->charset();                                    
+           Convert the literal to DB2 format
+                                                                                               */
         if ((field->type() != MYSQL_TYPE_BIT) &&           // Don't do conversion on BIT data
             (field->charset() != &my_charset_bin) &&       // Don't do conversion on BINARY data
-            (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR ||
-             litDefPtr->DataType == QMY_GRAPHIC || litDefPtr->DataType == QMY_VARGRAPHIC))
+            (litDefPtr->DataType == QMY_CHAR ||
+             litDefPtr->DataType == QMY_VARCHAR ||
+             litDefPtr->DataType == QMY_GRAPHIC ||
+             litDefPtr->DataType == QMY_VARGRAPHIC))
         {
-           if (litDefPtr->DataType == QMY_VARCHAR ||
-               litDefPtr->DataType == QMY_VARGRAPHIC) 
-             tempPtr = literalPtr + sizeof(uint16);
-           else
-             tempPtr = literalPtr;
-           /* The following code checks to determine if MySQL is passing a
-              partial key. DB2 will accept a partial field value, but only
-              in the last field position of the key composite (and only if
-              there is no ICU sort sequence on the index).                  */
-           tempMinPtr = (char*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0);
-           if (field->type() == MYSQL_TYPE_VARCHAR)
-           {
-             /* MySQL always stores key lengths as 2 bytes, little-endian. */
-               tempLen = *(uint8*)tempMinPtr + ((*(uint8*)(tempMinPtr+1)) << 8);
-               tempMinPtr = (char*)((char*)tempMinPtr + 2);
-           }
-           else
-             tempLen = field->field_length;                         
-
-           /* Determine if we are dealing with a partial key and if so, find the end of the partial key. */
-           if (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR )
-           { /* Char or varchar.  If UTF8, no conversion is done to DB2 graphic.) */
-               endOfMinPtr = (char*)memchr(tempMinPtr,field->charset()->min_sort_char,tempLen);
-               if (endOfMinPtr)
-                 endOfLiteralPtr = tempPtr + ((uint32_t)(endOfMinPtr - tempMinPtr));
-           }
-           else
-           {
-              if (strncmp(fieldCharSet->csname, "utf8", sizeof("utf8")) == 0)
-              {  /* The MySQL charset is UTF8 but we are converting to graphic on DB2. Divide number of UTF8 bytes
-                    by 3 to get the number of characters, then multiple by 2 for double-byte graphic.*/
-               endOfMinPtr = (char*)memchr(tempMinPtr,field->charset()->min_sort_char,tempLen);
-               if (endOfMinPtr)
-                 endOfLiteralPtr = tempPtr + (((uint32_t)((endOfMinPtr - tempMinPtr)) / 3) * 2);
-              } 
-              else
-              { /* The DB2 data type is graphic or vargraphic, and we are not converting from UTF8 to graphic. */  
-                endOfMinPtr = (char*)wmemchr((wchar_t*)tempMinPtr,field->charset()->min_sort_char,tempLen/2);
-                if (endOfMinPtr)
-                  endOfLiteralPtr = tempPtr + (endOfMinPtr - tempMinPtr);
+          // Most of the code is required by the considerable wrangling needed
+          // to prepare partial keys for use by DB2
+          // 1. UTF8 (CCSID 1208) data can be copied across unmodified if it is
+          //    utf8_bin. Otherwise, we need to convert the min and max
+          //    characters into the min and max characters employed
+          //    by the DB2 sort sequence. This is complicated by the fact that
+          //    the character widths are not always equal.
+          //  2. Likewise, UCS2 (CCSID 13488) data can be copied across unmodified
+          //     if it is ucs2_bin or ucs2_general_ci. Otherwise, we need to
+          //     convert the min and max characters into the min and max characters
+          //     employed by the DB2 sort sequence.
+          //  3. All other data will use standard iconv conversions. If an
+          //     unconvertible character is encountered, we assume it is the min
+          //     char and fill the remainder of the DB2 key with 0s. This may not
+          //     always be accurate, but it is probably sufficient for range
+          //     estimations.
+          const char* keyData = minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0);
+          char* db2Data = literalPtr;
+          uint16 outLen = db2Field.getByteLengthInRecord();
+          uint16 inLen;
+          if (litDefPtr->DataType == QMY_VARCHAR ||
+              litDefPtr->DataType == QMY_VARGRAPHIC)
+          {
+            inLen = *(uint8*)keyData + ((*(uint8*)(keyData+1)) << 8);
+            keyData += 2;
+            outLen -= sizeof(uint16);
+            db2Data += sizeof(uint16);
+          }
+          else
+          {
+            inLen = field->max_display_length();
+          }
+          
+          size_t convertedBytes = 0;
+          if (db2Field.getCCSID() == 1208)
+          {
+            DBUG_ASSERT(inLen <= outLen);
+            if (strcmp(field->charset()->name, "utf8_bin"))
+            {
+              const char* end = keyData+inLen;
+              const char* curKey = keyData;
+              char* curDB2 = db2Data;
+              uint32 min = field->charset()->min_sort_char;
+              while ((curKey < end) && (curDB2 < db2Data+outLen-3))
+              {
+                my_wc_t temp;
+                int len = field->charset()->cset->mb_wc(field->charset(),
+                                                        &temp, 
+                                                        (const uchar*)curKey, 
+                                                        (const uchar*)end);
+                if (temp != min)
+                {
+                  DBUG_ASSERT(len <= 3);
+                  switch (len)
+                  {
+                    case 3: *(curDB2+2) = *(curKey+2);
+                    case 2: *(curDB2+1) = *(curKey+1);
+                    case 1: *(curDB2) = *(curKey);
+                  }                      
+                  curDB2 += len;
+                }
+                else
+                {
+                  *(curDB2++) = 0xEF;
+                  *(curDB2++) = 0xBF;
+                  *(curDB2++) = 0xBF;
+                }
+                curKey += len;
+              }
+              convertedBytes = curDB2 - db2Data;
+            }
+            else
+            {
+              memcpy(db2Data, keyData, inLen);
+              convertedBytes = inLen;
+            }
+            rc = 0;
+          }
+          else if (db2Field.getCCSID() == 13488)
+          {
+            DBUG_ASSERT(inLen <= outLen);
+            if (strcmp(field->charset()->name, "ucs2_bin") &&
+                strcmp(field->charset()->name, "ucs2_general_ci"))
+            {
+              const char* end = keyData+inLen;
+              const uint16* curKey = (uint16*)keyData;
+              uint16* curDB2 = (uint16*)db2Data;
+              uint16 min = field->charset()->min_sort_char;
+              while (curKey < (uint16*)end)
+              {
+                if (*curKey != min)
+                  *curDB2 = *curKey;
+                else
+                  *curDB2 = 0xFFFF;
+                ++curKey;
+                ++curDB2;
               }
-           }
-           /* Enforce here that a partial is only allowed on the last field position 
-              of the key composite                                                    */
-           if (endOfLiteralPtr)
-           {
-             if ((partsInUse + 1) < minKeyCnt)   
-             {
-               rc = HA_POS_ERROR;
-               break;
-             }
-             endByte = endOfLiteralPtr - tempPtr;
-             /* We're making an assumption that if MySQL gives us a partial key, 
-                 the length of the partial is the same for both the min_key and max_key.      */
-           }  
+            }
+            else
+            {
+              memcpy(db2Data, keyData, inLen);
+            }
+            convertedBytes = inLen;
+            rc = 0;
+          }
+          else
+          {
+            rc = convertFieldChars(toDB2, 
+                                   field->field_index, 
+                                   keyData,
+                                   db2Data,
+                                   inLen,
+                                   outLen,
+                                   &convertedBytes,
+                                   true);
+
+            if (rc == DB2I_ERR_ILL_CHAR)
+            {
+              // If an illegal character is encountered, we fill the remainder
+              // of the key with 0x00. This was implemented as a corollary to
+              // Bug#45012, though it should probably remain even after that
+              // bug is fixed.
+              memset(db2Data+convertedBytes, 0x00, outLen-convertedBytes);
+              convertedBytes = outLen;
+              rc = 0;
+            }
+          }
+          
+          if (!rc &&
+              (litDefPtr->DataType == QMY_VARGRAPHIC ||
+               litDefPtr->DataType == QMY_VARCHAR))
+          {
+            *(uint16*)(db2Data-sizeof(uint16)) = 
+                convertedBytes / (litDefPtr->DataType == QMY_VARGRAPHIC ? 2 : 1);
+          }
+
+        }
+        else // Non-character fields
+        {
+          rc = convertMySQLtoDB2(field,
+                                 db2Field,
+                                 literalPtr,
+                                 (uchar*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
         }
+
+        if (rc != 0) break;
+        litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr);
+        litDefPtr->Length = db2Field.getByteLengthInRecord();
         literalPtr = literalPtr + litDefPtr->Length;  // Bump pointer for next literal
       }
       /* If there is a max_key value for this field, and if the max_key value is 
@@ -389,28 +470,168 @@ ha_rows ha_ibmdb2i::records_in_range(uin
         /*
            Convert the literal to DB2 format
                                                                                                */
-          rc = convertMySQLtoDB2(field,
-                 db2Field,
-                 literalPtr,
-                 (uchar*)maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
+        if ((field->type() != MYSQL_TYPE_BIT) &&           // Don't do conversion on BIT data
+            (field->charset() != &my_charset_bin) &&       // Don't do conversion on BINARY data
+            (litDefPtr->DataType == QMY_CHAR ||
+             litDefPtr->DataType == QMY_VARCHAR ||
+             litDefPtr->DataType == QMY_GRAPHIC ||
+             litDefPtr->DataType == QMY_VARGRAPHIC))
+          {
+            // We need to handle char fields in a special way in order to account
+            // for partial keys. Refer to the note above for a description of the
+            // basic design.
+            char* keyData = maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0);
+            char* db2Data = literalPtr;
+            uint16 outLen = db2Field.getByteLengthInRecord();
+            uint16 inLen;
+            if (litDefPtr->DataType == QMY_VARCHAR ||
+                litDefPtr->DataType == QMY_VARGRAPHIC)
+            {
+              inLen = *(uint8*)keyData + ((*(uint8*)(keyData+1)) << 8);
+              keyData += 2;
+              outLen -= sizeof(uint16);
+              db2Data += sizeof(uint16);
+            }
+            else
+            {
+              inLen = field->max_display_length();
+            }
+            
+            size_t convertedBytes;
+            if (db2Field.getCCSID() == 1208)
+            {
+              if (strcmp(field->charset()->name, "utf8_bin"))
+              {
+                const char* end = keyData+inLen;
+                const char* curKey = keyData;
+                char* curDB2 = db2Data;
+                uint32 max = field->charset()->max_sort_char;
+                while (curKey < end && (curDB2 < db2Data+outLen-3))
+                {
+                  my_wc_t temp;
+                  int len = field->charset()->cset->mb_wc(field->charset(), &temp, (const uchar*)curKey, (const uchar*)end);
+                  if (temp != max)
+                  {
+                    DBUG_ASSERT(len <= 3);
+                    switch (len)
+                    {
+                      case 3: *(curDB2+2) = *(curKey+2);
+                      case 2: *(curDB2+1) = *(curKey+1);
+                      case 1: *(curDB2) = *(curKey);
+                    }                      
+                    curDB2 += len;
+                  }
+                  else
+                  {
+                    *(curDB2++) = 0xE4;
+                    *(curDB2++) = 0xB6;
+                    *(curDB2++) = 0xBF;
+                  }
+                  curKey += len;
+                }
+                convertedBytes = curDB2 - db2Data;
+              }
+              else
+              {
+                DBUG_ASSERT(inLen <= outLen);
+                memcpy(db2Data, keyData, inLen);
+                convertedBytes = inLen;
+              }
+              rc = 0;
+            }
+            else if (db2Field.getCCSID() == 13488)
+            {
+              if (strcmp(field->charset()->name, "ucs2_bin") &&
+                  strcmp(field->charset()->name, "ucs2_general_ci"))
+              {
+                char* end = keyData+inLen;
+                uint16* curKey = (uint16*)keyData;
+                uint16* curDB2 = (uint16*)db2Data;
+                uint16 max = field->charset()->max_sort_char;
+                while (curKey < (uint16*)end)
+                {
+                  if (*curKey != max)
+                    *curDB2 = *curKey;
+                  else
+                    *curDB2 = 0x4DBF;
+                  ++curKey;
+                  ++curDB2;
+                }
+              }
+              else
+              {
+                memcpy(db2Data, keyData, outLen);
+              }
+              rc = 0;
+            }
+            else
+            {
+              size_t substituteChars = 0;
+              rc = convertFieldChars(toDB2, 
+                                     field->field_index, 
+                                     keyData,
+                                     db2Data,
+                                     inLen,
+                                     outLen,
+                                     &convertedBytes,
+                                     true,
+                                     &substituteChars);
+
+              if (rc == DB2I_ERR_ILL_CHAR)
+              {
+                // If an illegal character is encountered, we fill the remainder
+                // of the key with 0xFF. This was implemented to work around
+                // Bug#45012, though it should probably remain even after that
+                // bug is fixed.
+                memset(db2Data+convertedBytes, 0xFF, outLen-convertedBytes);
+                rc = 0;
+              }
+              else if ((substituteChars &&
+                        (litDefPtr->DataType == QMY_VARCHAR ||
+                         litDefPtr->DataType == QMY_CHAR)) ||
+                       strcmp(field->charset()->name, "cp1251_bulgarian_ci") == 0)
+              {
+                // When iconv translates the max_sort_char with a substitute 
+                // character, we have no way to know whether this affects
+                // the sort order of the key. Therefore, to be safe, when
+                // we know that substitute characters have been used in a
+                // single-byte string, we traverse the translated key
+                // in reverse, replacing substitue characters with 0xFF, which
+                // always sorts with the greatest weight in DB2 sort sequences.
+                // cp1251_bulgarian_ci is also handled this way because the
+                // max_sort_char is a control character which does not sort
+                // equivalently in DB2.
+                DBUG_ASSERT(inLen == outLen);
+                char* tmpKey = keyData + inLen - 1;
+                char* tmpDB2 = db2Data + outLen - 1;
+                while (*tmpKey == field->charset()->max_sort_char &&
+                       *tmpDB2 != 0xFF)
+                {
+                  *tmpDB2 = 0xFF;
+                  --tmpKey;
+                  --tmpDB2;
+                }                  
+              }
+            }
+            
+            if (!rc &&
+                (litDefPtr->DataType == QMY_VARGRAPHIC ||
+                 litDefPtr->DataType == QMY_VARCHAR))
+            {
+              *(uint16*)(db2Data-sizeof(uint16)) = 
+                  outLen / (litDefPtr->DataType == QMY_VARGRAPHIC ? 2 : 1);
+            }
+          }
+          else
+          {
+            rc = convertMySQLtoDB2(field,
+                                   db2Field,
+                                   literalPtr,
+                                   (uchar*)maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
+          }
           if (rc != 0) break;
           litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr);
           litDefPtr->Length = db2Field.getByteLengthInRecord();
-          tempLen = litDefPtr->Length;
-          /*
-             Now convert a character or graphic value.
-                                                                                 */
-          if ((field->type() != MYSQL_TYPE_BIT) &&     
-             (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR ||
-              litDefPtr->DataType == QMY_GRAPHIC || litDefPtr->DataType == QMY_VARGRAPHIC))
-          {
-             if (litDefPtr->DataType == QMY_VARCHAR || litDefPtr->DataType == QMY_VARGRAPHIC)
-             {
-                tempPtr = literalPtr + sizeof(uint16);
-             }
-             else
-               tempPtr = literalPtr;
-          }
           literalPtr = literalPtr + litDefPtr->Length;   // Bump pointer for next literal
         }
         boundsPtr->HiBound.Position = literalCnt;

=== modified file 'storage/ibmdb2i/ha_ibmdb2i.h'
--- a/storage/ibmdb2i/ha_ibmdb2i.h	2009-05-17 16:25:23 +0000
+++ b/storage/ibmdb2i/ha_ibmdb2i.h	2009-07-06 08:49:32 +0000
@@ -383,7 +383,15 @@ private:
   int32 prepareWriteBufferForLobs();
   uint32 adjustLobBuffersForRead();
   bool lobFieldsRequested();
-  int convertFieldChars(enum_conversionDirection direction, uint16 fieldID, const char* input, char* output, size_t ilen, size_t olen, size_t* outDataLen);
+  int convertFieldChars(enum_conversionDirection direction, 
+                        uint16 fieldID, 
+                        const char* input, 
+                        char* output, 
+                        size_t ilen, 
+                        size_t olen, 
+                        size_t* outDataLen,
+                        bool tacitErrors=FALSE,
+                        size_t* substChars=NULL);
 
   /**
     Fast integer log2 function

=== modified file 'storage/innobase/Makefile.am'
--- a/storage/innobase/Makefile.am	2008-12-14 18:54:01 +0000
+++ b/storage/innobase/Makefile.am	2009-07-01 05:37:02 +0000
@@ -50,13 +50,14 @@ noinst_HEADERS=		include/btr0btr.h inclu
 			include/eval0eval.h include/eval0eval.ic	\
 			include/eval0proc.h include/eval0proc.ic	\
 			include/fil0fil.h include/fsp0fsp.h		\
-			include/fsp0fsp.ic include/fut0fut.h		\
+			include/fsp0fsp.ic include/fsp0types.h		\
+			include/fut0fut.h				\
 			include/fut0fut.ic include/fut0lst.h		\
 			include/fut0lst.ic include/ha0ha.h		\
 			include/ha0ha.ic include/hash0hash.h		\
 			include/hash0hash.ic include/ibuf0ibuf.h	\
 			include/ibuf0ibuf.ic include/ibuf0types.h	\
-			include/lock0iter.h				\
+			include/lock0iter.h include/fsp0types.h		\
 			include/lock0lock.h include/lock0lock.ic	\
 			include/lock0priv.h include/lock0priv.ic	\
 			include/lock0types.h include/log0log.h		\

=== modified file 'storage/innobase/btr/btr0cur.c'
--- a/storage/innobase/btr/btr0cur.c	2008-12-14 18:13:36 +0000
+++ b/storage/innobase/btr/btr0cur.c	2009-06-22 11:28:00 +0000
@@ -23,6 +23,7 @@ Created 10/16/1994 Heikki Tuuri
 #include "btr0cur.ic"
 #endif
 
+#include "mtr0log.h"
 #include "page0page.h"
 #include "rem0rec.h"
 #include "rem0cmp.h"

=== modified file 'storage/innobase/include/fsp0fsp.h'
--- a/storage/innobase/include/fsp0fsp.h	2007-08-15 23:44:25 +0000
+++ b/storage/innobase/include/fsp0fsp.h	2009-06-11 12:51:54 +0000
@@ -15,29 +15,7 @@ Created 12/18/1995 Heikki Tuuri
 #include "fut0lst.h"
 #include "ut0byte.h"
 #include "page0types.h"
-
-/* If records are inserted in order, there are the following
-flags to tell this (their type is made byte for the compiler
-to warn if direction and hint parameters are switched in
-fseg_alloc_free_page): */
-#define	FSP_UP		((byte)111)	/* alphabetically upwards */
-#define	FSP_DOWN	((byte)112)	/* alphabetically downwards */
-#define	FSP_NO_DIR	((byte)113)	/* no order */
-
-/* File space extent size in pages */
-#define	FSP_EXTENT_SIZE		64
-
-/* On a page of any file segment, data may be put starting from this offset: */
-#define FSEG_PAGE_DATA		FIL_PAGE_DATA
-
-/* File segment header which points to the inode describing the file segment */
-typedef	byte	fseg_header_t;
-
-#define FSEG_HDR_SPACE		0	/* space id of the inode */
-#define FSEG_HDR_PAGE_NO	4	/* page number of the inode */
-#define FSEG_HDR_OFFSET		8	/* byte offset of the inode */
-
-#define FSEG_HEADER_SIZE	10
+#include "fsp0types.h"
 
 /**************************************************************************
 Initializes the file space system. */
@@ -350,40 +328,6 @@ fseg_print(
 	fseg_header_t*	header, /* in: segment header */
 	mtr_t*		mtr);	/* in: mtr */
 
-/* Flags for fsp_reserve_free_extents */
-#define FSP_NORMAL	1000000
-#define	FSP_UNDO	2000000
-#define FSP_CLEANING	3000000
-
-/* Number of pages described in a single descriptor page: currently each page
-description takes less than 1 byte; a descriptor page is repeated every
-this many file pages */
-#define XDES_DESCRIBED_PER_PAGE		UNIV_PAGE_SIZE
-
-/* The space low address page map */
-/*--------------------------------------*/
-				/* The following two pages are repeated
-				every XDES_DESCRIBED_PER_PAGE pages in
-				every tablespace. */
-#define FSP_XDES_OFFSET			0	/* extent descriptor */
-#define FSP_IBUF_BITMAP_OFFSET		1	/* insert buffer bitmap */
-				/* The ibuf bitmap pages are the ones whose
-				page number is the number above plus a
-				multiple of XDES_DESCRIBED_PER_PAGE */
-
-#define FSP_FIRST_INODE_PAGE_NO		2	/* in every tablespace */
-				/* The following pages exist
-				in the system tablespace (space 0). */
-#define FSP_IBUF_HEADER_PAGE_NO		3	/* in tablespace 0 */
-#define FSP_IBUF_TREE_ROOT_PAGE_NO	4	/* in tablespace 0 */
-				/* The ibuf tree root page number in
-				tablespace 0; its fseg inode is on the page
-				number FSP_FIRST_INODE_PAGE_NO */
-#define FSP_TRX_SYS_PAGE_NO		5	/* in tablespace 0 */
-#define	FSP_FIRST_RSEG_PAGE_NO		6	/* in tablespace 0 */
-#define FSP_DICT_HDR_PAGE_NO		7	/* in tablespace 0 */
-/*--------------------------------------*/
-
 #ifndef UNIV_NONINL
 #include "fsp0fsp.ic"
 #endif

=== added file 'storage/innobase/include/fsp0types.h'
--- a/storage/innobase/include/fsp0types.h	1970-01-01 00:00:00 +0000
+++ b/storage/innobase/include/fsp0types.h	2009-06-11 12:51:54 +0000
@@ -0,0 +1,89 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/******************************************************
+File space management types
+
+Created May 26, 2009 Vasil Dimov
+*******************************************************/
+
+#ifndef fsp0types_h
+#define fsp0types_h
+
+#include "univ.i"
+
+#include "fil0fil.h" /* for FIL_PAGE_DATA */
+
+/* If records are inserted in order, there are the following
+flags to tell this (their type is made byte for the compiler
+to warn if direction and hint parameters are switched in
+fseg_alloc_free_page): */
+#define	FSP_UP		((byte)111)	/* alphabetically upwards */
+#define	FSP_DOWN	((byte)112)	/* alphabetically downwards */
+#define	FSP_NO_DIR	((byte)113)	/* no order */
+
+/* File space extent size in pages */
+#define	FSP_EXTENT_SIZE		64
+
+/* On a page of any file segment, data may be put starting from this offset: */
+#define FSEG_PAGE_DATA		FIL_PAGE_DATA
+
+/* File segment header which points to the inode describing the file segment */
+typedef	byte	fseg_header_t;
+
+#define FSEG_HDR_SPACE		0	/* space id of the inode */
+#define FSEG_HDR_PAGE_NO	4	/* page number of the inode */
+#define FSEG_HDR_OFFSET		8	/* byte offset of the inode */
+
+#define FSEG_HEADER_SIZE	10
+
+/* Flags for fsp_reserve_free_extents */
+#define FSP_NORMAL	1000000
+#define	FSP_UNDO	2000000
+#define FSP_CLEANING	3000000
+
+/* Number of pages described in a single descriptor page: currently each page
+description takes less than 1 byte; a descriptor page is repeated every
+this many file pages */
+#define XDES_DESCRIBED_PER_PAGE		UNIV_PAGE_SIZE
+
+/* The space low address page map */
+/*--------------------------------------*/
+				/* The following two pages are repeated
+				every XDES_DESCRIBED_PER_PAGE pages in
+				every tablespace. */
+#define FSP_XDES_OFFSET			0	/* extent descriptor */
+#define FSP_IBUF_BITMAP_OFFSET		1	/* insert buffer bitmap */
+				/* The ibuf bitmap pages are the ones whose
+				page number is the number above plus a
+				multiple of XDES_DESCRIBED_PER_PAGE */
+
+#define FSP_FIRST_INODE_PAGE_NO		2	/* in every tablespace */
+				/* The following pages exist
+				in the system tablespace (space 0). */
+#define FSP_IBUF_HEADER_PAGE_NO		3	/* in tablespace 0 */
+#define FSP_IBUF_TREE_ROOT_PAGE_NO	4	/* in tablespace 0 */
+				/* The ibuf tree root page number in
+				tablespace 0; its fseg inode is on the page
+				number FSP_FIRST_INODE_PAGE_NO */
+#define FSP_TRX_SYS_PAGE_NO		5	/* in tablespace 0 */
+#define	FSP_FIRST_RSEG_PAGE_NO		6	/* in tablespace 0 */
+#define FSP_DICT_HDR_PAGE_NO		7	/* in tablespace 0 */
+/*--------------------------------------*/
+
+#endif /* fsp0types_h */

=== modified file 'storage/innobase/include/mtr0log.ic'
--- a/storage/innobase/include/mtr0log.ic	2006-09-05 01:52:15 +0000
+++ b/storage/innobase/include/mtr0log.ic	2009-06-11 13:05:12 +0000
@@ -9,6 +9,8 @@ Created 12/7/1995 Heikki Tuuri
 #include "mach0data.h"
 #include "ut0lst.h"
 #include "buf0buf.h"
+#include "fsp0types.h"
+#include "trx0sys.h"
 
 /************************************************************
 Opens a buffer to mlog. It must be closed with mlog_close. */
@@ -174,6 +176,28 @@ mlog_write_initial_log_record_fast(
 	space = buf_block_get_space(block);
 	offset = buf_block_get_page_no(block);
 
+	/* check whether the page is in the doublewrite buffer;
+	the doublewrite buffer is located in pages
+	FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the
+	system tablespace */
+	if (space == TRX_SYS_SPACE
+	    && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) {
+		if (trx_doublewrite_buf_is_being_created) {
+			/* Do nothing: we only come to this branch in an
+			InnoDB database creation. We do not redo log
+			anything for the doublewrite buffer pages. */
+			return(log_ptr);
+		} else {
+			fprintf(stderr,
+				"Error: trying to redo log a record of type "
+				"%d on page %lu of space %lu in the "
+				"doublewrite buffer, continuing anyway.\n"
+				"Please post a bug report to "
+				"bugs.mysql.com.\n",
+				type, offset, space);
+		}
+	}
+
 	mach_write_to_1(log_ptr, type);
 	log_ptr++;
 	log_ptr += mach_write_compressed(log_ptr, space);

=== modified file 'storage/innobase/include/trx0rseg.ic'
--- a/storage/innobase/include/trx0rseg.ic	2006-09-05 01:52:15 +0000
+++ b/storage/innobase/include/trx0rseg.ic	2009-06-22 11:28:00 +0000
@@ -7,6 +7,7 @@ Created 3/26/1996 Heikki Tuuri
 *******************************************************/
 
 #include "srv0srv.h"
+#include "mtr0log.h"
 
 /**********************************************************************
 Gets a rollback segment header. */

=== modified file 'storage/innobase/include/trx0sys.h'
--- a/storage/innobase/include/trx0sys.h	2006-03-10 16:22:21 +0000
+++ b/storage/innobase/include/trx0sys.h	2009-06-11 13:05:12 +0000
@@ -13,15 +13,12 @@ Created 3/26/1996 Heikki Tuuri
 
 #include "trx0types.h"
 #include "mtr0mtr.h"
-#include "mtr0log.h"
 #include "ut0byte.h"
 #include "mem0mem.h"
 #include "sync0sync.h"
 #include "ut0lst.h"
 #include "buf0buf.h"
 #include "fil0fil.h"
-#include "fut0lst.h"
-#include "fsp0fsp.h"
 #include "read0types.h"
 
 /* In a MySQL replication slave, in crash recovery we store the master log
@@ -45,6 +42,8 @@ extern trx_sys_t*	trx_sys;
 
 /* Doublewrite system */
 extern trx_doublewrite_t*	trx_doublewrite;
+/* Set to TRUE when the doublewrite buffer is being created */
+extern ibool			trx_doublewrite_buf_is_being_created;
 extern ibool			trx_doublewrite_must_reset_space_ids;
 extern ibool			trx_sys_multiple_tablespace_format;
 
@@ -302,6 +301,7 @@ trx_sys_print_mysql_master_log_pos(void)
 
 /* Space id and page no where the trx system file copy resides */
 #define	TRX_SYS_SPACE	0	/* the SYSTEM tablespace */
+#include "fsp0fsp.h"
 #define	TRX_SYS_PAGE_NO	FSP_TRX_SYS_PAGE_NO
 
 /* The offset of the transaction system header on the page */

=== modified file 'storage/innobase/row/row0mysql.c'
--- a/storage/innobase/row/row0mysql.c	2009-04-15 11:46:08 +0000
+++ b/storage/innobase/row/row0mysql.c	2009-06-25 09:52:46 +0000
@@ -1529,9 +1529,14 @@ row_unlock_for_mysql(
 			index = btr_pcur_get_btr_cur(clust_pcur)->index;
 		}
 
+		if (UNIV_UNLIKELY(!(index->type & DICT_CLUSTERED))) {
+			/* This is not a clustered index record.  We
+			do not know how to unlock the record. */
+			goto no_unlock;
+		}
+
 		/* If the record has been modified by this
 		transaction, do not unlock it. */
-		ut_a(index->type & DICT_CLUSTERED);
 
 		if (index->trx_id_offset) {
 			rec_trx_id = trx_read_trx_id(rec
@@ -1568,7 +1573,7 @@ row_unlock_for_mysql(
 						prebuilt->select_lock_type);
 			}
 		}
-
+no_unlock:
 		mtr_commit(&mtr);
 	}
 

=== modified file 'storage/innobase/trx/trx0rec.c'
--- a/storage/innobase/trx/trx0rec.c	2009-03-03 01:32:04 +0000
+++ b/storage/innobase/trx/trx0rec.c	2009-06-22 11:28:00 +0000
@@ -23,6 +23,7 @@ Created 3/26/1996 Heikki Tuuri
 #include "que0que.h"
 #include "trx0purge.h"
 #include "row0row.h"
+#include "mtr0log.h"
 
 /*=========== UNDO LOG RECORD CREATION AND DECODING ====================*/
 

=== modified file 'storage/innobase/trx/trx0sys.c'
--- a/storage/innobase/trx/trx0sys.c	2007-08-25 09:55:38 +0000
+++ b/storage/innobase/trx/trx0sys.c	2009-06-11 13:05:12 +0000
@@ -25,6 +25,7 @@ Created 3/26/1996 Heikki Tuuri
 /* The transaction system */
 trx_sys_t*		trx_sys		= NULL;
 trx_doublewrite_t*	trx_doublewrite = NULL;
+ibool			trx_doublewrite_buf_is_being_created = FALSE;
 
 /* The following is set to TRUE when we are upgrading from the old format data
 files to the new >= 4.1.x format multiple tablespaces format data files */
@@ -180,6 +181,7 @@ trx_sys_create_doublewrite_buf(void)
 
 start_again:
 	mtr_start(&mtr);
+	trx_doublewrite_buf_is_being_created = TRUE;
 
 	page = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
 #ifdef UNIV_SYNC_DEBUG
@@ -196,6 +198,7 @@ start_again:
 		trx_doublewrite_init(doublewrite);
 
 		mtr_commit(&mtr);
+		trx_doublewrite_buf_is_being_created = FALSE;
 	} else {
 		fprintf(stderr,
 			"InnoDB: Doublewrite buffer not found:"
@@ -274,14 +277,8 @@ start_again:
 			buf_page_dbg_add_level(new_page, SYNC_NO_ORDER_CHECK);
 #endif /* UNIV_SYNC_DEBUG */
 
-			/* Make a dummy change to the page to ensure it will
-			be written to disk in a flush */
-
-			mlog_write_ulint(new_page + FIL_PAGE_DATA,
-					 TRX_SYS_DOUBLEWRITE_MAGIC_N,
-					 MLOG_4BYTES, &mtr);
-
 			if (i == FSP_EXTENT_SIZE / 2) {
+				ut_a(page_no == FSP_EXTENT_SIZE);
 				mlog_write_ulint(doublewrite
 						 + TRX_SYS_DOUBLEWRITE_BLOCK1,
 						 page_no, MLOG_4BYTES, &mtr);
@@ -291,6 +288,7 @@ start_again:
 						 page_no, MLOG_4BYTES, &mtr);
 			} else if (i == FSP_EXTENT_SIZE / 2
 				   + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
+				ut_a(page_no == 2 * FSP_EXTENT_SIZE);
 				mlog_write_ulint(doublewrite
 						 + TRX_SYS_DOUBLEWRITE_BLOCK2,
 						 page_no, MLOG_4BYTES, &mtr);

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2009-06-04 23:30:08 +0000
+++ b/storage/myisam/ha_myisam.cc	2009-06-29 14:00:47 +0000
@@ -95,7 +95,7 @@ static void mi_check_print_msg(MI_CHECK 
 
   if (!thd->vio_ok())
   {
-    sql_print_error(msgbuf);
+    sql_print_error("%s", msgbuf);
     return;
   }
 

=== modified file 'strings/decimal.c'
--- a/strings/decimal.c	2008-08-15 19:49:43 +0000
+++ b/strings/decimal.c	2009-06-29 14:00:47 +0000
@@ -306,7 +306,7 @@ int decimal_actual_fraction(decimal_t *f
   {
     for (i= DIG_PER_DEC1 - ((frac - 1) % DIG_PER_DEC1);
          *buf0 % powers10[i++] == 0;
-         frac--);
+         frac--) ;
   }
   return frac;
 }
@@ -500,7 +500,7 @@ static void digits_bounds(decimal_t *fro
     stop= (int) ((buf_end - from->buf + 1) * DIG_PER_DEC1);
     i= 1;
   }
-  for (; *buf_end % powers10[i++] == 0; stop--);
+  for (; *buf_end % powers10[i++] == 0; stop--) ;
   *end_result= stop; /* index of position after last decimal digit (from 0) */
 }
 
@@ -1011,7 +1011,7 @@ static int ull2dec(ulonglong from, decim
 
   sanity(to);
 
-  for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE);
+  for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) ;
   if (unlikely(intg1 > to->len))
   {
     intg1=to->len;

Attachment: [text/bzr-bundle] bzr/joro@sun.com-20090708131116-kyz8iotbum8w9yic.bundle
Thread
bzr push into mysql-5.1 branch (joro:2968 to 3015) Georgi Kodinov8 Jul