List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:March 31 2011 10:09am
Subject:bzr commit into mysql-5.5-mtr branch (bjorn.munch:3189)
View as plain text  
#At file:///home/bm136801/my/mtr-55/ based on revid:bjorn.munch@stripped

 3189 Bjorn Munch	2011-03-31 [merge]
      merge from 5.5 main

    removed:
      include/my_handler.h
      mysys/my_gethostbyname.c
      mysys/my_handler.c
      mysys/my_port.c
    added:
      include/my_compare.h
      mysql-test/r/tablespace.result
      mysql-test/std_data/cluster_7022_table.MYD
      mysql-test/std_data/cluster_7022_table.MYI
      mysql-test/std_data/cluster_7022_table.frm
      mysql-test/t/tablespace.test
      mysys/my_compare.c
    modified:
      .bzrignore
      client/mysqlbinlog.cc
      extra/perror.c
      include/heap.h
      include/my_global.h
      include/my_net.h
      include/myisam.h
      include/mysql_com.h
      mysql-test/extra/rpl_tests/rpl_record_compare.test
      mysql-test/r/bootstrap.result
      mysql-test/r/events_bugs.result
      mysql-test/r/func_math.result
      mysql-test/r/func_time.result
      mysql-test/r/mysqlbinlog.result
      mysql-test/r/packet.result
      mysql-test/r/shm.result
      mysql-test/r/variables-notembedded.result
      mysql-test/r/variables.result
      mysql-test/suite/binlog/t/disabled.def
      mysql-test/suite/rpl/r/rpl_packet.result
      mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result
      mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result
      mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt
      mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt
      mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test
      mysql-test/suite/rpl/t/rpl_semi_sync_event.test
      mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result
      mysql-test/suite/sys_vars/r/max_allowed_packet_func.result
      mysql-test/t/bootstrap.test
      mysql-test/t/events_bugs.test
      mysql-test/t/func_math.test
      mysql-test/t/func_time.test
      mysql-test/t/mysqlbinlog.test
      mysql-test/t/variables-notembedded.test
      mysql-test/t/variables.test
      mysys/CMakeLists.txt
      mysys/my_handler_errors.h
      sql/handler.h
      sql/item.cc
      sql/item_func.cc
      sql/item_timefunc.cc
      sql/item_timefunc.h
      sql/log_event.cc
      sql/mysqld.cc
      sql/share/errmsg-utf8.txt
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sys_vars.cc
      sql/table.cc
      sql/table.h
      sql/unireg.cc
      storage/myisam/ft_stopwords.c
      storage/myisam/mi_check.c
=== modified file '.bzrignore'
--- a/.bzrignore	2010-12-17 11:11:34 +0000
+++ b/.bzrignore	2011-03-28 10:57:54 +0000
@@ -9,6 +9,7 @@
 *.core
 *.d
 *.da
+*.dir
 *.dll
 *.dylib
 *.exe
@@ -31,6 +32,7 @@
 *.pdb
 *.reject
 *.res
+*.rule
 *.sbr
 *.so
 *.so.*
@@ -38,6 +40,8 @@
 *.user
 *.vcproj
 *.vcproj.cmake
+*.vcxproj
+*.vcxproj.filters
 */*.dir/*
 */*_pure_*warnings
 */.deps
@@ -46,7 +50,7 @@
 */debug/*
 */minsizerel/*
 */release/*
-*/relwithdebinfo/*
+RelWithDebInfo
 *~
 .*.swp
 ./CMakeCache.txt

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2011-01-16 03:59:05 +0000
+++ b/client/mysqlbinlog.cc	2011-03-25 14:35:45 +0000
@@ -714,10 +714,18 @@ Exit_status process_event(PRINT_EVENT_IN
       */
       start_datetime= 0;
       offset= 0; // print everything and protect against cycling rec_count
+      /*
+        Skip events according to the --server-id flag.  However, don't
+        skip format_description or rotate events, because they they
+        are really "global" events that are relevant for the entire
+        binlog, even if they have a server_id.  Also, we have to read
+        the format_description event so that we can parse subsequent
+        events.
+      */
+      if (ev_type != ROTATE_EVENT &&
+          server_id && (server_id != ev->server_id))
+        goto end;
     }
-    if (server_id && (server_id != ev->server_id))
-      /* skip just this event, continue processing the log. */
-      goto end;
     if (((my_time_t)(ev->when) >= stop_datetime)
         || (pos >= stop_position_mot))
     {

=== modified file 'extra/perror.c'
--- a/extra/perror.c	2010-07-15 11:13:30 +0000
+++ b/extra/perror.c	2011-03-29 12:43:49 +0000
@@ -32,7 +32,7 @@ static my_bool verbose, print_all_codes;
 
 #include "../include/my_base.h"
 #include "../mysys/my_handler_errors.h"
-#include "../include/my_handler.h"
+// #include "../include/my_compare.h"
 
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
 static my_bool ndb_code;
@@ -240,7 +240,39 @@ static my_bool print_win_error_msg(DWORD
 }
 #endif
 
+/*
+  Register handler error messages for usage with my_error()
 
+  NOTES
+    This is safe to call multiple times as my_error_register()
+    will ignore calls to register already registered error numbers.
+*/
+
+static const char **get_handler_error_messages()
+{
+  return handler_error_messages;
+}
+
+void my_handler_error_register(void)
+{
+  /*
+    If you got compilation error here about compile_time_assert array, check
+    that every HA_ERR_xxx constant has a corresponding error message in
+    handler_error_messages[] list (check mysys/ma_handler_errors.h and
+    include/my_base.h).
+  */
+  compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
+                      HA_ERR_LAST + 1);
+  my_error_register(get_handler_error_messages, HA_ERR_FIRST,
+                    HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
+}
+
+
+void my_handler_error_unregister(void)
+{
+  my_error_unregister(HA_ERR_FIRST,
+                      HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
+}
 
 int main(int argc,char *argv[])
 {

=== modified file 'include/heap.h'
--- a/include/heap.h	2011-03-22 12:56:15 +0000
+++ b/include/heap.h	2011-03-29 12:43:49 +0000
@@ -30,7 +30,7 @@ extern "C" {
 #include <my_pthread.h>
 #include <thr_lock.h>
 
-#include "my_handler.h"
+#include "my_compare.h"
 #include "my_tree.h"
 
 	/* defines used by heap-funktions */

=== added file 'include/my_compare.h'
--- a/include/my_compare.h	1970-01-01 00:00:00 +0000
+++ b/include/my_compare.h	2011-03-29 12:43:49 +0000
@@ -0,0 +1,125 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   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 */
+
+#ifndef _my_compare_h
+#define _my_compare_h
+
+#include "myisampack.h"
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#include "m_ctype.h"                            /* CHARSET_INFO */
+
+/*
+  There is a hard limit for the maximum number of keys as there are only
+  8 bits in the index file header for the number of keys in a table.
+  This means that 0..255 keys can exist for a table. The idea of
+  HA_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on
+  a MyISAM table for which one has more keys than MyISAM is normally
+  compiled for. If you don't have this, you will get a core dump when
+  running myisamchk compiled for 128 keys on a table with 255 keys.
+*/
+
+#define HA_MAX_POSSIBLE_KEY         255         /* For myisamchk */
+/*
+  The following defines can be increased if necessary.
+  But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and HA_MAX_KEY_LENGTH.
+*/
+
+#define HA_MAX_KEY_LENGTH           1000        /* Max length in bytes */
+#define HA_MAX_KEY_SEG              16          /* Max segments for key */
+
+#define HA_MAX_POSSIBLE_KEY_BUFF    (HA_MAX_KEY_LENGTH + 24+ 6+6)
+#define HA_MAX_KEY_BUFF  (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8)
+
+typedef struct st_HA_KEYSEG		/* Key-portion */
+{
+  CHARSET_INFO *charset;
+  uint32 start;				/* Start of key in record */
+  uint32 null_pos;			/* position to NULL indicator */
+  uint16 bit_pos;                       /* Position to bit part */
+  uint16 flag;
+  uint16 length;			/* Keylength */
+  uint16 language;
+  uint8  type;				/* Type of key (for sort) */
+  uint8  null_bit;			/* bitmask to test for NULL */
+  uint8  bit_start,bit_end;		/* if bit field */
+  uint8  bit_length;                    /* Length of bit part */
+} HA_KEYSEG;
+
+#define get_key_length(length,key) \
+{ if (*(uchar*) (key) != 255) \
+    length= (uint) *(uchar*) ((key)++); \
+  else \
+  { length= mi_uint2korr((key)+1); (key)+=3; } \
+}
+
+#define get_key_length_rdonly(length,key) \
+{ if (*(uchar*) (key) != 255) \
+    length= ((uint) *(uchar*) ((key))); \
+  else \
+  { length= mi_uint2korr((key)+1); } \
+}
+
+#define get_key_pack_length(length,length_pack,key) \
+{ if (*(uchar*) (key) != 255) \
+  { length= (uint) *(uchar*) ((key)++); length_pack= 1; }\
+  else \
+  { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
+}
+
+#define store_key_length_inc(key,length) \
+{ if ((length) < 255) \
+  { *(key)++= (length); } \
+  else \
+  { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
+}
+
+#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
+
+#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
+  (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \
+   ((1 << (bit_len)) - 1))
+
+#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \
+{ \
+  (bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \
+                ((bits) << (bit_ofs)); \
+  if ((bit_ofs) + (bit_len) > 8) \
+    (bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \
+                  ((bits) >> (8 - (bit_ofs))); \
+}
+
+#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
+  set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
+
+extern int ha_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint ,
+			   my_bool, my_bool);
+extern int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
+		      register uchar *b, uint key_length, uint nextflag,
+		      uint *diff_pos);
+
+/*
+  Inside an in-memory data record, memory pointers to pieces of the
+  record (like BLOBs) are stored in their native byte order and in
+  this amount of bytes.
+*/
+#define portable_sizeof_char_ptr 8
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* _my_compare_h */

=== modified file 'include/my_global.h'
--- a/include/my_global.h	2011-03-22 12:56:15 +0000
+++ b/include/my_global.h	2011-03-29 12:43:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2003 MySQL AB, 2009 Sun Microsystems, Inc
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -285,7 +285,7 @@ C_MODE_END
 #define ulonglong2double(A) my_ulonglong2double(A)
 #define my_off_t2double(A)  my_ulonglong2double(A)
 C_MODE_START
-double my_ulonglong2double(unsigned long long A);
+inline double my_ulonglong2double(unsigned long long A) { return (double A); }
 C_MODE_END
 #endif /* _AIX */
 

=== removed file 'include/my_handler.h'
--- a/include/my_handler.h	2010-12-29 00:26:31 +0000
+++ b/include/my_handler.h	1970-01-01 00:00:00 +0000
@@ -1,130 +0,0 @@
-/* Copyright (C) 2002-2006 MySQL AB
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library 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
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with this library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA */
-
-#ifndef _my_handler_h
-#define _my_handler_h
-
-#include "myisampack.h"
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#include "m_ctype.h"                            /* CHARSET_INFO */
-
-/*
-  There is a hard limit for the maximum number of keys as there are only
-  8 bits in the index file header for the number of keys in a table.
-  This means that 0..255 keys can exist for a table. The idea of
-  HA_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on
-  a MyISAM table for which one has more keys than MyISAM is normally
-  compiled for. If you don't have this, you will get a core dump when
-  running myisamchk compiled for 128 keys on a table with 255 keys.
-*/
-
-#define HA_MAX_POSSIBLE_KEY         255         /* For myisamchk */
-/*
-  The following defines can be increased if necessary.
-  But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and HA_MAX_KEY_LENGTH.
-*/
-
-#define HA_MAX_KEY_LENGTH           1000        /* Max length in bytes */
-#define HA_MAX_KEY_SEG              16          /* Max segments for key */
-
-#define HA_MAX_POSSIBLE_KEY_BUFF    (HA_MAX_KEY_LENGTH + 24+ 6+6)
-#define HA_MAX_KEY_BUFF  (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8)
-
-typedef struct st_HA_KEYSEG		/* Key-portion */
-{
-  CHARSET_INFO *charset;
-  uint32 start;				/* Start of key in record */
-  uint32 null_pos;			/* position to NULL indicator */
-  uint16 bit_pos;                       /* Position to bit part */
-  uint16 flag;
-  uint16 length;			/* Keylength */
-  uint16 language;
-  uint8  type;				/* Type of key (for sort) */
-  uint8  null_bit;			/* bitmask to test for NULL */
-  uint8  bit_start,bit_end;		/* if bit field */
-  uint8  bit_length;                    /* Length of bit part */
-} HA_KEYSEG;
-
-#define get_key_length(length,key) \
-{ if (*(uchar*) (key) != 255) \
-    length= (uint) *(uchar*) ((key)++); \
-  else \
-  { length= mi_uint2korr((key)+1); (key)+=3; } \
-}
-
-#define get_key_length_rdonly(length,key) \
-{ if (*(uchar*) (key) != 255) \
-    length= ((uint) *(uchar*) ((key))); \
-  else \
-  { length= mi_uint2korr((key)+1); } \
-}
-
-#define get_key_pack_length(length,length_pack,key) \
-{ if (*(uchar*) (key) != 255) \
-  { length= (uint) *(uchar*) ((key)++); length_pack= 1; }\
-  else \
-  { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
-}
-
-#define store_key_length_inc(key,length) \
-{ if ((length) < 255) \
-  { *(key)++= (length); } \
-  else \
-  { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
-}
-
-#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
-
-#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
-  (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \
-   ((1 << (bit_len)) - 1))
-
-#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \
-{ \
-  (bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \
-                ((bits) << (bit_ofs)); \
-  if ((bit_ofs) + (bit_len) > 8) \
-    (bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \
-                  ((bits) >> (8 - (bit_ofs))); \
-}
-
-#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
-  set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
-
-extern int ha_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint ,
-			   my_bool, my_bool);
-extern int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
-		      register uchar *b, uint key_length, uint nextflag,
-		      uint *diff_pos);
-
-extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a);
-extern void my_handler_error_register(void);
-extern void my_handler_error_unregister(void);
-/*
-  Inside an in-memory data record, memory pointers to pieces of the
-  record (like BLOBs) are stored in their native byte order and in
-  this amount of bytes.
-*/
-#define portable_sizeof_char_ptr 8
-#ifdef	__cplusplus
-}
-#endif
-
-#endif /* _my_handler_h */

=== modified file 'include/my_net.h'
--- a/include/my_net.h	2010-07-23 20:14:35 +0000
+++ b/include/my_net.h	2011-03-29 12:43:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -73,38 +73,6 @@ C_MODE_START
 #define in_addr_t uint32
 #endif
 
-/*
-  Handling of gethostbyname_r()
-*/
-
-#if !defined(HAVE_GETHOSTBYNAME_R)
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop);
-void my_gethostbyname_r_free();
-#elif defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop);
-#define my_gethostbyname_r_free()
-#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX10)
-#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
-#endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
-
-#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
-#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop);
-#define my_gethostbyname_r_free()
-#else
-#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
-#define my_gethostbyname_r_free()
-#endif /* !defined(HAVE_GETHOSTBYNAME_R) */
-
-#ifndef GETHOSTBYNAME_BUFF_SIZE
-#define GETHOSTBYNAME_BUFF_SIZE 2048
-#endif
 
 C_MODE_END
 #endif

=== modified file 'include/myisam.h'
--- a/include/myisam.h	2011-03-22 12:56:15 +0000
+++ b/include/myisam.h	2011-03-29 12:43:49 +0000
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (C) 2000, 2011, Oracle and/or its affiliates. All rights 
+   reserved
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -30,7 +31,7 @@ extern "C" {
 #ifndef _keycache_h
 #include "keycache.h"
 #endif
-#include "my_handler.h"
+#include "my_compare.h"
 #include <mysql/plugin.h>
 
 /*

=== modified file 'include/mysql_com.h'
--- a/include/mysql_com.h	2010-12-29 00:26:31 +0000
+++ b/include/mysql_com.h	2011-03-04 08:41:29 +0000
@@ -114,6 +114,10 @@ enum enum_server_command
 #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
 #define FIELD_IN_ADD_INDEX (1<< 20)	/* Intern: Field used in ADD INDEX */
 #define FIELD_IS_RENAMED (1<< 21)       /* Intern: Field is being renamed */
+#define FIELD_FLAGS_STORAGE_MEDIA 22    /* Field storage media, bit 22-23,
+                                           reserved by MySQL Cluster */
+#define FIELD_FLAGS_COLUMN_FORMAT 24    /* Field column format, bit 24-25,
+                                           reserved by MySQL Cluster */
 
 #define REFRESH_GRANT		1	/* Refresh grant tables */
 #define REFRESH_LOG		2	/* Start on new log file */

=== modified file 'mysql-test/extra/rpl_tests/rpl_record_compare.test'
--- a/mysql-test/extra/rpl_tests/rpl_record_compare.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_record_compare.test	2011-03-24 10:52:40 +0000
@@ -62,4 +62,24 @@ UPDATE t1 SET c1= 0;
 DROP TABLE t1; 
 -- sync_slave_with_master
 
+#
+# BUG#11766865: 60091: RBR + NO PK + UPDATE NULL VALUE --> SLAVE BREAK WITH ERROR HA_ERR_END_OF_ 
+#
 
+--connection master
+--source include/rpl_reset.inc
+--connection master
+
+--eval CREATE TABLE t1 (c1 int(11) NOT NULL, c2 int(11) NOT NULL, c3 int(11) DEFAULT '-1') ENGINE=$engine DEFAULT CHARSET=latin1
+
+INSERT INTO t1 VALUES (1,2,NULL);
+UPDATE t1 SET c1=1, c2=2, c3=-1 WHERE c1=1 AND c2=2 AND ISNULL(c3);
+
+--sync_slave_with_master
+
+--let $diff_tables=master:test.t1, slave:test.t1
+--source include/diff_tables.inc
+
+--connection master
+DROP TABLE t1;
+--sync_slave_with_master

=== modified file 'mysql-test/r/bootstrap.result'
--- a/mysql-test/r/bootstrap.result	2007-02-20 11:48:15 +0000
+++ b/mysql-test/r/bootstrap.result	2011-03-23 17:03:42 +0000
@@ -6,3 +6,15 @@ set @my_max_allowed_packet= @@max_allowe
 set global max_allowed_packet=100*@@max_allowed_packet;
 set global max_allowed_packet=@my_max_allowed_packet;
 drop table t1;
+End of 5.1 tests
+#
+# Bug #11766306: 59393: HAVE_INNODB=YES WHEN MYSQLD 
+#  STARTED WITH --SKIP-INNODB
+#
+SHOW VARIABLES LIKE 'have_innodb';
+Variable_name	Value
+have_innodb	DISABLED
+SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb';
+SUPPORT
+NO
+End of 5.5 tests

=== modified file 'mysql-test/r/events_bugs.result'
--- a/mysql-test/r/events_bugs.result	2011-03-21 16:09:40 +0000
+++ b/mysql-test/r/events_bugs.result	2011-03-28 15:38:16 +0000
@@ -747,15 +747,15 @@ event_name	originator
 ev1	4294967295
 DROP EVENT ev1;
 SET GLOBAL server_id = @old_server_id;
+CREATE DATABASE event_test12;
+USE event_test12;
+CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
 CREATE DATABASE event_test1;
 USE event_test1;
-CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
-CREATE DATABASE event_test2;
-USE event_test2;
 SHOW EVENTS;
 Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
 DROP DATABASE event_test1;
-DROP DATABASE event_test2;
+DROP DATABASE event_test12;
 DROP DATABASE events_test;
 SET GLOBAL event_scheduler= 'ON';
 SET @@global.concurrent_insert= @concurrent_insert;

=== modified file 'mysql-test/r/func_math.result'
--- a/mysql-test/r/func_math.result	2011-03-03 14:25:41 +0000
+++ b/mysql-test/r/func_math.result	2011-03-28 08:52:47 +0000
@@ -514,6 +514,13 @@ t1	CREATE TABLE `t1` (
   `C` varchar(23) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 DROP TABLE t1;
+#
+# Bug#11764994  57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
+#
+CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
 End of 5.1 tests
 #
 # Bug #8433: Overflow must be an error

=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result	2011-03-16 14:11:20 +0000
+++ b/mysql-test/r/func_time.result	2011-03-30 07:25:49 +0000
@@ -1347,6 +1347,36 @@ Warning	1292	Truncated incorrect time va
 Warning	1292	Truncated incorrect time value: ''
 Warning	1292	Truncated incorrect time value: ''
 DROP TABLE t1;
+#
+# Bug#11766112  59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
+#
+SELECT STR_TO_DATE(SPACE(2),'1');
+STR_TO_DATE(SPACE(2),'1')
+0000-00-00
+#
+# Bug#11765216  58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
+#
+SET GLOBAL SQL_MODE='';
+DO  STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
+SET GLOBAL SQL_MODE=DEFAULT;
+#
+# Bug#11766087  59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
+#
+SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
+FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1)
+NULL
+#
+# Bug#11766126  59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
+#
+SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
+CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025))
+NULL
+#
+# Bug#11766124  59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
+#
+SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
+ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR)
+NULL
 End of 5.1 tests
 #
 # Bug#57039: constant subtime expression returns incorrect result.

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2010-12-29 05:22:52 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2011-03-25 14:35:45 +0000
@@ -903,3 +903,15 @@ master-bin.000002	#	Query	#	#	CREATE DAT
 master-bin.000002	#	Query	#	#	use `test1`; CREATE TABLE t1(id int)
 master-bin.000002	#	Query	#	#	use `test1`; DROP TABLE `t1` /* generated by server */
 master-bin.000002	#	Query	#	#	DROP DATABASE test1
+RESET MASTER;
+USE test;
+CREATE TABLE t1 (a INT);
+SET GLOBAL SERVER_ID = 2;
+DROP TABLE t1;
+FLUSH LOGS;
+SHOW TABLES IN test;
+Tables_in_test
+t1
+SHOW TABLES IN test;
+Tables_in_test
+SET GLOBAL SERVER_ID = 1;

=== modified file 'mysql-test/r/packet.result'
--- a/mysql-test/r/packet.result	2009-06-19 09:29:21 +0000
+++ b/mysql-test/r/packet.result	2011-03-25 12:55:22 +0000
@@ -3,6 +3,7 @@ set @net_buffer_length=@@global.net_buff
 set global max_allowed_packet=100;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '100'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 set global net_buffer_length=100;
 Warnings:
 Warning	1292	Truncated incorrect net_buffer_length value: '100'

=== modified file 'mysql-test/r/shm.result'
--- a/mysql-test/r/shm.result	2010-02-20 10:07:32 +0000
+++ b/mysql-test/r/shm.result	2011-03-28 10:57:54 +0000
@@ -2155,6 +2155,8 @@ mysqld is alive
 SET @max_allowed_packet= @@global.max_allowed_packet;
 SET @net_buffer_length= @@global.net_buffer_length;
 SET GLOBAL max_allowed_packet= 1024;
+Warnings:
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SET GLOBAL net_buffer_length= 1024;
 ERROR 1153 (08S01) at line 1: Got a packet bigger than 'max_allowed_packet' bytes
 SET GLOBAL max_allowed_packet= @max_allowed_packet;

=== added file 'mysql-test/r/tablespace.result'
--- a/mysql-test/r/tablespace.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/tablespace.result	2011-03-04 08:41:29 +0000
@@ -0,0 +1,112 @@
+CREATE TABLE t1(a int) TABLESPACE ts ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE DISK ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE MEMORY ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts STORAGE MEMORY */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) STORAGE MEMORY ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 STORAGE MEMORY */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) STORAGE DISK ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 STORAGE DISK */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) TABLESPACE ts ENGINE=MyISAM;
+ALTER TABLE t1 ADD COLUMN b int;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL,
+  `b` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE DISK ENGINE=MyISAM;
+ALTER TABLE t1 ADD COLUMN b int;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL,
+  `b` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+ALTER TABLE t1 TABLESPACE ts;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+ALTER TABLE t1 TABLESPACE ts2;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts2 */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+ALTER TABLE t1 STORAGE MEMORY;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 STORAGE MEMORY */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+ALTER TABLE t1 STORAGE DISK;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 STORAGE DISK */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+ALTER TABLE t1 STORAGE MEMORY TABLESPACE ts;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts STORAGE MEMORY */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+ALTER TABLE t1 STORAGE DISK TABLESPACE ts2;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL
+) /*!50100 TABLESPACE ts2 STORAGE DISK */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  `c` int(11) DEFAULT NULL,
+  `d` int(11) NOT NULL,
+  `e` int(11) DEFAULT NULL,
+  `f` int(11) DEFAULT NULL,
+  `g` int(11) DEFAULT NULL,
+  `h` int(11) NOT NULL,
+  `i` int(11) DEFAULT NULL,
+  `j` int(11) DEFAULT NULL,
+  `k` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) /*!50100 TABLESPACE the_tablespacename STORAGE DISK */ ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;

=== modified file 'mysql-test/r/variables-notembedded.result'
--- a/mysql-test/r/variables-notembedded.result	2009-04-06 11:42:33 +0000
+++ b/mysql-test/r/variables-notembedded.result	2011-03-28 10:57:54 +0000
@@ -108,3 +108,27 @@ SET @@session.slave_skip_errors= 7;
 ERROR HY000: Variable 'slave_skip_errors' is a read only variable
 SET @@global.slave_skip_errors= 7;
 ERROR HY000: Variable 'slave_skip_errors' is a read only variable
+#
+# Bug #11766769 : 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET 
+#   ARE NOT BEING HONORED
+#
+CREATE TABLE t1 (a MEDIUMTEXT);
+SET GLOBAL max_allowed_packet=2048;
+Warnings:
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
+SET GLOBAL net_buffer_length=4096;
+Warnings:
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
+SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
+Variable_name	Value
+max_allowed_packet	2048
+SHOW SESSION VARIABLES LIKE 'net_buffer_length';
+Variable_name	Value
+net_buffer_length	4096
+ERROR 08S01: Got a packet bigger than 'max_allowed_packet' bytes
+SELECT LENGTH(a) FROM t1;
+LENGTH(a)
+SET GLOBAL max_allowed_packet=default;
+SET GLOBAL net_buffer_length=default;
+DROP TABLE t1;
+End of 5.1 tests

=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2011-03-15 12:57:36 +0000
+++ b/mysql-test/r/variables.result	2011-03-28 10:57:54 +0000
@@ -505,6 +505,7 @@ set low_priority_updates=1;
 set global max_allowed_packet=100;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '100'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 set global max_binlog_cache_size=100;
 Warnings:
 Warning	1292	Truncated incorrect max_binlog_cache_size value: '100'
@@ -1059,6 +1060,8 @@ set global max_write_lock_count      =de
 set global myisam_data_pointer_size  =@my_myisam_data_pointer_size;
 set global myisam_max_sort_file_size =@my_myisam_max_sort_file_size;
 set global net_buffer_length         =@my_net_buffer_length;
+Warnings:
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 set global net_write_timeout         =@my_net_write_timeout;
 set global net_read_timeout          =@my_net_read_timeout;
 set global query_cache_limit         =@my_query_cache_limit;
@@ -1543,6 +1546,22 @@ Warning	1292	Truncated incorrect key_cac
 select @@max_long_data_size;
 @@max_long_data_size
 1048576
+#
+# Bug#11766424  59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
+#
+CREATE TABLE t1(f1 DECIMAL(1,1) UNSIGNED);
+INSERT INTO t1 VALUES (0.2),(0.1);
+SELECT 1 FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1);
+1
+1
+DROP TABLE t1;
+CREATE TABLE t1 AS SELECT @a:= CAST(1 AS UNSIGNED) AS a;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(1) unsigned NOT NULL DEFAULT '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
 SET @@global.max_binlog_cache_size=DEFAULT;
 SET @@global.max_join_size=DEFAULT;
 SET @@global.key_buffer_size=@kbs;

=== added file 'mysql-test/std_data/cluster_7022_table.MYD'

=== added file 'mysql-test/std_data/cluster_7022_table.MYI'
Files a/mysql-test/std_data/cluster_7022_table.MYI	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/cluster_7022_table.MYI	2011-03-04 08:41:29 +0000 differ

=== added file 'mysql-test/std_data/cluster_7022_table.frm'
Files a/mysql-test/std_data/cluster_7022_table.frm	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/cluster_7022_table.frm	2011-03-04 08:41:29 +0000 differ

=== modified file 'mysql-test/suite/binlog/t/disabled.def'
--- a/mysql-test/suite/binlog/t/disabled.def	2010-11-24 14:11:36 +0000
+++ b/mysql-test/suite/binlog/t/disabled.def	2011-03-24 14:39:45 +0000
@@ -11,4 +11,3 @@
 ##############################################################################
 binlog_truncate_innodb	: BUG#57291 2010-10-20 anitha Originally disabled due to BUG#42643. Product bug fixed, but test changes needed
 binlog_spurious_ddl_errors  : BUG#54195 2010-06-03 alik binlog_spurious_ddl_errors.test fails, thus disabled
-binlog_row_failure_mixing_engines : BUG#58416 2010-11-23 ramil Fails on win x86 debug_max

=== modified file 'mysql-test/suite/rpl/r/rpl_packet.result'
--- a/mysql-test/suite/rpl/r/rpl_packet.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_packet.result	2011-03-25 12:55:22 +0000
@@ -49,6 +49,8 @@ SET @max_allowed_packet_2= @@session.max
 ==== clean up ====
 DROP TABLE t1;
 SET @@global.max_allowed_packet= 1024;
+Warnings:
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SET @@global.net_buffer_length= 1024;
 DROP TABLE t1;
 RESET SLAVE;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result'
--- a/mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result	2011-03-24 10:52:40 +0000
@@ -25,4 +25,10 @@ INSERT INTO t1(c1) VALUES (NULL);
 UPDATE t1 SET c1= 0;
 include/diff_tables.inc [master:t1, slave:t1]
 DROP TABLE t1;
+include/rpl_reset.inc
+CREATE TABLE t1 (c1 int(11) NOT NULL, c2 int(11) NOT NULL, c3 int(11) DEFAULT '-1') ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES (1,2,NULL);
+UPDATE t1 SET c1=1, c2=2, c3=-1 WHERE c1=1 AND c2=2 AND ISNULL(c3);
+include/diff_tables.inc [master:test.t1, slave:test.t1]
+DROP TABLE t1;
 include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result'
--- a/mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result	2011-03-24 10:52:40 +0000
@@ -1,5 +1,14 @@
 include/master-slave.inc
 [connection master]
+## coverage purposes - Field_bits 
+##                     1 X bit + 2 Null bits + 5 bits => last_null_bit_pos==0
+include/rpl_reset.inc
+CREATE TABLE t1 (c1 bigint(20) DEFAULT 0, c2 bit(5)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1(c1,c2) VALUES (10, b'1');
+INSERT INTO t1(c1,c2) VALUES (NULL, b'1');
+UPDATE t1 SET c1= 0;
+include/diff_tables.inc [master:t1, slave:t1]
+DROP TABLE t1;
 ## case #1 - last_null_bit_pos==0 in record_compare without X bit
 include/rpl_reset.inc
 CREATE TABLE t1 (c1 bigint(20) DEFAULT 0, c2 bigint(20) DEFAULT 0, c3 bigint(20) DEFAULT 0, c4 varchar(1) DEFAULT '', c5 bigint(20) DEFAULT 0, c6 bigint(20) DEFAULT 0, c7 bigint(20) DEFAULT 0, c8 bigint(20) DEFAULT 0) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@@ -25,13 +34,10 @@ INSERT INTO t1(c1) VALUES (NULL);
 UPDATE t1 SET c1= 0;
 include/diff_tables.inc [master:t1, slave:t1]
 DROP TABLE t1;
-## coverage purposes - Field_bits 
-##                     1 X bit + 2 Null bits + 5 bits => last_null_bit_pos==0
 include/rpl_reset.inc
-CREATE TABLE t1 (c1 bigint(20) DEFAULT 0, c2 bit(5)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-INSERT INTO t1(c1,c2) VALUES (10, b'1');
-INSERT INTO t1(c1,c2) VALUES (NULL, b'1');
-UPDATE t1 SET c1= 0;
-include/diff_tables.inc [master:t1, slave:t1]
+CREATE TABLE t1 (c1 int(11) NOT NULL, c2 int(11) NOT NULL, c3 int(11) DEFAULT '-1') ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES (1,2,NULL);
+UPDATE t1 SET c1=1, c2=2, c3=-1 WHERE c1=1 AND c2=2 AND ISNULL(c3);
+include/diff_tables.inc [master:test.t1, slave:test.t1]
 DROP TABLE t1;
 include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt	2008-02-05 13:52:20 +0000
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_map-master.opt	2011-03-25 10:57:27 +0000
@@ -1 +1 @@
---read_buffer_size=12K --max_allowed_packet=8K
+--read_buffer_size=12K --max_allowed_packet=8K --net-buffer-length=8K

=== modified file 'mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt	2008-02-05 13:52:20 +0000
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_map-slave.opt	2011-03-25 10:57:27 +0000
@@ -1 +1 @@
---max_allowed_packet=8K
+--max_allowed_packet=8K --net-buffer-length=8K

=== modified file 'mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test'
--- a/mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test	2010-12-19 17:07:28 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test	2011-03-24 10:52:40 +0000
@@ -1,12 +1,11 @@
 -- source include/have_binlog_format_row.inc
 -- source include/master-slave.inc
+-- let $engine= MyISAM
 
 #
 # BUG#52868 Wrong handling of NULL value during update, replication out of sync
 #
 
--- let $engine= MyISAM
--- source extra/rpl_tests/rpl_record_compare.test
 
 -- echo ## coverage purposes - Field_bits 
 -- echo ##                     1 X bit + 2 Null bits + 5 bits => last_null_bit_pos==0
@@ -28,4 +27,7 @@ UPDATE t1 SET c1= 0;
 -- connection master
 DROP TABLE t1; 
 -- sync_slave_with_master
+
+-- source extra/rpl_tests/rpl_record_compare.test
+
 --source include/rpl_end.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_semi_sync_event.test'
--- a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test	2011-03-25 15:28:11 +0000
@@ -15,6 +15,7 @@ call mtr.add_suppression("Unsafe stateme
 connection slave;
 call mtr.add_suppression("Master server does not support semi-sync");
 call mtr.add_suppression("Semi-sync slave .* reply");
+call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
 enable_query_log;
 
 connection master;

=== modified file 'mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result'
--- a/mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result	2011-03-25 12:55:22 +0000
@@ -7,6 +7,7 @@ SET @@global.max_allowed_packet = DEFAUL
 SET @@global.max_allowed_packet = 1000;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '1000'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SET @@global.max_allowed_packet = DEFAULT;
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet
@@ -25,12 +26,15 @@ SELECT @@global.max_allowed_packet = 104
 1
 '#--------------------FN_DYNVARS_070_03-------------------------#'
 SET @@global.max_allowed_packet = 1024;
+Warnings:
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet
 1024
 SET @@global.max_allowed_packet = 1025;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '1025'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet
 1024
@@ -74,18 +78,21 @@ SELECT @@session.max_allowed_packet;
 SET @@global.max_allowed_packet = 0;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '0'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet
 1024
 SET @@global.max_allowed_packet = -1024;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '-1024'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet
 1024
 SET @@global.max_allowed_packet = 1023;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '1023'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet
 1024
@@ -148,17 +155,21 @@ WHERE VARIABLE_NAME='max_allowed_packet'
 SET @@global.max_allowed_packet = TRUE;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '1'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet
 1024
 SET @@global.max_allowed_packet = FALSE;
 Warnings:
 Warning	1292	Truncated incorrect max_allowed_packet value: '0'
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet
 1024
 '#---------------------FN_DYNVARS_070_09----------------------#'
 SET @@global.max_allowed_packet = 2048;
+Warnings:
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SELECT @@max_allowed_packet = @@global.max_allowed_packet;
 @@max_allowed_packet = @@global.max_allowed_packet
 0

=== modified file 'mysql-test/suite/sys_vars/r/max_allowed_packet_func.result'
--- a/mysql-test/suite/sys_vars/r/max_allowed_packet_func.result	2009-01-29 16:59:46 +0000
+++ b/mysql-test/suite/sys_vars/r/max_allowed_packet_func.result	2011-03-25 12:55:22 +0000
@@ -23,6 +23,8 @@ SELECT @@session.net_buffer_length;
 '#--------------------FN_DYNVARS_070_02-------------------------#'
 ## Setting value of max_allowed packet and net_buffer_length to 1024 ##
 SET @@global.max_allowed_packet = 1024;
+Warnings:
+Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
 SET @@global.net_buffer_length = 1024;
 SELECT @@global.max_allowed_packet;
 @@global.max_allowed_packet

=== modified file 'mysql-test/t/bootstrap.test'
--- a/mysql-test/t/bootstrap.test	2010-06-17 20:51:35 +0000
+++ b/mysql-test/t/bootstrap.test	2011-03-23 17:03:42 +0000
@@ -49,3 +49,15 @@ remove_file $MYSQLTEST_VARDIR/tmp/long_q
 set global max_allowed_packet=@my_max_allowed_packet;
 drop table t1;
 
+--echo End of 5.1 tests
+
+--echo #
+--echo # Bug #11766306: 59393: HAVE_INNODB=YES WHEN MYSQLD 
+--echo #  STARTED WITH --SKIP-INNODB
+--echo #
+
+# need the --skip-innodb option present for the test to succeed
+SHOW VARIABLES LIKE 'have_innodb';
+SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb';
+
+--echo End of 5.5 tests

=== modified file 'mysql-test/t/events_bugs.test'
--- a/mysql-test/t/events_bugs.test	2011-03-21 16:09:40 +0000
+++ b/mysql-test/t/events_bugs.test	2011-03-28 15:38:16 +0000
@@ -1225,15 +1225,15 @@ SET GLOBAL server_id = @old_server_id;
 # Bug#11751148: show events shows events in other schema
 #
 
+CREATE DATABASE event_test12;
+USE event_test12;
+CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
 CREATE DATABASE event_test1;
 USE event_test1;
-CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
-CREATE DATABASE event_test2;
-USE event_test2;
 # Following show events should not show ev1
 SHOW EVENTS;
 DROP DATABASE event_test1;
-DROP DATABASE event_test2;
+DROP DATABASE event_test12;
 
 
 ###########################################################################

=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test	2011-03-03 14:25:41 +0000
+++ b/mysql-test/t/func_math.test	2011-03-28 08:52:47 +0000
@@ -345,6 +345,15 @@ CREATE TABLE t1 SELECT CAST((CASE((''))
 SHOW CREATE TABLE t1;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#11764994  57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
+--echo #
+
+CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/func_time.test'
--- a/mysql-test/t/func_time.test	2011-03-16 14:11:20 +0000
+++ b/mysql-test/t/func_time.test	2011-03-30 07:25:49 +0000
@@ -862,6 +862,38 @@ INSERT INTO t1 VALUES (''),('');
 SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#11766112  59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
+--echo #
+
+SELECT STR_TO_DATE(SPACE(2),'1');
+
+--echo #
+--echo # Bug#11765216  58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
+--echo #
+
+SET GLOBAL SQL_MODE='';
+DO  STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
+SET GLOBAL SQL_MODE=DEFAULT;
+
+--echo #
+--echo # Bug#11766087  59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
+--echo #
+
+SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
+
+--echo #
+--echo # Bug#11766126  59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
+--echo #
+
+SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
+
+--echo #
+--echo # Bug#11766124  59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
+--echo #
+
+SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'mysql-test/t/mysqlbinlog.test'
--- a/mysql-test/t/mysqlbinlog.test	2010-12-29 05:22:52 +0000
+++ b/mysql-test/t/mysqlbinlog.test	2011-03-25 14:35:45 +0000
@@ -527,3 +527,23 @@ exec $MYSQL_BINLOG $MYSQLD_DATADIR/$mast
 let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
 source include/show_binlog_events.inc;
 
+#
+# BUG#11766427 BUG#59530: Filter by server id in mysqlbinlog fails
+# This test checks that the format description log event is not
+# filtered out by the --server-id option.
+#
+RESET MASTER;
+USE test;
+CREATE TABLE t1 (a INT);
+--let $old_server_id= `SELECT @@GLOBAL.SERVER_ID`
+SET GLOBAL SERVER_ID = 2;
+DROP TABLE t1;
+--let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
+FLUSH LOGS;
+# The following should only create t1, not drop it.
+--exec $MYSQL_BINLOG --server-id=1 $MYSQLD_DATADIR/$master_binlog | $MYSQL
+SHOW TABLES IN test;
+# The following should only drop t1, not create it.
+--exec $MYSQL_BINLOG --server-id=2 $MYSQLD_DATADIR/$master_binlog | $MYSQL
+SHOW TABLES IN test;
+eval SET GLOBAL SERVER_ID = $old_server_id;

=== added file 'mysql-test/t/tablespace.test'
--- a/mysql-test/t/tablespace.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/tablespace.test	2011-03-04 08:41:29 +0000
@@ -0,0 +1,122 @@
+#
+# BUG#60111 storage type for table not saved in .frm
+#
+
+#
+# Check that the table options for TABLESPACE and STORAGE
+# are printed in SHOW CREATE TABLE
+#
+
+# TABLESPACE only
+CREATE TABLE t1(a int) TABLESPACE ts ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# TABLESPACE + STORAGE DISK
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE DISK ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# TABLESPACE + STORAGE MEMORY
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE MEMORY ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# STORAGE MEMORY only
+CREATE TABLE t1(a int) STORAGE MEMORY ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# STORAGE DISK only
+CREATE TABLE t1(a int) STORAGE DISK ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
+# Check that the table options for TABLESPACE and STORAGE
+# are kept in an ALTER
+#
+
+# TABLESPACE only
+CREATE TABLE t1(a int) TABLESPACE ts ENGINE=MyISAM;
+ALTER TABLE t1 ADD COLUMN b int;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# TABLESPACE and STORAGE DISK
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE DISK ENGINE=MyISAM;
+ALTER TABLE t1 ADD COLUMN b int;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
+# Check that the table options for TABLESPACE and STORAGE
+# can be changed with an ALTER
+#
+
+# TABLESPACE only
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+
+ALTER TABLE t1 TABLESPACE ts;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 TABLESPACE ts2;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+# STORAGE only
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+
+ALTER TABLE t1 STORAGE MEMORY;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 STORAGE DISK;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+# TABLESPACE and STORAGE
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+
+ALTER TABLE t1 STORAGE MEMORY TABLESPACE ts;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 STORAGE DISK TABLESPACE ts2;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+#
+# Check that it's possible to read a .frm fle created
+# by MySQL Cluster 7.0(which introduced the new "format
+# section) with this statement:
+#
+# CREATE TABLE cluster_7022_table
+# (
+#   a int primary key,
+#   b int,
+#   c int STORAGE DISK,
+#   d int STORAGE MEMORY NOT NULL,
+#   e int COLUMN_FORMAT DYNAMIC,
+#   f int COLUMN_FORMAT FIXED,
+#   g int COLUMN_FORMAT DEFAULT,
+#   h int STORAGE DISK COLUMN_FORMAT DYNAMIC NOT NULL,
+#   i int STORAGE MEMORY COLUMN_FORMAT DYNAMIC,
+#   j int STORAGE DISK COLUMN_FORMAT FIXED,
+#   k int STORAGE MEMORY COLUMN_FORMAT FIXED
+# ) STORAGE DISK TABLESPACE the_tablespacename ENGINE=MyISAM;
+#
+# NOTE! The column level properties will not yet show up
+# in SHOW CREATE TABLE of MySQL Server(although they are
+# visible in .trace file)
+#
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/cluster_7022_table.frm $MYSQLD_DATADIR/test/t1.frm;
+copy_file std_data/cluster_7022_table.MYD $MYSQLD_DATADIR/test/t1.MYD;
+copy_file std_data/cluster_7022_table.MYI $MYSQLD_DATADIR/test/t1.MYI;
+
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;

=== modified file 'mysql-test/t/variables-notembedded.test'
--- a/mysql-test/t/variables-notembedded.test	2008-12-13 19:42:12 +0000
+++ b/mysql-test/t/variables-notembedded.test	2011-03-28 10:25:03 +0000
@@ -109,3 +109,30 @@ SET @@session.slave_skip_errors= 7;
 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
 SET @@global.slave_skip_errors= 7;
 #
+
+--echo #
+--echo # Bug #11766769 : 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET 
+--echo #   ARE NOT BEING HONORED
+--echo #
+
+CREATE TABLE t1 (a MEDIUMTEXT);
+
+SET GLOBAL max_allowed_packet=2048;
+SET GLOBAL net_buffer_length=4096;
+CONNECT (con1,localhost,root,,test);
+SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
+SHOW SESSION VARIABLES LIKE 'net_buffer_length';
+--disable_query_log
+--error ER_NET_PACKET_TOO_LARGE
+INSERT INTO t1 VALUES ('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234!
 5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012!
 34567890123456789012345678901234567890123456789012345678901234!
 5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012!
 3456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890!
 12345678901234567890123456789012345678901234567890123456789012345678901!
 2345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789!
 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+--enable_query_log
+
+CONNECTION default;
+DISCONNECT con1;
+SELECT LENGTH(a) FROM t1;
+
+SET GLOBAL max_allowed_packet=default;
+SET GLOBAL net_buffer_length=default;
+DROP TABLE t1;
+
+--echo End of 5.1 tests

=== modified file 'mysql-test/t/variables.test'
--- a/mysql-test/t/variables.test	2011-03-15 12:57:36 +0000
+++ b/mysql-test/t/variables.test	2011-03-28 10:57:54 +0000
@@ -1286,12 +1286,26 @@ SET @@global.key_cache_block_size=0;
 #
 select @@max_long_data_size;
 
+--echo #
+--echo # Bug#11766424  59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
+--echo #
+
+CREATE TABLE t1(f1 DECIMAL(1,1) UNSIGNED);
+INSERT INTO t1 VALUES (0.2),(0.1);
+SELECT 1 FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1);
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT @a:= CAST(1 AS UNSIGNED) AS a;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
 # cleanup
 SET @@global.max_binlog_cache_size=DEFAULT;
 SET @@global.max_join_size=DEFAULT;
 SET @@global.key_buffer_size=@kbs;
 SET @@global.key_cache_block_size=@kcbs;
 
+
 --echo End of 5.1 tests
 
 ###########################################################################

=== modified file 'mysys/CMakeLists.txt'
--- a/mysys/CMakeLists.txt	2011-03-22 12:56:15 +0000
+++ b/mysys/CMakeLists.txt	2011-03-29 12:43:49 +0000
@@ -23,8 +23,8 @@ SET(MYSYS_SOURCES  array.c charset-def.c
 				mf_tempfile.c mf_unixpath.c mf_wcomp.c mulalloc.c my_access.c
 				my_aes.c my_alloc.c my_bit.c my_bitmap.c my_chsize.c
 				my_compress.c my_copy.c  my_create.c my_delete.c
-				my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c 
-				my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
+				my_div.c my_error.c my_file.c my_fopen.c my_fstream.c 
+				my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_compare.c my_init.c
 				my_lib.c my_lock.c my_malloc.c my_mess.c
 				my_mkdir.c my_mmap.c my_once.c my_open.c my_pread.c my_pthread.c
 				my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c
@@ -64,11 +64,6 @@ IF(HAVE_MLOCK)
  SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_lockmem.c)
 ENDIF()
 
-IF(UNIX)
- # some workarounds
- SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_port.c)
-ENDIF()
-
 ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES})
 TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY} 
  ${LIBNSL} ${LIBM} ${LIBRT})

=== added file 'mysys/my_compare.c'
--- a/mysys/my_compare.c	1970-01-01 00:00:00 +0000
+++ b/mysys/my_compare.c	2011-03-29 12:43:49 +0000
@@ -0,0 +1,476 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   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 */
+   
+#include <my_global.h>
+#include <m_ctype.h>
+#include <my_base.h>
+#include <my_compare.h>
+#include <my_sys.h>
+
+#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
+
+int ha_compare_text(CHARSET_INFO *charset_info, uchar *a, uint a_length,
+		    uchar *b, uint b_length, my_bool part_key,
+		    my_bool skip_end_space)
+{
+  if (!part_key)
+    return charset_info->coll->strnncollsp(charset_info, a, a_length,
+                                           b, b_length, (my_bool)!skip_end_space);
+  return charset_info->coll->strnncoll(charset_info, a, a_length,
+                                       b, b_length, part_key);
+}
+
+
+static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
+                       my_bool part_key, my_bool skip_end_space)
+{
+  uint length= min(a_length,b_length);
+  uchar *end= a+ length;
+  int flag;
+
+  while (a < end)
+    if ((flag= (int) *a++ - (int) *b++))
+      return flag;
+  if (part_key && b_length < a_length)
+    return 0;
+  if (skip_end_space && a_length != b_length)
+  {
+    int swap= 1;
+    /*
+      We are using space compression. We have to check if longer key
+      has next character < ' ', in which case it's less than the shorter
+      key that has an implicite space afterwards.
+
+      This code is identical to the one in
+      strings/ctype-simple.c:my_strnncollsp_simple
+    */
+    if (a_length < b_length)
+    {
+      /* put shorter key in a */
+      a_length= b_length;
+      a= b;
+      swap= -1;					/* swap sign of result */
+    }
+    for (end= a + a_length-length; a < end ; a++)
+    {
+      if (*a != ' ')
+	return (*a < ' ') ? -swap : swap;
+    }
+    return 0;
+  }
+  return (int) (a_length-b_length);
+}
+
+
+/*
+  Compare two keys
+
+  SYNOPSIS
+    ha_key_cmp()
+    keyseg	Array of key segments of key to compare
+    a		First key to compare, in format from _mi_pack_key()
+		This is normally key specified by user
+    b		Second key to compare.  This is always from a row
+    key_length	Length of key to compare.  This can be shorter than
+		a to just compare sub keys
+    next_flag	How keys should be compared
+		If bit SEARCH_FIND is not set the keys includes the row
+		position and this should also be compared
+    diff_pos    OUT Number of first keypart where values differ, counting 
+                from one.
+    diff_pos[1] OUT  (b + diff_pos[1]) points to first value in tuple b
+                      that is different from corresponding value in tuple a.
+  
+  EXAMPLES 
+   Example1: if the function is called for tuples
+     ('aaa','bbb') and ('eee','fff'), then
+     diff_pos[0] = 1 (as 'aaa' != 'eee')
+     diff_pos[1] = 0 (offset from beggining of tuple b to 'eee' keypart).
+
+   Example2: if the index function is called for tuples
+     ('aaa','bbb') and ('aaa','fff'),
+     diff_pos[0] = 2 (as 'aaa' != 'eee')
+     diff_pos[1] = 3 (offset from beggining of tuple b to 'fff' keypart,
+                      here we assume that first key part is CHAR(3) NOT NULL)
+
+  NOTES
+    Number-keys can't be splited
+
+  RETURN VALUES
+    <0	If a < b
+    0	If a == b
+    >0	If a > b
+*/
+
+#define FCMP(A,B) ((int) (A) - (int) (B))
+
+int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
+	       register uchar *b, uint key_length, uint nextflag,
+	       uint *diff_pos)
+{
+  int flag;
+  int16 s_1,s_2;
+  int32 l_1,l_2;
+  uint32 u_1,u_2;
+  float f_1,f_2;
+  double d_1,d_2;
+  uint next_key_length;
+  uchar *orig_b= b;
+
+  *diff_pos=0;
+  for ( ; (int) key_length >0 ; key_length=next_key_length, keyseg++)
+  {
+    uchar *end;
+    uint piks=! (keyseg->flag & HA_NO_SORT);
+    (*diff_pos)++;
+    diff_pos[1]= (uint)(b - orig_b);
+
+    /* Handle NULL part */
+    if (keyseg->null_bit)
+    {
+      key_length--;
+      if (*a != *b && piks)
+      {
+        flag = (int) *a - (int) *b;
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      }
+      b++;
+      if (!*a++)                                /* If key was NULL */
+      {
+        if (nextflag == (SEARCH_FIND | SEARCH_UPDATE))
+          nextflag=SEARCH_SAME;                 /* Allow duplicate keys */
+  	else if (nextflag & SEARCH_NULL_ARE_NOT_EQUAL)
+	{
+	  /*
+	    This is only used from mi_check() to calculate cardinality.
+	    It can't be used when searching for a key as this would cause
+	    compare of (a,b) and (b,a) to return the same value.
+	  */
+	  return -1;
+	}
+        next_key_length=key_length;
+        continue;                               /* To next key part */
+      }
+    }
+    end= a+ min(keyseg->length,key_length);
+    next_key_length=key_length-keyseg->length;
+
+    switch ((enum ha_base_keytype) keyseg->type) {
+    case HA_KEYTYPE_TEXT:                       /* Ascii; Key is converted */
+      if (keyseg->flag & HA_SPACE_PACK)
+      {
+        int a_length,b_length,pack_length;
+        get_key_length(a_length,a);
+        get_key_pack_length(b_length,pack_length,b);
+        next_key_length=key_length-b_length-pack_length;
+
+        if (piks &&
+            (flag=ha_compare_text(keyseg->charset,a,a_length,b,b_length,
+				  (my_bool) ((nextflag & SEARCH_PREFIX) &&
+					     next_key_length <= 0),
+				  (my_bool)!(nextflag & SEARCH_PREFIX))))
+          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+        a+=a_length;
+        b+=b_length;
+        break;
+      }
+      else
+      {
+	uint length=(uint) (end-a), a_length=length, b_length=length;
+        if (piks &&
+            (flag= ha_compare_text(keyseg->charset, a, a_length, b, b_length,
+				   (my_bool) ((nextflag & SEARCH_PREFIX) &&
+					      next_key_length <= 0),
+				   (my_bool)!(nextflag & SEARCH_PREFIX))))
+          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+        a=end;
+        b+=length;
+      }
+      break;
+    case HA_KEYTYPE_BINARY:
+    case HA_KEYTYPE_BIT:
+      if (keyseg->flag & HA_SPACE_PACK)
+      {
+        int a_length,b_length,pack_length;
+        get_key_length(a_length,a);
+        get_key_pack_length(b_length,pack_length,b);
+        next_key_length=key_length-b_length-pack_length;
+
+        if (piks &&
+	    (flag=compare_bin(a,a_length,b,b_length,
+                              (my_bool) ((nextflag & SEARCH_PREFIX) &&
+                                         next_key_length <= 0),1)))
+          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+        a+=a_length;
+        b+=b_length;
+        break;
+      }
+      else
+      {
+        uint length=keyseg->length;
+        if (piks &&
+	    (flag=compare_bin(a,length,b,length,
+                              (my_bool) ((nextflag & SEARCH_PREFIX) &&
+                                         next_key_length <= 0),0)))
+          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+        a+=length;
+        b+=length;
+      }
+      break;
+    case HA_KEYTYPE_VARTEXT1:
+    case HA_KEYTYPE_VARTEXT2:
+      {
+        int a_length,b_length,pack_length;
+        get_key_length(a_length,a);
+        get_key_pack_length(b_length,pack_length,b);
+        next_key_length=key_length-b_length-pack_length;
+
+        if (piks &&
+	    (flag= ha_compare_text(keyseg->charset,a,a_length,b,b_length,
+                                   (my_bool) ((nextflag & SEARCH_PREFIX) &&
+                                              next_key_length <= 0),
+				   (my_bool) ((nextflag & (SEARCH_FIND |
+							   SEARCH_UPDATE)) ==
+					      SEARCH_FIND &&
+                                              ! (keyseg->flag &
+                                                 HA_END_SPACE_ARE_EQUAL)))))
+          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+        a+= a_length;
+        b+= b_length;
+        break;
+      }
+      break;
+    case HA_KEYTYPE_VARBINARY1:
+    case HA_KEYTYPE_VARBINARY2:
+      {
+        int a_length,b_length,pack_length;
+        get_key_length(a_length,a);
+        get_key_pack_length(b_length,pack_length,b);
+        next_key_length=key_length-b_length-pack_length;
+
+        if (piks &&
+	    (flag=compare_bin(a,a_length,b,b_length,
+                              (my_bool) ((nextflag & SEARCH_PREFIX) &&
+                                         next_key_length <= 0), 0)))
+          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+        a+=a_length;
+        b+=b_length;
+      }
+      break;
+    case HA_KEYTYPE_INT8:
+    {
+      int i_1= (int) *((signed char*) a);
+      int i_2= (int) *((signed char*) b);
+      if (piks && (flag = CMP_NUM(i_1,i_2)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a= end;
+      b++;
+      break;
+    }
+    case HA_KEYTYPE_SHORT_INT:
+      s_1= mi_sint2korr(a);
+      s_2= mi_sint2korr(b);
+      if (piks && (flag = CMP_NUM(s_1,s_2)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 2; /* sizeof(short int); */
+      break;
+    case HA_KEYTYPE_USHORT_INT:
+      {
+        uint16 us_1,us_2;
+        us_1= mi_sint2korr(a);
+        us_2= mi_sint2korr(b);
+        if (piks && (flag = CMP_NUM(us_1,us_2)))
+          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+        a=  end;
+        b+=2; /* sizeof(short int); */
+        break;
+      }
+    case HA_KEYTYPE_LONG_INT:
+      l_1= mi_sint4korr(a);
+      l_2= mi_sint4korr(b);
+      if (piks && (flag = CMP_NUM(l_1,l_2)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 4; /* sizeof(long int); */
+      break;
+    case HA_KEYTYPE_ULONG_INT:
+      u_1= mi_sint4korr(a);
+      u_2= mi_sint4korr(b);
+      if (piks && (flag = CMP_NUM(u_1,u_2)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 4; /* sizeof(long int); */
+      break;
+    case HA_KEYTYPE_INT24:
+      l_1=mi_sint3korr(a);
+      l_2=mi_sint3korr(b);
+      if (piks && (flag = CMP_NUM(l_1,l_2)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 3;
+      break;
+    case HA_KEYTYPE_UINT24:
+      l_1=mi_uint3korr(a);
+      l_2=mi_uint3korr(b);
+      if (piks && (flag = CMP_NUM(l_1,l_2)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 3;
+      break;
+    case HA_KEYTYPE_FLOAT:
+      mi_float4get(f_1,a);
+      mi_float4get(f_2,b);
+      /*
+        The following may give a compiler warning about floating point
+        comparison not being safe, but this is ok in this context as
+        we are bascily doing sorting
+      */
+      if (piks && (flag = CMP_NUM(f_1,f_2)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 4; /* sizeof(float); */
+      break;
+    case HA_KEYTYPE_DOUBLE:
+      mi_float8get(d_1,a);
+      mi_float8get(d_2,b);
+      /*
+        The following may give a compiler warning about floating point
+        comparison not being safe, but this is ok in this context as
+        we are bascily doing sorting
+      */
+      if (piks && (flag = CMP_NUM(d_1,d_2)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 8;  /* sizeof(double); */
+      break;
+    case HA_KEYTYPE_NUM:                                /* Numeric key */
+    {
+      int swap_flag= 0;
+      int alength,blength;
+
+      if (keyseg->flag & HA_REVERSE_SORT)
+      {
+        swap_variables(uchar*, a, b);
+        swap_flag=1;                            /* Remember swap of a & b */
+        end= a+ (int) (end-b);
+      }
+      if (keyseg->flag & HA_SPACE_PACK)
+      {
+        alength= *a++; blength= *b++;
+        end=a+alength;
+        next_key_length=key_length-blength-1;
+      }
+      else
+      {
+        alength= (int) (end-a);
+        blength=keyseg->length;
+        /* remove pre space from keys */
+        for ( ; alength && *a == ' ' ; a++, alength--) ;
+        for ( ; blength && *b == ' ' ; b++, blength--) ;
+      }
+      if (piks)
+      {
+	if (*a == '-')
+	{
+	  if (*b != '-')
+	    return -1;
+	  a++; b++;
+	  swap_variables(uchar*, a, b);
+	  swap_variables(int, alength, blength);
+	  swap_flag=1-swap_flag;
+	  alength--; blength--;
+	  end=a+alength;
+	}
+	else if (*b == '-')
+	  return 1;
+	while (alength && (*a == '+' || *a == '0'))
+	{
+	  a++; alength--;
+	}
+	while (blength && (*b == '+' || *b == '0'))
+	{
+	  b++; blength--;
+	}
+	if (alength != blength)
+	  return (alength < blength) ? -1 : 1;
+	while (a < end)
+	  if (*a++ !=  *b++)
+	    return ((int) a[-1] - (int) b[-1]);
+      }
+      else
+      {
+        b+=(end-a);
+        a=end;
+      }
+
+      if (swap_flag)                            /* Restore pointers */
+        swap_variables(uchar*, a, b);
+      break;
+    }
+#ifdef HAVE_LONG_LONG
+    case HA_KEYTYPE_LONGLONG:
+    {
+      longlong ll_a,ll_b;
+      ll_a= mi_sint8korr(a);
+      ll_b= mi_sint8korr(b);
+      if (piks && (flag = CMP_NUM(ll_a,ll_b)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 8;
+      break;
+    }
+    case HA_KEYTYPE_ULONGLONG:
+    {
+      ulonglong ll_a,ll_b;
+      ll_a= mi_uint8korr(a);
+      ll_b= mi_uint8korr(b);
+      if (piks && (flag = CMP_NUM(ll_a,ll_b)))
+        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
+      a=  end;
+      b+= 8;
+      break;
+    }
+#endif
+    case HA_KEYTYPE_END:                        /* Ready */
+      goto end;                                 /* diff_pos is incremented */
+    }
+  }
+  (*diff_pos)++;
+end:
+  if (!(nextflag & SEARCH_FIND))
+  {
+    uint i;
+    if (nextflag & (SEARCH_NO_FIND | SEARCH_LAST)) /* Find record after key */
+      return (nextflag & (SEARCH_BIGGER | SEARCH_LAST)) ? -1 : 1;
+    flag=0;
+    for (i=keyseg->length ; i-- > 0 ; )
+    {
+      if (*a++ != *b++)
+      {
+        flag= FCMP(a[-1],b[-1]);
+        break;
+      }
+    }
+    if (nextflag & SEARCH_SAME)
+      return (flag);                            /* read same */
+    if (nextflag & SEARCH_BIGGER)
+      return (flag <= 0 ? -1 : 1);              /* read next */
+    return (flag < 0 ? -1 : 1);                 /* read previous */
+  }
+  return 0;
+} /* ha_key_cmp */
+
+

=== removed file 'mysys/my_gethostbyname.c'
--- a/mysys/my_gethostbyname.c	2011-01-11 09:07:37 +0000
+++ b/mysys/my_gethostbyname.c	1970-01-01 00:00:00 +0000
@@ -1,111 +0,0 @@
-/* Copyright (C) 2002, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
-   
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public
-   License as published by the Free Software Foundation; version 2
-   of the License.
-   
-   This library 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
-   Library General Public License for more details.
-   
-   You should have received a copy of the GNU Library General Public
-   License along with this library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA */
-
-/* Thread safe version of gethostbyname_r() */
-
-#include "mysys_priv.h"
-#if !defined(__WIN__)
-#include <netdb.h>
-#endif
-#include <my_net.h>
-
-/* This file is not needed if my_gethostbyname_r is a macro */
-#if !defined(my_gethostbyname_r)
-
-/*
-  Emulate SOLARIS style calls, not because it's better, but just to make the
-  usage of getbostbyname_r simpler.
-*/
-
-#if defined(HAVE_GETHOSTBYNAME_R)
-
-#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
-
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop)
-{
-  struct hostent *hp;
-  DBUG_ASSERT((size_t) buflen >= sizeof(*result));
-  if (gethostbyname_r(name,result, buffer, (size_t) buflen, &hp, h_errnop))
-    return 0;
-  return hp;
-}
-
-#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
-
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop)
-{
-  if (gethostbyname_r(name,result,(struct hostent_data *) buffer) == -1)
-  {
-    *h_errnop= errno;
-    return 0;
-  }
-  return result;
-}
-
-#else
-
-/* gethostbyname_r with similar interface as gethostbyname() */
-
-struct hostent *my_gethostbyname_r(const char *name,
-				   struct hostent *result, char *buffer,
-				   int buflen, int *h_errnop)
-{
-  struct hostent *hp;
-  DBUG_ASSERT(buflen >= sizeof(struct hostent_data));
-  hp= gethostbyname_r(name,result,(struct hostent_data *) buffer);
-  *h_errnop= errno;
-  return hp;
-}
-#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */
-
-#else /* !HAVE_GETHOSTBYNAME_R */
-
-extern mysql_mutex_t LOCK_gethostbyname_r;
-
-/*
-  No gethostbyname_r() function exists.
-  In this case we have to keep a mutex over the call to ensure that no
-  other thread is going to reuse the internal memory.
-
-  The user is responsible to call my_gethostbyname_r_free() when he
-  is finished with the structure.
-*/
-
-struct hostent *my_gethostbyname_r(const char *name,
-                                   struct hostent *res __attribute__((unused)),
-                                   char *buffer __attribute__((unused)),
-                                   int buflen __attribute__((unused)),
-                                   int *h_errnop)
-{
-  struct hostent *hp;
-  mysql_mutex_lock(&LOCK_gethostbyname_r);
-  hp= gethostbyname(name);
-  *h_errnop= h_errno;
-  return hp;
-}
-
-void my_gethostbyname_r_free()
-{
-  mysql_mutex_unlock(&LOCK_gethostbyname_r);
-}
-
-#endif /* !HAVE_GETHOSTBYNAME_R */
-#endif /* !my_gethostbyname_r */

=== removed file 'mysys/my_handler.c'
--- a/mysys/my_handler.c	2010-07-23 20:16:29 +0000
+++ b/mysys/my_handler.c	1970-01-01 00:00:00 +0000
@@ -1,604 +0,0 @@
-/* Copyright (C) 2002-2006 MySQL AB
-   
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public
-   License as published by the Free Software Foundation; version 2
-   of the License.
-   
-   This library 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
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with this library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA */
-
-#include <my_global.h>
-#include <m_ctype.h>
-#include <my_base.h>
-#include <my_handler.h>
-#include <my_sys.h>
-
-#include "my_handler_errors.h"
-
-#define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
-
-int ha_compare_text(CHARSET_INFO *charset_info, uchar *a, uint a_length,
-		    uchar *b, uint b_length, my_bool part_key,
-		    my_bool skip_end_space)
-{
-  if (!part_key)
-    return charset_info->coll->strnncollsp(charset_info, a, a_length,
-                                           b, b_length, (my_bool)!skip_end_space);
-  return charset_info->coll->strnncoll(charset_info, a, a_length,
-                                       b, b_length, part_key);
-}
-
-
-static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
-                       my_bool part_key, my_bool skip_end_space)
-{
-  uint length= min(a_length,b_length);
-  uchar *end= a+ length;
-  int flag;
-
-  while (a < end)
-    if ((flag= (int) *a++ - (int) *b++))
-      return flag;
-  if (part_key && b_length < a_length)
-    return 0;
-  if (skip_end_space && a_length != b_length)
-  {
-    int swap= 1;
-    /*
-      We are using space compression. We have to check if longer key
-      has next character < ' ', in which case it's less than the shorter
-      key that has an implicite space afterwards.
-
-      This code is identical to the one in
-      strings/ctype-simple.c:my_strnncollsp_simple
-    */
-    if (a_length < b_length)
-    {
-      /* put shorter key in a */
-      a_length= b_length;
-      a= b;
-      swap= -1;					/* swap sign of result */
-    }
-    for (end= a + a_length-length; a < end ; a++)
-    {
-      if (*a != ' ')
-	return (*a < ' ') ? -swap : swap;
-    }
-    return 0;
-  }
-  return (int) (a_length-b_length);
-}
-
-
-/*
-  Compare two keys
-
-  SYNOPSIS
-    ha_key_cmp()
-    keyseg	Array of key segments of key to compare
-    a		First key to compare, in format from _mi_pack_key()
-		This is normally key specified by user
-    b		Second key to compare.  This is always from a row
-    key_length	Length of key to compare.  This can be shorter than
-		a to just compare sub keys
-    next_flag	How keys should be compared
-		If bit SEARCH_FIND is not set the keys includes the row
-		position and this should also be compared
-    diff_pos    OUT Number of first keypart where values differ, counting 
-                from one.
-    diff_pos[1] OUT  (b + diff_pos[1]) points to first value in tuple b
-                      that is different from corresponding value in tuple a.
-  
-  EXAMPLES 
-   Example1: if the function is called for tuples
-     ('aaa','bbb') and ('eee','fff'), then
-     diff_pos[0] = 1 (as 'aaa' != 'eee')
-     diff_pos[1] = 0 (offset from beggining of tuple b to 'eee' keypart).
-
-   Example2: if the index function is called for tuples
-     ('aaa','bbb') and ('aaa','fff'),
-     diff_pos[0] = 2 (as 'aaa' != 'eee')
-     diff_pos[1] = 3 (offset from beggining of tuple b to 'fff' keypart,
-                      here we assume that first key part is CHAR(3) NOT NULL)
-
-  NOTES
-    Number-keys can't be splited
-
-  RETURN VALUES
-    <0	If a < b
-    0	If a == b
-    >0	If a > b
-*/
-
-#define FCMP(A,B) ((int) (A) - (int) (B))
-
-int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
-	       register uchar *b, uint key_length, uint nextflag,
-	       uint *diff_pos)
-{
-  int flag;
-  int16 s_1,s_2;
-  int32 l_1,l_2;
-  uint32 u_1,u_2;
-  float f_1,f_2;
-  double d_1,d_2;
-  uint next_key_length;
-  uchar *orig_b= b;
-
-  *diff_pos=0;
-  for ( ; (int) key_length >0 ; key_length=next_key_length, keyseg++)
-  {
-    uchar *end;
-    uint piks=! (keyseg->flag & HA_NO_SORT);
-    (*diff_pos)++;
-    diff_pos[1]= (uint)(b - orig_b);
-
-    /* Handle NULL part */
-    if (keyseg->null_bit)
-    {
-      key_length--;
-      if (*a != *b && piks)
-      {
-        flag = (int) *a - (int) *b;
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      }
-      b++;
-      if (!*a++)                                /* If key was NULL */
-      {
-        if (nextflag == (SEARCH_FIND | SEARCH_UPDATE))
-          nextflag=SEARCH_SAME;                 /* Allow duplicate keys */
-  	else if (nextflag & SEARCH_NULL_ARE_NOT_EQUAL)
-	{
-	  /*
-	    This is only used from mi_check() to calculate cardinality.
-	    It can't be used when searching for a key as this would cause
-	    compare of (a,b) and (b,a) to return the same value.
-	  */
-	  return -1;
-	}
-        next_key_length=key_length;
-        continue;                               /* To next key part */
-      }
-    }
-    end= a+ min(keyseg->length,key_length);
-    next_key_length=key_length-keyseg->length;
-
-    switch ((enum ha_base_keytype) keyseg->type) {
-    case HA_KEYTYPE_TEXT:                       /* Ascii; Key is converted */
-      if (keyseg->flag & HA_SPACE_PACK)
-      {
-        int a_length,b_length,pack_length;
-        get_key_length(a_length,a);
-        get_key_pack_length(b_length,pack_length,b);
-        next_key_length=key_length-b_length-pack_length;
-
-        if (piks &&
-            (flag=ha_compare_text(keyseg->charset,a,a_length,b,b_length,
-				  (my_bool) ((nextflag & SEARCH_PREFIX) &&
-					     next_key_length <= 0),
-				  (my_bool)!(nextflag & SEARCH_PREFIX))))
-          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-        a+=a_length;
-        b+=b_length;
-        break;
-      }
-      else
-      {
-	uint length=(uint) (end-a), a_length=length, b_length=length;
-        if (piks &&
-            (flag= ha_compare_text(keyseg->charset, a, a_length, b, b_length,
-				   (my_bool) ((nextflag & SEARCH_PREFIX) &&
-					      next_key_length <= 0),
-				   (my_bool)!(nextflag & SEARCH_PREFIX))))
-          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-        a=end;
-        b+=length;
-      }
-      break;
-    case HA_KEYTYPE_BINARY:
-    case HA_KEYTYPE_BIT:
-      if (keyseg->flag & HA_SPACE_PACK)
-      {
-        int a_length,b_length,pack_length;
-        get_key_length(a_length,a);
-        get_key_pack_length(b_length,pack_length,b);
-        next_key_length=key_length-b_length-pack_length;
-
-        if (piks &&
-	    (flag=compare_bin(a,a_length,b,b_length,
-                              (my_bool) ((nextflag & SEARCH_PREFIX) &&
-                                         next_key_length <= 0),1)))
-          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-        a+=a_length;
-        b+=b_length;
-        break;
-      }
-      else
-      {
-        uint length=keyseg->length;
-        if (piks &&
-	    (flag=compare_bin(a,length,b,length,
-                              (my_bool) ((nextflag & SEARCH_PREFIX) &&
-                                         next_key_length <= 0),0)))
-          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-        a+=length;
-        b+=length;
-      }
-      break;
-    case HA_KEYTYPE_VARTEXT1:
-    case HA_KEYTYPE_VARTEXT2:
-      {
-        int a_length,b_length,pack_length;
-        get_key_length(a_length,a);
-        get_key_pack_length(b_length,pack_length,b);
-        next_key_length=key_length-b_length-pack_length;
-
-        if (piks &&
-	    (flag= ha_compare_text(keyseg->charset,a,a_length,b,b_length,
-                                   (my_bool) ((nextflag & SEARCH_PREFIX) &&
-                                              next_key_length <= 0),
-				   (my_bool) ((nextflag & (SEARCH_FIND |
-							   SEARCH_UPDATE)) ==
-					      SEARCH_FIND &&
-                                              ! (keyseg->flag &
-                                                 HA_END_SPACE_ARE_EQUAL)))))
-          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-        a+= a_length;
-        b+= b_length;
-        break;
-      }
-      break;
-    case HA_KEYTYPE_VARBINARY1:
-    case HA_KEYTYPE_VARBINARY2:
-      {
-        int a_length,b_length,pack_length;
-        get_key_length(a_length,a);
-        get_key_pack_length(b_length,pack_length,b);
-        next_key_length=key_length-b_length-pack_length;
-
-        if (piks &&
-	    (flag=compare_bin(a,a_length,b,b_length,
-                              (my_bool) ((nextflag & SEARCH_PREFIX) &&
-                                         next_key_length <= 0), 0)))
-          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-        a+=a_length;
-        b+=b_length;
-      }
-      break;
-    case HA_KEYTYPE_INT8:
-    {
-      int i_1= (int) *((signed char*) a);
-      int i_2= (int) *((signed char*) b);
-      if (piks && (flag = CMP_NUM(i_1,i_2)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a= end;
-      b++;
-      break;
-    }
-    case HA_KEYTYPE_SHORT_INT:
-      s_1= mi_sint2korr(a);
-      s_2= mi_sint2korr(b);
-      if (piks && (flag = CMP_NUM(s_1,s_2)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 2; /* sizeof(short int); */
-      break;
-    case HA_KEYTYPE_USHORT_INT:
-      {
-        uint16 us_1,us_2;
-        us_1= mi_sint2korr(a);
-        us_2= mi_sint2korr(b);
-        if (piks && (flag = CMP_NUM(us_1,us_2)))
-          return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-        a=  end;
-        b+=2; /* sizeof(short int); */
-        break;
-      }
-    case HA_KEYTYPE_LONG_INT:
-      l_1= mi_sint4korr(a);
-      l_2= mi_sint4korr(b);
-      if (piks && (flag = CMP_NUM(l_1,l_2)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 4; /* sizeof(long int); */
-      break;
-    case HA_KEYTYPE_ULONG_INT:
-      u_1= mi_sint4korr(a);
-      u_2= mi_sint4korr(b);
-      if (piks && (flag = CMP_NUM(u_1,u_2)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 4; /* sizeof(long int); */
-      break;
-    case HA_KEYTYPE_INT24:
-      l_1=mi_sint3korr(a);
-      l_2=mi_sint3korr(b);
-      if (piks && (flag = CMP_NUM(l_1,l_2)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 3;
-      break;
-    case HA_KEYTYPE_UINT24:
-      l_1=mi_uint3korr(a);
-      l_2=mi_uint3korr(b);
-      if (piks && (flag = CMP_NUM(l_1,l_2)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 3;
-      break;
-    case HA_KEYTYPE_FLOAT:
-      mi_float4get(f_1,a);
-      mi_float4get(f_2,b);
-      /*
-        The following may give a compiler warning about floating point
-        comparison not being safe, but this is ok in this context as
-        we are bascily doing sorting
-      */
-      if (piks && (flag = CMP_NUM(f_1,f_2)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 4; /* sizeof(float); */
-      break;
-    case HA_KEYTYPE_DOUBLE:
-      mi_float8get(d_1,a);
-      mi_float8get(d_2,b);
-      /*
-        The following may give a compiler warning about floating point
-        comparison not being safe, but this is ok in this context as
-        we are bascily doing sorting
-      */
-      if (piks && (flag = CMP_NUM(d_1,d_2)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 8;  /* sizeof(double); */
-      break;
-    case HA_KEYTYPE_NUM:                                /* Numeric key */
-    {
-      int swap_flag= 0;
-      int alength,blength;
-
-      if (keyseg->flag & HA_REVERSE_SORT)
-      {
-        swap_variables(uchar*, a, b);
-        swap_flag=1;                            /* Remember swap of a & b */
-        end= a+ (int) (end-b);
-      }
-      if (keyseg->flag & HA_SPACE_PACK)
-      {
-        alength= *a++; blength= *b++;
-        end=a+alength;
-        next_key_length=key_length-blength-1;
-      }
-      else
-      {
-        alength= (int) (end-a);
-        blength=keyseg->length;
-        /* remove pre space from keys */
-        for ( ; alength && *a == ' ' ; a++, alength--) ;
-        for ( ; blength && *b == ' ' ; b++, blength--) ;
-      }
-      if (piks)
-      {
-	if (*a == '-')
-	{
-	  if (*b != '-')
-	    return -1;
-	  a++; b++;
-	  swap_variables(uchar*, a, b);
-	  swap_variables(int, alength, blength);
-	  swap_flag=1-swap_flag;
-	  alength--; blength--;
-	  end=a+alength;
-	}
-	else if (*b == '-')
-	  return 1;
-	while (alength && (*a == '+' || *a == '0'))
-	{
-	  a++; alength--;
-	}
-	while (blength && (*b == '+' || *b == '0'))
-	{
-	  b++; blength--;
-	}
-	if (alength != blength)
-	  return (alength < blength) ? -1 : 1;
-	while (a < end)
-	  if (*a++ !=  *b++)
-	    return ((int) a[-1] - (int) b[-1]);
-      }
-      else
-      {
-        b+=(end-a);
-        a=end;
-      }
-
-      if (swap_flag)                            /* Restore pointers */
-        swap_variables(uchar*, a, b);
-      break;
-    }
-#ifdef HAVE_LONG_LONG
-    case HA_KEYTYPE_LONGLONG:
-    {
-      longlong ll_a,ll_b;
-      ll_a= mi_sint8korr(a);
-      ll_b= mi_sint8korr(b);
-      if (piks && (flag = CMP_NUM(ll_a,ll_b)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 8;
-      break;
-    }
-    case HA_KEYTYPE_ULONGLONG:
-    {
-      ulonglong ll_a,ll_b;
-      ll_a= mi_uint8korr(a);
-      ll_b= mi_uint8korr(b);
-      if (piks && (flag = CMP_NUM(ll_a,ll_b)))
-        return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
-      a=  end;
-      b+= 8;
-      break;
-    }
-#endif
-    case HA_KEYTYPE_END:                        /* Ready */
-      goto end;                                 /* diff_pos is incremented */
-    }
-  }
-  (*diff_pos)++;
-end:
-  if (!(nextflag & SEARCH_FIND))
-  {
-    uint i;
-    if (nextflag & (SEARCH_NO_FIND | SEARCH_LAST)) /* Find record after key */
-      return (nextflag & (SEARCH_BIGGER | SEARCH_LAST)) ? -1 : 1;
-    flag=0;
-    for (i=keyseg->length ; i-- > 0 ; )
-    {
-      if (*a++ != *b++)
-      {
-        flag= FCMP(a[-1],b[-1]);
-        break;
-      }
-    }
-    if (nextflag & SEARCH_SAME)
-      return (flag);                            /* read same */
-    if (nextflag & SEARCH_BIGGER)
-      return (flag <= 0 ? -1 : 1);              /* read next */
-    return (flag < 0 ? -1 : 1);                 /* read previous */
-  }
-  return 0;
-} /* ha_key_cmp */
-
-
-/*
-  Find the first NULL value in index-suffix values tuple
-
-  SYNOPSIS
-    ha_find_null()
-      keyseg     Array of keyparts for key suffix
-      a          Key suffix value tuple
-
-  DESCRIPTION
-    Find the first NULL value in index-suffix values tuple.
-
-  TODO
-    Consider optimizing this function or its use so we don't search for
-    NULL values in completely NOT NULL index suffixes.
-
-  RETURN
-    First key part that has NULL as value in values tuple, or the last key
-    part (with keyseg->type==HA_TYPE_END) if values tuple doesn't contain
-    NULLs.
-*/
-
-HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
-{
-  for (; (enum ha_base_keytype) keyseg->type != HA_KEYTYPE_END; keyseg++)
-  {
-    uchar *end;
-    if (keyseg->null_bit)
-    {
-      if (!*a++)
-        return keyseg;
-    }
-    end= a+ keyseg->length;
-
-    switch ((enum ha_base_keytype) keyseg->type) {
-    case HA_KEYTYPE_TEXT:
-    case HA_KEYTYPE_BINARY:
-    case HA_KEYTYPE_BIT:
-      if (keyseg->flag & HA_SPACE_PACK)
-      {
-        int a_length;
-        get_key_length(a_length, a);
-        a += a_length;
-        break;
-      }
-      else
-        a= end;
-      break;
-    case HA_KEYTYPE_VARTEXT1:
-    case HA_KEYTYPE_VARTEXT2:
-    case HA_KEYTYPE_VARBINARY1:
-    case HA_KEYTYPE_VARBINARY2:
-      {
-        int a_length;
-        get_key_length(a_length, a);
-        a+= a_length;
-        break;
-      }
-    case HA_KEYTYPE_NUM:
-      if (keyseg->flag & HA_SPACE_PACK)
-      {
-        int alength= *a++;
-        end= a+alength;
-      }
-      a= end;
-      break;
-    case HA_KEYTYPE_INT8:
-    case HA_KEYTYPE_SHORT_INT:
-    case HA_KEYTYPE_USHORT_INT:
-    case HA_KEYTYPE_LONG_INT:
-    case HA_KEYTYPE_ULONG_INT:
-    case HA_KEYTYPE_INT24:
-    case HA_KEYTYPE_UINT24:
-#ifdef HAVE_LONG_LONG
-    case HA_KEYTYPE_LONGLONG:
-    case HA_KEYTYPE_ULONGLONG:
-#endif
-    case HA_KEYTYPE_FLOAT:
-    case HA_KEYTYPE_DOUBLE:
-      a= end;
-      break;
-    case HA_KEYTYPE_END:                        /* purecov: inspected */
-      /* keep compiler happy */
-      DBUG_ASSERT(0);
-      break;
-    }
-  }
-  return keyseg;
-}
-
-
-
-/*
-  Register handler error messages for usage with my_error()
-
-  NOTES
-    This is safe to call multiple times as my_error_register()
-    will ignore calls to register already registered error numbers.
-*/
-
-static const char **get_handler_error_messages()
-{
-  return handler_error_messages;
-}
-
-void my_handler_error_register(void)
-{
-  /*
-    If you got compilation error here about compile_time_assert array, check
-    that every HA_ERR_xxx constant has a corresponding error message in
-    handler_error_messages[] list (check mysys/ma_handler_errors.h and
-    include/my_base.h).
-  */
-  compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
-                      HA_ERR_LAST + 1);
-  my_error_register(get_handler_error_messages, HA_ERR_FIRST,
-                    HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
-}
-
-
-void my_handler_error_unregister(void)
-{
-  my_error_unregister(HA_ERR_FIRST,
-                      HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
-}

=== modified file 'mysys/my_handler_errors.h'
--- a/mysys/my_handler_errors.h	2009-09-23 21:32:31 +0000
+++ b/mysys/my_handler_errors.h	2011-03-29 12:43:49 +0000
@@ -68,4 +68,8 @@ static const char *handler_error_message
   "Too many active concurrent transactions"
 };
 
+extern void my_handler_error_register(void);
+extern void my_handler_error_unregister(void);
+
+
 #endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */

=== removed file 'mysys/my_port.c'
--- a/mysys/my_port.c	2006-12-31 00:02:27 +0000
+++ b/mysys/my_port.c	1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
-/* Copyright (C) 2002 MySQL AB
-   
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public
-   License as published by the Free Software Foundation; version 2
-   of the License.
-   
-   This library 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
-   Library General Public License for more details.
-   
-   You should have received a copy of the GNU Library General Public
-   License along with this library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA */
-
-/* 
-   Small functions to make code portable
-*/
-
-#include "mysys_priv.h"
-
-#ifdef _AIX
-
-/*
-  On AIX, at least with gcc 3.1, the expression
-  '(double) (ulonglong) var' doesn't always work for big unsigned
-  integers like '18446744073709551615'.  The end result is that the
-  high bit is simply dropped. (probably bug in gcc optimizations)
-  Handling the conversion in a sub function seems to work.
-*/
-
-
-
-double my_ulonglong2double(unsigned long long nr)
-{
-  return (double) nr;
-}
-#endif /* _AIX */

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-03-08 08:41:57 +0000
+++ b/sql/handler.h	2011-03-29 12:43:49 +0000
@@ -29,7 +29,7 @@
 #include "sql_cache.h"
 #include "structs.h"                            /* SHOW_COMP_OPTION */
 
-#include <my_handler.h>
+#include <my_compare.h>
 #include <ft_global.h>
 #include <keycache.h>
 

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-03-16 14:11:20 +0000
+++ b/sql/item.cc	2011-03-30 07:25:49 +0000
@@ -997,8 +997,12 @@ bool Item::get_date(MYSQL_TIME *ltime,ui
   }
   else
   {
-    longlong value= val_int();
     int was_cut;
+    longlong value= val_int();
+
+    if (null_value)
+      goto err;
+
     if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == LL(-1))
     {
       char buff[22], *end;

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-03-16 14:11:20 +0000
+++ b/sql/item_func.cc	2011-03-28 13:33:35 +0000
@@ -505,7 +505,10 @@ bool Item_func::is_expensive_processor(u
 my_decimal *Item_func::val_decimal(my_decimal *decimal_value)
 {
   DBUG_ASSERT(fixed);
-  int2my_decimal(E_DEC_FATAL_ERROR, val_int(), unsigned_flag, decimal_value);
+  longlong nr= val_int();
+  if (null_value)
+    return 0; /* purecov: inspected */
+  int2my_decimal(E_DEC_FATAL_ERROR, nr, unsigned_flag, decimal_value);
   return decimal_value;
 }
 
@@ -2088,9 +2091,10 @@ void Item_func_integer::fix_length_and_d
 
 void Item_func_int_val::fix_num_length_and_dec()
 {
-  max_length= args[0]->max_length - (args[0]->decimals ?
-                                     args[0]->decimals + 1 :
-                                     0) + 2;
+  ulonglong tmp_max_length= (ulonglong ) args[0]->max_length - 
+    (args[0]->decimals ? args[0]->decimals + 1 : 0) + 2;
+  max_length= tmp_max_length > (ulonglong) 4294967295U ?
+    (uint32) 4294967295U : (uint32) tmp_max_length;
   uint tmp= float_length(decimals);
   set_if_smaller(max_length,tmp);
   decimals= 0;
@@ -4261,6 +4265,7 @@ Item_func_set_user_var::fix_length_and_d
     fix_length_and_charset(args[0]->max_char_length(),
                            args[0]->collation.collation);
   }
+  unsigned_flag= args[0]->unsigned_flag;
 }
 
 

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2011-02-18 08:10:30 +0000
+++ b/sql/item_timefunc.cc	2011-03-28 13:33:35 +0000
@@ -315,8 +315,8 @@ static bool extract_date_time(DATE_TIME_
   for (; ptr != end && val != val_end; ptr++)
   {
     /* Skip pre-space between each argument */
-    while (val != val_end && my_isspace(cs, *val))
-      val++;
+    if ((val+= cs->cset->scan(cs, val, val_end, MY_SEQ_SPACES)) >= val_end)
+      break;
 
     if (*ptr == '%' && ptr+1 != end)
     {
@@ -3405,6 +3405,7 @@ void Item_func_str_to_date::fix_length_a
 {
   maybe_null= 1;
   decimals=0;
+  cached_format_type= DATE_TIME;
   cached_field_type= MYSQL_TYPE_DATETIME;
   max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
   cached_timestamp_type= MYSQL_TIMESTAMP_NONE;

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2011-03-08 17:39:25 +0000
+++ b/sql/item_timefunc.h	2011-03-30 07:25:49 +0000
@@ -144,8 +144,11 @@ public:
   { DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
   String *val_str(String *str) 
   {
-    str->set(val_int(), collation.collation);
-    return null_value ? 0 : str;
+    longlong nr= val_int();
+    if (null_value)
+      return 0;
+    str->set(nr, collation.collation);
+    return str;
   }
   const char *func_name() const { return "month"; }
   enum Item_result result_type () const { return INT_RESULT; }

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-12-29 05:22:52 +0000
+++ b/sql/log_event.cc	2011-03-25 12:13:17 +0000
@@ -9052,7 +9052,19 @@ static bool record_compare(TABLE *table)
     }
   }
 
-  if (table->s->blob_fields + table->s->varchar_fields == 0)
+  /**
+    Compare full record only if:
+    - there are no blob fields (otherwise we would also need 
+      to compare blobs contents as well);
+    - there are no varchar fields (otherwise we would also need
+      to compare varchar contents as well);
+    - there are no null fields, otherwise NULLed fields 
+      contents (i.e., the don't care bytes) may show arbitrary 
+      values, depending on how each engine handles internally.
+    */
+  if ((table->s->blob_fields + 
+       table->s->varchar_fields + 
+       table->s->null_fields) == 0)
   {
     result= cmp_record(table,record[1]);
     goto record_compare_exit;
@@ -9067,13 +9079,22 @@ static bool record_compare(TABLE *table)
     goto record_compare_exit;
   }
 
-  /* Compare updated fields */
+  /* Compare fields */
   for (Field **ptr=table->field ; *ptr ; ptr++)
   {
-    if ((*ptr)->cmp_binary_offset(table->s->rec_buff_length))
+
+    /**
+      We only compare field contents that are not null.
+      NULL fields (i.e., their null bits) were compared 
+      earlier.
+    */
+    if (!(*(ptr))->is_null())
     {
-      result= TRUE;
-      goto record_compare_exit;
+      if ((*ptr)->cmp_binary_offset(table->s->rec_buff_length))
+      {
+        result= TRUE;
+        goto record_compare_exit;
+      }
     }
   }
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-03-15 12:57:36 +0000
+++ b/sql/mysqld.cc	2011-03-25 12:55:22 +0000
@@ -7282,6 +7282,14 @@ static int get_options(int *argc_ptr, ch
        opt_log_slow_slave_statements) &&
       !opt_slow_log)
     sql_print_warning("options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set");
+  if (global_system_variables.net_buffer_length > 
+      global_system_variables.max_allowed_packet)
+  {
+    sql_print_warning("net_buffer_length (%lu) is set to be larger "
+                      "than max_allowed_packet (%lu). Please rectify.",
+                      global_system_variables.net_buffer_length, 
+                      global_system_variables.max_allowed_packet);
+  }
 
   if (log_error_file_ptr != disabled_my_option)
     opt_error_log= 1;

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2011-03-08 08:41:57 +0000
+++ b/sql/share/errmsg-utf8.txt	2011-03-25 12:55:22 +0000
@@ -6402,3 +6402,6 @@ ER_MULTI_UPDATE_KEY_CONFLICT
 # message as mysqlcheck parses the error message looking for ALTER TABLE.
 ER_TABLE_NEEDS_REBUILD
         eng "Table rebuild required. Please do \"ALTER TABLE `%-.32s` FORCE\" or dump/reload to fix it!"
+
+WARN_OPTION_BELOW_LIMIT
+  eng "The value of '%s' should be no less than the value of '%s'"

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2011-03-08 17:39:25 +0000
+++ b/sql/sql_show.cc	2011-03-25 14:03:44 +0000
@@ -1379,17 +1379,24 @@ int store_create_info(THD *thd, TABLE_LI
   if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
   {
     show_table_options= TRUE;
-    /*
-      Get possible table space definitions and append them
-      to the CREATE TABLE statement
-    */
 
-    if ((for_str= file->get_tablespace_name(thd,0,0)))
+    /* TABLESPACE and STORAGE */
+    if (share->tablespace ||
+        share->default_storage_media != HA_SM_DEFAULT)
     {
-      packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE "));
-      packet->append(for_str, strlen(for_str));
-      packet->append(STRING_WITH_LEN(" STORAGE DISK */"));
-      my_free(for_str);
+      packet->append(STRING_WITH_LEN(" /*!50100"));
+      if (share->tablespace)
+      {
+        packet->append(STRING_WITH_LEN(" TABLESPACE "));
+        packet->append(share->tablespace, strlen(share->tablespace));
+      }
+
+      if (share->default_storage_media == HA_SM_DISK)
+        packet->append(STRING_WITH_LEN(" STORAGE DISK"));
+      if (share->default_storage_media == HA_SM_MEMORY)
+        packet->append(STRING_WITH_LEN(" STORAGE MEMORY"));
+
+      packet->append(STRING_WITH_LEN(" */"));
     }
 
     /*
@@ -5496,12 +5503,9 @@ static void store_schema_partitions_reco
                               strlen(part_elem->tablespace_name), cs);
     else
     {
-      char *ts= showing_table->file->get_tablespace_name(thd,0,0);
+      char *ts= showing_table->s->tablespace;
       if(ts)
-      {
         table->field[24]->store(ts, strlen(ts), cs);
-        my_free(ts);
-      }
       else
         table->field[24]->set_null();
     }

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-03-07 09:08:10 +0000
+++ b/sql/sql_table.cc	2011-03-25 14:03:44 +0000
@@ -5281,17 +5281,12 @@ mysql_prepare_alter_table(THD *thd, TABL
   if (!(used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE))
     create_info->key_block_size= table->s->key_block_size;
 
-  if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY)
-  {
-    char *tablespace= static_cast<char *>(thd->alloc(FN_LEN + 1));
-    /*
-       Regular alter table of disk stored table (no tablespace/storage change)
-       Copy tablespace name
-    */
-    if (tablespace &&
-        (table->file->get_tablespace_name(thd, tablespace, FN_LEN)))
-      create_info->tablespace= tablespace;
-  }
+  if (!create_info->tablespace)
+    create_info->tablespace= table->s->tablespace;
+
+  if (create_info->storage_media == HA_SM_DEFAULT)
+    create_info->storage_media= table->s->default_storage_media;
+
   restore_record(table, s->default_values);     // Empty record for DEFAULT
   Create_field *def;
 

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-03-15 12:57:36 +0000
+++ b/sql/sys_vars.cc	2011-03-25 12:55:22 +0000
@@ -1030,13 +1030,32 @@ static bool session_readonly(sys_var *se
            self->name.str, "GLOBAL");
   return true;
 }
+
+static bool
+check_max_allowed_packet(sys_var *self, THD *thd,  set_var *var)
+{
+  longlong val;
+  if (session_readonly(self, thd, var))
+    return true;
+
+  val= var->save_result.ulonglong_value;
+  if (val < (longlong) global_system_variables.net_buffer_length)
+  {
+    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        WARN_OPTION_BELOW_LIMIT, ER(WARN_OPTION_BELOW_LIMIT),
+                        "max_allowed_packet", "net_buffer_length");
+  }
+  return false;
+}
+
+
 static Sys_var_ulong Sys_max_allowed_packet(
        "max_allowed_packet",
        "Max packet length to send to or receive from the server",
        SESSION_VAR(max_allowed_packet), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(1024, 1024*1024*1024), DEFAULT(1024*1024),
        BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG,
-       ON_CHECK(session_readonly));
+       ON_CHECK(check_max_allowed_packet));
 
 static Sys_var_ulonglong Sys_max_binlog_cache_size(
        "max_binlog_cache_size",
@@ -1267,12 +1286,29 @@ static Sys_var_mybool Sys_named_pipe(
        DEFAULT(FALSE));
 #endif
 
+
+static bool 
+check_net_buffer_length(sys_var *self, THD *thd,  set_var *var)
+{
+  longlong val;
+  if (session_readonly(self, thd, var))
+    return true;
+
+  val= var->save_result.ulonglong_value;
+  if (val > (longlong) global_system_variables.max_allowed_packet)
+  {
+    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        WARN_OPTION_BELOW_LIMIT, ER(WARN_OPTION_BELOW_LIMIT),
+                        "max_allowed_packet", "net_buffer_length");
+  }
+  return false;
+}
 static Sys_var_ulong Sys_net_buffer_length(
        "net_buffer_length",
        "Buffer length for TCP/IP and socket communication",
        SESSION_VAR(net_buffer_length), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(1024, 1024*1024), DEFAULT(16384), BLOCK_SIZE(1024),
-       NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(session_readonly));
+       NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_net_buffer_length));
 
 static bool fix_net_read_timeout(sys_var *self, THD *thd, enum_var_type type)
 {
@@ -2766,7 +2802,7 @@ static Sys_var_charptr Sys_slow_log_path
        ON_CHECK(check_log_path), ON_UPDATE(fix_slow_log_file));
 
 /// @todo deprecate these four legacy have_PLUGIN variables and use I_S instead
-export SHOW_COMP_OPTION have_csv, have_innodb;
+export SHOW_COMP_OPTION have_csv, have_innodb= SHOW_OPTION_DISABLED;
 export SHOW_COMP_OPTION have_ndbcluster, have_partitioning;
 static Sys_var_have Sys_have_csv(
        "have_csv", "have_csv",

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-03-16 14:11:20 +0000
+++ b/sql/table.cc	2011-03-25 14:03:44 +0000
@@ -750,6 +750,9 @@ static int open_binary_frm(THD *thd, TAB
   const char **interval_array;
   enum legacy_db_type legacy_db_type;
   my_bitmap_map *bitmaps;
+  uchar *extra_segment_buff= 0;
+  const uint format_section_header_size= 8;
+  uchar *format_section_fields= 0;
   DBUG_ENTER("open_binary_frm");
 
   new_field_pack_flag= head[27];
@@ -942,27 +945,27 @@ static int open_binary_frm(THD *thd, TAB
   if ((n_length= uint4korr(head+55)))
   {
     /* Read extra data segment */
-    uchar *buff, *next_chunk, *buff_end;
+    uchar *next_chunk, *buff_end;
     DBUG_PRINT("info", ("extra segment size is %u bytes", n_length));
-    if (!(next_chunk= buff= (uchar*) my_malloc(n_length, MYF(MY_WME))))
+    if (!(extra_segment_buff= (uchar*) my_malloc(n_length, MYF(MY_WME))))
       goto err;
-    if (mysql_file_pread(file, buff, n_length, record_offset + share->reclength,
+    next_chunk= extra_segment_buff;
+    if (mysql_file_pread(file, extra_segment_buff,
+                         n_length, record_offset + share->reclength,
                          MYF(MY_NABP)))
     {
-      my_free(buff);
       goto err;
     }
-    share->connect_string.length= uint2korr(buff);
+    share->connect_string.length= uint2korr(next_chunk);
     if (!(share->connect_string.str= strmake_root(&share->mem_root,
                                                   (char*) next_chunk + 2,
                                                   share->connect_string.
                                                   length)))
     {
-      my_free(buff);
       goto err;
     }
     next_chunk+= share->connect_string.length + 2;
-    buff_end= buff + n_length;
+    buff_end= extra_segment_buff + n_length;
     if (next_chunk + 2 < buff_end)
     {
       uint str_db_type_length= uint2korr(next_chunk);
@@ -979,7 +982,6 @@ static int open_binary_frm(THD *thd, TAB
                 plugin_data(tmp_plugin, handlerton *)))
         {
           /* bad file, legacy_db_type did not match the name */
-          my_free(buff);
           goto err;
         }
         /*
@@ -1009,7 +1011,6 @@ static int open_binary_frm(THD *thd, TAB
           error= 8;
           my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
                    "--skip-partition");
-          my_free(buff);
           goto err;
         }
         plugin_unlock(NULL, share->db_plugin);
@@ -1025,7 +1026,6 @@ static int open_binary_frm(THD *thd, TAB
         error= 8;
         name.str[name.length]=0;
         my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), name.str);
-        my_free(buff);
         goto err;
         /* purecov: end */
       }
@@ -1042,7 +1042,6 @@ static int open_binary_frm(THD *thd, TAB
               memdup_root(&share->mem_root, next_chunk + 4,
                           partition_info_str_len + 1)))
         {
-          my_free(buff);
           goto err;
         }
       }
@@ -1050,7 +1049,6 @@ static int open_binary_frm(THD *thd, TAB
       if (partition_info_str_len)
       {
         DBUG_PRINT("info", ("WITH_PARTITION_STORAGE_ENGINE is not defined"));
-        my_free(buff);
         goto err;
       }
 #endif
@@ -1088,7 +1086,6 @@ static int open_binary_frm(THD *thd, TAB
         {
           DBUG_PRINT("error",
                      ("fulltext key uses parser that is not defined in .frm"));
-          my_free(buff);
           goto err;
         }
         parser_name.str= (char*) next_chunk;
@@ -1099,7 +1096,6 @@ static int open_binary_frm(THD *thd, TAB
         if (! keyinfo->parser)
         {
           my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), parser_name.str);
-          my_free(buff);
           goto err;
         }
       }
@@ -1111,19 +1107,68 @@ static int open_binary_frm(THD *thd, TAB
       {
           DBUG_PRINT("error",
                      ("long table comment is not defined in .frm"));
-          my_free(buff);
           goto err;
       }
       share->comment.length = uint2korr(next_chunk);
       if (! (share->comment.str= strmake_root(&share->mem_root,
              (char*)next_chunk + 2, share->comment.length)))
       {
-          my_free(buff);
           goto err;
       }
       next_chunk+= 2 + share->comment.length;
     }
-    my_free(buff);
+
+    if (next_chunk + format_section_header_size < buff_end)
+    {
+      /*
+        New extra data segment called "format section" with additional
+        table and column properties introduced by MySQL Cluster
+        based on 5.1.20
+
+        Table properties:
+        TABLESPACE <ts> and STORAGE [DISK|MEMORY]
+
+        Column properties:
+        COLUMN_FORMAT [DYNAMIC|FIXED] and STORAGE [DISK|MEMORY]
+      */
+      DBUG_PRINT("info", ("Found format section"));
+
+      /* header */
+      const uint format_section_length= uint2korr(next_chunk);
+      const uint format_section_flags= uint4korr(next_chunk+2);
+      /* 2 bytes unused */
+
+      if (next_chunk + format_section_length > buff_end)
+      {
+        DBUG_PRINT("error", ("format section length too long: %u",
+                             format_section_length));
+        goto err;
+      }
+      DBUG_PRINT("info", ("format_section_length: %u, format_section_flags: %u",
+                          format_section_length, format_section_flags));
+
+      share->default_storage_media=
+        (enum ha_storage_media) (format_section_flags & 0x7);
+
+      /* tablespace */
+      const char *tablespace=
+        (const char*)next_chunk + format_section_header_size;
+      const uint tablespace_length= strlen(tablespace);
+      if (tablespace_length &&
+          !(share->tablespace= strmake_root(&share->mem_root,
+                                            tablespace, tablespace_length+1)))
+      {
+        goto err;
+      }
+      DBUG_PRINT("info", ("tablespace: '%s'",
+                          share->tablespace ? share->tablespace : "<null>"));
+
+      /* pointer to format section for fields */
+      format_section_fields=
+        next_chunk + format_section_header_size + tablespace_length + 1;
+
+      next_chunk+= format_section_length;
+    }
   }
   share->key_block_size= uint2korr(head+62);
 
@@ -1438,6 +1483,18 @@ static int open_binary_frm(THD *thd, TAB
         error= 8; 
         goto err;
       }
+
+    if (format_section_fields)
+    {
+      const uchar field_flags= format_section_fields[i];
+      const uchar field_storage= (field_flags & STORAGE_TYPE_MASK);
+      const uchar field_column_format=
+        ((field_flags >> COLUMN_FORMAT_SHIFT)& COLUMN_FORMAT_MASK);
+      DBUG_PRINT("debug", ("field flags: %u, storage: %u, column_format: %u",
+                           field_flags, field_storage, field_column_format));
+      (void)field_storage; /* Reserved by and used in MySQL Cluster */
+      (void)field_column_format; /* Reserved by and used in MySQL Cluster */
+    }
   }
   *field_ptr=0;					// End marker
 
@@ -1705,6 +1762,7 @@ static int open_binary_frm(THD *thd, TAB
   if (use_hash)
     (void) my_hash_check(&share->name_hash);
 #endif
+  my_free(extra_segment_buff);
   DBUG_RETURN (0);
 
  err:
@@ -1712,6 +1770,7 @@ static int open_binary_frm(THD *thd, TAB
   share->open_errno= my_errno;
   share->errarg= errarg;
   my_free(disk_buff);
+  my_free(extra_segment_buff);
   delete crypted;
   delete handler_file;
   my_hash_free(&share->name_hash);
@@ -2687,6 +2746,8 @@ void update_create_info_from_table(HA_CR
   create_info->default_table_charset= share->table_charset;
   create_info->table_charset= 0;
   create_info->comment= share->comment;
+  create_info->storage_media= share->default_storage_media;
+  create_info->tablespace= share->tablespace;
 
   DBUG_VOID_RETURN;
 }

=== modified file 'sql/table.h'
--- a/sql/table.h	2010-12-29 00:26:31 +0000
+++ b/sql/table.h	2011-03-25 09:06:07 +0000
@@ -651,6 +651,16 @@ struct TABLE_SHARE
   */
   int cached_row_logging_check;
 
+  /*
+    Storage media to use for this table (unless another storage
+    media has been specified on an individual column - in versions
+    where that is supported)
+  */
+  enum ha_storage_media default_storage_media;
+
+  /* Name of the tablespace used for this table */
+  char *tablespace;
+
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   /* filled in when reading from frm */
   bool auto_partitioned;

=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc	2010-07-08 21:20:08 +0000
+++ b/sql/unireg.cc	2011-03-04 08:41:29 +0000
@@ -124,6 +124,9 @@ bool mysql_create_frm(THD *thd, const ch
 #endif
   Pack_header_error_handler pack_header_error_handler;
   int error;
+  const uint format_section_header_size= 8;
+  uint format_section_length;
+  uint tablespace_length= 0;
   DBUG_ENTER("mysql_create_frm");
 
   DBUG_ASSERT(*fn_rext((char*)file_name)); // Check .frm extension
@@ -256,6 +259,18 @@ bool mysql_create_frm(THD *thd, const ch
     forminfo[46]=(uchar) create_info->comment.length;
   }
 
+  /*
+    Add room in extra segment for "format section" with additional
+    table and column properties
+  */
+  if (create_info->tablespace)
+    tablespace_length= strlen(create_info->tablespace);
+  format_section_length=
+    format_section_header_size +
+    tablespace_length + 1 +
+    create_fields.elements;
+  create_info->extra_size+= format_section_length;
+
   if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo,
 		       create_info, keys, key_info)) < 0)
   {
@@ -353,6 +368,55 @@ bool mysql_create_frm(THD *thd, const ch
       goto err;
   }
 
+  /* "Format section" with additional table and column properties */
+  {
+    uchar *ptr, *format_section_buff;
+    if (!(format_section_buff=(uchar*) my_malloc(format_section_length,
+                                                 MYF(MY_WME))))
+      goto err;
+    ptr= format_section_buff;
+
+    /* header */
+    const uint format_section_flags=
+      create_info->storage_media; // 3 bits
+    const uint format_section_unused= 0;
+    int2store(ptr+0, format_section_length);
+    int4store(ptr+2, format_section_flags);
+    int2store(ptr+6, format_section_unused);
+    ptr+= format_section_header_size;
+
+    /* tablespace name */
+    if (tablespace_length > 0)
+      memcpy(ptr, create_info->tablespace, tablespace_length);
+    ptr+= tablespace_length;
+    *ptr= 0; /* tablespace string terminating zero */
+    ptr++;
+
+    /* column properties  */
+    Create_field *field;
+    List_iterator<Create_field> it(create_fields);
+    while ((field=it++))
+    {
+      const uchar field_storage= 0; /* Used in MySQL Cluster */
+      const uchar field_column_format= 0; /* Used in MySQL Cluster */
+      const uchar field_flags=
+        field_storage + (field_column_format << COLUMN_FORMAT_SHIFT);
+      *ptr= field_flags;
+      ptr++;
+    }
+    DBUG_ASSERT(format_section_buff + format_section_length == ptr);
+
+    if (mysql_file_write(file, format_section_buff,
+                         format_section_length, MYF_RW))
+    {
+      my_free(format_section_buff);
+      goto err;
+    }
+    DBUG_PRINT("info", ("wrote format section, length: %u",
+                        format_section_length));
+    my_free(format_section_buff);
+  }
+
   mysql_file_seek(file, filepos, MY_SEEK_SET, MYF(0));
   if (mysql_file_write(file, forminfo, 288, MYF_RW) ||
       mysql_file_write(file, screen_buff, info_length, MYF_RW) ||

=== modified file 'storage/myisam/ft_stopwords.c'
--- a/storage/myisam/ft_stopwords.c	2011-03-22 12:56:15 +0000
+++ b/storage/myisam/ft_stopwords.c	2011-03-29 12:43:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2005 MySQL AB
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
 /* Written by Sergei A. Golubchik, who has a shared copyright to this code */
 
 #include "ftdefs.h"
-#include "my_handler.h"
+#include "my_compare.h"
 
 
 static CHARSET_INFO *ft_stopword_cs= NULL;

=== modified file 'storage/myisam/mi_check.c'
--- a/storage/myisam/mi_check.c	2011-03-22 12:56:15 +0000
+++ b/storage/myisam/mi_check.c	2011-03-29 12:43:49 +0000
@@ -80,6 +80,7 @@ static SORT_KEY_BLOCKS	*alloc_key_blocks
 					  uint buffer_length);
 static ha_checksum mi_byte_checksum(const uchar *buf, uint length);
 static void set_data_file_type(SORT_INFO *sort_info, MYISAM_SHARE *share);
+static HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a);
 
 void myisamchk_init(MI_CHECK *param)
 {
@@ -4729,3 +4730,92 @@ set_data_file_type(SORT_INFO *sort_info,
     share->delete_record=tmp.delete_record;
   }
 }
+
+/*
+  Find the first NULL value in index-suffix values tuple
+
+  SYNOPSIS
+    ha_find_null()
+      keyseg     Array of keyparts for key suffix
+      a          Key suffix value tuple
+
+  DESCRIPTION
+    Find the first NULL value in index-suffix values tuple.
+
+  TODO
+    Consider optimizing this function or its use so we don't search for
+    NULL values in completely NOT NULL index suffixes.
+
+  RETURN
+    First key part that has NULL as value in values tuple, or the last key
+    part (with keyseg->type==HA_TYPE_END) if values tuple doesn't contain
+    NULLs.
+*/
+
+static HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
+{
+  for (; (enum ha_base_keytype) keyseg->type != HA_KEYTYPE_END; keyseg++)
+  {
+    uchar *end;
+    if (keyseg->null_bit)
+    {
+      if (!*a++)
+        return keyseg;
+    }
+    end= a+ keyseg->length;
+
+    switch ((enum ha_base_keytype) keyseg->type) {
+    case HA_KEYTYPE_TEXT:
+    case HA_KEYTYPE_BINARY:
+    case HA_KEYTYPE_BIT:
+      if (keyseg->flag & HA_SPACE_PACK)
+      {
+        int a_length;
+        get_key_length(a_length, a);
+        a += a_length;
+        break;
+      }
+      else
+        a= end;
+      break;
+    case HA_KEYTYPE_VARTEXT1:
+    case HA_KEYTYPE_VARTEXT2:
+    case HA_KEYTYPE_VARBINARY1:
+    case HA_KEYTYPE_VARBINARY2:
+      {
+        int a_length;
+        get_key_length(a_length, a);
+        a+= a_length;
+        break;
+      }
+    case HA_KEYTYPE_NUM:
+      if (keyseg->flag & HA_SPACE_PACK)
+      {
+        int alength= *a++;
+        end= a+alength;
+      }
+      a= end;
+      break;
+    case HA_KEYTYPE_INT8:
+    case HA_KEYTYPE_SHORT_INT:
+    case HA_KEYTYPE_USHORT_INT:
+    case HA_KEYTYPE_LONG_INT:
+    case HA_KEYTYPE_ULONG_INT:
+    case HA_KEYTYPE_INT24:
+    case HA_KEYTYPE_UINT24:
+#ifdef HAVE_LONG_LONG
+    case HA_KEYTYPE_LONGLONG:
+    case HA_KEYTYPE_ULONGLONG:
+#endif
+    case HA_KEYTYPE_FLOAT:
+    case HA_KEYTYPE_DOUBLE:
+      a= end;
+      break;
+    case HA_KEYTYPE_END:                        /* purecov: inspected */
+      /* keep compiler happy */
+      DBUG_ASSERT(0);
+      break;
+    }
+  }
+  return keyseg;
+}

No bundle (reason: revision is a merge).
Thread
bzr commit into mysql-5.5-mtr branch (bjorn.munch:3189) Bjorn Munch31 Mar