List:Commits« Previous MessageNext Message »
From:ingo Date:June 16 2007 5:53pm
Subject:bk commit into 5.2 tree (istruewing:1.2506)
View as plain text  
Below is the list of changes that have just been committed into a local
5.2 repository of istruewing. When istruewing 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-06-16 19:53:06+02:00, istruewing@stripped +47 -0
  Merge chilla.local:/home/mydev/mysql-5.1-axmrg
  into  chilla.local:/home/mydev/mysql-5.2-axmrg
  MERGE: 1.2482.20.7

  BitKeeper/deleted/.del-backup.result@stripped, 2007-06-16 18:47:18+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.22.1.3

  BitKeeper/deleted/.del-backup.result@stripped, 2007-06-16 18:47:18+02:00, istruewing@stripped +0 -0
    Merge rename: mysql-test/r/backup.result -> BitKeeper/deleted/.del-backup.result

  BitKeeper/deleted/.del-backup.test@stripped, 2007-06-16 18:47:19+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.24.1.2

  BitKeeper/deleted/.del-backup.test@stripped, 2007-06-16 18:47:18+02:00, istruewing@stripped +0 -0
    Merge rename: mysql-test/t/backup.test -> BitKeeper/deleted/.del-backup.test

  BitKeeper/triggers/post-commit@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -0
    Manual merge
    MERGE: 1.37.1.2

  configure.in@stripped, 2007-06-16 18:47:18+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.442.1.23

  include/my_base.h@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -0
    Manual merge
    MERGE: 1.100.1.1

  include/mysql_com.h@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -0
    Manual merge
    MERGE: 1.120.2.1

  mysql-test/mysql-test-run.pl@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -1
    Manual merge
    MERGE: 1.304.1.5

  mysql-test/r/rpl_row_until.result@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -38
    Manual merge
    MERGE: 1.5.1.1

  mysql-test/r/rpl_sp.result@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -0
    Manual merge
    MERGE: 1.38.1.1

  mysql-test/r/show_check.result@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -0
    Manual merge
    MERGE: 1.111.1.2

  mysql-test/r/sp-error.result@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -0
    Manual merge
    MERGE: 1.124.1.1

  mysql-test/r/sp.result@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +4 -0
    Manual merge
    MERGE: 1.270.1.7

  mysql-test/r/sp_trans.result@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -0
    Manual merge
    MERGE: 1.19.1.1

  mysql-test/r/warnings.result@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -0
    Manual merge
    MERGE: 1.57.1.1

  mysql-test/t/rpl_row_until.test@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -4
    Manual merge
    MERGE: 1.2.1.1

  mysql-test/t/rpl_sp.test@stripped, 2007-06-16 19:15:35+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.32.1.1

  mysql-test/t/show_check.test@stripped, 2007-06-16 19:15:36+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.76.1.2

  mysql-test/t/sp-error.test@stripped, 2007-06-16 19:15:36+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.120.1.1

  mysql-test/t/sp.test@stripped, 2007-06-16 19:15:36+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.237.1.5

  mysql-test/t/sp_trans.test@stripped, 2007-06-16 19:15:36+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.16.1.5

  scripts/mysql_system_tables_fix.sql@stripped, 2007-06-16 19:15:36+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.62.1.1

  sql/handler.cc@stripped, 2007-06-16 19:15:36+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.307.3.1

  sql/handler.h@stripped, 2007-06-16 19:15:36+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.258.2.3

  sql/lock.cc@stripped, 2007-06-16 19:15:36+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.102.1.7

  sql/mysql_priv.h@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -1
    Manual merge
    MERGE: 1.509.2.4

  sql/mysqld.cc@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +34 -0
    Manual merge
    MERGE: 1.645.1.10

  sql/repl_failsafe.cc@stripped, 2007-06-16 19:15:37+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.76.1.1

  sql/set_var.cc@stripped, 2007-06-16 19:15:37+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.233.1.2

  sql/set_var.h@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +12 -0
    Manual merge
    MERGE: 1.106.1.2

  sql/share/errmsg.txt@stripped, 2007-06-16 19:53:02+02:00, istruewing@stripped +2 -2
    Manual merge
    MERGE: 1.141.8.1

  sql/slave.cc@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -1
    Manual merge
    MERGE: 1.307.1.1

  sql/sp_head.cc@stripped, 2007-06-16 19:15:37+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.271.1.2

  sql/sql_lex.h@stripped, 2007-06-16 19:15:37+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.276.2.2

  sql/sql_load.cc@stripped, 2007-06-16 19:15:37+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.123.3.1

  sql/sql_parse.cc@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +2 -9
    Manual merge
    MERGE: 1.668.3.3

  sql/sql_repl.cc@stripped, 2007-06-16 19:15:38+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.168.1.1

  sql/sql_show.cc@stripped, 2007-06-16 19:53:01+02:00, istruewing@stripped +0 -1
    Manual merge
    MERGE: 1.412.2.2

  sql/sql_table.cc@stripped, 2007-06-16 19:53:02+02:00, istruewing@stripped +0 -11
    Manual merge
    MERGE: 1.416.5.2

  sql/sql_yacc.yy@stripped, 2007-06-16 19:53:02+02:00, istruewing@stripped +0 -2
    Manual merge
    MERGE: 1.569.1.4

  sql/structs.h@stripped, 2007-06-16 19:15:38+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.69.1.1

  sql/table.cc@stripped, 2007-06-16 19:53:02+02:00, istruewing@stripped +1 -1
    Manual merge
    MERGE: 1.288.3.1

  sql/table.h@stripped, 2007-06-16 19:15:39+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.169.2.1

  sql/unireg.cc@stripped, 2007-06-16 19:15:39+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.100.1.4

  storage/innobase/handler/ha_innodb.h@stripped, 2007-06-16 19:15:39+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.139.1.1

  storage/myisam/ha_myisam.cc@stripped, 2007-06-16 19:53:02+02:00, istruewing@stripped +0 -6
    Manual merge
    MERGE: 1.220.1.1

  storage/myisam/ha_myisam.h@stripped, 2007-06-16 19:15:39+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.84.1.1

  tests/mysql_client_test.c@stripped, 2007-06-16 19:15:39+02:00, istruewing@stripped +0 -0
    Auto merged
    MERGE: 1.236.2.1

# 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:	istruewing
# Host:	chilla.local
# Root:	/home/mydev/mysql-5.2-axmrg/RESYNC

--- 1.446/configure.in	2007-06-16 19:53:18 +02:00
+++ 1.447/configure.in	2007-06-16 19:53:18 +02:00
@@ -229,14 +229,8 @@ AC_CHECK_PROGS(YACC, ['bison -y -p MYSQL
 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()
     {
@@ -262,10 +256,12 @@ AC_TRY_RUN([
                [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)
 
@@ -737,6 +733,7 @@ AC_CHECK_HEADERS(fcntl.h float.h floatin
  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])
@@ -764,9 +761,6 @@ AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(H
 # 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
@@ -1666,6 +1660,12 @@ AC_ARG_WITH(client-ldflags,
     [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],
@@ -1783,8 +1783,6 @@ MYSQL_TYPE_ACCEPT
 #---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
@@ -1865,6 +1863,19 @@ else
   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.101/include/my_base.h	2007-06-16 19:53:18 +02:00
+++ 1.102/include/my_base.h	2007-06-16 19:53:18 +02:00
@@ -242,6 +242,7 @@ enum ha_base_keytype {
 #define HA_SPACE_PACK_USED	 4	/* Test for if SPACE_PACK used */
 #define HA_VAR_LENGTH_KEY	 8
 #define HA_NULL_PART_KEY	 64
+#define HA_USES_COMMENT          4096
 #define HA_USES_PARSER           16384  /* Fulltext index uses [pre]parser */
 #define HA_USES_BLOCK_SIZE	 ((uint) 32768)
 #define HA_SORT_ALLOWS_SAME      512    /* Intern bit when sorting records */

--- 1.122/include/mysql_com.h	2007-06-16 19:53:18 +02:00
+++ 1.123/include/mysql_com.h	2007-06-16 19:53:18 +02:00
@@ -31,6 +31,14 @@
 #define SQLSTATE_LENGTH 5
 
 /*
+  Maximum length of comments
+*/
+#define TABLE_COMMENT_MAXLEN 2048
+#define COLUMN_COMMENT_MAXLEN 1024
+#define INDEX_COMMENT_MAXLEN 1024
+
+
+/*
   USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
   username and hostname parts of the user identifier with trailing zero in
   MySQL standard format:

--- 1.224/storage/myisam/ha_myisam.cc	2007-06-16 19:53:18 +02:00
+++ 1.225/storage/myisam/ha_myisam.cc	2007-06-16 19:53:18 +02:00
@@ -521,91 +521,6 @@ const char *ha_myisam::index_type(uint k
 	  "BTREE");
 }
 
-#ifdef HAVE_REPLICATION
-int ha_myisam::net_read_dump(NET* net)
-{
-  int data_fd = file->dfile;
-  int error = 0;
-
-  my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
-  for (;;)
-  {
-    ulong packet_len = my_net_read(net);
-    if (!packet_len)
-      break ; // end of file
-    if (packet_len == packet_error)
-    {
-      sql_print_error("ha_myisam::net_read_dump - read error ");
-      error= -1;
-      goto err;
-    }
-    if (my_write(data_fd, (uchar*)net->read_pos, (uint) packet_len,
-		 MYF(MY_WME|MY_FNABP)))
-    {
-      error = errno;
-      goto err;
-    }
-  }
-err:
-  return error;
-}
-
-
-int ha_myisam::dump(THD* thd, int fd)
-{
-  MYISAM_SHARE* share = file->s;
-  NET* net = &thd->net;
-  uint blocksize = share->blocksize;
-  my_off_t bytes_to_read = share->state.state.data_file_length;
-  int data_fd = file->dfile;
-  uchar *buf = (uchar*) my_malloc(blocksize, MYF(MY_WME));
-  if (!buf)
-    return ENOMEM;
-
-  int error = 0;
-  my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
-  for (; bytes_to_read > 0;)
-  {
-    size_t bytes = my_read(data_fd, buf, blocksize, MYF(MY_WME));
-    if (bytes == MY_FILE_ERROR)
-    {
-      error = errno;
-      goto err;
-    }
-
-    if (fd >= 0)
-    {
-      if (my_write(fd, buf, bytes, MYF(MY_WME | MY_FNABP)))
-      {
-	error = errno ? errno : EPIPE;
-	goto err;
-      }
-    }
-    else
-    {
-      if (my_net_write(net, buf, bytes))
-      {
-	error = errno ? errno : EPIPE;
-	goto err;
-      }
-    }
-    bytes_to_read -= bytes;
-  }
-
-  if (fd < 0)
-  {
-    if (my_net_write(net, (uchar*) "", 0))
-      error = errno ? errno : EPIPE;
-    net_flush(net);
-  }
-
-err:
-  my_free((uchar*) buf, MYF(0));
-  return error;
-}
-#endif /* HAVE_REPLICATION */
-
-
 bool ha_myisam::check_if_locking_is_allowed(uint sql_command,
                                             ulong type, TABLE *table,
                                             uint count, uint current,
@@ -872,113 +787,6 @@ int ha_myisam::analyze(THD *thd, HA_CHEC
   else if (!mi_is_crashed(file) && !thd->killed)
     mi_mark_crashed(file);
   return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK;
-}
-
-
-int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
-{
-  HA_CHECK_OPT tmp_check_opt;
-  char *backup_dir= thd->lex->backup_dir;
-  char src_path[FN_REFLEN], dst_path[FN_REFLEN];
-  char table_name[FN_REFLEN];
-  int error;
-  const char* errmsg;
-  DBUG_ENTER("restore");
-
-  VOID(tablename_to_filename(table->s->table_name.str, table_name,
-                             sizeof(table_name)));
-
-  if (fn_format_relative_to_data_home(src_path, table_name, backup_dir,
-				      MI_NAME_DEXT))
-    DBUG_RETURN(HA_ADMIN_INVALID);
-
-  strxmov(dst_path, table->s->normalized_path.str, MI_NAME_DEXT, NullS);
-  if (my_copy(src_path, dst_path, MYF(MY_WME)))
-  {
-    error= HA_ADMIN_FAILED;
-    errmsg= "Failed in my_copy (Error %d)";
-    goto err;
-  }
-
-  tmp_check_opt.init();
-  tmp_check_opt.flags |= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
-  DBUG_RETURN(repair(thd, &tmp_check_opt));
-
- err:
-  {
-    MI_CHECK param;
-    myisamchk_init(&param);
-    param.thd= thd;
-    param.op_name=    "restore";
-    param.db_name=    table->s->db.str;
-    param.table_name= table->s->table_name.str;
-    param.testflag= 0;
-    mi_check_print_error(&param, errmsg, my_errno);
-    DBUG_RETURN(error);
-  }
-}
-
-
-int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
-{
-  char *backup_dir= thd->lex->backup_dir;
-  char src_path[FN_REFLEN], dst_path[FN_REFLEN];
-  char table_name[FN_REFLEN];
-  int error;
-  const char *errmsg;
-  DBUG_ENTER("ha_myisam::backup");
-
-  VOID(tablename_to_filename(table->s->table_name.str, table_name,
-                             sizeof(table_name)));
-
-  if (fn_format_relative_to_data_home(dst_path, table_name, backup_dir,
-				      reg_ext))
-  {
-    errmsg= "Failed in fn_format() for .frm file (errno: %d)";
-    error= HA_ADMIN_INVALID;
-    goto err;
-  }
-
-  strxmov(src_path, table->s->normalized_path.str, reg_ext, NullS);
-  if (my_copy(src_path, dst_path,
-	      MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_DONT_OVERWRITE_FILE)))
-  {
-    error = HA_ADMIN_FAILED;
-    errmsg = "Failed copying .frm file (errno: %d)";
-    goto err;
-  }
-
-  /* Change extension */
-  if (fn_format_relative_to_data_home(dst_path, table_name, backup_dir,
-                                      MI_NAME_DEXT))
-  {
-    errmsg = "Failed in fn_format() for .MYD file (errno: %d)";
-    error = HA_ADMIN_INVALID;
-    goto err;
-  }
-
-  strxmov(src_path, table->s->normalized_path.str, MI_NAME_DEXT, NullS);
-  if (my_copy(src_path, dst_path,
-	      MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_DONT_OVERWRITE_FILE)))
-  {
-    errmsg = "Failed copying .MYD file (errno: %d)";
-    error= HA_ADMIN_FAILED;
-    goto err;
-  }
-  DBUG_RETURN(HA_ADMIN_OK);
-
- err:
-  {
-    MI_CHECK param;
-    myisamchk_init(&param);
-    param.thd=        thd;
-    param.op_name=    "backup";
-    param.db_name=    table->s->db.str;
-    param.table_name= table->s->table_name.str;
-    param.testflag =  0;
-    mi_check_print_error(&param,errmsg, my_errno);
-    DBUG_RETURN(error);
-  }
 }
 
 

--- 1.85/storage/myisam/ha_myisam.h	2007-06-16 19:53:18 +02:00
+++ 1.86/storage/myisam/ha_myisam.h	2007-06-16 19:53:18 +02:00
@@ -128,13 +128,7 @@ class ha_myisam: public handler
   bool is_crashed() const;
   bool auto_repair() const { return myisam_recover_options != 0; }
   int optimize(THD* thd, HA_CHECK_OPT* check_opt);
-  int restore(THD* thd, HA_CHECK_OPT* check_opt);
-  int backup(THD* thd, HA_CHECK_OPT* check_opt);
   int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt);
   int preload_keys(THD* thd, HA_CHECK_OPT* check_opt);
   bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
-#ifdef HAVE_REPLICATION
-  int dump(THD* thd, int fd);
-  int net_read_dump(NET* net);
-#endif
 };

--- 1.312/sql/handler.cc	2007-06-16 19:53:18 +02:00
+++ 1.313/sql/handler.cc	2007-06-16 19:53:18 +02:00
@@ -45,7 +45,7 @@ static handlerton *installed_htons[128];
 
 #define BITMAP_STACKBUF_SIZE (128/8)
 
-KEY_CREATE_INFO default_key_create_info= { HA_KEY_ALG_UNDEF, 0, {NullS,0} };
+KEY_CREATE_INFO default_key_create_info= { HA_KEY_ALG_UNDEF, 0, {NullS,0}, {NullS,0} };
 
 /* number of entries in handlertons[] */
 ulong total_ha= 0;

--- 1.262/sql/handler.h	2007-06-16 19:53:19 +02:00
+++ 1.263/sql/handler.h	2007-06-16 19:53:19 +02:00
@@ -217,6 +217,10 @@
 #define HA_BLOCK_LOCK		256	/* unlock when reading some records */
 #define HA_OPEN_TEMPORARY	512
 
+/* For transactional LOCK TABLE. handler::lock_table() */
+#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
+#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
+
 	/* Some key definitions */
 #define HA_KEY_NULL_LENGTH	1
 #define HA_KEY_BLOB_LENGTH	2
@@ -773,6 +777,7 @@ typedef struct st_key_create_information
   enum ha_key_alg algorithm;
   ulong block_size;
   LEX_STRING parser_name;
+  LEX_STRING comment;
 } KEY_CREATE_INFO;
 
 
@@ -1413,15 +1418,6 @@ public:
   int check_old_types();
   /* to be actually called to get 'check()' functionality*/
   int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
-   
-  virtual int backup(THD* thd, HA_CHECK_OPT* check_opt)
-  { return HA_ADMIN_NOT_IMPLEMENTED; }
-  /*
-    restore assumes .frm file must exist, and that generate_table() has been
-    called; It will just copy the data file and run repair.
-  */
-  virtual int restore(THD* thd, HA_CHECK_OPT* check_opt)
-  { return HA_ADMIN_NOT_IMPLEMENTED; }
 protected:
   virtual int repair(THD* thd, HA_CHECK_OPT* check_opt)
   { return HA_ADMIN_NOT_IMPLEMENTED; }
@@ -1438,7 +1434,6 @@ public:
   /* end of the list of admin commands */
 
   virtual bool check_and_repair(THD *thd) { return HA_ERR_WRONG_COMMAND; }
-  virtual int dump(THD* thd, int fd = -1) { return HA_ERR_WRONG_COMMAND; }
   virtual int disable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; }
   virtual int enable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; }
   virtual int indexes_are_disabled(void) {return 0;}
@@ -1454,7 +1449,6 @@ public:
   }
   virtual int discard_or_import_tablespace(my_bool discard)
   {return HA_ERR_WRONG_COMMAND;}
-  virtual int net_read_dump(NET* net) { return HA_ERR_WRONG_COMMAND; }
   virtual char *update_table_comment(const char * comment)
   { return (char*) comment;}
   virtual void append_create_info(String *packet) {}
@@ -1677,6 +1671,39 @@ public:
     but we don't have a primary key
   */
   virtual void use_hidden_primary_key();
+
+  /*
+    Lock table.
+
+    SYNOPSIS
+      handler::lock_table()
+        thd                     Thread handle
+        lock_type               HA_LOCK_IN_SHARE_MODE     (F_RDLCK)
+                                HA_LOCK_IN_EXCLUSIVE_MODE (F_WRLCK)
+        lock_timeout            -1 default timeout
+                                0  no wait
+                                >0 wait timeout in milliseconds.
+
+    NOTE
+      lock_timeout >0 is not used by MySQL currently. If the storage
+      engine does not support NOWAIT (lock_timeout == 0) it should
+      return an error. But if it does not support WAIT X (lock_timeout
+      >0) it should treat it as lock_timeout == -1 and wait a default
+      (or even hard-coded) timeout.
+
+    RETURN
+      HA_ERR_WRONG_COMMAND      Storage engine does not support lock_table()
+      HA_ERR_UNSUPPORTED        Storage engine does not support NOWAIT
+      HA_ERR_LOCK_WAIT_TIMEOUT  Lock request timed out or
+                                lock conflict with NOWAIT option
+      HA_ERR_LOCK_DEADLOCK      Deadlock detected
+  */
+  virtual int lock_table(THD *thd         __attribute__((unused)),
+                         int lock_type    __attribute__((unused)),
+                         int lock_timeout __attribute__((unused)))
+  {
+    return HA_ERR_WRONG_COMMAND;
+  }
 
 private:
   /*

--- 1.106/sql/lock.cc	2007-06-16 19:53:19 +02:00
+++ 1.107/sql/lock.cc	2007-06-16 19:53:19 +02:00
@@ -137,7 +137,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, 
       {
         /* Clear the lock type of all lock data to avoid reusage. */
         reset_lock_data(sql_lock);
-	my_free((gptr) sql_lock,MYF(0));
+	my_free((uchar*) sql_lock,MYF(0));
 	sql_lock=0;
 	break;
       }
@@ -145,7 +145,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, 
       {
         /* Clear the lock type of all lock data to avoid reusage. */
         reset_lock_data(sql_lock);
-	my_free((gptr) sql_lock,MYF(0));
+	my_free((uchar*) sql_lock,MYF(0));
 	goto retry;
       }
     }
@@ -161,7 +161,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, 
         We do not wait for READ_ONLY=0, and fail.
       */
       reset_lock_data(sql_lock);
-      my_free((gptr) sql_lock, MYF(0));
+      my_free((uchar*) sql_lock, MYF(0));
       sql_lock=0;
       my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
       break;
@@ -173,7 +173,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, 
     {
       /* Clear the lock type of all lock data to avoid reusage. */
       reset_lock_data(sql_lock);
-      my_free((gptr) sql_lock,MYF(0));
+      my_free((uchar*) sql_lock,MYF(0));
       sql_lock=0;
       break;
     }
@@ -191,12 +191,19 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, 
     if (rc > 1)                                 /* a timeout or a deadlock */
     {
       my_error(rc, MYF(0));
-      my_free((gptr) sql_lock,MYF(0));
+      my_free((uchar*) sql_lock,MYF(0));
       sql_lock= 0;
       break;
     }
     else if (rc == 1)                           /* aborted */
     {
+      /*
+        reset_lock_data is required here. If thr_multi_lock fails it
+        resets lock type for tables, which were locked before (and
+        including) one that caused error. Lock type for other tables
+        preserved.
+      */
+      reset_lock_data(sql_lock);
       thd->some_tables_deleted=1;		// Try again
       sql_lock->lock_count= 0;                  // Locks are already freed
     }
@@ -285,7 +292,7 @@ void mysql_unlock_tables(THD *thd, MYSQL
     thr_multi_unlock(sql_lock->locks,sql_lock->lock_count);
   if (sql_lock->table_count)
     VOID(unlock_external(thd,sql_lock->table,sql_lock->table_count));
-  my_free((gptr) sql_lock,MYF(0));
+  my_free((uchar*) sql_lock,MYF(0));
   DBUG_VOID_RETURN;
 }
 
@@ -435,7 +442,7 @@ void mysql_lock_downgrade_write(THD *thd
   {
     for (uint i=0; i < locked->lock_count; i++)
       thr_downgrade_write_lock(locked->locks[i], new_lock_type);
-    my_free((gptr) locked,MYF(0));
+    my_free((uchar*) locked,MYF(0));
   }
 }
 
@@ -453,7 +460,7 @@ void mysql_lock_abort(THD *thd, TABLE *t
   {
     for (uint i=0; i < locked->lock_count; i++)
       thr_abort_locks(locked->locks[i]->lock, upgrade_lock);
-    my_free((gptr) locked,MYF(0));
+    my_free((uchar*) locked,MYF(0));
   }
   DBUG_VOID_RETURN;
 }
@@ -488,7 +495,7 @@ bool mysql_lock_abort_for_thread(THD *th
                                      table->in_use->thread_id))
         result= TRUE;
     }
-    my_free((gptr) locked,MYF(0));
+    my_free((uchar*) locked,MYF(0));
   }
   DBUG_RETURN(result);
 }
@@ -530,8 +537,8 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK 
   }
 
   /* Delete old, not needed locks */
-  my_free((gptr) a,MYF(0));
-  my_free((gptr) b,MYF(0));
+  my_free((uchar*) a,MYF(0));
+  my_free((uchar*) b,MYF(0));
   DBUG_RETURN(sql_lock);
 }
 
@@ -749,7 +756,7 @@ static MYSQL_LOCK *get_lock_data(THD *th
         /* Clear the lock type of the lock data that are stored already. */
         sql_lock->lock_count= locks - sql_lock->locks;
         reset_lock_data(sql_lock);
-	my_free((gptr) sql_lock,MYF(0));
+	my_free((uchar*) sql_lock,MYF(0));
 	DBUG_RETURN(0);
       }
     }
@@ -904,10 +911,10 @@ int lock_table_name(THD *thd, TABLE_LIST
   if (check_in_use)
   {
     /* Only insert the table if we haven't insert it already */
-    for (table=(TABLE*) hash_first(&open_cache, (byte*)key,
+    for (table=(TABLE*) hash_first(&open_cache, (uchar*)key,
                                    key_length, &state);
          table ;
-         table = (TABLE*) hash_next(&open_cache,(byte*) key,
+         table = (TABLE*) hash_next(&open_cache,(uchar*) key,
                                     key_length, &state))
     {
       if (table->in_use == thd)
@@ -935,7 +942,7 @@ void unlock_table_name(THD *thd, TABLE_L
 {
   if (table_list->table)
   {
-    hash_delete(&open_cache, (byte*) table_list->table);
+    hash_delete(&open_cache, (uchar*) table_list->table);
     broadcast_refresh();
   }
 }

--- 1.518/sql/mysql_priv.h	2007-06-16 19:53:19 +02:00
+++ 1.519/sql/mysql_priv.h	2007-06-16 19:53:19 +02:00
@@ -93,16 +93,35 @@ char* query_table_status(THD *thd,const 
 #define PREV_BITS(type,A)	((type) (((type) 1 << (A)) -1))
 #define all_bits_set(A,B) ((A) & (B) != (B))
 
-#define WARN_DEPRECATED(Thd,Ver,Old,New)                                             \
-  do {                                                                               \
-    DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0);              \
-    if (((uchar*)Thd) != NULL)                                                         \
-      push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN,                \
-                        ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX),    \
-                        (Old), (Ver), (New));                                        \
-    else                                                                             \
-      sql_print_warning("The syntax %s is deprecated and will be removed "           \
-                        "in MySQL %s. Please use %s instead.", (Old), (Ver), (New)); \
+/*
+  Generates a warning that a feature is deprecated. After a specified version
+  asserts that the feature is removed.
+
+  Using it as
+
+    WARN_DEPRECATED(thd, 6,2, "BAD", "'GOOD'");
+
+ Will result in a warning
+
+    "The syntax 'BAD' is deprecated and will be removed in MySQL 6.2. Please
+    use 'GOOD' instead"
+
+ Note, that in macro arguments BAD is not quoted, while 'GOOD' is.
+ Note, that the version is TWO numbers, separated with a comma
+ (two macro arguments, that is)
+*/
+#define WARN_DEPRECATED(Thd,VerHi,VerLo,Old,New)                            \
+  do {                                                                      \
+    compile_time_assert(MYSQL_VERSION_ID < VerHi * 10000 + VerLo * 100);    \
+    if (Thd)                                                                \
+      push_warning_printf((Thd), MYSQL_ERROR::WARN_LEVEL_WARN,              \
+                        ER_WARN_DEPRECATED_SYNTAX,                          \
+                        ER(ER_WARN_DEPRECATED_SYNTAX),                      \
+                        (Old), #VerHi "." #VerLo, (New));                   \
+    else                                                                    \
+      sql_print_warning("The syntax %s is deprecated and will be removed "  \
+                        "in MySQL %s. Please use %s instead.",              \
+                        (Old), #VerHi "." #VerLo, (New));                   \
   } while(0)
 
 extern CHARSET_INFO *system_charset_info, *files_charset_info ;
@@ -1786,6 +1805,10 @@ bool make_global_read_lock_block_commit(
 bool set_protect_against_global_read_lock(void);
 void unset_protect_against_global_read_lock(void);
 void broadcast_refresh(void);
+int try_transactional_lock(THD *thd, TABLE_LIST *table_list);
+int check_transactional_lock(THD *thd, TABLE_LIST *table_list);
+int set_handler_table_locks(THD *thd, TABLE_LIST *table_list,
+                            bool transactional);
 
 /* Lock based on name */
 int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list);
@@ -1903,7 +1926,7 @@ ulong next_io_size(ulong pos);
 void append_unescaped(String *res, const char *pos, uint length);
 int create_frm(THD *thd, const char *name, const char *db, const char *table,
                uint reclength, uchar *fileinfo,
-	       HA_CREATE_INFO *create_info, uint keys);
+	       HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
 void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
 int rename_file_ext(const char * from,const char * to,const char * ext);
 bool check_db_name(LEX_STRING *db);

--- 1.646/sql/mysqld.cc	2007-06-16 19:53:19 +02:00
+++ 1.647/sql/mysqld.cc	2007-06-16 19:53:19 +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 @@ static const char *sql_mode_names[]=
   "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 @@ static const unsigned int sql_mode_names
   /*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 @@ bool opt_endinfo, using_udf_functions;
 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;
@@ -461,8 +477,6 @@ ulong expire_logs_days = 0;
 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];
@@ -478,6 +492,7 @@ key_map key_map_full(0);                
 
 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;
@@ -1179,7 +1194,7 @@ void clean_up(bool print_message)
   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 */
@@ -1226,7 +1241,7 @@ void clean_up(bool print_message)
 #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 */
@@ -1404,6 +1419,15 @@ static struct passwd *check_user(const c
 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;
 }
@@ -1868,9 +1892,11 @@ static void init_signals(void)
 
 static void start_signal_handler(void)
 {
+#ifndef EMBEDDED_LIBRARY
   // Save vm id of this process
   if (!opt_bootstrap)
     create_pid_file();
+#endif /* EMBEDDED_LIBRARY */
 }
 
 
@@ -2187,7 +2213,7 @@ the thread stack. Please read http://www
   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)
@@ -2214,6 +2240,16 @@ later when used with nscd), disable LDAP
 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\
@@ -2575,7 +2611,7 @@ static void *my_str_malloc_mysqld(size_t
 
 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 */
 
@@ -3753,6 +3789,7 @@ int main(int argc, char **argv)
   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)))
   {
@@ -3787,6 +3824,11 @@ int main(int argc, char **argv)
     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
 
   /*
@@ -5013,12 +5055,12 @@ enum options_mysqld
 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,
@@ -5026,33 +5068,33 @@ struct my_option my_long_options[] =
    "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'. "
@@ -5066,7 +5108,7 @@ struct my_option my_long_options[] =
    "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.",
@@ -5078,8 +5120,8 @@ struct my_option my_long_options[] =
    "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, 
@@ -5091,61 +5133,61 @@ struct my_option my_long_options[] =
 #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},
@@ -5155,33 +5197,33 @@ struct my_option my_long_options[] =
 #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.",
@@ -5189,7 +5231,7 @@ struct my_option my_long_options[] =
   {"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},
@@ -5197,55 +5239,55 @@ struct my_option my_long_options[] =
      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
   /*
@@ -5256,7 +5298,7 @@ Disable with --skip-large-pages.",
   */
   {"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
   /*
@@ -5270,13 +5312,13 @@ Disable with --skip-large-pages.",
    "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.", 
@@ -5285,116 +5327,161 @@ Disable with --skip-large-pages.",
   {"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.",
+   (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.",
+   (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.",
+   (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.",
+   (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.",
+   (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.",
+   (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.",
+   (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",
+   (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.",
+   (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.",
+   (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.",
+   (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,
@@ -5402,113 +5489,113 @@ thread is in the master's binlogs.",
    "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},
 #endif
   {"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},
 #endif
   {"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},  
   {"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.%.",
@@ -5530,8 +5617,8 @@ thread is in the relay logs.",
    "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,
@@ -5543,19 +5630,19 @@ Can't be set to 1 if --log-slave-updates
   // 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},
@@ -5566,43 +5653,43 @@ Can't be set to 1 if --log-slave-updates
 #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,
@@ -5629,8 +5716,8 @@ Can't be set to 1 if --log-slave-updates
    "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},
@@ -5643,23 +5730,23 @@ Can't be set to 1 if --log-slave-updates
   {"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,
@@ -5668,7 +5755,7 @@ log and this option does nothing anymore
    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"
@@ -5679,7 +5766,7 @@ log and this option does nothing anymore
    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
@@ -5688,19 +5775,19 @@ log and this option does nothing anymore
    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 "
@@ -5710,83 +5797,83 @@ log and this option does nothing anymore
    "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)",
@@ -5794,70 +5881,70 @@ log and this option does nothing anymore
     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
@@ -5866,356 +5953,356 @@ log and this option does nothing anymore
    , 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},
 #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:  "
@@ -6223,13 +6310,13 @@ The minimum value for this variable is 4
    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}
@@ -6592,8 +6679,8 @@ SHOW_VAR status_vars[]= {
   {"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},
@@ -6924,7 +7011,7 @@ static void mysql_init_variables(void)
   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();
@@ -6971,6 +7058,7 @@ static void mysql_init_variables(void)
 	  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_info_file= (char*) "master.info",
@@ -7128,6 +7216,7 @@ get_one_option(int optid, const struct m
     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))
@@ -7545,7 +7634,7 @@ get_one_option(int optid, const struct m
     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);
@@ -7566,7 +7655,7 @@ get_one_option(int optid, const struct m
 }
 	/* Initiates DEBUG - but no debugging here ! */
 
-static gptr *
+static uchar* *
 mysql_getopt_value(const char *keyname, uint key_length,
 		   const struct my_option *option)
 {
@@ -7581,13 +7670,13 @@ mysql_getopt_value(const char *keyname, 
       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;
     }
   }
   }
@@ -7739,7 +7828,7 @@ static char *get_relative_path(const cha
 */
 
 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];
@@ -7857,7 +7946,7 @@ static ulong find_bit_type(const char *x
 
   found=0;
   found_end= 0;
-  pos=(my_string) x;
+  pos=(char *) x;
   while (*pos == ' ') pos++;
   found_end= *pos == 0;
   while (!found_end)
@@ -7954,7 +8043,7 @@ static void create_pid_file()
     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.309/sql/slave.cc	2007-06-16 19:53:19 +02:00
+++ 1.310/sql/slave.cc	2007-06-16 19:53:19 +02:00
@@ -74,9 +74,6 @@ static int connect_to_master(THD* thd, M
                              bool reconnect, bool suppress_warnings);
 static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed,
                       void* thread_killed_arg);
-static int request_table_dump(MYSQL* mysql, const char* db, const char* table);
-static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
-                                  const char* table_name, bool overwrite);
 static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi);
 static Log_event* next_event(RELAY_LOG_INFO* rli);
 
@@ -175,18 +172,15 @@ int init_slave()
   }
 
   if (init_master_info(active_mi,master_info_file,relay_log_info_file,
-                       !master_host, (SLAVE_IO | SLAVE_SQL)))
+                       1, (SLAVE_IO | SLAVE_SQL)))
   {
     sql_print_error("Failed to initialize the master info structure");
     goto err;
   }
 
-  if (server_id && !master_host && active_mi->host[0])
-    master_host= active_mi->host;
-
   /* If server id is not set, start_slave_thread() will say it */
 
-  if (master_host && !opt_skip_slave_start)
+  if (active_mi->host[0] && !opt_skip_slave_start)
   {
     if (start_slave_threads(1 /* need mutex */,
                             0 /* no wait for start*/,
@@ -900,188 +894,6 @@ err:
   DBUG_RETURN(0);
 }
 
-/*
-  Used by fetch_master_table (used by LOAD TABLE tblname FROM MASTER and LOAD
-  DATA FROM MASTER). Drops the table (if 'overwrite' is true) and recreates it
-  from the dump. Honours replication inclusion/exclusion rules.
-  db must be non-zero (guarded by assertion).
-
-  RETURN VALUES
-    0           success
-    1           error
-*/
-
-static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
-                                  const char* table_name, bool overwrite)
-{
-  ulong packet_len;
-  char *query, *save_db;
-  uint32 save_db_length;
-  Vio* save_vio;
-  HA_CHECK_OPT check_opt;
-  TABLE_LIST tables;
-  int error= 1;
-  handler *file;
-  ulonglong save_options;
-  NET *net= &mysql->net;
-  const char *found_semicolon= NULL;
-  DBUG_ENTER("create_table_from_dump");
-
-  packet_len= my_net_read(net); // read create table statement
-  if (packet_len == packet_error)
-  {
-    my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
-    DBUG_RETURN(1);
-  }
-  if (net->read_pos[0] == 255) // error from master
-  {
-    char *err_msg;
-    err_msg= (char*) net->read_pos + ((mysql->server_capabilities &
-                                       CLIENT_PROTOCOL_41) ?
-                                      3+SQLSTATE_LENGTH+1 : 3);
-    my_error(ER_MASTER, MYF(0), err_msg);
-    DBUG_RETURN(1);
-  }
-  thd->command = COM_TABLE_DUMP;
-  thd->query_length= packet_len;
-  /* Note that we should not set thd->query until the area is initalized */
-  if (!(query = thd->strmake((char*) net->read_pos, packet_len)))
-  {
-    sql_print_error("create_table_from_dump: out of memory");
-    my_message(ER_GET_ERRNO, "Out of memory", MYF(0));
-    DBUG_RETURN(1);
-  }
-  thd->query= query;
-  thd->query_error = 0;
-  thd->net.no_send_ok = 1;
-
-  bzero((char*) &tables,sizeof(tables));
-  tables.db = (char*)db;
-  tables.alias= tables.table_name= (char*)table_name;
-
-  /* Drop the table if 'overwrite' is true */
-  if (overwrite && mysql_rm_table(thd,&tables,1,0)) /* drop if exists */
-  {
-    sql_print_error("create_table_from_dump: failed to drop the table");
-    goto err;
-  }
-
-  /* Create the table. We do not want to log the "create table" statement */
-  save_options = thd->options;
-  thd->options &= ~(ulong) (OPTION_BIN_LOG);
-  thd->proc_info = "Creating table from master dump";
-  // save old db in case we are creating in a different database
-  save_db = thd->db;
-  save_db_length= thd->db_length;
-  thd->db = (char*)db;
-  DBUG_ASSERT(thd->db != 0);
-  thd->db_length= strlen(thd->db);
-  mysql_parse(thd, thd->query, packet_len, &found_semicolon); // run create table
-  thd->db = save_db;            // leave things the way the were before
-  thd->db_length= save_db_length;
-  thd->options = save_options;
-
-  if (thd->query_error)
-    goto err;                   // mysql_parse took care of the error send
-
-  thd->proc_info = "Opening master dump table";
-  tables.lock_type = TL_WRITE;
-  if (!open_ltable(thd, &tables, TL_WRITE))
-  {
-    sql_print_error("create_table_from_dump: could not open created table");
-    goto err;
-  }
-
-  file = tables.table->file;
-  thd->proc_info = "Reading master dump table data";
-  /* Copy the data file */
-  if (file->net_read_dump(net))
-  {
-    my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
-    sql_print_error("create_table_from_dump: failed in\
- handler::net_read_dump()");
-    goto err;
-  }
-
-  check_opt.init();
-  check_opt.flags|= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
-  thd->proc_info = "Rebuilding the index on master dump table";
-  /*
-    We do not want repair() to spam us with messages
-    just send them to the error log, and report the failure in case of
-    problems.
-  */
-  save_vio = thd->net.vio;
-  thd->net.vio = 0;
-  /* Rebuild the index file from the copied data file (with REPAIR) */
-  error=file->ha_repair(thd,&check_opt) != 0;
-  thd->net.vio = save_vio;
-  if (error)
-    my_error(ER_INDEX_REBUILD, MYF(0), tables.table->s->table_name.str);
-
-err:
-  close_thread_tables(thd);
-  thd->net.no_send_ok = 0;
-  DBUG_RETURN(error);
-}
-
-
-int fetch_master_table(THD *thd, const char *db_name, const char *table_name,
-                       MASTER_INFO *mi, MYSQL *mysql, bool overwrite)
-{
-  int error= 1;
-  const char *errmsg=0;
-  bool called_connected= (mysql != NULL);
-  DBUG_ENTER("fetch_master_table");
-  DBUG_PRINT("enter", ("db_name: '%s'  table_name: '%s'",
-                       db_name,table_name));
-
-  if (!called_connected)
-  {
-    if (!(mysql = mysql_init(NULL)))
-    {
-      DBUG_RETURN(1);
-    }
-    if (connect_to_master(thd, mysql, mi))
-    {
-      my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql));
-      /*
-        We need to clear the active VIO since, theoretically, somebody
-        might issue an awake() on this thread.  If we are then in the
-        middle of closing and destroying the VIO inside the
-        mysql_close(), we will have a problem.
-       */
-#ifdef SIGNAL_WITH_VIO_CLOSE
-      thd->clear_active_vio();
-#endif
-      mysql_close(mysql);
-      DBUG_RETURN(1);
-    }
-    if (thd->killed)
-      goto err;
-  }
-
-  if (request_table_dump(mysql, db_name, table_name))
-  {
-    error= ER_UNKNOWN_ERROR;
-    errmsg= "Failed on table dump request";
-    goto err;
-  }
-  if (create_table_from_dump(thd, mysql, db_name,
-                             table_name, overwrite))
-    goto err;    // create_table_from_dump have sent the error already
-  error = 0;
-
- err:
-  thd->net.no_send_ok = 0; // Clear up garbage after create_table_from_dump
-  if (!called_connected)
-    mysql_close(mysql);
-  if (errmsg && thd->vio_ok())
-    my_message(error, errmsg, MYF(0));
-  DBUG_RETURN(test(error));                     // Return 1 on error
-}
-
-
 static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli)
 {
   bool slave_killed=0;
@@ -1523,44 +1335,13 @@ static int request_dump(MYSQL* mysql, MA
     else
       sql_print_error("Error on COM_BINLOG_DUMP: %d  %s, will retry in %d secs",
                       mysql_errno(mysql), mysql_error(mysql),
-                      master_connect_retry);
+                      mi->connect_retry);
     DBUG_RETURN(1);
   }
 
   DBUG_RETURN(0);
 }
 
-
-static int request_table_dump(MYSQL* mysql, const char* db, const char* table)
-{
-  uchar buf[1024], *p = buf;
-  DBUG_ENTER("request_table_dump");
-
-  uint table_len = (uint) strlen(table);
-  uint db_len = (uint) strlen(db);
-  if (table_len + db_len > sizeof(buf) - 2)
-  {
-    sql_print_error("request_table_dump: Buffer overrun");
-    DBUG_RETURN(1);
-  }
-
-  *p++ = db_len;
-  memcpy(p, db, db_len);
-  p += db_len;
-  *p++ = table_len;
-  memcpy(p, table, table_len);
-
-  if (simple_command(mysql, COM_TABLE_DUMP, buf, p - buf + table_len, 1))
-  {
-    sql_print_error("request_table_dump: Error sending the table dump \
-command");
-    DBUG_RETURN(1);
-  }
-
-  DBUG_RETURN(0);
-}
-
-
 /*
   Read one event from the master
 
@@ -2450,7 +2231,7 @@ Slave SQL thread aborted. Can't execute 
             "position %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, 
             llbuff));
         else
-          sql_print_error("\
+        sql_print_error("\
 Error running query, slave SQL thread aborted. Fix the problem, and restart \
 the slave SQL thread with \"SLAVE START\". We stopped at log \
 '%s' position %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, llbuff));

--- 1.282/sql/sql_lex.h	2007-06-16 19:53:19 +02:00
+++ 1.283/sql/sql_lex.h	2007-06-16 19:53:19 +02:00
@@ -39,8 +39,8 @@ class Event_parse_data;
 #ifdef MYSQL_YACC
 #define LEX_YYSTYPE void *
 #else
-#include "lex_symbol.h"
 #if MYSQL_LEX
+#include "lex_symbol.h"
 #include "sql_yacc.h"
 #define LEX_YYSTYPE YYSTYPE *
 #else
@@ -84,10 +84,10 @@ enum enum_sql_command {
   SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
   SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
   SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
-  SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER,
-  SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE,
+  SQLCOM_BEGIN, SQLCOM_CHANGE_MASTER,
+  SQLCOM_RENAME_TABLE,
   SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_PURGE_BEFORE, SQLCOM_SHOW_BINLOGS,
-  SQLCOM_SHOW_OPEN_TABLES, SQLCOM_LOAD_MASTER_DATA,
+  SQLCOM_SHOW_OPEN_TABLES,
   SQLCOM_HA_OPEN, SQLCOM_HA_CLOSE, SQLCOM_HA_READ,
   SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
   SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
@@ -1213,6 +1213,7 @@ typedef struct st_lex : public Query_tab
   union {
     enum ha_rkey_function ha_rkey_mode;
     enum xa_option_words xa_opt;
+    bool lock_transactional;            /* For LOCK TABLE ... IN ... MODE */
   };
   enum enum_var_type option_type;
   enum enum_view_create_mode create_view_mode;

--- 1.128/sql/sql_load.cc	2007-06-16 19:53:19 +02:00
+++ 1.129/sql/sql_load.cc	2007-06-16 19:53:19 +02:00
@@ -287,6 +287,15 @@ bool mysql_load(THD *thd,sql_exchange *e
     {
       (void) fn_format(name, ex->file_name, mysql_real_data_home, "",
 		       MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
+
+      if (opt_secure_file_priv &&
+          strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
+      {
+        /* Read only allowed from within dir specified by secure_file_priv */
+        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
+        DBUG_RETURN(TRUE);
+      }
+
 #if !defined(__WIN__) && ! defined(__NETWARE__)
       MY_STAT stat_info;
       if (!my_stat(name,&stat_info,MYF(MY_WME)))
@@ -305,15 +314,6 @@ bool mysql_load(THD *thd,sql_exchange *e
       if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
 	is_fifo = 1;
 #endif
-
-      if (opt_secure_file_priv &&
-          strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
-      {
-        /* Read only allowed from within dir specified by secure_file_priv */
-        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
-        DBUG_RETURN(TRUE);
-      }
-
     }
     if ((file=my_open(name,O_RDONLY,MYF(MY_WME))) < 0)
       DBUG_RETURN(TRUE);

--- 1.682/sql/sql_parse.cc	2007-06-16 19:53:19 +02:00
+++ 1.683/sql/sql_parse.cc	2007-06-16 19:53:19 +02:00
@@ -204,14 +204,12 @@ void init_update_queries(void)
   sql_command_flags[SQLCOM_CREATE_DB]=      CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_DROP_DB]=        CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_RENAME_TABLE]=   CF_CHANGES_DATA;
-  sql_command_flags[SQLCOM_BACKUP_TABLE]=   CF_CHANGES_DATA;
-  sql_command_flags[SQLCOM_RESTORE_TABLE]=  CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_DROP_INDEX]=     CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_CREATE_VIEW]=    CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_DROP_VIEW]=      CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_CREATE_EVENT]=   CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_ALTER_EVENT]=    CF_CHANGES_DATA;
-  sql_command_flags[SQLCOM_DROP_EVENT]=     CF_CHANGES_DATA;  
+  sql_command_flags[SQLCOM_DROP_EVENT]=     CF_CHANGES_DATA;
 
   sql_command_flags[SQLCOM_UPDATE]=	    CF_CHANGES_DATA | CF_HAS_ROW_COUNT;
   sql_command_flags[SQLCOM_UPDATE_MULTI]=   CF_CHANGES_DATA | CF_HAS_ROW_COUNT;
@@ -440,81 +438,13 @@ void free_items(Item *item)
 
 void cleanup_items(Item *item)
 {
-  DBUG_ENTER("cleanup_items");  
+  DBUG_ENTER("cleanup_items");
   for (; item ; item=item->next)
     item->cleanup();
   DBUG_VOID_RETURN;
 }
 
 /*
-  Handle COM_TABLE_DUMP command
-
-  SYNOPSIS
-    mysql_table_dump
-      thd           thread handle
-      db            database name or an empty string. If empty,
-                    the current database of the connection is used
-      tbl_name      name of the table to dump
-
-  NOTES
-    This function is written to handle one specific command only.
-
-  RETURN VALUE
-    0               success
-    1               error, the error message is set in THD
-*/
-
-static
-int mysql_table_dump(THD *thd, LEX_STRING *db, char *tbl_name)
-{
-  TABLE* table;
-  TABLE_LIST* table_list;
-  int error = 0;
-  DBUG_ENTER("mysql_table_dump");
-  if (db->length == 0)
-  {
-    db->str= thd->db;            /* purecov: inspected */
-    db->length= thd->db_length;  /* purecov: inspected */
-  }
-  if (!(table_list = (TABLE_LIST*) thd->calloc(sizeof(TABLE_LIST))))
-    DBUG_RETURN(1); // out of memory
-  table_list->db= db->str;
-  table_list->table_name= table_list->alias= tbl_name;
-  table_list->lock_type= TL_READ_NO_INSERT;
-  table_list->prev_global= &table_list;	// can be removed after merge with 4.1
-
-  if (check_db_name(db))
-  {
-    /* purecov: begin inspected */
-    my_error(ER_WRONG_DB_NAME ,MYF(0), db->str ? db->str : "NULL");
-    goto err;
-    /* purecov: end */
-  }
-  if (lower_case_table_names)
-    my_casedn_str(files_charset_info, tbl_name);
-
-  if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT)))
-    DBUG_RETURN(1);
-
-  if (check_one_table_access(thd, SELECT_ACL, table_list))
-    goto err;
-  thd->free_list = 0;
-  thd->query_length=(uint) strlen(tbl_name);
-  thd->query = tbl_name;
-  if ((error = mysqld_dump_create_info(thd, table_list, -1)))
-  {
-    my_error(ER_GET_ERRNO, MYF(0), my_errno);
-    goto err;
-  }
-  net_flush(&thd->net);
-  if ((error= table->file->dump(thd,-1)))
-    my_error(ER_GET_ERRNO, MYF(0), error);
-
-err:
-  DBUG_RETURN(error);
-}
-
-/*
   Ends the current transaction and (maybe) begin the next
 
   SYNOPSIS
@@ -740,37 +670,6 @@ bool dispatch_command(enum enum_server_c
     break;
   }
 #endif
-  case COM_TABLE_DUMP:
-  {
-    char *tbl_name;
-    LEX_STRING db;
-    uint db_len= *(uchar*) packet;
-    if (db_len >= packet_length || db_len > NAME_LEN)
-    {
-      my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
-      break;
-    }
-    uint tbl_len= *(uchar*) (packet + db_len + 1);
-    if (db_len+tbl_len+2 > packet_length || tbl_len > NAME_LEN)
-    {
-      my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
-      break;
-    }
-
-    status_var_increment(thd->status_var.com_other);
-    thd->enable_slow_log= opt_log_slow_admin_statements;
-    db.str= (char*) thd->alloc(db_len + tbl_len + 2);
-    if (!db.str)
-    {
-      my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
-      break;
-    }
-    db.length= db_len;
-    tbl_name= strmake(db.str, packet + 1, db_len)+1;
-    strmake(tbl_name, packet + db_len + 2, tbl_len);
-    mysql_table_dump(thd, &db, tbl_name);
-    break;
-  }
   case COM_CHANGE_USER:
   {
     status_var_increment(thd->status_var.com_other);
@@ -1947,30 +1846,6 @@ mysql_execute_command(THD *thd)
   }
 #endif
 
-  case SQLCOM_BACKUP_TABLE:
-  {
-    DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, SELECT_ACL, all_tables, 0) ||
-	check_global_access(thd, FILE_ACL))
-      goto error; /* purecov: inspected */
-    thd->enable_slow_log= opt_log_slow_admin_statements;
-    res = mysql_backup_table(thd, first_table);
-    select_lex->table_list.first= (uchar*) first_table;
-    lex->query_tables=all_tables;
-    break;
-  }
-  case SQLCOM_RESTORE_TABLE:
-  {
-    DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    if (check_table_access(thd, INSERT_ACL, all_tables, 0) ||
-	check_global_access(thd, FILE_ACL))
-      goto error; /* purecov: inspected */
-    thd->enable_slow_log= opt_log_slow_admin_statements;
-    res = mysql_restore_table(thd, first_table);
-    select_lex->table_list.first= (uchar*) first_table;
-    lex->query_tables=all_tables;
-    break;
-  }
   case SQLCOM_ASSIGN_TO_KEYCACHE:
   {
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
@@ -2020,13 +1895,6 @@ mysql_execute_command(THD *thd)
     break;
   }
 
-  case SQLCOM_LOAD_MASTER_DATA: // sync with master
-    if (check_global_access(thd, SUPER_ACL))
-      goto error;
-    if (end_active_trans(thd))
-      goto error;
-    res = load_master_data(thd);
-    break;
 #endif /* HAVE_REPLICATION */
   case SQLCOM_SHOW_ENGINE_STATUS:
     {
@@ -2042,35 +1910,6 @@ mysql_execute_command(THD *thd)
       res = ha_show_status(thd, lex->create_info.db_type, HA_ENGINE_MUTEX);
       break;
     }
-#ifdef HAVE_REPLICATION
-  case SQLCOM_LOAD_MASTER_TABLE:
-  {
-    DBUG_ASSERT(first_table == all_tables && first_table != 0);
-    DBUG_ASSERT(first_table->db); /* Must be set in the parser */
-
-    if (check_access(thd, CREATE_ACL, first_table->db,
-		     &first_table->grant.privilege, 0, 0,
-                     test(first_table->schema_table)))
-      goto error;				/* purecov: inspected */
-    /* Check that the first table has CREATE privilege */
-    if (check_grant(thd, CREATE_ACL, all_tables, 0, 1, 0))
-      goto error;
-
-    pthread_mutex_lock(&LOCK_active_mi);
-    /*
-      fetch_master_table will send the error to the client on failure.
-      Give error if the table already exists.
-    */
-    if (!fetch_master_table(thd, first_table->db, first_table->table_name,
-			    active_mi, 0, 0))
-    {
-      send_ok(thd);
-    }
-    pthread_mutex_unlock(&LOCK_active_mi);
-    break;
-  }
-#endif /* HAVE_REPLICATION */
-
   case SQLCOM_CREATE_TABLE:
   {
     /* If CREATE TABLE of non-temporary table, do implicit commit */
@@ -2490,6 +2329,7 @@ end_with_restore_list:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
     if (check_table_access(thd, SELECT_ACL | EXTRA_ACL, all_tables, 0))
       goto error; /* purecov: inspected */
+
     res = mysql_checksum_table(thd, first_table, &lex->check_opt);
     break;
   }
@@ -3025,11 +2865,50 @@ end_with_restore_list:
     send_ok(thd);
     break;
   case SQLCOM_LOCK_TABLES:
+    if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, 0))
+      goto error;
+    /*
+      We try to take transactional locks if
+      - only transactional locks are requested (lex->lock_transactional) and
+      - no non-transactional locks exist (!thd->locked_tables).
+    */
+    DBUG_PRINT("lock_info", ("lex->lock_transactional: %d  "
+                             "thd->locked_tables: 0x%lx",
+                             lex->lock_transactional,
+                             (long) thd->locked_tables));
+    if (lex->lock_transactional && !thd->locked_tables)
+    {
+      int rc;
+      /*
+        All requested locks are transactional and no non-transactional
+        locks exist.
+      */
+      if ((rc= try_transactional_lock(thd, all_tables)) == -1)
+        goto error;
+      if (rc == 0)
+      {
+        send_ok(thd);
+        break;
+      }
+      /*
+        Non-transactional locking has been requested or
+        non-transactional locks exist already or transactional locks are
+        not supported by all storage engines. Take non-transactional
+        locks.
+      */
+    }
+    /*
+      One or more requested locks are non-transactional and/or
+      non-transactional locks exist or a storage engine does not support
+      transactional locks. Check if at least one transactional lock is
+      requested. If yes, warn about the conversion to non-transactional
+      locks or abort in strict mode.
+    */
+    if (check_transactional_lock(thd, all_tables))
+      goto error;
     unlock_locked_tables(thd);
     if (end_active_trans(thd))
       goto error;
-    if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, 0))
-      goto error;
     thd->in_lock_tables=1;
     thd->options|= OPTION_TABLE_LOCK;
 
@@ -3041,6 +2920,9 @@ end_with_restore_list:
 #endif /*HAVE_QUERY_CACHE*/
       thd->locked_tables=thd->lock;
       thd->lock=0;
+      (void) set_handler_table_locks(thd, all_tables, FALSE);
+      DBUG_PRINT("lock_info", ("thd->locked_tables: 0x%lx",
+                               (long) thd->locked_tables));
       send_ok(thd);
     }
     else
@@ -4903,8 +4785,12 @@ check_table_access(THD *thd, ulong want_
       goto deny;
   }
   thd->security_ctx= backup_ctx;
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
   return check_grant(thd,want_access & ~EXTRA_ACL,org_tables,
 		       test(want_access & EXTRA_ACL), UINT_MAX, no_errors);
+#else
+  return FALSE;
+#endif
 deny:
   thd->security_ctx= backup_ctx;
   return TRUE;
@@ -5536,17 +5422,6 @@ bool add_field_to_list(THD *thd, LEX_STR
     DBUG_RETURN(1);
   }
 
-  if (type == MYSQL_TYPE_TIMESTAMP && length)
-  {
-    /* Display widths are no longer supported for TIMSTAMP as of MySQL 4.1.
-       In other words, for declarations such as TIMESTAMP(2), TIMESTAMP(4),
-       and so on, the display width is ignored.
-    */
-    char buf[32];
-    my_snprintf(buf, sizeof(buf), "TIMESTAMP(%s)", length);
-    WARN_DEPRECATED(thd, "5.2", buf, "'TIMESTAMP'");
-  }
-
   if (!(new_field= new create_field()) ||
       new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
                       default_value, on_update_value, comment, change,
@@ -5684,6 +5559,8 @@ TABLE_LIST *st_select_lex::add_table_to_
   ptr->table_name=table->table.str;
   ptr->table_name_length=table->table.length;
   ptr->lock_type=   lock_type;
+  ptr->lock_timeout= -1;      /* default timeout */
+  ptr->lock_transactional= 1; /* allow transactional locks */
   ptr->updating=    test(table_options & TL_OPTION_UPDATING);
   ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX);
   ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);

--- 1.415/sql/sql_show.cc	2007-06-16 19:53:19 +02:00
+++ 1.416/sql/sql_show.cc	2007-06-16 19:53:19 +02:00
@@ -759,33 +759,6 @@ mysqld_list_fields(THD *thd, TABLE_LIST 
 }
 
 
-int
-mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd)
-{
-  Protocol *protocol= thd->protocol;
-  String *packet= protocol->storage_packet();
-  DBUG_ENTER("mysqld_dump_create_info");
-  DBUG_PRINT("enter",("table: %s",table_list->table->s->table_name.str));
-
-  protocol->prepare_for_resend();
-  if (store_create_info(thd, table_list, packet, NULL))
-    DBUG_RETURN(-1);
-
-  if (fd < 0)
-  {
-    if (protocol->write())
-      DBUG_RETURN(-1);
-    protocol->flush();
-  }
-  else
-  {
-    if (my_write(fd, (const uchar*) packet->ptr(), packet->length(),
-		 MYF(MY_WME)))
-      DBUG_RETURN(-1);
-  }
-  DBUG_RETURN(0);
-}
-
 /*
   Go through all character combinations and ensure that sql_lex.cc can
   parse it as an identifier.
@@ -1406,6 +1379,15 @@ static void store_key_options(THD *thd, 
       end= longlong10_to_str(key_info->block_size, buff, 10);
       packet->append(buff, (uint) (end - buff));
     }
+
+    DBUG_ASSERT(test(key_info->flags & HA_USES_COMMENT) == 
+               (key_info->comment.length > 0));
+    if (key_info->flags & HA_USES_COMMENT)
+    {
+      packet->append(STRING_WITH_LEN(" COMMENT "));
+      append_unescaped(packet, key_info->comment.str, 
+                       key_info->comment.length);
+    }
   }
 }
 
@@ -3585,6 +3567,11 @@ static int get_schema_stat_record(THD *t
         else
           table->field[14]->store("", 0, cs);
         table->field[14]->set_notnull();
+        DBUG_ASSERT(test(key_info->flags & HA_USES_COMMENT) == 
+                   (key_info->comment.length > 0));
+        if (key_info->flags & HA_USES_COMMENT)
+          table->field[15]->store(key_info->comment.str, 
+                                  key_info->comment.length, cs);
         if (schema_table_store_record(thd, table))
           DBUG_RETURN(1);
       }
@@ -5284,7 +5271,7 @@ ST_FIELD_INFO tables_fields_info[]=
   {"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
    (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum"},
   {"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options"},
-  {"TABLE_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, "Comment"},
+  {"TABLE_COMMENT", TABLE_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Comment"},
   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
 };
 
@@ -5315,7 +5302,7 @@ ST_FIELD_INFO columns_fields_info[]=
   {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key"},
   {"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra"},
   {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges"},
-  {"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment"},
+  {"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Comment"},
   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
 };
 
@@ -5434,6 +5421,7 @@ ST_FIELD_INFO stat_fields_info[]=
   {"NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"},
   {"INDEX_TYPE", 16, MYSQL_TYPE_STRING, 0, 0, "Index_type"},
   {"COMMENT", 16, MYSQL_TYPE_STRING, 0, 1, "Comment"},
+  {"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Index_Comment"},
   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
 };
 

--- 1.436/sql/sql_table.cc	2007-06-16 19:53:19 +02:00
+++ 1.437/sql/sql_table.cc	2007-06-16 19:53:19 +02:00
@@ -214,7 +214,7 @@ uint build_tmptable_filename(THD* thd, c
 
   char *p= strnmov(buff, mysql_tmpdir, bufflen);
   my_snprintf(p, bufflen - (p - buff), "/%s%lx_%lx_%x%s",
-              tmp_file_prefix, current_pid,
+	      tmp_file_prefix, current_pid,
               thd->thread_id, thd->tmp_table++, reg_ext);
 
   if (lower_case_table_names)
@@ -2027,7 +2027,7 @@ int prepare_create_field(create_field *s
       sql_field->pack_flag|=FIELDFLAG_BINARY;
     sql_field->unireg_check=Field::INTERVAL_FIELD;
     if (check_duplicates_in_interval("ENUM",sql_field->field_name,
-                                     sql_field->interval,
+                                 sql_field->interval,
                                      sql_field->charset, &dup_val_count))
       DBUG_RETURN(1);
     break;
@@ -2038,7 +2038,7 @@ int prepare_create_field(create_field *s
       sql_field->pack_flag|=FIELDFLAG_BINARY;
     sql_field->unireg_check=Field::BIT_FIELD;
     if (check_duplicates_in_interval("SET",sql_field->field_name,
-                                     sql_field->interval,
+                                 sql_field->interval,
                                      sql_field->charset, &dup_val_count))
       DBUG_RETURN(1);
     /* Check that count of unique members is not more then 64 */
@@ -2685,6 +2685,36 @@ mysql_prepare_create_table(THD *thd, HA_
     if (key_info->block_size)
       key_info->flags|= HA_USES_BLOCK_SIZE;
 
+    uint tmp_len= system_charset_info->cset->charpos(system_charset_info,
+                                           key->key_create_info.comment.str,
+                                           key->key_create_info.comment.str +
+                                           key->key_create_info.comment.length,
+                                           INDEX_COMMENT_MAXLEN);
+
+    if (tmp_len < key->key_create_info.comment.length)
+    {
+      if ((thd->variables.sql_mode &
+	   (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
+      {
+        my_error(ER_WRONG_STRING_LENGTH, MYF(0),
+                   key->key_create_info.comment.str,"INDEX COMMENT",
+                   (uint) INDEX_COMMENT_MAXLEN);
+        DBUG_RETURN(-1);
+      }
+      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                          ER_WRONG_STRING_LENGTH, ER(ER_WRONG_STRING_LENGTH),
+                          key->key_create_info.comment.str,"INDEX COMMENT",
+                          (uint) INDEX_COMMENT_MAXLEN);
+      key->key_create_info.comment.length= tmp_len;
+    }
+
+    key_info->comment.length= key->key_create_info.comment.length;
+    if (key_info->comment.length > 0)
+    {
+      key_info->flags|= HA_USES_COMMENT;
+      key_info->comment.str= key->key_create_info.comment.str;
+    }
+
     List_iterator<key_part_spec> cols(key->columns), cols2(key->columns);
     CHARSET_INFO *ft_key_charset=0;  // for FULLTEXT
     for (uint column_nr=0 ; (column=cols++) ; column_nr++)
@@ -3415,10 +3445,10 @@ bool mysql_create_table_no_lock(THD *thd
       case HA_ERR_TABLE_EXIST:
         DBUG_PRINT("info", ("Table existed in handler"));
 
-        if (create_if_not_exists)
-          goto warn;
-        my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
-        goto unlock_and_end;
+      if (create_if_not_exists)
+        goto warn;
+      my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
+      goto unlock_and_end;
         break;
       default:
         DBUG_PRINT("info", ("error: %u from storage engine", retcode));
@@ -3777,70 +3807,6 @@ static int send_check_errmsg(THD *thd, T
 }
 
 
-static int prepare_for_restore(THD* thd, TABLE_LIST* table,
-			       HA_CHECK_OPT *check_opt)
-{
-  DBUG_ENTER("prepare_for_restore");
-
-  if (table->table) // do not overwrite existing tables on restore
-  {
-    DBUG_RETURN(send_check_errmsg(thd, table, "restore",
-				  "table exists, will not overwrite on restore"
-				  ));
-  }
-  else
-  {
-    char* backup_dir= thd->lex->backup_dir;
-    char src_path[FN_REFLEN], dst_path[FN_REFLEN], uname[FN_REFLEN];
-    char* table_name= table->table_name;
-    char* db= table->db;
-
-    VOID(tablename_to_filename(table->table_name, uname, sizeof(uname)));
-
-    if (fn_format_relative_to_data_home(src_path, uname, backup_dir, reg_ext))
-      DBUG_RETURN(-1); // protect buffer overflow
-
-    build_table_filename(dst_path, sizeof(dst_path),
-                         db, table_name, reg_ext, 0);
-
-    if (lock_and_wait_for_table_name(thd,table))
-      DBUG_RETURN(-1);
-
-    if (my_copy(src_path, dst_path, MYF(MY_WME)))
-    {
-      pthread_mutex_lock(&LOCK_open);
-      unlock_table_name(thd, table);
-      pthread_mutex_unlock(&LOCK_open);
-      DBUG_RETURN(send_check_errmsg(thd, table, "restore",
-				    "Failed copying .frm file"));
-    }
-    if (mysql_truncate(thd, table, 1))
-    {
-      pthread_mutex_lock(&LOCK_open);
-      unlock_table_name(thd, table);
-      pthread_mutex_unlock(&LOCK_open);
-      DBUG_RETURN(send_check_errmsg(thd, table, "restore",
-				    "Failed generating table from .frm file"));
-    }
-  }
-
-  /*
-    Now we should be able to open the partially restored table
-    to finish the restore in the handler later on
-  */
-  pthread_mutex_lock(&LOCK_open);
-  if (reopen_name_locked_table(thd, table, TRUE))
-  {
-    unlock_table_name(thd, table);
-    pthread_mutex_unlock(&LOCK_open);
-    DBUG_RETURN(send_check_errmsg(thd, table, "restore",
-                                  "Failed to open partially restored table"));
-  }
-  pthread_mutex_unlock(&LOCK_open);
-  DBUG_RETURN(0);
-}
-
-
 static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
 			      HA_CHECK_OPT *check_opt)
 {
@@ -4413,29 +4379,6 @@ send_result_message:
   if (table)
     table->table=0;
   DBUG_RETURN(TRUE);
-}
-
-
-bool mysql_backup_table(THD* thd, TABLE_LIST* table_list)
-{
-  DBUG_ENTER("mysql_backup_table");
-  WARN_DEPRECATED(thd, "5.2", "BACKUP TABLE",
-                  "MySQL Administrator (mysqldump, mysql)");
-  DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
-				"backup", TL_READ, 0, 0, 0, 0,
-				&handler::backup, 0));
-}
-
-
-bool mysql_restore_table(THD* thd, TABLE_LIST* table_list)
-{
-  DBUG_ENTER("mysql_restore_table");
-  WARN_DEPRECATED(thd, "5.2", "RESTORE TABLE",
-                  "MySQL Administrator (mysqldump, mysql)");
-  DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
-				"restore", TL_WRITE, 1, 1, 0,
-				&prepare_for_restore,
-				&handler::restore, 0));
 }
 
 

--- 1.578/sql/sql_yacc.yy	2007-06-16 19:53:19 +02:00
+++ 1.579/sql/sql_yacc.yy	2007-06-16 19:53:19 +02:00
@@ -472,6 +472,7 @@ Item* handle_sql2003_note184_exception(T
   enum Item_udftype udf_type;
   CHARSET_INFO *charset;
   thr_lock_type lock_type;
+  struct st_table_lock_info table_lock_info;
   interval_type interval, interval_time_st;
   timestamp_type date_time_type;
   st_select_lex *select_lex;
@@ -491,10 +492,10 @@ bool my_yyoverflow(short **a, YYSTYPE **
 
 %pure_parser					/* We have threads */
 /*
-  Currently there is 286 shift/reduce conflict. We should not introduce
+  Currently there is 285 shift/reduce conflict. We should not introduce
   new conflicts any more.
 */
-%expect 286
+%expect 285
 
 /*
    Comments for TOKENS.
@@ -660,6 +661,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  EVENTS_SYM
 %token  EVENT_SYM
 %token  EVERY_SYM                     /* SQL-2003-N */
+%token  EXCLUSIVE_SYM
 %token  EXECUTE_SYM                   /* SQL-2003-R */
 %token  EXISTS                        /* SQL-2003-R */
 %token  EXIT_SYM
@@ -718,7 +720,6 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  INFILE
 %token  INITIAL_SIZE_SYM
 %token  INNER_SYM                     /* SQL-2003-R */
-%token  INNOBASE_SYM
 %token  INOUT_SYM                     /* SQL-2003-R */
 %token  INSENSITIVE_SYM               /* SQL-2003-R */
 %token  INSERT                        /* SQL-2003-R */
@@ -831,6 +832,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  NOT2_SYM
 %token  NOT_SYM                       /* SQL-2003-R */
 %token  NOW_SYM
+%token  NOWAIT_SYM
 %token  NO_SYM                        /* SQL-2003-R */
 %token  NO_WAIT_SYM
 %token  NO_WRITE_TO_BINLOG
@@ -1107,7 +1109,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 	text_string opt_gconcat_separator
 
 %type <num>
-	type int_type real_type order_dir lock_option
+	type int_type real_type order_dir
 	udf_type if_exists opt_local opt_table_options table_options
         table_option opt_if_not_exists opt_no_write_to_binlog
         delete_option opt_temporary all_or_any opt_distinct
@@ -1117,6 +1119,8 @@ bool my_yyoverflow(short **a, YYSTYPE **
         opt_natural_language_mode opt_query_expansion
         opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment
         ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt
+        opt_transactional_lock_timeout
+        /* opt_lock_timeout_value */
 
 %type <ulong_num>
 	ulong_num real_ulong_num merge_insert_types
@@ -1129,6 +1133,10 @@ bool my_yyoverflow(short **a, YYSTYPE **
 
 %type <lock_type>
 	replace_lock_option opt_low_priority insert_lock_option load_data_lock
+        transactional_lock_mode
+
+%type <table_lock_info>
+        table_lock_info
 
 %type <item>
 	literal text_literal insert_ident order_ident
@@ -1219,7 +1227,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 	show describe load alter optimize keycache preload flush
 	reset purge begin commit rollback savepoint release
 	slave master_def master_defs master_file_def slave_until_opts
-	repair restore backup analyze check start checksum
+	repair analyze check start checksum
 	field_list field_list_item field_spec kill column_def key_def
 	keycache_list assign_to_keycache preload_list preload_keys
 	select_item_list select_item values_list no_braces
@@ -1248,7 +1256,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
         prepare prepare_src execute deallocate
 	statement sp_suid
 	sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic xa
-        load_data opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
+        opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
         definer view_replace_or_algorithm view_replace
         view_algorithm view_or_trigger_or_sp_or_event
         view_or_trigger_or_sp_or_event_tail
@@ -1308,7 +1316,6 @@ verb_clause:
 statement:
 	  alter
 	| analyze
-	| backup
 	| binlog_base64_event
 	| call
 	| change
@@ -1342,7 +1349,6 @@ statement:
 	| repair
 	| replace
 	| reset
-	| restore
 	| revoke
 	| rollback
 	| savepoint
@@ -4287,13 +4293,6 @@ create_table_options:
 
 create_table_option:
 	ENGINE_SYM opt_equal storage_engines    { Lex->create_info.db_type= $3; Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; }
-	| TYPE_SYM opt_equal storage_engines
-          {
-            Lex->create_info.db_type= $3;
-            WARN_DEPRECATED(yythd, "5.2", "TYPE=storage_engine",
-                            "'ENGINE=storage_engine'");
-            Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
-          }
 	| MAX_ROWS opt_equal ulonglong_num	{ Lex->create_info.max_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;}
 	| MIN_ROWS opt_equal ulonglong_num	{ Lex->create_info.min_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;}
 	| AVG_ROW_LENGTH opt_equal ulong_num	{ Lex->create_info.avg_row_length=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;}
@@ -4595,21 +4594,19 @@ type:
 	| nvarchar '(' NUM ')' opt_bin_mod { Lex->length=$3.str;
 					  $$= MYSQL_TYPE_VARCHAR;
 					  Lex->charset=national_charset_info; }
-	| VARBINARY '(' NUM ')' 	{ Lex->length=$3.str;
+        | VARBINARY '(' NUM ')'         { Lex->length=$3.str;
 					  Lex->charset=&my_charset_bin;
 					  $$= MYSQL_TYPE_VARCHAR; }
 	| YEAR_SYM opt_len field_options { $$=MYSQL_TYPE_YEAR; }
 	| DATE_SYM			{ $$=MYSQL_TYPE_DATE; }
 	| TIME_SYM			{ $$=MYSQL_TYPE_TIME; }
-	| TIMESTAMP opt_len
+	| TIMESTAMP
 	  {
 	    if (YYTHD->variables.sql_mode & MODE_MAXDB)
 	      $$=MYSQL_TYPE_DATETIME;
 	    else
             {
-              /* 
-                Unlike other types TIMESTAMP fields are NOT NULL by default.
-              */
+              /* Unlike other types TIMESTAMP fields are NOT NULL by default */
               Lex->type|= NOT_NULL_FLAG;
 	      $$=MYSQL_TYPE_TIMESTAMP;
             }
@@ -5035,6 +5032,7 @@ key_opt:
         key_using_alg
 	| KEY_BLOCK_SIZE opt_equal ulong_num
 	  { Lex->key_create_info.block_size= $3; }
+	| COMMENT_SYM TEXT_STRING_sys { Lex->key_create_info.comment= $2; }
 	| WITH PARSER_SYM IDENT_sys
           {
             if (plugin_is_ready(&$3, MYSQL_FTPARSER_PLUGIN))
@@ -5746,27 +5744,6 @@ slave_until_opts:
        master_file_def
        | slave_until_opts ',' master_file_def ;
 
-
-restore:
-	RESTORE_SYM table_or_tables
-	{
-	   Lex->sql_command = SQLCOM_RESTORE_TABLE;
-	}
-	table_list FROM TEXT_STRING_sys
-        {
-	  Lex->backup_dir = $6.str;
-        };
-
-backup:
-	BACKUP_SYM table_or_tables
-	{
-	   Lex->sql_command = SQLCOM_BACKUP_TABLE;
-	}
-	table_list TO_SYM TEXT_STRING_sys
-        {
-	  Lex->backup_dir = $6.str;
-        };
-
 checksum:
         CHECKSUM_SYM table_or_tables
 	{
@@ -8632,14 +8609,6 @@ show_param:
             if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
               MYSQL_YYABORT;
 	  }
-        | opt_full PLUGIN_SYM
-	  {
-	    LEX *lex= Lex;
-	    WARN_DEPRECATED(yythd, "5.2", "SHOW PLUGIN", "'SHOW PLUGINS'");
-            lex->sql_command= SQLCOM_SHOW_PLUGINS;
-            if (prepare_schema_table(YYTHD, lex, 0, SCH_PLUGINS))
-              MYSQL_YYABORT;
-	  }
         | PLUGINS_SYM
 	  {
 	    LEX *lex= Lex;
@@ -8697,12 +8666,6 @@ show_param:
 	    LEX *lex=Lex;
 	    lex->sql_command= SQLCOM_SHOW_COLUMN_TYPES;
 	  }
-	| TABLE_SYM TYPES_SYM
-	  {
-	    LEX *lex=Lex;
-	    lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
-	    WARN_DEPRECATED(yythd, "5.2", "SHOW TABLE TYPES", "'SHOW [STORAGE] ENGINES'");
-	  }
 	| opt_storage ENGINES_SYM
 	  {
 	    LEX *lex=Lex;
@@ -8741,30 +8704,6 @@ show_param:
             if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
               MYSQL_YYABORT;
 	  }
-        | INNOBASE_SYM STATUS_SYM
-          {
-            LEX *lex= Lex;
-            lex->sql_command = SQLCOM_SHOW_ENGINE_STATUS;
-            if (!(lex->create_info.db_type=
-                  ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
-            {
-	      my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
-	      MYSQL_YYABORT;
-            }
-            WARN_DEPRECATED(yythd, "5.2", "SHOW INNODB STATUS", "'SHOW ENGINE INNODB STATUS'");
-	  }
-        | MUTEX_SYM STATUS_SYM
-          {
-	    LEX *lex= Lex;
-            lex->sql_command = SQLCOM_SHOW_ENGINE_MUTEX;
-            if (!(lex->create_info.db_type=
-                  ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
-            {
-	      my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
-	      MYSQL_YYABORT;
-            }
-            WARN_DEPRECATED(yythd, "5.2", "SHOW MUTEX STATUS", "'SHOW ENGINE INNODB MUTEX'");
-	  }
 	| opt_full PROCESSLIST_SYM
 	  { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
         | opt_var_type  VARIABLES wild_and_where
@@ -9110,34 +9049,15 @@ load:   LOAD DATA_SYM
 	  }
           lex->fname_start= lip->ptr;
         }
-        load_data
-        {}
-        |
-        LOAD TABLE_SYM table_ident FROM MASTER_SYM
-        {
-	  LEX *lex=Lex;
-          WARN_DEPRECATED(yythd, "5.2", "LOAD TABLE FROM MASTER",
-                          "MySQL Administrator (mysqldump, mysql)");
-          if (lex->sphead)
-	  {
-	    my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD TABLE");
-	    MYSQL_YYABORT;
-	  }
-          lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
-          if (!Select->add_table_to_list(YYTHD, $3, NULL, TL_OPTION_UPDATING))
-            MYSQL_YYABORT;
-        };
-
-load_data:
 	load_data_lock opt_local INFILE TEXT_STRING_filesystem
 	{
 	  LEX *lex=Lex;
 	  lex->sql_command= SQLCOM_LOAD;
-	  lex->lock_option= $1;
-	  lex->local_file=  $2;
+	  lex->lock_option= $4;
+	  lex->local_file=  $5;
 	  lex->duplicates= DUP_ERROR;
 	  lex->ignore= 0;
-	  if (!(lex->exchange= new sql_exchange($4.str, 0)))
+	  if (!(lex->exchange= new sql_exchange($7.str, 0)))
 	    MYSQL_YYABORT;
         }
         opt_duplicate INTO
@@ -9150,7 +9070,7 @@ load_data:
         TABLE_SYM table_ident
         {
           LEX *lex=Lex;
-          if (!Select->add_table_to_list(YYTHD, $10, NULL, TL_OPTION_UPDATING,
+          if (!Select->add_table_to_list(YYTHD, $13, NULL, TL_OPTION_UPDATING,
                                          lex->lock_option))
             MYSQL_YYABORT;
           lex->field_list.empty();
@@ -9158,18 +9078,11 @@ load_data:
           lex->value_list.empty();
         }
         opt_load_data_charset
-	{ Lex->exchange->cs= $12; }
+	{ Lex->exchange->cs= $15; }
         opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
         opt_load_data_set_spec
         {}
-        |
-	FROM MASTER_SYM
-        {
-	  Lex->sql_command = SQLCOM_LOAD_MASTER_DATA;
-          WARN_DEPRECATED(yythd, "5.2", "LOAD DATA FROM MASTER",
-                          "mysqldump or future "
-                          "BACKUP/RESTORE DATABASE facility");
-        };
+        ;
 
 opt_local:
 	/* empty */	{ $$=0;}
@@ -9904,6 +9817,7 @@ keyword_sp:
 	| EVENT_SYM		{}
 	| EVENTS_SYM		{}
 	| EVERY_SYM             {}
+	| EXCLUSIVE_SYM         { /* purecov: tested */ }
 	| EXPANSION_SYM         {}
 	| EXTENDED_SYM		{}
 	| EXTENT_SIZE_SYM       {}
@@ -9930,7 +9844,6 @@ keyword_sp:
 	| INITIAL_SIZE_SYM      {}
 	| ISOLATION		{}
 	| ISSUER_SYM		{}
-	| INNOBASE_SYM		{}
 	| INSERT_METHOD		{}
 	| KEY_BLOCK_SIZE	{}
 	| LAST_SYM		{}
@@ -9989,6 +9902,7 @@ keyword_sp:
 	| NO_WAIT_SYM           {}
 	| NODEGROUP_SYM         {}
 	| NONE_SYM		{}
+	| NOWAIT_SYM            { /* purecov: tested */ }
 	| NVARCHAR_SYM		{}
 	| OFFSET_SYM		{}
 	| OLD_PASSWORD		{}
@@ -10513,7 +10427,19 @@ set_expr_or_default:
 /* Lock function */
 
 lock:
-	LOCK_SYM table_or_tables
+	LOCK_SYM
+        {
+          /*
+            Transactional locks can be taken only if all requested locks
+            are transactional. Initialize lex->lock_transactional as
+            TRUE. Any non-transactional lock request turns this to FALSE.
+            Table specific variables keep track of the locking method
+            requested for the table. This is used to warn about a
+            changed locking method later.
+          */
+          Lex->lock_transactional= TRUE;
+        }
+        table_or_tables
 	{
 	  LEX *lex= Lex;
 
@@ -10537,19 +10463,73 @@ table_lock_list:
 	| table_lock_list ',' table_lock;
 
 table_lock:
-	table_ident opt_table_alias lock_option
-	{
-	  if (!Select->add_table_to_list(YYTHD, $1, $2, 0, (thr_lock_type) $3))
-	   MYSQL_YYABORT;
-	}
+        table_ident opt_table_alias table_lock_info
+        {
+          TABLE_LIST *tlist;
+          if (!(tlist= Select->add_table_to_list(YYTHD, $1, $2, 0,
+                                                 $3.lock_type)))
+            MYSQL_YYABORT; /* purecov: inspected */
+          tlist->lock_timeout= $3.lock_timeout;
+          /* Store the requested lock method for later warning. */
+          tlist->lock_transactional= $3.lock_transactional;
+          /* Compute the resulting lock method for all tables. */
+          if (!$3.lock_transactional)
+            Lex->lock_transactional= FALSE;
+        }
         ;
 
-lock_option:
-	READ_SYM	{ $$=TL_READ_NO_INSERT; }
-	| WRITE_SYM     { $$=TL_WRITE_DEFAULT; }
-	| LOW_PRIORITY WRITE_SYM { $$=TL_WRITE_LOW_PRIORITY; }
-	| READ_SYM LOCAL_SYM { $$= TL_READ; }
+table_lock_info:
+        READ_SYM
+        {
+          $$.lock_type=          TL_READ_NO_INSERT;
+          $$.lock_timeout=       -1;
+          $$.lock_transactional= FALSE;
+        }
+        | WRITE_SYM
+        {
+          $$.lock_type=          YYTHD->update_lock_default;
+          $$.lock_timeout=       -1;
+          $$.lock_transactional= FALSE;
+        }
+        | LOW_PRIORITY WRITE_SYM
+        {
+          $$.lock_type=          TL_WRITE_LOW_PRIORITY;
+          $$.lock_timeout=       -1;
+          $$.lock_transactional= FALSE;
+        }
+        | READ_SYM LOCAL_SYM
+        {
+          $$.lock_type=          TL_READ;
+          $$.lock_timeout=       -1;
+          $$.lock_transactional= FALSE;
+        }
+        | IN_SYM transactional_lock_mode MODE_SYM opt_transactional_lock_timeout
+        {
+          $$.lock_type=          $2;
+          $$.lock_timeout=       $4;
+          $$.lock_transactional= TRUE;
+        }
         ;
+
+/* Use thr_lock_type here for easier fallback to non-trans locking. */
+transactional_lock_mode:
+        SHARE_SYM       { $$= TL_READ_NO_INSERT; }
+        | EXCLUSIVE_SYM { $$= YYTHD->update_lock_default; }
+        ;
+
+opt_transactional_lock_timeout:
+        /* empty */     { $$= -1; }
+        | NOWAIT_SYM    { $$= 0; }
+        /* | WAIT_SYM opt_lock_timeout_value { $$= $2; } */
+        ;
+
+/*
+  We have a timeout resolution of milliseconds. The WAIT argument is in
+  seconds with decimal fragments for sub-second resolution. E.g. 22.5, 0.015
+*/
+/* opt_lock_timeout_value: */
+        /* empty { $$= -1; } */
+        /* | NUM       { $$= (int) (atof($1.str) * 1000.0 + 0.5); } */
 
 unlock:
 	UNLOCK_SYM

--- 1.71/sql/structs.h	2007-06-16 19:53:19 +02:00
+++ 1.72/sql/structs.h	2007-06-16 19:53:19 +02:00
@@ -98,6 +98,7 @@ typedef struct st_key {
     int  bdb_return_if_eq;
   } handler;
   struct st_table *table;
+  LEX_STRING comment;
 } KEY;
 
 

--- 1.293/sql/table.cc	2007-06-16 19:53:19 +02:00
+++ 1.294/sql/table.cc	2007-06-16 19:53:19 +02:00
@@ -329,7 +329,7 @@ int open_table_def(THD *thd, TABLE_SHARE
   int error, table_type;
   bool error_given;
   File file;
-  uchar head[288], *disk_buff;
+  uchar head[64], *disk_buff;
   char	path[FN_REFLEN];
   MEM_ROOT **root_ptr, *old_root;
   DBUG_ENTER("open_table_def");
@@ -478,6 +478,7 @@ static int open_binary_frm(THD *thd, TAB
   uint extra_rec_buf_length;
   uint i,j;
   bool use_hash;
+  uchar forminfo[288];
   char *keynames, *names, *comment_pos;
   uchar *record;
   uchar *disk_buff, *strpos, *null_flags, *null_pos;
@@ -500,6 +501,9 @@ static int open_binary_frm(THD *thd, TAB
   error= 3;
   if (!(pos=get_form_pos(file,head,(TYPELIB*) 0)))
     goto err;                                   /* purecov: inspected */
+  VOID(my_seek(file,pos,MY_SEEK_SET,MYF(0)));
+  if (my_read(file,(byte*) forminfo,288,MYF(MY_NABP)))
+    goto err;
 
   share->frm_version= head[2];
   /*
@@ -645,6 +649,20 @@ static int open_binary_frm(THD *thd, TAB
   keynames=(char*) key_part;
   strpos+= (strmov(keynames, (char *) strpos) - keynames)+1;
 
+  //reading index comments
+  for (keyinfo= share->key_info, i=0; i < keys; i++, keyinfo++)
+  {
+    if (keyinfo->flags & HA_USES_COMMENT)
+    {
+      keyinfo->comment.length= uint2korr(strpos);
+      keyinfo->comment.str= strmake_root(&share->mem_root, (char*) strpos+2,
+                                         keyinfo->comment.length);
+      strpos+= 2 + keyinfo->comment.length;
+    } 
+    DBUG_ASSERT(test(keyinfo->flags & HA_USES_COMMENT) == 
+               (keyinfo->comment.length > 0));
+  }
+
   share->reclength = uint2korr((head+16));
   if (*(head+26) == 1)
     share->system= 1;				/* one-record-database */
@@ -798,6 +816,7 @@ static int open_binary_frm(THD *thd, TAB
         }
         parser_name.str= (char*) next_chunk;
         parser_name.length= strlen((char*) next_chunk);
+        next_chunk += parser_name.length + 1;
         keyinfo->parser= my_plugin_lock_by_name(NULL, &parser_name,
                                                 MYSQL_FTPARSER_PLUGIN);
         if (! keyinfo->parser)
@@ -808,6 +827,24 @@ static int open_binary_frm(THD *thd, TAB
         }
       }
     }
+    if (forminfo[46] == (uchar)255)
+    {
+      //reading long table comment
+      if (next_chunk + 2 > buff_end)
+      {
+          DBUG_PRINT("error",
+                     ("long table comment is not defined in .frm"));
+          my_free(buff, MYF(0));
+          goto err;
+      }
+      share->comment.length = uint2korr(next_chunk);
+      if (! (share->comment.str= strmake_root(&share->mem_root, next_chunk + 2,                                        share->comment.length)))
+      {
+          my_free(buff, MYF(0));
+          goto err;
+      }
+      next_chunk+= 2 + share->comment.length;
+    }
     my_free(buff, MYF(0));
   }
   share->key_block_size= uint2korr(head+62);
@@ -824,29 +861,30 @@ static int open_binary_frm(THD *thd, TAB
                record_offset, MYF(MY_NABP)))
     goto err;                                   /* purecov: inspected */
 
-  VOID(my_seek(file,pos,MY_SEEK_SET,MYF(0)));
-  if (my_read(file, head,288,MYF(MY_NABP)))
-    goto err;
+  VOID(my_seek(file,pos+288,MY_SEEK_SET,MYF(0)));
 #ifdef HAVE_CRYPTED_FRM
   if (crypted)
   {
-    crypted->decode((char*) head+256,288-256);
-    if (sint2korr(head+284) != 0)		// Should be 0
+    crypted->decode((char*) forminfo+256,288-256);
+    if (sint2korr(forminfo+284) != 0)		// Should be 0
       goto err;                                 // Wrong password
   }
 #endif
 
-  share->fields= uint2korr(head+258);
-  pos= uint2korr(head+260);			/* Length of all screens */
-  n_length= uint2korr(head+268);
-  interval_count= uint2korr(head+270);
-  interval_parts= uint2korr(head+272);
-  int_length= uint2korr(head+274);
-  share->null_fields= uint2korr(head+282);
-  com_length= uint2korr(head+284);
-  share->comment.length=  (int) (head[46]);
-  share->comment.str= strmake_root(&share->mem_root, (char*) head+47,
-                                   share->comment.length);
+  share->fields= uint2korr(forminfo+258);
+  pos= uint2korr(forminfo+260);			/* Length of all screens */
+  n_length= uint2korr(forminfo+268);
+  interval_count= uint2korr(forminfo+270);
+  interval_parts= uint2korr(forminfo+272);
+  int_length= uint2korr(forminfo+274);
+  share->null_fields= uint2korr(forminfo+282);
+  com_length= uint2korr(forminfo+284);
+  if (forminfo[46] != (uchar)255)
+  {
+    share->comment.length=  (int) (forminfo[46]);
+    share->comment.str= strmake_root(&share->mem_root, (char*) forminfo+47,
+                                     share->comment.length);
+  }
 
   DBUG_PRINT("info",("i_count: %d  i_parts: %d  index: %d  n_length: %d  int_length: %d  com_length: %d", interval_count,interval_parts, share->keys,n_length,int_length, com_length));
 
@@ -2182,12 +2220,14 @@ void append_unescaped(String *res, const
 
 File create_frm(THD *thd, const char *name, const char *db,
                 const char *table, uint reclength, uchar *fileinfo,
-  		HA_CREATE_INFO *create_info, uint keys)
+  		HA_CREATE_INFO *create_info, uint keys, KEY *key_info)
 {
   register File file;
   ulong length;
   uchar fill[IO_SIZE];
   int create_flags= O_RDWR | O_TRUNC;
+  ulong key_comment_total_bytes= 0;
+  int i;
 
   if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
     create_flags|= O_EXCL | O_NOFOLLOW;
@@ -2212,7 +2252,14 @@ File create_frm(THD *thd, const char *na
           ha_checktype(thd,ha_legacy_type(create_info->db_type),0,0));
     fileinfo[4]=1;
     int2store(fileinfo+6,IO_SIZE);		/* Next block starts here */
-    key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;
+    for (i= 0; i < keys; i++)
+    {
+      DBUG_ASSERT(test(key_info[i].flags & HA_USES_COMMENT) == 
+                 (key_info[i].comment.length > 0));
+      if (key_info[i].flags & HA_USES_COMMENT)
+        key_comment_total_bytes += 2 + key_info[i].comment.length;
+    }
+    key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16+key_comment_total_bytes;
     length= next_io_size((ulong) (IO_SIZE+key_length+reclength+
                                   create_info->extra_size));
     int4store(fileinfo+10,length);

--- 1.174/sql/table.h	2007-06-16 19:53:19 +02:00
+++ 1.175/sql/table.h	2007-06-16 19:53:19 +02:00
@@ -929,6 +929,9 @@ typedef struct st_table_list
     ... SELECT implementation).
   */
   bool          create;
+  /* For transactional locking. */
+  int           lock_timeout;           /* NOWAIT or WAIT [X]               */
+  bool          lock_transactional;     /* If transactional lock requested. */
 
   enum enum_schema_table_state schema_table_state;
   void calc_md5(char *buffer);
@@ -936,6 +939,10 @@ typedef struct st_table_list
   int view_check_option(THD *thd, bool ignore_failure);
   bool setup_underlying(THD *thd);
   void cleanup_items();
+  /*
+    If you change placeholder(), please check the condition in
+    check_transactional_lock() too.
+  */
   bool placeholder()
   {
     return derived || view || schema_table || create && !table->db_stat ||

--- 1.102/sql/unireg.cc	2007-06-16 19:53:19 +02:00
+++ 1.103/sql/unireg.cc	2007-06-16 19:53:19 +02:00
@@ -149,8 +149,44 @@ bool mysql_create_frm(THD *thd, const ch
       create_info->extra_size+= key_info[i].parser_name->length + 1;
   }
 
+  tmp_len= system_charset_info->cset->charpos(system_charset_info,
+                                              create_info->comment.str,
+                                              create_info->comment.str +
+                                              create_info->comment.length, 
+                                              TABLE_COMMENT_MAXLEN);
+
+  if (tmp_len < create_info->comment.length)
+  {
+    if ((thd->variables.sql_mode &
+         (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
+    {
+      my_error(ER_WRONG_STRING_LENGTH, MYF(0),
+                 create_info->comment.str,"TABLE COMMENT",
+                 (uint) TABLE_COMMENT_MAXLEN);
+      my_free((gptr) screen_buff,MYF(0));
+      DBUG_RETURN(1);
+    }
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_WRONG_STRING_LENGTH, ER(ER_WRONG_STRING_LENGTH),
+                        create_info->comment.str,"TABLE COMMENT",
+                        (uint) TABLE_COMMENT_MAXLEN);
+    create_info->comment.length= tmp_len;
+  }
+
+  //if table comment is larger than 180 bytes, store into extra segment.
+  if (create_info->comment.length > 180)
+  {
+    forminfo[46]=255;
+    create_info->extra_size+= 2 + create_info->comment.length;
+  }
+  else{
+    strmake((char*) forminfo+47, create_info->comment.str ?
+            create_info->comment.str : "", create_info->comment.length);
+    forminfo[46]=(uchar) create_info->comment.length;
+  }
+
   if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo,
-		       create_info, keys)) < 0)
+		       create_info, keys, key_info)) < 0)
   {
     my_free(screen_buff, MYF(0));
     DBUG_RETURN(1);
@@ -169,28 +205,7 @@ bool mysql_create_frm(THD *thd, const ch
 			     (create_info->min_rows == 1) && (keys == 0));
   int2store(fileinfo+28,key_info_length);
 
-  tmp_len= system_charset_info->cset->charpos(system_charset_info,
-                                              create_info->comment.str,
-                                              create_info->comment.str +
-                                              create_info->comment.length, 60);
-  if (tmp_len < create_info->comment.length)
-  {
-    (void) my_snprintf(buff, sizeof(buff), "Too long comment for table '%s'",
-                       table);
-    if ((thd->variables.sql_mode &
-         (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
-    {
-      my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
-      goto err;
-    }
-    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                        ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
-    create_info->comment.length= tmp_len;
-  }
 
-  strmake((char*) forminfo+47, create_info->comment.str ?
-          create_info->comment.str : "", create_info->comment.length);
-  forminfo[46]=(uchar) create_info->comment.length;
 #ifdef WITH_PARTITION_STORAGE_ENGINE
   if (part_info)
   {
@@ -252,6 +267,16 @@ bool mysql_create_frm(THD *thd, const ch
     }
   }
 
+  if (forminfo[46] == (uchar)255)
+  {
+    uchar comment_length_buff[2];
+    int2store(comment_length_buff,create_info->comment.length);
+    if (my_write(file, (byte*) comment_length_buff, 2, MYF(MY_NABP)) ||
+        my_write(file, (byte*) create_info->comment.str,
+                  create_info->comment.length, MYF(MY_NABP)))
+      goto err;
+  }
+
   VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
   if (my_write(file, forminfo, 288, MYF_RW) ||
       my_write(file, screen_buff, info_length, MYF_RW) ||
@@ -500,6 +525,16 @@ static uint pack_keys(uchar *keybuff, ui
   }
   *(pos++)=0;
 
+  for (key=keyinfo,end=keyinfo+key_count ; key != end ; key++)
+  {
+    if (key->flags & HA_USES_COMMENT)
+    {
+      int2store(pos, key->comment.length);
+      uchar *tmp= (uchar*)strnmov((char*) pos+2,key->comment.str,key->comment.length);
+      pos= tmp;
+    }
+  }
+
   if (key_count > 127 || key_parts > 127)
   {
     keybuff[0]= (key_count & 0x7f) | 0x80;
@@ -552,20 +587,22 @@ static bool pack_header(uchar *forminfo,
                                                      field->comment.str,
                                                      field->comment.str +
                                                      field->comment.length,
-                                                     255);
+                                                     COLUMN_COMMENT_MAXLEN);
+
     if (tmp_len < field->comment.length)
     {
-      char buff[128];
-      (void) my_snprintf(buff,sizeof(buff), "Too long comment for field '%s'",
-                         field->field_name);
       if ((current_thd->variables.sql_mode &
 	   (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
       {
-        my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
+        my_error(ER_WRONG_STRING_LENGTH, MYF(0),
+                   field->comment.str,"COLUMN COMMENT",
+                   (uint) COLUMN_COMMENT_MAXLEN);
 	DBUG_RETURN(1);
       }
       push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                          ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+                          ER_WRONG_STRING_LENGTH, ER(ER_WRONG_STRING_LENGTH),
+                          field->comment.str,"COLUMN COMMENT",
+                          (uint) COLUMN_COMMENT_MAXLEN);
       field->comment.length= tmp_len;
     }
 

--- 1.145/sql/share/errmsg.txt	2007-06-16 19:53:19 +02:00
+++ 1.146/sql/share/errmsg.txt	2007-06-16 19:53:19 +02:00
@@ -6072,3 +6072,5 @@ ER_NO_AUTO_CONVERT_LOCK_TRANSACTION
         eng "Cannot convert to non-transactional lock in an active transaction on '%-.64s'"
         ger "In einer laufenden Transaktion ist die Umwandlung zu nicht-transaktionalen Sperren verboten. Betrifft '%-.64s'"
 
+ER_ADMIN_WRONG_MRG_TABLE
+	eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist"

--- 1.39/mysql-test/r/rpl_sp.result	2007-06-16 19:53:19 +02:00
+++ 1.40/mysql-test/r/rpl_sp.result	2007-06-16 19:53:19 +02:00
@@ -107,7 +107,7 @@ call foo4();
 ERROR 23000: Duplicate entry '20' for key 'a'
 show warnings;
 Level	Code	Message
-Error	1582	Duplicate entry '20' for key 'a'
+Error	1062	Duplicate entry '20' for key 'a'
 select * from t2;
 a
 20
@@ -238,7 +238,7 @@ return 10;
 end|
 do fn1(100);
 Warnings:
-Error	1582	Duplicate entry '100' for key 'a'
+Error	1062	Duplicate entry '100' for key 'a'
 select fn1(20);
 ERROR 23000: Duplicate entry '20' for key 'a'
 select * from t2;

--- 1.33/mysql-test/t/rpl_sp.test	2007-06-16 19:53:19 +02:00
+++ 1.34/mysql-test/t/rpl_sp.test	2007-06-16 19:53:19 +02:00
@@ -148,7 +148,7 @@ create procedure foo4()
 
 delimiter ;|
 
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 call foo4();
 show warnings;
 
@@ -300,7 +300,7 @@ delimiter ;|
 
 do fn1(100);
 
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 select fn1(20);
 
 select * from t2;

--- 1.305/mysql-test/mysql-test-run.pl	2007-06-16 19:53:19 +02:00
+++ 1.306/mysql-test/mysql-test-run.pl	2007-06-16 19:53:19 +02:00
@@ -104,8 +104,6 @@ our $glob_mysql_bench_dir=        undef;
 our $glob_hostname=               undef;
 our $glob_scriptname=             undef;
 our $glob_timers=                 undef;
-our $glob_use_running_ndbcluster= 0;
-our $glob_use_running_ndbcluster_slave= 0;
 our $glob_use_embedded_server=    0;
 our @glob_test_mode;
 
@@ -772,7 +770,7 @@ sub command_line_setup () {
   # Find out type of logging that are being used
   # --------------------------------------------------------------------------
   # NOTE if the default binlog format is changed, this has to be changed
-  $used_binlog_format= "stmt";
+  $used_binlog_format= "statement";
   if (!$opt_extern && $mysql_version_id >= 50100 )
   {
     $used_binlog_format= "mixed"; # Default value for binlog format
@@ -913,6 +911,9 @@ sub command_line_setup () {
     $opt_skip_ndbcluster= 1;       # Turn off use of NDB cluster
     $opt_skip_ssl= 1;              # Turn off use of SSL
 
+    # Turn off use of bin log
+    push(@opt_extra_mysqld_opt, "--skip-log-bin");
+
     if ( $opt_extern )
     {
       mtr_error("Can't use --extern with --embedded-server");
@@ -929,40 +930,6 @@ sub command_line_setup () {
   }
 
   # --------------------------------------------------------------------------
-  # Ndb cluster flags
-  # --------------------------------------------------------------------------
-
-  if ( $opt_ndbconnectstring )
-  {
-    $glob_use_running_ndbcluster= 1;
-    mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster")
-      if $opt_skip_ndbcluster;
-    mtr_error("Can't specify --ndb-connectstring and --ndbcluster-port")
-      if $opt_ndbcluster_port;
-  }
-  else
-  {
-    # Set default connect string
-    $opt_ndbconnectstring= "host=localhost:$opt_ndbcluster_port";
-  }
-
-  if ( $opt_ndbconnectstring_slave )
-  {
-      $glob_use_running_ndbcluster_slave= 1;
-      mtr_error("Can't specify ndb-connectstring_slave and " .
-		"--skip-ndbcluster-slave")
-	if $opt_skip_ndbcluster;
-      mtr_error("Can't specify --ndb-connectstring-slave and " .
-		"--ndbcluster-port-slave")
-	if $opt_ndbcluster_port_slave;
-  }
-  else
-  {
-    # Set default connect string
-    $opt_ndbconnectstring_slave= "host=localhost:$opt_ndbcluster_port_slave";
-  }
-
-  # --------------------------------------------------------------------------
   # Bench flags
   # --------------------------------------------------------------------------
   if ( $opt_small_bench )
@@ -1205,7 +1172,7 @@ sub command_line_setup () {
    nodes           => 2,
    port            => "$opt_ndbcluster_port",
    data_dir        => "$data_dir",
-   connect_string  => "$opt_ndbconnectstring",
+   connect_string  => "host=localhost:$opt_ndbcluster_port",
    path_pid        => "$data_dir/ndb_3.pid", # Nodes + 1
    pid             => 0, # pid of ndb_mgmd
    installed_ok    => 0,
@@ -1218,7 +1185,7 @@ sub command_line_setup () {
    nodes           => 1,
    port            => "$opt_ndbcluster_port_slave",
    data_dir        => "$data_dir",
-   connect_string  => "$opt_ndbconnectstring_slave",
+   connect_string  => "host=localhost:$opt_ndbcluster_port_slave",
    path_pid        => "$data_dir/ndb_2.pid", # Nodes + 1
    pid             => 0, # pid of ndb_mgmd
    installed_ok    => 0,
@@ -1240,6 +1207,9 @@ sub command_line_setup () {
     }
   }
 
+  # --------------------------------------------------------------------------
+  # extern
+  # --------------------------------------------------------------------------
   if ( $opt_extern )
   {
     # Turn off features not supported when running with extern server
@@ -1256,6 +1226,38 @@ sub command_line_setup () {
       if $opt_socket;
   }
 
+
+  # --------------------------------------------------------------------------
+  # ndbconnectstring and ndbconnectstring_slave
+  # --------------------------------------------------------------------------
+  if ( $opt_ndbconnectstring )
+  {
+    # ndbconnectstring was supplied by user, the tests shoudl be run
+    # against an already started cluster, change settings
+    my $cluster= $clusters->[0]; # Master cluster
+    $cluster->{'connect_string'}= $opt_ndbconnectstring;
+    $cluster->{'use_running'}= 1;
+
+    mtr_error("Can't specify --ndb-connectstring and --skip-ndbcluster")
+      if $opt_skip_ndbcluster;
+  }
+  $ENV{'NDB_CONNECTSTRING'}= $clusters->[0]->{'connect_string'};
+
+
+  if ( $opt_ndbconnectstring_slave )
+  {
+    # ndbconnectstring-slave was supplied by user, the tests should be run
+    # agains an already started slave cluster, change settings
+    my $cluster= $clusters->[1]; # Slave cluster
+    $cluster->{'connect_string'}= $opt_ndbconnectstring_slave;
+    $cluster->{'use_running'}= 1;
+
+    mtr_error("Can't specify ndb-connectstring_slave and " .
+	      "--skip-ndbcluster-slave")
+      if $opt_skip_ndbcluster_slave;
+  }
+
+
   $path_timefile=  "$opt_vardir/log/mysqltest-time";
   $path_mysqltest_log=  "$opt_vardir/log/mysqltest.log";
   $path_current_test_log= "$opt_vardir/log/current_test";
@@ -1795,6 +1797,17 @@ sub environment_setup () {
 				  split(':', $ENV{'DYLD_LIBRARY_PATH'}) : ());
   mtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
 
+  # The environment variable used for shared libs on AIX
+  $ENV{'SHLIB_PATH'}= join(":", @ld_library_paths,
+                           $ENV{'SHLIB_PATH'} ?
+                           split(':', $ENV{'SHLIB_PATH'}) : ());
+  mtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
+
+  # The environment variable used for shared libs on hp-ux
+  $ENV{'LIBPATH'}= join(":", @ld_library_paths,
+                        $ENV{'LIBPATH'} ?
+                        split(':', $ENV{'LIBPATH'}) : ());
+  mtr_debug("LIBPATH: $ENV{'LIBPATH'}");
 
   # --------------------------------------------------------------------------
   # Also command lines in .opt files may contain env vars
@@ -1803,6 +1816,18 @@ sub environment_setup () {
   $ENV{'CHARSETSDIR'}=              $path_charsetsdir;
   $ENV{'UMASK'}=              "0660"; # The octal *string*
   $ENV{'UMASK_DIR'}=          "0770"; # The octal *string*
+  
+  #
+  # MySQL tests can produce output in various character sets
+  # (especially, ctype_xxx.test). To avoid confusing Perl
+  # with output which is incompatible with the current locale
+  # settings, we reset the current values of LC_ALL and LC_CTYPE to "C".
+  # For details, please see
+  # Bug#27636 tests fails if LC_* variables set to *_*.UTF-8
+  #
+  $ENV{'LC_ALL'}=             "C";
+  $ENV{'LC_CTYPE'}=           "C";
+  
   $ENV{'LC_COLLATE'}=         "C";
   $ENV{'USE_RUNNING_SERVER'}= $opt_extern;
   $ENV{'MYSQL_TEST_DIR'}=     $glob_mysql_test_dir;
@@ -1842,7 +1867,6 @@ sub environment_setup () {
     $ENV{'NDB_DATA_DIR'}=             $clusters->[0]->{'data_dir'};
     $ENV{'NDB_TOOLS_DIR'}=            $path_ndb_tools_dir;
     $ENV{'NDB_TOOLS_OUTPUT'}=         $path_ndb_testrun_log;
-    $ENV{'NDB_CONNECTSTRING'}=        $opt_ndbconnectstring;
 
     if ( $mysql_version_id >= 50000 )
     {
@@ -2321,16 +2345,23 @@ sub  check_running_as_root () {
     close FILE;
   }
 
-  chmod(oct("0755"), $test_file);
-  unlink($test_file);
+  # Some filesystems( for example CIFS) allows reading a file
+  # although mode was set to 0000, but in that case a stat on
+  # the file will not return 0000
+  my $file_mode= (stat($test_file))[2] & 07777;
 
   $ENV{'MYSQL_TEST_ROOT'}= "NO";
-  if ($result eq "MySQL")
+  mtr_verbose("result: $result, file_mode: $file_mode");
+  if ($result eq "MySQL" && $file_mode == 0)
   {
     mtr_warning("running this script as _root_ will cause some " .
                 "tests to be skipped");
     $ENV{'MYSQL_TEST_ROOT'}= "YES";
   }
+
+  chmod(oct("0755"), $test_file);
+  unlink($test_file);
+
 }
 
 
@@ -2667,7 +2698,7 @@ sub ndbcluster_start ($$) {
 
   mtr_verbose("ndbcluster_start '$cluster->{'name'}'");
 
-  if ( $glob_use_running_ndbcluster )
+  if ( $cluster->{'use_running'} )
   {
     return 0;
   }
@@ -2884,30 +2915,34 @@ sub mysql_install_db () {
 
   my $cluster_started_ok= 1; # Assume it can be started
 
-  if ($opt_skip_ndbcluster || $glob_use_running_ndbcluster ||
-      $clusters->[0]->{executable_setup_failed})
+  my $cluster= $clusters->[0]; # Master cluster
+  if ($opt_skip_ndbcluster ||
+      $cluster->{'use_running'} ||
+      $cluster->{executable_setup_failed})
   {
     # Don't install master cluster
   }
-  elsif (ndbcluster_start_install($clusters->[0]))
+  elsif (ndbcluster_start_install($cluster))
   {
-    mtr_warning("Failed to start install of $clusters->[0]->{name}");
+    mtr_warning("Failed to start install of $cluster->{name}");
     $cluster_started_ok= 0;
   }
 
+  $cluster= $clusters->[1]; # Slave cluster
   if ($max_slave_num == 0 ||
-      $opt_skip_ndbcluster_slave || $glob_use_running_ndbcluster_slave ||
-      $clusters->[1]->{executable_setup_failed})
+      $opt_skip_ndbcluster_slave ||
+      $cluster->{'use_running'} ||
+      $cluster->{executable_setup_failed})
   {
     # Don't install slave cluster
   }
-  elsif (ndbcluster_start_install($clusters->[1]))
+  elsif (ndbcluster_start_install($cluster))
   {
-    mtr_warning("Failed to start install of $clusters->[1]->{name}");
+    mtr_warning("Failed to start install of $cluster->{name}");
     $cluster_started_ok= 0;
   }
 
-  foreach my $cluster (@{$clusters})
+  foreach $cluster (@{$clusters})
   {
 
     next if !$cluster->{'pid'};
@@ -3182,9 +3217,16 @@ sub run_testcase_check_skip_test($)
   {
     foreach my $cluster (@{$clusters})
     {
+      # Slave cluster is skipped and thus not
+      # installed, no need to perform checks
       last if ($opt_skip_ndbcluster_slave and
 	       $cluster->{'name'} eq 'Slave');
 
+      # Using running cluster - no need
+      # to check if test should be skipped
+      # will be done by test itself
+      last if ($cluster->{'use_running'});
+
       # If test needs this cluster, check binaries was found ok
       if ( $cluster->{'executable_setup_failed'} )
       {
@@ -3637,6 +3679,9 @@ sub do_before_start_master ($) {
 
   # FIXME what about second master.....
 
+  # Don't delete anything if starting dirty
+  return if ($opt_start_dirty);
+
   foreach my $bin ( glob("$opt_vardir/log/master*-bin*") )
   {
     unlink($bin);
@@ -3659,6 +3704,9 @@ sub do_before_start_slave ($) {
   my $tname= $tinfo->{'name'};
   my $init_script= $tinfo->{'master_sh'};
 
+  # Don't delete anything if starting dirty
+  return if ($opt_start_dirty);
+
   foreach my $bin ( glob("$opt_vardir/log/slave*-bin*") )
   {
     unlink($bin);
@@ -3768,8 +3816,7 @@ sub mysqld_arguments ($$$$) {
 	      "%s--log-slow-queries=%s-slow.log", $prefix, $log_base_path);
 
   # Check if "extra_opt" contains --skip-log-bin
-  my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt);
-
+  my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt, @opt_extra_mysqld_opt);
   if ( $mysqld->{'type'} eq 'master' )
   {
     if (! ($opt_skip_master_binlog || $skip_binlog) )
@@ -3792,12 +3839,8 @@ sub mysqld_arguments ($$$$) {
     }
 
     my $cluster= $clusters->[$mysqld->{'cluster'}];
-    if ( $opt_skip_ndbcluster ||
-	 !$cluster->{'pid'})
-    {
-      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
-    }
-    else
+    if ( $cluster->{'pid'} ||           # Cluster is started
+	 $cluster->{'use_running'} )    # Using running cluster
     {
       mtr_add_arg($args, "%s--ndbcluster", $prefix);
       mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
@@ -3807,6 +3850,10 @@ sub mysqld_arguments ($$$$) {
 	mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
       }
     }
+    else
+    {
+      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
+    }
   }
   else
   {
@@ -3849,28 +3896,38 @@ sub mysqld_arguments ($$$$) {
     }
     else
     {
+      if ($mysql_version_id < 50200)
+      {
+        mtr_add_arg($args, "%s--master-user=root", $prefix);
+        mtr_add_arg($args, "%s--master-connect-retry=1", $prefix);
+        mtr_add_arg($args, "%s--master-host=127.0.0.1", $prefix);
+        mtr_add_arg($args, "%s--master-password=", $prefix);
+        mtr_add_arg($args, "%s--master-port=%d", $prefix,
+    	            $master->[0]->{'port'}); # First master
+      }
       my $slave_server_id=  2 + $idx;
       my $slave_rpl_rank= $slave_server_id;
       mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
       mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
     }
 
-    if ( $opt_skip_ndbcluster_slave ||
-         $mysqld->{'cluster'} == -1 ||
-         !$clusters->[$mysqld->{'cluster'}]->{'pid'} )
-    {
-      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
-    }
-    else
+    my $cluster= $clusters->[$mysqld->{'cluster'}];
+    if ( $cluster->{'pid'} ||         # Slave cluster is started
+	 $cluster->{'use_running'} )  # Using running slave cluster
     {
       mtr_add_arg($args, "%s--ndbcluster", $prefix);
       mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
-                  $clusters->[$mysqld->{'cluster'}]->{'connect_string'});
+		  $cluster->{'connect_string'});
       if ( $mysql_version_id >= 50100 )
       {
 	mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
       }
     }
+    else
+    {
+      mtr_add_arg($args, "%s--loose-skip-ndbcluster", $prefix);
+    }
+
   } # end slave
 
   if ( $opt_debug )
@@ -4419,7 +4476,8 @@ sub run_testcase_start_servers($) {
 
     }
 
-    if ( $clusters->[0]->{'pid'} and ! $master->[1]->{'pid'} and
+    if ( $clusters->[0]->{'pid'} || $clusters->[0]->{'use_running'}
+	 and ! $master->[1]->{'pid'} and
 	 $tinfo->{'master_num'} > 1 )
     {
       # Test needs cluster, start an extra mysqld connected to cluster

--- 1.7/mysql-test/r/rpl_row_until.result	2007-06-16 19:53:19 +02:00
+++ 1.8/mysql-test/r/rpl_row_until.result	2007-06-16 19:53:19 +02:00
@@ -19,7 +19,7 @@ n
 2
 3
 4
-show slave status;
+SHOW SLAVE STATUS;;
 Slave_IO_State	#
 Master_Host	127.0.0.1
 Master_User	root
@@ -27,7 +27,7 @@ Master_Port	MASTER_MYPORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
 Read_Master_Log_Pos	744
-Relay_Log_File	slave-relay-bin.000003
+Relay_Log_File	slave-relay-bin.000004
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
 Slave_IO_Running	#
@@ -61,7 +61,7 @@ n
 2
 3
 4
-show slave status;
+SHOW SLAVE STATUS;;
 Slave_IO_State	#
 Master_Host	127.0.0.1
 Master_User	root
@@ -69,7 +69,7 @@ Master_Port	MASTER_MYPORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
 Read_Master_Log_Pos	744
-Relay_Log_File	slave-relay-bin.000003
+Relay_Log_File	slave-relay-bin.000004
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
 Slave_IO_Running	#
@@ -96,12 +96,11 @@ Master_SSL_Cipher	
 Master_SSL_Key	
 Seconds_Behind_Master	#
 Master_SSL_Verify_Server_Cert	No
-start slave until relay_log_file='slave-relay-bin.000003', relay_log_pos=728;
 select * from t2;
 n
 1
 2
-show slave status;
+SHOW SLAVE STATUS;;
 Slave_IO_State	#
 Master_Host	127.0.0.1
 Master_User	root
@@ -109,7 +108,7 @@ Master_Port	MASTER_MYPORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
 Read_Master_Log_Pos	744
-Relay_Log_File	slave-relay-bin.000003
+Relay_Log_File	slave-relay-bin.000004
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
 Slave_IO_Running	#
@@ -126,7 +125,7 @@ Skip_Counter	0
 Exec_Master_Log_Pos	590
 Relay_Log_Space	#
 Until_Condition	Relay
-Until_Log_File	slave-relay-bin.000003
+Until_Log_File	slave-relay-bin.000004
 Until_Log_Pos	728
 Master_SSL_Allowed	No
 Master_SSL_CA_File	
@@ -139,7 +138,7 @@ Master_SSL_Verify_Server_Cert	No
 start slave;
 stop slave;
 start slave until master_log_file='master-bin.000001', master_log_pos=740;
-show slave status;
+SHOW SLAVE STATUS;;
 Slave_IO_State	#
 Master_Host	127.0.0.1
 Master_User	root
@@ -147,7 +146,7 @@ Master_Port	MASTER_MYPORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
 Read_Master_Log_Pos	744
-Relay_Log_File	slave-relay-bin.000003
+Relay_Log_File	slave-relay-bin.000004
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
 Slave_IO_Running	Yes

--- 1.4/mysql-test/t/rpl_row_until.test	2007-06-16 19:53:19 +02:00
+++ 1.5/mysql-test/t/rpl_row_until.test	2007-06-16 19:53:19 +02:00
@@ -33,7 +33,7 @@ wait_for_slave_to_stop;
 select * from t1;
 --replace_result $MASTER_MYPORT MASTER_MYPORT
 --replace_column 1 # 9 # 11 # 23 # 33 #
-query_vertical show slave status;
+--query_vertical SHOW SLAVE STATUS;
 
 # this should fail right after start
 start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
@@ -43,7 +43,7 @@ sleep 2;
 wait_for_slave_to_stop;
 --replace_result $MASTER_MYPORT MASTER_MYPORT
 --replace_column 1 # 9 # 11 # 23 # 33 #
-query_vertical show slave status;
+--query_vertical SHOW SLAVE STATUS;
 
 # try replicate all up to and not including the second insert to t2;
 start slave until relay_log_file='slave-relay-bin.000003', relay_log_pos=728;
@@ -52,7 +52,7 @@ wait_for_slave_to_stop;
 select * from t2;
 --replace_result $MASTER_MYPORT MASTER_MYPORT
 --replace_column 1 # 9 # 11 # 23 # 33 #
-query_vertical show slave status;
+--query_vertical SHOW SLAVE STATUS;
 
 # clean up
 start slave;
@@ -69,7 +69,7 @@ wait_for_slave_to_stop;
 # here the sql slave thread should be stopped
 --replace_result $MASTER_MYPORT MASTER_MYPORT bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
 --replace_column 1 # 9 # 23 # 33 #
-query_vertical show slave status;
+--query_vertical SHOW SLAVE STATUS;
 
 #testing various error conditions
 --error 1277

--- 1.112/mysql-test/r/show_check.result	2007-06-16 19:53:19 +02:00
+++ 1.113/mysql-test/r/show_check.result	2007-06-16 19:53:19 +02:00
@@ -747,4 +747,6 @@ Tables_in_test	Table_type
 été	BASE TABLE
 drop table `été`;
 set names latin1;
+show columns from `#mysql50#????????`;
+Got one of the listed errors
 End of 5.1 tests

--- 1.77/mysql-test/t/show_check.test	2007-06-16 19:53:19 +02:00
+++ 1.78/mysql-test/t/show_check.test	2007-06-16 19:53:19 +02:00
@@ -30,7 +30,7 @@ check table t1 changed;
 check table t1 medium;
 check table t1 extended;
 show index from t1;
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 insert into t1 values (5,5,5);
 optimize table t1;
 optimize table t1;
@@ -587,5 +587,11 @@ create table `été` (field1 int);
 show full tables;
 drop table `été`;
 set names latin1;
+
+#
+# Bug#26402 Server crashes with old-style named table
+#
+--error ER_NO_SUCH_TABLE,ER_FILE_NOT_FOUND
+show columns from `#mysql50#????????`;
 
 --echo End of 5.1 tests

--- 1.140/storage/innobase/handler/ha_innodb.h	2007-06-16 19:53:19 +02:00
+++ 1.141/storage/innobase/handler/ha_innodb.h	2007-06-16 19:53:19 +02:00
@@ -142,6 +142,22 @@ class ha_innobase: public handler
 	int discard_or_import_tablespace(my_bool discard);
 	int extra(enum ha_extra_function operation);
         int reset();
+        int lock_table(THD *thd, int lock_type, int lock_timeout)
+        {
+          /*
+            Preliminarily call the pre-existing internal method for
+            transactional locking and ignore non-transactional locks.
+          */
+          if (!lock_timeout)
+          {
+            /* Preliminarily show both possible errors for NOWAIT. */
+            if (lock_type == F_WRLCK)
+              return HA_ERR_UNSUPPORTED;
+            else
+              return HA_ERR_LOCK_WAIT_TIMEOUT;
+          }
+          return transactional_table_lock(thd, lock_type);
+        }
 	int external_lock(THD *thd, int lock_type);
 	int transactional_table_lock(THD *thd, int lock_type);
 	int start_stmt(THD *thd, thr_lock_type lock_type);

--- 1.239/sql/set_var.cc	2007-06-16 19:53:19 +02:00
+++ 1.240/sql/set_var.cc	2007-06-16 19:53:19 +02:00
@@ -240,9 +240,6 @@ static sys_var_key_cache_long  sys_key_c
 							      param_age_threshold));
 static sys_var_bool_ptr	sys_local_infile(&vars, "local_infile",
 					 &opt_local_infile);
-static sys_var_trust_routine_creators
-sys_trust_routine_creators(&vars, "log_bin_trust_routine_creators",
-                           &trust_function_creators);
 static sys_var_bool_ptr       
 sys_trust_function_creators(&vars, "log_bin_trust_function_creators",
                             &trust_function_creators);
@@ -432,8 +429,6 @@ sys_updatable_views_with_limit(&vars, "u
                                &SV::updatable_views_with_limit,
                                &updatable_views_with_limit_typelib);
 
-static sys_var_thd_table_type  sys_table_type(&vars, "table_type",
-				       &SV::table_plugin);
 static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
 				       &SV::table_plugin);
 static sys_var_bool_ptr	sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
@@ -3289,24 +3284,6 @@ bool sys_var_thd_storage_engine::update(
   return 0;
 }
 
-void sys_var_thd_table_type::warn_deprecated(THD *thd)
-{
-  WARN_DEPRECATED(thd, "5.2", "table_type", "'storage_engine'");
-}
-
-void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type)
-{
-  warn_deprecated(thd);
-  sys_var_thd_storage_engine::set_default(thd, type);
-}
-
-bool sys_var_thd_table_type::update(THD *thd, set_var *var)
-{
-  warn_deprecated(thd);
-  return sys_var_thd_storage_engine::update(thd, var);
-}
-
-
 /****************************************************************************
  Functions to handle sql_mode
 ****************************************************************************/
@@ -3548,24 +3525,6 @@ bool process_key_caches(int (* func) (co
   return 0;
 }
 
-
-void sys_var_trust_routine_creators::warn_deprecated(THD *thd)
-{
-  WARN_DEPRECATED(thd, "5.2", "log_bin_trust_routine_creators",
-                      "'log_bin_trust_function_creators'");
-}
-
-void sys_var_trust_routine_creators::set_default(THD *thd, enum_var_type type)
-{
-  warn_deprecated(thd);
-  sys_var_bool_ptr::set_default(thd, type);
-}
-
-bool sys_var_trust_routine_creators::update(THD *thd, set_var *var)
-{
-  warn_deprecated(thd);
-  return sys_var_bool_ptr::update(thd, var);
-}
 
 bool sys_var_opt_readonly::update(THD *thd, set_var *var)
 {

--- 1.107/sql/set_var.h	2007-06-16 19:53:19 +02:00
+++ 1.108/sql/set_var.h	2007-06-16 19:53:19 +02:00
@@ -36,7 +36,7 @@ typedef int (*sys_check_func)(THD *,  se
 typedef bool (*sys_update_func)(THD *, set_var *);
 typedef void (*sys_after_update_func)(THD *,enum_var_type);
 typedef void (*sys_set_default_func)(THD *, enum_var_type);
-typedef byte *(*sys_value_ptr_func)(THD *thd);
+typedef uchar *(*sys_value_ptr_func)(THD *thd);
 
 struct sys_var_chain
 {
@@ -73,7 +73,7 @@ public:
   virtual bool update(THD *thd, set_var *var)=0;
   virtual void set_default(THD *thd_arg, enum_var_type type) {}
   virtual SHOW_TYPE show_type() { return SHOW_UNDEF; }
-  virtual byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  virtual uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
   { return 0; }
   virtual bool check_type(enum_var_type type)
   { return type != OPT_GLOBAL; }		/* Error if not GLOBAL */
@@ -123,8 +123,8 @@ public:
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_LONG; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
-  { return (byte*) value; }
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  { return (uchar*) value; }
 };
 
 
@@ -154,8 +154,8 @@ public:
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_LONGLONG; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
-  { return (byte*) value; }
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  { return (uchar*) value; }
 };
 
 
@@ -173,8 +173,8 @@ public:
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
-  { return (byte*) value; }
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  { return (uchar*) value; }
   bool check_update_type(Item_result type) { return 0; }
 };
 
@@ -216,8 +216,8 @@ public:
     (*set_default_func)(thd, type);
   }
   SHOW_TYPE show_type() { return SHOW_CHAR; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
-  { return (byte*) value; }
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  { return (uchar*) value; }
   bool check_update_type(Item_result type)
   {
     return type != STRING_RESULT;		/* Only accept strings */
@@ -242,9 +242,9 @@ public:
     return 1;
   }
   SHOW_TYPE show_type() { return SHOW_CHAR; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
   {
-    return (byte*) value;
+    return (uchar*) value;
   }
   bool check_update_type(Item_result type)
   {
@@ -271,9 +271,9 @@ public:
     return 1;
   }
   SHOW_TYPE show_type() { return SHOW_CHAR; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
   {
-    return (byte*) *value;
+    return (uchar*) *value;
   }
   bool check_update_type(Item_result type)
   {
@@ -299,7 +299,7 @@ public:
   }
   bool update(THD *thd, set_var *var);
   SHOW_TYPE show_type() { return SHOW_CHAR; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   bool check_update_type(Item_result type) { return 0; }
 };
 
@@ -335,7 +335,7 @@ public:
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_LONG; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
 
@@ -355,7 +355,7 @@ public:
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
 
@@ -377,7 +377,7 @@ public:
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_LONGLONG; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   bool check_default(enum_var_type type)
   {
     return type == OPT_GLOBAL && !option_limits;
@@ -403,7 +403,7 @@ public:
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   bool check(THD *thd, set_var *var)
   {
     return check_enum(thd, var, &bool_typelib);
@@ -446,7 +446,7 @@ public:
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_CHAR; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   bool check_update_type(Item_result type) { return 0; }
 };
 
@@ -466,7 +466,7 @@ public:
     return check_set(thd, var, enum_names);
   }
   void set_default(THD *thd, enum_var_type type);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode,
                                            LEX_STRING *rep);
 };
@@ -489,7 +489,7 @@ public:
   }
   void set_default(THD *thd, enum_var_type type);
   bool update(THD *thd, set_var *var);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
 class sys_var_thd_bit :public sys_var_thd
@@ -510,7 +510,7 @@ public:
   bool check_update_type(Item_result type) { return 0; }
   bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
   SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
 class sys_var_thd_dbug :public sys_var_thd
@@ -524,7 +524,7 @@ public:
   SHOW_TYPE show_type() { return SHOW_CHAR; }
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type) { DBUG_POP(); }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b);
 };
 
 
@@ -542,7 +542,7 @@ public:
   bool check_type(enum_var_type type)    { return type == OPT_GLOBAL; }
   bool check_default(enum_var_type type) { return 0; }
   SHOW_TYPE show_type() { return SHOW_LONG; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
 
@@ -555,7 +555,7 @@ public:
   bool update(THD *thd, set_var *var);
   bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
   SHOW_TYPE show_type() { return SHOW_LONGLONG; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
 
@@ -568,7 +568,7 @@ public:
   bool update(THD *thd, set_var *var);
   bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
   SHOW_TYPE show_type() { return SHOW_LONGLONG; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
 
@@ -632,23 +632,22 @@ public:
   }
   bool check_default(enum_var_type type) { return 0; }
   bool update(THD *thd, set_var *var);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   virtual void set_default(THD *thd, enum_var_type type)= 0;
   virtual CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
 };
 
-
 class sys_var_character_set_sv :public sys_var_character_set
 {
   CHARSET_INFO *SV::*offset;
   CHARSET_INFO **global_default;
 public:
   sys_var_character_set_sv(sys_var_chain *chain, const char *name_arg,
-                            CHARSET_INFO *SV::*offset_arg,
-                            CHARSET_INFO **global_default_arg,
-                            bool is_nullable= 0)
+			   CHARSET_INFO *SV::*offset_arg,
+			   CHARSET_INFO **global_default_arg,
+			   bool is_nullable= 0)
     : sys_var_character_set(name_arg, is_nullable),
-      offset(offset_arg), global_default(global_default_arg)
+    offset(offset_arg), global_default(global_default_arg)
   { chain_sys_var(chain); }
   void set_default(THD *thd, enum_var_type type);
   CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
@@ -671,16 +670,16 @@ class sys_var_collation_sv :public sys_v
   CHARSET_INFO **global_default;
 public:
   sys_var_collation_sv(sys_var_chain *chain, const char *name_arg,
-                               CHARSET_INFO *SV::*offset_arg,
-                               CHARSET_INFO **global_default_arg)
+		       CHARSET_INFO *SV::*offset_arg,
+		       CHARSET_INFO **global_default_arg)
     :sys_var_collation(name_arg),
-     offset(offset_arg), global_default(global_default_arg)
+    offset(offset_arg), global_default(global_default_arg)
   {
     chain_sys_var(chain);
   }
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
 
@@ -693,7 +692,7 @@ public:
                           size_t offset_arg)
     :sys_var(name_arg), offset(offset_arg)
   { chain_sys_var(chain); }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   bool check_default(enum_var_type type) { return 1; }
   bool is_struct() { return 1; }
 };
@@ -742,7 +741,7 @@ public:
   bool check(THD *thd, set_var *var);
   bool update(THD *thd, set_var *var);
   void update2(THD *thd, enum_var_type type, DATE_TIME_FORMAT *new_value);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   void set_default(THD *thd, enum_var_type type);
 };
 
@@ -773,7 +772,7 @@ public:
     return check_set(thd, var, enum_names);
   }
   bool update(THD *thd, set_var *var);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   bool check_update_type(Item_result type) { return 0; }
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_CHAR; }
@@ -798,7 +797,7 @@ public:
   bool check_default(enum_var_type type) { return 1; }
   bool check_type(enum_var_type type) { return type != var_type; }
   bool check_update_type(Item_result type) { return 1; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
   {
     return (*value_ptr_func)(thd);
   }
@@ -815,9 +814,9 @@ public:
   sys_var_have_option(sys_var_chain *chain, const char *variable_name):
     sys_var(variable_name)
   { chain_sys_var(chain); }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
   {
-    return (byte*) show_comp_option_name[get_option()];
+    return (uchar*) show_comp_option_name[get_option()];
   }
   bool update(THD *thd, set_var *var) { return 1; }
   bool check_default(enum_var_type type) { return 1; }
@@ -878,7 +877,7 @@ public:
   }
   bool check_default(enum_var_type type) { return 0; }
   bool update(THD *thd, set_var *var);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   virtual void set_default(THD *thd, enum_var_type type);
 };
 
@@ -897,9 +896,23 @@ public:
   }
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE show_type() { return SHOW_INT; }
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
+class sys_var_trust_routine_creators :public sys_var_bool_ptr
+{
+  /* We need a derived class only to have a warn_deprecated() */
+public:
+  sys_var_trust_routine_creators(sys_var_chain *chain,
+                                 const char *name_arg, my_bool *value_arg) :
+    sys_var_bool_ptr(chain, name_arg, value_arg) {};
+  void warn_deprecated(THD *thd);
+  void set_default(THD *thd, enum_var_type type);
+  bool update(THD *thd, set_var *var);
+};
+
+
+
 /**
   Handler for setting the system variable --read-only.
 */
@@ -934,7 +947,7 @@ public:
   }
   bool check_default(enum_var_type type) { return 0; }
   bool update(THD *thd, set_var *var);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   virtual void set_default(THD *thd, enum_var_type type);
 };
 
@@ -946,7 +959,7 @@ public:
   sys_var_event_scheduler(sys_var_chain *chain, const char *name_arg) :
     sys_var_long_ptr(chain, name_arg, NULL, NULL) {};
   bool update(THD *thd, set_var *var);
-  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
   SHOW_TYPE show_type() { return SHOW_CHAR; }
   bool check(THD *thd, set_var *var);
   bool check_update_type(Item_result type)
@@ -1089,10 +1102,10 @@ class NAMED_LIST :public ilink
   const char *name;
   uint name_length;
 public:
-  gptr data;
+  uchar* data;
 
   NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg,
-	     uint name_length_arg, gptr data_arg)
+	     uint name_length_arg, uchar* data_arg)
     :name_length(name_length_arg), data(data_arg)
   {
     name= my_strndup(name_arg, name_length, MYF(MY_WME));
@@ -1104,12 +1117,12 @@ public:
   }
   ~NAMED_LIST()
   {
-    my_free((char*) name, MYF(0));
+    my_free((uchar*) name, MYF(0));
   }
   friend bool process_key_caches(int (* func) (const char *name,
 					       KEY_CACHE *));
   friend void delete_elements(I_List<NAMED_LIST> *list,
-			      void (*free_element)(const char*, gptr));
+			      void (*free_element)(const char*, uchar*));
 };
 
 /* updated in sql_acl.cc */
@@ -1146,7 +1159,7 @@ extern sys_var_str sys_init_slave;
 extern sys_var_thd_time_zone sys_time_zone;
 extern sys_var_thd_bit sys_autocommit;
 CHARSET_INFO *get_old_charset_by_name(const char *old_name);
-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);
 
 extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path;
@@ -1157,4 +1170,4 @@ KEY_CACHE *get_or_create_key_cache(const
 void free_key_cache(const char *name, KEY_CACHE *key_cache);
 bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
 void delete_elements(I_List<NAMED_LIST> *list,
-		     void (*free_element)(const char*, gptr));
+		     void (*free_element)(const char*, uchar*));

--- 1.63/scripts/mysql_system_tables_fix.sql	2007-06-16 19:53:19 +02:00
+++ 1.64/scripts/mysql_system_tables_fix.sql	2007-06-16 19:53:19 +02:00
@@ -328,7 +328,7 @@ ALTER TABLE procs_priv
     COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
 
 ALTER TABLE procs_priv
-  MODIFY Timestamp timestamp(14) AFTER Proc_priv;
+  MODIFY Timestamp timestamp AFTER Proc_priv;
 
 #
 # proc

--- 1.125/mysql-test/r/sp-error.result	2007-06-16 19:53:19 +02:00
+++ 1.126/mysql-test/r/sp-error.result	2007-06-16 19:53:19 +02:00
@@ -917,10 +917,6 @@ CREATE TRIGGER tr1 BEFORE INSERT ON t1 F
 ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
 CREATE FUNCTION bug_13627_f() returns int BEGIN DROP TRIGGER test1; return 1; END |
 ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
-CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN load table t1 from master; END |
-ERROR 0A000: LOAD TABLE is not allowed in stored procedures
-CREATE FUNCTION bug_13627_f() returns int BEGIN load table t1 from master; return 1; END |
-ERROR 0A000: LOAD TABLE is not allowed in stored procedures
 CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create table t2 (a int); END |
 ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
 CREATE FUNCTION bug_13627_f() returns int BEGIN create table t2 (a int); return 1; END |
@@ -1095,18 +1091,6 @@ DROP FUNCTION IF EXISTS bug13012|
 CREATE FUNCTION bug13012() RETURNS INT
 BEGIN
 REPAIR TABLE t1;
-RETURN 1;
-END|
-ERROR 0A000: Not allowed to return a result set from a function
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
-BACKUP TABLE t1 TO '/tmp';
-RETURN 1;
-END|
-ERROR 0A000: Not allowed to return a result set from a function
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
-RESTORE TABLE t1 FROM '/tmp';
 RETURN 1;
 END|
 ERROR 0A000: Not allowed to return a result set from a function

--- 1.271/mysql-test/r/sp.result	2007-06-16 19:53:19 +02:00
+++ 1.272/mysql-test/r/sp.result	2007-06-16 19:53:19 +02:00
@@ -1497,10 +1497,10 @@ insert into t3 (a) values (1)|
 create procedure h_ee()
 deterministic
 begin
-declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+declare continue handler for 1062 -- ER_DUP_ENTRY
 select 'Outer (bad)' as 'h_ee';
 begin
-declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+declare continue handler for 1062 -- ER_DUP_ENTRY
 select 'Inner (good)' as 'h_ee';
 insert into t3 values (1);
 end;
@@ -1508,7 +1508,7 @@ end|
 create procedure h_es()
 deterministic
 begin
-declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+declare continue handler for 1062 -- ER_DUP_ENTRY
 select 'Outer (good)' as 'h_es';
 begin
 -- integrity constraint violation
@@ -1545,7 +1545,7 @@ end|
 create procedure h_ex()
 deterministic
 begin
-declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+declare continue handler for 1062 -- ER_DUP_ENTRY
 select 'Outer (good)' as 'h_ex';
 begin
 declare continue handler for sqlexception
@@ -1560,7 +1560,7 @@ begin
 declare continue handler for sqlstate '23000' 
 select 'Outer (bad)' as 'h_se';
 begin
-declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+declare continue handler for 1062 -- ER_DUP_ENTRY
 select 'Inner (good)' as 'h_se';
 insert into t3 values (1);
 end;
@@ -1700,7 +1700,7 @@ begin
 declare continue handler for sqlexception
 select 'Outer (bad)' as 'h_xe';
 begin
-declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+declare continue handler for 1062 -- ER_DUP_ENTRY
 select 'Inner (good)' as 'h_xe';
 insert into t3 values (1);
 end;
@@ -4400,6 +4400,12 @@ END|
 call bug13012()|
 Table	Op	Msg_type	Msg_text
 test.t1	repair	status	OK
+Table	Op	Msg_type	Msg_text
+test.t1	backup	Warning	The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t1	backup	status	OK
+Table	Op	Msg_type	Msg_text
+test.t1	restore	Warning	The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t1	restore	status	OK
 drop procedure bug13012|
 create view v1 as select * from t1|
 create procedure bug13012()
@@ -4413,61 +4419,58 @@ Table	Op	Msg_type	Msg_text
 test.t1	repair	status	OK
 test.t2	repair	status	OK
 test.t3	repair	status	OK
-test.v1	repair	error	'test.v1' is not BASE TABLE
+test.v1	repair	Error	'test.v1' is not BASE TABLE
+test.v1	repair	error	Corrupt
 Table	Op	Msg_type	Msg_text
 test.t1	optimize	status	OK
 test.t2	optimize	status	OK
 test.t3	optimize	status	OK
-test.v1	optimize	error	'test.v1' is not BASE TABLE
+test.v1	optimize	Error	'test.v1' is not BASE TABLE
+test.v1	optimize	error	Corrupt
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	Table is already up to date
 test.t2	analyze	status	Table is already up to date
 test.t3	analyze	status	Table is already up to date
-test.v1	analyze	error	'test.v1' is not BASE TABLE
-Warnings:
-Error	1347	'test.v1' is not BASE TABLE
-Error	1347	'test.v1' is not BASE TABLE
-Error	1347	'test.v1' is not BASE TABLE
+test.v1	analyze	Error	'test.v1' is not BASE TABLE
+test.v1	analyze	error	Corrupt
 call bug13012()|
 Table	Op	Msg_type	Msg_text
 test.t1	repair	status	OK
 test.t2	repair	status	OK
 test.t3	repair	status	OK
-test.v1	repair	error	'test.v1' is not BASE TABLE
+test.v1	repair	Error	'test.v1' is not BASE TABLE
+test.v1	repair	error	Corrupt
 Table	Op	Msg_type	Msg_text
 test.t1	optimize	status	OK
 test.t2	optimize	status	OK
 test.t3	optimize	status	OK
-test.v1	optimize	error	'test.v1' is not BASE TABLE
+test.v1	optimize	Error	'test.v1' is not BASE TABLE
+test.v1	optimize	error	Corrupt
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	Table is already up to date
 test.t2	analyze	status	Table is already up to date
 test.t3	analyze	status	Table is already up to date
-test.v1	analyze	error	'test.v1' is not BASE TABLE
-Warnings:
-Error	1347	'test.v1' is not BASE TABLE
-Error	1347	'test.v1' is not BASE TABLE
-Error	1347	'test.v1' is not BASE TABLE
+test.v1	analyze	Error	'test.v1' is not BASE TABLE
+test.v1	analyze	error	Corrupt
 call bug13012()|
 Table	Op	Msg_type	Msg_text
 test.t1	repair	status	OK
 test.t2	repair	status	OK
 test.t3	repair	status	OK
-test.v1	repair	error	'test.v1' is not BASE TABLE
+test.v1	repair	Error	'test.v1' is not BASE TABLE
+test.v1	repair	error	Corrupt
 Table	Op	Msg_type	Msg_text
 test.t1	optimize	status	OK
 test.t2	optimize	status	OK
 test.t3	optimize	status	OK
-test.v1	optimize	error	'test.v1' is not BASE TABLE
+test.v1	optimize	Error	'test.v1' is not BASE TABLE
+test.v1	optimize	error	Corrupt
 Table	Op	Msg_type	Msg_text
 test.t1	analyze	status	Table is already up to date
 test.t2	analyze	status	Table is already up to date
 test.t3	analyze	status	Table is already up to date
-test.v1	analyze	error	'test.v1' is not BASE TABLE
-Warnings:
-Error	1347	'test.v1' is not BASE TABLE
-Error	1347	'test.v1' is not BASE TABLE
-Error	1347	'test.v1' is not BASE TABLE
+test.v1	analyze	Error	'test.v1' is not BASE TABLE
+test.v1	analyze	error	Corrupt
 drop procedure bug13012|
 drop view v1|
 select * from t1 order by data|
@@ -4698,10 +4701,10 @@ insert into t3 values (1)|
 create procedure bug15011()
 deterministic
 begin
-declare continue handler for 1582
+declare continue handler for 1062
 select 'Outer' as 'Handler';
 begin
-declare continue handler for 1582
+declare continue handler for 1062
 select 'Inner' as 'Handler';
 insert into t3 values (1);
 end;
@@ -4903,7 +4906,7 @@ create table t3 as select * from v1|
 show create table t3|
 Table	Create Table
 t3	CREATE TABLE `t3` (
-  `j` int(11) DEFAULT NULL
+  `j` bigint(11) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 select * from t3|
 j
@@ -5610,6 +5613,23 @@ Called B
 Called B
 drop procedure proc_21462_a|
 drop procedure proc_21462_b|
+drop table if exists t3|
+drop procedure if exists proc_bug19733|
+create table t3 (s1 int)|
+create procedure proc_bug19733()
+begin
+declare v int default 0;
+while v < 100 do
+create index i on t3 (s1);
+drop index i on t3;
+set v = v + 1;
+end while;
+end|
+call proc_bug19733()|
+call proc_bug19733()|
+call proc_bug19733()|
+drop procedure proc_bug19733|
+drop table t3|
 DROP PROCEDURE IF EXISTS p1|
 DROP VIEW IF EXISTS v1, v2|
 DROP TABLE IF EXISTS t3, t4|
@@ -6103,6 +6123,8 @@ select bug20777(9223372036854775810) as 
 select bug20777(-9223372036854775808) as 'lower bounds signed bigint';
 lower bounds signed bigint
 0
+Warnings:
+Warning	1264	Out of range value for column 'f1' at row 1
 select bug20777(9223372036854775807) as 'upper bounds signed bigint';
 upper bounds signed bigint
 9223372036854775807
@@ -6115,9 +6137,13 @@ upper bounds unsigned bigint
 select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1';
 upper bounds unsigned bigint + 1
 18446744073709551615
+Warnings:
+Warning	1264	Out of range value for column 'f1' at row 1
 select bug20777(-1) as 'lower bounds unsigned bigint - 1';
 lower bounds unsigned bigint - 1
 0
+Warnings:
+Warning	1264	Out of range value for column 'f1' at row 1
 create table examplebug20777 as select 
 0 as 'i',
 bug20777(9223372036854775806) as '2**63-2',
@@ -6129,7 +6155,12 @@ bug20777(18446744073709551615) as '2**64
 bug20777(18446744073709551616) as '2**64',
 bug20777(0) as '0',
 bug20777(-1) as '-1';
+Warnings:
+Warning	1264	Out of range value for column 'f1' at row 1
+Warning	1264	Out of range value for column 'f1' at row 1
 insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1);
+Warnings:
+Warning	1264	Out of range value for column '-1' at row 1
 show create table examplebug20777;
 Table	Create Table
 examplebug20777	CREATE TABLE `examplebug20777` (
@@ -6237,3 +6268,14 @@ count(*)
 3
 drop table t1,t2;
 drop function   bug27354;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12;
+CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1;
+SHOW CREATE VIEW v1;
+View	Create View
+v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`metered`(`t1`.`a`) AS `metered` from `t1`
+DROP VIEW v1;
+DROP FUNCTION metered;
+DROP TABLE t1;
+End of 5.0 tests

--- 1.122/mysql-test/t/sp-error.test	2007-06-16 19:53:19 +02:00
+++ 1.123/mysql-test/t/sp-error.test	2007-06-16 19:53:19 +02:00
@@ -1321,11 +1321,6 @@ CREATE TRIGGER tr1 BEFORE INSERT ON t1 F
 -- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
 CREATE FUNCTION bug_13627_f() returns int BEGIN DROP TRIGGER test1; return 1; END |
 
--- error ER_SP_BADSTATEMENT
-CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN load table t1 from master; END |
--- error ER_SP_BADSTATEMENT
-CREATE FUNCTION bug_13627_f() returns int BEGIN load table t1 from master; return 1; END |
-
 -- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
 CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create table t2 (a int); END |
 -- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
@@ -1563,18 +1558,6 @@ DROP FUNCTION IF EXISTS bug13012|
 CREATE FUNCTION bug13012() RETURNS INT
 BEGIN
   REPAIR TABLE t1;
-  RETURN 1;
-END|
---error ER_SP_NO_RETSET
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
-  BACKUP TABLE t1 TO '/tmp';
-  RETURN 1;
-END|
---error ER_SP_NO_RETSET
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
-  RESTORE TABLE t1 FROM '/tmp';
   RETURN 1;
 END|
 create table t1 (a int)|

--- 1.238/mysql-test/t/sp.test	2007-06-16 19:53:19 +02:00
+++ 1.239/mysql-test/t/sp.test	2007-06-16 19:53:19 +02:00
@@ -1767,11 +1767,11 @@ insert into t3 (a) values (1)|
 create procedure h_ee()
     deterministic
 begin
-  declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+  declare continue handler for 1062 -- ER_DUP_ENTRY
     select 'Outer (bad)' as 'h_ee';
 
   begin
-    declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+    declare continue handler for 1062 -- ER_DUP_ENTRY
         select 'Inner (good)' as 'h_ee';
 
     insert into t3 values (1);
@@ -1781,7 +1781,7 @@ end|
 create procedure h_es()
     deterministic
 begin
-  declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+  declare continue handler for 1062 -- ER_DUP_ENTRY
     select 'Outer (good)' as 'h_es';
 
   begin
@@ -1827,7 +1827,7 @@ end|
 create procedure h_ex()
     deterministic
 begin
-  declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+  declare continue handler for 1062 -- ER_DUP_ENTRY
     select 'Outer (good)' as 'h_ex';
 
   begin
@@ -1846,7 +1846,7 @@ begin
     select 'Outer (bad)' as 'h_se';
 
   begin
-    declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+    declare continue handler for 1062 -- ER_DUP_ENTRY
       select 'Inner (good)' as 'h_se';
 
     insert into t3 values (1);
@@ -2019,7 +2019,7 @@ begin
     select 'Outer (bad)' as 'h_xe';
 
   begin
-    declare continue handler for 1582 -- ER_DUP_ENTRY_WITH_KEY_NAME
+    declare continue handler for 1062 -- ER_DUP_ENTRY
       select 'Inner (good)' as 'h_xe';
 
     insert into t3 values (1);
@@ -4511,7 +4511,7 @@ begin
    select bug12379();
 end|
 
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 select bug12379()|
 select 1|
 # statement-based binlogging will show warning which row-based won't;
@@ -4522,7 +4522,7 @@ select 2|
 call bug12379_2()|
 --enable_warnings
 select 3|
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 call bug12379_3()|
 select 4|
 
@@ -4604,7 +4604,7 @@ end|
 
 call bug6127()|
 select * from t3|
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 call bug6127()|
 select * from t3|
 set sql_mode=@sm|
@@ -5528,11 +5528,11 @@ insert into t3 values (1)|
 create procedure bug15011()
   deterministic
 begin
-  declare continue handler for 1582
+  declare continue handler for 1062
     select 'Outer' as 'Handler';
 
   begin
-    declare continue handler for 1582
+    declare continue handler for 1062
       select 'Inner' as 'Handler';
 
     insert into t3 values (1);
@@ -6566,6 +6566,34 @@ drop procedure proc_21462_b|
 
 
 #
+# Bug#19733 "Repeated alter, or repeated create/drop, fails"
+# Check that CREATE/DROP INDEX is re-execution friendly.
+# 
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists proc_bug19733|
+--enable_warnings
+create table t3 (s1 int)|
+
+create procedure proc_bug19733()
+begin
+  declare v int default 0;
+  while v < 100 do
+    create index i on t3 (s1);
+    drop index i on t3;
+    set v = v + 1;
+  end while;
+end|
+
+call proc_bug19733()|
+call proc_bug19733()|
+call proc_bug19733()|
+
+drop procedure proc_bug19733|
+drop table t3|
+
+
+#
 # BUG#20492: Subsequent calls to stored procedure yeild incorrect
 # result if join is used 
 #
@@ -7063,7 +7091,7 @@ use test|
 --disable_warnings
 drop function if exists bug20777|
 drop table if exists examplebug20777|
---enabled_warnings
+--enable_warnings
 create function bug20777(f1 bigint unsigned) returns bigint unsigned
 begin
   set f1 = (f1 - 10); set f1 = (f1 + 10);
@@ -7200,3 +7228,23 @@ select count(*) from t1 /* must be 3 */;
 
 drop table t1,t2;
 drop function   bug27354;
+
+#
+# Bug #28605: SHOW CREATE VIEW with views using stored_procedures no longer
+# showing SP names.
+#
+CREATE TABLE t1 (a INT); 
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12;
+
+CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1;
+
+SHOW CREATE VIEW v1;
+
+DROP VIEW v1;
+DROP FUNCTION metered;
+DROP TABLE t1;
+
+
+--echo End of 5.0 tests

--- 1.275/sql/sp_head.cc	2007-06-16 19:53:19 +02:00
+++ 1.276/sql/sp_head.cc	2007-06-16 19:53:19 +02:00
@@ -161,7 +161,6 @@ sp_get_flags_for_command(LEX *lex)
     }
     /* fallthrough */
   case SQLCOM_ANALYZE:
-  case SQLCOM_BACKUP_TABLE:
   case SQLCOM_OPTIMIZE:
   case SQLCOM_PRELOAD_KEYS:
   case SQLCOM_ASSIGN_TO_KEYCACHE:
@@ -206,7 +205,6 @@ sp_get_flags_for_command(LEX *lex)
   case SQLCOM_SHOW_VARIABLES:
   case SQLCOM_SHOW_WARNS:
   case SQLCOM_REPAIR:
-  case SQLCOM_RESTORE_TABLE:
     flags= sp_head::MULTI_RESULTS;
     break;
   /*
@@ -258,7 +256,6 @@ sp_get_flags_for_command(LEX *lex)
   case SQLCOM_COMMIT:
   case SQLCOM_ROLLBACK:
   case SQLCOM_LOAD:
-  case SQLCOM_LOAD_MASTER_DATA:
   case SQLCOM_LOCK_TABLES:
   case SQLCOM_CREATE_PROCEDURE:
   case SQLCOM_CREATE_SPFUNCTION:
@@ -3453,6 +3450,9 @@ typedef struct st_sp_table
   thr_lock_type lock_type; /* lock type used for prelocking */
   uint lock_count;
   uint query_lock_count;
+  /* For transactional locking. */
+  int           lock_timeout;           /* NOWAIT or WAIT [X]               */
+  bool          lock_transactional;     /* If transactional lock requested. */
 } SP_TABLE;
 
 uchar *
@@ -3535,7 +3535,11 @@ sp_head::merge_table_list(THD *thd, TABL
            tab->temp))
       {
         if (tab->lock_type < table->lock_type)
-          tab->lock_type= table->lock_type; // Use the table with the highest lock type
+          tab->lock_type= table->lock_type; // Use the highest lock type
+        if (tab->lock_timeout > table->lock_timeout)
+          tab->lock_timeout= table->lock_timeout; // Use the lowest timeout
+        if (!table->lock_transactional)
+          tab->lock_transactional= FALSE; // Non-transactional locks win
         tab->query_lock_count++;
         if (tab->query_lock_count > tab->lock_count)
           tab->lock_count++;
@@ -3559,6 +3563,8 @@ sp_head::merge_table_list(THD *thd, TABL
         tab->table_name_length= table->table_name_length;
         tab->db_length= table->db_length;
         tab->lock_type= table->lock_type;
+        tab->lock_timeout= table->lock_timeout;
+        tab->lock_transactional= table->lock_transactional;
         tab->lock_count= tab->query_lock_count= 1;
 	my_hash_insert(&m_sptabs, (uchar *)tab);
       }
@@ -3634,6 +3640,8 @@ sp_head::add_used_tables_to_table_list(T
       table->table_name_length= stab->table_name_length;
       table->alias= table->table_name + table->table_name_length + 1;
       table->lock_type= stab->lock_type;
+      table->lock_timeout= stab->lock_timeout;
+      table->lock_transactional= stab->lock_transactional;
       table->cacheable_table= 1;
       table->prelocking_placeholder= 1;
       table->belong_to_view= belong_to_view;
@@ -3679,6 +3687,8 @@ sp_add_to_query_tables(THD *thd, LEX *le
   table->table_name= thd->strmake(name, table->table_name_length);
   table->alias= thd->strdup(name);
   table->lock_type= locktype;
+  table->lock_timeout= -1;      /* default timeout */
+  table->lock_transactional= 1; /* allow transactional locks */
   table->select_lex= lex->current_select;
   table->cacheable_table= 1;
   

--- 1.38/BitKeeper/triggers/post-commit	2007-06-16 19:53:19 +02:00
+++ 1.39/BitKeeper/triggers/post-commit	2007-06-16 19:53:19 +02:00
@@ -33,6 +33,13 @@ then
   exit
 fi
 
+IS_MERGE=`bk changes -r+ -k -m`
+if [ "$IS_MERGE" = "" ]
+then
+  echo Merge changeset, not sending mails
+  exit
+fi
+
 CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet`
 CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet`
 #
@@ -48,44 +55,35 @@ WL=`bk -R prs -r+ -h -d':C:' ChangeSet |
               s/.*\(WL#[0-9][0-9]*\)/ \1/p'`
 if [ "$BUG" = "" ]
 then
-  TO=dev-public@stripped
+#  TO=dev-public@stripped
   BS=""
   BH=""
 else
-  TO=dev-bugs@stripped
+#  TO=dev-bugs@stripped
   BS=" BUG#$BUG"
 # need newline here
   BH="X-Bug: $BUG
 "
 fi
+
 #++
-# dev-public@ / dev-bugs@
+# commits@ or dev-private@ mail
 #--
- echo "Commit successful, notifying developers at $TO"
- (
-   cat <<EOF
-List-ID: <bk.mysql-$VERSION>
-From: $FROM
-To: $TO
-Subject: bk commit - $VERSION tree ($CHANGESET)${BS}${WL}
-X-CSetKey: <$CSETKEY>
-$BH
-EOF
-  bk changes -v -r+
-  bk rset -r+ -ah | bk gnupatch -h -dup -T
- ) > $BKROOT/BitKeeper/tmp/dev_public.txt
 
-$SENDMAIL -t < $BKROOT/BitKeeper/tmp/dev_public.txt
+LIST="commits"
+TO="commits@stripped"
+if [ -f .tree-is-private ]
+then
+  LIST="dev-private"
+  TO="dev-private@stripped"
+fi
 
-#++
-# commits@ mail
-#--
- echo "Notifying commits list at $COMMITS"
+ echo "Notifying $LIST list at $TO"
  (
    cat <<EOF
 List-ID: <bk.mysql-$VERSION>
 From: $FROM
-To: $COMMITS
+To: $TO
 Subject: bk commit into $VERSION tree ($CHANGESET)$BS
 X-CSetKey: <$CSETKEY>
 $BH

--- 1.77/sql/repl_failsafe.cc	2007-06-16 19:53:20 +02:00
+++ 1.78/sql/repl_failsafe.cc	2007-06-16 19:53:20 +02:00
@@ -678,322 +678,5 @@ bool show_slave_hosts(THD* thd)
   DBUG_RETURN(FALSE);
 }
 
-
-int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
-{
-  DBUG_ENTER("connect_to_master");
-
-  if (!mi->host || !*mi->host)			/* empty host */
-  {
-    strmov(mysql->net.last_error, "Master is not configured");
-    DBUG_RETURN(1);
-  }
-  mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);
-  mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
-
-#ifdef HAVE_OPENSSL
-  if (mi->ssl)
-  {
-    mysql_ssl_set(mysql, 
-        mi->ssl_key[0]?mi->ssl_key:0,
-        mi->ssl_cert[0]?mi->ssl_cert:0,
-        mi->ssl_ca[0]?mi->ssl_ca:0, 
-        mi->ssl_capath[0]?mi->ssl_capath:0,
-        mi->ssl_cipher[0]?mi->ssl_cipher:0);
-    mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
-                  &mi->ssl_verify_server_cert);
-  }
-#endif
-    
-  mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname);
-  mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
-  if (!mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0,
-			mi->port, 0, 0))
-    DBUG_RETURN(1);
-  mysql->reconnect= 1;
-  DBUG_RETURN(0);
-}
-
-
-static inline void cleanup_mysql_results(MYSQL_RES* db_res,
-					 MYSQL_RES** cur, MYSQL_RES** start)
-{
-  for (; cur >= start; --cur)
-  {
-    if (*cur)
-      mysql_free_result(*cur);
-  }
-  mysql_free_result(db_res);
-}
-
-
-static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db,
-			   MYSQL_RES *table_res, MASTER_INFO *mi)
-{
-  MYSQL_ROW row;
-  for (row = mysql_fetch_row(table_res); row;
-       row = mysql_fetch_row(table_res))
-  {
-    TABLE_LIST table;
-    const char* table_name= row[0];
-    int error;
-    if (rpl_filter->is_on())
-    {
-      bzero((char*) &table, sizeof(table)); //just for safe
-      table.db= (char*) db;
-      table.table_name= (char*) table_name;
-      table.updating= 1;
-
-      if (!rpl_filter->tables_ok(thd->db, &table))
-	continue;
-    }
-    /* download master's table and overwrite slave's table */
-    if ((error= fetch_master_table(thd, db, table_name, mi, mysql, 1)))
-      return error;
-  }
-  return 0;
-}
-
-/*
-  Load all MyISAM tables from master to this slave.
-
-  REQUIREMENTS
-   - No active transaction (flush_relay_log_info would not work in this case)
-*/
-
-bool load_master_data(THD* thd)
-{
-  MYSQL mysql;
-  MYSQL_RES* master_status_res = 0;
-  int error = 0;
-  const char* errmsg=0;
-  int restart_thread_mask;
-  HA_CREATE_INFO create_info;
-
-  mysql_init(&mysql);
-
-  /*
-    We do not want anyone messing with the slave at all for the entire
-    duration of the data load.
-  */
-  pthread_mutex_lock(&LOCK_active_mi);
-  lock_slave_threads(active_mi);
-  init_thread_mask(&restart_thread_mask,active_mi,0 /*not inverse*/);
-  if (restart_thread_mask &&
-      (error=terminate_slave_threads(active_mi,restart_thread_mask,
-				     1 /*skip lock*/)))
-  {
-    my_message(error, ER(error), MYF(0));
-    unlock_slave_threads(active_mi);
-    pthread_mutex_unlock(&LOCK_active_mi);
-    return TRUE;
-  }
-  
-  if (connect_to_master(thd, &mysql, active_mi))
-  {
-    my_error(error= ER_CONNECT_TO_MASTER, MYF(0), mysql_error(&mysql));
-    goto err;
-  }
-
-  // now that we are connected, get all database and tables in each
-  {
-    MYSQL_RES *db_res, **table_res, **table_res_end, **cur_table_res;
-    uint num_dbs;
-
-    if (mysql_real_query(&mysql, STRING_WITH_LEN("SHOW DATABASES")) ||
-	!(db_res = mysql_store_result(&mysql)))
-    {
-      my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
-      goto err;
-    }
-
-    if (!(num_dbs = (uint) mysql_num_rows(db_res)))
-      goto err;
-    /*
-      In theory, the master could have no databases at all
-      and run with skip-grant
-    */
-
-    if (!(table_res = (MYSQL_RES**)thd->alloc(num_dbs * sizeof(MYSQL_RES*))))
-    {
-      my_message(error = ER_OUTOFMEMORY, ER(ER_OUTOFMEMORY), MYF(0));
-      goto err;
-    }
-
-    /*
-      This is a temporary solution until we have online backup
-      capabilities - to be replaced once online backup is working
-      we wait to issue FLUSH TABLES WITH READ LOCK for as long as we
-      can to minimize the lock time.
-    */
-    if (mysql_real_query(&mysql,
-                         STRING_WITH_LEN("FLUSH TABLES WITH READ LOCK")) ||
-	mysql_real_query(&mysql, STRING_WITH_LEN("SHOW MASTER STATUS")) ||
-	!(master_status_res = mysql_store_result(&mysql)))
-    {
-      my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
-      goto err;
-    }
-
-    /*
-      Go through every table in every database, and if the replication
-      rules allow replicating it, get it
-    */
-
-    table_res_end = table_res + num_dbs;
-
-    for (cur_table_res = table_res; cur_table_res < table_res_end;
-	 cur_table_res++)
-    {
-      // since we know how many rows we have, this can never be NULL
-      MYSQL_ROW row = mysql_fetch_row(db_res);
-      char* db = row[0];
-
-      /*
-	Do not replicate databases excluded by rules. We also test
-	replicate_wild_*_table rules (replicate_wild_ignore_table='db1.%' will
-	be considered as "ignore the 'db1' database as a whole, as it already
-	works for CREATE DATABASE and DROP DATABASE).
-	Also skip 'mysql' database - in most cases the user will
-	mess up and not exclude mysql database with the rules when
-	he actually means to - in this case, he is up for a surprise if
-	his priv tables get dropped and downloaded from master
-	TODO - add special option, not enabled
-	by default, to allow inclusion of mysql database into load
-	data from master
-      */
-
-      if (!rpl_filter->db_ok(db) || 
-	  !rpl_filter->db_ok_with_wild_table(db) || 
-	  !strcmp(db,"mysql") ||
-          is_schema_db(db))
-      {
-	*cur_table_res = 0;
-	continue;
-      }
-
-      bzero((char*) &create_info, sizeof(create_info));
-      create_info.options= HA_LEX_CREATE_IF_NOT_EXISTS;
-
-      if (mysql_create_db(thd, db, &create_info, 1))
-      {
-	cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
-	goto err;
-      }
-
-      if (mysql_select_db(&mysql, db) ||
-	  mysql_real_query(&mysql, STRING_WITH_LEN("SHOW TABLES")) ||
-	  !(*cur_table_res = mysql_store_result(&mysql)))
-      {
-	my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
-	cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
-	goto err;
-      }
-
-      if ((error = fetch_db_tables(thd,&mysql,db,*cur_table_res,active_mi)))
-      {
-	// we do not report the error - fetch_db_tables handles it
-	cleanup_mysql_results(db_res, cur_table_res, table_res);
-	goto err;
-      }
-    }
-
-    cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
-
-    // adjust replication coordinates from the master
-    if (master_status_res)
-    {
-      MYSQL_ROW row = mysql_fetch_row(master_status_res);
-
-      /*
-	We need this check because the master may not be running with
-	log-bin, but it will still allow us to do all the steps
-	of LOAD DATA FROM MASTER - no reason to forbid it, really,
-	although it does not make much sense for the user to do it
-      */
-      if (row && row[0] && row[1])
-      {
-        /*
-          If the slave's master info is not inited, we init it, then we write
-          the new coordinates to it. Must call init_master_info() *before*
-          setting active_mi, because init_master_info() sets active_mi with
-          defaults.
-        */
-        int error_2;
-
-        if (init_master_info(active_mi, master_info_file, relay_log_info_file, 
-			     0, (SLAVE_IO | SLAVE_SQL)))
-          my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0));
-	strmake(active_mi->master_log_name, row[0],
-		sizeof(active_mi->master_log_name));
-	active_mi->master_log_pos= my_strtoll10(row[1], (char**) 0, &error_2);
-        /* at least in recent versions, the condition below should be false */
-	if (active_mi->master_log_pos < BIN_LOG_HEADER_SIZE)
-	  active_mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-        /*
-          Relay log's IO_CACHE may not be inited (even if we are sure that some
-          host was specified; there could have been a problem when replication
-          started, which led to relay log's IO_CACHE to not be inited.
-        */
-        if (flush_master_info(active_mi, 0))
-          sql_print_error("Failed to flush master info file");
-      }
-      mysql_free_result(master_status_res);
-    }
-
-    if (mysql_real_query(&mysql, STRING_WITH_LEN("UNLOCK TABLES")))
-    {
-      my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
-      goto err;
-    }
-  }
-  thd->proc_info="purging old relay logs";
-  if (purge_relay_logs(&active_mi->rli,thd,
-		       0 /* not only reset, but also reinit */,
-		       &errmsg))
-  {
-    my_error(ER_RELAY_LOG_FAIL, MYF(0), errmsg);
-    unlock_slave_threads(active_mi);
-    pthread_mutex_unlock(&LOCK_active_mi);
-    return TRUE;
-  }
-  pthread_mutex_lock(&active_mi->rli.data_lock);
-  active_mi->rli.group_master_log_pos = active_mi->master_log_pos;
-  strmake(active_mi->rli.group_master_log_name,active_mi->master_log_name,
-	  sizeof(active_mi->rli.group_master_log_name)-1);
-  /*
-     Cancel the previous START SLAVE UNTIL, as the fact to download
-     a new copy logically makes UNTIL irrelevant.
-  */
-  active_mi->rli.clear_until_condition();
-
-  /*
-    No need to update rli.event* coordinates, they will be when the slave
-    threads start ; only rli.group* coordinates are necessary here.
-  */
-  flush_relay_log_info(&active_mi->rli);
-  pthread_cond_broadcast(&active_mi->rli.data_cond);
-  pthread_mutex_unlock(&active_mi->rli.data_lock);
-  thd->proc_info = "starting slave";
-  if (restart_thread_mask)
-  {
-    error=start_slave_threads(0 /* mutex not needed */,
-			      1 /* wait for start */,
-			      active_mi,master_info_file,relay_log_info_file,
-			      restart_thread_mask);
-  }
-
-err:
-  unlock_slave_threads(active_mi);
-  pthread_mutex_unlock(&LOCK_active_mi);
-  thd->proc_info = 0;
-
-  mysql_close(&mysql); // safe to call since we always do mysql_init()
-  if (!error)
-    send_ok(thd);
-
-  return error;
-}
-
 #endif /* HAVE_REPLICATION */
 

--- 1.170/sql/sql_repl.cc	2007-06-16 19:53:20 +02:00
+++ 1.171/sql/sql_repl.cc	2007-06-16 19:53:20 +02:00
@@ -979,14 +979,8 @@ int reset_slave(THD *thd, MASTER_INFO* m
 			       &errmsg)))
     goto err;
 
-  /*
-    Clear master's log coordinates and reset host/user/etc to the values
-    specified in mysqld's options (only for good display of SHOW SLAVE STATUS;
-    next init_master_info() (in start_slave() for example) would have set them
-    the same way; but here this is for the case where the user does SHOW SLAVE
-    STATUS; before doing START SLAVE;
-  */
-  init_master_info_with_options(mi);
+  /* Clear master's log coordinates */
+  init_master_log_pos(mi);
   /*
      Reset errors (the idea is that we forget about the
      old master).

--- 1.17/mysql-test/t/sp_trans.test	2007-06-16 19:53:20 +02:00
+++ 1.18/mysql-test/t/sp_trans.test	2007-06-16 19:53:20 +02:00
@@ -2,6 +2,7 @@
 # tests that require InnoDB...
 #
 
+-- source include/have_log_bin.inc
 -- source include/have_innodb.inc
 
 --disable_warnings
@@ -89,7 +90,7 @@ create function bug10015_5(i int) return
     end if;
     return i;
   end|
---error ER_DUP_ENTRY_WITH_KEY_NAME
+--error ER_DUP_ENTRY
 insert into t1 values (bug10015_5(4)), (bug10015_5(5))|
 select * from t1|
 drop function bug10015_5|

--- 1.241/tests/mysql_client_test.c	2007-06-16 19:53:20 +02:00
+++ 1.242/tests/mysql_client_test.c	2007-06-16 19:53:20 +02:00
@@ -1486,7 +1486,7 @@ static void test_prepare_field_result()
   myquery(rc);
 
   rc= mysql_query(mysql, "CREATE TABLE test_prepare_field_result(int_c int, "
-                         "var_c varchar(50), ts_c timestamp(14), "
+                         "var_c varchar(50), ts_c timestamp, "
                          "char_c char(4), date_c date, extra tinyint)");
   myquery(rc);
 
@@ -4242,11 +4242,11 @@ static void test_fetch_date()
   myquery(rc);
 
   rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 date, c2 time, \
-                                                        c3 timestamp(14), \
+                                                        c3 timestamp, \
                                                         c4 year, \
                                                         c5 datetime, \
-                                                        c6 timestamp(4), \
-                                                        c7 timestamp(6))");
+                                                        c6 timestamp, \
+                                                        c7 timestamp)");
   myquery(rc);
 
   rc= mysql_query(mysql, "SET SQL_MODE=''");
@@ -4560,7 +4560,7 @@ static void test_prepare_ext()
                " c12 numeric(8, 4),"
                " c13 date,"
                " c14 datetime,"
-               " c15 timestamp(14),"
+               " c15 timestamp,"
                " c16 time,"
                " c17 year,"
                " c18 bit,"
@@ -5591,7 +5591,7 @@ static void test_manual_sample()
   }
   if (mysql_query(mysql, "CREATE TABLE test_table(col1 int, col2 varchar(50), \
                                                  col3 smallint, \
-                                                 col4 timestamp(14))"))
+                                                 col4 timestamp)"))
   {
     fprintf(stderr, "\n create table failed");
     fprintf(stderr, "\n %s", mysql_error(mysql));
@@ -6487,7 +6487,7 @@ static void test_date()
   rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date");
   myquery(rc);
 
-  rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP(14), \
+  rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP, \
                                                  c2 TIME, \
                                                  c3 DATETIME, \
                                                  c4 DATE)");
@@ -6553,10 +6553,10 @@ static void test_date_ts()
   rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date");
   myquery(rc);
 
-  rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP(10), \
-                                                 c2 TIMESTAMP(14), \
+  rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP, \
+                                                 c2 TIMESTAMP, \
                                                  c3 TIMESTAMP, \
-                                                 c4 TIMESTAMP(6))");
+                                                 c4 TIMESTAMP)");
 
   myquery(rc);
 
@@ -7233,7 +7233,7 @@ static void test_field_misc()
   mysql_free_result(result);
   mysql_stmt_close(stmt);
 
-  stmt= mysql_simple_prepare(mysql, "SELECT @@table_type");
+  stmt= mysql_simple_prepare(mysql, "SELECT @@storage_engine");
   check_stmt(stmt);
 
   rc= mysql_stmt_execute(stmt);
@@ -7258,7 +7258,7 @@ static void test_field_misc()
 
   mysql_stmt_close(stmt);
 
-  stmt= mysql_simple_prepare(mysql, "SELECT @@table_type");
+  stmt= mysql_simple_prepare(mysql, "SELECT @@storage_engine");
   check_stmt(stmt);
 
   result= mysql_stmt_result_metadata(stmt);
@@ -7271,7 +7271,7 @@ static void test_field_misc()
   DIE_UNLESS(1 == my_process_stmt_result(stmt));
 
   verify_prepare_field(result, 0,
-                       "@@table_type", "",   /* field and its org name */
+                       "@@storage_engine", "",   /* field and its org name */
                        mysql_get_server_version(mysql) <= 50000 ?
                        MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING,
                        "", "",              /* table and its org name */
@@ -8292,7 +8292,7 @@ static void test_fetch_seek()
 
   myquery(rc);
 
-  rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))");
+  rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10), c3 timestamp)");
   myquery(rc);
 
   rc= mysql_query(mysql, "insert into t1(c2) values('venu'), ('mysql'), ('open'), ('source')");
Thread
bk commit into 5.2 tree (istruewing:1.2506)ingo16 Jun