diff --git a/Docs/Makefile.am b/Docs/Makefile.am
index ce5fbd263c63b16a8fb5c700ef06dcb1c816c026..4f61d93c0e5061a03368163f358193b6b3424365 100644
--- a/Docs/Makefile.am
+++ b/Docs/Makefile.am
@@ -99,7 +99,7 @@ nusphere.pdf: manual.texi
 manual_a4.ps:	manual.texi include.texi
 	TEXINPUTS=$(srcdir):$$TEXINPUTS \
 	  MAKEINFO='$(MAKEINFO) -I $(srcdir)' \
-	    $(TEXI2DVI) --batch --texinfo '@afourpaper' $<
+	    $(TEXI2DVI) --batch --texinfo --quiet '@afourpaper' $<
 	$(DVIPS) -t a4 manual.dvi -o $@
 	touch $@
 
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 095cc68d48dde24391fbfe4f353035bf90f0104d..403e232b1a77c46d5bd3a3e963360c86f1a80540 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -713,7 +713,7 @@ Some Common Errors When Using MySQL
 
 Solving Some Common Problems with MySQL
 
-* Log Replication::             Database replication with  update log
+* Log Replication::             Database replication with update log
 * Backup::                      Database backups
 * Update log::                  The update log
 * Binary log::                  The binary log
@@ -846,6 +846,7 @@ Changes in release 4.0.x (Development; Alpha)
 
 Changes in release 3.23.x  (Recommended; Gamma)
 
+* News-3.23.31::                
 * News-3.23.30::                Changes in release 3.23.30
 * News-3.23.29::                Changes in release 3.23.29
 * News-3.23.28::                Changes in release 3.23.28
@@ -9284,6 +9285,15 @@ The @code{mysql.server} script uses the following variables:
 @code{user}, @code{datadir}, @code{basedir}, @code{bindir}, and
 @code{pid-file}.
 
+The following table shows which option sections each of the startup script
+uses:
+
+@multitable @columnfractions .20 .80
+@item @code{mysqld} @tab @code{mysqld} and @code{server}
+@item @code{mysql.server} @tab @code{mysql.server}, @code{mysqld} and @code{server}
+@item @code{safe_mysqld} @tab @code{mysql.server}, @code{mysqld} and @code{server}
+@end multitable
+
 @xref{Option files}.
 
 @findex command-line options
@@ -20146,6 +20156,7 @@ below, though the format and numbers probably differ:
 | Sort_scan                | 5298       |
 | Threads_cached           | 0          |
 | Threads_connected        | 1          |
+| Threads_created          | 30022      |
 | Threads_running          | 1          |
 | Uptime                   | 39613      |
 +--------------------------+------------+
@@ -20213,6 +20224,7 @@ open by the slave thread
 @item @code{Sort_scan}  @tab Number of sorts that where done by scanning the table.
 @item @code{Threads_cached} @tab Number of threads in the thread cache.
 @item @code{Threads_connected} @tab Number of currently open connections.
+@item @code{Threads_created} @tab Number of threads created to handle connections.
 @item @code{Threads_running} @tab Number of threads that are not sleeping.
 @item @code{Uptime} @tab How many seconds the server has been up.
 @end multitable
@@ -20237,6 +20249,9 @@ your @code{mysqld} @code{sort_buffer} variables is probably too small.
 @item
 @code{Created_tmp_files} doesn't count the files needed to handle temporary
 tables.
+@item
+If @code{Threads_created} is big, you may want to increase the
+@code{thread_cache_size} variable.
 @end itemize
 
 @node SHOW VARIABLES, SHOW LOGS, SHOW STATUS, SHOW
@@ -20706,7 +20721,9 @@ threads are first taken from the cache, and only when the cache is empty
 is a new thread created.  This variable can be increased to improve
 performance if you have a lot of new connections. (Normally this doesn't
 give a notable performance improvement if you have a good
-thread implementation.)
+thread implementation.)  By examing the difference between
+the @code{Connections} and @code{Threads_created} you can see how efficient
+the current thread cache is for you.
 
 @item @code{thread_concurrency}
 On Solaris, @code{mysqld} will call @code{thr_setconcurrency()} with
@@ -28438,8 +28455,8 @@ information to a log file.
 Normally one should never edit the @code{safe_mysqld} script, but
 instead put the options to @code{safe_mysqld} in the
 @code{[safe_mysqld]} section in the @code{my.cnf}
-file. @code{safe_mysqld} will read all options from the @code{[mysqld]}
-and @code{[safe_mysqld]} sections from the option files.
+file. @code{safe_mysqld} will read all options from the @code{[mysqld]},
+@code{[server]} and @code{[safe_mysqld]} sections from the option files.
 @xref{Option files}.
 
 Note that all options on the command line to @code{safe_mysqld} are passed
@@ -30801,10 +30818,13 @@ print some informational statistics, too.
 @node Repair, Optimization, Check, Crash recovery
 @subsection How to Repair Tables
 
-In the following section we only talk about using @code{myisamchk} on @code{MyISAM}
-tables (extensions @code{.MYI} and @code{.MYD}).  If you are using
-@code{ISAM} tables (extensions @code{.ISM} and @code{.ISD}), you should use
-@code{isamchk} instead.
+In the following section we only talk about using @code{myisamchk} on
+@code{MyISAM} tables (extensions @code{.MYI} and @code{.MYD}).  If you
+are using @code{ISAM} tables (extensions @code{.ISM} and @code{.ISD}),
+you should use @code{isamchk} instead.
+
+Starting with @strong{MySQL} Version 3.23.14, you can repair MyISAM
+tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
 
 The symptoms of a corrupted table include queries that abort unexpectedly
 and observable errors such as these:
@@ -30815,11 +30835,45 @@ and observable errors such as these:
 @item
 Can't find file @file{tbl_name.MYI} (Errcode: ###)
 @item
-Got error ### from table handler (Error 135 is an exception in this case)
-@item
 Unexpected end of file
 @item
 Record file is crashed
+@item
+Got error ### from table handler
+
+To get more information about the error you can do @code{perror
+###}. Here is the most common errors that indicates a problem with the
+table:
+
+@example
+shell> perror 126 127 132 134 135 136 141 144 145
+126 = Index file is crashed / Wrong file format
+127 = Record-file is crashed
+132 = Old database file
+134 = Record was already deleted (or record file crashed)
+135 = No more room in record file
+136 = No more room in index file
+141 = Duplicate unique key or constraint on write or update
+144 = Table is crashed and last repair failed
+145 = Table was marked as crashed and should be repaired
+@end example
+
+Note that error 135, no more room in record file, is not a error that
+can be fixed by a simple repair. In this case you have to do:
+
+@itemize @bullet
+@item
+@code{CREATE TABLE ...} for the table with proper @code{MAX_ROWS} and
+@code{AVG_ROW_LENGTH} values. @xref{CREATE TABLE}.
+@item
+Copy the data over from the old table with @code{INSERT INTO new_table
+SELECT * from old_table}.
+@item
+Rename the old table to the new table:
+@code{RENAME old_table to tmp_table, new_table to old_table}
+@item
+Delete the old table: @code{DROP TABLE tmp_table}.
+@end itemize
 @end itemize
 
 In these cases, you must repair your tables. @code{myisamchk}
@@ -40035,6 +40089,7 @@ version.  The replication and BerkeleyDB code is still under development,
 though, so Version 3.23 is not released as a stable version yet.
 
 @menu
+* News-3.23.31::                Changes in release 3.23.31
 * News-3.23.30::                Changes in release 3.23.30
 * News-3.23.29::                Changes in release 3.23.29
 * News-3.23.28::                Changes in release 3.23.28
@@ -40068,7 +40123,23 @@ though, so Version 3.23 is not released as a stable version yet.
 * News-3.23.0::                 Changes in release 3.23.0
 @end menu
 
-@node News-3.23.30, News-3.23.29, News-3.23.x, News-3.23.x
+@node News-3.23.31, News-3.23.30, News-3.23.x, News-3.23.x
+@appendixsubsec Changes in release 3.23.31
+@itemize @bullet
+@item
+Fixed bug in @@code{MyISAM} when deleting keys with possible @code{NULL}
+values, but the first key-column was not a prefix-compressed text column.
+@item
+Fixed that @code{mysql.server} reads the @code{mysql.server} option section
+instead of @code{mysql_server}.
+@item
+Fixed that @code{safe_mysqld} and @code{mysql.server} also reads the
+@code{server} option section.
+@item
+Added @code{Threads_created} status variable to @code{mysqld}.
+@end itemize
+
+@node News-3.23.30, News-3.23.29, News-3.23.31, News-3.23.x
 @appendixsubsec Changes in release 3.23.30
 @itemize @bullet
 @item
diff --git a/acinclude.m4 b/acinclude.m4
index c0b7222dd0bbba7dac15b406a59c2a1a71361014..5f3020264fe355fb39e3e8de38e4c2ce9d4b1a14 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -823,7 +823,7 @@ AC_DEFUN([MYSQL_CHECK_BDB_VERSION], [
     bdb_version_ok=yes
   # This is ugly, but about as good as it can get
   elif test $db_major -eq 3 && test $db_minor -eq 2 && test $db_patch -eq 3 &&\
-       grep 'DB_VERSION_STRING\>.*g: (' [$1] > /dev/null
+       grep 'DB_VERSION_STRING.*g: ' [$1] > /dev/null
   then
     bdb_version_ok=yes
   else
diff --git a/client/mysqltest.c b/client/mysqltest.c
index ef6fae184f3fc0108dbe2c96d4e42dbb42ca981e..d2efead34133312a91c7f0a0b0e718dc8e9ae717 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -23,16 +23,37 @@
  *   Monty
  **/
 
-#define MTEST_VERSION "1.4"
-
-#include "global.h"
-#include "my_sys.h"
-#include "m_string.h"
-#include "mysql.h"
-#include "mysql_version.h"
-#include "my_config.h"
-#include "my_dir.h"
-#include "mysqld_error.h"
+/**********************************************************************
+  TODO:
+
+- Print also the queries that returns a result to the log file;  This makes
+  it much easier to find out what's wrong.
+
+- Do comparison line by line, instead of doing a full comparison of
+  the text file.  This will save space as we don't need to keep many
+  results in memory.  It will also make it possible to do simple
+  'comparison' fixes like accepting the result even if a float differed
+  in the last decimals.
+
+- Don't buffer lines from the test that you don't expect to need
+  again.
+
+- Change 'read_line' to be faster by using the readline.cc code;
+  We can do better than calling feof() for each character!
+
+**********************************************************************/
+
+#define MTEST_VERSION "1.5"
+
+#include <global.h>
+#include <my_sys.h>
+#include <m_string.h>
+#include <mysql.h>
+#include <mysql_version.h>
+#include <m_ctype.h>
+#include <my_config.h>
+#include <my_dir.h>
+#include <mysqld_error.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <getopt.h>
@@ -56,6 +77,7 @@ const char* user = 0, *host = 0, *unix_sock = 0;
 int port = 0;
 static uint start_lineno, *lineno;
 
+static char **default_argv;
 static const char *load_default_groups[]= { "mysqltest","client",0 };
 
 FILE* file_stack[MAX_INCLUDE_DEPTH];
@@ -104,9 +126,9 @@ struct connection cons[MAX_CONS];
 struct connection* cur_con, *next_con, *cons_end;
 
 /* this should really be called command */
-struct query
+struct st_query
 {
-  char q[MAX_QUERY];
+  char *query, *first_argument;
   int first_word_len;
   my_bool abort_on_error, require_file;
   uint expected_errno;
@@ -127,60 +149,83 @@ const char *command_names[] = {
 TYPELIB command_typelib= {array_elements(command_names),"",
 			  command_names};
 
+DYNAMIC_STRING ds_res;
 
-#define DS_CHUNK   16384
-
-typedef struct dyn_string
-{
-  char* str;
-  int len,max_len;
-} DYN_STRING;
-
-DYN_STRING ds_res;
-
-void dyn_string_init(DYN_STRING* ds);
-void dyn_string_end(DYN_STRING* ds);
-void dyn_string_append(DYN_STRING* ds, const char* str, int len);
-int dyn_string_cmp(DYN_STRING* ds, const char* fname);
+int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname);
 void reject_dump(const char* record_file, char* buf, int size);
 
-int close_connection(struct query* q);
+int close_connection(struct st_query* q);
 VAR* var_get(char* var_name, char* var_name_end, int raw);
 
 static void close_cons()
 {
-  for(--next_con; next_con >= cons; --next_con)
-    {
-      mysql_close(&next_con->mysql);
-      my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR));
-    }
+  DBUG_ENTER("close_cons");
+  for (--next_con; next_con >= cons; --next_con)
+  {
+    mysql_close(&next_con->mysql);
+    my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR));
+  }
+  DBUG_VOID_RETURN;
+}
+
+static void close_files()
+{
+  do
+  {
+    if (*cur_file != stdin)
+      my_fclose(*cur_file,MYF(0));
+  } while (cur_file-- != file_stack);
+}
+
+static void free_used_memory()
+{
+  uint i;
+  DBUG_ENTER("free_used_memory");
+  close_cons();
+  close_files();
+  for (i=0 ; i < q_lines.elements ; i++)
+  {
+    struct st_query **q= dynamic_element(&q_lines, i, struct st_query**);
+    my_free((gptr) (*q)->query,MYF(MY_ALLOW_ZERO_PTR));
+    my_free((gptr) (*q),MYF(0));
+  }
+  delete_dynamic(&q_lines);
+  dynstr_free(&ds_res);
+  my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
+  free_defaults(default_argv);
+  my_end(MY_CHECK_ERROR);
+  DBUG_VOID_RETURN;
 }
 
 static void die(const char* fmt, ...)
 {
   va_list args;
+  DBUG_ENTER("die");
   va_start(args, fmt);
-  fprintf(stderr, "%s: ", my_progname);
-  vfprintf(stderr, fmt, args);
-  fprintf(stderr, "\n");
+  if (fmt)
+  {
+    fprintf(stderr, "%s: ", my_progname);
+    vfprintf(stderr, fmt, args);
+    fprintf(stderr, "\n");
+  }
   va_end(args);
-  close_cons();
+  free_used_memory();
   exit(1);
 }
 
 static void abort_not_supported_test()
 {
+  DBUG_ENTER("abort_not_supported_test");
   fprintf(stderr, "This test is not supported by this installation\n");
   if (!silent)
     printf("skipped\n");
-  close_cons();
+  free_used_memory();
   exit(2);
 }
 
 static void verbose_msg(const char* fmt, ...)
 {
   va_list args;
-
   if (!verbose) return;
 
   va_start(args, fmt);
@@ -208,70 +253,32 @@ int hex_val(int c)
     return -1;
 }
 
-void dyn_string_init(DYN_STRING* ds)
-{
-  if (!(ds->str = (char*)my_malloc(DS_CHUNK, MYF(0))))
-    die("Out of memory");
-  ds->len = 0;
-  ds->max_len = DS_CHUNK;
-}
-
-void dyn_string_end(DYN_STRING* ds)
-{
-  my_free(ds->str, MYF(0));
-  memset(ds, 0, sizeof(*ds)); /* safety */
-}
-
-void dyn_string_append(DYN_STRING* ds, const char* str, int len)
-{
-  int new_len;
-  if (!len)
-    len = strlen(str);
-  new_len = ds->len + len;
-  if (new_len > ds->max_len)
-    {
-      int new_alloc_len = (new_len & ~(DS_CHUNK-1)) + DS_CHUNK;
-      char* tmp = (char*) my_malloc(new_alloc_len, MYF(0));
-      if (!tmp)
-	die("Out of memory");
-      memcpy(tmp, ds->str, ds->len);
-      memcpy(tmp + ds->len, str, len);
-      my_free((gptr)ds->str, MYF(0));
-      ds->str = tmp;
-      ds->len = new_len;
-      ds->max_len = new_alloc_len;
-    }
-  else
-    {
-      memcpy(ds->str + ds->len, str, len);
-      ds->len += len;
-    }
-}
-
-
-int dyn_string_cmp(DYN_STRING* ds, const char* fname)
+int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
 {
   MY_STAT stat_info;
   char *tmp;
   int res;
   int fd;
+  DBUG_ENTER("dyn_string_cmp");
+
   if (!my_stat(fname, &stat_info, MYF(MY_WME)))
-    die("Could not stat %s: errno =%d", fname, errno);
-  if (stat_info.st_size != ds->len)
-    return 2;
-  if (!(tmp = (char*) my_malloc(ds->len, MYF(0))))
-    die("Out of memory");
+    die(NullS);
+  if (stat_info.st_size != ds->length)
+    DBUG_RETURN(2);
+  if (!(tmp = (char*) my_malloc(ds->length, MYF(MY_WME))))
+    die(NullS);
   if ((fd = my_open(fname, O_RDONLY, MYF(MY_WME))) < 0)
-    die("Could not open %s: errno = %d", fname, errno);
+    die(NullS);
   if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP)))
-    die("read failed");
+    die(NullS);
   res = (memcmp(tmp, ds->str, stat_info.st_size)) ?  1 : 0;
-  my_free((gptr)tmp, MYF(0));
-  my_close(fd, MYF(0));
-  return res;
+  my_free((gptr) tmp, MYF(0));
+  my_close(fd, MYF(MY_WME));
+
+  DBUG_RETURN(res);
 }
 
-static int check_result(DYN_STRING* ds, const char* fname,
+static int check_result(DYNAMIC_STRING* ds, const char* fname,
 			my_bool require_option)
 {
   int error = 0;
@@ -295,7 +302,7 @@ static int check_result(DYN_STRING* ds, const char* fname,
     die("Unknown error code from dyn_string_cmp()");
   }
   if (error)
-    reject_dump(fname, ds->str, ds->len);
+    reject_dump(fname, ds->str, ds->length);
   return error;
 }
 
@@ -364,24 +371,23 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
 
 int open_file(const char* name)
 {
-  if (*cur_file && ++cur_file == file_stack_end)
+  if (*cur_file && cur_file == file_stack_end)
     die("Source directives are nesting too deep");
-  if (!(*cur_file = my_fopen(name, O_RDONLY, MYF(MY_WME))))
-    die("Could not read '%s': errno %d\n", name, errno);
+  if (!(*(cur_file+1) = my_fopen(name, O_RDONLY, MYF(MY_WME))))
+    die(NullS);
+  cur_file++;
   *++lineno=1;
 
   return 0;
 }
 
-int do_source(struct query* q)
+int do_source(struct st_query* q)
 {
-  char* p, *name;
-  p = (char*)q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
+  char* p=q->first_argument, *name;
   if (!*p)
     die("Missing file name in source\n");
   name = p;
-  while(*p && !isspace(*p))
+  while (*p && !isspace(*p))
     p++;
   *p = 0;
 
@@ -413,36 +419,30 @@ int eval_expr(VAR* v, char* p, char* p_end)
   return 1;
 }
 
-int do_inc(struct query* q)
+int do_inc(struct st_query* q)
 {
-  char* p;
+  char* p=q->first_argument;
   VAR* v;
-  p = (char*)q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
   v = var_get(p, 0, 1);
   v->int_val++;
   v->int_dirty = 1;
   return 0;
 }
 
-int do_dec(struct query* q)
+int do_dec(struct st_query* q)
 {
-  char* p;
+  char* p=q->first_argument;
   VAR* v;
-  p = (char*)q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
   v = var_get(p, 0, 1);
   v->int_val--;
   v->int_dirty = 1;
   return 0;
 }
 
-int do_system(struct query* q)
+int do_system(struct st_query* q)
 {
-  char* p;
+  char* p=q->first_argument;
   VAR v;
-  p = (char*)q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
   eval_expr(&v, p, 0); /* NULL terminated */
   if (v.str_val_len > 1)
     {
@@ -457,12 +457,10 @@ int do_system(struct query* q)
   return 0;
 }
 
-int do_echo(struct query* q)
+int do_echo(struct st_query* q)
 {
-  char* p;
+  char* p=q->first_argument;
   VAR v;
-  p = (char*)q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
   eval_expr(&v, p, 0); /* NULL terminated */
   if (v.str_val_len > 1)
     {
@@ -473,11 +471,10 @@ int do_echo(struct query* q)
   return 0;
 }
 
-int do_let(struct query* q)
+int do_let(struct st_query* q)
 {
-  char* p, *var_name, *var_name_end, *var_val_start;
-  p = (char*)q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
+  char* p=q->first_argument;
+  char *var_name, *var_name_end, *var_val_start;
   if (!*p)
     die("Missing variable name in let\n");
   var_name = p;
@@ -493,12 +490,11 @@ int do_let(struct query* q)
   return var_set(var_name, var_name_end, var_val_start, p);
 }
 
-int do_sleep(struct query* q)
+int do_sleep(struct st_query* q)
 {
-  char *p;
+  char* p=q->first_argument;
   struct timeval t;
   int dec_mul = 1000000;
-  p = (char*)q->q + q->first_word_len;
   while(*p && isspace(*p)) p++;
   if (!*p)
     die("Missing argument in sleep\n");
@@ -534,10 +530,9 @@ int do_sleep(struct query* q)
   return select(0,0,0,0, &t);
 }
 
-static void get_file_name(char *filename, struct query* q)
+static void get_file_name(char *filename, struct st_query* q)
 {
-  char *p = (char*) q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
+  char* p=q->first_argument;
   strnmov(filename, p, FN_REFLEN);
   /* Remove end space */
   while (p > filename && isspace(p[-1]))
@@ -546,12 +541,13 @@ static void get_file_name(char *filename, struct query* q)
 }
 
 
-int select_connection(struct query* q)
+int select_connection(struct st_query* q)
 {
-  char* p, *name;
+  char* p=q->first_argument, *name;
   struct connection *con;
-  p = (char*)q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
+  DBUG_ENTER("select_connection");
+  DBUG_PRINT("enter",("name: '%s'",p));
+
   if (!*p)
     die("Missing connection name in connect\n");
   name = p;
@@ -559,23 +555,25 @@ int select_connection(struct query* q)
     p++;
   *p = 0;
 
-  for(con = cons; con < next_con; con++)
+  for (con = cons; con < next_con; con++)
+  {
     if (!strcmp(con->name, name))
-      {
-	cur_con = con;
-	return 0;
-      }
-
+    {
+      cur_con = con;
+      DBUG_RETURN(0);
+    }
+  }
   die("connection '%s' not found in connection pool", name);
-  return 1;
+  DBUG_RETURN(1);				/* Never reached */
 }
 
-int close_connection(struct query* q)
+int close_connection(struct st_query* q)
 {
-  char* p, *name;
+  char* p=q->first_argument, *name;
   struct connection *con;
-  p = (char*)q->q + q->first_word_len;
-  while(*p && isspace(*p)) p++;
+  DBUG_ENTER("close_connection");
+  DBUG_PRINT("enter",("name: '%s'",p));
+
   if (!*p)
     die("Missing connection name in connect\n");
   name = p;
@@ -584,14 +582,15 @@ int close_connection(struct query* q)
   *p = 0;
 
   for(con = cons; con < next_con; con++)
+  {
     if (!strcmp(con->name, name))
-      {
-	mysql_close(&con->mysql);
-	return 0;
-      }
-
+    {
+      mysql_close(&con->mysql);
+      DBUG_RETURN(0);
+    }
+  }
   die("connection '%s' not found in connection pool", name);
-  return 1;
+  DBUG_RETURN(1);				/* Never reached */
 }
 
 
@@ -600,8 +599,10 @@ int close_connection(struct query* q)
    a comma, a space or ) belongs to the argument. space is a chopper, comma or
    ) are delimiters/terminators
 */
+
 char* safe_get_param(char* str, char** arg, const char* msg)
 {
+  DBUG_ENTER("safe_get_param");
   while(*str && isspace(*str)) str++;
   *arg = str;
   while(*str && *str != ',' && *str != ')')
@@ -613,21 +614,21 @@ char* safe_get_param(char* str, char** arg, const char* msg)
     die(msg);
 
   *str++ = 0;
-  return str;
+  DBUG_RETURN(str);
 }
 
-int do_connect(struct query* q)
+
+int do_connect(struct st_query* q)
 {
   char* con_name, *con_user,*con_pass, *con_host, *con_port_str,
     *con_db, *con_sock;
-  char* p;
+  char* p=q->first_argument;
   char buff[FN_REFLEN];
+  DBUG_ENTER("do_connect");
+  DBUG_PRINT("enter",("connect: %s",p));
 
-  p = q->q + q->first_word_len;
-
-  while(*p && isspace(*p)) p++;
   if (*p != '(')
-    die("Syntax error in connect - expeected '(' found '%c'", *p);
+    die("Syntax error in connect - expected '(' found '%c'", *p);
   p++;
   p = safe_get_param(p, &con_name, "missing connection name");
   p = safe_get_param(p, &con_host, "missing connection host");
@@ -648,13 +649,13 @@ int do_connect(struct query* q)
 	mysql_error(&next_con->mysql));
 
   if (!(next_con->name = my_strdup(con_name, MYF(MY_WME))))
-    die("Out of memory");
+    die(NullS);
   cur_con = next_con++;
 
-  return 0;
+  DBUG_RETURN(0);
 }
 
-int do_done(struct query* q)
+int do_done(struct st_query* q)
 {
   q->type = Q_END_BLOCK;
   if (cur_block == block_stack)
@@ -670,9 +671,9 @@ int do_done(struct query* q)
   return 0;
 }
 
-int do_while(struct query* q)
+int do_while(struct st_query* q)
 {
-  char *p = q->q + q->first_word_len;
+  char* p=q->first_argument;
   char* expr_start, *expr_end;
   VAR v;
   if (cur_block == block_stack_end)
@@ -767,7 +768,8 @@ int read_line(char* buf, int size)
     c = fgetc(*cur_file);
     if (feof(*cur_file))
     {
-      my_fclose(*cur_file,MYF(0));
+      if ((*cur_file) != stdin)
+	my_fclose(*cur_file,MYF(0));
 
       if (cur_file == file_stack)
 	return 1;
@@ -883,19 +885,19 @@ int read_line(char* buf, int size)
 
 static char read_query_buf[MAX_QUERY];
 
-int read_query(struct query** q_ptr)
+int read_query(struct st_query** q_ptr)
 {
-  char* p = read_query_buf, * p1 ;
+  char *p = read_query_buf, * p1 ;
   int c, expected_errno;
-  struct query* q;
+  struct st_query* q;
 
   if (parser.current_line < parser.read_lines)
   {
-    get_dynamic(&q_lines, (gptr)q_ptr, parser.current_line) ;
+    get_dynamic(&q_lines, (gptr) q_ptr, parser.current_line) ;
     return 0;
   }
-  if (!(*q_ptr=q=(struct query*)my_malloc(sizeof(*q), MYF(MY_WME)))
-     || insert_dynamic(&q_lines, (gptr)&q)
+  if (!(*q_ptr=q=(struct st_query*) my_malloc(sizeof(*q), MYF(MY_WME)))
+     || insert_dynamic(&q_lines, (gptr) &q)
      )
     die("Out of memory");
 
@@ -905,6 +907,7 @@ int read_query(struct query** q_ptr)
   q->first_word_len = 0;
   q->expected_errno = 0;
   q->type = Q_UNKNOWN;
+  q->query=0;
   if (read_line(read_query_buf, sizeof(read_query_buf)))
     return 1;
 
@@ -944,20 +947,24 @@ int read_query(struct query** q_ptr)
       *p1 = 0;
     }
   }
-  while(*p && isspace(*p)) p++;
-  /* Calculate first word */
-  p1 = q->q;
-  while(*p && !isspace(*p))
-    *p1++ = *p++;
+  while (*p && isspace(*p)) p++;
+  if (!(q->query=my_strdup(p,MYF(MY_WME))))
+    die(NullS);
+
+  /* Calculate first word and first argument */
+  for (p=q->query; *p && !isspace(*p) ; p++) ;
+  q->first_word_len = (uint) (p - q->query);
+  while (*p && isspace(*p)) p++;
+  q->first_argument=p;
 
-  q->first_word_len = p1 - q->q;
-  strmov(p1, p);
   parser.read_lines++;
   return 0;
 }
 
+
 struct option long_options[] =
 {
+  {"debug",    optional_argument, 0, '#'},
   {"database", required_argument, 0, 'D'},
   {"help", no_argument, 0, '?'},
   {"host", required_argument, 0, 'h'},
@@ -991,7 +998,12 @@ void usage()
   printf("Runs a test against the mysql server and compares output with a results file.\n\n");
   printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname);
   printf("\n\
-  -?, --help               Display this help and exit.\n\
+  -?, --help               Display this help and exit.\n");
+#ifndef DBUG_OFF
+  puts("\
+  -#, --debug=[...]        Output debug log. Often this is 'd:t:o,filename`");
+#endif
+  printf("\
   -h, --host=...           Connect to host.\n\
   -u, --user=...           User for login.\n\
   -p[password], --password[=...]\n\
@@ -1015,65 +1027,68 @@ int parse_args(int argc, char **argv)
   my_bool tty_password=0;
 
   load_defaults("my",load_default_groups,&argc,&argv);
+  default_argv= argv;
 
-  while((c = getopt_long(argc, argv, "h:p::u:P:D:S:R:t:T:?rvVq",
+  while((c = getopt_long(argc, argv, "h:p::u:P:D:S:R:t:T:#:?rvVq",
 			 long_options, &option_index)) != EOF)
     {
-      switch(c)
+      switch(c)	{
+      case '#':
+	DBUG_PUSH(optarg ? optarg : "d:t:o,/tmp/mysqltest.trace");
+	break;
+      case 'v':
+	verbose = 1;
+	break;
+      case 'r':
+	record = 1;
+	break;
+      case 'u':
+	user = optarg;
+	break;
+      case 'R':
+	result_file = optarg;
+	break;
+      case 'p':
+	if (optarg)
 	{
-	case 'v':
-	  verbose = 1;
-	  break;
-	case 'r':
-	  record = 1;
-	  break;
-	case 'u':
-	  user = optarg;
-	  break;
-	case 'R':
-	  result_file = optarg;
-	  break;
-	case 'p':
-	  if (optarg)
-	    {
-	      my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
-	      pass=my_strdup(optarg,MYF(MY_FAE));
-	      while (*optarg) *optarg++= 'x';		/* Destroy argument */
-	    }
-	  else
-	    tty_password=1;
-	  break;
-	case 'P':
-	  port = atoi(optarg);
-	  break;
-	case 'S':
-	  unix_sock = optarg;
-	  break;
-	case 'D':
-	  db = optarg;
-	  break;
-	case 'h':
-	  host = optarg;
-	  break;
-	case 'q':
-	  silent = 1;
-	  break;
-	case 't':
-	  strnmov(TMPDIR,optarg,sizeof(TMPDIR));
-	  break;
-	case 'T':
-	  opt_sleep=atoi(optarg);
-	  break;
-	case 'V':
-	  print_version();
-	  exit(0);
-	case '?':
-	  usage();
-	  exit(0);
-	default:
-	  usage();
-	  exit(1);
+	  my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
+	  pass=my_strdup(optarg,MYF(MY_FAE));
+	  while (*optarg) *optarg++= 'x';		/* Destroy argument */
 	}
+	else
+	  tty_password=1;
+	break;
+      case 'P':
+	port = atoi(optarg);
+	break;
+      case 'S':
+	unix_sock = optarg;
+	break;
+      case 'D':
+	db = optarg;
+	break;
+      case 'h':
+	host = optarg;
+	break;
+      case 'q':
+	silent = 1;
+	break;
+      case 't':
+	strnmov(TMPDIR,optarg,sizeof(TMPDIR));
+	break;
+      case 'T':
+	opt_sleep=atoi(optarg);
+	break;
+      case 'V':
+	print_version();
+	exit(0);
+      case '?':
+	usage();
+	exit(1);				/* Unknown option */
+      default:
+	usage();
+	exit(1);
+      }
     }
 
   argc-=optind;
@@ -1118,7 +1133,7 @@ void reject_dump(const char* record_file, char* buf, int size)
 }
 
 
-int run_query(MYSQL* mysql, struct query* q)
+int run_query(MYSQL* mysql, struct st_query* q)
 {
   MYSQL_RES* res = 0;
   MYSQL_FIELD* fields;
@@ -1127,21 +1142,24 @@ int run_query(MYSQL* mysql, struct query* q)
   unsigned long* lengths;
   char* val;
   int len;
-  DYN_STRING *ds = &ds_res;
-  DYN_STRING ds_tmp;
-  dyn_string_init(&ds_tmp);
+  DYNAMIC_STRING *ds;
+  DYNAMIC_STRING ds_tmp;
+  DBUG_ENTER("run_query");
 
   if ( q->record_file[0])
   {
+    init_dynamic_string(&ds_tmp, "", 16384, 65536);
     ds = &ds_tmp;
   }
+  else
+    ds= &ds_res;
 
-  if (mysql_query(mysql, q->q))
+  if (mysql_query(mysql, q->query))
   {
     if (q->require_file)
       abort_not_supported_test();
     if (q->abort_on_error)
-      die("At line %u: query '%s' failed: %d: %s", start_lineno, q->q,
+      die("At line %u: query '%s' failed: %d: %s", start_lineno, q->query,
 	  mysql_errno(mysql), mysql_error(mysql));
     else
     {
@@ -1150,11 +1168,11 @@ int run_query(MYSQL* mysql, struct query* q)
 	error = (q->expected_errno != mysql_errno(mysql));
 	if (error)
 	  verbose_msg("query '%s' failed with wrong errno\
- %d instead of %d", q->q, mysql_errno(mysql), q->expected_errno);
+ %d instead of %d", q->query, mysql_errno(mysql), q->expected_errno);
 	goto end;
       }
 
-      verbose_msg("query '%s' failed: %d: %s", q->q, mysql_errno(mysql),
+      verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql),
 		  mysql_error(mysql));
       /* if we do not abort on error, failure to run the query does
 	 not fail the whole test case
@@ -1167,7 +1185,7 @@ int run_query(MYSQL* mysql, struct query* q)
   {
     error = 1;
     verbose_msg("query '%s' succeeded - should have failed with errno %d",
-		q->q, q->expected_errno);
+		q->query, q->expected_errno);
     goto end;
   }
 
@@ -1178,10 +1196,10 @@ int run_query(MYSQL* mysql, struct query* q)
       abort_not_supported_test();
     if (q->abort_on_error)
       die("At line %u: Failed in mysql_store_result for query '%s' (%d)",
-	  start_lineno, q->q, mysql_errno(mysql));
+	  start_lineno, q->query, mysql_errno(mysql));
     else
     {
-      verbose_msg("failed in mysql_store_result for query '%s' (%d)", q->q,
+      verbose_msg("failed in mysql_store_result for query '%s' (%d)", q->query,
 		  mysql_errno(mysql));
       error = 1;
       goto end;
@@ -1195,11 +1213,11 @@ int run_query(MYSQL* mysql, struct query* q)
   for( i = 0; i < num_fields; i++)
   {
     if (i)
-      dyn_string_append(ds, "\t", 1);
-    dyn_string_append(ds, fields[i].name, 0);
+      dynstr_append_mem(ds, "\t", 1);
+    dynstr_append(ds, fields[i].name);
   }
 
-  dyn_string_append(ds, "\n", 1);
+  dynstr_append_mem(ds, "\n", 1);
 
 
   while((row = mysql_fetch_row(res)))
@@ -1217,11 +1235,11 @@ int run_query(MYSQL* mysql, struct query* q)
       }
 
       if (i)
-	dyn_string_append(ds, "\t", 1);
-      dyn_string_append(ds, val, len);
+	dynstr_append_mem(ds, "\t", 1);
+      dynstr_append_mem(ds, val, len);
     }
 
-    dyn_string_append(ds, "\n", 1);
+    dynstr_append_mem(ds, "\n", 1);
   }
 
   if (record)
@@ -1229,7 +1247,7 @@ int run_query(MYSQL* mysql, struct query* q)
     if (!q->record_file[0] && !result_file)
       die("At line %u: Missing result file", start_lineno);
     if (!result_file)
-      str_to_file(q->record_file, ds->str, ds->len);
+      str_to_file(q->record_file, ds->str, ds->length);
   }
   else if (q->record_file[0])
   {
@@ -1238,15 +1256,17 @@ int run_query(MYSQL* mysql, struct query* q)
 
 end:
   if (res) mysql_free_result(res);
-  return error;
+  if (ds == &ds_tmp)
+    dynstr_free(&ds_tmp);
+  DBUG_RETURN(error);
 }
 
 
-void get_query_type(struct query* q)
+void get_query_type(struct st_query* q)
 {
   char save;
   uint type;
-  if (*q->q == '}')
+  if (*q->query == '}')
   {
     q->type = Q_END_BLOCK;
     return;
@@ -1254,26 +1274,25 @@ void get_query_type(struct query* q)
   if (q->type != Q_COMMENT_WITH_COMMAND)
     q->type = Q_QUERY;
 
-  save=q->q[q->first_word_len];
-  q->q[q->first_word_len]=0;
-  type=find_type(q->q, &command_typelib, 0);
-  q->q[q->first_word_len]=save;
+  save=q->query[q->first_word_len];
+  q->query[q->first_word_len]=0;
+  type=find_type(q->query, &command_typelib, 1);
+  q->query[q->first_word_len]=save;
   if (type > 0)
     q->type=type;				/* Found command */
 }
 
 
-
 int main(int argc, char** argv)
 {
   int error = 0;
-  struct query* q;
+  struct st_query* q;
   my_bool require_file=0;
   char save_file[FN_REFLEN];
+  MY_INIT(argv[0]);
+
   save_file[0]=0;
   TMPDIR[0]=0;
-
-  MY_INIT(argv[0]);
   memset(cons, 0, sizeof(cons));
   cons_end = cons + MAX_CONS;
   next_con = cons + 1;
@@ -1283,12 +1302,12 @@ int main(int argc, char** argv)
   file_stack_end = file_stack + MAX_INCLUDE_DEPTH;
   cur_file = file_stack;
   lineno   = lineno_stack;
-  init_dynamic_array(&q_lines, sizeof(struct query*), INIT_Q_LINES,
+  init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES,
 		     INIT_Q_LINES);
   memset(block_stack, 0, sizeof(block_stack));
   block_stack_end = block_stack + BLOCK_STACK_DEPTH;
   cur_block = block_stack;
-  dyn_string_init(&ds_res);
+  init_dynamic_string(&ds_res, "", 0, 65536);
   parse_args(argc, argv);
   if (!*cur_file)
     *cur_file = stdin;
@@ -1362,16 +1381,14 @@ int main(int argc, char** argv)
     parser.current_line += current_line_inc;
   }
 
-  close_cons();
-
-  if (result_file && ds_res.len)
+  if (result_file && ds_res.length)
   {
-    if(!record)
+    if (!record)
       error |= check_result(&ds_res, result_file, q->require_file);
     else
-      str_to_file(result_file, ds_res.str, ds_res.len);
+      str_to_file(result_file, ds_res.str, ds_res.length);
   }
-  dyn_string_end(&ds_res);
+  dynstr_free(&ds_res);
 
   if (!silent) {
     if(error)
@@ -1380,6 +1397,7 @@ int main(int argc, char** argv)
       printf("ok\n");
   }
 
+  free_used_memory();
   exit(error);
   return error;
 }
diff --git a/configure.in b/configure.in
index 4a0acd2ab0b7bda7105bb87c998a874661b5317d..e24297c5e390a8b8f1b6d4ec30a6809425fc3fc8 100644
--- a/configure.in
+++ b/configure.in
@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
 AC_INIT(sql/mysqld.cc)
 AC_CANONICAL_SYSTEM
 # The Docs Makefile.am parses this line!
-AM_INIT_AUTOMAKE(mysql, 3.23.30-gamma)
+AM_INIT_AUTOMAKE(mysql, 3.23.31)
 AM_CONFIG_HEADER(config.h)
 
 PROTOCOL_VERSION=10
diff --git a/include/my_sys.h b/include/my_sys.h
index fd1bf885c726f2e986f426615bd8217ff176052a..0f010fc71afc11def80ff0254a82a0f138b5bf2e 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -551,6 +551,8 @@ extern const char *get_type(TYPELIB *typelib,uint nr);
 extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
 				   uint init_alloc,uint alloc_increment);
 extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
+my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
+			  uint length);
 extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
 extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
 extern void dynstr_free(DYNAMIC_STRING *str);
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index 385739514688c8c1a27d03cb504786ad45db7a67..6de13f8f84afa50eccf29b9f818de3e8ec117912 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -274,86 +274,86 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
     }
     else
     {
-    /* Test if prefix compression */
-    if (keydef->flag & HA_PACK_KEY)
-    {
-      /* Can't use space_compression on number keys */
-      if ((keydef->seg[0].flag & HA_SPACE_PACK) &&
-	  keydef->seg[0].type == (int) HA_KEYTYPE_NUM)
-	keydef->seg[0].flag&= ~HA_SPACE_PACK;
-
-      /* Only use HA_PACK_KEY if the first segment is a variable length key */
-      if (!(keydef->seg[0].flag & (HA_SPACE_PACK | HA_BLOB_PART |
-				   HA_VAR_LENGTH)))
+      /* Test if prefix compression */
+      if (keydef->flag & HA_PACK_KEY)
       {
-	/* pack relative to previous key */
-	keydef->flag&= ~HA_PACK_KEY;
-	keydef->flag|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
+	/* Can't use space_compression on number keys */
+	if ((keydef->seg[0].flag & HA_SPACE_PACK) &&
+	    keydef->seg[0].type == (int) HA_KEYTYPE_NUM)
+	  keydef->seg[0].flag&= ~HA_SPACE_PACK;
+
+	/* Only use HA_PACK_KEY if the first segment is a variable length key */
+	if (!(keydef->seg[0].flag & (HA_SPACE_PACK | HA_BLOB_PART |
+				     HA_VAR_LENGTH)))
+	{
+	  /* pack relative to previous key */
+	  keydef->flag&= ~HA_PACK_KEY;
+	  keydef->flag|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
+	}
+	else
+	{
+	  keydef->seg[0].flag|=HA_PACK_KEY;	/* for easyer intern test */
+	  keydef->flag|=HA_VAR_LENGTH_KEY;
+	  options|=HA_OPTION_PACK_KEYS;		/* Using packed keys */
+	}
       }
-      else
-      {
-	keydef->seg[0].flag|=HA_PACK_KEY;	/* for easyer intern test */
-	keydef->flag|=HA_VAR_LENGTH_KEY;
+      if (keydef->flag & HA_BINARY_PACK_KEY)
 	options|=HA_OPTION_PACK_KEYS;		/* Using packed keys */
-      }
-    }
-    if (keydef->flag & HA_BINARY_PACK_KEY)
-      options|=HA_OPTION_PACK_KEYS;		/* Using packed keys */
 
-    if (keydef->flag & HA_AUTO_KEY)
-      share.base.auto_key=i+1;
-    for (j=0, keyseg=keydef->seg ; j < keydef->keysegs ; j++, keyseg++)
-    {
-      /* numbers are stored with high by first to make compression easier */
-      switch (keyseg->type) {
-      case HA_KEYTYPE_SHORT_INT:
-      case HA_KEYTYPE_LONG_INT:
-      case HA_KEYTYPE_FLOAT:
-      case HA_KEYTYPE_DOUBLE:
-      case HA_KEYTYPE_USHORT_INT:
-      case HA_KEYTYPE_ULONG_INT:
-      case HA_KEYTYPE_LONGLONG:
-      case HA_KEYTYPE_ULONGLONG:
-      case HA_KEYTYPE_INT24:
-      case HA_KEYTYPE_UINT24:
-      case HA_KEYTYPE_INT8:
-	keyseg->flag|= HA_SWAP_KEY;
-	/* fall through */
-      default:
-	break;
-      }
-      if (keyseg->flag & HA_SPACE_PACK)
+      if (keydef->flag & HA_AUTO_KEY)
+	share.base.auto_key=i+1;
+      for (j=0, keyseg=keydef->seg ; j < keydef->keysegs ; j++, keyseg++)
       {
-	keydef->flag |= HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY;
-	options|=HA_OPTION_PACK_KEYS;		/* Using packed keys */
-	length++;				/* At least one length byte */
-	min_key_length_skipp+=keyseg->length;
-	if (keyseg->length >= 255)
-	{					/* prefix may be 3 bytes */
-	  min_key_length_skipp+=2;
-	  length+=2;
+	/* numbers are stored with high by first to make compression easier */
+	switch (keyseg->type) {
+	case HA_KEYTYPE_SHORT_INT:
+	case HA_KEYTYPE_LONG_INT:
+	case HA_KEYTYPE_FLOAT:
+	case HA_KEYTYPE_DOUBLE:
+	case HA_KEYTYPE_USHORT_INT:
+	case HA_KEYTYPE_ULONG_INT:
+	case HA_KEYTYPE_LONGLONG:
+	case HA_KEYTYPE_ULONGLONG:
+	case HA_KEYTYPE_INT24:
+	case HA_KEYTYPE_UINT24:
+	case HA_KEYTYPE_INT8:
+	  keyseg->flag|= HA_SWAP_KEY;
+	  /* fall through */
+	default:
+	  break;
 	}
-      }
-      if (keyseg->flag & (HA_VAR_LENGTH | HA_BLOB_PART))
-      {
-	keydef->flag|=HA_VAR_LENGTH_KEY;
-	length++;				/* At least one length byte */
-	options|=HA_OPTION_PACK_KEYS;		/* Using packed keys */
-	min_key_length_skipp+=keyseg->length;
-	if (keyseg->length >= 255)
-	{					/* prefix may be 3 bytes */
-	  min_key_length_skipp+=2;
-	  length+=2;
+	if (keyseg->flag & HA_SPACE_PACK)
+	{
+	  keydef->flag |= HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY;
+	  options|=HA_OPTION_PACK_KEYS;		/* Using packed keys */
+	  length++;				/* At least one length byte */
+	  min_key_length_skipp+=keyseg->length;
+	  if (keyseg->length >= 255)
+	  {					/* prefix may be 3 bytes */
+	    min_key_length_skipp+=2;
+	    length+=2;
+	  }
+	}
+	if (keyseg->flag & (HA_VAR_LENGTH | HA_BLOB_PART))
+	{
+	  keydef->flag|=HA_VAR_LENGTH_KEY;
+	  length++;				/* At least one length byte */
+	  options|=HA_OPTION_PACK_KEYS;		/* Using packed keys */
+	  min_key_length_skipp+=keyseg->length;
+	  if (keyseg->length >= 255)
+	  {					/* prefix may be 3 bytes */
+	    min_key_length_skipp+=2;
+	    length+=2;
+	  }
+	}
+	key_length+= keyseg->length;
+	if (keyseg->null_bit)
+	{
+	  key_length++;
+	  options|=HA_OPTION_PACK_KEYS;
+	  keyseg->flag|=HA_NULL_PART;
+	  keydef->flag|=HA_VAR_LENGTH_KEY | HA_NULL_PART_KEY;
 	}
-      }
-      key_length+= keyseg->length;
-      if (keyseg->null_bit)
-      {
-	key_length++;
-	options|=HA_OPTION_PACK_KEYS;
-	keyseg->flag|=HA_NULL_PART;
-	keydef->flag|=HA_VAR_LENGTH_KEY | HA_NULL_PART_KEY;
-        }
       }
     } /* if HA_FULLTEXT */
     key_segs+=keydef->keysegs;
diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c
index f8bc37d8e201426677388d9e8d1069979c4a7d6c..445e745b07d622962bac0c45c61d6141cb56ad10 100644
--- a/myisam/mi_delete.c
+++ b/myisam/mi_delete.c
@@ -707,9 +707,10 @@ static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag,
       }
       else
       {
-	/* A variable length first key part */
-	if (*keypos & 128)			/* Next key is packed */
+	/* Check if a variable length first key part */
+	if ((keyinfo->seg->flag & HA_PACK_KEY) && *keypos & 128)
 	{
+	  /* Next key is packed against the current one */
 	  uint next_length,prev_length,prev_pack_length,lastkey_length,
 	    rest_length;
 	  if (keyinfo->seg[0].length >= 127)
diff --git a/myisam/mi_search.c b/myisam/mi_search.c
index 3ffc348ca5c8d10ea56f16212104bb44131e825b..7888e73b2355741e4b6785fd99346590c23b9e3a 100644
--- a/myisam/mi_search.c
+++ b/myisam/mi_search.c
@@ -830,6 +830,7 @@ uint _mi_get_static_key(register MI_KEYDEF *keyinfo, uint nod_flag,
 } /* _mi_get_static_key */
 
 
+/* Key with is packed against previous key or key with a NULL column */
 
 uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag,
 		      register uchar **page_pos, register uchar *key)
@@ -841,7 +842,6 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag,
   start_key=key;
   for (keyseg=keyinfo->seg ; keyseg->type ;keyseg++)
   {
-    /* First key part is always packed !*/
     if (keyseg->flag & HA_PACK_KEY)
     {
       /* key with length, packed to previous key */
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index cb463e338bb516044e9eb0a95ca7653f838d82fb..0e6f5927a3a0c48179bb2bf7e4a74a9718cbc550 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -200,7 +200,7 @@ static struct option long_options[] =
 
 static void print_version(void)
 {
-  printf("%s  Ver 1.39 for %s at %s\n",my_progname,SYSTEM_TYPE,
+  printf("%s  Ver 1.40 for %s at %s\n",my_progname,SYSTEM_TYPE,
 	 MACHINE_TYPE);
 }
 
@@ -995,6 +995,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, my_string name)
   {
     keyseg=keyinfo->seg;
     if (keyinfo->flag & HA_NOSAME) text="unique ";
+    else if (keyinfo->flag & HA_FULLTEXT) text="fulltext ";
     else text="multip.";
 
     pos=buff;
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index 65e4f395e756afa736687d97337f48bfdef79f4c..474e91ad2e7dc3a3302ea4d3842f034147c0ea6e 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -136,6 +136,7 @@ while test $# -gt 0; do
     --debug)
       EXTRA_MASTER_MYSQLD_OPT=--debug=d:t:O,$MYSQL_TMP_DIR/master.trace
       EXTRA_SLAVE_MYSQLD_OPT=--debug=d:t:O,$MYSQL_TMP_DIR/slave.trace
+      EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT --debug"
       ;;
     -- )  shift; break ;;
     --* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
@@ -161,6 +162,8 @@ SLAVE_MYPID="$MYRUN_DIR/mysqld-slave.pid"
 SLAVE_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld-slave.log"
 SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/mysqld-slave.err"
 
+SMALL_SERVER="-O key_buffer_size=1M -O sort_buffer=256K -O max_heap_table_size=1M"
+
 if [ x$SOURCE_DIST = x1 ] ; then
  MY_BASEDIR=$MYSQL_TEST_DIR
 else
@@ -333,7 +336,9 @@ start_master()
             --log=$MASTER_MYLOG --default-character-set=latin1 \
 	    --core \
 	    --tmpdir=$MYSQL_TMP_DIR \
-	    --language=english $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
+	    --language=english \
+	     $SMALL_SERVER \
+	     $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
     if [ x$DO_DDD = x1 ]
     then
       $ECHO "set args $master_args" > $GDB_MASTER_INIT
@@ -376,7 +381,9 @@ start_slave()
             --log=$SLAVE_MYLOG --default-character-set=latin1 \
 	    --core \
 	    --tmpdir=$MYSQL_TMP_DIR \
-            --language=english $EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT"
+            --language=english \
+	     $SMALL_SERVER \
+             $EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT"
     if [ x$DO_DDD = x1 ]
     then
       $ECHO "set args $master_args" > $GDB_SLAVE_INIT
@@ -591,21 +598,23 @@ run_testcase ()
 [ "$DO_GCOV" ] && gcov_prepare 
 
 # Ensure that no old mysqld test servers are running
-$MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O connect_timeout=5 shutdown > /dev/null 2>&1
-$MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 shutdown > /dev/null 2>&1
-
-$ECHO "Installing Test Databases"
-mysql_install_db
+if [ -z "$USE_RUNNING_SERVER" ]
+then
+  $MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O connect_timeout=5 shutdown > /dev/null 2>&1
+  $MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 shutdown > /dev/null 2>&1
+  $ECHO "Installing Test Databases"
+  mysql_install_db
 
 #do not automagically start deamons if we are in gdb or running only one test
 #case
-if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
-then
- mysql_start
+  if [ -z "$DO_GDB" ] && [ -z "$DO_DDD" ]
+  then
+    mysql_start
+  fi
+  $ECHO  "Loading Standard Test Databases"
+  mysql_loadstd
 fi
 
-$ECHO  "Loading Standard Test Databases"
-mysql_loadstd
 
 $ECHO  "Starting Tests"
 
@@ -622,6 +631,7 @@ then
   do
     run_testcase $tf
   done
+  $RM -f $TIMEFILE	# Remove for full test
  fi
 else 
 tname=`$BASENAME $1 .test`
@@ -636,8 +646,6 @@ fi
 $ECHO $DASH72
 $ECHO
 
-$RM -f $TIMEFILE
-
 if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
 then
     mysql_stop
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index 7d9ba18d933ae7559da1bde6aeac5e89fc0fdc1a..a08b5da99a47cf900b921044ec645d0d50282070 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -6,3 +6,17 @@ Full-text indexes	are called collections
 a	b
 Full-text indexes	are called collections
 Only MyISAM tables	support collections
+id
+id
+id
+3
+Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Comment
+t2	1	tig	1	ticket	A	NULL	NULL	NULL	
+t2	1	tix	1	inhalt	A	NULL	1	NULL	FULLTEXT
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `ticket` int(11) default NULL,
+  `inhalt` text,
+  KEY `tig`(`ticket`),
+  FULLTEXT KEY `tix`(`inhalt`)
+) TYPE=MyISAM
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index 33d1dfe65e73f03238f234fa29de7db92d625def..cee67a3e25cd98dbb83496eb351322048fc032f7 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -16,7 +16,7 @@ pow(10,log10(10))	power(2,4)
 10.000000	16.000000
 rand(999999)	rand()
 0.18435012473199	0.76373626176616
-PI()	sin(pi()/2)	cos(pi()/2)	tan(pi())	cot(1)	asin(1)	acos(0)	atan(1)
-3.141593	1.000000	0.000000	-0.000000	0.64209262	1.570796	1.570796	0.785398
+PI()	sin(pi()/2)	cos(pi()/2)	abs(tan(pi()))	cot(1)	asin(1)	acos(0)	atan(1)
+3.141593	1.000000	0.000000	0.000000	0.64209262	1.570796	1.570796	0.785398
 degrees(pi())	radians(360)
 180	6.2831853071796
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index ad7c97022f590e3207c447ee62403dcabb06a3ab..3e3061fcd4dd6fa89c7978c072acecc3e0ed1ddd 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -2,6 +2,8 @@
 # Test of fulltext index
 #
 
+drop table if exists t1,t2;
+
 CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
 INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),('Full-text indexes', 'are called collections'),('Only MyISAM tables','support collections'),('Function MATCH ... AGAINST()','is used to do a search'),('Full-text search in MySQL', 'implements vector space model');
 select * from t1 where MATCH(a,b) AGAINST ("collections");
@@ -9,3 +11,37 @@ select * from t1 where MATCH(a,b) AGAINST ("indexes");
 select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
 delete from t1 where a like "MySQL%";
 drop table t1;
+
+#
+# Check bug reported by Matthias Urlichs
+#
+
+CREATE TABLE t1 (
+  id int(11),
+  ticket int(11),
+  KEY ti (id),
+  KEY tit (ticket)
+)/*! type=MyISAM */;
+INSERT INTO t1 VALUES (2,3),(1,2);
+
+CREATE TABLE t2 (
+  ticket int(11),
+  inhalt text,
+  KEY tig (ticket),
+  fulltext index tix (inhalt(1)) /* this line modified by hand */
+)/*! type=MyISAM */;
+INSERT INTO t2 VALUES (1,'foo'),(2,'bar'),(3,'foobar');
+
+select t1.id FROM t2 as ttxt,t1,t1 as ticket2  WHERE ticket2.id = ttxt.ticket AND t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
+
+# In the following query MySQL didn't use the fulltext index
+select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON ticket2.id = ttxt.ticket WHERE t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
+
+INSERT INTO t1 VALUES (3,3);
+select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON ticket2.id = ttxt.ticket WHERE t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
+
+# Check that we get 'fulltext' index in SHOW CREATE
+
+show keys from t2;
+show create table t2;
+drop table t1,t2;
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index f6b4672f91a0c21b53a56ef144dcded8b6f9b042..ab7990eea7975309020fc4ccec669652c58612a3 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -11,5 +11,5 @@ select abs(-10), sign(-5), sign(5), sign(0);
 select log(exp(10)),exp(log(sqrt(10))*2);
 select pow(10,log10(10)),power(2,4);
 select rand(999999),rand();
-select pi(),sin(pi()/2),cos(pi()/2),tan(pi()),cot(1),asin(1),acos(0),atan(1);
+select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1);
 select degrees(pi()),radians(360);
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index 9880c1615bb5b8eb5f0661691123d60788fbd9d8..1397c14515b75dbabd0df1206b4b8bccc1a8a583 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -100,6 +100,7 @@ uint my_b_fill(IO_CACHE *info)
 
 uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
 {
+  char *start = to;
   uint length;
   max_length--;					/* Save place for end \0 */
   /* Calculate number of characters in buffer */
@@ -115,10 +116,9 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
     {
       if ((*to++ = *pos++) == '\n')
       {
-	length= (uint) (pos-info->rc_pos);
 	info->rc_pos=pos;
 	*to='\0';
-	return length;
+	return (uint) (to-start);
       }
     }
     if (!(max_length-=length))
@@ -126,7 +126,7 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
      /* Found enough charcters;  Return found string */
       info->rc_pos=pos;
       *to='\0';
-      return length;
+      return (uint) (to-start);
     }
     if (!(length=my_b_fill(info)))
       return 0;
diff --git a/mysys/string.c b/mysys/string.c
index 0696c72b92215932e5ad8b53521ce0339d689996..96a503c11792c52cc5646d5aefac8303117dd3cf 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -48,6 +48,7 @@ my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
   DBUG_RETURN(FALSE);
 }
 
+
 my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
 {
   uint length;
@@ -72,6 +73,7 @@ my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
   DBUG_RETURN(FALSE);
 }
 
+
 my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size)
 {
   DBUG_ENTER("dynstr_realloc");
@@ -89,12 +91,18 @@ my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size)
 
 
 my_bool dynstr_append(DYNAMIC_STRING *str, const char *append)
+{
+  return dynstr_append_mem(str,append,strlen(append));
+}
+
+
+my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
+			  uint length)
 {
   char *new_ptr;
-  uint length=(uint) strlen(append)+1;
-  if (str->length+length > str->max_length)
+  if (str->length+length >= str->max_length)
   {
-    uint new_length=(str->length+length+str->alloc_increment-1)/
+    uint new_length=(str->length+length+str->alloc_increment)/
       str->alloc_increment;
     new_length*=str->alloc_increment;
     if (!(new_ptr=(char*) my_realloc(str->str,new_length,MYF(MY_WME))))
@@ -103,10 +111,12 @@ my_bool dynstr_append(DYNAMIC_STRING *str, const char *append)
     str->max_length=new_length;
   }
   memcpy(str->str + str->length,append,length);
-  str->length+=length-1;
+  str->length+=length;
+  str->str[str->length]=0;			/* Safety for C programs */
   return FALSE;
 }
 
+
 void dynstr_free(DYNAMIC_STRING *str)
 {
   if (str->str)
diff --git a/mysys/typelib.c b/mysys/typelib.c
index 903a730406549215528b0b8a53cb7cd0d77715ff..929278d1b8f6d14acf4cf4b47566ea270637975b 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -26,7 +26,7 @@
 ** If part, uniq field is found and full_name == 0 then x is expanded
 ** to full field.
 ** full_name has the following bit values:
-**   If & 1 accept only hole names
+**   If & 1 accept only whole names
 **   If & 2 don't expand if half field
 **   If & 4 allow #number# as type
 ****************************************************************************/
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index 48057b43a76d4c45e2684721bae352185e6222f8..14c4b616dec2629f50e5b037a9c247ba5f794253 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -18,6 +18,14 @@ then
   shift 1
 fi
 
+# Get optional suffix for distribution
+SUFFIX=""
+if test $# -gt 0 -a x$1 != x"-debug" 
+then
+  SUFFIX=$1
+  shift 1
+fi
+
 if test x$1 = x"-debug"
 then
   DEBUG=1
@@ -33,7 +41,7 @@ fi
 BASE=$TMP/my_dist
 
 if [ -d $BASE ] ; then
- rm -rf $BASE
+ rm -r -f $BASE
 fi
 
 mkdir $BASE $BASE/bin $BASE/data $BASE/data/mysql $BASE/data/test \
@@ -56,7 +64,10 @@ for i in extra/comp_err extra/replace extra/perror extra/resolveip \
  client/mysqladmin client/mysqldump client/mysqlimport client/mysqltest \
  client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin client/.libs/mysqldump client/.libs/mysqlimport client/.libs/mysqltest
 do
-  cp -p $i $BASE/bin
+  if [ -f $i ]
+  then
+    cp -p $i $BASE/bin
+   fi
 done
 
 cp -p config.h include/* $BASE/include
@@ -67,10 +78,8 @@ cp -p support-files/* $BASE/support-files
 cp -p libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a $BASE/lib
 cp -r -p sql/share/* $BASE/share/mysql
 rm -f $BASE/share/mysql/Makefile* $BASE/share/mysql/*/*.OLD
-rm -rf $BASE/share/SCCS  $BASE/share/*/SCCS 
 
 cp -p mysql-test/mysql-test-run mysql-test/install_test_db $BASE/mysql-test/
-cp -p mysql-test/create-test-result $BASE/mysql-test
 cp -p mysql-test/README $BASE/mysql-test/README
 cp -p mysql-test/include/*.inc $BASE/mysql-test/include
 cp -p mysql-test/std_data/*.dat  mysql-test/std_data/*.frm \
@@ -89,13 +98,17 @@ mv $BASE/support-files/binary-configure $BASE/configure
 chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/configure
 cp -r -p sql-bench/* $BASE/sql-bench
 rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
-rm -rf `find $BASE/sql-bench -name SCCS`
-rm -rf `find $BASE/share -name SCCS`
 
-# Change the distribution to a long descreptive name
-NEW_NAME=mysql-$version-$system-$machine
+# Clean up if we did this from a bk tree
+if [ -d $BASE/sql-bench/SCCS ] ; then 
+  find $BASE/share -name SCCS -print | xargs rm -r -f
+  find $BASE/sql-bench -name SCCS -print | xargs rm -r -f
+fi
+
+# Change the distribution to a long descriptive name
+NEW_NAME=mysql-$version-$system-$machine$SUFFIX
 BASE2=$TMP/$NEW_NAME
-rm -rf $BASE2
+rm -r -f $BASE2
 mv $BASE $BASE2
 BASE=$BASE2
 #
@@ -160,6 +173,6 @@ cd $SOURCE
 echo "Compressing archive"
 gzip -9 $NEW_NAME.tar
 echo "Removing temporary directory"
-rm -rf $BASE
+rm -r -f $BASE
 
 echo "$NEW_NAME.tar.gz created"
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index efb92bb7f62c649e05f46afc6c2fccd707bd1308..068fc4a384ad87e135ec763ba25c57987b6b6bd6 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -10,7 +10,7 @@
 IN_RPM=0
 case "$1" in
     -IN-RPM)
-      IN_RPM="$1"; shift
+      IN_RPM="1"; shift
       ;;
 esac
 defaults=
diff --git a/scripts/safe_mysqld.sh b/scripts/safe_mysqld.sh
index 0265dcdeeb9ed515da2792d1e5a68c0aa8e66eff..fc89f0c78484ecc279b113f72d5f6293e366cca0 100644
--- a/scripts/safe_mysqld.sh
+++ b/scripts/safe_mysqld.sh
@@ -110,7 +110,7 @@ else
 fi
 
 args=
-parse_arguments `$print_defaults $defaults mysqld safe_mysqld`
+parse_arguments `$print_defaults $defaults mysqld server safe_mysqld`
 parse_arguments PICK-ARGS-FROM-ARGV "$@"
 
 if test ! -x $ledir/$MYSQLD
diff --git a/sql-bench/Results/ATIS-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/ATIS-mysql-Linux_2.2.13_SMP_alpha
index e411b45a05648c8da1e6a4518e03251c0fe487a3..063581537ec2f6af193c865c4bd3f8a32acfa3bf 100644
--- a/sql-bench/Results/ATIS-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/ATIS-mysql-Linux_2.2.13_SMP_alpha
@@ -1,4 +1,4 @@
-Testing server 'MySQL 3.23.30 gamma' at 2000-12-28 15:29:27
+Testing server 'MySQL 3.23.30 gamma' at 2001-01-03 18:34:25
 
 ATIS table test
 
@@ -6,15 +6,15 @@ Creating tables
 Time for create_table (28):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Inserting data
-Time to insert (9768):  3 wallclock secs ( 0.64 usr  0.61 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to insert (9768):  3 wallclock secs ( 0.63 usr  0.59 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Retrieving data
-Time for select_simple_join (500):  2 wallclock secs ( 0.62 usr  0.39 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_join (100):  2 wallclock secs ( 0.47 usr  0.35 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_key_prefix_join (100): 10 wallclock secs ( 3.80 usr  2.75 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_distinct (800): 11 wallclock secs ( 1.63 usr  1.04 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_group (2800): 10 wallclock secs ( 1.48 usr  0.66 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_simple_join (500):  2 wallclock secs ( 0.61 usr  0.39 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_join (100):  1 wallclock secs ( 0.48 usr  0.34 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key_prefix_join (100): 11 wallclock secs ( 3.75 usr  2.76 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_distinct (800): 11 wallclock secs ( 1.72 usr  0.97 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_group (2800): 10 wallclock secs ( 1.55 usr  0.68 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Removing tables
 Time to drop_table (28):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Total time: 38 wallclock secs ( 8.65 usr  5.80 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 38 wallclock secs ( 8.76 usr  5.73 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/RUN-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/RUN-mysql-Linux_2.2.13_SMP_alpha
index 8a9c8e6eb7b6eb7b3235ec5a7c738ea6d648acd5..ae76a336e983253d2a3fd0e62d7c412384e9d629 100644
--- a/sql-bench/Results/RUN-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/RUN-mysql-Linux_2.2.13_SMP_alpha
@@ -1,96 +1,96 @@
 Benchmark DBD suite: 2.11
-Date of test:        2000-12-28 17:09:41
+Date of test:        2001-01-03 18:34:24
 Running tests on:    Linux 2.2.13-SMP alpha
 Arguments:           
 Comments:            Alpha DS20 2x500 MHz, 2G memory, key_buffer=16M; cxx 6.3 + ccc 6.2.9
 Limits from:         
 Server version:      MySQL 3.23.30 gamma
 
-ATIS: Total time: 38 wallclock secs ( 8.65 usr  5.80 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-alter-table: Total time: 396 wallclock secs ( 0.30 usr  0.17 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-big-tables: Total time: 41 wallclock secs ( 8.30 usr 10.73 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-connect: Total time: 74 wallclock secs (32.31 usr 18.97 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-create: Total time: 207 wallclock secs (10.36 usr  4.42 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-insert: Total time: 1932 wallclock secs (465.91 usr 251.37 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-select: Total time: 1127 wallclock secs (61.16 usr 29.24 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-wisconsin: Total time: 18 wallclock secs ( 3.58 usr  2.86 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+ATIS: Total time: 38 wallclock secs ( 8.76 usr  5.73 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+alter-table: Total time: 392 wallclock secs ( 0.29 usr  0.17 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+big-tables: Total time: 41 wallclock secs ( 8.53 usr 10.35 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+connect: Total time: 75 wallclock secs (31.88 usr 18.52 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+create: Total time: 134 wallclock secs (10.30 usr  4.28 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+insert: Total time: 1914 wallclock secs (453.84 usr 255.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+select: Total time: 1144 wallclock secs (59.15 usr 27.51 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+wisconsin: Total time: 18 wallclock secs ( 3.58 usr  2.87 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 All 8 test executed successfully
 
 Totals per operation:
 Operation             seconds     usr     sys     cpu   tests
-alter_table_add                      213.00    0.17    0.06    0.00     992 
-alter_table_drop                     175.00    0.06    0.04    0.00     496 
-connect                               13.00    7.51    2.43    0.00   10000 
-connect+select_1_row                  17.00    7.95    3.44    0.00   10000 
-connect+select_simple                 16.00    7.69    3.23    0.00   10000 
-count                                 50.00    0.04    0.01    0.00     100 
-count_distinct                       102.00    0.71    0.21    0.00    2000 
-count_distinct_big                   133.00    8.01    9.25    0.00     120 
-count_distinct_group                  63.00    1.16    0.69    0.00    1000 
-count_distinct_group_on_key           42.00    0.45    0.16    0.00    1000 
-count_distinct_group_on_key_parts     62.00    1.20    0.66    0.00    1000 
-count_group_on_key_parts              38.00    1.16    0.66    0.00    1000 
-count_on_key                         395.00   16.46    4.54    0.00   50100 
-create+drop                           13.00    2.77    1.02    0.00   10000 
-create_MANY_tables                   164.00    1.93    0.57    0.00   10000 
+alter_table_add                      213.00    0.18    0.06    0.00     992 
+alter_table_drop                     170.00    0.05    0.04    0.00     496 
+connect                               14.00    7.52    2.57    0.00   10000 
+connect+select_1_row                  17.00    7.74    3.33    0.00   10000 
+connect+select_simple                 16.00    7.76    3.27    0.00   10000 
+count                                 51.00    0.05    0.01    0.00     100 
+count_distinct                        99.00    0.70    0.22    0.00    2000 
+count_distinct_big                   131.00    7.32    8.60    0.00     120 
+count_distinct_group                  63.00    1.11    0.59    0.00    1000 
+count_distinct_group_on_key           43.00    0.46    0.15    0.00    1000 
+count_distinct_group_on_key_parts     63.00    1.12    0.57    0.00    1000 
+count_group_on_key_parts              39.00    1.03    0.61    0.00    1000 
+count_on_key                         405.00   16.37    4.36    0.00   50100 
+create+drop                           12.00    2.63    0.97    0.00   10000 
+create_MANY_tables                    92.00    1.81    0.60    0.00   10000 
 create_index                           4.00    0.00    0.00    0.00       8 
-create_key+drop                       17.00    4.14    1.36    0.00   10000 
+create_key+drop                       17.00    4.27    1.28    0.00   10000 
 create_table                           0.00    0.00    0.00    0.00      31 
-delete_all                            11.00    0.00    0.00    0.00      12 
-delete_all_many_keys                  50.00    0.01    0.01    0.00       1 
+delete_all                            12.00    0.00    0.00    0.00      12 
+delete_all_many_keys                  49.00    0.01    0.01    0.00       1 
 delete_big                             0.00    0.00    0.00    0.00       1 
-delete_big_many_keys                  50.00    0.01    0.01    0.00     128 
-delete_key                             5.00    0.60    0.53    0.00   10000 
+delete_big_many_keys                  49.00    0.01    0.01    0.00     128 
+delete_key                             5.00    0.75    0.63    0.00   10000 
 drop_index                             4.00    0.00    0.00    0.00       8 
 drop_table                             0.00    0.00    0.00    0.00      28 
-drop_table_when_MANY_tables            7.00    0.68    0.64    0.00   10000 
-insert                               133.00   23.24   21.08    0.00  350768 
-insert_duplicates                     38.00    5.55    6.19    0.00  100000 
-insert_key                            96.00    8.23    5.98    0.00  100000 
+drop_table_when_MANY_tables            7.00    0.71    0.58    0.00   10000 
+insert                               136.00   24.25   21.36    0.00  350768 
+insert_duplicates                     37.00    5.54    6.23    0.00  100000 
+insert_key                            94.00    8.92    5.51    0.00  100000 
 insert_many_fields                    14.00    0.35    0.12    0.00    2000 
-insert_select_1_key                    6.00    0.00    0.00    0.00       1 
-insert_select_2_keys                   6.00    0.00    0.00    0.00       1 
+insert_select_1_key                    5.00    0.00    0.00    0.00       1 
+insert_select_2_keys                   7.00    0.00    0.00    0.00       1 
 min_max                               22.00    0.02    0.01    0.00      60 
-min_max_on_key                       162.00   26.32    7.66    0.00   85000 
-multiple_value_insert                  7.00    2.08    0.05    0.00  100000 
-order_by_big                          53.00   20.57   21.79    0.00      10 
-order_by_big_key                      38.00   22.77   15.36    0.00      10 
-order_by_big_key2                     35.00   19.87   14.91    0.00      10 
-order_by_big_key_desc                 38.00   22.72   15.24    0.00      10 
-order_by_big_key_diff                 49.00   20.43   21.94    0.00      10 
-order_by_big_key_prefix               35.00   19.98   14.81    0.00      10 
-order_by_key2_diff                     5.00    1.81    1.27    0.00     500 
-order_by_key_prefix                    3.00    1.07    0.64    0.00     500 
-order_by_range                         4.00    1.09    0.62    0.00     500 
-outer_join                            60.00    0.00    0.00    0.00      10 
+min_max_on_key                       166.00   26.17    7.53    0.00   85000 
+multiple_value_insert                  7.00    2.10    0.06    0.00  100000 
+order_by_big                          52.00   20.66   21.59    0.00      10 
+order_by_big_key                      38.00   22.00   15.43    0.00      10 
+order_by_big_key2                     35.00   19.97   14.93    0.00      10 
+order_by_big_key_desc                 37.00   21.90   15.47    0.00      10 
+order_by_big_key_diff                 50.00   20.51   21.78    0.00      10 
+order_by_big_key_prefix               35.00   19.88   14.96    0.00      10 
+order_by_key2_diff                     5.00    1.89    1.22    0.00     500 
+order_by_key_prefix                    3.00    1.07    0.65    0.00     500 
+order_by_range                         4.00    1.05    0.68    0.00     500 
+outer_join                            61.00    0.00    0.00    0.00      10 
 outer_join_found                      56.00    0.00    0.00    0.00      10 
-outer_join_not_found                  37.00    0.00    0.00    0.00     500 
+outer_join_not_found                  38.00    0.00    0.00    0.00     500 
 outer_join_on_key                     44.00    0.00    0.00    0.00      10 
-select_1_row                           2.00    0.46    1.12    0.00   10000 
-select_2_rows                          3.00    0.36    1.00    0.00   10000 
-select_big                            56.00   28.42   21.18    0.00   10080 
-select_column+column                   3.00    0.28    0.76    0.00   10000 
-select_diff_key                      151.00    0.25    0.04    0.00     500 
-select_distinct                       11.00    1.63    1.04    0.00     800 
-select_group                          50.00    1.52    0.68    0.00    2911 
-select_group_when_MANY_tables          6.00    0.84    0.83    0.00   10000 
-select_join                            2.00    0.47    0.35    0.00     100 
-select_key                           141.00   75.34   22.71    0.00  200000 
-select_key2                          146.00   75.75   22.08    0.00  200000 
-select_key_prefix                    147.00   76.05   21.66    0.00  200000 
-select_key_prefix_join                10.00    3.80    2.75    0.00     100 
-select_many_fields                    26.00    7.94   10.60    0.00    2000 
-select_range                         227.00    9.67    5.91    0.00     410 
-select_range_key2                     19.00    6.72    2.30    0.00   25010 
-select_range_prefix                   19.00    6.65    2.24    0.00   25010 
-select_simple                          1.00    0.31    0.80    0.00   10000 
-select_simple_join                     2.00    0.62    0.39    0.00     500 
-update_big                            26.00    0.00    0.00    0.00      10 
-update_of_key                         27.00    3.58    3.11    0.00   50000 
+select_1_row                           2.00    0.39    0.97    0.00   10000 
+select_2_rows                          3.00    0.36    0.97    0.00   10000 
+select_big                            55.00   27.62   21.08    0.00   10080 
+select_column+column                   3.00    0.31    0.72    0.00   10000 
+select_diff_key                      154.00    0.22    0.07    0.00     500 
+select_distinct                       11.00    1.72    0.97    0.00     800 
+select_group                          50.00    1.61    0.69    0.00    2911 
+select_group_when_MANY_tables          6.00    0.88    0.86    0.00   10000 
+select_join                            1.00    0.48    0.34    0.00     100 
+select_key                           137.00   73.11   21.92    0.00  200000 
+select_key2                          141.00   71.45   23.77    0.00  200000 
+select_key_prefix                    142.00   71.84   23.50    0.00  200000 
+select_key_prefix_join                11.00    3.75    2.76    0.00     100 
+select_many_fields                    26.00    8.17   10.23    0.00    2000 
+select_range                         227.00    8.60    5.58    0.00     410 
+select_range_key2                     18.00    6.51    2.11    0.00   25010 
+select_range_prefix                   20.00    6.30    2.34    0.00   25010 
+select_simple                          1.00    0.29    0.79    0.00   10000 
+select_simple_join                     2.00    0.61    0.39    0.00     500 
+update_big                            28.00    0.00    0.00    0.00      10 
+update_of_key                         26.00    3.42    2.98    0.00   50000 
 update_of_key_big                     19.00    0.04    0.03    0.00     501 
-update_of_primary_key_many_keys       21.00    0.02    0.01    0.00     256 
-update_with_key                      135.00   21.98   17.77    0.00  300000 
-update_with_key_prefix                42.00    7.22    5.96    0.00  100000 
-wisc_benchmark                         4.00    1.71    0.98    0.00     114 
-TOTALS                              3881.00  590.44  323.49    0.00 2046247 
+update_of_primary_key_many_keys       22.00    0.02    0.01    0.00     256 
+update_with_key                      131.00   21.64   18.34    0.00  300000 
+update_with_key_prefix                40.00    7.20    6.06    0.00  100000 
+wisc_benchmark                         4.00    1.77    0.99    0.00     114 
+TOTALS                              3801.00  576.19  324.46    0.00 2046247 
diff --git a/sql-bench/Results/alter-table-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/alter-table-mysql-Linux_2.2.13_SMP_alpha
index b2f9f2e537a538a9f8131ec8aea95ad09689f4ba..4bddee44315a8b77c53272f50870bfe644cde5e1 100644
--- a/sql-bench/Results/alter-table-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/alter-table-mysql-Linux_2.2.13_SMP_alpha
@@ -1,16 +1,16 @@
-Testing server 'MySQL 3.23.30 gamma' at 2000-12-28 15:30:07
+Testing server 'MySQL 3.23.30 gamma' at 2001-01-03 18:35:03
 
 Testing of ALTER TABLE
 Testing with 1000 columns and 1000 rows in 20 steps
 Insert data into the table
-Time for insert (1000) 0 wallclock secs ( 0.06 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for insert (1000) 1 wallclock secs ( 0.06 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
-Time for alter_table_add (992): 213 wallclock secs ( 0.17 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for alter_table_add (992): 213 wallclock secs ( 0.18 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Time for create_index (8):  4 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Time for drop_index (8):  4 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
-Time for alter_table_drop (496): 175 wallclock secs ( 0.06 usr  0.04 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for alter_table_drop (496): 170 wallclock secs ( 0.05 usr  0.04 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
-Total time: 396 wallclock secs ( 0.30 usr  0.17 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 392 wallclock secs ( 0.29 usr  0.17 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/big-tables-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/big-tables-mysql-Linux_2.2.13_SMP_alpha
index 0f2d03e3e7eefdcd08f4a0400faebbf3689af41a..35c00c7b72a1ac8c9ef1940651f513740544503e 100644
--- a/sql-bench/Results/big-tables-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/big-tables-mysql-Linux_2.2.13_SMP_alpha
@@ -1,19 +1,19 @@
-Testing server 'MySQL 3.23.30 gamma' at 2000-12-28 15:36:43
+Testing server 'MySQL 3.23.30 gamma' at 2001-01-03 18:41:35
 
 Testing of some unusual tables
 All tests are done 1000 times with 1000 fields
 
 Testing table with 1000 fields
 Testing select * from table with 1 record
-Time to select_many_fields(1000): 10 wallclock secs ( 3.89 usr  5.32 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to select_many_fields(1000): 10 wallclock secs ( 4.03 usr  5.13 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing select all_fields from table with 1 record
-Time to select_many_fields(1000): 16 wallclock secs ( 4.05 usr  5.28 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to select_many_fields(1000): 16 wallclock secs ( 4.14 usr  5.10 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing insert VALUES()
-Time to insert_many_fields(1000):  5 wallclock secs ( 0.32 usr  0.07 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to insert_many_fields(1000):  5 wallclock secs ( 0.32 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing insert (all_fields) VALUES()
-Time to insert_many_fields(1000):  9 wallclock secs ( 0.03 usr  0.05 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to insert_many_fields(1000):  9 wallclock secs ( 0.03 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
-Total time: 41 wallclock secs ( 8.30 usr 10.73 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 41 wallclock secs ( 8.53 usr 10.35 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/connect-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/connect-mysql-Linux_2.2.13_SMP_alpha
index bb435fe30ad21a72855798973d919c3482163ef9..dfd5cdcdf843df54f2937ec53546738289fdc31f 100644
--- a/sql-bench/Results/connect-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/connect-mysql-Linux_2.2.13_SMP_alpha
@@ -1,30 +1,30 @@
-Testing server 'MySQL 3.23.30 gamma' at 2000-12-28 15:37:25
+Testing server 'MySQL 3.23.30 gamma' at 2001-01-03 18:42:16
 
 Testing the speed of connecting to the server and sending of data
 All tests are done 10000 times
 
 Testing connection/disconnect
-Time to connect (10000): 13 wallclock secs ( 7.51 usr  2.43 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to connect (10000): 14 wallclock secs ( 7.52 usr  2.57 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Test connect/simple select/disconnect
-Time for connect+select_simple (10000): 16 wallclock secs ( 7.69 usr  3.23 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for connect+select_simple (10000): 16 wallclock secs ( 7.76 usr  3.27 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Test simple select
-Time for select_simple (10000):  1 wallclock secs ( 0.31 usr  0.80 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_simple (10000):  1 wallclock secs ( 0.29 usr  0.79 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing connect/select 1 row from table/disconnect
-Time to connect+select_1_row (10000): 17 wallclock secs ( 7.95 usr  3.44 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to connect+select_1_row (10000): 17 wallclock secs ( 7.74 usr  3.33 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing select 1 row from table
-Time to select_1_row (10000):  2 wallclock secs ( 0.46 usr  1.12 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to select_1_row (10000):  2 wallclock secs ( 0.39 usr  0.97 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing select 2 rows from table
-Time to select_2_rows (10000):  3 wallclock secs ( 0.36 usr  1.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to select_2_rows (10000):  3 wallclock secs ( 0.36 usr  0.97 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Test select with aritmetic (+)
-Time for select_column+column (10000):  3 wallclock secs ( 0.28 usr  0.76 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_column+column (10000):  3 wallclock secs ( 0.31 usr  0.72 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing retrieval of big records (65000 bytes)
-Time to select_big (10000): 19 wallclock secs ( 7.75 usr  6.19 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to select_big (10000): 19 wallclock secs ( 7.50 usr  5.90 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
-Total time: 74 wallclock secs (32.31 usr 18.97 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 75 wallclock secs (31.88 usr 18.52 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/create-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/create-mysql-Linux_2.2.13_SMP_alpha
index 894ac19360cabe5ae5ef936b9898ed1896253bf4..f8fbcda381859b616f66a4e7e9278f2e787fc3d1 100644
--- a/sql-bench/Results/create-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/create-mysql-Linux_2.2.13_SMP_alpha
@@ -1,18 +1,18 @@
-Testing server 'MySQL 3.23.30 gamma' at 2000-12-28 15:38:39
+Testing server 'MySQL 3.23.30 gamma' at 2001-01-03 18:43:31
 
 Testing the speed of creating and droping tables
 Testing with 10000 tables and 10000 loop count
 
 Testing create of tables
-Time for create_MANY_tables (10000): 164 wallclock secs ( 1.93 usr  0.57 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for create_MANY_tables (10000): 92 wallclock secs ( 1.81 usr  0.60 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Accessing tables
-Time to select_group_when_MANY_tables (10000):  6 wallclock secs ( 0.84 usr  0.83 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to select_group_when_MANY_tables (10000):  6 wallclock secs ( 0.88 usr  0.86 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing drop
-Time for drop_table_when_MANY_tables (10000):  7 wallclock secs ( 0.68 usr  0.64 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for drop_table_when_MANY_tables (10000):  7 wallclock secs ( 0.71 usr  0.58 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing create+drop
-Time for create+drop (10000): 13 wallclock secs ( 2.77 usr  1.02 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for create_key+drop (10000): 17 wallclock secs ( 4.14 usr  1.36 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Total time: 207 wallclock secs (10.36 usr  4.42 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for create+drop (10000): 12 wallclock secs ( 2.63 usr  0.97 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for create_key+drop (10000): 17 wallclock secs ( 4.27 usr  1.28 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 134 wallclock secs (10.30 usr  4.28 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/insert-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/insert-mysql-Linux_2.2.13_SMP_alpha
index 47ec44ea3d51a9c3e2e2e348da15c5af9ff0b367..d10c44c49cb22826f82832c43b41ea24f9922cac 100644
--- a/sql-bench/Results/insert-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/insert-mysql-Linux_2.2.13_SMP_alpha
@@ -1,4 +1,4 @@
-Testing server 'MySQL 3.23.30 gamma' at 2000-12-28 15:42:07
+Testing server 'MySQL 3.23.30 gamma' at 2001-01-03 18:45:45
 
 Testing the speed of inserting data into 1 table and do some selects on it.
 The tests are done with a table that has 100000 rows.
@@ -8,80 +8,80 @@ Creating tables
 Inserting 100000 rows in order
 Inserting 100000 rows in reverse order
 Inserting 100000 rows in random order
-Time for insert (300000): 113 wallclock secs (20.01 usr 17.88 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for insert (300000): 115 wallclock secs (21.05 usr 18.25 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing insert of duplicates
-Time for insert_duplicates (100000): 38 wallclock secs ( 5.55 usr  6.19 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for insert_duplicates (100000): 37 wallclock secs ( 5.54 usr  6.23 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Retrieving data from the table
-Time for select_big (10:3000000): 36 wallclock secs (20.53 usr 14.90 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_big_key (10:3000000): 38 wallclock secs (22.77 usr 15.36 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_big_key_desc (10:3000000): 38 wallclock secs (22.72 usr 15.24 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_big_key_prefix (10:3000000): 35 wallclock secs (19.98 usr 14.81 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_big_key2 (10:3000000): 35 wallclock secs (19.87 usr 14.91 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_big_key_diff (10:3000000): 49 wallclock secs (20.43 usr 21.94 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_big (10:3000000): 53 wallclock secs (20.57 usr 21.79 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_range (500:125750):  4 wallclock secs ( 1.09 usr  0.62 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_key_prefix (500:125750):  3 wallclock secs ( 1.07 usr  0.64 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for order_by_key2_diff (500:250500):  5 wallclock secs ( 1.81 usr  1.27 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_diff_key (500:1000): 151 wallclock secs ( 0.25 usr  0.04 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_range_prefix (5010:42084): 10 wallclock secs ( 2.87 usr  0.92 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_range_key2 (5010:42084): 11 wallclock secs ( 2.92 usr  1.02 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_key_prefix (200000): 147 wallclock secs (76.05 usr 21.66 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_key (200000): 141 wallclock secs (75.34 usr 22.71 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_key2 (200000): 146 wallclock secs (75.75 usr 22.08 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_big (10:3000000): 35 wallclock secs (19.98 usr 15.08 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key (10:3000000): 38 wallclock secs (22.00 usr 15.43 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key_desc (10:3000000): 37 wallclock secs (21.90 usr 15.47 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key_prefix (10:3000000): 35 wallclock secs (19.88 usr 14.96 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key2 (10:3000000): 35 wallclock secs (19.97 usr 14.93 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key_diff (10:3000000): 50 wallclock secs (20.51 usr 21.78 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big (10:3000000): 52 wallclock secs (20.66 usr 21.59 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_range (500:125750):  4 wallclock secs ( 1.05 usr  0.68 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_key_prefix (500:125750):  3 wallclock secs ( 1.07 usr  0.65 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_key2_diff (500:250500):  5 wallclock secs ( 1.89 usr  1.22 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_diff_key (500:1000): 154 wallclock secs ( 0.22 usr  0.07 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range_prefix (5010:42084): 11 wallclock secs ( 2.69 usr  1.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range_key2 (5010:42084): 10 wallclock secs ( 2.88 usr  0.84 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key_prefix (200000): 142 wallclock secs (71.84 usr 23.50 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key (200000): 137 wallclock secs (73.11 usr 21.92 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key2 (200000): 141 wallclock secs (71.45 usr 23.77 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Test of compares with simple ranges
-Time for select_range_prefix (20000:43500):  9 wallclock secs ( 3.78 usr  1.32 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_range_key2 (20000:43500):  8 wallclock secs ( 3.80 usr  1.28 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_group (111): 40 wallclock secs ( 0.04 usr  0.02 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for min_max_on_key (15000):  9 wallclock secs ( 4.77 usr  1.28 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range_prefix (20000:43500):  9 wallclock secs ( 3.61 usr  1.34 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range_key2 (20000:43500):  8 wallclock secs ( 3.63 usr  1.27 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_group (111): 40 wallclock secs ( 0.06 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for min_max_on_key (15000):  9 wallclock secs ( 4.57 usr  1.41 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 Time for min_max (60): 22 wallclock secs ( 0.02 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for count_on_key (100): 40 wallclock secs ( 0.04 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for count (100): 50 wallclock secs ( 0.04 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_on_key (100): 36 wallclock secs ( 0.04 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count (100): 51 wallclock secs ( 0.05 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 Time for count_distinct_big (20): 52 wallclock secs ( 0.01 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing update of keys with functions
-Time for update_of_key (50000):  27 wallclock secs ( 3.58 usr  3.11 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for update_of_key (50000):  26 wallclock secs ( 3.42 usr  2.98 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 Time for update_of_key_big (501): 19 wallclock secs ( 0.04 usr  0.03 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing update with key
-Time for update_with_key (300000):  135 wallclock secs (21.98 usr 17.77 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for update_with_key_prefix (100000):  42 wallclock secs ( 7.22 usr  5.96 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for update_with_key (300000):  131 wallclock secs (21.64 usr 18.34 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for update_with_key_prefix (100000):  40 wallclock secs ( 7.20 usr  6.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing update of all rows
-Time for update_big (10):  26 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for update_big (10):  28 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing left outer join
 Time for outer_join_on_key (10:10):  44 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for outer_join (10:10):  60 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for outer_join (10:10):  61 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 Time for outer_join_found (10:10):  56 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for outer_join_not_found (500:10):  37 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for outer_join_not_found (500:10):  38 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing INSERT INTO ... SELECT
-Time for insert_select_1_key (1):   6 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for insert_select_2_keys (1):   6 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for insert_select_1_key (1):   5 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for insert_select_2_keys (1):   7 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 Time for drop table(2):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing delete
-Time for delete_key (10000):  5 wallclock secs ( 0.60 usr  0.53 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for delete_all (12): 11 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for delete_key (10000):  5 wallclock secs ( 0.75 usr  0.63 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for delete_all (12): 12 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Insert into table with 16 keys and with a primary key with 16 parts
-Time for insert_key (100000): 96 wallclock secs ( 8.23 usr  5.98 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for insert_key (100000): 94 wallclock secs ( 8.92 usr  5.51 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing update of keys
-Time for update_of_primary_key_many_keys (256): 21 wallclock secs ( 0.02 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for update_of_primary_key_many_keys (256): 22 wallclock secs ( 0.02 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Deleting rows from the table
-Time for delete_big_many_keys (128): 50 wallclock secs ( 0.01 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for delete_big_many_keys (128): 49 wallclock secs ( 0.01 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Deleting everything from table
-Time for delete_all_many_keys (1): 50 wallclock secs ( 0.01 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for delete_all_many_keys (1): 49 wallclock secs ( 0.01 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Inserting 100000 rows with multiple values
-Time for multiple_value_insert (100000):  7 wallclock secs ( 2.08 usr  0.05 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for multiple_value_insert (100000):  7 wallclock secs ( 2.10 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Time for drop table(1):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
-Total time: 1932 wallclock secs (465.91 usr 251.37 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 1914 wallclock secs (453.84 usr 255.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/select-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/select-mysql-Linux_2.2.13_SMP_alpha
index 818e562797c15ea395bce793d0b9b84a478b2444..02db3bf4601cd6e833f26147f80b0dfe2a358d1e 100644
--- a/sql-bench/Results/select-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/select-mysql-Linux_2.2.13_SMP_alpha
@@ -1,23 +1,23 @@
-Testing server 'MySQL 3.23.30 gamma' at 2000-12-28 16:14:21
+Testing server 'MySQL 3.23.30 gamma' at 2001-01-03 19:17:40
 
 Testing the speed of selecting on keys that consist of many parts
 The test-table has 10000 rows and the test is done with 500 ranges.
 
 Creating table
 Inserting 10000 rows
-Time to insert (10000):  3 wallclock secs ( 0.72 usr  0.71 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to insert (10000):  4 wallclock secs ( 0.75 usr  0.65 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Testing big selects on the table
-Time for select_big (70:17207):  1 wallclock secs ( 0.14 usr  0.09 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for select_range (410:1057904): 227 wallclock secs ( 9.67 usr  5.91 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for min_max_on_key (70000): 153 wallclock secs (21.55 usr  6.38 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for count_on_key (50000): 355 wallclock secs (16.42 usr  4.53 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_big (70:17207):  1 wallclock secs ( 0.14 usr  0.10 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range (410:1057904): 227 wallclock secs ( 8.60 usr  5.58 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for min_max_on_key (70000): 157 wallclock secs (21.60 usr  6.12 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_on_key (50000): 369 wallclock secs (16.33 usr  4.35 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
-Time for count_group_on_key_parts (1000:100000): 38 wallclock secs ( 1.16 usr  0.66 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_group_on_key_parts (1000:100000): 39 wallclock secs ( 1.03 usr  0.61 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 Testing count(distinct) on the table
-Time for count_distinct (2000:2000): 102 wallclock secs ( 0.71 usr  0.21 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for count_distinct_group_on_key (1000:6000): 42 wallclock secs ( 0.45 usr  0.16 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for count_distinct_group_on_key_parts (1000:100000): 62 wallclock secs ( 1.20 usr  0.66 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for count_distinct_group (1000:100000): 63 wallclock secs ( 1.16 usr  0.69 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Time for count_distinct_big (100:1000000): 81 wallclock secs ( 8.00 usr  9.24 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
-Total time: 1127 wallclock secs (61.16 usr 29.24 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct (2000:2000): 99 wallclock secs ( 0.70 usr  0.22 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_group_on_key (1000:6000): 43 wallclock secs ( 0.46 usr  0.15 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_group_on_key_parts (1000:100000): 63 wallclock secs ( 1.12 usr  0.57 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_group (1000:100000): 63 wallclock secs ( 1.11 usr  0.59 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_big (100:1000000): 79 wallclock secs ( 7.31 usr  8.59 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 1144 wallclock secs (59.15 usr 27.51 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/wisconsin-mysql-Linux_2.2.13_SMP_alpha b/sql-bench/Results/wisconsin-mysql-Linux_2.2.13_SMP_alpha
index 7f7bd4f6b71bcc5e0fa83dd439f5962da04693ef..2c2c85bda3b546a034c226cc6068a4a3e5476235 100644
--- a/sql-bench/Results/wisconsin-mysql-Linux_2.2.13_SMP_alpha
+++ b/sql-bench/Results/wisconsin-mysql-Linux_2.2.13_SMP_alpha
@@ -1,14 +1,14 @@
-Testing server 'MySQL 3.23.30 gamma' at 2000-12-28 16:33:09
+Testing server 'MySQL 3.23.30 gamma' at 2001-01-03 19:36:45
 
 Wisconsin benchmark test
 
 Time for create_table (3):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Inserting data
-Time to insert (31000): 14 wallclock secs ( 1.87 usr  1.88 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to insert (31000): 14 wallclock secs ( 1.82 usr  1.87 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 Time to delete_big (1):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
 Running actual benchmark
-Time for wisc_benchmark (114):  4 wallclock secs ( 1.71 usr  0.98 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for wisc_benchmark (114):  4 wallclock secs ( 1.77 usr  0.99 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
 
-Total time: 18 wallclock secs ( 3.58 usr  2.86 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 18 wallclock secs ( 3.58 usr  2.87 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh
index 54a5d624b32cd0439f0002fed0f5a86d08b02de3..d18d2c79ced1afb0708a68758ef1d80d0399b1cd 100644
--- a/sql-bench/bench-init.pl.sh
+++ b/sql-bench/bench-init.pl.sh
@@ -31,7 +31,7 @@
 # $server	Object for current server
 # $limits	Hash reference to limits for benchmark
 
-$benchmark_version="2.11";
+$benchmark_version="2.11a";
 use Getopt::Long;
 
 require "$pwd/server-cfg" || die "Can't read Configuration file: $!\n";
@@ -51,7 +51,7 @@ $log_prog_args=join(" ", skip_arguments(\@ARGV,"comments","cmp","server",
 					"user", "host", "database", "password",
 					"use-old-results","skip-test",
 					"machine", "dir", "suffix", "log"));
-GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","old-headers","die-on-errors","create-options=s","hires","tcpip") || usage();
+GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","old-headers","die-on-errors","create-options=s","hires","tcpip","silent") || usage();
 
 usage() if ($opt_help);
 $server=get_server($opt_server,$opt_host,$opt_database,$opt_odbc,
@@ -495,12 +495,15 @@ All benchmarks takes the following options:
   Known servers names are: Access, Adabas, AdabasD, Empress, Oracle,
   Informix, DB2, mSQL, MS-SQL, MySQL, Pg, Solid and Sybase
 
+--silent
+  Don't print info about the server when starting test.
+
 --skip-delete
   This is a test specific option that is only used when debugging a test.
   This will keep the test tables after the test is run.
 
 --skip-test=test1[,test2,...]
-  For run-all-programs;  Don\'t execute the named tests
+  For run-all-programs;  Don\'t execute the named tests.
 
 --small-test
   This runs some tests with smaller limits to get a faster test.
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 0b8fbfdf78862a2f218e0ad4df4c3e0a29b1f948..1d72f21df1dfcc4f0b38546447b2fba297b1f906 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -258,7 +258,7 @@ ulong refresh_version=1L,flush_version=1L;	/* Increments on each reload */
 ulong query_id=1L,long_query_count,long_query_time,aborted_threads,
       aborted_connects,delayed_insert_timeout,delayed_insert_limit,
       delayed_queue_size,delayed_insert_threads,delayed_insert_writes,
-      delayed_rows_in_use,delayed_insert_errors,flush_time;
+      delayed_rows_in_use,delayed_insert_errors,flush_time, thread_created;
 ulong filesort_rows, filesort_range_count, filesort_scan_count;
 ulong filesort_merge_passes;
 ulong select_range_check_count, select_range_count, select_scan_count;
@@ -801,7 +801,9 @@ static void server_init(void)
       sql_print_error("Do you already have another mysqld server running on port: %d ?",mysql_port);
       unireg_abort(1);
     }
-    (void) listen(ip_sock,(int) back_log);
+    if (listen(ip_sock,(int) back_log) < 0)
+      sql_print_error("Warning:  listen() on TCP/IP failed with error %d",
+		      errno);
   }
 
   if (mysqld_chroot)
@@ -886,7 +888,9 @@ static void server_init(void)
 #if defined(S_IFSOCK) && defined(SECURE_SOCKETS)
     (void) chmod(mysql_unix_port,S_IFSOCK);	/* Fix solaris 2.6 bug */
 #endif
-    (void) listen(unix_sock,(int) back_log);
+    if (listen(unix_sock,(int) back_log) < 0)
+      sql_print_error("Warning:  listen() on Unix socket failed with error %d",
+		      errno);
   }
 #endif
   DBUG_PRINT("info",("server started"));
@@ -1082,6 +1086,8 @@ inline static __volatile__ void  trace_stack()
   uchar **stack_bottom;
   uchar** ebp;
   LINT_INIT(ebp);
+  LINT_INIT(stack_bottom);
+
   fprintf(stderr,
 "Attemping backtrace. You can use the following information to find out\n\
 where mysqld died.  If you see no messages after this, something went\n\
@@ -1099,12 +1105,15 @@ terribly wrong\n");
   }
   if (!thd)
   {
-    fprintf(stderr, "Cannot determine thread, ebp=%p, aborting backtrace\n",
-	    ebp);
-    return;
+    fprintf(stderr, "Cannot determine thread, ebp=%p, backtrace may not be correct\n", ebp);
+    /* Assume that the stack starts at the previous even 65K */
+    ulong tmp= min(0x10000,thread_stack);
+    stack_bottom= (uchar**) (((ulong) &stack_bottom + tmp) &
+			     ~(ulong) 0xFFFF);
   }
-  stack_bottom = (uchar**)thd->thread_stack;
-  if(ebp > stack_bottom || ebp < stack_bottom - thread_stack)
+  else
+    stack_bottom = (uchar**) thd->thread_stack;
+  if (ebp > stack_bottom || ebp < stack_bottom - thread_stack)
   {
     fprintf(stderr,
 	    "Bogus stack limit or frame pointer, aborting backtrace\n");
@@ -2010,6 +2019,7 @@ static void create_new_thread(THD *thd)
     {
       int error;
       thread_count++;
+      thread_created++;
       threads.append(thd);
       DBUG_PRINT("info",(("creating thread %d"), thd->thread_id));
       thd->connect_time = time(NULL);
@@ -2595,7 +2605,7 @@ CHANGEABLE_VAR changeable_vars[] = {
   { "thread_concurrency",      (long*) &concurrency,
       DEFAULT_CONCURRENCY, 1, 512, 0, 1 },
   { "thread_cache_size",       (long*) &thread_cache_size,
-      0, 1, 16384, 0, 1 },
+      0, 0, 16384, 0, 1 },
   { "tmp_table_size",          (long*) &tmp_table_size,
       1024*1024L, 1024, ~0L, MALLOC_OVERHEAD, 1 },
   { "thread_stack",            (long*) &thread_stack,
@@ -2748,6 +2758,7 @@ struct show_var_st status_vars[]= {
   {"Sort_rows",		       (char*) &filesort_rows,	        SHOW_LONG},
   {"Sort_scan",		       (char*) &filesort_scan_count,    SHOW_LONG},
   {"Threads_cached",           (char*) &cached_thread_count,    SHOW_LONG_CONST},
+  {"Threads_created",	       (char*) &thread_created,		SHOW_LONG_CONST},
   {"Threads_connected",        (char*) &thread_count,           SHOW_INT_CONST},
   {"Threads_running",          (char*) &thread_running,         SHOW_INT_CONST},
   {"Uptime",                   (char*) 0,                       SHOW_STARTTIME},
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index 333c225276147a93428abf03b2f64620deb14b07..5204c22962fc79d3970cf5d93722289c8f4bbfab 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -302,7 +302,6 @@ fi
 %attr(755, root, root) /usr/bin/mysql_fix_privilege_tables
 %attr(755, root, root) /usr/bin/mysql_convert_table_format
 %attr(755, root, root) /usr/bin/mysql_install_db
-%attr(755, root, root) /usr/bin/mysql_config
 %attr(755, root, root) /usr/bin/mysql_setpermission
 %attr(755, root, root) /usr/bin/mysql_zap
 %attr(755, root, root) /usr/bin/mysqlbug