List:Commits« Previous MessageNext Message »
From:tomas Date:July 5 2007 1:54pm
Subject:bk commit into 5.1 tree (tomas:1.2538)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-07-05 13:54:04+02:00, tomas@stripped +17 -0
  Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-telco-6.2-merge
  into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-telco-merge
  MERGE: 1.2482.8.56

  BitKeeper/etc/ignore@stripped, 2007-07-05 13:48:32+02:00, tomas@stripped +2
-2
    auto-union
    MERGE: 1.288.1.1

  configure.in@stripped, 2007-07-05 13:54:00+02:00, tomas@stripped +1 -2
    manual merge
    MERGE: 1.459.1.2

  mysql-test/t/disabled.def@stripped, 2007-07-05 13:48:37+02:00,
tomas@stripped +0 -0
    Auto merged
    MERGE: 1.258.1.3

  mysql-test/t/ndb_alter_table.test@stripped, 2007-07-05 13:48:37+02:00,
tomas@stripped +0 -0
    Auto merged
    MERGE: 1.40.1.2

  mysql-test/t/ndb_autodiscover3.test@stripped, 2007-07-05 13:48:38+02:00,
tomas@stripped +0 -0
    Auto merged
    MERGE: 1.13.1.2

  mysql-test/t/ndb_basic.test@stripped, 2007-07-05 13:48:38+02:00,
tomas@stripped +0 -0
    Auto merged
    MERGE: 1.57.1.1

  sql/ha_ndbcluster.cc@stripped, 2007-07-05 13:54:00+02:00, tomas@stripped +2
-3
    manual merge
    MERGE: 1.472.1.8

  sql/ha_ndbcluster.h@stripped, 2007-07-05 13:54:00+02:00, tomas@stripped +0
-0
    manual merge
    MERGE: 1.182.1.4

  sql/ha_ndbcluster_binlog.cc@stripped, 2007-07-05 13:48:38+02:00,
tomas@stripped +0 -0
    Auto merged
    MERGE: 1.120.1.4

  sql/ha_ndbcluster_binlog.h@stripped, 2007-07-05 13:48:38+02:00,
tomas@stripped +0 -0
    Auto merged
    MERGE: 1.27.1.1

  sql/handler.h@stripped, 2007-07-05 13:48:38+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.258.2.2

  sql/log_event.cc@stripped, 2007-07-05 13:48:38+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.278.1.1

  sql/mysqld.cc@stripped, 2007-07-05 13:48:38+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.643.1.3

  sql/set_var.cc@stripped, 2007-07-05 13:48:39+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.233.1.1

  sql/share/errmsg.txt@stripped, 2007-07-05 13:54:00+02:00, tomas@stripped +5
-4
    manual merge
    MERGE: 1.155.1.1

  storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp@stripped, 2007-07-05 13:48:39+02:00,
tomas@stripped +0 -0
    Auto merged
    MERGE: 1.83.1.2

  storage/ndb/test/run-test/daily-basic-tests.txt@stripped, 2007-07-05 13:48:39+02:00,
tomas@stripped +0 -0
    Auto merged
    MERGE: 1.112.1.9

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tomas
# Host:	whalegate.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-telco-merge/RESYNC

--- 1.462/configure.in	2007-07-04 08:19:00 +02:00
+++ 1.463/configure.in	2007-07-05 13:54:00 +02:00
@@ -10,7 +10,7 @@
 #
 # When changing major version number please also check switch statement
 # in mysqlbinlog::check_master_version().
-AM_INIT_AUTOMAKE(mysql, 5.1.19-ndb-6.3.1)
+AM_INIT_AUTOMAKE(mysql, 5.1.21-ndb-6.3.1)
 AM_CONFIG_HEADER(config.h)
 
 NDB_VERSION_MAJOR=6
@@ -235,14 +235,8 @@
 AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf)
 AC_CHECK_PROG(DVIS,      tex,    manual.dvi)
 
-AC_MSG_CHECKING("return type of sprintf")
-
 #check the return type of sprintf
-case $SYSTEM_TYPE in
-  *netware*)
-    AC_DEFINE(SPRINTF_RETURNS_INT, [1]) AC_MSG_RESULT("int")
-    ;;
-  *)
+AC_MSG_CHECKING("return type of sprintf")
 AC_TRY_RUN([
   int main()
     {
@@ -268,10 +262,12 @@
                [AC_DEFINE(SPRINTF_RETURNS_PTR, [1], [Broken sprintf])
                 AC_MSG_RESULT("ptr")],
                [AC_DEFINE(SPRINTF_RETURNS_GARBAGE, [1], [Broken sprintf])
-                AC_MSG_RESULT("garbage")])
-   ])
-    ;;
-esac
+                AC_MSG_RESULT("garbage")]
+   )],
+   # Cross compile, assume POSIX
+   [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf])
+    AC_MSG_RESULT("int (we assume)")]
+)
 
 AC_PATH_PROG(uname_prog, uname, no)
 
@@ -743,6 +739,7 @@
  sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \
  unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \
  sys/ioctl.h malloc.h sys/malloc.h sys/ipc.h sys/shm.h linux/config.h \
+ sys/prctl.h \
  sys/resource.h sys/param.h port.h)
 
 AC_CHECK_HEADERS([xfs/xfs.h])
@@ -770,9 +767,6 @@
 # For the sched_yield() function on Solaris
 AC_CHECK_FUNC(sched_yield, , AC_CHECK_LIB(posix4, sched_yield))
 
-# For the sem_*() functions on BSDish
-AC_CHECK_FUNC(sem_init, , AC_CHECK_LIB(rt, sem_init))
-
 MYSQL_CHECK_ZLIB_WITH_COMPRESS
 
 # For large pages support
@@ -1672,6 +1666,12 @@
     [CLIENT_EXTRA_LDFLAGS=])
 AC_SUBST(CLIENT_EXTRA_LDFLAGS)
 
+AC_ARG_WITH(mysqld-libs,
+    [  --with-mysqld-libs   Extra libraries to link with for mysqld],
+    [MYSQLD_EXTRA_LIBS=$withval],
+    [MYSQLD_EXTRA_LIBS=])
+AC_SUBST(MYSQLD_EXTRA_LIBS)
+
 AC_ARG_WITH(lib-ccflags,
     [  --with-lib-ccflags      Extra CC options for libraries],
     [LIB_EXTRA_CCFLAGS=$withval],
@@ -1789,8 +1789,6 @@
 #---END:
 # Figure out what type of struct rlimit to use with setrlimit
 MYSQL_TYPE_STRUCT_RLIMIT
-# Find where the stack goes
-MYSQL_STACK_DIRECTION
 # We want to skip alloca on irix unconditionally. It may work on some version..
 MYSQL_FUNC_ALLOCA
 # Do struct timespec have members tv_sec or ts_sec
@@ -1871,6 +1869,19 @@
   TERMCAP_LIB="$with_named_curses"
 fi
 AC_SUBST(TERMCAP_LIB)
+
+# Check if the termcap function 'tgoto' is already declared in
+# system header files or if it need to be declared locally
+AC_CHECK_DECLS(tgoto,,,[
+#ifdef HAVE_CURSES_H
+# include <curses.h>
+#elif HAVE_NCURSES_H
+# include <ncurses.h>
+#endif
+#ifdef HAVE_TERM_H
+# include <term.h>
+#endif
+])
 
 LIBEDIT_LOBJECTS=""
 AC_CHECK_FUNC(strunvis, ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS unvis.o"])

--- 1.265/sql/handler.h	2007-06-29 07:51:38 +02:00
+++ 1.266/sql/handler.h	2007-07-05 13:48:38 +02:00
@@ -1713,7 +1713,6 @@
     but we don't have a primary key
   */
   virtual void use_hidden_primary_key();
-
 private:
   /*
     Row-level primitives for storage engines.  These should be

--- 1.280/sql/log_event.cc	2007-06-06 15:59:04 +02:00
+++ 1.281/sql/log_event.cc	2007-07-05 13:48:38 +02:00
@@ -146,12 +146,11 @@
 
 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
 
-static void clear_all_errors(THD *thd, struct st_relay_log_info *rli)
+static void clear_all_errors(THD *thd, RELAY_LOG_INFO *rli)
 {
   thd->query_error = 0;
   thd->clear_error();
-  *rli->last_slave_error = 0;
-  rli->last_slave_errno = 0;
+  rli->clear_error();
 }
 
 
@@ -299,10 +298,10 @@
 
 static bool write_str(IO_CACHE *file, char *str, uint length)
 {
-  byte tmp[1];
-  tmp[0]= (byte) length;
+  uchar tmp[1];
+  tmp[0]= (uchar) length;
   return (my_b_safe_write(file, tmp, sizeof(tmp)) ||
-	  my_b_safe_write(file, (byte*) str, length));
+	  my_b_safe_write(file, (uchar*) str, length));
 }
 
 
@@ -310,8 +309,8 @@
   read_str()
 */
 
-static inline int read_str(const char **buf, const char *buf_end, const char **str,
-			   uint8 *len)
+static inline int read_str(const char **buf, const char *buf_end,
+                           const char **str, uint8 *len)
 {
   if (*buf + ((uint) (uchar) **buf) >= buf_end)
     return 1;
@@ -637,7 +636,7 @@
 
 bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
 {
-  byte header[LOG_EVENT_HEADER_LEN];
+  uchar header[LOG_EVENT_HEADER_LEN];
   DBUG_ENTER("Log_event::write_header");
 
   /* Store number of bytes that will be written by this event */
@@ -724,7 +723,7 @@
 
   if (log_lock)
     pthread_mutex_lock(log_lock);
-  if (my_b_read(file, (byte*) buf, sizeof(buf)))
+  if (my_b_read(file, (uchar*) buf, sizeof(buf)))
   {
     /*
       If the read hits eof, we must report it as eof so the caller
@@ -825,7 +824,7 @@
 
   LOCK_MUTEX;
   DBUG_PRINT("info", ("my_b_tell: %lu", (ulong) my_b_tell(file)));
-  if (my_b_read(file, (byte *) head, header_size))
+  if (my_b_read(file, (uchar *) head, header_size))
   {
     DBUG_PRINT("info", ("Log_event::read_log_event(IO_CACHE*,Format_desc*) \
 failed my_b_read"));
@@ -859,14 +858,14 @@
   }
 
   // some events use the extra byte to null-terminate strings
-  if (!(buf = my_malloc(data_len+1, MYF(MY_WME))))
+  if (!(buf = (char*) my_malloc(data_len+1, MYF(MY_WME))))
   {
     error = "Out of memory";
     goto err;
   }
   buf[data_len] = 0;
   memcpy(buf, head, header_size);
-  if (my_b_read(file, (byte*) buf + header_size, data_len - header_size))
+  if (my_b_read(file, (uchar*) buf + header_size, data_len - header_size))
   {
     error = "read error";
     goto err;
@@ -911,16 +910,15 @@
   DBUG_ENTER("Log_event::read_log_event(char*,...)");
   DBUG_ASSERT(description_event != 0);
   DBUG_PRINT("info", ("binlog_version: %d", description_event->binlog_version));
+  /* Check the integrity */
   if (event_len < EVENT_LEN_OFFSET ||
+      buf[EVENT_TYPE_OFFSET] >= ENUM_END_EVENT ||
       (uint) event_len != uint4korr(buf+EVENT_LEN_OFFSET))
   {
     *error="Sanity check failed";		// Needed to free buffer
     DBUG_RETURN(NULL); // general sanity check - will fail on a partial read
   }
 
-  /* To check the integrity of the Log_event_type enumeration */
-  DBUG_ASSERT(buf[EVENT_TYPE_OFFSET] < ENUM_END_EVENT);
-
   switch(buf[EVENT_TYPE_OFFSET]) {
   case QUERY_EVENT:
     ev  = new Query_log_event(buf, event_len, description_event, QUERY_EVENT);
@@ -1092,8 +1090,8 @@
                     ptr[7], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13],
                     ptr[14], ptr[15], ptr[16], ptr[17], ptr[18]);
       DBUG_ASSERT(bytes_written >= 0);
-      DBUG_ASSERT(static_cast<my_size_t>(bytes_written) < sizeof(emit_buf));
-      my_b_write(file, (byte*) emit_buf, bytes_written);
+      DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
+      my_b_write(file, (uchar*) emit_buf, bytes_written);
       ptr += LOG_EVENT_MINIMAL_HEADER_LEN;
       hexdump_from += LOG_EVENT_MINIMAL_HEADER_LEN;
     }
@@ -1123,8 +1121,8 @@
                       (unsigned long) (hexdump_from + (i & 0xfffffff0)),
                       hex_string, char_string);
         DBUG_ASSERT(bytes_written >= 0);
-        DBUG_ASSERT(static_cast<my_size_t>(bytes_written) < sizeof(emit_buf));
-	my_b_write(file, (byte*) emit_buf, bytes_written);
+        DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
+	my_b_write(file, (uchar*) emit_buf, bytes_written);
 	hex_string[0]= 0;
 	char_string[0]= 0;
 	c= char_string;
@@ -1134,7 +1132,6 @@
     }
     *c= '\0';
 
-    /* Non-full last line */
     if (hex_string[0])
     {
       char emit_buf[256];
@@ -1144,14 +1141,14 @@
                     (unsigned long) (hexdump_from + (i & 0xfffffff0)),
                     hex_string, char_string);
       DBUG_ASSERT(bytes_written >= 0);
-      DBUG_ASSERT(static_cast<my_size_t>(bytes_written) < sizeof(emit_buf));
-      my_b_write(file, (byte*) emit_buf, bytes_written);
+      DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
+      my_b_write(file, (uchar*) emit_buf, bytes_written);
     }
     /*
       need a # to prefix the rest of printouts for example those of
       Rows_log_event::print_helper().
     */
-    my_b_write(file, reinterpret_cast<const byte*>("# "), 2);
+    my_b_write(file, reinterpret_cast<const uchar*>("# "), 2);
   }
   DBUG_VOID_RETURN;
 }
@@ -1239,7 +1236,7 @@
 {
   // TODO: show the catalog ??
   char *buf, *pos;
-  if (!(buf= my_malloc(9 + db_len + q_len, MYF(MY_WME))))
+  if (!(buf= (char*) my_malloc(9 + db_len + q_len, MYF(MY_WME))))
     return;
   pos= buf;
   if (!(flags & LOG_EVENT_SUPPRESS_USE_F)
@@ -1440,12 +1437,12 @@
   event_length= (uint) (start-buf) + get_post_header_size_for_derived() + db_len + 1 +
q_len;
 
   return (write_header(file, event_length) ||
-          my_b_safe_write(file, (byte*) buf, QUERY_HEADER_LEN) ||
+          my_b_safe_write(file, (uchar*) buf, QUERY_HEADER_LEN) ||
           write_post_header_for_derived(file) ||
-          my_b_safe_write(file, (byte*) start_of_status,
+          my_b_safe_write(file, (uchar*) start_of_status,
                           (uint) (start-start_of_status)) ||
-          my_b_safe_write(file, (db) ? (byte*) db : (byte*)"", db_len + 1) ||
-          my_b_safe_write(file, (byte*) query, q_len)) ? 1 : 0;
+          my_b_safe_write(file, (db) ? (uchar*) db : (uchar*)"", db_len + 1) ||
+          my_b_safe_write(file, (uchar*) query, q_len)) ? 1 : 0;
 }
 
 /*
@@ -1462,20 +1459,31 @@
 
 
 /*
-  Query_log_event::Query_log_event()
+  SYNOPSIS
+    Query_log_event::Query_log_event()
+      thd               - thread handle
+      query_arg         - array of char representing the query
+      query_length      - size of the  `query_arg' array
+      using_trans       - there is a modified transactional table
+      suppress_use      - suppress the generation of 'USE' statements
+      killed_status_arg - an optional with default to THD::KILLED_NO_VALUE
+                          if the value is different from the default, the arg
+                          is set to the current thd->killed value.
+                          A caller might need to masquerade thd->killed with
+                          THD::NOT_KILLED.
+  DESCRIPTION
+  Creates an event for binlogging
+  The value for local `killed_status' can be supplied by caller.
 */
 Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
 				 ulong query_length, bool using_trans,
-				 bool suppress_use)
+				 bool suppress_use, THD::killed_state killed_status_arg)
   :Log_event(thd_arg,
 	     ((thd_arg->tmp_table_used ? LOG_EVENT_THREAD_SPECIFIC_F : 0)
 	      | (suppress_use          ? LOG_EVENT_SUPPRESS_USE_F    : 0)),
 	     using_trans),
    data_buf(0), query(query_arg), catalog(thd_arg->catalog),
    db(thd_arg->db), q_len((uint32) query_length),
-   error_code((thd_arg->killed != THD::NOT_KILLED) ?
-              ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ?
-               0 : thd->killed_errno()) : thd_arg->net.last_errno),
    thread_id(thd_arg->thread_id),
    /* save the original thread id; we already know the server id */
    slave_proxy_id(thd_arg->variables.pseudo_thread_id),
@@ -1487,6 +1495,14 @@
    charset_database_number(0)
 {
   time_t end_time;
+
+  if (killed_status_arg == THD::KILLED_NO_VALUE)
+    killed_status_arg= thd_arg->killed;
+  error_code=
+    (killed_status_arg == THD::NOT_KILLED) ? thd_arg->net.last_errno :
+    ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 :
+     thd->killed_errno());
+  
   time(&end_time);
   exec_time = (ulong) (end_time  - thd->start_time);
   catalog_len = (catalog) ? (uint32) strlen(catalog) : 0;
@@ -1559,7 +1575,8 @@
 */
 
 Query_log_event::Query_log_event(const char* buf, uint event_len,
-                                 const Format_description_log_event *description_event,
+                                 const Format_description_log_event
+                                 *description_event,
                                  Log_event_type event_type)
   :Log_event(buf, description_event), data_buf(0), query(NullS),
    db(NullS), catalog_len(0), status_vars_len(0),
@@ -1752,7 +1769,7 @@
   end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
   end= strmov(end, print_event_info->delimiter);
   *end++='\n';
-  my_b_write(file, (byte*) buff, (uint) (end-buff));
+  my_b_write(file, (uchar*) buff, (uint) (end-buff));
   if (flags & LOG_EVENT_THREAD_SPECIFIC_F)
     my_b_printf(file,"SET @@session.pseudo_thread_id=%lu%s\n",
                 (ulong)thread_id, print_event_info->delimiter);
@@ -1836,7 +1853,7 @@
       print_event_info->charset_inited= 1;
       print_event_info->charset[0]= ~charset[0]; // force a difference to force write
     }
-    if (unlikely(bcmp(print_event_info->charset, charset, 6)))
+    if (unlikely(bcmp((uchar*) print_event_info->charset, (uchar*) charset, 6)))
     {
       CHARSET_INFO *cs_info= get_charset(uint2korr(charset), MYF(MY_WME));
       if (cs_info)
@@ -1859,7 +1876,8 @@
   }
   if (time_zone_len)
   {
-    if (bcmp(print_event_info->time_zone_str, time_zone_str, time_zone_len+1))
+    if (bcmp((uchar*) print_event_info->time_zone_str,
+             (uchar*) time_zone_str, time_zone_len+1))
     {
       my_b_printf(file,"SET @@session.time_zone='%s'%s\n",
                   time_zone_str, print_event_info->delimiter);
@@ -1890,7 +1908,7 @@
   Write_on_release_cache cache(&print_event_info->head_cache, file);
 
   print_query_header(&cache, print_event_info);
-  my_b_write(&cache, (byte*) query, q_len);
+  my_b_write(&cache, (uchar*) query, q_len);
   my_b_printf(&cache, "%s\n", print_event_info->delimiter);
 }
 #endif /* MYSQL_CLIENT */
@@ -2070,7 +2088,7 @@
         clear_all_errors(thd, const_cast<RELAY_LOG_INFO*>(rli)); /* Can ignore
query */
       else
       {
-        slave_print_msg(ERROR_LEVEL, rli, expected_error, 
+        rli->report(ERROR_LEVEL, expected_error, 
                           "\
 Query partially completed on the master (error on master: %d) \
 and was aborted. There is a chance that your master is inconsistent at this \
@@ -2099,7 +2117,7 @@
  	!ignored_error_code(actual_error) &&
  	!ignored_error_code(expected_error))
     {
-      slave_print_msg(ERROR_LEVEL, rli, 0,
+      rli->report(ERROR_LEVEL, 0,
                       "\
 Query caused different errors on master and slave.     \
 Error on master: '%s' (%d), Error on slave: '%s' (%d). \
@@ -2119,13 +2137,14 @@
     {
       DBUG_PRINT("info",("error ignored"));
       clear_all_errors(thd, const_cast<RELAY_LOG_INFO*>(rli));
+      thd->killed= THD::NOT_KILLED;
     }
     /*
       Other cases: mostly we expected no error and get one.
     */
     else if (thd->query_error || thd->is_fatal_error)
     {
-      slave_print_msg(ERROR_LEVEL, rli, actual_error,
+      rli->report(ERROR_LEVEL, actual_error,
                       "Error '%s' on query. Default database: '%s'. Query: '%s'",
                       (actual_error ? thd->net.last_error :
                        "unexpected success or fatal error"),
@@ -2327,7 +2346,7 @@
   memcpy(buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
   int4store(buff + ST_CREATED_OFFSET,created);
   return (write_header(file, sizeof(buff)) ||
-          my_b_safe_write(file, (byte*) buff, sizeof(buff)));
+          my_b_safe_write(file, (uchar*) buff, sizeof(buff)));
 }
 #endif
 
@@ -2562,7 +2581,7 @@
   DBUG_PRINT("info", ("common_header_len=%d number_of_event_types=%d",
                       common_header_len, number_of_event_types));
   /* If alloc fails, we'll detect it in is_valid() */
-  post_header_len= (uint8*) my_memdup((byte*)buf+ST_COMMON_HEADER_LEN_OFFSET+1,
+  post_header_len= (uint8*) my_memdup((uchar*)buf+ST_COMMON_HEADER_LEN_OFFSET+1,
                                       number_of_event_types*
                                       sizeof(*post_header_len), MYF(0));
   calc_server_version_split();
@@ -2576,12 +2595,12 @@
     We don't call Start_log_event_v3::write() because this would make 2
     my_b_safe_write().
   */
-  byte buff[FORMAT_DESCRIPTION_HEADER_LEN];
+  uchar buff[FORMAT_DESCRIPTION_HEADER_LEN];
   int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
   memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
   int4store(buff + ST_CREATED_OFFSET,created);
   buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN;
-  memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (byte*) post_header_len,
+  memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (uchar*) post_header_len,
          LOG_EVENT_TYPES);
   return (write_header(file, sizeof(buff)) ||
           my_b_safe_write(file, buff, sizeof(buff)));
@@ -2608,11 +2627,11 @@
   if (!artificial_event && created && thd->transaction.all.nht)
   {
     /* This is not an error (XA is safe), just an information */
-    slave_print_msg(INFORMATION_LEVEL, rli, 0,
-                    "Rolling back unfinished transaction (no COMMIT "
-                    "or ROLLBACK in relay log). A probable cause is that "
-                    "the master died while writing the transaction to "
-                    "its binary log, thus rolled back too."); 
+    rli->report(INFORMATION_LEVEL, 0,
+                "Rolling back unfinished transaction (no COMMIT "
+                "or ROLLBACK in relay log). A probable cause is that "
+                "the master died while writing the transaction to "
+                "its binary log, thus rolled back too."); 
     const_cast<RELAY_LOG_INFO*>(rli)->cleanup_context(thd, 1);
   }
 #endif
@@ -2836,7 +2855,7 @@
 {
   char *buf, *end;
 
-  if (!(buf= my_malloc(get_query_buffer_length(), MYF(MY_WME))))
+  if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME))))
     return;
   print_query(TRUE, buf, &end, 0, 0);
   protocol->store(buf, end-buf, &my_charset_bin);
@@ -2860,7 +2879,7 @@
   buf[L_TBL_LEN_OFFSET] = (char)table_name_len;
   buf[L_DB_LEN_OFFSET] = (char)db_len;
   int4store(buf + L_NUM_FIELDS_OFFSET, num_fields);
-  return my_b_safe_write(file, (byte*)buf, LOAD_HEADER_LEN) != 0;
+  return my_b_safe_write(file, (uchar*)buf, LOAD_HEADER_LEN) != 0;
 }
 
 
@@ -2874,13 +2893,13 @@
     return 1;
   if (num_fields && fields && field_lens)
   {
-    if (my_b_safe_write(file, (byte*)field_lens, num_fields) ||
-	my_b_safe_write(file, (byte*)fields, field_block_len))
+    if (my_b_safe_write(file, (uchar*)field_lens, num_fields) ||
+	my_b_safe_write(file, (uchar*)fields, field_block_len))
       return 1;
   }
-  return (my_b_safe_write(file, (byte*)table_name, table_name_len + 1) ||
-	  my_b_safe_write(file, (byte*)db, db_len + 1) ||
-	  my_b_safe_write(file, (byte*)fname, fname_len));
+  return (my_b_safe_write(file, (uchar*)table_name, table_name_len + 1) ||
+	  my_b_safe_write(file, (uchar*)db, db_len + 1) ||
+	  my_b_safe_write(file, (uchar*)fname, fname_len));
 }
 
 
@@ -3430,6 +3449,10 @@
   thd->query_length= 0;
   VOID(pthread_mutex_unlock(&LOCK_thread_count));
   close_thread_tables(thd);
+
+  DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error",
+                  thd->query_error= 0; thd->is_fatal_error= 1;);
+
   if (thd->query_error)
   {
     /* this err/sql_errno code is copy-paste from net_send_error() */
@@ -3442,19 +3465,25 @@
       sql_errno=ER_UNKNOWN_ERROR;
       err=ER(sql_errno);       
     }
-    slave_print_msg(ERROR_LEVEL, rli, sql_errno,"\
+    rli->report(ERROR_LEVEL, sql_errno,"\
 Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'",
                     err, (char*)table_name, print_slave_db_safe(remember_db));
     free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
     return 1;
   }
   free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
-	    
+
   if (thd->is_fatal_error)
   {
-    slave_print_msg(ERROR_LEVEL, rli, ER_UNKNOWN_ERROR, "\
-Fatal error running LOAD DATA INFILE on table '%s'. Default database: '%s'",
-                    (char*)table_name, print_slave_db_safe(remember_db));
+    char buf[256];
+    my_snprintf(buf, sizeof(buf),
+                "Running LOAD DATA INFILE on table '%-.64s'."
+                " Default database: '%-.64s'",
+                (char*)table_name,
+                print_slave_db_safe(remember_db));
+
+    rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+                ER(ER_SLAVE_FATAL_ERROR), buf);
     return 1;
   }
 
@@ -3501,7 +3530,7 @@
   print_header(&cache, print_event_info, FALSE);
   my_b_printf(&cache, "\tRotate to ");
   if (new_log_ident)
-    my_b_write(&cache, (byte*) new_log_ident, (uint)ident_len);
+    my_b_write(&cache, (uchar*) new_log_ident, (uint)ident_len);
   my_b_printf(&cache, "  pos: %s\n", llstr(pos, buf));
 }
 #endif /* MYSQL_CLIENT */
@@ -3567,8 +3596,8 @@
   char buf[ROTATE_HEADER_LEN];
   int8store(buf + R_POS_OFFSET, pos);
   return (write_header(file, ROTATE_HEADER_LEN + ident_len) ||
-          my_b_safe_write(file, (byte*)buf, ROTATE_HEADER_LEN) ||
-          my_b_safe_write(file, (byte*)new_log_ident, (uint) ident_len));
+          my_b_safe_write(file, (uchar*)buf, ROTATE_HEADER_LEN) ||
+          my_b_safe_write(file, (uchar*)new_log_ident, (uint) ident_len));
 }
 #endif
 
@@ -3735,8 +3764,8 @@
 #ifndef MYSQL_CLIENT
 bool Intvar_log_event::write(IO_CACHE* file)
 {
-  byte buf[9];
-  buf[I_TYPE_OFFSET]= (byte) type;
+  uchar buf[9];
+  buf[I_TYPE_OFFSET]= (uchar) type;
   int8store(buf + I_VAL_OFFSET, val);
   return (write_header(file, sizeof(buf)) ||
           my_b_safe_write(file, buf, sizeof(buf)));
@@ -3864,7 +3893,7 @@
 #ifndef MYSQL_CLIENT
 bool Rand_log_event::write(IO_CACHE* file)
 {
-  byte buf[16];
+  uchar buf[16];
   int8store(buf + RAND_SEED1_OFFSET, seed1);
   int8store(buf + RAND_SEED2_OFFSET, seed2);
   return (write_header(file, sizeof(buf)) ||
@@ -3971,7 +4000,7 @@
 bool Xid_log_event::write(IO_CACHE* file)
 {
   return write_header(file, sizeof(xid)) ||
-         my_b_safe_write(file, (byte*) &xid, sizeof(xid));
+         my_b_safe_write(file, (uchar*) &xid, sizeof(xid));
 }
 #endif
 
@@ -4019,7 +4048,8 @@
 
   if (is_null)
   {
-    buf= my_malloc(val_offset + 5, MYF(MY_WME));
+    if (!(buf= (char*) my_malloc(val_offset + 5, MYF(MY_WME))))
+      return;
     strmov(buf + val_offset, "NULL");
     event_len= val_offset + 4;
   }
@@ -4029,28 +4059,37 @@
     case REAL_RESULT:
       double real_val;
       float8get(real_val, val);
-      buf= my_malloc(val_offset + FLOATING_POINT_BUFFER, MYF(MY_WME));
+      if (!(buf= (char*) my_malloc(val_offset + FLOATING_POINT_BUFFER,
+                                   MYF(MY_WME))))
+        return;
       event_len+= my_sprintf(buf + val_offset,
 			     (buf + val_offset, "%.14g", real_val));
       break;
     case INT_RESULT:
-      buf= my_malloc(val_offset + 22, MYF(MY_WME));
+      if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
+        return;
       event_len= longlong10_to_str(uint8korr(val), buf + val_offset,-10)-buf;
       break;
     case DECIMAL_RESULT:
     {
-      buf= my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH, MYF(MY_WME));
+      if (!(buf= (char*) my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH,
+                                   MYF(MY_WME))))
+        return;
       String str(buf+val_offset, DECIMAL_MAX_STR_LENGTH, &my_charset_bin);
       my_decimal dec;
-      binary2my_decimal(E_DEC_FATAL_ERROR, val+2, &dec, val[0], val[1]);
+      binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) (val+2), &dec, val[0],
+                        val[1]);
       my_decimal2string(E_DEC_FATAL_ERROR, &dec, 0, 0, 0, &str);
       event_len= str.length() + val_offset;
       break;
     } 
     case STRING_RESULT:
       /* 15 is for 'COLLATE' and other chars */
-      buf= my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15, MYF(MY_WME));
+      buf= (char*) my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15,
+                             MYF(MY_WME));
       CHARSET_INFO *cs;
+      if (!buf)
+        return;
       if (!(cs= get_charset(charset_number, MYF(0))))
       {
         strmov(buf+val_offset, "???");
@@ -4072,11 +4111,11 @@
   }
   buf[0]= '@';
   buf[1]= '`';
+  memcpy(buf+2, name, name_len);
   buf[2+name_len]= '`';
   buf[3+name_len]= '=';
-  memcpy(buf+2, name, name_len);
   protocol->store(buf, event_len, &my_charset_bin);
-  my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+  my_free(buf, MYF(0));
 }
 #endif /* !MYSQL_CLIENT */
 
@@ -4116,7 +4155,7 @@
   char buf[UV_NAME_LEN_SIZE];
   char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE + 
 	    UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-  char buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
+  uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
   uint buf1_length;
   ulong event_length;
 
@@ -4125,7 +4164,7 @@
   if ((buf1[0]= is_null))
   {
     buf1_length= 1;
-    val_len= 0;
+    val_len= 0;                                 // Length of 'pos'
   }    
   else
   {
@@ -4150,7 +4189,7 @@
       break;
     }
     case STRING_RESULT:
-      pos= val;
+      pos= (uchar*) val;
       break;
     case ROW_RESULT:
     default:
@@ -4165,10 +4204,10 @@
   event_length= sizeof(buf)+ name_len + buf1_length + val_len;
 
   return (write_header(file, event_length) ||
-          my_b_safe_write(file, (byte*) buf, sizeof(buf))   ||
-	  my_b_safe_write(file, (byte*) name, name_len)     ||
-	  my_b_safe_write(file, (byte*) buf1, buf1_length) ||
-	  my_b_safe_write(file, (byte*) pos, val_len));
+          my_b_safe_write(file, (uchar*) buf, sizeof(buf))   ||
+	  my_b_safe_write(file, (uchar*) name, name_len)     ||
+	  my_b_safe_write(file, (uchar*) buf1, buf1_length) ||
+	  my_b_safe_write(file, pos, val_len));
 }
 #endif
 
@@ -4190,7 +4229,7 @@
   }
 
   my_b_printf(&cache, "SET @`");
-  my_b_write(&cache, (byte*) name, (uint) (name_len));
+  my_b_write(&cache, (uchar*) name, (uint) (name_len));
   my_b_printf(&cache, "`");
 
   if (is_null)
@@ -4221,7 +4260,7 @@
       dec.len= 10;
       dec.buf= dec_buf;
 
-      bin2decimal(val+2, &dec, precision, scale);
+      bin2decimal((uchar*) val+2, &dec, precision, scale);
       decimal2string(&dec, str_buf, &str_len, 0, 0, 0);
       str_buf[str_len]= 0;
       my_b_printf(&cache, ":=%s%s\n", str_buf, print_event_info->delimiter);
@@ -4322,7 +4361,7 @@
       break;
     case DECIMAL_RESULT:
     {
-      Item_decimal *dec= new Item_decimal(val+2, val[0], val[1]);
+      Item_decimal *dec= new Item_decimal((uchar*) val+2, val[0], val[1]);
       it= dec;
       val= (char *)dec->val_decimal(NULL);
       val_len= sizeof(my_decimal);
@@ -4487,7 +4526,7 @@
   // log and host are already there
 
   return (write_header(file, event_length) ||
-          my_b_safe_write(file, (byte*) mem_pool, event_length));
+          my_b_safe_write(file, (uchar*) mem_pool, event_length));
 }
 #endif
 
@@ -4630,8 +4669,8 @@
   bool res;
   if ((res= Load_log_event::write_data_body(file)) || fake_base)
     return res;
-  return (my_b_safe_write(file, (byte*) "", 1) ||
-          my_b_safe_write(file, (byte*) block, block_len));
+  return (my_b_safe_write(file, (uchar*) "", 1) ||
+          my_b_safe_write(file, (uchar*) block, block_len));
 }
 
 
@@ -4642,7 +4681,7 @@
 bool Create_file_log_event::write_data_header(IO_CACHE* file)
 {
   bool res;
-  byte buf[CREATE_FILE_HEADER_LEN];
+  uchar buf[CREATE_FILE_HEADER_LEN];
   if ((res= Load_log_event::write_data_header(file)) || fake_base)
     return res;
   int4store(buf + CF_FILE_ID_OFFSET, file_id);
@@ -4678,7 +4717,7 @@
   uint header_len= description_event->common_header_len;
   uint8 load_header_len= description_event->post_header_len[LOAD_EVENT-1];
   uint8 create_file_header_len=
description_event->post_header_len[CREATE_FILE_EVENT-1];
-  if (!(event_buf= my_memdup((byte*) buf, len, MYF(MY_WME))) ||
+  if (!(event_buf= (char*) my_memdup(buf, len, MYF(MY_WME))) ||
       copy_log_event(event_buf,len,
                      ((buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ?
                       load_header_len + header_len :
@@ -4804,8 +4843,9 @@
       init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0,
 		    MYF(MY_WME|MY_NABP)))
   {
-    slave_print_msg(ERROR_LEVEL, rli, my_errno, "Error in Create_file event: "
-                    "could not open file '%s'", fname_buf);
+    rli->report(ERROR_LEVEL, my_errno,
+                "Error in Create_file event: could not open file '%s'",
+                fname_buf);
     goto err;
   }
   
@@ -4815,9 +4855,9 @@
   if (write_base(&file))
   {
     strmov(ext, ".info"); // to have it right in the error message
-    slave_print_msg(ERROR_LEVEL, rli, my_errno,
-                    "Error in Create_file event: could not write to file '%s'",
-                    fname_buf);
+    rli->report(ERROR_LEVEL, my_errno,
+                "Error in Create_file event: could not write to file '%s'",
+                fname_buf);
     goto err;
   }
   end_io_cache(&file);
@@ -4829,14 +4869,16 @@
 		     O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
 		     MYF(MY_WME))) < 0)
   {
-    slave_print_msg(ERROR_LEVEL, rli, my_errno, "Error in Create_file event: "
-                    "could not open file '%s'", fname_buf);
+    rli->report(ERROR_LEVEL, my_errno,
+                "Error in Create_file event: could not open file '%s'",
+                fname_buf);
     goto err;
   }
-  if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP)))
+  if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP)))
   {
-    slave_print_msg(ERROR_LEVEL, rli, my_errno, "Error in Create_file event: "
-                    "write to '%s' failed", fname_buf);
+    rli->report(ERROR_LEVEL, my_errno,
+                "Error in Create_file event: write to '%s' failed",
+                fname_buf);
     goto err;
   }
   error=0;					// Everything is ok
@@ -4901,11 +4943,11 @@
 #ifndef MYSQL_CLIENT
 bool Append_block_log_event::write(IO_CACHE* file)
 {
-  byte buf[APPEND_BLOCK_HEADER_LEN];
+  uchar buf[APPEND_BLOCK_HEADER_LEN];
   int4store(buf + AB_FILE_ID_OFFSET, file_id);
   return (write_header(file, APPEND_BLOCK_HEADER_LEN + block_len) ||
           my_b_safe_write(file, buf, APPEND_BLOCK_HEADER_LEN) ||
-	  my_b_safe_write(file, (byte*) block, block_len));
+	  my_b_safe_write(file, (uchar*) block, block_len));
 }
 #endif
 
@@ -4975,25 +5017,25 @@
 		       O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
 		       MYF(MY_WME))) < 0)
     {
-      slave_print_msg(ERROR_LEVEL, rli, my_errno,
-                      "Error in %s event: could not create file '%s'",
-                      get_type_str(), fname);
+      rli->report(ERROR_LEVEL, my_errno,
+                  "Error in %s event: could not create file '%s'",
+                  get_type_str(), fname);
       goto err;
     }
   }
   else if ((fd = my_open(fname, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW,
                          MYF(MY_WME))) < 0)
   {
-    slave_print_msg(ERROR_LEVEL, rli, my_errno,
-                    "Error in %s event: could not open file '%s'",
-                    get_type_str(), fname);
+    rli->report(ERROR_LEVEL, my_errno,
+                "Error in %s event: could not open file '%s'",
+                get_type_str(), fname);
     goto err;
   }
-  if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP)))
+  if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP)))
   {
-    slave_print_msg(ERROR_LEVEL, rli, my_errno,
-                    "Error in %s event: write to '%s' failed",
-                    get_type_str(), fname);
+    rli->report(ERROR_LEVEL, my_errno,
+                "Error in %s event: write to '%s' failed",
+                get_type_str(), fname);
     goto err;
   }
   error=0;
@@ -5046,7 +5088,7 @@
 #ifndef MYSQL_CLIENT
 bool Delete_file_log_event::write(IO_CACHE* file)
 {
- byte buf[DELETE_FILE_HEADER_LEN];
+ uchar buf[DELETE_FILE_HEADER_LEN];
  int4store(buf + DF_FILE_ID_OFFSET, file_id);
  return (write_header(file, sizeof(buf)) ||
          my_b_safe_write(file, buf, sizeof(buf)));
@@ -5142,7 +5184,7 @@
 #ifndef MYSQL_CLIENT
 bool Execute_load_log_event::write(IO_CACHE* file)
 {
-  byte buf[EXEC_LOAD_HEADER_LEN];
+  uchar buf[EXEC_LOAD_HEADER_LEN];
   int4store(buf + EL_FILE_ID_OFFSET, file_id);
   return (write_header(file, sizeof(buf)) || 
           my_b_safe_write(file, buf, sizeof(buf)));
@@ -5201,8 +5243,9 @@
       init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0,
 		    MYF(MY_WME|MY_NABP)))
   {
-    slave_print_msg(ERROR_LEVEL, rli, my_errno, "Error in Exec_load event: "
-                    "could not open file '%s'", fname);
+    rli->report(ERROR_LEVEL, my_errno,
+                "Error in Exec_load event: could not open file '%s'",
+                fname);
     goto err;
   }
   if (!(lev = (Load_log_event*)Log_event::read_log_event(&file,
@@ -5210,7 +5253,7 @@
                                                         
rli->relay_log.description_event_for_exec)) ||
       lev->get_type_code() != NEW_LOAD_EVENT)
   {
-    slave_print_msg(ERROR_LEVEL, rli, 0, "Error in Exec_load event: "
+    rli->report(ERROR_LEVEL, 0, "Error in Exec_load event: "
                     "file '%s' appears corrupted", fname);
     goto err;
   }
@@ -5235,13 +5278,11 @@
       don't want to overwrite it with the filename.
       What we want instead is add the filename to the current error message.
     */
-    char *tmp= my_strdup(rli->last_slave_error,MYF(MY_WME));
+    char *tmp= my_strdup(rli->last_error().message, MYF(MY_WME));
     if (tmp)
     {
-      slave_print_msg(ERROR_LEVEL, rli,
-                      rli->last_slave_errno, /* ok to re-use error code */
-                      "%s. Failed executing load from '%s'", 
-                      tmp, fname);
+      rli->report(ERROR_LEVEL, rli->last_error().number,
+                  "%s. Failed executing load from '%s'", tmp, fname);
       my_free(tmp,MYF(0));
     }
     goto err;
@@ -5360,12 +5401,12 @@
 bool
 Execute_load_query_log_event::write_post_header_for_derived(IO_CACHE* file)
 {
-  char buf[EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN];
+  uchar buf[EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN];
   int4store(buf, file_id);
   int4store(buf + 4, fn_pos_start);
   int4store(buf + 4 + 4, fn_pos_end);
-  *(buf + 4 + 4 + 4)= (char)dup_handling;
-  return my_b_safe_write(file, (byte*) buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
+  *(buf + 4 + 4 + 4)= (uchar) dup_handling;
+  return my_b_safe_write(file, buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
 }
 #endif
 
@@ -5388,19 +5429,19 @@
 
   if (local_fname)
   {
-    my_b_write(&cache, (byte*) query, fn_pos_start);
+    my_b_write(&cache, (uchar*) query, fn_pos_start);
     my_b_printf(&cache, " LOCAL INFILE \'");
     my_b_printf(&cache, local_fname);
     my_b_printf(&cache, "\'");
     if (dup_handling == LOAD_DUP_REPLACE)
       my_b_printf(&cache, " REPLACE");
     my_b_printf(&cache, " INTO");
-    my_b_write(&cache, (byte*) query + fn_pos_end, q_len-fn_pos_end);
+    my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end);
     my_b_printf(&cache, "%s\n", print_event_info->delimiter);
   }
   else
   {
-    my_b_write(&cache, (byte*) query, q_len);
+    my_b_write(&cache, (uchar*) query, q_len);
     my_b_printf(&cache, "%s\n", print_event_info->delimiter);
   }
 
@@ -5414,7 +5455,7 @@
 void Execute_load_query_log_event::pack_info(Protocol *protocol)
 {
   char *buf, *pos;
-  if (!(buf= my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
+  if (!(buf= (char*) my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
     return;
   pos= buf;
   if (db && db_len)
@@ -5444,11 +5485,16 @@
   char *fname_end;
   int error;
 
+  buf= (char*) my_malloc(q_len + 1 - (fn_pos_end - fn_pos_start) +
+                         (FN_REFLEN + 10) + 10 + 8 + 5, MYF(MY_WME));
+
+  DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error", my_free(buf, MYF(0)); buf= NULL;);
+
   /* Replace filename and LOCAL keyword in query before executing it */
-  if (!(buf = my_malloc(q_len + 1 - (fn_pos_end - fn_pos_start) +
-                        (FN_REFLEN + 10) + 10 + 8 + 5, MYF(MY_WME))))
+  if (buf == NULL)
   {
-    slave_print_msg(ERROR_LEVEL, rli, my_errno, "Not enough memory");
+    rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+                ER(ER_SLAVE_FATAL_ERROR), "Not enough memory");
     return 1;
   }
 
@@ -5508,7 +5554,7 @@
 	    write_str(file, line_term,  (uint) line_term_len) ||
 	    write_str(file, line_start, (uint) line_start_len) ||
 	    write_str(file, escaped,    (uint) escaped_len) ||
-	    my_b_safe_write(file,(byte*) &opt_flags,1));
+	    my_b_safe_write(file,(uchar*) &opt_flags,1));
   }
   else
   {
@@ -5520,7 +5566,7 @@
     old_ex.escaped=    *escaped;
     old_ex.opt_flags=  opt_flags;
     old_ex.empty_flags=empty_flags;
-    return my_b_safe_write(file, (byte*) &old_ex, sizeof(old_ex)) != 0;
+    return my_b_safe_write(file, (uchar*) &old_ex, sizeof(old_ex)) != 0;
   }
 }
 
@@ -5655,9 +5701,9 @@
 
   m_flags= uint2korr(post_start);
 
-  byte const *const var_start=
-    (const byte *)buf + common_header_len + post_header_len;
-  byte const *const ptr_width= var_start;
+  uchar const *const var_start=
+    (const uchar *)buf + common_header_len + post_header_len;
+  uchar const *const ptr_width= var_start;
   uchar *ptr_after_width= (uchar*) ptr_width;
   DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
   m_width = net_field_length(&ptr_after_width);
@@ -5671,7 +5717,7 @@
     DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
     memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8);
     ptr_after_width+= (m_width + 7) / 8;
-    DBUG_DUMP("m_cols", (char*) m_cols.bitmap, no_bytes_in_map(&m_cols));
+    DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols));
   }
   else
   {
@@ -5695,7 +5741,8 @@
       DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
       memcpy(m_cols_ai.bitmap, ptr_after_width, (m_width + 7) / 8);
       ptr_after_width+= (m_width + 7) / 8;
-      DBUG_DUMP("m_cols_ai", (char*) m_cols_ai.bitmap, no_bytes_in_map(&m_cols_ai));
+      DBUG_DUMP("m_cols_ai", (uchar*) m_cols_ai.bitmap,
+                no_bytes_in_map(&m_cols_ai));
     }
     else
     {
@@ -5705,13 +5752,13 @@
     }
   }
 
-  const byte* const ptr_rows_data= (const byte*) ptr_after_width;
+  const uchar* const ptr_rows_data= (const uchar*) ptr_after_width;
 
-  my_size_t const data_size= event_len - (ptr_rows_data - (const byte *) buf);
+  size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf);
   DBUG_PRINT("info",("m_table_id: %lu  m_flags: %d  m_width: %lu  data_size: %lu",
-                     m_table_id, m_flags, m_width, data_size));
+                     m_table_id, m_flags, m_width, (ulong) data_size));
 
-  m_rows_buf= (byte*)my_malloc(data_size, MYF(MY_WME));
+  m_rows_buf= (uchar*) my_malloc(data_size, MYF(MY_WME));
   if (likely((bool)m_rows_buf))
   {
     m_rows_end= m_rows_buf + data_size;
@@ -5729,15 +5776,15 @@
   if (m_cols.bitmap == m_bitbuf) // no my_malloc happened
     m_cols.bitmap= 0; // so no my_free in bitmap_free
   bitmap_free(&m_cols); // To pair with bitmap_init().
-  my_free((gptr)m_rows_buf, MYF(MY_ALLOW_ZERO_PTR));
+  my_free((uchar*)m_rows_buf, MYF(MY_ALLOW_ZERO_PTR));
 }
 
 int Rows_log_event::get_data_size()
 {
   int const type_code= get_type_code();
 
-  char buf[sizeof(m_width)+1];
-  char *end= net_store_length(buf, (m_width + 7) / 8);
+  uchar buf[sizeof(m_width)+1];
+  uchar *end= net_store_length(buf, (m_width + 7) / 8);
 
   DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
                   return 6 + no_bytes_in_map(&m_cols) + (end - buf) +
@@ -5756,7 +5803,7 @@
 
 
 #ifndef MYSQL_CLIENT
-int Rows_log_event::do_add_row_data(byte *row_data, my_size_t length)
+int Rows_log_event::do_add_row_data(uchar *row_data, size_t length)
 {
   /*
     When the table has a primary key, we would probably want, by default, to
@@ -5771,7 +5818,7 @@
     trigger false warnings.
    */
 #ifndef HAVE_purify
-  DBUG_DUMP("row_data", (const char*)row_data, min(length, 32));
+  DBUG_DUMP("row_data", row_data, min(length, 32));
 #endif
 
   DBUG_ASSERT(m_rows_buf <= m_rows_cur);
@@ -5779,14 +5826,14 @@
   DBUG_ASSERT(m_rows_cur <= m_rows_end);
 
   /* The cast will always work since m_rows_cur <= m_rows_end */
-  if (static_cast<my_size_t>(m_rows_end - m_rows_cur) <= length)
+  if (static_cast<size_t>(m_rows_end - m_rows_cur) <= length)
   {
-    my_size_t const block_size= 1024;
+    size_t const block_size= 1024;
     my_ptrdiff_t const cur_size= m_rows_cur - m_rows_buf;
     my_ptrdiff_t const new_alloc= 
         block_size * ((cur_size + length + block_size - 1) / block_size);
 
-    byte* const new_buf= (byte*)my_realloc((gptr)m_rows_buf, (uint) new_alloc,
+    uchar* const new_buf= (uchar*)my_realloc((uchar*)m_rows_buf, (uint) new_alloc,
                                            MYF(MY_ALLOW_ZERO_PTR|MY_WME));
     if (unlikely(!new_buf))
       DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -5818,7 +5865,7 @@
 {
   DBUG_ENTER("Rows_log_event::do_apply_event(st_relay_log_info*)");
   int error= 0;
-  char const *row_start= (char const *)m_rows_buf;
+  uchar const *row_start= m_rows_buf;
 
   /*
     If m_table_id == ~0UL, then we have a dummy event that does not
@@ -5877,18 +5924,18 @@
             simplifications (we don't honour --slave-skip-errors)
           */
           uint actual_error= thd->net.last_errno;
-          slave_print_msg(ERROR_LEVEL, rli, actual_error,
-                          "Error '%s' in %s event: when locking tables",
-                          (actual_error ? thd->net.last_error :
-                           "unexpected success or fatal error"),
-                          get_type_str());
+          rli->report(ERROR_LEVEL, actual_error,
+                      "Error '%s' in %s event: when locking tables",
+                      (actual_error ? thd->net.last_error :
+                       "unexpected success or fatal error"),
+                      get_type_str());
           thd->is_fatal_error= 1;
         }
         else
         {
-          slave_print_msg(ERROR_LEVEL, rli, error,
-                         "Error in %s event: when locking tables",
-                         get_type_str());
+          rli->report(ERROR_LEVEL, error,
+                      "Error in %s event: when locking tables",
+                      get_type_str());
         }
         const_cast<RELAY_LOG_INFO*>(rli)->clear_tables_to_lock();
         DBUG_RETURN(error);
@@ -5921,10 +5968,10 @@
             simplifications (we don't honour --slave-skip-errors)
           */
           uint actual_error= thd->net.last_errno;
-          slave_print_msg(ERROR_LEVEL, rli, actual_error,
-                          "Error '%s' on reopening tables",
-                          (actual_error ? thd->net.last_error :
-                           "unexpected success or fatal error"));
+          rli->report(ERROR_LEVEL, actual_error,
+                      "Error '%s' on reopening tables",
+                      (actual_error ? thd->net.last_error :
+                       "unexpected success or fatal error"));
           thd->query_error= 1;
         }
         const_cast<RELAY_LOG_INFO*>(rli)->clear_tables_to_lock();
@@ -6035,15 +6082,15 @@
     const_cast<RELAY_LOG_INFO*>(rli)->set_flag(RELAY_LOG_INFO::IN_STMT);
 
     error= do_before_row_operations(table);
-    while (error == 0 && row_start < (const char*) m_rows_end)
+    while (error == 0 && row_start < m_rows_end)
     {
-      char const *row_end= NULL;
+      uchar const *row_end= NULL;
       if ((error= do_prepare_row(thd, rli, table, row_start, &row_end)))
         break; // We should perform the after-row operation even in
                // the case of error
 
       DBUG_ASSERT(row_end != NULL); // cannot happen
-      DBUG_ASSERT(row_end <= (const char*)m_rows_end);
+      DBUG_ASSERT(row_end <= m_rows_end);
 
       /* in_use can have been set to NULL in close_tables_for_reopen */
       THD* old_thd= table->in_use;
@@ -6062,9 +6109,9 @@
 	break;
 
       default:
-	slave_print_msg(ERROR_LEVEL, rli, thd->net.last_errno,
-                        "Error in %s event: row application failed",
-                        get_type_str());
+	rli->report(ERROR_LEVEL, thd->net.last_errno,
+                    "Error in %s event: row application failed",
+                    get_type_str());
 	thd->query_error= 1;
 	break;
       }
@@ -6083,13 +6130,13 @@
 
   if (error)
   {                     /* error has occured during the transaction */
-    slave_print_msg(ERROR_LEVEL, rli, thd->net.last_errno,
-                    "Error in %s event: error during transaction execution "
-                    "on table %s.%s",
-                    get_type_str(), table->s->db.str, 
-                    table->s->table_name.str);
+    rli->report(ERROR_LEVEL, thd->net.last_errno,
+                "Error in %s event: error during transaction execution "
+                "on table %s.%s",
+                get_type_str(), table->s->db.str,
+                table->s->table_name.str);
 
-     /*
+    /*
       If one day we honour --skip-slave-errors in row-based replication, and
       the error should be skipped, then we would clear mappings, rollback,
       close tables, but the slave SQL thread would not stop and then may
@@ -6136,6 +6183,20 @@
   DBUG_RETURN(0);
 }
 
+Log_event::enum_skip_reason
+Rows_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+  /*
+    If the slave skip counter is 1 and this event does not end a
+    statement, then we should not start executing on the next event.
+    Otherwise, we defer the decision to the normal skipping logic.
+  */
+  if (rli->slave_skip_counter == 1 && !get_flags(STMT_END_F))
+    return Log_event::EVENT_SKIP_IGNORE;
+  else
+    return Log_event::do_shall_skip(rli);
+}
+
 int
 Rows_log_event::do_update_pos(RELAY_LOG_INFO *rli)
 {
@@ -6207,9 +6268,11 @@
       thd->clear_error();
     }
     else
-      slave_print_msg(ERROR_LEVEL, rli, error,
-                      "Error in %s event: commit of row events failed",
-                      get_type_str());
+      rli->report(ERROR_LEVEL, error,
+                  "Error in %s event: commit of row events failed, "
+                  "table `%s`.`%s`",
+                  get_type_str(), m_table->s->db.str,
+                  m_table->s->table_name.str);
   }
   else
   {
@@ -6224,7 +6287,7 @@
 #ifndef MYSQL_CLIENT
 bool Rows_log_event::write_data_header(IO_CACHE *file)
 {
-  byte buf[ROWS_HEADER_LEN];	// No need to init the buffer
+  uchar buf[ROWS_HEADER_LEN];	// No need to init the buffer
   DBUG_ASSERT(m_table_id != ~0UL);
   DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
                   {
@@ -6243,34 +6306,30 @@
      Note that this should be the number of *bits*, not the number of
      bytes.
   */
-  char sbuf[sizeof(m_width)];
+  uchar sbuf[sizeof(m_width)];
   my_ptrdiff_t const data_size= m_rows_cur - m_rows_buf;
   bool res= false;
+  uchar *const sbuf_end= net_store_length(sbuf, (size_t) m_width);
+  DBUG_ASSERT(static_cast<size_t>(sbuf_end - sbuf) <= sizeof(sbuf));
 
-  char *const sbuf_end= net_store_length((char*) sbuf, (uint) m_width);
-  DBUG_ASSERT(static_cast<my_size_t>(sbuf_end - sbuf) <= sizeof(sbuf));
+  DBUG_DUMP("m_width", sbuf, (size_t) (sbuf_end - sbuf));
+  res= res || my_b_safe_write(file, sbuf, (size_t) (sbuf_end - sbuf));
 
-  DBUG_DUMP("m_width", sbuf, sbuf_end - sbuf);
-  res= res || my_b_safe_write(file,
-                              reinterpret_cast<byte*>(sbuf),
-                              sbuf_end - sbuf);
-
-  DBUG_DUMP("m_cols", (char*) m_cols.bitmap, no_bytes_in_map(&m_cols));
-  res= res || my_b_safe_write(file,
-                              reinterpret_cast<byte*>(m_cols.bitmap),
+  DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols));
+  res= res || my_b_safe_write(file, (uchar*) m_cols.bitmap,
                               no_bytes_in_map(&m_cols));
   /*
     TODO[refactor write]: Remove the "down cast" here (and elsewhere).
    */
   if (get_type_code() == UPDATE_ROWS_EVENT)
   {
-    DBUG_DUMP("m_cols_ai", (char*) m_cols_ai.bitmap, no_bytes_in_map(&m_cols_ai));
-    res= res || my_b_safe_write(file,
-                                reinterpret_cast<byte*>(m_cols_ai.bitmap),
+    DBUG_DUMP("m_cols_ai", (uchar*) m_cols_ai.bitmap,
+              no_bytes_in_map(&m_cols_ai));
+    res= res || my_b_safe_write(file, (uchar*) m_cols_ai.bitmap,
                                 no_bytes_in_map(&m_cols_ai));
   }
-  DBUG_DUMP("rows",(const char *) m_rows_buf, data_size);
-  res= res || my_b_safe_write(file, m_rows_buf, (uint) data_size);
+  DBUG_DUMP("rows", m_rows_buf, data_size);
+  res= res || my_b_safe_write(file, m_rows_buf, (size_t) data_size);
 
   return res;
 
@@ -6283,7 +6342,7 @@
   char buf[256];
   char const *const flagstr=
     get_flags(STMT_END_F) ? " flags: STMT_END_F" : "";
-  my_size_t bytes= my_snprintf(buf, sizeof(buf),
+  size_t bytes= my_snprintf(buf, sizeof(buf),
                                "table_id: %lu%s", m_table_id, flagstr);
   protocol->store(buf, bytes, &my_charset_bin);
 }
@@ -6355,7 +6414,7 @@
   m_data_size+= 1 + m_colcnt;	// COLCNT and column types
 
   /* If malloc fails, catched in is_valid() */
-  if ((m_memory= my_malloc(m_colcnt, MYF(MY_WME))))
+  if ((m_memory= (uchar*) my_malloc(m_colcnt, MYF(MY_WME))))
   {
     m_coltype= reinterpret_cast<uchar*>(m_memory);
     for (unsigned int i= 0 ; i < m_table->s->fields ; ++i)
@@ -6390,7 +6449,7 @@
     trigger false warnings.
    */
 #ifndef HAVE_purify
-  DBUG_DUMP("event buffer", buf, event_len);
+  DBUG_DUMP("event buffer", (uchar*) buf, event_len);
 #endif
 
   /* Read the post-header */
@@ -6418,29 +6477,29 @@
   const char *const vpart= buf + common_header_len + post_header_len;
 
   /* Extract the length of the various parts from the buffer */
-  byte const *const ptr_dblen= (byte const*)vpart + 0;
+  uchar const *const ptr_dblen= (uchar const*)vpart + 0;
   m_dblen= *(uchar*) ptr_dblen;
 
   /* Length of database name + counter + terminating null */
-  byte const *const ptr_tbllen= ptr_dblen + m_dblen + 2;
+  uchar const *const ptr_tbllen= ptr_dblen + m_dblen + 2;
   m_tbllen= *(uchar*) ptr_tbllen;
 
   /* Length of table name + counter + terminating null */
-  byte const *const ptr_colcnt= ptr_tbllen + m_tbllen + 2;
+  uchar const *const ptr_colcnt= ptr_tbllen + m_tbllen + 2;
   uchar *ptr_after_colcnt= (uchar*) ptr_colcnt;
   m_colcnt= net_field_length(&ptr_after_colcnt);
 
   DBUG_PRINT("info",("m_dblen: %lu  off: %ld  m_tbllen: %lu  off: %ld  m_colcnt: %lu 
off: %ld",
-                     m_dblen, (long) (ptr_dblen-(const byte*)vpart), 
-                     m_tbllen, (long) (ptr_tbllen-(const byte*)vpart),
-                     m_colcnt, (long) (ptr_colcnt-(const byte*)vpart)));
+                     (ulong) m_dblen, (long) (ptr_dblen-(const uchar*)vpart), 
+                     (ulong) m_tbllen, (long) (ptr_tbllen-(const uchar*)vpart),
+                     m_colcnt, (long) (ptr_colcnt-(const uchar*)vpart)));
 
   /* Allocate mem for all fields in one go. If fails, catched in is_valid() */
-  m_memory= my_multi_malloc(MYF(MY_WME),
-			    &m_dbnam, m_dblen + 1,
-			    &m_tblnam, m_tbllen + 1,
-			    &m_coltype, m_colcnt,
-			    NULL);
+  m_memory= (uchar*) my_multi_malloc(MYF(MY_WME),
+                                     &m_dbnam, (uint) m_dblen + 1,
+                                     &m_tblnam, (uint) m_tbllen + 1,
+                                     &m_coltype, (uint) m_colcnt,
+                                     NullS);
 
   if (m_memory)
   {
@@ -6473,8 +6532,11 @@
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
 int Table_map_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
 {
+  RPL_TABLE_LIST *table_list;
+  char *db_mem, *tname_mem;
+  size_t dummy_len;
+  void *memory;
   DBUG_ENTER("Table_map_log_event::do_apply_event(st_relay_log_info*)");
-
   DBUG_ASSERT(rli->sql_thd == thd);
 
   /* Step the query id to mark what columns that are actually used. */
@@ -6482,19 +6544,13 @@
   thd->query_id= next_query_id();
   pthread_mutex_unlock(&LOCK_thread_count);
 
-  RPL_TABLE_LIST *table_list;
-  char *db_mem, *tname_mem;
-  void *const memory=
-    my_multi_malloc(MYF(MY_WME),
-                    &table_list, sizeof(RPL_TABLE_LIST),
-                    &db_mem, NAME_LEN + 1,
-                    &tname_mem, NAME_LEN + 1,
-                    NULL);
-
-  if (memory == NULL)
+  if (!(memory= my_multi_malloc(MYF(MY_WME),
+                                &table_list, (uint) sizeof(RPL_TABLE_LIST),
+                                &db_mem, (uint) NAME_LEN + 1,
+                                &tname_mem, (uint) NAME_LEN + 1,
+                                NullS)))
     DBUG_RETURN(HA_ERR_OUT_OF_MEM);
 
-  uint dummy_len;
   bzero(table_list, sizeof(*table_list));
   table_list->db = db_mem;
   table_list->alias= table_list->table_name = tname_mem;
@@ -6510,7 +6566,7 @@
   if (!rpl_filter->db_ok(table_list->db) ||
       (rpl_filter->is_on() && !rpl_filter->tables_ok("", table_list)))
   {
-    my_free((gptr) memory, MYF(MY_WME));
+    my_free(memory, MYF(MY_WME));
   }
   else
   {
@@ -6562,11 +6618,11 @@
           simplifications (we don't honour --slave-skip-errors)
         */
         uint actual_error= thd->net.last_errno;
-        slave_print_msg(ERROR_LEVEL, rli, actual_error,
-                        "Error '%s' on opening table `%s`.`%s`",
-                        (actual_error ? thd->net.last_error :
-                         "unexpected success or fatal error"),
-                        table_list->db, table_list->table_name);
+        rli->report(ERROR_LEVEL, actual_error,
+                    "Error '%s' on opening table `%s`.`%s`",
+                    (actual_error ? thd->net.last_error :
+                     "unexpected success or fatal error"),
+                    table_list->db, table_list->table_name);
         thd->query_error= 1;
       }
       goto err;
@@ -6605,10 +6661,23 @@
   DBUG_RETURN(error);
 
 err:
-  my_free((gptr) memory, MYF(MY_WME));
+  my_free(memory, MYF(MY_WME));
   DBUG_RETURN(error);
 }
 
+Log_event::enum_skip_reason
+Table_map_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+  /*
+    If the slave skip counter is 1, then we should not start executing
+    on the next event.
+  */
+  if (rli->slave_skip_counter == 1)
+    return Log_event::EVENT_SKIP_IGNORE;
+  else
+    return Log_event::do_shall_skip(rli);
+}
+
 int Table_map_log_event::do_update_pos(RELAY_LOG_INFO *rli)
 {
   rli->inc_event_relay_log_pos();
@@ -6621,7 +6690,7 @@
 bool Table_map_log_event::write_data_header(IO_CACHE *file)
 {
   DBUG_ASSERT(m_table_id != ~0UL);
-  byte buf[TABLE_MAP_HEADER_LEN];
+  uchar buf[TABLE_MAP_HEADER_LEN];
   DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
                   {
                     int4store(buf + 0, m_table_id);
@@ -6641,20 +6710,19 @@
   DBUG_ASSERT(m_dblen < 128);
   DBUG_ASSERT(m_tbllen < 128);
 
-  byte const dbuf[]= { (byte) m_dblen };
-  byte const tbuf[]= { (byte) m_tbllen };
+  uchar const dbuf[]= { (uchar) m_dblen };
+  uchar const tbuf[]= { (uchar) m_tbllen };
 
-  char cbuf[sizeof(m_colcnt)];
-  char *const cbuf_end= net_store_length((char*) cbuf, (uint) m_colcnt);
-  DBUG_ASSERT(static_cast<my_size_t>(cbuf_end - cbuf) <= sizeof(cbuf));
+  uchar cbuf[sizeof(m_colcnt)];
+  uchar *const cbuf_end= net_store_length(cbuf, (size_t) m_colcnt);
+  DBUG_ASSERT(static_cast<size_t>(cbuf_end - cbuf) <= sizeof(cbuf));
 
   return (my_b_safe_write(file, dbuf,      sizeof(dbuf)) ||
-          my_b_safe_write(file, (const byte*)m_dbnam,   m_dblen+1) ||
+          my_b_safe_write(file, (const uchar*)m_dbnam,   m_dblen+1) ||
           my_b_safe_write(file, tbuf,      sizeof(tbuf)) ||
-          my_b_safe_write(file, (const byte*)m_tblnam,  m_tbllen+1) ||
-          my_b_safe_write(file, reinterpret_cast<byte*>(cbuf),
-                          cbuf_end - (char*) cbuf) ||
-          my_b_safe_write(file, reinterpret_cast<byte*>(m_coltype), m_colcnt));
+          my_b_safe_write(file, (const uchar*)m_tblnam,  m_tbllen+1) ||
+          my_b_safe_write(file, cbuf, (size_t) (cbuf_end - cbuf)) ||
+          my_b_safe_write(file, m_coltype, m_colcnt));
  }
 #endif
 
@@ -6669,7 +6737,7 @@
 void Table_map_log_event::pack_info(Protocol *protocol)
 {
     char buf[256];
-    my_size_t bytes= my_snprintf(buf, sizeof(buf),
+    size_t bytes= my_snprintf(buf, sizeof(buf),
                                  "table_id: %lu (%s.%s)",
                               m_table_id, m_dbnam, m_tblnam);
     protocol->store(buf, bytes, &my_charset_bin);
@@ -6743,10 +6811,23 @@
     lex->duplicates flag.
   */
   thd->lex->sql_command= SQLCOM_REPLACE;
-
-  table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);  // Needed for ndbcluster
-  table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);  // Needed for ndbcluster
-  table->file->extra(HA_EXTRA_IGNORE_NO_KEY);   // Needed for ndbcluster
+  /* 
+     Do not raise the error flag in case of hitting to an unique attribute
+  */
+  table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
+  /* 
+     NDB specific: update from ndb master wrapped as Write_rows
+  */
+  /*
+    so that the event should be applied to replace slave's row
+  */
+  table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
+  /* 
+     NDB specific: if update from ndb master wrapped as Write_rows
+     does not find the row it's assumed idempotent binlog applying
+     is taking place; don't raise the error.
+  */
+  table->file->extra(HA_EXTRA_IGNORE_NO_KEY);
   /*
     TODO: the cluster team (Tomas?) says that it's better if the engine knows
     how many rows are going to be inserted, then it can allocate needed memory
@@ -6774,24 +6855,38 @@
 
 int Write_rows_log_event::do_after_row_operations(TABLE *table, int error)
 {
-  if (error == 0)
-    error= table->file->ha_end_bulk_insert();
-  return error;
+  int local_error= 0;
+  table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
+  table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
+  /*
+    reseting the extra with 
+    table->file->extra(HA_EXTRA_NO_IGNORE_NO_KEY); 
+    fires bug#27077
+    todo: explain or fix
+  */
+  if ((local_error= table->file->ha_end_bulk_insert()))
+  {
+    table->file->print_error(local_error, MYF(0));
+  }
+  return error? error : local_error;
 }
 
 int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
                                          TABLE *table,
-                                         char const *const row_start,
-                                         char const **const row_end)
+                                         uchar const *const row_start,
+                                         uchar const **const row_end)
 {
   DBUG_ASSERT(table != NULL);
   DBUG_ASSERT(row_start && row_end);
 
-  int error;
-  error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
-                    &m_master_reclength, table->write_set, WRITE_ROWS_EVENT);
+  if (int error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
+                            &m_master_reclength, table->write_set,
WRITE_ROWS_EVENT))
+  {
+    thd->net.last_errno= error;
+    return error;
+  }
   bitmap_copy(table->read_set, table->write_set);
-  return error;
+  return 0;
 }
 
 /*
@@ -6847,7 +6942,7 @@
  */
 static int
 copy_extra_record_fields(TABLE *table,
-                         my_size_t master_reclength,
+                         size_t master_reclength,
                          my_ptrdiff_t master_fields)
 {
   DBUG_PRINT("info", ("Copying to 0x%lx "
@@ -6989,7 +7084,7 @@
   auto_afree_ptr<char> key(NULL);
 
 #ifndef DBUG_OFF
-  DBUG_DUMP("record[0]",(const char *) table->record[0], table->s->reclength);
+  DBUG_DUMP("record[0]", table->record[0], table->s->reclength);
   DBUG_PRINT_BITSET("debug", "write_set = %s", table->write_set);
   DBUG_PRINT_BITSET("debug", "read_set = %s", table->read_set);
 #endif
@@ -7040,9 +7135,9 @@
           DBUG_RETURN(ENOMEM);
       }
 
-      key_copy((byte*)key.get(), table->record[0], table->key_info + keynum, 0);
+      key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum, 0);
       error= table->file->index_read_idx(table->record[1], keynum,
-                                         (const byte*)key.get(),
+                                         (const uchar*)key.get(),
                                          HA_WHOLE_KEY,
                                          HA_READ_KEY_EXACT);
       if (error)
@@ -7082,8 +7177,10 @@
     {
       error=table->file->ha_update_row(table->record[1],
                                        table->record[0]);
-      if (error)
+      if (error && error != HA_ERR_RECORD_IS_THE_SAME)
         table->file->print_error(error, MYF(0));
+      else
+        error= 0;
       DBUG_RETURN(error);
     }
     else
@@ -7140,7 +7237,7 @@
    */
 
   bool result= FALSE;
-  byte saved_x[2], saved_filler[2];
+  uchar saved_x[2], saved_filler[2];
 
   if (table->s->null_bytes > 0)
   {
@@ -7223,15 +7320,15 @@
   <code>table->record[1]</code>, error code otherwise.
  */
 
-static int find_and_fetch_row(TABLE *table, byte *key)
+static int find_and_fetch_row(TABLE *table, uchar *key)
 {
-  DBUG_ENTER("find_and_fetch_row(TABLE *table, byte *key, byte *record)");
+  DBUG_ENTER("find_and_fetch_row(TABLE *table, uchar *key, uchar *record)");
   DBUG_PRINT("enter", ("table: 0x%lx, key: 0x%lx  record: 0x%lx",
 		       (long) table, (long) key, (long) table->record[1]));
 
   DBUG_ASSERT(table->in_use != NULL);
 
-  DBUG_DUMP("record[0]",(const char *) table->record[0], table->s->reclength);
+  DBUG_DUMP("record[0]", table->record[0], table->s->reclength);
 
   if ((table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION)
&&
       table->s->primary_key < MAX_KEY)
@@ -7296,8 +7393,8 @@
     trigger false warnings.
    */
 #ifndef HAVE_purify
-    DBUG_DUMP("table->record[0]", (const char *)table->record[0],
table->s->reclength);
-    DBUG_DUMP("table->record[1]", (const char *)table->record[1],
table->s->reclength);
+    DBUG_DUMP("table->record[0]", table->record[0], table->s->reclength);
+    DBUG_DUMP("table->record[1]", table->record[1], table->s->reclength);
 #endif
 
     /*
@@ -7322,8 +7419,8 @@
     trigger false warnings.
    */
 #ifndef HAVE_purify
-    DBUG_DUMP("table->record[0]", (const char *)table->record[0],
table->s->reclength);
-    DBUG_DUMP("table->record[1]", (const char *)table->record[1],
table->s->reclength);
+    DBUG_DUMP("table->record[0]", table->record[0], table->s->reclength);
+    DBUG_DUMP("table->record[1]", table->record[1], table->s->reclength);
 #endif
     /*
       Below is a minor "optimization".  If the key (i.e., key number
@@ -7391,11 +7488,10 @@
     {
       error= table->file->rnd_next(table->record[1]);
 
-      DBUG_DUMP("record[0]",(const char *) table->record[0],
table->s->reclength);
-      DBUG_DUMP("record[1]",(const char *) table->record[1],
table->s->reclength);
+      DBUG_DUMP("record[0]", table->record[0], table->s->reclength);
+      DBUG_DUMP("record[1]", table->record[1], table->s->reclength);
 
-      switch (error)
-      {
+      switch (error) {
       case 0:
       case HA_ERR_RECORD_DELETED:
 	break;
@@ -7480,16 +7576,17 @@
 
   if (table->s->keys > 0)
   {
-    m_memory=
-      my_multi_malloc(MYF(MY_WME),
-		      &m_after_image, table->s->reclength,
-		      &m_key, table->key_info->key_length,
-		      NULL);
+    m_memory= (uchar*) my_multi_malloc(MYF(MY_WME),
+                                       &m_after_image,
+                                       (uint) table->s->reclength,
+                                       &m_key,
+                                       (uint) table->key_info->key_length,
+                                       NullS);
   }
   else
   {
-    m_after_image= (byte*)my_malloc(table->s->reclength, MYF(MY_WME));
-    m_memory= (gptr)m_after_image;
+    m_after_image= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME));
+    m_memory= (uchar*)m_after_image;
     m_key= NULL;
   }
   if (!m_memory)
@@ -7512,10 +7609,9 @@
 
 int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
                                           TABLE *table,
-                                          char const *const row_start,
-                                          char const **const row_end)
+                                          uchar const *const row_start,
+                                          uchar const **const row_end)
 {
-  int error;
   DBUG_ASSERT(row_start && row_end);
   /*
     This assertion actually checks that there is at least as many
@@ -7523,8 +7619,13 @@
   */
   DBUG_ASSERT(table->s->fields >= m_width);
 
-  error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
-                    &m_master_reclength, table->read_set, DELETE_ROWS_EVENT);
+  if (int error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
+                            &m_master_reclength, table->read_set,
DELETE_ROWS_EVENT))
+  {
+    thd->net.last_errno= error;
+    return error;
+  }
+
   /*
     If we will access rows using the random access method, m_key will
     be set to NULL, so we do not need to make a key copy in that case.
@@ -7536,7 +7637,7 @@
     key_copy(m_key, table->record[0], key_info, 0);
   }
 
-  return error;
+  return 0;
 }
 
 int Delete_rows_log_event::do_exec_row(TABLE *table)
@@ -7652,16 +7753,17 @@
 
   if (table->s->keys > 0)
   {
-    m_memory=
-      my_multi_malloc(MYF(MY_WME),
-		      &m_after_image, table->s->reclength,
-		      &m_key, table->key_info->key_length,
-		      NULL);
+    m_memory= (uchar*) my_multi_malloc(MYF(MY_WME),
+                                       &m_after_image,
+                                       (uint) table->s->reclength,
+                                       &m_key,
+                                       (uint) table->key_info->key_length,
+                                       NullS);
   }
   else
   {
-    m_after_image= (byte*)my_malloc(table->s->reclength, MYF(MY_WME));
-    m_memory= (gptr)m_after_image;
+    m_after_image= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME));
+    m_memory= m_after_image;
     m_key= NULL;
   }
   if (!m_memory)
@@ -7686,8 +7788,8 @@
 
 int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
                                           TABLE *table,
-                                          char const *const row_start,
-                                          char const **const row_end)
+                                          uchar const *const row_start,
+                                          uchar const **const row_end)
 {
   int error;
   DBUG_ASSERT(row_start && row_end);
@@ -7704,13 +7806,23 @@
   */
 
   /* record[0] is the before image for the update */
-  error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
-                    &m_master_reclength, table->read_set, UPDATE_ROWS_EVENT);
+  if ((error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
+                         &m_master_reclength, table->read_set,
UPDATE_ROWS_EVENT)))
+  {
+    thd->net.last_errno= error;
+    return error;
+  }
+
   store_record(table, record[1]);
-  char const *next_start = *row_end;
+  uchar const *next_start = *row_end;
   /* m_after_image is the after image for the update */
-  error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end,
-                    &m_master_reclength, table->write_set, UPDATE_ROWS_EVENT);
+  if ((error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end,
+                         &m_master_reclength, table->write_set,
UPDATE_ROWS_EVENT)))
+  {
+    thd->net.last_errno= error;
+    return error;
+  }
+
   bmove_align(m_after_image, table->record[0], table->s->reclength);
   restore_record(table, record[1]);
 
@@ -7719,8 +7831,8 @@
     trigger false warnings.
    */
 #ifndef HAVE_purify
-  DBUG_DUMP("record[0]", (const char *)table->record[0], table->s->reclength);
-  DBUG_DUMP("m_after_image", (const char *)m_after_image, table->s->reclength);
+  DBUG_DUMP("record[0]",     table->record[0], table->s->reclength);
+  DBUG_DUMP("m_after_image", m_after_image, table->s->reclength);
 #endif
 
   /*
@@ -7768,6 +7880,8 @@
     database into the after image delivered from the master.
   */
   error= table->file->ha_update_row(table->record[1], table->record[0]);
+  if (error == HA_ERR_RECORD_IS_THE_SAME)
+    error= 0;
 
   return error;
 }
@@ -7824,7 +7938,7 @@
   DBUG_PRINT("info", ("m_incident: %d", m_incident));
 
   DBUG_ASSERT(0 <= m_incident);
-  DBUG_ASSERT((my_size_t) m_incident <= sizeof(description)/sizeof(*description));
+  DBUG_ASSERT((size_t) m_incident <= sizeof(description)/sizeof(*description));
 
   return description[m_incident];
 }
@@ -7834,7 +7948,7 @@
 void Incident_log_event::pack_info(Protocol *protocol)
 {
   char buf[256];
-  my_size_t bytes;
+  size_t bytes;
   if (m_message.length > 0)
     bytes= my_snprintf(buf, sizeof(buf), "#%d (%s)",
                        m_incident, description());
@@ -7865,10 +7979,10 @@
 Incident_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
 {
   DBUG_ENTER("Incident_log_event::do_apply_event");
-  slave_print_msg(ERROR_LEVEL, rli, ER_SLAVE_INCIDENT,
-                  ER(ER_SLAVE_INCIDENT),
-                  description(),
-                  m_message.length > 0 ? m_message.str : "<none>");
+  rli->report(ERROR_LEVEL, ER_SLAVE_INCIDENT,
+              ER(ER_SLAVE_INCIDENT),
+              description(),
+              m_message.length > 0 ? m_message.str : "<none>");
   DBUG_RETURN(1);
 }
 #endif
@@ -7878,7 +7992,7 @@
 {
   DBUG_ENTER("Incident_log_event::write_data_header");
   DBUG_PRINT("enter", ("m_incident: %d", m_incident));
-  byte buf[sizeof(int16)];
+  uchar buf[sizeof(int16)];
   int2store(buf, (int16) m_incident);
   DBUG_RETURN(my_b_safe_write(file, buf, sizeof(buf)));
 }

--- 1.646/sql/mysqld.cc	2007-06-18 07:38:38 +02:00
+++ 1.647/sql/mysqld.cc	2007-07-05 13:48:38 +02:00
@@ -30,6 +30,10 @@
 
 #include "rpl_injector.h"
 
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
 #if defined(NOT_ENOUGH_TESTED) \
   && defined(NDB_SHM_TRANSPORTER) && MYSQL_VERSION_ID >= 50000
@@ -216,8 +220,10 @@
   "ERROR_FOR_DIVISION_BY_ZERO",
   "TRADITIONAL", "NO_AUTO_CREATE_USER", "HIGH_NOT_PRECEDENCE",
   "NO_ENGINE_SUBSTITUTION",
+  "PAD_CHAR_TO_FULL_LENGTH",
   NullS
 };
+
 static const unsigned int sql_mode_names_len[]=
 {
   /*REAL_AS_FLOAT*/               13,
@@ -250,8 +256,10 @@
   /*TRADITIONAL*/                 11,
   /*NO_AUTO_CREATE_USER*/         19,
   /*HIGH_NOT_PRECEDENCE*/         19,
-  /*NO_ENGINE_SUBSTITUTION*/      22
+  /*NO_ENGINE_SUBSTITUTION*/      22,
+  /*PAD_CHAR_TO_FULL_LENGTH*/     23
 };
+
 TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"",
 			    sql_mode_names,
                             (unsigned int *)sql_mode_names_len };
@@ -347,7 +355,15 @@
 my_bool locked_in_memory;
 bool opt_using_transactions, using_update_log;
 bool volatile abort_loop;
-bool volatile shutdown_in_progress, grant_option;
+bool volatile shutdown_in_progress;
+/**
+   @brief 'grant_option' is used to indicate if privileges needs
+   to be checked, in which case the lock, LOCK_grant, is used
+   to protect access to the grant table.
+   @note This flag is dropped in 5.1 
+   @see grant_init()
+ */
+bool volatile grant_option;
 
 my_bool opt_skip_slave_start = 0; // If set, slave is not autostarted
 my_bool opt_reckless_slave = 0;
@@ -466,8 +482,6 @@
 ulong rpl_recovery_rank=0;
 const char *log_output_str= "TABLE";
 
-double log_10[32];			/* 10 potences */
-double log_01[32];
 time_t server_start_time;
 
 char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30];
@@ -483,6 +497,7 @@
 
 const char *opt_date_time_formats[3];
 
+uint mysql_data_home_len;
 char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
 char server_version[SERVER_VERSION_LENGTH];
 char *mysqld_unix_port, *opt_mysql_tmpdir;
@@ -1189,7 +1204,7 @@
   if (tc_log)
     tc_log->close();
   xid_cache_free();
-  delete_elements(&key_caches, (void (*)(const char*, gptr)) free_key_cache);
+  delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache);
   multi_keycache_free();
   free_status_vars();
   end_thr_alarm(1);			/* Free allocated memory */
@@ -1236,7 +1251,7 @@
 #endif
   thread_scheduler.end();
   finish_client_errs();
-  my_free((gptr) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST),
+  my_free((uchar*) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST),
           MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
   DBUG_PRINT("quit", ("Error messages freed"));
   /* Tell main we are ready */
@@ -1414,6 +1429,15 @@
 err:
   sql_print_error("Fatal error: Can't change to run as user '%s' ;  Please check that the
user exists!\n",user);
   unireg_abort(1);
+
+#ifdef PR_SET_DUMPABLE
+  if (test_flags & TEST_CORE_ON_SIGNAL)
+  {
+    /* inform kernel that process is dumpable */
+    (void) prctl(PR_SET_DUMPABLE, 1);
+  }
+#endif
+
 #endif
   return NULL;
 }
@@ -1878,9 +1902,11 @@
 
 static void start_signal_handler(void)
 {
+#ifndef EMBEDDED_LIBRARY
   // Save vm id of this process
   if (!opt_bootstrap)
     create_pid_file();
+#endif /* EMBEDDED_LIBRARY */
 }
 
 
@@ -2197,7 +2223,7 @@
   if (!(test_flags & TEST_NO_STACKTRACE))
   {
     fprintf(stderr,"thd: 0x%lx\n",(long) thd);
-    print_stacktrace(thd ? (gptr) thd->thread_stack : (gptr) 0,
+    print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0,
 		     thread_stack);
   }
   if (thd)
@@ -2224,6 +2250,16 @@
 mysqld that is not statically linked.\n");
 #endif
 
+#ifdef HAVE_NPTL
+  if (thd_lib_detected == THD_LIB_LT && !getenv("LD_ASSUME_KERNEL"))
+    fprintf(stderr,"\n\
+You are running a statically-linked LinuxThreads binary on an NPTL system.\n\
+This can result in crashes on some distributions due to LT/NPTL conflicts.\n\
+You should either build a dynamically-linked binary, or force LinuxThreads\n\
+to be used with the LD_ASSUME_KERNEL environment variable. Please consult\n\
+the documentation for your distribution on how to do that.\n");
+#endif
+  
   if (locked_in_memory)
   {
     fprintf(stderr, "\n\
@@ -2585,7 +2621,7 @@
 
 static void my_str_free_mysqld(void *ptr)
 {
-  my_free((gptr)ptr, MYF(MY_FAE));
+  my_free((uchar*)ptr, MYF(MY_FAE));
 }
 #endif /* EMBEDDED_LIBRARY */
 
@@ -3292,7 +3328,7 @@
   }
     else
   {
-      global_system_variables.binlog_format= BINLOG_FORMAT_UNSPEC;
+      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
     }
   else
     if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
@@ -3763,6 +3799,7 @@
   mysql_data_home= mysql_data_home_buff;
   mysql_data_home[0]=FN_CURLIB;		// all paths are relative from here
   mysql_data_home[1]=0;
+  mysql_data_home_len= 2;
 
   if ((user_info= check_user(mysqld_user)))
   {
@@ -3806,6 +3843,11 @@
     freopen(log_error_file,"a+",stderr);
     FreeConsole();				// Remove window
   }
+  else
+  {
+    /* Don't show error dialog box when on foreground: it stops the server */ 
+    SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
+  }
 #endif
 
   /*
@@ -4654,7 +4696,7 @@
   HANDLE event_connect_answer= 0;
   ulong smem_buffer_length= shared_memory_buffer_length + 4;
   ulong connect_number= 1;
-  char tmp[63];
+  char *tmp= NULL;
   char *suffix_pos;
   char connect_number_char[22], *p;
   const char *errmsg= 0;
@@ -4663,6 +4705,12 @@
   DBUG_ENTER("handle_connections_shared_memorys");
   DBUG_PRINT("general",("Waiting for allocated shared memory."));
 
+  /*
+     get enough space base-name + '_' + longest suffix we might ever send
+   */
+  if (!(tmp= (char *)my_malloc(strlen(shared_memory_base_name) + 32L, MYF(MY_FAE))))
+    goto error;
+
   if (my_security_attr_create(&sa_event, &errmsg,
                               GENERIC_ALL, SYNCHRONIZE | EVENT_MODIFY_STATE))
     goto error;
@@ -4850,6 +4898,9 @@
 
   /* End shared memory handling */
 error:
+  if (tmp)
+    my_free(tmp, MYF(0));
+
   if (errmsg)
   {
     char buff[180];
@@ -5040,12 +5091,12 @@
 struct my_option my_long_options[] =
 {
   {"help", '?', "Display this help and exit.", 
-   (gptr*) &opt_help, (gptr*) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
+   (uchar**) &opt_help, (uchar**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
    0, 0},
 #ifdef HAVE_REPLICATION
   {"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT,
    "Option used by mysql-test for debugging and testing of replication.",
-   (gptr*) &abort_slave_event_count,  (gptr*) &abort_slave_event_count,
+   (uchar**) &abort_slave_event_count,  (uchar**) &abort_slave_event_count,
    0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #endif /* HAVE_REPLICATION */
   {"allow-suspicious-udfs", OPT_ALLOW_SUSPICIOUS_UDFS,
@@ -5053,33 +5104,33 @@
    "without corresponding xxx_init() or xxx_deinit(). That also means "
    "that one can load any function from any library, for example exit() "
    "from libc.so",
-   (gptr*) &opt_allow_suspicious_udfs, (gptr*) &opt_allow_suspicious_udfs,
+   (uchar**) &opt_allow_suspicious_udfs, (uchar**) &opt_allow_suspicious_udfs,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode will also set
transaction isolation level 'serializable'.", 0, 0, 0,
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"auto-increment-increment", OPT_AUTO_INCREMENT,
    "Auto-increment columns are incremented by this",
-   (gptr*) &global_system_variables.auto_increment_increment,
-   (gptr*) &max_system_variables.auto_increment_increment, 0, GET_ULONG,
+   (uchar**) &global_system_variables.auto_increment_increment,
+   (uchar**) &max_system_variables.auto_increment_increment, 0, GET_ULONG,
    OPT_ARG, 1, 1, 65535, 0, 1, 0 },
   {"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET,
    "Offset added to Auto-increment columns. Used when auto-increment-increment != 1",
-   (gptr*) &global_system_variables.auto_increment_offset,
-   (gptr*) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG,
+   (uchar**) &global_system_variables.auto_increment_offset,
+   (uchar**) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG,
    1, 1, 65535, 0, 1, 0 },
   {"automatic-sp-privileges", OPT_SP_AUTOMATIC_PRIVILEGES,
    "Creating and dropping stored procedures alters ACLs. Disable with
--skip-automatic-sp-privileges.",
-   (gptr*) &sp_automatic_privileges, (gptr*) &sp_automatic_privileges,
+   (uchar**) &sp_automatic_privileges, (uchar**) &sp_automatic_privileges,
    0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
   {"basedir", 'b',
    "Path to installation directory. All paths are usually resolved relative to this.",
-   (gptr*) &mysql_home_ptr, (gptr*) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG,
+   (uchar**) &mysql_home_ptr, (uchar**) &mysql_home_ptr, 0, GET_STR,
REQUIRED_ARG,
    0, 0, 0, 0, 0, 0},
   {"big-tables", OPT_BIG_TABLES,
    "Allow big result sets by saving all temporary sets on file (Solves most 'table full'
errors).",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.",
-   (gptr*) &my_bind_addr_str, (gptr*) &my_bind_addr_str, 0, GET_STR,
+   (uchar**) &my_bind_addr_str, (uchar**) &my_bind_addr_str, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"binlog_format", OPT_BINLOG_FORMAT,
    "Does not have any effect without '--log-bin'. "
@@ -5093,7 +5144,7 @@
    "If ndbcluster is enabled and binlog_format is `mixed', the format switches"
    " to 'row' and back implicitly per each query accessing a NDB table."
 #endif
-   ,(gptr*) &opt_binlog_format, (gptr*) &opt_binlog_format,
+   ,(uchar**) &opt_binlog_format, (uchar**) &opt_binlog_format,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"binlog-do-db", OPT_BINLOG_DO_DB,
    "Tells the master it should log updates for the specified database, and exclude all
others not explicitly mentioned.",
@@ -5105,8 +5156,8 @@
    "The maximum size of a row-based binary log event in bytes. Rows will be "
    "grouped into events smaller than this size if possible. "
    "The value has to be a multiple of 256.",
-   (gptr*) &opt_binlog_rows_event_max_size, 
-   (gptr*) &opt_binlog_rows_event_max_size, 0, 
+   (uchar**) &opt_binlog_rows_event_max_size, 
+   (uchar**) &opt_binlog_rows_event_max_size, 0, 
    GET_ULONG, REQUIRED_ARG, 
    /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX, 
    /* sub_size */     0, /* block_size */ 256, 
@@ -5118,61 +5169,61 @@
 #endif
   {"character-set-client-handshake", OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
    "Don't ignore client side character set value sent during handshake.",
-   (gptr*) &opt_character_set_client_handshake,
-   (gptr*) &opt_character_set_client_handshake,
+   (uchar**) &opt_character_set_client_handshake,
+   (uchar**) &opt_character_set_client_handshake,
     0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
   {"character-set-filesystem", OPT_CHARACTER_SET_FILESYSTEM,
    "Set the filesystem character set.",
-   (gptr*) &character_set_filesystem_name,
-   (gptr*) &character_set_filesystem_name,
+   (uchar**) &character_set_filesystem_name,
+   (uchar**) &character_set_filesystem_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   {"character-set-server", 'C', "Set the default character set.",
-   (gptr*) &default_character_set_name, (gptr*) &default_character_set_name,
+   (uchar**) &default_character_set_name, (uchar**) &default_character_set_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   {"character-sets-dir", OPT_CHARSETS_DIR,
-   "Directory where character sets are.", (gptr*) &charsets_dir,
-   (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+   "Directory where character sets are.", (uchar**) &charsets_dir,
+   (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"chroot", 'r', "Chroot mysqld daemon during startup.",
-   (gptr*) &mysqld_chroot, (gptr*) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG,
+   (uchar**) &mysqld_chroot, (uchar**) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0},
   {"collation-server", OPT_DEFAULT_COLLATION, "Set the default collation.",
-   (gptr*) &default_collation_name, (gptr*) &default_collation_name,
+   (uchar**) &default_collation_name, (uchar**) &default_collation_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   {"completion-type", OPT_COMPLETION_TYPE, "Default completion type.",
-   (gptr*) &global_system_variables.completion_type,
-   (gptr*) &max_system_variables.completion_type, 0, GET_ULONG,
+   (uchar**) &global_system_variables.completion_type,
+   (uchar**) &max_system_variables.completion_type, 0, GET_ULONG,
    REQUIRED_ARG, 0, 0, 2, 0, 1, 0},
   {"concurrent-insert", OPT_CONCURRENT_INSERT,
    "Use concurrent insert with MyISAM. Disable with --concurrent-insert=0",
-   (gptr*) &myisam_concurrent_insert, (gptr*) &myisam_concurrent_insert,
+   (uchar**) &myisam_concurrent_insert, (uchar**) &myisam_concurrent_insert,
    0, GET_LONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
   {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window
on windows.",
-   (gptr*) &opt_console, (gptr*) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0,
+   (uchar**) &opt_console, (uchar**) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0,
    0, 0, 0},
   {"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
-  {"datadir", 'h', "Path to the database root.", (gptr*) &mysql_data_home,
-   (gptr*) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"datadir", 'h', "Path to the database root.", (uchar**) &mysql_data_home,
+   (uchar**) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #ifndef DBUG_OFF
-  {"debug", '#', "Debug log.", (gptr*) &default_dbug_option,
-   (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+  {"debug", '#', "Debug log.", (uchar**) &default_dbug_option,
+   (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"default-character-set", 'C', "Set the default character set (deprecated option, use
--character-set-server instead).",
-   (gptr*) &default_character_set_name, (gptr*) &default_character_set_name,
+   (uchar**) &default_character_set_name, (uchar**) &default_character_set_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation (deprecated
option, use --collation-server instead).",
-   (gptr*) &default_collation_name, (gptr*) &default_collation_name,
+   (uchar**) &default_collation_name, (uchar**) &default_collation_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   {"default-storage-engine", OPT_STORAGE_ENGINE,
    "Set the default storage engine (table type) for tables.",
-   (gptr*)&default_storage_engine_str, (gptr*)&default_storage_engine_str,
+   (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"default-table-type", OPT_STORAGE_ENGINE,
    "(deprecated) Use --default-storage-engine.",
-   (gptr*)&default_storage_engine_str, (gptr*)&default_storage_engine_str,
+   (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.",
-   (gptr*) &default_tz_name, (gptr*) &default_tz_name,
+   (uchar**) &default_tz_name, (uchar**) &default_tz_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE.",
    0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@@ -5182,33 +5233,33 @@
 #ifdef HAVE_OPENSSL
   {"des-key-file", OPT_DES_KEY_FILE,
    "Load keys for des_encrypt() and des_encrypt from given file.",
-   (gptr*) &des_key_file, (gptr*) &des_key_file, 0, GET_STR, REQUIRED_ARG,
+   (uchar**) &des_key_file, (uchar**) &des_key_file, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0},
 #endif /* HAVE_OPENSSL */
 #ifdef HAVE_REPLICATION
   {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT,
    "Option used by mysql-test for debugging and testing of replication.",
-   (gptr*) &disconnect_slave_event_count,
-   (gptr*) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
+   (uchar**) &disconnect_slave_event_count,
+   (uchar**) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
    0, 0, 0},
 #endif /* HAVE_REPLICATION */
   {"enable-locking", OPT_ENABLE_LOCK,
    "Deprecated option, use --external-locking instead.",
-   (gptr*) &opt_external_locking, (gptr*) &opt_external_locking,
+   (uchar**) &opt_external_locking, (uchar**) &opt_external_locking,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef __NT__
   {"enable-named-pipe", OPT_HAVE_NAMED_PIPE, "Enable the named pipe (NT).",
-   (gptr*) &opt_enable_named_pipe, (gptr*) &opt_enable_named_pipe, 0, GET_BOOL,
+   (uchar**) &opt_enable_named_pipe, (uchar**) &opt_enable_named_pipe, 0,
GET_BOOL,
    NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"enable-pstack", OPT_DO_PSTACK, "Print a symbolic stack trace on failure.",
-   (gptr*) &opt_do_pstack, (gptr*) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
+   (uchar**) &opt_do_pstack, (uchar**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
    0, 0, 0, 0},
   {"engine-condition-pushdown",
    OPT_ENGINE_CONDITION_PUSHDOWN,
    "Push supported query conditions to the storage engine.",
-   (gptr*) &global_system_variables.engine_condition_pushdown,
-   (gptr*) &global_system_variables.engine_condition_pushdown,
+   (uchar**) &global_system_variables.engine_condition_pushdown,
+   (uchar**) &global_system_variables.engine_condition_pushdown,
    0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
   /* See how it's handled in get_one_option() */
   {"event-scheduler", OPT_EVENT_SCHEDULER, "Enable/disable the event scheduler.",
@@ -5216,7 +5267,7 @@
   {"exit-info", 'T', "Used for debugging;  Use at your own risk!", 0, 0, 0,
    GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"external-locking", OPT_USE_LOCKING, "Use system (external) locking (disabled by
default).  With this option enabled you can run myisamchk to test (not repair) tables
while the MySQL server is running. Disable with --skip-external-locking.",
-   (gptr*) &opt_external_locking, (gptr*) &opt_external_locking,
+   (uchar**) &opt_external_locking, (uchar**) &opt_external_locking,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"flush", OPT_FLUSH, "Flush tables to disk between SQL commands.", 0, 0, 0,
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -5224,55 +5275,55 @@
      easier to do */
   {"gdb", OPT_DEBUGGING,
    "Set up signals usable for debugging",
-   (gptr*) &opt_debugging, (gptr*) &opt_debugging,
+   (uchar**) &opt_debugging, (uchar**) &opt_debugging,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"general-log", OPT_GENERAL_LOG,
-   "Enable|disable general log", (gptr*) &opt_log,
-   (gptr*) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
+   "Enable|disable general log", (uchar**) &opt_log,
+   (uchar**) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef HAVE_LARGE_PAGES
   {"large-pages", OPT_ENABLE_LARGE_PAGES, "Enable support for large pages. \
 Disable with --skip-large-pages.",
-   (gptr*) &opt_large_pages, (gptr*) &opt_large_pages, 0, GET_BOOL, NO_ARG, 0, 0,
0,
+   (uchar**) &opt_large_pages, (uchar**) &opt_large_pages, 0, GET_BOOL, NO_ARG,
0, 0, 0,
    0, 0, 0},
 #endif
   {"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new
connection",
-   (gptr*) &opt_init_connect, (gptr*) &opt_init_connect, 0, GET_STR_ALLOC,
+   (uchar**) &opt_init_connect, (uchar**) &opt_init_connect, 0, GET_STR_ALLOC,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #ifndef DISABLE_GRANT_OPTIONS
   {"init-file", OPT_INIT_FILE, "Read SQL commands from this file at startup.",
-   (gptr*) &opt_init_file, (gptr*) &opt_init_file, 0, GET_STR, REQUIRED_ARG,
+   (uchar**) &opt_init_file, (uchar**) &opt_init_file, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0},
 #endif
   {"init-rpl-role", OPT_INIT_RPL_ROLE, "Set the replication role.", 0, 0, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"init-slave", OPT_INIT_SLAVE, "Command(s) that are executed when a slave connects to
this master",
-   (gptr*) &opt_init_slave, (gptr*) &opt_init_slave, 0, GET_STR_ALLOC,
+   (uchar**) &opt_init_slave, (uchar**) &opt_init_slave, 0, GET_STR_ALLOC,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-   {"language", 'L',
+  {"language", 'L',
    "Client error messages in given language. May be given as a full path.",
-   (gptr*) &language_ptr, (gptr*) &language_ptr, 0, GET_STR, REQUIRED_ARG,
+   (uchar**) &language_ptr, (uchar**) &language_ptr, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0},
   {"lc-time-names", OPT_LC_TIME_NAMES,
    "Set the language used for the month names and the days of the week.",
-   (gptr*) &lc_time_names_name,
-   (gptr*) &lc_time_names_name,
+   (uchar**) &lc_time_names_name,
+   (uchar**) &lc_time_names_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   {"local-infile", OPT_LOCAL_INFILE,
    "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0).",
-   (gptr*) &opt_local_infile,
-   (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
+   (uchar**) &opt_local_infile,
+   (uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG,
    1, 0, 0, 0, 0, 0},
-  {"log", 'l', "Log connections and queries to file.", (gptr*) &opt_logname,
-   (gptr*) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+  {"log", 'l', "Log connections and queries to file.", (uchar**) &opt_logname,
+   (uchar**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"log-bin", OPT_BIN_LOG,
    "Log update queries in binary format. Optional (but strongly recommended "
    "to avoid replication problems if server's hostname changes) argument "
    "should be the chosen location for the binary log files.",
-   (gptr*) &opt_bin_logname, (gptr*) &opt_bin_logname, 0, GET_STR_ALLOC,
+   (uchar**) &opt_bin_logname, (uchar**) &opt_bin_logname, 0, GET_STR_ALLOC,
    OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"log-bin-index", OPT_BIN_LOG_INDEX,
    "File that holds the names for last binary log files.",
-   (gptr*) &opt_binlog_index_name, (gptr*) &opt_binlog_index_name, 0, GET_STR,
+   (uchar**) &opt_binlog_index_name, (uchar**) &opt_binlog_index_name, 0,
GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #ifndef TO_BE_REMOVED_IN_5_1_OR_6_0
   /*
@@ -5283,7 +5334,7 @@
   */
   {"log-bin-trust-routine-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
    "(deprecated) Use log-bin-trust-function-creators.",
-   (gptr*) &trust_function_creators, (gptr*) &trust_function_creators, 0,
+   (uchar**) &trust_function_creators, (uchar**) &trust_function_creators, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   /*
@@ -5297,13 +5348,13 @@
    "Note that if ALL connections to this server ALWAYS use row-based binary "
    "logging, the security issues do not exist and the binary logging cannot "
    "break, so you can safely set this to 1."
-   ,(gptr*) &trust_function_creators, (gptr*) &trust_function_creators, 0,
+   ,(uchar**) &trust_function_creators, (uchar**) &trust_function_creators, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"log-error", OPT_ERROR_LOG_FILE, "Error log file.",
-   (gptr*) &log_error_file_ptr, (gptr*) &log_error_file_ptr, 0, GET_STR,
+   (uchar**) &log_error_file_ptr, (uchar**) &log_error_file_ptr, 0, GET_STR,
    OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.",
-   (gptr*) &myisam_log_filename, (gptr*) &myisam_log_filename, 0, GET_STR,
+   (uchar**) &myisam_log_filename, (uchar**) &myisam_log_filename, 0, GET_STR,
    OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"log-long-format", '0',
    "Log some extra information to update log. Please note that this option is deprecated;
see --log-short-format option.", 
@@ -5312,161 +5363,161 @@
   {"log-output", OPT_LOG_OUTPUT,
    "Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, "
    "FILE or NONE.",
-   (gptr*) &log_output_str, (gptr*) &log_output_str, 0,
+   (uchar**) &log_output_str, (uchar**) &log_output_str, 0,
    GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
    "Log queries that are executed without benefit of any index to the slow log if it is
open.",
-   (gptr*) &opt_log_queries_not_using_indexes, (gptr*)
&opt_log_queries_not_using_indexes,
+   (uchar**) &opt_log_queries_not_using_indexes, (uchar**)
&opt_log_queries_not_using_indexes,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"log-short-format", OPT_SHORT_LOG_FORMAT,
    "Don't log extra information to update and slow-query logs.",
-   (gptr*) &opt_short_log_format, (gptr*) &opt_short_log_format,
+   (uchar**) &opt_short_log_format, (uchar**) &opt_short_log_format,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
    "Tells the slave to log the updates from the slave thread to the binary log. You will
need to turn it on if you plan to daisy-chain the slaves.",
-   (gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL,
+   (uchar**) &opt_log_slave_updates, (uchar**) &opt_log_slave_updates, 0,
GET_BOOL,
    NO_ARG, 0, 0, 0, 0, 0, 0},
   {"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS,
    "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to the slow log
if it is open.",
-   (gptr*) &opt_log_slow_admin_statements,
-   (gptr*) &opt_log_slow_admin_statements,
+   (uchar**) &opt_log_slow_admin_statements,
+   (uchar**) &opt_log_slow_admin_statements,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"log-slow-queries", OPT_SLOW_QUERY_LOG,
     "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must
be enabled to activate other slow log options.",
-   (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
+   (uchar**) &opt_slow_logname, (uchar**) &opt_slow_logname, 0, GET_STR, OPT_ARG,
    0, 0, 0, 0, 0, 0},
   {"log-tc", OPT_LOG_TC,
    "Path to transaction coordinator log (used for transactions that affect "
    "more than one storage engine, when binary log is disabled)",
-   (gptr*) &opt_tc_log_file, (gptr*) &opt_tc_log_file, 0, GET_STR,
+   (uchar**) &opt_tc_log_file, (uchar**) &opt_tc_log_file, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef HAVE_MMAP
   {"log-tc-size", OPT_LOG_TC_SIZE, "Size of transaction coordinator log.",
-   (gptr*) &opt_tc_log_size, (gptr*) &opt_tc_log_size, 0, GET_ULONG,
+   (uchar**) &opt_tc_log_size, (uchar**) &opt_tc_log_size, 0, GET_ULONG,
    REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ~0L, 0, TC_LOG_PAGE_SIZE, 0},
 #endif
   {"log-update", OPT_UPDATE_LOG,
    "The update log is deprecated since version 5.0, is replaced by the binary \
 log and this option justs turns on --log-bin instead.",
-   (gptr*) &opt_update_logname, (gptr*) &opt_update_logname, 0, GET_STR,
+   (uchar**) &opt_update_logname, (uchar**) &opt_update_logname, 0, GET_STR,
    OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"log-warnings", 'W', "Log some not critical warnings to the log file.",
-   (gptr*) &global_system_variables.log_warnings,
-   (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
+   (uchar**) &global_system_variables.log_warnings,
+   (uchar**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
    0, 0, 0},
   {"low-priority-updates", OPT_LOW_PRIORITY_UPDATES,
    "INSERT/DELETE/UPDATE has lower priority than selects.",
-   (gptr*) &global_system_variables.low_priority_updates,
-   (gptr*) &max_system_variables.low_priority_updates,
+   (uchar**) &global_system_variables.low_priority_updates,
+   (uchar**) &max_system_variables.low_priority_updates,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"master-connect-retry", OPT_MASTER_CONNECT_RETRY,
    "The number of seconds the slave thread will sleep before retrying to connect to the
master in case the master goes down or the connection is lost.",
-   (gptr*) &master_connect_retry, (gptr*) &master_connect_retry, 0, GET_UINT,
+   (uchar**) &master_connect_retry, (uchar**) &master_connect_retry, 0, GET_UINT,
    REQUIRED_ARG, 60, 0, 0, 0, 0, 0},
   {"master-host", OPT_MASTER_HOST,
    "Master hostname or IP address for replication. If not set, the slave thread will not
be started. Note that the setting of master-host will be ignored if there exists a valid
master.info file.",
-   (gptr*) &master_host, (gptr*) &master_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
+   (uchar**) &master_host, (uchar**) &master_host, 0, GET_STR, REQUIRED_ARG, 0,
0,
    0, 0, 0, 0},
   {"master-info-file", OPT_MASTER_INFO_FILE,
    "The location and name of the file that remembers the master and where the I/O
replication \
 thread is in the master's binlogs.",
-   (gptr*) &master_info_file, (gptr*) &master_info_file, 0, GET_STR,
+   (uchar**) &master_info_file, (uchar**) &master_info_file, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"master-password", OPT_MASTER_PASSWORD,
    "The password the slave thread will authenticate with when connecting to the master.
If not set, an empty password is assumed.The value in master.info will take precedence if
it can be read.",
-   (gptr*)&master_password, (gptr*)&master_password, 0,
+   (uchar**)&master_password, (uchar**)&master_password, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"master-port", OPT_MASTER_PORT,
    "The port the master is listening on. If not set, the compiled setting of MYSQL_PORT
is assumed. If you have not tinkered with configure options, this should be 3306. The
value in master.info will take precedence if it can be read.",
-   (gptr*) &master_port, (gptr*) &master_port, 0, GET_UINT, REQUIRED_ARG,
+   (uchar**) &master_port, (uchar**) &master_port, 0, GET_UINT, REQUIRED_ARG,
    MYSQL_PORT, 0, 0, 0, 0, 0},
   {"master-retry-count", OPT_MASTER_RETRY_COUNT,
    "The number of tries the slave will make to connect to the master before giving up.",
-   (gptr*) &master_retry_count, (gptr*) &master_retry_count, 0, GET_ULONG,
+   (uchar**) &master_retry_count, (uchar**) &master_retry_count, 0, GET_ULONG,
    REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0},
   {"master-ssl", OPT_MASTER_SSL,
    "Enable the slave to connect to the master using SSL.",
-   (gptr*) &master_ssl, (gptr*) &master_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
+   (uchar**) &master_ssl, (uchar**) &master_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
    0, 0},
   {"master-ssl-ca", OPT_MASTER_SSL_CA,
    "Master SSL CA file. Only applies if you have enabled master-ssl.",
-   (gptr*) &master_ssl_ca, (gptr*) &master_ssl_ca, 0, GET_STR, OPT_ARG,
+   (uchar**) &master_ssl_ca, (uchar**) &master_ssl_ca, 0, GET_STR, OPT_ARG,
    0, 0, 0, 0, 0, 0},
   {"master-ssl-capath", OPT_MASTER_SSL_CAPATH,
    "Master SSL CA path. Only applies if you have enabled master-ssl.",
-   (gptr*) &master_ssl_capath, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG,
+   (uchar**) &master_ssl_capath, (uchar**) &master_ssl_capath, 0, GET_STR,
OPT_ARG,
    0, 0, 0, 0, 0, 0},
   {"master-ssl-cert", OPT_MASTER_SSL_CERT,
    "Master SSL certificate file name. Only applies if you have enabled \
 master-ssl",
-   (gptr*) &master_ssl_cert, (gptr*) &master_ssl_cert, 0, GET_STR, OPT_ARG,
+   (uchar**) &master_ssl_cert, (uchar**) &master_ssl_cert, 0, GET_STR, OPT_ARG,
    0, 0, 0, 0, 0, 0},
   {"master-ssl-cipher", OPT_MASTER_SSL_CIPHER,
    "Master SSL cipher. Only applies if you have enabled master-ssl.",
-   (gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG,
+   (uchar**) &master_ssl_cipher, (uchar**) &master_ssl_capath, 0, GET_STR,
OPT_ARG,
    0, 0, 0, 0, 0, 0},
   {"master-ssl-key", OPT_MASTER_SSL_KEY,
    "Master SSL keyfile name. Only applies if you have enabled master-ssl.",
-   (gptr*) &master_ssl_key, (gptr*) &master_ssl_key, 0, GET_STR, OPT_ARG,
+   (uchar**) &master_ssl_key, (uchar**) &master_ssl_key, 0, GET_STR, OPT_ARG,
    0, 0, 0, 0, 0, 0},
   {"master-user", OPT_MASTER_USER,
    "The username the slave thread will use for authentication when connecting to the
master. The user must have FILE privilege. If the master user is not set, user test is
assumed. The value in master.info will take precedence if it can be read.",
-   (gptr*) &master_user, (gptr*) &master_user, 0, GET_STR, REQUIRED_ARG, 0, 0,
+   (uchar**) &master_user, (uchar**) &master_user, 0, GET_STR, REQUIRED_ARG, 0,
0,
    0, 0, 0, 0},
 #ifdef HAVE_REPLICATION
   {"max-binlog-dump-events", OPT_MAX_BINLOG_DUMP_EVENTS,
    "Option used by mysql-test for debugging and testing of replication.",
-   (gptr*) &max_binlog_dump_events, (gptr*) &max_binlog_dump_events, 0,
+   (uchar**) &max_binlog_dump_events, (uchar**) &max_binlog_dump_events, 0,
    GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #endif /* HAVE_REPLICATION */
-  {"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (gptr*) &locked_in_memory,
-   (gptr*) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (uchar**) &locked_in_memory,
+   (uchar**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"myisam-recover", OPT_MYISAM_RECOVER,
    "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP,
FORCE or QUICK.",
-   (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0,
+   (uchar**) &myisam_recover_options_str, (uchar**) &myisam_recover_options_str,
0,
    GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
   {"ndb-connectstring", OPT_NDB_CONNECTSTRING,
    "Connect string for ndbcluster.",
-   (gptr*) &opt_ndb_connectstring,
-   (gptr*) &opt_ndb_connectstring,
+   (uchar**) &opt_ndb_connectstring,
+   (uchar**) &opt_ndb_connectstring,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"ndb-mgmd-host", OPT_NDB_MGMD,
    "Set host and port for ndb_mgmd. Syntax: hostname[:port]",
-   (gptr*) &opt_ndb_mgmd,
-   (gptr*) &opt_ndb_mgmd,
+   (uchar**) &opt_ndb_mgmd,
+   (uchar**) &opt_ndb_mgmd,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"ndb-nodeid", OPT_NDB_NODEID,
    "Nodeid for this mysqlserver in the cluster.",
-   (gptr*) &opt_ndb_nodeid,
-   (gptr*) &opt_ndb_nodeid,
+   (uchar**) &opt_ndb_nodeid,
+   (uchar**) &opt_ndb_nodeid,
    0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"ndb-autoincrement-prefetch-sz", OPT_NDB_AUTOINCREMENT_PREFETCH_SZ,
    "Specify number of autoincrement values that are prefetched.",
-   (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz,
-   (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz,
+   (uchar**) &global_system_variables.ndb_autoincrement_prefetch_sz,
+   (uchar**) &global_system_variables.ndb_autoincrement_prefetch_sz,
    0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0},
   {"ndb-distribution", OPT_NDB_DISTRIBUTION,
    "Default distribution for new tables in ndb",
-   (gptr*) &opt_ndb_distribution,
-   (gptr*) &opt_ndb_distribution,
+   (uchar**) &opt_ndb_distribution,
+   (uchar**) &opt_ndb_distribution,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"ndb-force-send", OPT_NDB_FORCE_SEND,
    "Force send of buffers to ndb immediately without waiting for "
    "other threads.",
-   (gptr*) &global_system_variables.ndb_force_send,
-   (gptr*) &global_system_variables.ndb_force_send,
+   (uchar**) &global_system_variables.ndb_force_send,
+   (uchar**) &global_system_variables.ndb_force_send,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
   {"ndb_force_send", OPT_NDB_FORCE_SEND,
    "same as --ndb-force-send.",
-   (gptr*) &global_system_variables.ndb_force_send,
-   (gptr*) &global_system_variables.ndb_force_send,
+   (uchar**) &global_system_variables.ndb_force_send,
+   (uchar**) &global_system_variables.ndb_force_send,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
   {"ndb-extra-logging", OPT_NDB_EXTRA_LOGGING,
    "Turn on more logging in the error log.",
-   (gptr*) &ndb_extra_logging,
-   (gptr*) &ndb_extra_logging,
+   (uchar**) &ndb_extra_logging,
+   (uchar**) &ndb_extra_logging,
    0, GET_INT, OPT_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef HAVE_NDB_BINLOG
   {"ndb-report-thresh-binlog-epoch-slip", OPT_NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP,
@@ -5474,16 +5525,16 @@
    "E.g. 3 means that if the difference between what epoch has been received "
    "from the storage nodes and what has been applied to the binlog is 3 or more, "
    "a status message will be sent to the cluster log.",
-   (gptr*) &ndb_report_thresh_binlog_epoch_slip,
-   (gptr*) &ndb_report_thresh_binlog_epoch_slip,
+   (uchar**) &ndb_report_thresh_binlog_epoch_slip,
+   (uchar**) &ndb_report_thresh_binlog_epoch_slip,
    0, GET_ULONG, REQUIRED_ARG, 3, 0, 256, 0, 0, 0},
   {"ndb-report-thresh-binlog-mem-usage", OPT_NDB_REPORT_THRESH_BINLOG_MEM_USAGE,
    "Threshold on percentage of free memory before reporting binlog status. E.g. "
    "10 means that if amount of available memory for receiving binlog data from "
    "the storage nodes goes below 10%, "
    "a status message will be sent to the cluster log.",
-   (gptr*) &ndb_report_thresh_binlog_mem_usage,
-   (gptr*) &ndb_report_thresh_binlog_mem_usage,
+   (uchar**) &ndb_report_thresh_binlog_mem_usage,
+   (uchar**) &ndb_report_thresh_binlog_mem_usage,
    0, GET_ULONG, REQUIRED_ARG, 10, 0, 100, 0, 0, 0},
   {"ndb-log-update-as-write", OPT_NDB_LOG_UPDATE_AS_WRITE,
    "For efficiency log only after image as a write event."
@@ -5504,107 +5555,107 @@
   {"ndb-use-exact-count", OPT_NDB_USE_EXACT_COUNT,
    "Use exact records count during query planning and for fast "
    "select count(*), disable for faster queries.",
-   (gptr*) &global_system_variables.ndb_use_exact_count,
-   (gptr*) &global_system_variables.ndb_use_exact_count,
+   (uchar**) &global_system_variables.ndb_use_exact_count,
+   (uchar**) &global_system_variables.ndb_use_exact_count,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
   {"ndb_use_exact_count", OPT_NDB_USE_EXACT_COUNT,
    "same as --ndb-use-exact-count.",
-   (gptr*) &global_system_variables.ndb_use_exact_count,
-   (gptr*) &global_system_variables.ndb_use_exact_count,
+   (uchar**) &global_system_variables.ndb_use_exact_count,
+   (uchar**) &global_system_variables.ndb_use_exact_count,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
   {"ndb-use-transactions", OPT_NDB_USE_TRANSACTIONS,
    "Use transactions for large inserts, if enabled then large "
    "inserts will be split into several smaller transactions",
-   (gptr*) &global_system_variables.ndb_use_transactions,
-   (gptr*) &global_system_variables.ndb_use_transactions,
+   (uchar**) &global_system_variables.ndb_use_transactions,
+   (uchar**) &global_system_variables.ndb_use_transactions,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
   {"ndb_use_transactions", OPT_NDB_USE_TRANSACTIONS,
    "same as --ndb-use-transactions.",
-   (gptr*) &global_system_variables.ndb_use_transactions,
-   (gptr*) &global_system_variables.ndb_use_transactions,
+   (uchar**) &global_system_variables.ndb_use_transactions,
+   (uchar**) &global_system_variables.ndb_use_transactions,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
   {"ndb-shm", OPT_NDB_SHM,
    "Use shared memory connections when available.",
-   (gptr*) &opt_ndb_shm,
-   (gptr*) &opt_ndb_shm,
+   (uchar**) &opt_ndb_shm,
+   (uchar**) &opt_ndb_shm,
    0, GET_BOOL, OPT_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0},
   {"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION,
    "Select nodes for transactions in a more optimal way.",
-   (gptr*) &opt_ndb_optimized_node_selection,
-   (gptr*) &opt_ndb_optimized_node_selection,
+   (uchar**) &opt_ndb_optimized_node_selection,
+   (uchar**) &opt_ndb_optimized_node_selection,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
   { "ndb-cache-check-time", OPT_NDB_CACHE_CHECK_TIME,
     "A dedicated thread is created to, at the given millisecons interval, invalidate the
query cache if another MySQL server in the cluster has changed the data in the
database.",
-    (gptr*) &opt_ndb_cache_check_time, (gptr*) &opt_ndb_cache_check_time, 0,
GET_ULONG, REQUIRED_ARG,
+    (uchar**) &opt_ndb_cache_check_time, (uchar**) &opt_ndb_cache_check_time, 0,
GET_ULONG, REQUIRED_ARG,
     0, 0, LONG_TIMEOUT, 0, 1, 0},
   {"ndb-index-stat-enable", OPT_NDB_INDEX_STAT_ENABLE,
    "Use ndb index statistics in query optimization.",
-   (gptr*) &global_system_variables.ndb_index_stat_enable,
-   (gptr*) &max_system_variables.ndb_index_stat_enable,
+   (uchar**) &global_system_variables.ndb_index_stat_enable,
+   (uchar**) &max_system_variables.ndb_index_stat_enable,
    0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 0, 0},
   {"ndb-use-copying-alter-table",
    OPT_NDB_USE_COPYING_ALTER_TABLE,
    "Force ndbcluster to always copy tables at alter table (should only be used if on-line
alter table fails).",
-   (gptr*) &global_system_variables.ndb_use_copying_alter_table,
-   (gptr*) &global_system_variables.ndb_use_copying_alter_table,
+   (uchar**) &global_system_variables.ndb_use_copying_alter_table,
+   (uchar**) &global_system_variables.ndb_use_copying_alter_table,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  
   { "ndb-wait-connected", OPT_NDB_WAIT_CONNECTED,
     "Time (in seconds) for mysqld to wait for connection to cluster management and data
nodes.",
-    (gptr*) &opt_ndb_wait_connected, (gptr*) &opt_ndb_wait_connected,
+    (uchar**) &opt_ndb_wait_connected, (uchar**) &opt_ndb_wait_connected,
     0, GET_ULONG, REQUIRED_ARG, 0, 0, LONG_TIMEOUT, 0, 0, 0},
   { "ndb-cluster-connection-pool", OPT_NDB_CLUSTER_CONNECTION_POOL,
     "Pool of cluster connections to cluster to be used by mysql server.",
-    (gptr*) &opt_ndb_cluster_connection_pool,
-    (gptr*) &opt_ndb_cluster_connection_pool,
+    (uchar**) &opt_ndb_cluster_connection_pool,
+    (uchar**) &opt_ndb_cluster_connection_pool,
     0, GET_ULONG, REQUIRED_ARG, 1, 1, 63, 0, 0, 0},
 #endif
   {"new", 'n', "Use very new possible 'unsafe' functions.",
-   (gptr*) &global_system_variables.new_mode,
-   (gptr*) &max_system_variables.new_mode,
+   (uchar**) &global_system_variables.new_mode,
+   (uchar**) &max_system_variables.new_mode,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef NOT_YET
   {"no-mix-table-types", OPT_NO_MIX_TYPE, "Don't allow commands with uses two different
table types.",
-   (gptr*) &opt_no_mix_types, (gptr*) &opt_no_mix_types, 0, GET_BOOL, NO_ARG,
+   (uchar**) &opt_no_mix_types, (uchar**) &opt_no_mix_types, 0, GET_BOOL, NO_ARG,
    0, 0, 0, 0, 0, 0},
 #endif
   {"old-alter-table", OPT_OLD_ALTER_TABLE,
    "Use old, non-optimized alter table.",
-   (gptr*) &global_system_variables.old_alter_table,
-   (gptr*) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
+   (uchar**) &global_system_variables.old_alter_table,
+   (uchar**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
    0, 0, 0, 0, 0, 0},
   {"old-passwords", OPT_OLD_PASSWORDS, "Use old password encryption method (needed for
4.0 and older clients).",
-   (gptr*) &global_system_variables.old_passwords,
-   (gptr*) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG,
+   (uchar**) &global_system_variables.old_passwords,
+   (uchar**) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG,
    0, 0, 0, 0, 0, 0},
   {"one-thread", OPT_ONE_THREAD,
    "(deprecated): Only use one thread (for debugging under Linux). Use
thread-handling=no-threads instead",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS,
    "Enable old-style user limits (before 5.0.3 user resources were counted per each
user+host vs. per account)",
-   (gptr*) &opt_old_style_user_limits, (gptr*) &opt_old_style_user_limits,
+   (uchar**) &opt_old_style_user_limits, (uchar**) &opt_old_style_user_limits,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.",
-   (gptr*) &pidfile_name_ptr, (gptr*) &pidfile_name_ptr, 0, GET_STR,
+   (uchar**) &pidfile_name_ptr, (uchar**) &pidfile_name_ptr, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"port", 'P', "Port number to use for connection.", (gptr*) &mysqld_port,
-   (gptr*) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"port", 'P', "Port number to use for connection.", (uchar**) &mysqld_port,
+   (uchar**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
    "Maximum time in seconds to wait for the port to become free. "
-   "(Default: no wait)", (gptr*) &mysqld_port_timeout,
-   (gptr*) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+   "(Default: no wait)", (uchar**) &mysqld_port_timeout,
+   (uchar**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"relay-log", OPT_RELAY_LOG,
    "The location and name to use for relay logs.",
-   (gptr*) &opt_relay_logname, (gptr*) &opt_relay_logname, 0,
+   (uchar**) &opt_relay_logname, (uchar**) &opt_relay_logname, 0,
    GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"relay-log-index", OPT_RELAY_LOG_INDEX,
    "The location and name to use for the file that keeps a list of the last \
 relay logs.",
-   (gptr*) &opt_relaylog_index_name, (gptr*) &opt_relaylog_index_name, 0,
+   (uchar**) &opt_relaylog_index_name, (uchar**) &opt_relaylog_index_name, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE,
    "The location and name of the file that remembers where the SQL replication \
 thread is in the relay logs.",
-   (gptr*) &relay_log_info_file, (gptr*) &relay_log_info_file, 0, GET_STR,
+   (uchar**) &relay_log_info_file, (uchar**) &relay_log_info_file, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"replicate-do-db", OPT_REPLICATE_DO_DB,
    "Tells the slave thread to restrict replication to the specified database. To specify
more than one database, use the directive multiple times, once for each database. Note
that this will only work if you do not use cross-database queries such as UPDATE
some_db.some_table SET foo='bar' while having selected a different or no database. If you
need cross database updates to work, make sure you have 3.23.28 or later, and use
replicate-wild-do-table=db_name.%.",
@@ -5626,8 +5677,8 @@
    "In replication, if set to 1, do not skip events having our server id. \
 Default value is 0 (to break infinite loops in circular replication). \
 Can't be set to 1 if --log-slave-updates is used.",
-   (gptr*) &replicate_same_server_id,
-   (gptr*) &replicate_same_server_id,
+   (uchar**) &replicate_same_server_id,
+   (uchar**) &replicate_same_server_id,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE,
@@ -5639,19 +5690,19 @@
   // In replication, we may need to tell the other servers how to connect
   {"report-host", OPT_REPORT_HOST,
    "Hostname or IP of the slave to be reported to to the master during slave
registration. Will appear in the output of SHOW SLAVE HOSTS. Leave unset if you do not
want the slave to register itself with the master. Note that it is not sufficient for the
master to simply read the IP of the slave off the socket once the slave connects. Due to
NAT and other routing issues, that IP may not be valid for connecting to the slave from
the master or other hosts.",
-   (gptr*) &report_host, (gptr*) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
+   (uchar**) &report_host, (uchar**) &report_host, 0, GET_STR, REQUIRED_ARG, 0,
0,
    0, 0, 0, 0},
   {"report-password", OPT_REPORT_PASSWORD, "Undocumented.",
-   (gptr*) &report_password, (gptr*) &report_password, 0, GET_STR,
+   (uchar**) &report_password, (uchar**) &report_password, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"report-port", OPT_REPORT_PORT,
    "Port for connecting to slave reported to the master during slave registration. Set it
only if the slave is listening on a non-default port or if you have a special tunnel from
the master or other clients to the slave. If not sure, leave this option unset.",
-   (gptr*) &report_port, (gptr*) &report_port, 0, GET_UINT, REQUIRED_ARG,
+   (uchar**) &report_port, (uchar**) &report_port, 0, GET_UINT, REQUIRED_ARG,
    MYSQL_PORT, 0, 0, 0, 0, 0},
-  {"report-user", OPT_REPORT_USER, "Undocumented.", (gptr*) &report_user,
-   (gptr*) &report_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"report-user", OPT_REPORT_USER, "Undocumented.", (uchar**) &report_user,
+   (uchar**) &report_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
-   (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
+   (uchar**) &rpl_recovery_rank, (uchar**) &rpl_recovery_rank, 0, GET_ULONG,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -5662,43 +5713,43 @@
 #endif
   {"safe-user-create", OPT_SAFE_USER_CREATE,
    "Don't allow new user creation by the user who has no write privileges to the
mysql.user table.",
-   (gptr*) &opt_safe_user_create, (gptr*) &opt_safe_user_create, 0, GET_BOOL,
+   (uchar**) &opt_safe_user_create, (uchar**) &opt_safe_user_create, 0, GET_BOOL,
    NO_ARG, 0, 0, 0, 0, 0, 0},
   {"safemalloc-mem-limit", OPT_SAFEMALLOC_MEM_LIMIT,
    "Simulate memory shortage when compiled with the --with-debug=full option.",
    0, 0, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"secure-auth", OPT_SECURE_AUTH, "Disallow authentication for accounts that have old
(pre-4.1) passwords.",
-   (gptr*) &opt_secure_auth, (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG,
+   (uchar**) &opt_secure_auth, (uchar**) &opt_secure_auth, 0, GET_BOOL, NO_ARG,
    my_bool(0), 0, 0, 0, 0, 0},
   {"secure-file-priv", OPT_SECURE_FILE_PRIV,
    "Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files within specified
directory",
-   (gptr*) &opt_secure_file_priv, (gptr*) &opt_secure_file_priv, 0,
+   (uchar**) &opt_secure_file_priv, (uchar**) &opt_secure_file_priv, 0,
    GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"server-id",	OPT_SERVER_ID,
    "Uniquely identifies the server instance in the community of replication partners.",
-   (gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
+   (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0,
0,
    0, 0, 0},
   {"set-variable", 'O',
    "Change the value of a variable. Please note that this option is deprecated;you can
set variables directly with --variable-name=value.",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef HAVE_SMEM
   {"shared-memory", OPT_ENABLE_SHARED_MEMORY,
-   "Enable the shared memory.",(gptr*) &opt_enable_shared_memory, (gptr*)
&opt_enable_shared_memory,
+   "Enable the shared memory.",(uchar**) &opt_enable_shared_memory, (uchar**)
&opt_enable_shared_memory,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
 #ifdef HAVE_SMEM
   {"shared-memory-base-name",OPT_SHARED_MEMORY_BASE_NAME,
-   "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*)
&shared_memory_base_name,
+   "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**)
&shared_memory_base_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO,
    "Show user and password in SHOW SLAVE HOSTS on this master",
-   (gptr*) &opt_show_slave_auth_info, (gptr*) &opt_show_slave_auth_info, 0,
+   (uchar**) &opt_show_slave_auth_info, (uchar**) &opt_show_slave_auth_info, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 #ifndef DISABLE_GRANT_OPTIONS
   {"skip-grant-tables", OPT_SKIP_GRANT,
    "Start without grant tables. This gives all users FULL ACCESS to all tables!",
-   (gptr*) &opt_noacl, (gptr*) &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+   (uchar**) &opt_noacl, (uchar**) &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0,
    0},
 #endif
   {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names.", 0, 0, 0,
@@ -5725,8 +5776,8 @@
    "Don't allow 'SHOW DATABASE' commands.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
    0, 0, 0, 0},
   {"skip-slave-start", OPT_SKIP_SLAVE_START,
-   "If set, slave is not autostarted.", (gptr*) &opt_skip_slave_start,
-   (gptr*) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+   "If set, slave is not autostarted.", (uchar**) &opt_skip_slave_start,
+   (uchar**) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"skip-stack-trace", OPT_SKIP_STACK_TRACE,
    "Don't print a stack trace on failure.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
    0, 0, 0, 0},
@@ -5739,23 +5790,23 @@
   {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR,
    "The location where the slave should put its temporary files when \
 replicating a LOAD DATA INFILE command.",
-   (gptr*) &slave_load_tmpdir, (gptr*) &slave_load_tmpdir, 0, GET_STR_ALLOC,
+   (uchar**) &slave_load_tmpdir, (uchar**) &slave_load_tmpdir, 0, GET_STR_ALLOC,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"slave-skip-errors", OPT_SLAVE_SKIP_ERRORS,
    "Tells the slave thread to continue replication when a query returns an error from the
provided list.",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"slow-query-log", OPT_SLOW_LOG,
-   "Enable|disable slow query log", (gptr*) &opt_slow_log,
-   (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
+   "Enable|disable slow query log", (uchar**) &opt_slow_log,
+   (uchar**) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"socket", OPT_SOCKET, "Socket file to use for connection.",
-   (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
+   (uchar**) &mysqld_unix_port, (uchar**) &mysqld_unix_port, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #ifdef HAVE_REPLICATION
   {"sporadic-binlog-dump-fail", OPT_SPORADIC_BINLOG_DUMP_FAIL,
    "Option used by mysql-test for debugging and testing of replication.",
-   (gptr*) &opt_sporadic_binlog_dump_fail,
-   (gptr*) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+   (uchar**) &opt_sporadic_binlog_dump_fail,
+   (uchar**) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
    0},
 #endif /* HAVE_REPLICATION */
   {"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME,
@@ -5764,7 +5815,7 @@
    0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"sql-mode", OPT_SQL_MODE,
    "Syntax: sql-mode=option[,option[,option...]] where option can be one of:
REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, ONLY_FULL_GROUP_BY,
NO_UNSIGNED_SUBTRACTION.",
-   (gptr*) &sql_mode_str, (gptr*) &sql_mode_str, 0, GET_STR, REQUIRED_ARG, 0,
+   (uchar**) &sql_mode_str, (uchar**) &sql_mode_str, 0, GET_STR, REQUIRED_ARG, 0,
    0, 0, 0, 0, 0},
 #ifdef HAVE_OPENSSL
 #include "sslopt-longopts.h"
@@ -5775,7 +5826,7 @@
    NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"symbolic-links", 's', "Enable symbolic link support.",
-   (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
+   (uchar**) &my_use_symdir, (uchar**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
    /*
      The system call realpath() produces warnings under valgrind and
      purify. These are not suppressed: instead we disable symlinks
@@ -5784,19 +5835,19 @@
    IF_PURIFY(0,1), 0, 0, 0, 0, 0},
   {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
    "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0,
SYSDATE() returns a `dynamic' value different for different invocations, even within the
same statement.",
-   (gptr*) &global_system_variables.sysdate_is_now,
+   (uchar**) &global_system_variables.sysdate_is_now,
    0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
   {"tc-heuristic-recover", OPT_TC_HEURISTIC_RECOVER,
    "Decision to use in heuristic recover process. Possible values are COMMIT or
ROLLBACK.",
-   (gptr*) &opt_tc_heuristic_recover, (gptr*) &opt_tc_heuristic_recover,
+   (uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"temp-pool", OPT_TEMP_POOL,
    "Using this option will cause most temporary files created to use a small set of
names, rather than a unique name for each new file.",
-   (gptr*) &use_temp_pool, (gptr*) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1,
+   (uchar**) &use_temp_pool, (uchar**) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1,
    0, 0, 0, 0, 0},
   {"timed_mutexes", OPT_TIMED_MUTEXES,
    "Specify whether to time mutexes (only InnoDB mutexes are currently supported)",
-   (gptr*) &timed_mutexes, (gptr*) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, 
+   (uchar**) &timed_mutexes, (uchar**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, 
     0, 0, 0, 0, 0},
   {"tmpdir", 't',
    "Path for temporary files. Several paths may be specified, separated by a "
@@ -5806,83 +5857,83 @@
    "colon (:)"
 #endif
    ", in this case they are used in a round-robin fashion.",
-   (gptr*) &opt_mysql_tmpdir,
-   (gptr*) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+   (uchar**) &opt_mysql_tmpdir,
+   (uchar**) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"transaction-isolation", OPT_TX_ISOLATION,
    "Default transaction isolation level.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0,
    0, 0, 0, 0, 0},
   {"use-symbolic-links", 's', "Enable symbolic link support. Deprecated option; use
--symbolic-links instead.",
-   (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
+   (uchar**) &my_use_symdir, (uchar**) &my_use_symdir, 0, GET_BOOL, NO_ARG,
    IF_PURIFY(0,1), 0, 0, 0, 0, 0},
   {"user", 'u', "Run mysqld daemon as user.", 0, 0, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0},
   {"verbose", 'v', "Used with --help option for detailed help",
-   (gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
+   (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0,
    0, 0},
   {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
   {"warnings", 'W', "Deprecated; use --log-warnings instead.",
-   (gptr*) &global_system_variables.log_warnings,
-   (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L,
+   (uchar**) &global_system_variables.log_warnings,
+   (uchar**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L,
    0, 0, 0},
   { "back_log", OPT_BACK_LOG,
     "The number of outstanding connection requests MySQL can have. This comes into play
when the main MySQL thread gets very many connection requests in a very short time.",
-    (gptr*) &back_log, (gptr*) &back_log, 0, GET_ULONG,
+    (uchar**) &back_log, (uchar**) &back_log, 0, GET_ULONG,
     REQUIRED_ARG, 50, 1, 65535, 0, 1, 0 },
   {"binlog_cache_size", OPT_BINLOG_CACHE_SIZE,
    "The size of the cache to hold the SQL statements for the binary log during a
transaction. If you often use big, multi-statement transactions you can increase this to
get more performance.",
-   (gptr*) &binlog_cache_size, (gptr*) &binlog_cache_size, 0, GET_ULONG,
+   (uchar**) &binlog_cache_size, (uchar**) &binlog_cache_size, 0, GET_ULONG,
    REQUIRED_ARG, 32*1024L, IO_SIZE, ~0L, 0, IO_SIZE, 0},
   {"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
    "Size of tree cache used in bulk insert optimisation. Note that this is a limit per
thread!",
-   (gptr*) &global_system_variables.bulk_insert_buff_size,
-   (gptr*) &max_system_variables.bulk_insert_buff_size,
+   (uchar**) &global_system_variables.bulk_insert_buff_size,
+   (uchar**) &max_system_variables.bulk_insert_buff_size,
    0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ~0L, 0, 1, 0},
   {"connect_timeout", OPT_CONNECT_TIMEOUT,
    "The number of seconds the mysqld server is waiting for a connect packet before
responding with 'Bad handshake'.",
-    (gptr*) &connect_timeout, (gptr*) &connect_timeout,
+    (uchar**) &connect_timeout, (uchar**) &connect_timeout,
    0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
   { "date_format", OPT_DATE_FORMAT,
     "The DATE format (For future).",
-    (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE],
-    (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE],
+    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE],
+    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE],
     0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   { "datetime_format", OPT_DATETIME_FORMAT,
     "The DATETIME/TIMESTAMP format (for future).",
-    (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME],
-    (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME],
+    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME],
+    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME],
     0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   { "default_week_format", OPT_DEFAULT_WEEK_FORMAT,
     "The default week format used by WEEK() functions.",
-    (gptr*) &global_system_variables.default_week_format,
-    (gptr*) &max_system_variables.default_week_format,
+    (uchar**) &global_system_variables.default_week_format,
+    (uchar**) &max_system_variables.default_week_format,
     0, GET_ULONG, REQUIRED_ARG, 0, 0, 7L, 0, 1, 0},
   {"delayed_insert_limit", OPT_DELAYED_INSERT_LIMIT,
    "After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if
there are any SELECT statements pending. If so, it allows these to execute before
continuing.",
-    (gptr*) &delayed_insert_limit, (gptr*) &delayed_insert_limit, 0, GET_ULONG,
+    (uchar**) &delayed_insert_limit, (uchar**) &delayed_insert_limit, 0,
GET_ULONG,
     REQUIRED_ARG, DELAYED_LIMIT, 1, ~0L, 0, 1, 0},
   {"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT,
    "How long a INSERT DELAYED thread should wait for INSERT statements before
terminating.",
-   (gptr*) &delayed_insert_timeout, (gptr*) &delayed_insert_timeout, 0,
+   (uchar**) &delayed_insert_timeout, (uchar**) &delayed_insert_timeout, 0,
    GET_ULONG, REQUIRED_ARG, DELAYED_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
   { "delayed_queue_size", OPT_DELAYED_QUEUE_SIZE,
     "What size queue (in rows) should be allocated for handling INSERT DELAYED. If the
queue becomes full, any client that does INSERT DELAYED will wait until there is room in
the queue again.",
-    (gptr*) &delayed_queue_size, (gptr*) &delayed_queue_size, 0, GET_ULONG,
+    (uchar**) &delayed_queue_size, (uchar**) &delayed_queue_size, 0, GET_ULONG,
     REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, ~0L, 0, 1, 0},
   {"div_precision_increment", OPT_DIV_PRECINCREMENT,
    "Precision of the result of '/' operator will be increased on that value.",
-   (gptr*) &global_system_variables.div_precincrement,
-   (gptr*) &max_system_variables.div_precincrement, 0, GET_ULONG,
+   (uchar**) &global_system_variables.div_precincrement,
+   (uchar**) &max_system_variables.div_precincrement, 0, GET_ULONG,
    REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0},
   {"expire_logs_days", OPT_EXPIRE_LOGS_DAYS,
    "If non-zero, binary logs will be purged after expire_logs_days "
    "days; possible purges happen at startup and at binary log rotation.",
-   (gptr*) &expire_logs_days,
-   (gptr*) &expire_logs_days, 0, GET_ULONG,
+   (uchar**) &expire_logs_days,
+   (uchar**) &expire_logs_days, 0, GET_ULONG,
    REQUIRED_ARG, 0, 0, 99, 0, 1, 0},
   { "flush_time", OPT_FLUSH_TIME,
     "A dedicated thread is created to flush all tables at the given interval.",
-    (gptr*) &flush_time, (gptr*) &flush_time, 0, GET_ULONG, REQUIRED_ARG,
+    (uchar**) &flush_time, (uchar**) &flush_time, 0, GET_ULONG, REQUIRED_ARG,
     FLUSH_TIME, 0, LONG_TIMEOUT, 0, 1, 0},
   { "ft_boolean_syntax", OPT_FT_BOOLEAN_SYNTAX,
     "List of operators for MATCH ... AGAINST ( ... IN BOOLEAN MODE)",
@@ -5890,70 +5941,70 @@
     REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   { "ft_max_word_len", OPT_FT_MAX_WORD_LEN,
     "The maximum length of the word to be included in a FULLTEXT index. Note: FULLTEXT
indexes must be rebuilt after changing this variable.",
-    (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG,
+    (uchar**) &ft_max_word_len, (uchar**) &ft_max_word_len, 0, GET_ULONG,
     REQUIRED_ARG, HA_FT_MAXCHARLEN, 10, HA_FT_MAXCHARLEN, 0, 1, 0},
   { "ft_min_word_len", OPT_FT_MIN_WORD_LEN,
     "The minimum length of the word to be included in a FULLTEXT index. Note: FULLTEXT
indexes must be rebuilt after changing this variable.",
-    (gptr*) &ft_min_word_len, (gptr*) &ft_min_word_len, 0, GET_ULONG,
+    (uchar**) &ft_min_word_len, (uchar**) &ft_min_word_len, 0, GET_ULONG,
     REQUIRED_ARG, 4, 1, HA_FT_MAXCHARLEN, 0, 1, 0},
   { "ft_query_expansion_limit", OPT_FT_QUERY_EXPANSION_LIMIT,
     "Number of best matches to use for query expansion",
-    (gptr*) &ft_query_expansion_limit, (gptr*) &ft_query_expansion_limit, 0,
GET_ULONG,
+    (uchar**) &ft_query_expansion_limit, (uchar**) &ft_query_expansion_limit, 0,
GET_ULONG,
     REQUIRED_ARG, 20, 0, 1000, 0, 1, 0},
   { "ft_stopword_file", OPT_FT_STOPWORD_FILE,
     "Use stopwords from this file instead of built-in list.",
-    (gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR,
+    (uchar**) &ft_stopword_file, (uchar**) &ft_stopword_file, 0, GET_STR,
     REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
     "The maximum length of the result of function  group_concat.",
-    (gptr*) &global_system_variables.group_concat_max_len,
-    (gptr*) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
+    (uchar**) &global_system_variables.group_concat_max_len,
+    (uchar**) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
     REQUIRED_ARG, 1024, 4, (long) ~0, 0, 1, 0},
   {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
    "The number of seconds the server waits for activity on an interactive connection
before closing it.",
-   (gptr*) &global_system_variables.net_interactive_timeout,
-   (gptr*) &max_system_variables.net_interactive_timeout, 0,
+   (uchar**) &global_system_variables.net_interactive_timeout,
+   (uchar**) &max_system_variables.net_interactive_timeout, 0,
    GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
   {"join_buffer_size", OPT_JOIN_BUFF_SIZE,
    "The size of the buffer that is used for full joins.",
-   (gptr*) &global_system_variables.join_buff_size,
-   (gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG,
+   (uchar**) &global_system_variables.join_buff_size,
+   (uchar**) &max_system_variables.join_buff_size, 0, GET_ULONG,
    REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD,
    IO_SIZE, 0},
   {"key_buffer_size", OPT_KEY_BUFFER_SIZE,
    "The size of the buffer used for index blocks for MyISAM tables. Increase this to get
better index handling (for all reads and multiple writes) to as much as you can afford;
64M on a 256M machine that mainly runs MySQL is quite common.",
-   (gptr*) &dflt_key_cache_var.param_buff_size,
-   (gptr*) 0,
+   (uchar**) &dflt_key_cache_var.param_buff_size,
+   (uchar**) 0,
    0, (GET_ULL | GET_ASK_ADDR),
    REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD,
    IO_SIZE, 0},
   {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
    "This characterizes the number of hits a hot block has to be untouched until it is
considered aged enough to be downgraded to a warm block. This specifies the percentage
ratio of that number of hits to the total number of blocks in key cache",
-   (gptr*) &dflt_key_cache_var.param_age_threshold,
-   (gptr*) 0,
+   (uchar**) &dflt_key_cache_var.param_age_threshold,
+   (uchar**) 0,
    0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 
    300, 100, ~0L, 0, 100, 0},
   {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
    "The default size of key cache blocks",
-   (gptr*) &dflt_key_cache_var.param_block_size,
-   (gptr*) 0,
+   (uchar**) &dflt_key_cache_var.param_block_size,
+   (uchar**) 0,
    0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
-   KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0},
+   KEY_CACHE_BLOCK_SIZE, 512, 1024 * 16, 0, 512, 0},
   {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT,
    "The minimum percentage of warm blocks in key cache",
-   (gptr*) &dflt_key_cache_var.param_division_limit,
-   (gptr*) 0,
+   (uchar**) &dflt_key_cache_var.param_division_limit,
+   (uchar**) 0,
    0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
    1, 100, 0, 1, 0},
   {"long_query_time", OPT_LONG_QUERY_TIME,
    "Log all queries that have taken more than long_query_time seconds to execute to
file.",
-   (gptr*) &global_system_variables.long_query_time,
-   (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
+   (uchar**) &global_system_variables.long_query_time,
+   (uchar**) &max_system_variables.long_query_time, 0, GET_ULONG,
    REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
   {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
    "If set to 1 table names are stored in lowercase on disk and table names will be
case-insensitive.  Should be set to 2 if you are using a case insensitive file system",
-   (gptr*) &lower_case_table_names,
-   (gptr*) &lower_case_table_names, 0, GET_UINT, OPT_ARG,
+   (uchar**) &lower_case_table_names,
+   (uchar**) &lower_case_table_names, 0, GET_UINT, OPT_ARG,
 #ifdef FN_NO_CASE_SENCE
     1
 #else
@@ -5962,360 +6013,360 @@
    , 0, 2, 0, 1, 0},
   {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
    "Max packetlength to send/receive from to server.",
-   (gptr*) &global_system_variables.max_allowed_packet,
-   (gptr*) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
+   (uchar**) &global_system_variables.max_allowed_packet,
+   (uchar**) &max_system_variables.max_allowed_packet, 0, GET_ULONG,
    REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
   {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
    "Can be used to restrict the total size used to cache a multi-transaction query.",
-   (gptr*) &max_binlog_cache_size, (gptr*) &max_binlog_cache_size, 0,
+   (uchar**) &max_binlog_cache_size, (uchar**) &max_binlog_cache_size, 0,
    GET_ULONG, REQUIRED_ARG, ~0L, IO_SIZE, ~0L, 0, IO_SIZE, 0},
   {"max_binlog_size", OPT_MAX_BINLOG_SIZE,
    "Binary log will be rotated automatically when the size exceeds this \
 value. Will also apply to relay logs if max_relay_log_size is 0. \
 The minimum value for this variable is 4096.",
-   (gptr*) &max_binlog_size, (gptr*) &max_binlog_size, 0, GET_ULONG,
+   (uchar**) &max_binlog_size, (uchar**) &max_binlog_size, 0, GET_ULONG,
    REQUIRED_ARG, 1024*1024L*1024L, IO_SIZE, 1024*1024L*1024L, 0, IO_SIZE, 0},
   {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
    "If there is more than this number of interrupted connections from a host this host
will be blocked from further connections.",
-   (gptr*) &max_connect_errors, (gptr*) &max_connect_errors, 0, GET_ULONG,
+   (uchar**) &max_connect_errors, (uchar**) &max_connect_errors, 0, GET_ULONG,
     REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0},
   // Default max_connections of 151 is larger than Apache's default max
   // children, to avoid "too many connections" error in a common setup
   {"max_connections", OPT_MAX_CONNECTIONS,
-   "The number of simultaneous clients allowed.", (gptr*) &max_connections,
-   (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
+   "The number of simultaneous clients allowed.", (uchar**) &max_connections,
+   (uchar**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1,
    0},
   {"max_delayed_threads", OPT_MAX_DELAYED_THREADS,
    "Don't start more than this number of threads to handle INSERT DELAYED statements. If
set to zero, which means INSERT DELAYED is not used.",
-   (gptr*) &global_system_variables.max_insert_delayed_threads,
-   (gptr*) &max_system_variables.max_insert_delayed_threads,
+   (uchar**) &global_system_variables.max_insert_delayed_threads,
+   (uchar**) &max_system_variables.max_insert_delayed_threads,
    0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0},
   {"max_error_count", OPT_MAX_ERROR_COUNT,
    "Max number of errors/warnings to store for a statement.",
-   (gptr*) &global_system_variables.max_error_count,
-   (gptr*) &max_system_variables.max_error_count,
+   (uchar**) &global_system_variables.max_error_count,
+   (uchar**) &max_system_variables.max_error_count,
    0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0},
   {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
    "Don't allow creation of heap tables bigger than this.",
-   (gptr*) &global_system_variables.max_heap_table_size,
-   (gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULL,
+   (uchar**) &global_system_variables.max_heap_table_size,
+   (uchar**) &max_system_variables.max_heap_table_size, 0, GET_ULL,
    REQUIRED_ARG, 16*1024*1024L, 16384, MAX_MEM_TABLE_SIZE,
    MALLOC_OVERHEAD, 1024, 0},
   {"max_join_size", OPT_MAX_JOIN_SIZE,
    "Joins that are probably going to read more than max_join_size records return an
error.",
-   (gptr*) &global_system_variables.max_join_size,
-   (gptr*) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG,
+   (uchar**) &global_system_variables.max_join_size,
+   (uchar**) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG,
    ~0L, 1, ~0L, 0, 1, 0},
    {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA,
     "Max number of bytes in sorted records.",
-    (gptr*) &global_system_variables.max_length_for_sort_data,
-    (gptr*) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG,
+    (uchar**) &global_system_variables.max_length_for_sort_data,
+    (uchar**) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG,
     REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
   {"max_prepared_stmt_count", OPT_MAX_PREPARED_STMT_COUNT,
    "Maximum number of prepared statements in the server.",
-   (gptr*) &max_prepared_stmt_count, (gptr*) &max_prepared_stmt_count,
+   (uchar**) &max_prepared_stmt_count, (uchar**) &max_prepared_stmt_count,
    0, GET_ULONG, REQUIRED_ARG, 16382, 0, 1*1024*1024, 0, 1, 0},
   {"max_relay_log_size", OPT_MAX_RELAY_LOG_SIZE,
    "If non-zero: relay log will be rotated automatically when the size exceeds this
value; if zero (the default): when the size exceeds max_binlog_size. 0 excepted, the
minimum value for this variable is 4096.",
-   (gptr*) &max_relay_log_size, (gptr*) &max_relay_log_size, 0, GET_ULONG,
+   (uchar**) &max_relay_log_size, (uchar**) &max_relay_log_size, 0, GET_ULONG,
    REQUIRED_ARG, 0L, 0L, 1024*1024L*1024L, 0, IO_SIZE, 0},
   { "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY,
     "Limit assumed max number of seeks when looking up rows based on a key",
-    (gptr*) &global_system_variables.max_seeks_for_key,
-    (gptr*) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
+    (uchar**) &global_system_variables.max_seeks_for_key,
+    (uchar**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
     REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0 },
   {"max_sort_length", OPT_MAX_SORT_LENGTH,
    "The number of bytes to use when sorting BLOB or TEXT values (only the first
max_sort_length bytes of each value are used; the rest are ignored).",
-   (gptr*) &global_system_variables.max_sort_length,
-   (gptr*) &max_system_variables.max_sort_length, 0, GET_ULONG,
+   (uchar**) &global_system_variables.max_sort_length,
+   (uchar**) &max_system_variables.max_sort_length, 0, GET_ULONG,
    REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0},
   {"max_sp_recursion_depth", OPT_MAX_SP_RECURSION_DEPTH,
    "Maximum stored procedure recursion depth. (discussed with docs).",
-   (gptr*) &global_system_variables.max_sp_recursion_depth,
-   (gptr*) &max_system_variables.max_sp_recursion_depth, 0, GET_ULONG,
+   (uchar**) &global_system_variables.max_sp_recursion_depth,
+   (uchar**) &max_system_variables.max_sp_recursion_depth, 0, GET_ULONG,
    OPT_ARG, 0, 0, 255, 0, 1, 0 },
   {"max_tmp_tables", OPT_MAX_TMP_TABLES,
    "Maximum number of temporary tables a client can keep open at a time.",
-   (gptr*) &global_system_variables.max_tmp_tables,
-   (gptr*) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
+   (uchar**) &global_system_variables.max_tmp_tables,
+   (uchar**) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
    REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0},
   {"max_user_connections", OPT_MAX_USER_CONNECTIONS,
    "The maximum number of active connections for a single user (0 = no limit).",
-   (gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT,
+   (uchar**) &max_user_connections, (uchar**) &max_user_connections, 0, GET_UINT,
    REQUIRED_ARG, 0, 1, ~0, 0, 1, 0},
   {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
    "After this many write locks, allow some read locks to run in between.",
-   (gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG,
+   (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0,
GET_ULONG,
    REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0},
   {"multi_range_count", OPT_MULTI_RANGE_COUNT,
    "Number of key ranges to request at once.",
-   (gptr*) &global_system_variables.multi_range_count,
-   (gptr*) &max_system_variables.multi_range_count, 0,
+   (uchar**) &global_system_variables.multi_range_count,
+   (uchar**) &max_system_variables.multi_range_count, 0,
    GET_ULONG, REQUIRED_ARG, 256, 1, ~0L, 0, 1, 0},
   {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
    "Block size to be used for MyISAM index pages.",
-   (gptr*) &opt_myisam_block_size,
-   (gptr*) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG,
+   (uchar**) &opt_myisam_block_size,
+   (uchar**) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG,
    MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH,
    0, MI_MIN_KEY_BLOCK_LENGTH, 0},
   {"myisam_data_pointer_size", OPT_MYISAM_DATA_POINTER_SIZE,
    "Default pointer size to be used for MyISAM tables.",
-   (gptr*) &myisam_data_pointer_size,
-   (gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
+   (uchar**) &myisam_data_pointer_size,
+   (uchar**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
    6, 2, 7, 0, 1, 0},
   {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
    "Deprecated option",
-   (gptr*) &global_system_variables.myisam_max_extra_sort_file_size,
-   (gptr*) &max_system_variables.myisam_max_extra_sort_file_size,
+   (uchar**) &global_system_variables.myisam_max_extra_sort_file_size,
+   (uchar**) &max_system_variables.myisam_max_extra_sort_file_size,
    0, GET_ULL, REQUIRED_ARG, (ulonglong) MI_MAX_TEMP_LENGTH,
    0, (ulonglong) MAX_FILE_SIZE, 0, 1, 0},
   {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE,
    "Don't use the fast sort index method to created index if the temporary file would get
bigger than this.",
-   (gptr*) &global_system_variables.myisam_max_sort_file_size,
-   (gptr*) &max_system_variables.myisam_max_sort_file_size, 0,
+   (uchar**) &global_system_variables.myisam_max_sort_file_size,
+   (uchar**) &max_system_variables.myisam_max_sort_file_size, 0,
    GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, (ulonglong) MAX_FILE_SIZE,
    0, 1024*1024, 0},
   {"myisam_repair_threads", OPT_MYISAM_REPAIR_THREADS,
    "Number of threads to use when repairing MyISAM tables. The value of 1 disables
parallel repair.",
-   (gptr*) &global_system_variables.myisam_repair_threads,
-   (gptr*) &max_system_variables.myisam_repair_threads, 0,
+   (uchar**) &global_system_variables.myisam_repair_threads,
+   (uchar**) &max_system_variables.myisam_repair_threads, 0,
    GET_ULONG, REQUIRED_ARG, 1, 1, ~0L, 0, 1, 0},
   {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
    "The buffer that is allocated when sorting the index when doing a REPAIR or when
creating indexes with CREATE INDEX or ALTER TABLE.",
-   (gptr*) &global_system_variables.myisam_sort_buff_size,
-   (gptr*) &max_system_variables.myisam_sort_buff_size, 0,
+   (uchar**) &global_system_variables.myisam_sort_buff_size,
+   (uchar**) &max_system_variables.myisam_sort_buff_size, 0,
    GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0},
   {"myisam_use_mmap", OPT_MYISAM_USE_MMAP,
    "Use memory mapping for reading and writing MyISAM tables",
-   (gptr*) &opt_myisam_use_mmap,
-   (gptr*) &opt_myisam_use_mmap, 0, GET_BOOL, NO_ARG, 0, 
+   (uchar**) &opt_myisam_use_mmap,
+   (uchar**) &opt_myisam_use_mmap, 0, GET_BOOL, NO_ARG, 0, 
     0, 0, 0, 0, 0},
   {"myisam_stats_method", OPT_MYISAM_STATS_METHOD,
    "Specifies how MyISAM index statistics collection code should threat NULLs. "
    "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), "
    "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".",
-   (gptr*) &myisam_stats_method_str, (gptr*) &myisam_stats_method_str, 0,
+   (uchar**) &myisam_stats_method_str, (uchar**) &myisam_stats_method_str, 0,
     GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"net_buffer_length", OPT_NET_BUFFER_LENGTH,
    "Buffer length for TCP/IP and socket communication.",
-   (gptr*) &global_system_variables.net_buffer_length,
-   (gptr*) &max_system_variables.net_buffer_length, 0, GET_ULONG,
+   (uchar**) &global_system_variables.net_buffer_length,
+   (uchar**) &max_system_variables.net_buffer_length, 0, GET_ULONG,
    REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0},
   {"net_read_timeout", OPT_NET_READ_TIMEOUT,
    "Number of seconds to wait for more data from a connection before aborting the read.",
-   (gptr*) &global_system_variables.net_read_timeout,
-   (gptr*) &max_system_variables.net_read_timeout, 0, GET_ULONG,
+   (uchar**) &global_system_variables.net_read_timeout,
+   (uchar**) &max_system_variables.net_read_timeout, 0, GET_ULONG,
    REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
   {"net_retry_count", OPT_NET_RETRY_COUNT,
    "If a read on a communication port is interrupted, retry this many times before giving
up.",
-   (gptr*) &global_system_variables.net_retry_count,
-   (gptr*) &max_system_variables.net_retry_count,0,
+   (uchar**) &global_system_variables.net_retry_count,
+   (uchar**) &max_system_variables.net_retry_count,0,
    GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1, 0},
   {"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
    "Number of seconds to wait for a block to be written to a connection  before aborting
the write.",
-   (gptr*) &global_system_variables.net_write_timeout,
-   (gptr*) &max_system_variables.net_write_timeout, 0, GET_ULONG,
+   (uchar**) &global_system_variables.net_write_timeout,
+   (uchar**) &max_system_variables.net_write_timeout, 0, GET_ULONG,
    REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
   { "old", OPT_OLD_MODE, "Use compatible behavior.", 
-    (gptr*) &global_system_variables.old_mode,
-    (gptr*) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG, 
+    (uchar**) &global_system_variables.old_mode,
+    (uchar**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG, 
     0, 0, 0, 0, 0, 0},
   {"open_files_limit", OPT_OPEN_FILES_LIMIT,
    "If this is not 0, then mysqld will use this value to reserve file descriptors to use
with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or
max_connections + table_cache*2 (whichever is larger) number of files.",
-   (gptr*) &open_files_limit, (gptr*) &open_files_limit, 0, GET_ULONG,
+   (uchar**) &open_files_limit, (uchar**) &open_files_limit, 0, GET_ULONG,
    REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0},
   {"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
    "Controls the heuristic(s) applied during query optimization to prune less-promising
partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic,
thus perform exhaustive search; 1 - prune plans based on number of retrieved rows.",
-   (gptr*) &global_system_variables.optimizer_prune_level,
-   (gptr*) &max_system_variables.optimizer_prune_level,
+   (uchar**) &global_system_variables.optimizer_prune_level,
+   (uchar**) &max_system_variables.optimizer_prune_level,
    0, GET_ULONG, OPT_ARG, 1, 0, 1, 0, 1, 0},
   {"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH,
    "Maximum depth of search performed by the query optimizer. Values larger than the
number of relations in a query result in better query plans, but take longer to compile a
query. Smaller values than the number of tables in a relation result in faster
optimization, but may produce very bad query plans. If set to 0, the system will
automatically pick a reasonable value; if set to MAX_TABLES+2, the optimizer will switch
to the original find_best (used for testing/comparison).",
-   (gptr*) &global_system_variables.optimizer_search_depth,
-   (gptr*) &max_system_variables.optimizer_search_depth,
+   (uchar**) &global_system_variables.optimizer_search_depth,
+   (uchar**) &max_system_variables.optimizer_search_depth,
    0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
   {"plugin_dir", OPT_PLUGIN_DIR,
    "Directory for plugins.",
-   (gptr*) &opt_plugin_dir_ptr, (gptr*) &opt_plugin_dir_ptr, 0,
+   (uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"plugin_load", OPT_PLUGIN_LOAD,
    "Optional colon separated list of plugins to load, where each plugin is "
    "identified by name and path to library seperated by an equals.",
-   (gptr*) &opt_plugin_load, (gptr*) &opt_plugin_load, 0,
+   (uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-   {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
+  {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
     "The size of the buffer that is allocated when preloading indexes",
-    (gptr*) &global_system_variables.preload_buff_size,
-    (gptr*) &max_system_variables.preload_buff_size, 0, GET_ULONG,
+    (uchar**) &global_system_variables.preload_buff_size,
+    (uchar**) &max_system_variables.preload_buff_size, 0, GET_ULONG,
     REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0},
   {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE,
    "Allocation block size for query parsing and execution",
-   (gptr*) &global_system_variables.query_alloc_block_size,
-   (gptr*) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
+   (uchar**) &global_system_variables.query_alloc_block_size,
+   (uchar**) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
    REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0},
 #ifdef HAVE_QUERY_CACHE
   {"query_cache_limit", OPT_QUERY_CACHE_LIMIT,
    "Don't cache results that are bigger than this.",
-   (gptr*) &query_cache_limit, (gptr*) &query_cache_limit, 0, GET_ULONG,
+   (uchar**) &query_cache_limit, (uchar**) &query_cache_limit, 0, GET_ULONG,
    REQUIRED_ARG, 1024*1024L, 0, (longlong) ULONG_MAX, 0, 1, 0},
   {"query_cache_min_res_unit", OPT_QUERY_CACHE_MIN_RES_UNIT,
    "minimal size of unit in wich space for results is allocated (last unit will be trimed
after writing all result data.",
-   (gptr*) &query_cache_min_res_unit, (gptr*) &query_cache_min_res_unit,
+   (uchar**) &query_cache_min_res_unit, (uchar**) &query_cache_min_res_unit,
    0, GET_ULONG, REQUIRED_ARG, QUERY_CACHE_MIN_RESULT_DATA_SIZE,
    0, (longlong) ULONG_MAX, 0, 1, 0},
 #endif /*HAVE_QUERY_CACHE*/
   {"query_cache_size", OPT_QUERY_CACHE_SIZE,
    "The memory allocated to store results from old queries.",
-   (gptr*) &query_cache_size, (gptr*) &query_cache_size, 0, GET_ULONG,
+   (uchar**) &query_cache_size, (uchar**) &query_cache_size, 0, GET_ULONG,
    REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1024, 0},
 #ifdef HAVE_QUERY_CACHE
   {"query_cache_type", OPT_QUERY_CACHE_TYPE,
    "0 = OFF = Don't cache or retrieve results. 1 = ON = Cache all results except SELECT
SQL_NO_CACHE ... queries. 2 = DEMAND = Cache only SELECT SQL_CACHE ... queries.",
-   (gptr*) &global_system_variables.query_cache_type,
-   (gptr*) &max_system_variables.query_cache_type,
+   (uchar**) &global_system_variables.query_cache_type,
+   (uchar**) &max_system_variables.query_cache_type,
    0, GET_ULONG, REQUIRED_ARG, 1, 0, 2, 0, 1, 0},
   {"query_cache_wlock_invalidate", OPT_QUERY_CACHE_WLOCK_INVALIDATE,
    "Invalidate queries in query cache on LOCK for write",
-   (gptr*) &global_system_variables.query_cache_wlock_invalidate,
-   (gptr*) &max_system_variables.query_cache_wlock_invalidate,
+   (uchar**) &global_system_variables.query_cache_wlock_invalidate,
+   (uchar**) &max_system_variables.query_cache_wlock_invalidate,
    0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
 #endif /*HAVE_QUERY_CACHE*/
   {"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE,
    "Persistent buffer for query parsing and execution",
-   (gptr*) &global_system_variables.query_prealloc_size,
-   (gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
+   (uchar**) &global_system_variables.query_prealloc_size,
+   (uchar**) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
    REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
    ~0L, 0, 1024, 0},
   {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
    "Allocation block size for storing ranges during optimization",
-   (gptr*) &global_system_variables.range_alloc_block_size,
-   (gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
+   (uchar**) &global_system_variables.range_alloc_block_size,
+   (uchar**) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
    REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 4096, ~0L, 0, 1024, 0},
   {"read_buffer_size", OPT_RECORD_BUFFER,
    "Each thread that does a sequential scan allocates a buffer of this size for each
table it scans. If you do many sequential scans, you may want to increase this value.",
-   (gptr*) &global_system_variables.read_buff_size,
-   (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
+   (uchar**) &global_system_variables.read_buff_size,
+   (uchar**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
    128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE,
    0},
   {"read_only", OPT_READONLY,
    "Make all non-temporary tables read-only, with the exception for replication (slave)
threads and users with the SUPER privilege",
-   (gptr*) &opt_readonly,
-   (gptr*) &opt_readonly,
+   (uchar**) &opt_readonly,
+   (uchar**) &opt_readonly,
    0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
   {"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER,
    "When reading rows in sorted order after a sort, the rows are read through this buffer
to avoid a disk seeks. If not set, then it's set to the value of record_buffer.",
-   (gptr*) &global_system_variables.read_rnd_buff_size,
-   (gptr*) &max_system_variables.read_rnd_buff_size, 0,
+   (uchar**) &global_system_variables.read_rnd_buff_size,
+   (uchar**) &max_system_variables.read_rnd_buff_size, 0,
    GET_ULONG, REQUIRED_ARG, 256*1024L, IO_SIZE*2+MALLOC_OVERHEAD,
    SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0},
   {"record_buffer", OPT_RECORD_BUFFER,
    "Alias for read_buffer_size",
-   (gptr*) &global_system_variables.read_buff_size,
-   (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
+   (uchar**) &global_system_variables.read_buff_size,
+   (uchar**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG,
    128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0},
 #ifdef HAVE_REPLICATION
   {"relay_log_purge", OPT_RELAY_LOG_PURGE,
    "0 = do not purge relay logs. 1 = purge them as soon as they are no more needed.",
-   (gptr*) &relay_log_purge,
-   (gptr*) &relay_log_purge, 0, GET_BOOL, NO_ARG,
+   (uchar**) &relay_log_purge,
+   (uchar**) &relay_log_purge, 0, GET_BOOL, NO_ARG,
    1, 0, 1, 0, 1, 0},
   {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT,
    "Maximum space to use for all relay logs.",
-   (gptr*) &relay_log_space_limit,
-   (gptr*) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L,
+   (uchar**) &relay_log_space_limit,
+   (uchar**) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L,
    (longlong) ULONG_MAX, 0, 1, 0},
   {"slave_compressed_protocol", OPT_SLAVE_COMPRESSED_PROTOCOL,
    "Use compression on master/slave protocol.",
-   (gptr*) &opt_slave_compressed_protocol,
-   (gptr*) &opt_slave_compressed_protocol,
+   (uchar**) &opt_slave_compressed_protocol,
+   (uchar**) &opt_slave_compressed_protocol,
    0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
   {"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT,
    "Number of seconds to wait for more data from a master/slave connection before
aborting the read.",
-   (gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0,
+   (uchar**) &slave_net_timeout, (uchar**) &slave_net_timeout, 0,
    GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
   {"slave_transaction_retries", OPT_SLAVE_TRANS_RETRIES,
    "Number of times the slave SQL thread will retry a transaction in case "
    "it failed with a deadlock or elapsed lock wait timeout, "
    "before giving up and stopping.",
-   (gptr*) &slave_trans_retries, (gptr*) &slave_trans_retries, 0,
+   (uchar**) &slave_trans_retries, (uchar**) &slave_trans_retries, 0,
    GET_ULONG, REQUIRED_ARG, 10L, 0L, (longlong) ULONG_MAX, 0, 1, 0},
   {"slave-allow-batching", OPT_SLAVE_ALLOW_BATCHING,
    "Allow slave to batch requests.",
-   (gptr*) &slave_allow_batching, (gptr*) &slave_allow_batching,
+   (uchar**) &slave_allow_batching, (uchar**) &slave_allow_batching,
    0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
 #endif /* HAVE_REPLICATION */
   {"slow_launch_time", OPT_SLOW_LAUNCH_TIME,
    "If creating the thread takes longer than this value (in seconds), the
Slow_launch_threads counter will be incremented.",
-   (gptr*) &slow_launch_time, (gptr*) &slow_launch_time, 0, GET_ULONG,
+   (uchar**) &slow_launch_time, (uchar**) &slow_launch_time, 0, GET_ULONG,
    REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0},
   {"sort_buffer_size", OPT_SORT_BUFFER,
    "Each thread that needs to do a sort allocates a buffer of this size.",
-   (gptr*) &global_system_variables.sortbuff_size,
-   (gptr*) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
+   (uchar**) &global_system_variables.sortbuff_size,
+   (uchar**) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG,
    MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ~0L, MALLOC_OVERHEAD,
    1, 0},
   {"sync-binlog", OPT_SYNC_BINLOG,
    "Synchronously flush binary log to disk after every #th event. "
    "Use 0 (default) to disable synchronous flushing.",
-   (gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG,
+   (uchar**) &sync_binlog_period, (uchar**) &sync_binlog_period, 0, GET_ULONG,
    REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
   {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.",
-   (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
+   (uchar**) &opt_sync_frm, (uchar**) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
    0, 0, 0, 0},
   {"table_cache", OPT_TABLE_OPEN_CACHE,
    "Deprecated; use --table_open_cache instead.",
-   (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG,
+   (uchar**) &table_cache_size, (uchar**) &table_cache_size, 0, GET_ULONG,
    REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
   {"table_definition_cache", OPT_TABLE_DEF_CACHE,
    "The number of cached table definitions.",
-   (gptr*) &table_def_size, (gptr*) &table_def_size,
+   (uchar**) &table_def_size, (uchar**) &table_def_size,
    0, GET_ULONG, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
   {"table_open_cache", OPT_TABLE_OPEN_CACHE,
    "The number of cached open tables.",
-   (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG,
+   (uchar**) &table_cache_size, (uchar**) &table_cache_size, 0, GET_ULONG,
    REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
   {"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
    "Timeout in seconds to wait for a table level lock before returning an "
    "error. Used only if the connection has active cursors.",
-   (gptr*) &table_lock_wait_timeout, (gptr*) &table_lock_wait_timeout,
+   (uchar**) &table_lock_wait_timeout, (uchar**) &table_lock_wait_timeout,
    0, GET_ULONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
   {"thread_cache_size", OPT_THREAD_CACHE_SIZE,
    "How many threads we should keep in a cache for reuse.",
-   (gptr*) &thread_cache_size, (gptr*) &thread_cache_size, 0, GET_ULONG,
+   (uchar**) &thread_cache_size, (uchar**) &thread_cache_size, 0, GET_ULONG,
    REQUIRED_ARG, 0, 0, 16384, 0, 1, 0},
   {"thread_concurrency", OPT_THREAD_CONCURRENCY,
    "Permits the application to give the threads system a hint for the desired number of
threads that should be run at the same time.",
-   (gptr*) &concurrency, (gptr*) &concurrency, 0, GET_ULONG, REQUIRED_ARG,
+   (uchar**) &concurrency, (uchar**) &concurrency, 0, GET_ULONG, REQUIRED_ARG,
    DEFAULT_CONCURRENCY, 1, 512, 0, 1, 0},
 #if HAVE_POOL_OF_THREADS == 1
   {"thread_pool_size", OPT_THREAD_CACHE_SIZE,
    "How many threads we should create to handle query requests in case of
'thread_handling=pool-of-threads'",
-   (gptr*) &thread_pool_size, (gptr*) &thread_pool_size, 0, GET_ULONG,
+   (uchar**) &thread_pool_size, (uchar**) &thread_pool_size, 0, GET_ULONG,
    REQUIRED_ARG, 20, 1, 16384, 0, 1, 0},
 #endif
   {"thread_stack", OPT_THREAD_STACK,
-   "The stack size for each thread.", (gptr*) &thread_stack,
-   (gptr*) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
+   "The stack size for each thread.", (uchar**) &thread_stack,
+   (uchar**) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
    1024L*128L, ~0L, 0, 1024, 0},
   { "time_format", OPT_TIME_FORMAT,
     "The TIME format (for future).",
-    (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
-    (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
+    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
+    (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
     0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"tmp_table_size", OPT_TMP_TABLE_SIZE,
    "If an in-memory temporary table exceeds this size, MySQL will automatically convert
it to an on-disk MyISAM table.",
-   (gptr*) &global_system_variables.tmp_table_size,
-   (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULL,
+   (uchar**) &global_system_variables.tmp_table_size,
+   (uchar**) &max_system_variables.tmp_table_size, 0, GET_ULL,
    REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
   {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
    "Allocation block size for various transaction-related structures",
-   (gptr*) &global_system_variables.trans_alloc_block_size,
-   (gptr*) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
+   (uchar**) &global_system_variables.trans_alloc_block_size,
+   (uchar**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
    REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0},
   {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
    "Persistent buffer for various transaction-related structures",
-   (gptr*) &global_system_variables.trans_prealloc_size,
-   (gptr*) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
+   (uchar**) &global_system_variables.trans_prealloc_size,
+   (uchar**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
    REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0},
   {"thread_handling", OPT_THREAD_HANDLING,
    "Define threads usage for handling queries:  "
@@ -6323,13 +6374,13 @@
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"updatable_views_with_limit", OPT_UPDATABLE_VIEWS_WITH_LIMIT,
    "1 = YES = Don't issue an error message (warning only) if a VIEW without presence of a
key of the underlying table is used in queries with a LIMIT clause for updating. 0 = NO =
Prohibit update of a VIEW, which does not contain a key of the underlying table and the
query uses a LIMIT clause (usually get from GUI tools).",
-   (gptr*) &global_system_variables.updatable_views_with_limit,
-   (gptr*) &max_system_variables.updatable_views_with_limit,
+   (uchar**) &global_system_variables.updatable_views_with_limit,
+   (uchar**) &max_system_variables.updatable_views_with_limit,
    0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 1, 0},
   {"wait_timeout", OPT_WAIT_TIMEOUT,
    "The number of seconds the server waits for activity on a connection before closing
it.",
-   (gptr*) &global_system_variables.net_wait_timeout,
-   (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
+   (uchar**) &global_system_variables.net_wait_timeout,
+   (uchar**) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
    REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
    0, 1, 0},
   {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
@@ -6692,8 +6743,8 @@
   {"Aborted_connects",         (char*) &aborted_connects,       SHOW_LONG},
   {"Binlog_cache_disk_use",    (char*) &binlog_cache_disk_use,  SHOW_LONG},
   {"Binlog_cache_use",         (char*) &binlog_cache_use,       SHOW_LONG},
-  {"Bytes_received",           (char*) offsetof(STATUS_VAR, bytes_received),
SHOW_LONG_STATUS},
-  {"Bytes_sent",               (char*) offsetof(STATUS_VAR, bytes_sent),
SHOW_LONG_STATUS},
+  {"Bytes_received",           (char*) offsetof(STATUS_VAR, bytes_received),
SHOW_LONGLONG_STATUS},
+  {"Bytes_sent",               (char*) offsetof(STATUS_VAR, bytes_sent),
SHOW_LONGLONG_STATUS},
   {"Com_admin_commands",       (char*) offsetof(STATUS_VAR, com_other),
SHOW_LONG_STATUS},
   {"Com_alter_db",	       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_ALTER_DB]),
SHOW_LONG_STATUS},
   {"Com_alter_event",	       (char*) offsetof(STATUS_VAR, com_stat[(uint)
SQLCOM_ALTER_EVENT]), SHOW_LONG_STATUS},
@@ -7028,7 +7079,7 @@
   prepared_stmt_count= 0;
   errmesg= 0;
   mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
-  bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
+  bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
   bzero((char *) &global_status_var, sizeof(global_status_var));
   opt_large_pages= 0;
   key_map_full.set_all();
@@ -7075,6 +7126,7 @@
 	  sizeof(mysql_real_data_home)-1);
   mysql_data_home_buff[0]=FN_CURLIB;	// all paths are relative from here
   mysql_data_home_buff[1]=0;
+  mysql_data_home_len= 2;
 
   /* Replication parameters */
   master_user= (char*) "test";
@@ -7236,6 +7288,7 @@
     strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1);
     /* Correct pointer set by my_getopt (for embedded library) */
     mysql_data_home= mysql_real_data_home;
+    mysql_data_home_len= strlen(mysql_data_home);
     break;
   case 'u':
     if (!mysqld_user || !strcmp(mysqld_user, argument))
@@ -7676,7 +7729,7 @@
     break;
   }
   case OPT_FT_BOOLEAN_SYNTAX:
-    if (ft_boolean_check_syntax_string((byte*) argument))
+    if (ft_boolean_check_syntax_string((uchar*) argument))
     {
       fprintf(stderr, "Invalid ft-boolean-syntax string: %s\n", argument);
       exit(1);
@@ -7697,7 +7750,7 @@
 }
 	/* Initiates DEBUG - but no debugging here ! */
 
-static gptr *
+static uchar* *
 mysql_getopt_value(const char *keyname, uint key_length,
 		   const struct my_option *option)
 {
@@ -7712,13 +7765,13 @@
       exit(1);
     switch (option->id) {
     case OPT_KEY_BUFFER_SIZE:
-      return (gptr*) &key_cache->param_buff_size;
+      return (uchar**) &key_cache->param_buff_size;
     case OPT_KEY_CACHE_BLOCK_SIZE:
-      return (gptr*) &key_cache->param_block_size;
+      return (uchar**) &key_cache->param_block_size;
     case OPT_KEY_CACHE_DIVISION_LIMIT:
-      return (gptr*) &key_cache->param_division_limit;
+      return (uchar**) &key_cache->param_division_limit;
     case OPT_KEY_CACHE_AGE_THRESHOLD:
-      return (gptr*) &key_cache->param_age_threshold;
+      return (uchar**) &key_cache->param_age_threshold;
     }
   }
   }
@@ -7870,7 +7923,7 @@
 */
 
 bool
-fn_format_relative_to_data_home(my_string to, const char *name,
+fn_format_relative_to_data_home(char * to, const char *name,
 				const char *dir, const char *extension)
 {
   char tmp_path[FN_REFLEN];
@@ -7988,7 +8041,7 @@
 
   found=0;
   found_end= 0;
-  pos=(my_string) x;
+  pos=(char *) x;
   while (*pos == ' ') pos++;
   found_end= *pos == 0;
   while (!found_end)
@@ -8085,7 +8138,7 @@
     char buff[21], *end;
     end= int10_to_str((long) getpid(), buff, 10);
     *end++= '\n';
-    if (!my_write(file, (byte*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
+    if (!my_write(file, (uchar*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP)))
     {
       (void) my_close(file, MYF(0));
       return;

--- 1.160/sql/share/errmsg.txt	2007-06-28 19:34:50 +02:00
+++ 1.161/sql/share/errmsg.txt	2007-07-05 13:54:00 +02:00
@@ -6097,3 +6097,8 @@
 
 ER_TRG_CANT_OPEN_TABLE
   eng "Cannot open table for trigger `%-.64s`.`%-.64s`"
+
+ER_NDB_REPLICATION_SCHEMA_ERROR
+        eng "Bad schema for mysql.ndb_replication table. Message: %-.64s"
+ER_CONFLICT_FN_PARSE_ERROR
+        eng "Error in parsing conflict function. Message: %-.64s"

--- 1.261/mysql-test/t/disabled.def	2007-07-04 09:53:36 +02:00
+++ 1.262/mysql-test/t/disabled.def	2007-07-05 13:48:37 +02:00
@@ -14,7 +14,11 @@
 im_options               : Bug#20294 2006-07-24 stewart   Instance manager test
im_options fails randomly
 im_daemon_life_cycle     : Bug#20294 2007-05-14 alik      Instance manager tests fail
randomly
 im_cmd_line              : Bug#20294 2007-05-14 alik      Instance manager tests fail
randomly
+im_utils                 : Bug#20294 2007-05-30 alik      Instance manager tests fail
randomly
+im_instance_conf         : Bug#20294 2007-05-30 alik      Instance manager tests fail
randomly
 im_life_cycle            : BUG#27851 Instance manager dies on ASSERT in
~Thread_registry() or from not being able to close a mysqld instance.
+im_instance_conf         : BUG#28743 Instance manager generates warnings in test suite
+im_utils                 : BUG#28743 Instance manager generates warnings in test suite
 concurrent_innodb        : BUG#21579 2006-08-11 mleich innodb_concurrent random failures
with varying differences
 ndb_single_user          : Bug will not be fixed in this release (not yet atleast)
 ndb_autodiscover         : BUG#18952 2006-02-16 NDB Auto Discovery is failing designed
tests in ndb_autodiscovery.test
@@ -26,14 +30,17 @@
 rpl_ndb_2innodb          : BUG#19227 2006-04-20 pekka pk delete apparently not replicated
 rpl_ndb_2myisam          : BUG#19227 Seems to pass currently
 rpl_ndb_dd_partitions    : BUG#19259 2006-04-21 rpl_ndb_dd_partitions fails on s/AMD
-rpl_ndb_ddl              : BUG#18946 result file needs update + test needs to checked
 rpl_ddl                  : BUG#26418 2007-03-01 mleich Slave out of sync after
CREATE/DROP TEMPORARY TABLE + ROLLBACK on master
 rpl_ndb_innodb2ndb       : Bug #19710  Cluster replication to partition table fails on
DELETE FROM statement
 rpl_ndb_myisam2ndb       : Bug #19710  Cluster replication to partition table fails on
DELETE FROM statement
-rpl_row_blob_innodb      : BUG#18980 2006-04-10 kent    Test fails randomly
-synchronization          : Bug#24529  	Test 'synchronization' fails on Mac pushbuild;
Also on Linux 64 bit.
+#rpl_row_blob_innodb      : BUG#18980 2006-04-10 kent    Test fails randomly
+rpl_ndb_ddl              : BUG#28798 2007-05-31  lars  Valgrind failure in NDB
+rpl_ndb_mix_innodb       : BUG#28123 rpl_ndb_mix_innodb.test casue slave to core on
sol10-sparc-a
 rpl_ndb_ctype_ucs2_def   : BUG#27404 util thd mysql_parse sig11 when mysqld default
multibyte charset
 
+rpl_invoked_features     : BUG#29020 2007-06-21 Lars Non-deterministic test case
+ctype_big5               : BUG#26711 2007-06-21 Lars Test has never worked on Double
Whopper
+
 # the below testcase have been reworked to avoid the bug, test contains comment, keep bug
open
 #ndb_binlog_ddl_multi     : BUG#18976 2006-04-10 kent    CRBR: multiple binlog, second
binlog may miss schema log events
 #ndb_binlog_discover      : bug#21806 2006-08-24
@@ -42,4 +49,9 @@
 #rpl_ndb_dd_advance	 : Bug#25913 rpl_ndb_dd_advance fails randomly
 
 ndb_partition_error2	 : HF is not sure if the test can work as internded on all the
platforms
-mysql_upgrade		 : Bug#28560 test links to /usr/local/mysql/lib libraries, causes
non-determinism and failures on ABI breakage
+
+im_options_set       : Bug#20294: Instance manager tests fail randomly
+im_options_unset     : Bug#20294: Instance manager tests fail randomly
+mysql_upgrade        : Bug#28560 test links to /usr/local/mysql/lib libraries, causes
non-determinism and failures on ABI breakage
+rpl_udf              : Bug#28993 rpl_udf test causes server crash and valgrind warning in
pushbuild
+ndb_dd_sql_features  : Bug#29102 ndb_dd_sql_features fails in pushbuild

--- 1.58/mysql-test/t/ndb_basic.test	2007-06-14 12:59:06 +02:00
+++ 1.59/mysql-test/t/ndb_basic.test	2007-07-05 13:48:38 +02:00
@@ -775,7 +775,7 @@
 # insert ignore
 create table t1 (a int not null primary key, b int not null) engine=ndb;
 insert into t1 values (1,10), (2,20), (3,30);
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 insert into t1 set a=1, b=100;
 insert ignore into t1 set a=1, b=100;
 select * from t1 order by a;
@@ -788,12 +788,12 @@
 create table t2 (c int not null primary key, d int not null) engine=ndb;
 insert into t1 values (1,10), (2,10), (3,30), (4, 30);
 insert into t2 values (1,10), (2,10), (3,30), (4, 30);
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 update t1 set a = 1 where a = 3;
 select * from t1 order by a;
 update t1 set b = 1 where a > 1 order by a desc limit 1;
 select * from t1 order by a;
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 update t1,t2 set a = 1, c = 1 where a = 3 and c = 3;
 select * from t1 order by a;
 update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3;

--- 1.484/sql/ha_ndbcluster.cc	2007-07-04 10:03:28 +02:00
+++ 1.485/sql/ha_ndbcluster.cc	2007-07-05 13:54:00 +02:00
@@ -154,7 +154,7 @@
 // Table lock handling
 HASH ndbcluster_open_tables;
 
-static byte *ndbcluster_get_key(NDB_SHARE *share,uint *length,
+static uchar *ndbcluster_get_key(NDB_SHARE *share, size_t *length,
                                 my_bool not_used __attribute__((unused)));
 #ifdef HAVE_NDB_BINLOG
 static int rename_share(NDB_SHARE *share, const char *new_key);
@@ -369,11 +369,11 @@
   Place holder for ha_ndbcluster thread specific data
 */
 static
-byte *thd_ndb_share_get_key(THD_NDB_SHARE *thd_ndb_share, uint *length,
+uchar *thd_ndb_share_get_key(THD_NDB_SHARE *thd_ndb_share, size_t *length,
                             my_bool not_used __attribute__((unused)))
 {
   *length= sizeof(thd_ndb_share->key);
-  return (byte*) &thd_ndb_share->key;
+  return (uchar*) &thd_ndb_share->key;
 }
 
 Thd_ndb::Thd_ndb()
@@ -439,9 +439,9 @@
   DBUG_ENTER("Thd_ndb::get_open_table");
   HASH_SEARCH_STATE state;
   THD_NDB_SHARE *thd_ndb_share=
-    (THD_NDB_SHARE*)hash_first(&open_tables, (byte *)&key, sizeof(key),
&state);
+    (THD_NDB_SHARE*)hash_first(&open_tables, (uchar *)&key, sizeof(key),
&state);
   while (thd_ndb_share && thd_ndb_share->key != key)
-    thd_ndb_share= (THD_NDB_SHARE*)hash_next(&open_tables, (byte *)&key,
sizeof(key), &state);
+    thd_ndb_share= (THD_NDB_SHARE*)hash_next(&open_tables, (uchar *)&key,
sizeof(key), &state);
   if (thd_ndb_share == 0)
   {
     thd_ndb_share= (THD_NDB_SHARE *) alloc_root(&thd->transaction.mem_root,
@@ -450,7 +450,7 @@
     thd_ndb_share->stat.last_count= count;
     thd_ndb_share->stat.no_uncommitted_rows_count= 0;
     thd_ndb_share->stat.records= ~(ha_rows)0;
-    my_hash_insert(&open_tables, (byte *)thd_ndb_share);
+    my_hash_insert(&open_tables, (uchar *)thd_ndb_share);
   }
   else if (thd_ndb_share->stat.last_count != count)
   {
@@ -692,7 +692,7 @@
 
 
 void
-ha_ndbcluster::set_hidden_key(char *row, Uint64 auto_value)
+ha_ndbcluster::set_hidden_key(uchar *row, Uint64 auto_value)
 {
   /* The hidden primary key is stored just after the normal row data. */
   uint32 offset= offset_hidden_key();
@@ -700,7 +700,7 @@
 }
 
 Uint64
-ha_ndbcluster::get_hidden_key(const char *row)
+ha_ndbcluster::get_hidden_key(const uchar *row)
 {
   Uint64 hidden_key;
   uint32 offset= offset_hidden_key();
@@ -736,7 +736,7 @@
 }
 
 void
-ha_ndbcluster::set_partition_function_value(char *row, uint32 func_value)
+ha_ndbcluster::set_partition_function_value(uchar *row, uint32 func_value)
 {
   /* The partition function value is stored just after the hidden primary
      key (if any). */
@@ -745,7 +745,7 @@
 }
 
 uint32
-ha_ndbcluster::get_partition_fragment(const char *row)
+ha_ndbcluster::get_partition_fragment(const uchar *row)
 {
   uint32 fragment;
   uint32 offset= offset_user_partition_fragment();
@@ -760,7 +760,7 @@
   mask[field_no>>3]|= (1 << (field_no & 7));
 }
 
-static inline char *
+static inline uchar *
 alloc_batch_row(Thd_ndb *thd_ndb, uint size)
 {
   /*
@@ -771,7 +771,7 @@
    */
   if (thd_ndb->m_unsent_bytes == 0)
     free_root(&(thd_ndb->m_batch_mem_root), MY_MARK_BLOCKS_FREE);
-  return alloc_root(&(thd_ndb->m_batch_mem_root), size);
+  return (uchar*)alloc_root(&(thd_ndb->m_batch_mem_root), size);
 }
 
 /*
@@ -782,11 +782,11 @@
   needed for the operation; this is used to set the output parameter
   batch_full to true when it is time to flush the batch with execute().
 */
-char *
-ha_ndbcluster::batch_copy_row_to_buffer(Thd_ndb *thd_ndb, const byte *record,
+uchar *
+ha_ndbcluster::batch_copy_row_to_buffer(Thd_ndb *thd_ndb, const uchar *record,
                                         bool & batch_full)
 {
-  char *row= copy_row_to_buffer(thd_ndb, record);
+  uchar *row= copy_row_to_buffer(thd_ndb, record);
   if (unlikely(!row))
     return NULL;
   uint unsent= thd_ndb->m_unsent_bytes;
@@ -796,12 +796,12 @@
   return row;
 }
 
-char *
-ha_ndbcluster::batch_copy_key_to_buffer(Thd_ndb *thd_ndb, const byte *key,
+uchar *
+ha_ndbcluster::batch_copy_key_to_buffer(Thd_ndb *thd_ndb, const uchar *key,
                                         uint key_len,
                                         uint op_batch_size, bool & batch_full)
 {
-  char *row= alloc_batch_row(thd_ndb, key_len);
+  uchar *row= alloc_batch_row(thd_ndb, key_len);
   if (unlikely(!row))
     return NULL;
   memcpy(row, key, key_len);
@@ -817,10 +817,10 @@
   Simpler row buffer copy, for when we know we will not batch.
   Only valid until next buffer allocation.
 */
-char *
-ha_ndbcluster::copy_row_to_buffer(Thd_ndb *thd_ndb, const byte *record)
+uchar *
+ha_ndbcluster::copy_row_to_buffer(Thd_ndb *thd_ndb, const uchar *record)
 {
-  char *row;
+  uchar *row;
   uint size= table->s->reclength + m_extra_reclength;
   row= alloc_batch_row(thd_ndb, size);
   if (unlikely(!row))
@@ -830,12 +830,12 @@
 }
 
 /* Return a row buffer, valid until next execute(). */
-char *
+uchar *
 ha_ndbcluster::get_row_buffer()
 {
   Thd_ndb *thd_ndb= get_thd_ndb(table->in_use);
-  return alloc_root(&(thd_ndb->m_batch_mem_root),
-                    table->s->reclength + m_extra_reclength);
+  return (uchar*)alloc_root(&(thd_ndb->m_batch_mem_root),
+                            table->s->reclength + m_extra_reclength);
 }
 
 /* Return a row buffer, valid until next execute(). */
@@ -913,7 +913,8 @@
     my_free(ha->m_blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
     DBUG_PRINT("info", ("allocate blobs buffer size %u",
                         (uint32)(ha->m_blob_total_size)));
-    ha->m_blobs_buffer= my_malloc(ha->m_blob_total_size, MYF(MY_WME));
+    ha->m_blobs_buffer=
+      (uchar*) my_malloc(ha->m_blob_total_size, MYF(MY_WME));
     if (ha->m_blobs_buffer == NULL)
     {
       ha->m_blobs_buffer_size= 0;
@@ -949,7 +950,7 @@
       if (ndb_blob->getLength(len64) != 0)
         ERR_RETURN(ndb_blob->getNdbError());
       DBUG_ASSERT(len64 < 0xffffffff);
-      char *buf= ha->m_blobs_buffer + offset;
+      uchar *buf= ha->m_blobs_buffer + offset;
       uint32 len= ha->m_blobs_buffer_size - offset;
       if (ndb_blob->readData(buf, len) != 0)
           ERR_RETURN(ndb_blob->getNdbError());
@@ -972,7 +973,7 @@
       /* Have to set length even in this case. */
       my_ptrdiff_t ptrdiff=
         ha->m_blob_destination_record - ha->table->record[0];
-      char *buf= ha->m_blobs_buffer + offset;
+      uchar *buf= ha->m_blobs_buffer + offset;
       field_blob->move_field_offset(ptrdiff);
       field_blob->set_ptr((uint32)0, buf);
       field_blob->set_null();
@@ -992,7 +993,7 @@
   unpack_record().
 */
 int
-ha_ndbcluster::get_blob_values(NdbOperation *ndb_op, byte *dst_record,
+ha_ndbcluster::get_blob_values(NdbOperation *ndb_op, uchar *dst_record,
                                const MY_BITMAP *bitmap)
 {
   uint i;
@@ -1064,23 +1065,23 @@
       Field_blob *field_blob= (Field_blob *)field;
 
       // Get length and pointer to data
-      const byte* field_ptr= field->ptr + row_offset;
+      const uchar *field_ptr= field->ptr + row_offset;
       uint32 blob_len= field_blob->get_length(field_ptr);
-      char* blob_ptr= NULL;
+      uchar* blob_ptr= NULL;
       field_blob->get_ptr(&blob_ptr);
 
       // Looks like NULL ptr signals length 0 blob
       if (blob_ptr == NULL) {
         DBUG_ASSERT(blob_len == 0);
-        blob_ptr= (char*)"";
+        blob_ptr= (uchar*)"";
       }
 
       DBUG_PRINT("value", ("set blob ptr: 0x%lx  len: %u",
                            (long) blob_ptr, blob_len));
-      DBUG_DUMP("value", (char*)blob_ptr, min(blob_len, 26));
+      DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
 
       // No callback needed to write value
-      res= ndb_blob->setValue(blob_ptr, blob_len);
+      res= ndb_blob->setValue((char*)blob_ptr, blob_len);
       if (res != 0)
         DBUG_RETURN(1);
     }
@@ -1097,7 +1098,7 @@
   passes a record pointer diff.
  */
 int get_ndb_blobs_value(TABLE* table, NdbValue* value_array,
-                        byte*& buffer, uint& buffer_size,
+                        uchar*& buffer, uint& buffer_size,
                         my_ptrdiff_t ptrdiff)
 {
   DBUG_ENTER("get_ndb_blobs_value");
@@ -1133,7 +1134,7 @@
           size+= 8 - size % 8;
         if (loop == 1)
         {
-          char *buf= buffer + offset;
+          uchar *buf= buffer + offset;
           uint32 len= 0xffffffff;  // Max uint32
           if (ndb_blob->readData(buf, len) != 0)
             ERR_RETURN(ndb_blob->getNdbError());
@@ -1148,9 +1149,9 @@
       else if (loop == 1) // undefined or null
       {
         // have to set length even in this case
-        char *buf= buffer + offset; // or maybe NULL
+        uchar *buf= buffer + offset; // or maybe NULL
         uint32 len= 0;
-        field_blob->set_ptr_offset(ptrdiff, len, buf);
+	field_blob->set_ptr_offset(ptrdiff, len, buf);
         DBUG_PRINT("info", ("[%u] isNull=%d", i, isNull));
       }
     }
@@ -1159,7 +1160,7 @@
       my_free(buffer, MYF(MY_ALLOW_ZERO_PTR));
       buffer_size= 0;
       DBUG_PRINT("info", ("allocate blobs buffer size %u", offset));
-      buffer= my_malloc(offset, MYF(MY_WME));
+      buffer= (uchar*) my_malloc(offset, MYF(MY_WME));
       if (buffer == NULL)
       {
         sql_print_error("ha_ndbcluster::get_ndb_blobs_value: "
@@ -1231,8 +1232,8 @@
   DBUG_ASSERT(m_table == NULL);
   DBUG_ASSERT(m_table_info == NULL);
 
-  const void *data= NULL, *pack_data= NULL;
-  uint length, pack_length;
+  uchar *data= NULL, *pack_data= NULL;
+  size_t length, pack_length;
 
   /*
     Compare FrmData in NDB with frm file from disk.
@@ -1241,8 +1242,8 @@
   if (readfrm(path, &data, &length) ||
       packfrm(data, length, &pack_data, &pack_length))
   {
-    my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
-    my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
+    my_free(data, MYF(MY_ALLOW_ZERO_PTR));
+    my_free(pack_data, MYF(MY_ALLOW_ZERO_PTR));
     DBUG_RETURN(1);
   }
     
@@ -1254,11 +1255,11 @@
       && cmp_frm(tab, pack_data, pack_length))
   {
     DBUG_PRINT("error", 
-               ("metadata, pack_length: %d  getFrmLength: %d  memcmp: %d",
-                pack_length, tab->getFrmLength(),
+               ("metadata, pack_length: %lu  getFrmLength: %d  memcmp: %d",
+                (ulong) pack_length, tab->getFrmLength(),
                 memcmp(pack_data, tab->getFrmData(), pack_length)));
-    DBUG_DUMP("pack_data", (char*)pack_data, pack_length);
-    DBUG_DUMP("frm", (char*)tab->getFrmData(), tab->getFrmLength());
+    DBUG_DUMP("pack_data", (uchar*) pack_data, pack_length);
+    DBUG_DUMP("frm", (uchar*) tab->getFrmData(), tab->getFrmLength());
     error= HA_ERR_TABLE_DEF_CHANGED;
   }
   my_free((char*)data, MYF(0));
@@ -1546,7 +1547,7 @@
   if (table->field[field_no]->null_ptr)
   {
     spec->nullbit_byte_offset=
-      (char *)table->field[field_no]->null_ptr - table->record[0];
+      table->field[field_no]->null_ptr - table->record[0];
     spec->nullbit_bit_in_byte=
       null_bit_mask_to_bit_number(table->field[field_no]->null_bit);
   }
@@ -1555,7 +1556,7 @@
     /* We need to store the position of the overflow bits. */
     const Field_bit* field_bit= static_cast<Field_bit*>(table->field[field_no]);
     spec->nullbit_byte_offset=
-      (char *)field_bit->bit_ptr - table->record[0];
+      field_bit->bit_ptr - table->record[0];
     spec->nullbit_bit_in_byte= field_bit->bit_ofs;
   }
   else
@@ -2140,7 +2141,7 @@
               HA_KEY_SCAN_NOT_ROR);
 }
 
-static void shrink_varchar(Field* field, const byte* & ptr, char* buf)
+static void shrink_varchar(Field* field, const uchar* & ptr, uchar* buf)
 {
   if (field->type() == MYSQL_TYPE_VARCHAR && ptr != NULL) {
     Field_varstring* f= (Field_varstring*)field;
@@ -2164,17 +2165,17 @@
   Read one record from NDB using primary key
 */
 
-int ha_ndbcluster::pk_read(const byte *key, uint key_len, byte *buf,
+int ha_ndbcluster::pk_read(const uchar *key, uint key_len, uchar *buf,
                            uint32 part_id)
 {
   NdbConnection *trans= m_active_trans;
   NdbOperation *op;
-  char *row;
+  uchar *row;
   int res;
   DBUG_ENTER("pk_read");
   DBUG_PRINT("enter", ("key_len: %u read_set=%x",
                        key_len, table->read_set->bitmap[0]));
-  DBUG_DUMP("key", (char*)key, key_len);
+  DBUG_DUMP("key", key, key_len);
 
   if (table_share->primary_key == MAX_KEY)
   {
@@ -2217,7 +2218,7 @@
   or hidden key
 */
 
-int ha_ndbcluster::complemented_read(const byte *old_data, byte *new_data,
+int ha_ndbcluster::complemented_read(const uchar *old_data, uchar *new_data,
                                      uint32 old_part_id)
 {
   NdbTransaction *trans= m_active_trans;
@@ -2231,7 +2232,7 @@
   }
 
   const NdbRecord *key_rec;
-  const char *key_row;
+  const uchar *key_row;
   if (table_share->primary_key != MAX_KEY)
   {
     key_rec= m_index[table->s->primary_key].ndb_unique_record_row;
@@ -2241,7 +2242,7 @@
   {
     /* Hidden primary key, previously read into m_ref. */
     key_rec= m_ndb_hidden_key_record;
-    key_row= (const char *)(&m_ref);
+    key_row= (const uchar*)(&m_ref);
   }
 
   /*
@@ -2253,7 +2254,8 @@
   bitmap_invert(&m_bitmap);
   NdbOperation::LockMode lm=
     (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type, &m_bitmap);
-  if (!(op= trans->readTuple(key_rec, key_row, m_ndb_record, new_data,
+  if (!(op= trans->readTuple(key_rec, (const char *)key_row,
+                             m_ndb_record, (char *)new_data,
                              lm, (const unsigned char *)(m_bitmap.bitmap))))
     ERR_RETURN(trans->getNdbError());
 
@@ -2341,7 +2343,7 @@
  */
 static
 int
-check_null_in_record(const KEY* key_info, const byte *record)
+check_null_in_record(const KEY* key_info, const uchar *record)
 {
   KEY_PART_INFO *curr_part, *end_part;
   curr_part= key_info->key_part;
@@ -2373,7 +2375,8 @@
  * primary key or unique index values
 */
 
-int ha_ndbcluster::peek_indexed_rows(const byte *record, bool check_pk)
+int ha_ndbcluster::peek_indexed_rows(const uchar *record,
+				     bool check_pk)
 {
   NdbTransaction *trans= m_active_trans;
   NdbOperation *op;
@@ -2437,7 +2440,8 @@
 
       NdbOperation *iop;
       const NdbRecord *key_rec= m_index[i].ndb_unique_record_row;
-      if (!(iop= trans->readTuple(key_rec, record, key_rec, dummy_row,
+      if (!(iop= trans->readTuple(key_rec, (const char *)record,
+                                  key_rec, dummy_row,
                                   lm, empty_mask)))
         ERR_RETURN(trans->getNdbError());
 
@@ -2472,15 +2476,15 @@
   Read one record from NDB using unique secondary index
 */
 
-int ha_ndbcluster::unique_index_read(const byte *key,
-                                     uint key_len, byte *buf)
+int ha_ndbcluster::unique_index_read(const uchar *key,
+                                     uint key_len, uchar *buf)
 {
   NdbTransaction *trans= m_active_trans;
   NdbOperation *op;
-  char *row;
+  uchar *row;
   DBUG_ENTER("ha_ndbcluster::unique_index_read");
   DBUG_PRINT("enter", ("key_len: %u, index: %u", key_len, active_index));
-  DBUG_DUMP("key", (char*)key, key_len);
+  DBUG_DUMP("key", key, key_len);
   
   if (table_share->primary_key == MAX_KEY)
   {
@@ -2569,7 +2573,8 @@
         DBUG_RETURN(ndb_err(trans));
     }
     
-    if ((local_check= cursor->nextResult(m_next_row, contact_ndb,
+    if ((local_check= cursor->nextResult(_m_next_row,
+                                         contact_ndb,
                                          m_force_send)) == 0)
     {
       /*
@@ -2619,7 +2624,7 @@
 
 */
 
-inline int ha_ndbcluster::next_result(byte *buf)
+inline int ha_ndbcluster::next_result(uchar *buf)
 {  
   int res;
   DBUG_ENTER("next_result");
@@ -2661,7 +2666,7 @@
   The key value is taken from a buffer in mysqld key format.
 */
 NdbOperation *
-ha_ndbcluster::pk_unique_index_read_key(uint idx, const byte *key, byte *buf,
+ha_ndbcluster::pk_unique_index_read_key(uint idx, const uchar *key, uchar *buf,
                                         NdbOperation::LockMode lm)
 {
   NdbOperation *op;
@@ -2691,7 +2696,8 @@
         ndb_record= m_ndb_record_fragment;
     }
   }
-  op= m_active_trans->readTuple(key_rec, key, ndb_record, buf, lm, mask);
+  op= m_active_trans->readTuple(key_rec, (const char *)key,
+                                ndb_record, (char *)buf, lm, mask);
 
   if (uses_blob_value(table->read_set) &&
       get_blob_values(op, buf, table->read_set) != 0)
@@ -2750,10 +2756,10 @@
     struct part_st {
       bool part_last;
       const key_range *key;
-      const byte *part_ptr;
+      const uchar *part_ptr;
       bool part_null;
       int bound_type;
-      const char* bound_ptr;
+      const uchar* bound_ptr;
     };
     struct part_st part[2];
 
@@ -2863,13 +2869,13 @@
       {
         DBUG_PRINT("info", ("key %d:%d  offset: %d  length: %d  last: %d  bound: %d",
                             j, i, tot_len, part_len, p.part_last, p.bound_type));
-        DBUG_DUMP("info", (const char*)p.part_ptr, part_store_len);
+        DBUG_DUMP("info", p.part_ptr, part_store_len);
 
         // Set bound if not cancelled via type -1
         if (p.bound_type != -1)
         {
-          const char* ptr= p.bound_ptr;
-          char buf[256];
+          const uchar* ptr= p.bound_ptr;
+          uchar buf[256];
           shrink_varchar(field, ptr, buf);
           if (op->setBound(i, p.bound_type, ptr))
             ERR_RETURN(op->getNdbError());
@@ -2907,7 +2913,7 @@
 {
   if (start_key)
   {
-    bound.low_key= start_key->key;
+    bound.low_key= (const char*)start_key->key;
     bound.low_key_count= count_key_columns(key_info, start_key);
     bound.low_inclusive=
       start_key->flag != HA_READ_AFTER_KEY &&
@@ -2929,7 +2935,7 @@
   }
   else if (end_key)
   {
-    bound.high_key= end_key->key;
+    bound.high_key= (const char*)end_key->key;
     bound.high_key_count= count_key_columns(key_info, end_key);
     /*
       For some reason, 'where b >= 1 and b <= 3' uses HA_READ_AFTER_KEY for
@@ -2978,7 +2984,7 @@
 int ha_ndbcluster::ordered_index_scan(const key_range *start_key,
                                       const key_range *end_key,
                                       bool sorted, bool descending,
-                                      byte* buf, part_id_range *part_spec)
+                                      uchar* buf, part_id_range *part_spec)
 {  
   NdbTransaction *trans= m_active_trans;
   NdbIndexScanOperation *op;
@@ -3083,9 +3089,9 @@
  */
 
 int ha_ndbcluster::unique_index_scan(const KEY* key_info, 
-				     const byte *key, 
+				     const uchar *key, 
 				     uint key_len,
-				     byte *buf)
+				     uchar *buf)
 {
   NdbScanOperation *op;
   NdbTransaction *trans= m_active_trans;
@@ -3178,7 +3184,7 @@
   Start full table scan in NDB
  */
 
-int ha_ndbcluster::full_table_scan(byte *buf)
+int ha_ndbcluster::full_table_scan(uchar *buf)
 {
   NdbScanOperation *op;
   NdbTransaction *trans= m_active_trans;
@@ -3256,18 +3262,19 @@
 }
 
 inline void
-ha_ndbcluster::eventSetAnyValue(const THD *thd, NdbOperation *op)
+ha_ndbcluster::eventSetAnyValue(THD *thd, NdbOperation *op)
 {
   if (unlikely(m_slow_path))
   {
-    if (!(thd->options & OPTION_BIN_LOG))
+    Thd_ndb *thd_ndb= get_thd_ndb(thd);
+    if (thd_ndb->trans_options & TNTO_NO_LOGGING)
       op->setAnyValue(NDB_ANYVALUE_FOR_NOLOGGING);
     else if (thd->slave_thread)
       op->setAnyValue(thd->server_id);
   }
 }
 
-int ha_ndbcluster::write_row(byte *record)
+int ha_ndbcluster::write_row(uchar *record)
 {
   DBUG_ENTER("ha_ndbcluster::write_row");
   DBUG_RETURN(ndb_write_row(record, FALSE, FALSE));
@@ -3276,7 +3283,8 @@
 /*
   Insert one record into NDB
 */
-int ha_ndbcluster::ndb_write_row(byte *record, bool primary_key_update,
+int ha_ndbcluster::ndb_write_row(uchar *record,
+                                 bool primary_key_update,
                                  bool batched_update)
 {
   bool has_auto_increment;
@@ -3285,7 +3293,7 @@
   THD *thd= table->in_use;
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
   uint32 part_id;
-  char *row;
+  uchar *row;
   bool need_execute;
   int error;
   DBUG_ENTER("ha_ndbcluster::ndb_write_row");
@@ -3376,13 +3384,13 @@
       Ndb_tuple_id_range_guard g(m_share);
       if (ndb->getAutoIncrementValue(m_table, g.range, auto_value, 1) == -1)
       {
-        if (--retries &&
-            ndb->getNdbError().status == NdbError::TemporaryError);
-        {
-          my_sleep(retry_sleep);
-          continue;
-        }
-        ERR_RETURN(ndb->getNdbError());
+	if (--retries &&
+	    ndb->getNdbError().status == NdbError::TemporaryError);
+	{
+	  my_sleep(retry_sleep);
+	  continue;
+	}
+	ERR_RETURN(ndb->getNdbError());
       }
       break;
     }
@@ -3434,7 +3442,7 @@
   if (m_use_write)
   {
     const NdbRecord *key_rec;
-    const char *key_row;
+    const uchar *key_row;
     uchar *mask;
     if (table_share->primary_key == MAX_KEY || m_use_partition_function)
     {
@@ -3457,10 +3465,11 @@
       key_rec= m_index[table_share->primary_key].ndb_unique_record_row;
       key_row= row;
     }
-    op= trans->writeTuple(key_rec, key_row, m_ndb_record, row, mask);
+    op= trans->writeTuple(key_rec, (const char *)key_row,
+                          m_ndb_record, (char *)row, mask);
   }
   else
-    op= trans->insertTuple(m_ndb_record, row);
+    op= trans->insertTuple(m_ndb_record, (char *)row);
   if (!(op))
     ERR_RETURN(trans->getNdbError());
 
@@ -3522,7 +3531,7 @@
 
 
 /* Compare if an update changes the primary key in a row. */
-int ha_ndbcluster::primary_key_cmp(const byte * old_row, const byte * new_row)
+int ha_ndbcluster::primary_key_cmp(const uchar * old_row, const uchar * new_row)
 {
   uint keynr= table_share->primary_key;
   KEY_PART_INFO *key_part=table->key_info[keynr].key_part;
@@ -3539,8 +3548,8 @@
     if (key_part->key_part_flag & (HA_BLOB_PART | HA_VAR_LENGTH_PART))
     {
 
-      if (key_part->field->cmp_binary((char*) (old_row + key_part->offset),
-                                      (char*) (new_row + key_part->offset),
+      if (key_part->field->cmp_binary((old_row + key_part->offset),
+                                      (new_row + key_part->offset),
                                       (ulong) key_part->length))
         return 1;
     }
@@ -3689,7 +3698,7 @@
   Update one record in NDB using primary key
 */
 
-int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
+int ha_ndbcluster::update_row(const uchar *old_data, uchar *new_data)
 {
   THD *thd= table->in_use;
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -3773,7 +3782,7 @@
 #ifdef FIXED_OLD_DATA_TO_ACTUALLY_CONTAIN_GOOD_DATA
         int undo_res;
         // Undo delete_row(old_data)
-        undo_res= ndb_write_row((byte *)old_data, TRUE, batched_update);
+        undo_res= ndb_write_row((uchar *)old_data, TRUE, batched_update);
         if (undo_res)
           push_warning(current_thd, 
                        MYSQL_ERROR::WARN_LEVEL_WARN, 
@@ -3800,7 +3809,7 @@
     clear_extended_column_set(mask);
 
   /* Need to set the value of any user-defined partitioning function. */
-  char *row;
+  uchar *row;
   bool need_execute;
   /*
     Batch update operation if we are doing a scan for update, unless
@@ -3845,7 +3854,8 @@
     */
     DBUG_PRINT("info", ("Calling updateTuple on cursor, write_set=0x%x",
                         table->write_set->bitmap[0]));
-    if (!(op= cursor->updateCurrentTuple(trans, m_ndb_record, row, mask)))
+    if (!(op= cursor->updateCurrentTuple(trans, m_ndb_record,
+                                         (const char*)row, mask)))
       ERR_RETURN(trans->getNdbError());
 
     m_lock_tuple= FALSE;
@@ -3854,7 +3864,7 @@
   else
   {  
     const NdbRecord *key_rec;
-    const char *key_row;
+    const uchar *key_row;
     if (table_share->primary_key != MAX_KEY)
     {
       key_rec= m_index[table_share->primary_key].ndb_unique_record_row;
@@ -3864,7 +3874,7 @@
     {
       /* Use hidden primary key previously read into m_ref. */
       key_rec= m_ndb_hidden_key_record;
-      key_row= (const char *)(&m_ref);
+      key_row= (const uchar *)(&m_ref);
     }
 
     NdbInterpretedCode *code= NULL;
@@ -3889,7 +3899,8 @@
       }
     }
 #endif
-    if (!(op= trans->updateTuple(key_rec, key_row, m_ndb_record, row, mask,
+    if (!(op= trans->updateTuple(key_rec, (const char *)key_row,
+                                 m_ndb_record, (const char*)row, mask,
                                  NULL, NULL, code)))
       ERR_RETURN(trans->getNdbError());  
   }
@@ -3920,7 +3931,7 @@
 }
 
 
-int ha_ndbcluster::delete_row(const byte *record)
+int ha_ndbcluster::delete_row(const uchar *record)
 {
   return ndb_delete_row(record, FALSE);
 }
@@ -3929,7 +3940,7 @@
   Delete one record from NDB, using primary key 
 */
 
-int ha_ndbcluster::ndb_delete_row(const byte *record, bool primary_key_update)
+int ha_ndbcluster::ndb_delete_row(const uchar *record, bool primary_key_update)
 {
   THD *thd= table->in_use;
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -3979,7 +3990,7 @@
   else
   {
     const NdbRecord *key_rec;
-    const char *key_row;
+    const uchar *key_row;
     uint key_len;
     if (table_share->primary_key != MAX_KEY)
     {
@@ -3990,7 +4001,7 @@
     else
     {
       key_rec= m_ndb_hidden_key_record;
-      key_row= (const char *)(&m_ref);
+      key_row= (const uchar *)(&m_ref);
       key_len= sizeof(m_ref);
     }
     /*
@@ -4028,7 +4039,7 @@
     else
       need_execute= TRUE;
 
-    if (!(op=trans->deleteTuple(key_rec, key_row)))
+    if (!(op=trans->deleteTuple(key_rec, (const char *)key_row)))
       ERR_RETURN(trans->getNdbError());
     
     if (m_use_partition_function)
@@ -4058,7 +4069,7 @@
   Note that we do not unpack all returned rows; some primary/unique key
   operations can read directly into the destination row.
 */
-void ha_ndbcluster::unpack_record(byte *dst_row, const byte *src_row)
+void ha_ndbcluster::unpack_record(uchar *dst_row, const uchar *src_row)
 {
   int res;
   DBUG_ASSERT(src_row != NULL);
@@ -4069,7 +4080,7 @@
   /* Initialize the NULL bitmap. */
   memset(dst_row, 0xff, table->s->null_bytes);
 
-  char *blob_ptr= m_blobs_buffer;
+  uchar *blob_ptr= m_blobs_buffer;
 
   for (uint i= 0; i < table_share->fields; i++) 
   {
@@ -4123,7 +4134,7 @@
         {
           /* Only copy actually used bytes of varstrings. */
           uint32 actual_length= field->used_length();
-          char *src_ptr= field->ptr;
+          uchar *src_ptr= field->ptr;
           field->move_field_offset(dst_offset - src_offset);
           field->set_notnull();
           memcpy(field->ptr, src_ptr, actual_length);
@@ -4239,10 +4250,10 @@
  */
 static
 int
-check_null_in_key(const KEY* key_info, const byte *key, uint key_len)
+check_null_in_key(const KEY* key_info, const uchar *key, uint key_len)
 {
   KEY_PART_INFO *curr_part, *end_part;
-  const byte* end_ptr= key + key_len;
+  const uchar* end_ptr= key + key_len;
   curr_part= key_info->key_part;
   end_part= curr_part + key_info->key_parts;
 
@@ -4256,8 +4267,8 @@
   return 0;
 }
 
-int ha_ndbcluster::index_read(byte *buf,
-                              const byte *key, uint key_len, 
+int ha_ndbcluster::index_read(uchar *buf,
+                              const uchar *key, uint key_len, 
                               enum ha_rkey_function find_flag)
 {
   key_range start_key;
@@ -4285,7 +4296,7 @@
 }
 
 
-int ha_ndbcluster::index_next(byte *buf)
+int ha_ndbcluster::index_next(uchar *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_next");
   ha_statistic_increment(&SSV::ha_read_next_count);
@@ -4293,7 +4304,7 @@
 }
 
 
-int ha_ndbcluster::index_prev(byte *buf)
+int ha_ndbcluster::index_prev(uchar *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_prev");
   ha_statistic_increment(&SSV::ha_read_prev_count);
@@ -4301,7 +4312,7 @@
 }
 
 
-int ha_ndbcluster::index_first(byte *buf)
+int ha_ndbcluster::index_first(uchar *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_first");
   ha_statistic_increment(&SSV::ha_read_first_count);
@@ -4312,14 +4323,14 @@
 }
 
 
-int ha_ndbcluster::index_last(byte *buf)
+int ha_ndbcluster::index_last(uchar *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_last");
   ha_statistic_increment(&SSV::ha_read_last_count);
   DBUG_RETURN(ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL));
 }
 
-int ha_ndbcluster::index_read_last(byte * buf, const byte * key, uint key_len)
+int ha_ndbcluster::index_read_last(uchar * buf, const uchar * key, uint key_len)
 {
   DBUG_ENTER("ha_ndbcluster::index_read_last");
   DBUG_RETURN(index_read(buf, key, key_len, HA_READ_PREFIX_LAST));
@@ -4328,7 +4339,7 @@
 int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key,
                                            const key_range *end_key,
                                            bool desc, bool sorted,
-                                           byte* buf)
+                                           uchar* buf)
 {
   part_id_range part_spec;
   ndb_index_type type= get_index_type(active_index);
@@ -4407,7 +4418,7 @@
                                     const key_range *end_key,
                                     bool eq_r, bool sorted)
 {
-  byte* buf= table->record[0];
+  uchar* buf= table->record[0];
   DBUG_ENTER("ha_ndbcluster::read_range_first");
   DBUG_RETURN(read_range_first_to_buf(start_key, end_key, FALSE,
                                       sorted, buf));
@@ -4471,7 +4482,7 @@
 }
 
 
-int ha_ndbcluster::rnd_next(byte *buf)
+int ha_ndbcluster::rnd_next(uchar *buf)
 {
   DBUG_ENTER("rnd_next");
   ha_statistic_increment(&SSV::ha_read_rnd_next_count);
@@ -4489,7 +4500,7 @@
   again
 */
 
-int ha_ndbcluster::rnd_pos(byte *buf, byte *pos)
+int ha_ndbcluster::rnd_pos(uchar *buf, uchar *pos)
 {
   DBUG_ENTER("rnd_pos");
   ha_statistic_increment(&SSV::ha_read_rnd_count);
@@ -4506,7 +4517,7 @@
           The partition id has been fetched from ndb
           and has been stored directly after the hidden key
         */
-        DBUG_DUMP("key+part", (char *)pos, key_length);
+        DBUG_DUMP("key+part", pos, key_length);
         key_length= ref_length - sizeof(m_part_id);
         part_spec.start_part= part_spec.end_part= *(uint32 *)(pos + key_length);
       }
@@ -4523,7 +4534,7 @@
       }
       DBUG_PRINT("info", ("partition id %u", part_spec.start_part));
     }
-    DBUG_DUMP("key", (char *)pos, key_length);
+    DBUG_DUMP("key", pos, key_length);
     DBUG_RETURN(pk_read(pos, key_length, buf, part_spec.start_part));
   }
 }
@@ -4535,12 +4546,12 @@
   using "reference" in rnd_pos
 */
 
-void ha_ndbcluster::position(const byte *record)
+void ha_ndbcluster::position(const uchar *record)
 {
   KEY *key_info;
   KEY_PART_INFO *key_part;
   KEY_PART_INFO *end;
-  byte *buff;
+  uchar *buff;
   uint key_length;
 
   DBUG_ENTER("position");
@@ -4566,7 +4577,7 @@
       }
 
       size_t len = key_part->length;
-      const byte * ptr = record + key_part->offset;
+      const uchar * ptr = record + key_part->offset;
       Field *field = key_part->field;
       if (field->type() ==  MYSQL_TYPE_VARCHAR)
       {
@@ -4617,9 +4628,9 @@
   }
 #ifndef DBUG_OFF
   if (table_share->primary_key == MAX_KEY && m_use_partition_function) 
-    DBUG_DUMP("key+part", (char*)ref, key_length+sizeof(m_part_id));
+    DBUG_DUMP("key+part", ref, key_length+sizeof(m_part_id));
 #endif
-  DBUG_DUMP("ref", (char*)ref, key_length);
+  DBUG_DUMP("ref", ref, key_length);
   DBUG_VOID_RETURN;
 }
 
@@ -5109,8 +5120,13 @@
 	thd_ndb->query_state&= NDB_QUERY_NORMAL;
         thd_ndb->trans_options= 0;
         thd_ndb->m_slow_path= FALSE;
-        if (thd->slave_thread ||
-            !(thd->options & OPTION_BIN_LOG))
+        if (!(thd->options & OPTION_BIN_LOG) ||
+            thd->variables.binlog_format == BINLOG_FORMAT_STMT)
+        {
+          thd_ndb->trans_options|= TNTO_NO_LOGGING;
+          thd_ndb->m_slow_path= TRUE;
+        }
+        else if (thd->slave_thread)
           thd_ndb->m_slow_path= TRUE;
         trans_register_ha(thd, FALSE, ndbcluster_hton);
       } 
@@ -5130,8 +5146,13 @@
 	  thd_ndb->query_state&= NDB_QUERY_NORMAL;
           thd_ndb->trans_options= 0;
           thd_ndb->m_slow_path= FALSE;
-          if (thd->slave_thread ||
-              !(thd->options & OPTION_BIN_LOG))
+          if (!(thd->options & OPTION_BIN_LOG) ||
+              thd->variables.binlog_format == BINLOG_FORMAT_STMT)
+          {
+            thd_ndb->trans_options|= TNTO_NO_LOGGING;
+            thd_ndb->m_slow_path= TRUE;
+          }
+          else if (thd->slave_thread)
             thd_ndb->m_slow_path= TRUE;
           trans_register_ha(thd, TRUE, ndbcluster_hton);
 
@@ -5247,7 +5268,6 @@
       DBUG_PRINT("warning", ("ops_pending != 0L"));
     m_ops_pending= 0;
   }
-  thd->set_current_stmt_binlog_row_based_if_mixed();
   DBUG_RETURN(error);
 }
 
@@ -5298,7 +5318,6 @@
   // Start of statement
   m_ops_pending= 0;
   m_blobs_pending= FALSE;
-  thd->set_current_stmt_binlog_row_based_if_mixed();
 
   DBUG_RETURN(error);
 }
@@ -5734,8 +5753,9 @@
   THD *thd= current_thd;
   NDBTAB tab;
   NDBCOL col;
-  uint pack_length, length, i, pk_length= 0;
-  const void *data= NULL, *pack_data= NULL;
+  size_t pack_length, length;
+  uint i, pk_length= 0;
+  uchar *data= NULL, *pack_data= NULL;
   bool create_from_engine= (create_info->table_options &
HA_OPTION_CREATE_FROM_ENGINE);
   bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE);
   char tablespace[FN_LEN];
@@ -5819,7 +5839,9 @@
     my_free((char*)data, MYF(0));
     DBUG_RETURN(2);
   }
-  DBUG_PRINT("info", ("setFrm data: 0x%lx  len: %d", (long) pack_data, pack_length));
+  DBUG_PRINT("info",
+             ("setFrm data: 0x%lx  len: %lu", (long) pack_data,
+              (ulong) pack_length));
   tab.setFrm(pack_data, pack_length);      
   my_free((char*)data, MYF(0));
   my_free((char*)pack_data, MYF(0));
@@ -6054,7 +6076,7 @@
     {
       uint length= (uint) strlen(name);
       if ((share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
-                                           (byte*) name, length)))
+                                           (uchar*) name, length)))
         handle_trailing_share(share);
     }
     /*
@@ -6136,8 +6158,8 @@
 { 
   Ndb* ndb;
   const NDBTAB *tab;
-  const void *data= NULL, *pack_data= NULL;
-  uint length, pack_length;
+  uchar *data= NULL, *pack_data= NULL;
+  size_t length, pack_length;
   int error= 0;
 
   DBUG_ENTER("create_handler_files");
@@ -6875,6 +6897,11 @@
   Constructor for the NDB Cluster table handler 
  */
 
+/*
+  Normal flags for binlogging is that ndb has HA_HAS_OWN_BINLOGGING
+  and preferes HA_BINLOG_ROW_CAPABLE
+  Other flags are set under certain circumstaces in table_flags()
+*/
 #define HA_NDBCLUSTER_TABLE_FLAGS \
                 HA_REC_NOT_IN_SEQ | \
                 HA_NULL_IN_KEY | \
@@ -6887,6 +6914,7 @@
                 HA_PRIMARY_KEY_REQUIRED_FOR_DELETE | \
                 HA_PARTIAL_COLUMN_READ | \
                 HA_HAS_OWN_BINLOGGING | \
+                HA_BINLOG_ROW_CAPABLE | \
                 HA_HAS_RECORDS
 
 ha_ndbcluster::ha_ndbcluster(handlerton *hton, TABLE_SHARE *table_arg):
@@ -7247,13 +7275,13 @@
 
 int ndbcluster_discover(handlerton *hton, THD* thd, const char *db, 
                         const char *name,
-                        const void** frmblob, 
-                        uint* frmlen)
+                        uchar **frmblob, 
+                        size_t *frmlen)
 {
   int error= 0;
   NdbError ndb_error;
-  uint len;
-  const void* data= NULL;
+  size_t len;
+  uchar* data= NULL;
   Ndb* ndb;
   char key[FN_REFLEN];
   DBUG_ENTER("ndbcluster_discover");
@@ -7314,7 +7342,7 @@
       goto err;
     }
     
-    if (unpackfrm(&data, &len, tab->getFrmData()))
+    if (unpackfrm(&data, &len, (uchar*) tab->getFrmData()))
     {
       DBUG_PRINT("error", ("Could not unpack table"));
       error= 1;
@@ -7384,11 +7412,11 @@
 
 
 
-extern "C" byte* tables_get_key(const char *entry, uint *length,
+extern "C" uchar* tables_get_key(const char *entry, size_t *length,
                                 my_bool not_used __attribute__((unused)))
 {
   *length= strlen(entry);
-  return (byte*) entry;
+  return (uchar*) entry;
 }
 
 
@@ -7569,8 +7597,8 @@
       /* finalize construction of path */
       end+= tablename_to_filename(elmt.name, end,
                                   sizeof(key)-(end-key));
-      const void *data= 0, *pack_data= 0;
-      uint length, pack_length;
+      uchar *data= 0, *pack_data= 0;
+      size_t length, pack_length;
       int discover= 0;
       if (readfrm(key, &data, &length) ||
           packfrm(data, length, &pack_data, &pack_length))
@@ -7698,7 +7726,7 @@
         continue;
     }
     DBUG_PRINT("info", ("Inserting %s into ndb_tables hash", elmt.name));     
-    my_hash_insert(&ndb_tables, (byte*)thd->strdup(elmt.name));
+    my_hash_insert(&ndb_tables, (uchar*)thd->strdup(elmt.name));
   }
 
   char *file_name;
@@ -7708,7 +7736,7 @@
   {
     bool file_on_disk= FALSE;
     DBUG_PRINT("info", ("%s", file_name));     
-    if (hash_search(&ndb_tables, file_name, strlen(file_name)))
+    if (hash_search(&ndb_tables, (uchar*) file_name, strlen(file_name)))
     {
       DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name));
       file_on_disk= TRUE;
@@ -7724,7 +7752,8 @@
       if (file_on_disk)
       {
 	// Ignore this ndb table
-	gptr record=  hash_search(&ndb_tables, file_name, strlen(file_name));
+	uchar *record= hash_search(&ndb_tables, (uchar*) file_name,
+                                   strlen(file_name));
 	DBUG_ASSERT(record);
 	hash_delete(&ndb_tables, record);
 	push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
@@ -7737,7 +7766,7 @@
     if (file_on_disk) 
     {
       // File existed in NDB and as frm file, put in ok_tables list
-      my_hash_insert(&ok_tables, (byte*)file_name);
+      my_hash_insert(&ok_tables, (uchar*)file_name);
       continue;
     }
     DBUG_PRINT("info", ("%s existed on disk", name));     
@@ -7775,8 +7804,8 @@
   List<char> create_list;
   for (i= 0 ; i < ndb_tables.records ; i++)
   {
-    file_name= hash_element(&ndb_tables, i);
-    if (!hash_search(&ok_tables, file_name, strlen(file_name)))
+    file_name= (char*) hash_element(&ndb_tables, i);
+    if (!hash_search(&ok_tables, (uchar*) file_name, strlen(file_name)))
     {
       build_table_filename(name, sizeof(name), db, file_name, reg_ext, 0);
       if (my_access(name, F_OK))
@@ -8138,7 +8167,7 @@
         if (g_ndb_cluster_connection_pool[i])
           delete g_ndb_cluster_connection_pool[i];
       }
-      my_free((gptr) g_ndb_cluster_connection_pool, MYF(MY_ALLOW_ZERO_PTR));
+      my_free((uchar*) g_ndb_cluster_connection_pool, MYF(MY_ALLOW_ZERO_PTR));
       pthread_mutex_destroy(&g_ndb_cluster_connection_pool_mutex);
       g_ndb_cluster_connection_pool= 0;
     }
@@ -8218,7 +8247,7 @@
         if (g_ndb_cluster_connection_pool[i])
           delete g_ndb_cluster_connection_pool[i];
       }
-      my_free((gptr) g_ndb_cluster_connection_pool, MYF(MY_ALLOW_ZERO_PTR));
+      my_free((uchar*) g_ndb_cluster_connection_pool, MYF(MY_ALLOW_ZERO_PTR));
       pthread_mutex_destroy(&g_ndb_cluster_connection_pool_mutex);
       g_ndb_cluster_connection_pool= 0;
     }
@@ -8465,9 +8494,17 @@
 
 ulonglong ha_ndbcluster::table_flags(void) const
 {
+  THD *thd= current_thd;
+  ulonglong f= m_table_flags;
   if (m_ha_not_exact_count)
-    return m_table_flags & ~HA_STATS_RECORDS_IS_EXACT;
-  return m_table_flags;
+    f= f & ~HA_STATS_RECORDS_IS_EXACT;
+  /*
+    To allow for logging of ndb tables during stmt based logging;
+    flag cabablity, but also turn off flag for OWN_BINLOGGING
+  */
+  if (thd->variables.binlog_format == BINLOG_FORMAT_STMT)
+    f= (f | HA_BINLOG_STMT_CAPABLE) & ~HA_HAS_OWN_BINLOGGING;
+  return f;
 }
 const char * ha_ndbcluster::table_type() const 
 {
@@ -8533,7 +8570,7 @@
   DBUG_PRINT("enter", ("name: %s", name));
   pthread_mutex_lock(&ndbcluster_mutex);
   if (!(share=(NDB_SHARE*) hash_search(&ndbcluster_open_tables,
-                                       (byte*) name,
+                                       (uchar*) name,
                                        strlen(name))))
   {
     pthread_mutex_unlock(&ndbcluster_mutex);
@@ -8758,11 +8795,11 @@
   data we want to or can share.
  */
 
-static byte *ndbcluster_get_key(NDB_SHARE *share,uint *length,
+static uchar *ndbcluster_get_key(NDB_SHARE *share, size_t *length,
                                 my_bool not_used __attribute__((unused)))
 {
   *length= share->key_length;
-  return (byte*) share->key;
+  return (uchar*) share->key;
 }
 
 
@@ -8905,7 +8942,7 @@
     at the cost of a possible mem leak, by "renaming" the share
     - First remove from hash
   */
-  hash_delete(&ndbcluster_open_tables, (byte*) share);
+  hash_delete(&ndbcluster_open_tables, (uchar*) share);
 
   /*
     now give it a new name, just a running number
@@ -8915,7 +8952,7 @@
     const uint min_key_length= 10;
     if (share->key_length < min_key_length)
     {
-      share->key= alloc_root(&share->mem_root, min_key_length + 1);
+      share->key= (char*) alloc_root(&share->mem_root, min_key_length + 1);
       share->key_length= min_key_length;
     }
     share->key_length=
@@ -8923,7 +8960,7 @@
                   trailing_share_id++);
   }
   /* Keep it for possible the future trailing free */
-  my_hash_insert(&ndbcluster_open_tables, (byte*) share);
+  my_hash_insert(&ndbcluster_open_tables, (uchar*) share);
 
   DBUG_RETURN(0);
 }
@@ -8939,11 +8976,11 @@
   DBUG_PRINT("rename_share", ("old_key: %s  old__length: %d",
                               share->key, share->key_length));
   if ((tmp= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
-                                     (byte*) new_key, new_length)))
+                                     (uchar*) new_key, new_length)))
     handle_trailing_share(tmp);
 
   /* remove the share from hash */
-  hash_delete(&ndbcluster_open_tables, (byte*) share);
+  hash_delete(&ndbcluster_open_tables, (uchar*) share);
   dbug_print_open_tables();
 
   /* save old stuff if insert should fail */
@@ -8954,18 +8991,18 @@
     now allocate and set the new key, db etc
     enough space for key, db, and table_name
   */
-  share->key= alloc_root(&share->mem_root, 2 * (new_length + 1));
+  share->key= (char*) alloc_root(&share->mem_root, 2 * (new_length + 1));
   strmov(share->key, new_key);
   share->key_length= new_length;
 
-  if (my_hash_insert(&ndbcluster_open_tables, (byte*) share))
+  if (my_hash_insert(&ndbcluster_open_tables, (uchar*) share))
   {
     // ToDo free the allocated stuff above?
     DBUG_PRINT("error", ("rename_share: my_hash_insert %s failed",
                          share->key));
     share->key= old_key;
     share->key_length= old_length;
-    if (my_hash_insert(&ndbcluster_open_tables, (byte*) share))
+    if (my_hash_insert(&ndbcluster_open_tables, (uchar*) share))
     {
       sql_print_error("rename_share: failed to recover %s", share->key);
       DBUG_PRINT("error", ("rename_share: my_hash_insert %s failed",
@@ -9045,7 +9082,7 @@
   if (!have_lock)
     pthread_mutex_lock(&ndbcluster_mutex);
   if (!(share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
-                                        (byte*) key,
+                                        (uchar*) key,
                                         length)))
   {
     if (!create_if_not_exists)
@@ -9065,13 +9102,13 @@
       *root_ptr= &share->mem_root; // remember to reset before return
       share->state= NSS_INITIAL;
       /* enough space for key, db, and table_name */
-      share->key= alloc_root(*root_ptr, 2 * (length + 1));
+      share->key= (char*) alloc_root(*root_ptr, 2 * (length + 1));
       share->key_length= length;
       strmov(share->key, key);
-      if (my_hash_insert(&ndbcluster_open_tables, (byte*) share))
+      if (my_hash_insert(&ndbcluster_open_tables, (uchar*) share))
       {
         free_root(&share->mem_root, MYF(0));
-        my_free((gptr) share, 0);
+        my_free((uchar*) share, 0);
         *root_ptr= old_root;
         if (!have_lock)
           pthread_mutex_unlock(&ndbcluster_mutex);
@@ -9114,7 +9151,7 @@
   DBUG_ENTER("ndbcluster_real_free_share");
   dbug_print_share("ndbcluster_real_free_share:", *share);
 
-  hash_delete(&ndbcluster_open_tables, (byte*) *share);
+  hash_delete(&ndbcluster_open_tables, (uchar*) *share);
   thr_lock_delete(&(*share)->lock);
   pthread_mutex_destroy(&(*share)->mutex);
 
@@ -9126,15 +9163,15 @@
     // (*share)->table_share->mem_root is freed by free_table_share
     free_table_share((*share)->table_share);
 #ifndef DBUG_OFF
-    bzero((gptr)(*share)->table_share, sizeof(*(*share)->table_share));
-    bzero((gptr)(*share)->table, sizeof(*(*share)->table));
+    bzero((uchar*)(*share)->table_share, sizeof(*(*share)->table_share));
+    bzero((uchar*)(*share)->table, sizeof(*(*share)->table));
     (*share)->table_share= 0;
     (*share)->table= 0;
 #endif
   }
 #endif
   free_root(&(*share)->mem_root, MYF(0));
-  my_free((gptr) *share, MYF(0));
+  my_free((uchar*) *share, MYF(0));
   *share= 0;
 
   dbug_print_open_tables();
@@ -9535,13 +9572,13 @@
   KEY* key_info= table->key_info + active_index;
   KEY_MULTI_RANGE *range= ranges;
   ulong reclength= table->s->reclength;
-  byte *curr= (byte*)buffer->buffer;
-  byte *end_of_buffer= (byte*)buffer->buffer_end;
+  uchar *curr= (uchar*)buffer->buffer;
+  uchar *end_of_buffer= (uchar*)buffer->buffer_end;
   
   for (; range<end_range && curr+reclength <= end_of_buffer; 
        range++)
   {
-    const byte *key= range->start_key.key;
+    const uchar *key= range->start_key.key;
     uint key_len= range->start_key.length;
     if (check_null_in_key(key_info, key, key_len))
       DBUG_RETURN(TRUE);
@@ -9675,8 +9712,8 @@
   const NdbOperation* lastOp= m_active_trans->getLastDefinedOperation();
   NdbOperation::LockMode lm= 
     (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type, table->read_set);
-  byte *row_buf= (byte*)buffer->buffer;
-  byte *end_of_buffer= (byte*)buffer->buffer_end;
+  uchar *row_buf= (uchar *)buffer->buffer;
+  const uchar *end_of_buffer= buffer->buffer_end;
   uint num_scan_ranges= 0;
   uint i;
   for (i= 0; i < range_count; i++)
@@ -9806,7 +9843,7 @@
   if (execute_no_commit_ie(this, m_active_trans, true))
     ERR_RETURN(m_active_trans->getNdbError());
 
-  m_multi_range_result_ptr= (byte*)buffer->buffer;
+  m_multi_range_result_ptr= buffer->buffer;
 
   DBUG_RETURN(read_multi_range_next(found_range_p));
 }
@@ -9836,7 +9873,7 @@
       multi_range_curr= old_multi_range_curr + 1;
       const NdbOperation *op= m_current_multi_operation;
       m_current_multi_operation= m_active_trans->getNextCompletedOperation(op);
-      byte *src_row= m_multi_range_result_ptr;
+      const uchar *src_row= m_multi_range_result_ptr;
       m_multi_range_result_ptr= src_row + table_share->reclength;
 
       const NdbError &error= op->getNdbError();
@@ -10011,7 +10048,7 @@
   char *str;
   const char *fmt="%s%snumber_of_replicas: %d";
   const unsigned fmt_len_plus_extra= length + strlen(fmt);
-  if ((str= my_malloc(fmt_len_plus_extra, MYF(0))) == NULL)
+  if ((str= (char*) my_malloc(fmt_len_plus_extra, MYF(0))) == NULL)
   {
     sql_print_error("ha_ndbcluster::update_table_comment: "
                     "my_malloc(%u) failed", (unsigned int)fmt_len_plus_extra);
@@ -10060,7 +10097,6 @@
   my_net_init(&thd->net, 0);
   thd->main_security_ctx.master_access= ~0;
   thd->main_security_ctx.priv_user = 0;
-  thd->current_stmt_binlog_row_based= TRUE;     // If in mixed mode
 
   CHARSET_INFO *charset_connection;
   charset_connection= get_charset_by_csname("utf8",

--- 1.187/sql/ha_ndbcluster.h	2007-07-04 09:53:36 +02:00
+++ 1.188/sql/ha_ndbcluster.h	2007-07-05 13:54:00 +02:00
@@ -95,7 +95,7 @@
 typedef union { const NdbRecAttr *rec; NdbBlob *blob; void *ptr; } NdbValue;
 
 int get_ndb_blobs_value(TABLE* table, NdbValue* value_array,
-                        byte*& buffer, uint& buffer_size,
+                        uchar*& buffer, uint& buffer_size,
                         my_ptrdiff_t ptrdiff);
 
 typedef enum {
@@ -128,7 +128,7 @@
   char *old_names; // for rename table
   TABLE_SHARE *table_share;
   TABLE *table;
-  byte *record[2]; // pointer to allocated records for receiving data
+  uchar *record[2]; // pointer to allocated records for receiving data
   NdbValue *ndb_value[2];
   MY_BITMAP *subscriber_bitmap;
 #endif
@@ -212,6 +212,7 @@
 enum THD_NDB_TRANS_OPTIONS
 {
   TNTO_INJECTED_APPLY_STATUS= 1 << 0
+  ,TNTO_NO_LOGGING=           1 << 1
 };
 
 struct Ndb_local_table_statistics {
@@ -272,30 +273,30 @@
   int open(const char *name, int mode, uint test_if_locked);
   int close(void);
 
-  int write_row(byte *buf);
-  int update_row(const byte *old_data, byte *new_data);
-  int delete_row(const byte *buf);
+  int write_row(uchar *buf);
+  int update_row(const uchar *old_data, uchar *new_data);
+  int delete_row(const uchar *buf);
   int index_init(uint index, bool sorted);
   int index_end();
-  int index_read(byte *buf, const byte *key, uint key_len, 
+  int index_read(uchar *buf, const uchar *key, uint key_len, 
                  enum ha_rkey_function find_flag);
-  int index_next(byte *buf);
-  int index_prev(byte *buf);
-  int index_first(byte *buf);
-  int index_last(byte *buf);
-  int index_read_last(byte * buf, const byte * key, uint key_len);
+  int index_next(uchar *buf);
+  int index_prev(uchar *buf);
+  int index_first(uchar *buf);
+  int index_last(uchar *buf);
+  int index_read_last(uchar * buf, const uchar * key, uint key_len);
   int rnd_init(bool scan);
   int rnd_end();
-  int rnd_next(byte *buf);
-  int rnd_pos(byte *buf, byte *pos);
-  void position(const byte *record);
+  int rnd_next(uchar *buf);
+  int rnd_pos(uchar *buf, uchar *pos);
+  void position(const uchar *record);
   int read_range_first(const key_range *start_key,
                        const key_range *end_key,
                        bool eq_range, bool sorted);
   int read_range_first_to_buf(const key_range *start_key,
                               const key_range *end_key,
                               bool eq_range, bool sorted,
-                              byte* buf);
+                              uchar* buf);
   int read_range_next();
   int alter_tablespace(st_alter_tablespace *info);
 
@@ -472,34 +473,35 @@
   char* get_tablespace_name(THD *thd, char *name, uint name_len);
   int set_range_data(void *tab, partition_info* part_info);
   int set_list_data(void *tab, partition_info* part_info);
-  int complemented_read(const byte *old_data, byte *new_data,
+  int complemented_read(const uchar *old_data, uchar *new_data,
                         uint32 old_part_id);
-  int pk_read(const byte *key, uint key_len, byte *buf, uint32 part_id);
+  int pk_read(const uchar *key, uint key_len, uchar *buf, uint32 part_id);
   int ordered_index_scan(const key_range *start_key,
                          const key_range *end_key,
-                         bool sorted, bool descending, byte* buf,
+                         bool sorted, bool descending, uchar* buf,
                          part_id_range *part_spec);
-  int unique_index_read(const byte *key, uint key_len, 
-                        byte *buf);
+  int unique_index_read(const uchar *key, uint key_len, 
+                        uchar *buf);
   int unique_index_scan(const KEY* key_info, 
-			const byte *key, 
+			const uchar *key, 
 			uint key_len,
-			byte *buf);
-  int full_table_scan(byte * buf);
+			uchar *buf);
+  int full_table_scan(uchar * buf);
   int flush_bulk_insert();
-  int ndb_write_row(byte *record, bool primary_key_update, bool batched_update);
-  int ndb_delete_row(const byte *record, bool primary_key_update);
+  int ndb_write_row(uchar *record, bool primary_key_update,
+                    bool batched_update);
+  int ndb_delete_row(const uchar *record, bool primary_key_update);
 
   bool check_all_operations_for_error(NdbTransaction *trans,
                                       const NdbOperation *first,
                                       const NdbOperation *last,
                                       uint errcode);
-  int peek_indexed_rows(const byte *record, bool check_pk);
+  int peek_indexed_rows(const uchar *record, bool check_pk);
   int scan_handle_lock_tuple(NdbScanOperation *scanOp, NdbTransaction *trans);
   int fetch_next(NdbScanOperation* op);
-  int next_result(byte *buf); 
+  int next_result(uchar *buf); 
   int close_scan();
-  void unpack_record(byte *dst_row, const byte *src_row);
+  void unpack_record(uchar *dst_row, const uchar *src_row);
   int get_ndb_lock_type(enum thr_lock_type type,
                         const MY_BITMAP *column_bitmap);
 
@@ -523,37 +525,37 @@
       (table_share->primary_key == MAX_KEY ? 1 : 0);
   }
 
-  void set_hidden_key(char *row, Uint64 auto_value);
-  Uint64 get_hidden_key(const char *row);
+  void set_hidden_key(uchar *row, Uint64 auto_value);
+  Uint64 get_hidden_key(const uchar *row);
   void request_hidden_key(uchar *mask);
-  void set_partition_function_value(char *row, uint32 func_value);
-  uint32 get_partition_fragment(const char *row);
+  void set_partition_function_value(uchar *row, uint32 func_value);
+  uint32 get_partition_fragment(const uchar *row);
   void request_partition_function_value(uchar *mask);
-  char *batch_copy_row_to_buffer(Thd_ndb *thd_ndb, const byte *record,
-                                 bool & batch_full);
-  char *batch_copy_key_to_buffer(Thd_ndb *thd_ndb, const byte *key,
-                                 uint key_len,
-                                 uint op_batch_size, bool & batch_full);
-  char *copy_row_to_buffer(Thd_ndb *thd_ndb, const byte *record);
-  char *get_row_buffer();
+  uchar *batch_copy_row_to_buffer(Thd_ndb *thd_ndb, const uchar *record,
+                                  bool & batch_full);
+  uchar *batch_copy_key_to_buffer(Thd_ndb *thd_ndb, const uchar *key,
+                                  uint key_len,
+                                  uint op_batch_size, bool & batch_full);
+  uchar *copy_row_to_buffer(Thd_ndb *thd_ndb, const uchar *record);
+  uchar *get_row_buffer();
   char *get_buffer(uint size);
   void clear_extended_column_set(uchar *mask);
   uchar *copy_column_set(MY_BITMAP *bitmap);
 
-  int get_blob_values(NdbOperation *ndb_op, byte *dst_record,
+  int get_blob_values(NdbOperation *ndb_op, uchar *dst_record,
                       const MY_BITMAP *bitmap);
   int set_blob_values(NdbOperation *ndb_op, my_ptrdiff_t row_offset,
                       const MY_BITMAP *bitmap, uint *set_count);
   friend int g_get_ndb_blobs_value(NdbBlob *ndb_blob, void *arg);
-  void eventSetAnyValue(const THD *thd, NdbOperation *op);
+  void eventSetAnyValue(THD *thd, NdbOperation *op);
 
-  NdbOperation *pk_unique_index_read_key(uint idx, const byte *key, byte *buf,
+  NdbOperation *pk_unique_index_read_key(uint idx, const uchar *key, uchar *buf,
                                          NdbOperation::LockMode lm);
   int read_multi_range_fetch_next();
   
   int set_bounds(NdbIndexScanOperation*, uint inx, bool rir,
                  const key_range *keys[2], uint= 0);
-  int primary_key_cmp(const byte * old_row, const byte * new_row);
+  int primary_key_cmp(const uchar * old_row, const uchar * new_row);
   void print_results();
 
   virtual void get_auto_increment(ulonglong offset, ulonglong increment,
@@ -623,7 +625,11 @@
   /*
     Pointer to row returned from scan nextResult().
   */
-  const char *m_next_row;
+  union
+  {
+    const char *_m_next_row;
+    const uchar *m_next_row;
+  };
   /* For read_multi_range scans, the get_range_no() of current row. */
   int m_current_range_no;
   /*
@@ -662,11 +668,11 @@
   /* State for setActiveHook() callback for reading blob data. */
   uint m_blob_counter;
   uint m_blob_expected_count;
-  byte *m_blob_destination_record;
+  uchar *m_blob_destination_record;
   Uint64 m_blob_total_size;
   
   // memory for blobs in one tuple
-  char *m_blobs_buffer;
+  uchar *m_blobs_buffer;
   uint32 m_blobs_buffer_size;
   uint m_dupkey;
   // set from thread variables at external lock
@@ -677,7 +683,7 @@
 
   ha_ndbcluster_cond *m_cond;
   bool m_disable_multi_read;
-  byte *m_multi_range_result_ptr;
+  const uchar *m_multi_range_result_ptr;
   KEY_MULTI_RANGE *m_multi_ranges;
   /*
     Points 1 past the end of last multi range operation currently being

--- 1.235/sql/set_var.cc	2007-06-08 22:22:18 +02:00
+++ 1.236/sql/set_var.cc	2007-07-05 13:48:39 +02:00
@@ -124,9 +124,9 @@
 static void fix_server_id(THD *thd, enum_var_type type);
 static KEY_CACHE *create_key_cache(const char *name, uint length);
 void fix_sql_mode_var(THD *thd, enum_var_type type);
-static byte *get_error_count(THD *thd);
-static byte *get_warning_count(THD *thd);
-static byte *get_tmpdir(THD *thd);
+static uchar *get_error_count(THD *thd);
+static uchar *get_warning_count(THD *thd);
+static uchar *get_tmpdir(THD *thd);
 static int  sys_check_log_path(THD *thd,  set_var *var);
 static bool sys_update_general_log_path(THD *thd, set_var * var);
 static void sys_default_general_log_path(THD *thd, enum_var_type type);
@@ -709,8 +709,6 @@
 #ifdef HAVE_SYS_UN_H
   {"socket",                  (char*) &mysqld_unix_port,            SHOW_CHAR_PTR},
 #endif
-  {"table_definition_cache",  (char*) &table_def_size,              SHOW_LONG},
-  {"table_lock_wait_timeout", (char*) &table_lock_wait_timeout,     SHOW_LONG },
 #ifdef HAVE_THR_SETCONCURRENCY
   {"thread_concurrency",      (char*) &concurrency,                 SHOW_LONG},
 #endif
@@ -798,7 +796,7 @@
 static int sys_check_ftb_syntax(THD *thd,  set_var *var)
 {
   if (thd->security_ctx->master_access & SUPER_ACL)
-    return (ft_boolean_check_syntax_string((byte*)
+    return (ft_boolean_check_syntax_string((uchar*)
                                            var->value->str_value.c_ptr()) ?
             -1 : 0);
   else
@@ -834,7 +832,11 @@
 
 static void fix_low_priority_updates(THD *thd, enum_var_type type)
 {
-  if (type != OPT_GLOBAL)
+  if (type == OPT_GLOBAL)
+    thr_upgraded_concurrent_insert_lock= 
+      (global_system_variables.low_priority_updates ?
+       TL_WRITE_LOW_PRIORITY : TL_WRITE);
+  else
     thd->update_lock_default= (thd->variables.low_priority_updates ?
 			       TL_WRITE_LOW_PRIORITY : TL_WRITE);
 }
@@ -912,14 +914,14 @@
 static void fix_net_read_timeout(THD *thd, enum_var_type type)
 {
   if (type != OPT_GLOBAL)
-    net_set_read_timeout(&thd->net, thd->variables.net_read_timeout);
+    my_net_set_read_timeout(&thd->net, thd->variables.net_read_timeout);
 }
 
 
 static void fix_net_write_timeout(THD *thd, enum_var_type type)
 {
   if (type != OPT_GLOBAL)
-    net_set_write_timeout(&thd->net, thd->variables.net_write_timeout);
+    my_net_set_write_timeout(&thd->net, thd->variables.net_write_timeout);
 }
 
 static void fix_net_retry_count(THD *thd, enum_var_type type)
@@ -943,12 +945,19 @@
 static void fix_query_cache_size(THD *thd, enum_var_type type)
 {
 #ifdef HAVE_QUERY_CACHE
-  ulong requested= query_cache_size;
-  query_cache.resize(query_cache_size);
-  if (requested != query_cache_size)
+  ulong new_cache_size= query_cache.resize(query_cache_size);
+
+  /*
+     Note: query_cache_size is a global variable reflecting the 
+     requested cache size. See also query_cache_size_arg
+  */
+
+  if (query_cache_size != new_cache_size)
     push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
 			ER_WARN_QC_RESIZE, ER(ER_WARN_QC_RESIZE),
-			requested, query_cache_size);
+			query_cache_size, new_cache_size);
+  
+  query_cache_size= new_cache_size;
 #endif
 }
 
@@ -1010,17 +1019,6 @@
     my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
     return 1;    
   }
-#ifdef HAVE_NDB_BINLOG
-  /*
-    Cluster does not support changing the binlog format on the fly yet.
-  */
-  LEX_STRING ndb_name= {(char*)STRING_WITH_LEN("ndbcluster")};
-  if (opt_bin_log && plugin_is_ready(&ndb_name, MYSQL_STORAGE_ENGINE_PLUGIN))
-  {
-    my_error(ER_NDB_CANT_SWITCH_BINLOG_FORMAT, MYF(0));
-    return 1;
-  }
-#endif /* HAVE_NDB_BINLOG */
   return sys_var_thd_enum::is_readonly();
 }
 
@@ -1182,9 +1180,9 @@
 }
 
 
-byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+uchar *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
 {
-  return (byte*) enum_names->type_names[*value];
+  return (uchar*) enum_names->type_names[*value];
 }
 
 bool sys_var_thd_ulong::check(THD *thd, set_var *var)
@@ -1229,12 +1227,12 @@
 }
 
 
-byte *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
 				   LEX_STRING *base)
 {
   if (type == OPT_GLOBAL)
-    return (byte*) &(global_system_variables.*offset);
-  return (byte*) &(thd->variables.*offset);
+    return (uchar*) &(global_system_variables.*offset);
+  return (uchar*) &(thd->variables.*offset);
 }
 
 
@@ -1275,12 +1273,12 @@
 }
 
 
-byte *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
 				     LEX_STRING *base)
 {
   if (type == OPT_GLOBAL)
-    return (byte*) &(global_system_variables.*offset);
-  return (byte*) &(thd->variables.*offset);
+    return (uchar*) &(global_system_variables.*offset);
+  return (uchar*) &(thd->variables.*offset);
 }
 
 bool sys_var_thd_ulonglong::update(THD *thd,  set_var *var)
@@ -1318,12 +1316,12 @@
 }
 
 
-byte *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
 				       LEX_STRING *base)
 {
   if (type == OPT_GLOBAL)
-    return (byte*) &(global_system_variables.*offset);
-  return (byte*) &(thd->variables.*offset);
+    return (uchar*) &(global_system_variables.*offset);
+  return (uchar*) &(thd->variables.*offset);
 }
 
 
@@ -1346,12 +1344,12 @@
 }
 
 
-byte *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
 				  LEX_STRING *base)
 {
   if (type == OPT_GLOBAL)
-    return (byte*) &(global_system_variables.*offset);
-  return (byte*) &(thd->variables.*offset);
+    return (uchar*) &(global_system_variables.*offset);
+  return (uchar*) &(thd->variables.*offset);
 }
 
 
@@ -1499,6 +1497,25 @@
     pthread_mutex_unlock(&LOCK_global_system_variables);
     return new Item_int(value,1);
   }
+  case SHOW_CHAR_PTR:
+  {
+    Item *tmp;
+    pthread_mutex_lock(&LOCK_global_system_variables);
+    char *str= *(char**) value_ptr(thd, var_type, base);
+    if (str)
+    {
+      uint length= strlen(str);
+      tmp= new Item_string(thd->strmake(str, length), length,
+                           system_charset_info, DERIVATION_SYSCONST);
+    }
+    else
+    {
+      tmp= new Item_null();
+      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
+    }
+    pthread_mutex_unlock(&LOCK_global_system_variables);
+    return tmp;
+  }
   case SHOW_CHAR:
   {
     Item *tmp;
@@ -1541,13 +1558,13 @@
 }
 
 
-byte *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
 				  LEX_STRING *base)
 {
   ulong tmp= ((type == OPT_GLOBAL) ?
 	      global_system_variables.*offset :
 	      thd->variables.*offset);
-  return (byte*) enum_names->type_names[tmp];
+  return (uchar*) enum_names->type_names[tmp];
 }
 
 bool sys_var_thd_bit::check(THD *thd, set_var *var)
@@ -1563,7 +1580,7 @@
 }
 
 
-byte *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type,
 				 LEX_STRING *base)
 {
   /*
@@ -1572,7 +1589,7 @@
   */
   thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
 				   !reverse : reverse);
-  return (byte*) &thd->sys_var_tmp.my_bool_value;
+  return (uchar*) &thd->sys_var_tmp.my_bool_value;
 }
 
 
@@ -1583,7 +1600,7 @@
 {
   DATE_TIME_FORMAT *old;
   DBUG_ENTER("sys_var_date_time_format::update2");
-  DBUG_DUMP("positions",(char*) new_value->positions,
+  DBUG_DUMP("positions", (uchar*) new_value->positions,
 	    sizeof(new_value->positions));
 
   if (type == OPT_GLOBAL)
@@ -1663,7 +1680,7 @@
 }
 
 
-byte *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
 					      LEX_STRING *base)
 {
   if (type == OPT_GLOBAL)
@@ -1676,9 +1693,9 @@
     */
     res= thd->strmake((global_system_variables.*offset)->format.str,
 		      (global_system_variables.*offset)->format.length);
-    return (byte*) res;
+    return (uchar*) res;
   }
-  return (byte*) (thd->variables.*offset)->format.str;
+  return (uchar*) (thd->variables.*offset)->format.str;
 }
 
 
@@ -1799,11 +1816,11 @@
 }
 
 
-byte *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
 				       LEX_STRING *base)
 {
   CHARSET_INFO *cs= ci_ptr(thd,type)[0];
-  return cs ? (byte*) cs->csname : (byte*) NULL;
+  return cs ? (uchar*) cs->csname : (uchar*) NULL;
 }
 
 
@@ -1873,11 +1890,12 @@
 }
 
 
-byte *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
+                                       LEX_STRING *base)
 {
   CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
-		  global_system_variables.*offset : thd->variables.*offset);
-  return cs ? (byte*) cs->name : (byte*) "NULL";
+		     global_system_variables.*offset : thd->variables.*offset);
+  return cs ? (uchar*) cs->name : (uchar*) "NULL";
 }
 
 
@@ -1895,13 +1913,13 @@
 }
 
 
-byte *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
 					 LEX_STRING *base)
 {
   KEY_CACHE *key_cache= get_key_cache(base);
   if (!key_cache)
     key_cache= &zero_key_cache;
-  return (byte*) key_cache + offset ;
+  return (uchar*) key_cache + offset ;
 }
 
 
@@ -2087,11 +2105,12 @@
   }
   else
   {
+    size_t path_length;
     /*
       Check if directory exists and 
       we have permission to create file & write to file
     */
-    (void) dirname_part(path, var_path);
+    (void) dirname_part(path, var_path, &path_length);
     if (my_access(path, (F_OK|W_OK)))
       return -1;
   }
@@ -2217,7 +2236,7 @@
 }
 
 
-byte *sys_var_log_output::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_log_output::value_ptr(THD *thd, enum_var_type type,
                                     LEX_STRING *base)
 {
   char buff[256];
@@ -2238,7 +2257,7 @@
 
   if ((length= tmp.length()))
     length--;
-  return (byte*) thd->strmake(tmp.ptr(), length);
+  return (uchar*) thd->strmake(tmp.ptr(), length);
 }
 
 
@@ -2277,11 +2296,11 @@
 }
 
 
-byte *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type,
 				   LEX_STRING *base)
 {
   thd->sys_var_tmp.long_value= (long) thd->start_time;
-  return (byte*) &thd->sys_var_tmp.long_value;
+  return (uchar*) &thd->sys_var_tmp.long_value;
 }
 
 
@@ -2293,7 +2312,7 @@
 }
 
 
-byte *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type,
 					LEX_STRING *base)
 {
   /*
@@ -2302,7 +2321,7 @@
   */
   thd->sys_var_tmp.ulonglong_value= 
     thd->read_first_successful_insert_id_in_prev_stmt();
-  return (byte*) &thd->sys_var_tmp.ulonglong_value;
+  return (uchar*) &thd->sys_var_tmp.ulonglong_value;
 }
 
 
@@ -2313,12 +2332,12 @@
 }
 
 
-byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
 				   LEX_STRING *base)
 {
   thd->sys_var_tmp.ulonglong_value= 
     thd->auto_inc_intervals_forced.minimum();
-  return (byte*) &thd->sys_var_tmp.ulonglong_value;
+  return (uchar*) &thd->sys_var_tmp.ulonglong_value;
 }
 
 
@@ -2365,7 +2384,7 @@
 }
 
 
-byte *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
 				       LEX_STRING *base)
 {
   /* 
@@ -2373,7 +2392,7 @@
     time zone name is guaranteed to be zero ended.
   */
   if (type == OPT_GLOBAL)
-    return (byte *)(global_system_variables.time_zone->get_name()->ptr());
+    return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
   else
   {
     /*
@@ -2385,7 +2404,7 @@
       (binlog code stores session value only).
     */
     thd->time_zone_used= 1;
-    return (byte *)(thd->variables.time_zone->get_name()->ptr());
+    return (uchar *)(thd->variables.time_zone->get_name()->ptr());
   }
 }
 
@@ -2447,13 +2466,13 @@
 }
 
 
-byte *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
                                        LEX_STRING *base)
 {
   if (type != OPT_GLOBAL &&
       thd->user_connect && thd->user_connect->user_resources.user_conn)
-    return (byte*) &(thd->user_connect->user_resources.user_conn);
-  return (byte*) &(max_user_connections);
+    return (uchar*) &(thd->user_connect->user_resources.user_conn);
+  return (uchar*) &(max_user_connections);
 }
 
 
@@ -2504,12 +2523,12 @@
 }
 
 
-byte *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type,
 					  LEX_STRING *base)
 {
   return type == OPT_GLOBAL ?
-                 (byte *) global_system_variables.lc_time_names->name :
-                 (byte *) thd->variables.lc_time_names->name;
+                 (uchar *) global_system_variables.lc_time_names->name :
+                 (uchar *) thd->variables.lc_time_names->name;
 }
 
 
@@ -2618,20 +2637,20 @@
 #endif
 }
 
-static byte *get_warning_count(THD *thd)
+static uchar *get_warning_count(THD *thd)
 {
   thd->sys_var_tmp.long_value=
     (thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
      thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
      thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
-  return (byte*) &thd->sys_var_tmp.long_value;
+  return (uchar*) &thd->sys_var_tmp.long_value;
 }
 
-static byte *get_error_count(THD *thd)
+static uchar *get_error_count(THD *thd)
 {
   thd->sys_var_tmp.long_value= 
     thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
-  return (byte*) &thd->sys_var_tmp.long_value;
+  return (uchar*) &thd->sys_var_tmp.long_value;
 }
 
 
@@ -2652,11 +2671,11 @@
   RETURN VALUES
     ptr		pointer to NUL-terminated string
  */
-static byte *get_tmpdir(THD *thd)
+static uchar *get_tmpdir(THD *thd)
 {
   if (opt_mysql_tmpdir)
-    return (byte *)opt_mysql_tmpdir;
-  return (byte*)mysql_tmpdir;
+    return (uchar *)opt_mysql_tmpdir;
+  return (uchar*)mysql_tmpdir;
 }
 
 /****************************************************************************
@@ -2702,11 +2721,11 @@
   Return variable name and length for hashing of variables
 */
 
-static byte *get_sys_var_length(const sys_var *var, uint *length,
-				my_bool first)
+static uchar *get_sys_var_length(const sys_var *var, size_t *length,
+                                 my_bool first)
 {
   *length= var->name_length;
-  return (byte*) var->name;
+  return (uchar*) var->name;
 }
 
 
@@ -2723,6 +2742,7 @@
     otherwise   FAILURE
 */
 
+
 int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options)
 {
   sys_var *var;
@@ -2733,7 +2753,7 @@
   {
     var->name_length= strlen(var->name);
     /* this fails if there is a conflicting variable name. see HASH_UNIQUE */
-    if (my_hash_insert(&system_variable_hash, (byte*) var))
+    if (my_hash_insert(&system_variable_hash, (uchar*) var))
       goto error;
     if (long_options)
       var->option_limits= find_option(long_options, var->name);
@@ -2742,42 +2762,42 @@
 
 error:
   for (; first != var; first= first->next)
-    hash_delete(&system_variable_hash, (byte*) first);
+    hash_delete(&system_variable_hash, (uchar*) first);
   return 1;
 }
-
-
+ 
+ 
 /*
   Remove variables to the dynamic hash of system variables
-  
+   
   SYNOPSIS
     mysql_del_sys_var_chain()
     first       Pointer to first system variable to remove
-  
+   
   RETURN VALUES
     0           SUCCESS
     otherwise   FAILURE
 */
-
+ 
 int mysql_del_sys_var_chain(sys_var *first)
 {
   int result= 0;
-
+ 
   /* A write lock should be held on LOCK_system_variables_hash */
-  
+   
   for (sys_var *var= first; var; var= var->next)
-    result|= hash_delete(&system_variable_hash, (byte*) var);
+    result|= hash_delete(&system_variable_hash, (uchar*) var);
 
   return result;
 }
-
-
+ 
+ 
 static int show_cmp(SHOW_VAR *a, SHOW_VAR *b)
 {
   return strcmp(a->name, b->name);
 }
-
-
+ 
+ 
 /*
   Constructs an array of system variables for display to the user.
   
@@ -2894,7 +2914,7 @@
 int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count)
 {
   for (; count > 0; count--, show_vars++)
-    if (insert_dynamic(&fixed_show_vars, (char*) show_vars))
+    if (insert_dynamic(&fixed_show_vars, (uchar*) show_vars))
       return 1;
   return 0;
 }
@@ -2923,7 +2943,7 @@
     A lock on LOCK_system_variable_hash should be held
   */
   var= (sys_var*) hash_search(&system_variable_hash,
-			      (byte*) str, length ? length : strlen(str));
+			      (uchar*) str, length ? length : strlen(str));
   if (!(var || no_error))
     my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);
 
@@ -3216,10 +3236,10 @@
 }
 
 
-byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
 					    LEX_STRING *base)
 {
-  byte* result;
+  uchar* result;
   handlerton *hton;
   LEX_STRING *name;
   plugin_ref plugin= thd->variables.*offset;
@@ -3227,7 +3247,7 @@
     plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
   hton= plugin_data(plugin, handlerton*);
   name= &hton2plugin[hton->slot]->name;
-  result= (byte *) thd->strmake(name->str, name->length);
+  result= (uchar *) thd->strmake(name->str, name->length);
   if (type == OPT_GLOBAL)
     plugin_unlock(thd, plugin);
   return result;
@@ -3329,14 +3349,14 @@
 }
 
 
-byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type,
 				      LEX_STRING *base)
 {
   LEX_STRING sql_mode;
   ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
                   thd->variables.*offset);
   (void) symbolic_mode_representation(thd, val, &sql_mode);
-  return (byte *) sql_mode.str;
+  return (uchar *) sql_mode.str;
 }
 
 
@@ -3427,7 +3447,7 @@
   Named list handling
 ****************************************************************************/
 
-gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
+uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
 		NAMED_LIST **found)
 {
   I_List_iterator<NAMED_LIST> it(*list);
@@ -3446,7 +3466,7 @@
 
 
 void delete_elements(I_List<NAMED_LIST> *list,
-		     void (*free_element)(const char *name, gptr))
+		     void (*free_element)(const char *name, uchar*))
 {
   NAMED_LIST *element;
   DBUG_ENTER("delete_elements");
@@ -3470,7 +3490,7 @@
   if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
 					     MYF(MY_ZEROFILL | MY_WME))))
   {
-    if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache))
+    if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
     {
       my_free((char*) key_cache, MYF(0));
       key_cache= 0;
@@ -3629,14 +3649,14 @@
 }
 
 
-byte *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
+uchar *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
 {
   char buf[256];
   if (type == OPT_GLOBAL)
     DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
   else
     DBUG_EXPLAIN(buf, sizeof(buf));
-  return (byte*) thd->strdup(buf);
+  return (uchar*) thd->strdup(buf);
 }
 
 
@@ -3679,10 +3699,10 @@
 }
 
 
-byte *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type,
                                          LEX_STRING *base)
 {
-  return (byte *) Events::get_opt_event_scheduler_str();
+  return (uchar *) Events::get_opt_event_scheduler_str();
 }
 
 

--- 1.289/BitKeeper/etc/ignore	2007-06-01 08:52:12 +02:00
+++ 1.290/BitKeeper/etc/ignore	2007-07-05 13:48:32 +02:00
@@ -38,7 +38,9 @@
 */.libs/*
 */.pure
 */debug/*
+*/minsizerel/*
 */release/*
+*/relwithdebinfo/*
 *~
 .*.swp
 ./CMakeCache.txt
@@ -64,6 +66,7 @@
 .libs
 .o
 .out
+.pc/*
 .snprj/*
 .vimrc
 50
@@ -489,6 +492,8 @@
 dbug/output*.r
 dbug/user.ps
 dbug/user.t
+debian/control
+debian/defs.mk
 depcomp
 emacs.h
 examples/*.ds?
@@ -1017,6 +1022,7 @@
 libmysqld/backup_dir
 libmysqld/client.c
 libmysqld/client_settings.h
+libmysqld/cmake_dummy.c
 libmysqld/convert.cc
 libmysqld/derror.cc
 libmysqld/discover.cc
@@ -1275,7 +1281,6 @@
 mysql-test/r/*.log
 mysql-test/r/*.out
 mysql-test/r/*.reject
-mysql-test/r/*.warnings
 mysql-test/r/alter_table.err
 mysql-test/r/archive.err
 mysql-test/r/backup.log
@@ -1785,9 +1790,8 @@
 netware/init_db.sql
 netware/libmysql.imp
 netware/test_db.sql
-patches/*
-.pc/*
 pack_isam/*.ds?
+patches/*
 perror/*.ds?
 perror/*.vcproj
 plugin/fulltext/.deps/mypluglib_la-plugin_example.Plo

--- 1.128/sql/ha_ndbcluster_binlog.cc	2007-06-18 19:48:03 +02:00
+++ 1.129/sql/ha_ndbcluster_binlog.cc	2007-07-05 13:48:38 +02:00
@@ -167,14 +167,14 @@
 
 #ifndef DBUG_OFF
 /* purecov: begin deadcode */
-static void print_records(TABLE *table, const char *record)
+static void print_records(TABLE *table, const uchar *record)
 {
   for (uint j= 0; j < table->s->fields; j++)
   {
     char buf[40];
     int pos= 0;
     Field *field= table->field[j];
-    const byte* field_ptr= field->ptr - table->record[0] + record;
+    const uchar* field_ptr= field->ptr - table->record[0] + record;
     int pack_len= field->pack_length();
     int n= pack_len < 10 ? pack_len : 10;
 
@@ -233,14 +233,14 @@
                 (long) f->ptr, (int) (f->ptr - table->record[0]),
                 f->null_bit,
                 (long) f->null_ptr,
-                (int) ((byte*) f->null_ptr - table->record[0])));
+                (int) ((uchar*) f->null_ptr - table->record[0])));
     if (f->type() == MYSQL_TYPE_BIT)
     {
       Field_bit *g= (Field_bit*) f;
       DBUG_PRINT("MYSQL_TYPE_BIT",("field_length: %d  bit_ptr: 0x%lx[+%d] "
                                    "bit_ofs: %d  bit_len: %u",
                                    g->field_length, (long) g->bit_ptr,
-                                   (int) ((byte*) g->bit_ptr -
+                                   (int) ((uchar*) g->bit_ptr -
                                           table->record[0]),
                                    g->bit_ofs, g->bit_len));
     }
@@ -729,7 +729,7 @@
   pthread_mutex_lock(&ndbcluster_mutex);
 
   void *share= hash_search(&ndbcluster_open_tables, 
-                           NDB_APPLY_TABLE_FILE,
+                           (uchar*) NDB_APPLY_TABLE_FILE,
                            sizeof(NDB_APPLY_TABLE_FILE) - 1);
   DBUG_PRINT("info",("ndbcluster_check_ndb_apply_status_share %s 0x%lx",
                      NDB_APPLY_TABLE_FILE, (long) share));
@@ -747,7 +747,7 @@
   pthread_mutex_lock(&ndbcluster_mutex);
 
   void *share= hash_search(&ndbcluster_open_tables, 
-                           NDB_SCHEMA_TABLE_FILE,
+                           (uchar*) NDB_SCHEMA_TABLE_FILE,
                            sizeof(NDB_SCHEMA_TABLE_FILE) - 1);
   DBUG_PRINT("info",("ndbcluster_check_ndb_schema_share %s 0x%lx",
                      NDB_SCHEMA_TABLE_FILE, (long) share));
@@ -953,7 +953,7 @@
   TABLE *table= share->table;
   Field **field;
   /* unpack blob values */
-  byte* blobs_buffer= 0;
+  uchar* blobs_buffer= 0;
   uint blobs_buffer_size= 0;
   my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
   {
@@ -968,14 +968,14 @@
       DBUG_ASSERT(FALSE);
     }
   }
-  /* db varchar 1 length byte */
+  /* db varchar 1 length uchar */
   field= table->field;
   s->db_length= *(uint8*)(*field)->ptr;
   DBUG_ASSERT(s->db_length <= (*field)->field_length);
   DBUG_ASSERT((*field)->field_length + 1 == sizeof(s->db));
   memcpy(s->db, (*field)->ptr + 1, s->db_length);
   s->db[s->db_length]= 0;
-  /* name varchar 1 length byte */
+  /* name varchar 1 length uchar */
   field++;
   s->name_length= *(uint8*)(*field)->ptr;
   DBUG_ASSERT(s->name_length <= (*field)->field_length);
@@ -992,13 +992,11 @@
   {
     Field_blob *field_blob= (Field_blob*)(*field);
     uint blob_len= field_blob->get_length((*field)->ptr);
-    char *blob_ptr= 0;
+    uchar *blob_ptr= 0;
     field_blob->get_ptr(&blob_ptr);
     assert(blob_len == 0 || blob_ptr != 0);
     s->query_length= blob_len;
-    s->query= sql_alloc(blob_len+1);
-    memcpy(s->query, blob_ptr, blob_len);
-    s->query[blob_len]= 0;
+    s->query= sql_strmake((char*) blob_ptr, blob_len);
   }
   /* node_id */
   field++;
@@ -1367,7 +1365,7 @@
       (void) pthread_mutex_unlock(&ndb_schema_object->mutex);
     }
 
-    DBUG_DUMP("schema_subscribers", (char*)schema_subscribers.bitmap,
+    DBUG_DUMP("schema_subscribers", (uchar*)schema_subscribers.bitmap,
               no_bytes_in_map(&schema_subscribers));
     DBUG_PRINT("info", ("bitmap_is_clear_all(&schema_subscribers): %d",
                         bitmap_is_clear_all(&schema_subscribers)));
@@ -1571,7 +1569,7 @@
       bitmap_intersect(&ndb_schema_object->slock_bitmap, &schema_subscribers);
 
       DBUG_DUMP("ndb_schema_object->slock_bitmap.bitmap",
-                (char*)ndb_schema_object->slock_bitmap.bitmap,
+                (uchar*)ndb_schema_object->slock_bitmap.bitmap,
                 no_bytes_in_map(&ndb_schema_object->slock_bitmap));
 
       if (bitmap_is_clear_all(&ndb_schema_object->slock_bitmap))
@@ -1656,8 +1654,8 @@
   {
     const char *tabname= table_share->table_name.str;
     char key[FN_REFLEN];
-    const void *data= 0, *pack_data= 0;
-    uint length, pack_length;
+    uchar *data= 0, *pack_data= 0;
+    size_t length, pack_length;
     int error;
     NDBDICT *dict= ndb->getDictionary();
     const NDBTAB *altered_table= pOp->getTable();
@@ -1675,7 +1673,7 @@
         packfrm(data, length, &pack_data, &pack_length) == 0 &&
         cmp_frm(altered_table, pack_data, pack_length))
     {
-      DBUG_DUMP("frm", (char*)altered_table->getFrmData(), 
+      DBUG_DUMP("frm", (uchar*) altered_table->getFrmData(), 
                 altered_table->getFrmLength());
       pthread_mutex_lock(&LOCK_open);
       Ndb_table_guard ndbtab_g(dict, tabname);
@@ -1686,7 +1684,8 @@
       
       my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
       data= NULL;
-      if ((error= unpackfrm(&data, &length, altered_table->getFrmData())) ||
+      if ((error= unpackfrm(&data, &length,
+                            (const uchar*) altered_table->getFrmData())) ||
           (error= writefrm(key, data, length)))
       {
         sql_print_information("NDB: Failed write frm for %s.%s, error %d",
@@ -1942,16 +1941,16 @@
           pthread_mutex_lock(&LOCK_open);
           if (ndbcluster_check_if_local_table(schema->db, schema->name))
           {
-            DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'",
+            DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
                                 schema->db, schema->name));
-            sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from "
+            sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from "
                             "binlog schema event '%s' from node %d. ",
                             schema->db, schema->name, schema->query,
                             schema->node_id);
           }
           else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
           {
-            sql_print_error("NDB binlog: Could not discover table '%s.%s' from "
+            sql_print_error("NDB Binlog: Could not discover table '%s.%s' from "
                             "binlog schema event '%s' from node %d. "
                             "my_errno: %d",
                             schema->db, schema->name, schema->query,
@@ -1959,7 +1958,7 @@
             List_iterator_fast<MYSQL_ERROR> it(thd->warn_list);
             MYSQL_ERROR *err;
             while ((err= it++))
-              sql_print_warning("NDB binlog: (%d)%s", err->code, err->msg);
+              sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg);
           }
           pthread_mutex_unlock(&LOCK_open);
           log_query= 1;
@@ -1981,7 +1980,7 @@
           else
           {
             /* Database contained local tables, leave it */
-            sql_print_error("NDB binlog: Skipping drop database '%s' since it contained
local tables "
+            sql_print_error("NDB Binlog: Skipping drop database '%s' since it contained
local tables "
                             "binlog schema event '%s' from node %d. ",
                             schema->db, schema->query,
                             schema->node_id);
@@ -2010,7 +2009,7 @@
         if (log_query && ndb_binlog_running)
           ndb_binlog_query(thd, schema);
         /* signal that schema operation has been handled */
-        DBUG_DUMP("slock", (char*)schema->slock, schema->slock_length);
+        DBUG_DUMP("slock", (uchar*) schema->slock, schema->slock_length);
         if (bitmap_is_set(&slock, node_id))
         {
           if (post_epoch_unlock)
@@ -2157,14 +2156,14 @@
         pthread_mutex_lock(&ndbcluster_mutex);
         NDB_SCHEMA_OBJECT *ndb_schema_object=
           (NDB_SCHEMA_OBJECT*) hash_search(&ndb_schema_objects,
-                                           (byte*) key, strlen(key));
+                                           (uchar*) key, strlen(key));
         if (ndb_schema_object)
         {
           pthread_mutex_lock(&ndb_schema_object->mutex);
           memcpy(ndb_schema_object->slock, schema->slock,
                  sizeof(ndb_schema_object->slock));
           DBUG_DUMP("ndb_schema_object->slock_bitmap.bitmap",
-                    (char*)ndb_schema_object->slock_bitmap.bitmap,
+                    (uchar*)ndb_schema_object->slock_bitmap.bitmap,
                     no_bytes_in_map(&ndb_schema_object->slock_bitmap));
           pthread_mutex_unlock(&ndb_schema_object->mutex);
           pthread_cond_signal(&injector_cond);
@@ -2232,23 +2231,23 @@
           pthread_mutex_lock(&LOCK_open);
           if (ndbcluster_check_if_local_table(schema->db, schema->name))
           {
-            DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'",
+            DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
                                 schema->db, schema->name));
-            sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from "
+            sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from "
                             "binlog schema event '%s' from node %d. ",
                             schema->db, schema->name, schema->query,
                             schema->node_id);
           }
           else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
           {
-            sql_print_error("NDB binlog: Could not discover table '%s.%s' from "
+            sql_print_error("NDB Binlog: Could not discover table '%s.%s' from "
                             "binlog schema event '%s' from node %d. my_errno: %d",
                             schema->db, schema->name, schema->query,
                             schema->node_id, my_errno);
             List_iterator_fast<MYSQL_ERROR> it(thd->warn_list);
             MYSQL_ERROR *err;
             while ((err= it++))
-              sql_print_warning("NDB binlog: (%d)%s", err->code, err->msg);
+              sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg);
           }
           pthread_mutex_unlock(&LOCK_open);
         }
@@ -3031,7 +3030,7 @@
 
   /* Handle any trailing share */
   NDB_SHARE *share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables,
-                                             (byte*) key, key_len);
+                                             (uchar*) key, key_len);
 
   if (share && share_may_exist)
   {
@@ -3468,10 +3467,10 @@
         if (is_ndb_compatible_type(f))
         {
           DBUG_PRINT("info", ("%s compatible", col_name));
-          attr0.rec= op->getValue(col_name, f->ptr);
+          attr0.rec= op->getValue(col_name, (char*) f->ptr);
           attr1.rec= op->getPreValue(col_name,
-                                 (f->ptr - share->table->record[0]) +
-                                 share->table->record[1]);
+                                     (f->ptr - share->table->record[0]) +
+                                     (char*) share->table->record[1]);
         }
         else if (! (f->flags & BLOB_FLAG))
         {
@@ -3714,7 +3713,7 @@
 */
 
 static void ndb_unpack_record(TABLE *table, NdbValue *value,
-                              MY_BITMAP *defined, byte *buf)
+                              MY_BITMAP *defined, uchar *buf)
 {
   Field **p_field= table->field, *field= *p_field;
   my_ptrdiff_t row_offset= (my_ptrdiff_t) (buf - table->record[0]);
@@ -3801,13 +3800,13 @@
           field_bit->Field_bit::move_field_offset(-row_offset);
           DBUG_PRINT("info",("[%u] SET",
                              (*value).rec->getColumn()->getColumnNo()));
-          DBUG_DUMP("info", (const char*) field->ptr, field->pack_length());
+          DBUG_DUMP("info", (const uchar*) field->ptr, field->pack_length());
         }
         else
         {
           DBUG_PRINT("info",("[%u] SET",
                              (*value).rec->getColumn()->getColumnNo()));
-          DBUG_DUMP("info", (const char*) field->ptr, field->pack_length());
+          DBUG_DUMP("info", (const uchar*) field->ptr, field->pack_length());
         }
       }
       else
@@ -3831,7 +3830,7 @@
 #ifndef DBUG_OFF
           // pointer vas set in get_ndb_blobs_value
           Field_blob *field_blob= (Field_blob*)field;
-          char* ptr;
+          uchar* ptr;
           field_blob->get_ptr(&ptr, row_offset);
           uint32 len= field_blob->get_length(row_offset);
           DBUG_PRINT("info",("[%u] SET ptr: 0x%lx  len: %u",
@@ -4016,7 +4015,7 @@
     for now malloc/free blobs buffer each time
     TODO if possible share single permanent buffer with handlers
    */
-  byte* blobs_buffer[2] = { 0, 0 };
+  uchar* blobs_buffer[2] = { 0, 0 };
   uint blobs_buffer_size[2] = { 0, 0 };
 
   switch(pOp->getEventType())
@@ -4177,11 +4176,13 @@
   Injector thread main loop
 ****************************************************************/
 
-static byte *ndb_schema_objects_get_key(NDB_SCHEMA_OBJECT *schema_object, uint *length,
-                                        my_bool not_used __attribute__((unused)))
+static uchar *
+ndb_schema_objects_get_key(NDB_SCHEMA_OBJECT *schema_object,
+                           size_t *length,
+                           my_bool not_used __attribute__((unused)))
 {
   *length= schema_object->key_length;
-  return (byte*) schema_object->key;
+  return (uchar*) schema_object->key;
 }
 
 static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
@@ -4197,7 +4198,7 @@
     pthread_mutex_lock(&ndbcluster_mutex);
   while (!(ndb_schema_object=
            (NDB_SCHEMA_OBJECT*) hash_search(&ndb_schema_objects,
-                                            (byte*) key,
+                                            (uchar*) key,
                                             length)))
   {
     if (!create_if_not_exists)
@@ -4215,9 +4216,9 @@
     ndb_schema_object->key= (char *)(ndb_schema_object+1);
     memcpy(ndb_schema_object->key, key, length + 1);
     ndb_schema_object->key_length= length;
-    if (my_hash_insert(&ndb_schema_objects, (byte*) ndb_schema_object))
+    if (my_hash_insert(&ndb_schema_objects, (uchar*) ndb_schema_object))
     {
-      my_free((gptr) ndb_schema_object, 0);
+      my_free((uchar*) ndb_schema_object, 0);
       break;
     }
     pthread_mutex_init(&ndb_schema_object->mutex, MY_MUTEX_INIT_FAST);
@@ -4247,9 +4248,9 @@
   if (!--(*ndb_schema_object)->use_count)
   {
     DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
-    hash_delete(&ndb_schema_objects, (byte*) *ndb_schema_object);
+    hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object);
     pthread_mutex_destroy(&(*ndb_schema_object)->mutex);
-    my_free((gptr) *ndb_schema_object, MYF(0));
+    my_free((uchar*) *ndb_schema_object, MYF(0));
     *ndb_schema_object= 0;
   }
   else
@@ -4365,15 +4366,7 @@
 
   if (opt_bin_log)
   {
-    if (global_system_variables.binlog_format == BINLOG_FORMAT_ROW ||
-        global_system_variables.binlog_format == BINLOG_FORMAT_MIXED)
-    {
-      ndb_binlog_running= TRUE;
-    }
-    else
-    {
-      sql_print_error("NDB: only row based binary logging is supported");
-    }
+    ndb_binlog_running= TRUE;
   }
 
   /* Thread start up completed  */
@@ -4687,7 +4680,7 @@
                                 NdbDictionary::Event::TE_DELETE)) == 0)
             {
               DBUG_PRINT("info", ("skipping non data event table: %.*s",
-                                  name.length, name.str));
+                                  (int) name.length, name.str));
               continue;
             }
             if (!trans.good())
@@ -4696,7 +4689,8 @@
                          ("Found new data event, initializing transaction"));
               inj->new_trans(thd, &trans);
             }
-            DBUG_PRINT("info", ("use_table: %.*s", name.length, name.str));
+            DBUG_PRINT("info", ("use_table: %.*s",
+                                (int) name.length, name.str));
             injector::transaction::table tbl(table, TRUE);
             IF_DBUG(int ret=) trans.use_table(::server_id, tbl);
             DBUG_ASSERT(ret == 0);
@@ -4710,7 +4704,8 @@
 
 #ifndef DBUG_OFF
             const LEX_STRING& name= table->s->table_name;
-            DBUG_PRINT("info", ("use_table: %.*s", name.length, name.str));
+            DBUG_PRINT("info", ("use_table: %.*s",
+                                (int) name.length, name.str));
 #endif
             injector::transaction::table tbl(table, TRUE);
             IF_DBUG(int ret=) trans.use_table(::server_id, tbl);
@@ -4829,7 +4824,7 @@
           injector::transaction::binlog_pos start= trans.start_pos();
           if (int r= trans.commit())
           {
-            sql_print_error("NDB binlog: "
+            sql_print_error("NDB Binlog: "
                             "Error during COMMIT of GCI. Error: %d",
                             r);
             /* TODO: Further handling? */
Thread
bk commit into 5.1 tree (tomas:1.2538)tomas5 Jul