From b55de19ed2e26603858d51be232adfecf1c429f6 Mon Sep 17 00:00:00 2001
From: "monty@donna.mysql.com" <>
Date: Wed, 4 Oct 2000 23:20:16 +0300
Subject: [PATCH] Portability fixes

---
 BitKeeper/etc/logging_ok    |   2 +-
 Docs/manual.texi            |  21 +++--
 config.guess                |   3 +
 config.sub                  |   2 +-
 configure.in                |  22 ++++-
 extra/my_print_defaults.c   |   2 +-
 include/my_pthread.h        |  13 +++
 ltconfig                    |   2 +-
 myisam/mi_check.c           |   6 +-
 mysys/Makefile.am           |   3 +-
 mysys/mf_cache.c            |  12 ---
 mysys/mf_tempfile.c         | 173 ++++++++++++++++++++++++++++++++++++
 sql/log.cc                  |   5 +-
 sql/sql_cache.cc            |   4 +-
 sql/sql_show.cc             |  51 ++++++-----
 strings/strtol.c            |   2 +-
 support-files/mysql.spec.sh |   4 +-
 17 files changed, 261 insertions(+), 66 deletions(-)
 create mode 100644 mysys/mf_tempfile.c

diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index a3e121b77e3..84bd71dbd9f 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -1 +1 @@
-monty@tramp.mysql.fi
+monty@donna.mysql.com
diff --git a/Docs/manual.texi b/Docs/manual.texi
index e74c919731e..fb4b6edc45a 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -2161,7 +2161,7 @@ Webmerger -  This CGI tool interprets files and generates dynamic output
 based on a set of simple tags. Ready-to-run drivers for @strong{MySQL} and
 PostgreSQL through ODBC.
 
-@item @uref{http://phpclub.unet.ru/index_e.php3}@*
+@item @uref{http://phpclub.net/}@*
 PHPclub - Tips and tricks for PHP.
 
 @item @uref{http://www.penguinservices.com/scripts}@*
@@ -35859,7 +35859,7 @@ don't yet support:
 
 @table @code
 @item Sub select
-@item Foregin keys
+@item Foreign keys
 @item Stored procedures
 @item An extendable type system.
 @item A way to extend the SQL to handle new key types (like R-trees)
@@ -36670,13 +36670,12 @@ only on Linux.
 You can always find the latest version
 @uref{http://www.trash.net/~ffischer/admin/index.html, here}.
 
-@c Link temporary removed on request because of a bug in the current version
-@c @item @uref{http://www.mysql.com/Downloads/Win32/MySQL-Maker092.zip,MySQL-Maker 092}.
-@c Shareware @strong{MySQL} client for windows. It's WYSIWYG tool which allows
-@c you to create, change and delete databases and tables.
-@c You can change field - structure and add, change and delete data in
-@c these tables directly without ODBC-driver.
-@c @uref{http://62.26.183.157/presult/support/su_sweiche_download.html, MySQL Maker homepage}
+@item @uref{http://www.mysql.com/Downloads/Win32/MySQL-Maker-1.0.zip,MySQL-Maker 1.0}.
+Shareware @strong{MySQL} client for windows. It's WYSIWYG tool which allows
+you to create, change and delete databases and tables.
+You can change field - structure and add, change and delete data in
+these tables directly without ODBC-driver.
+@uref{http://www.presult.de/presult/frames/fs_mysqlmaker.html, MySQL Maker homepage}
 
 @item @uref{http://www.mysql.com/Downloads/Contrib/mysqlwinadmn.zip, mysqlwinadmn.zip}
 Windows GUI (binary only) to administrate a database, by David B. Mansel,
@@ -36979,8 +36978,8 @@ Raw port of a SQL mode for XEmacs. Supports completion. Original by
 Peter D. Pezaris @email{pez@@atlantic2.sbi.com} and partial
 @strong{MySQL} port by David Axmark.
 
-@item @uref{http://www.mysql.com/Downloads/Win32/myaccess97_1_1.zip, MyAccess97 1.1}
-@item @uref{http://www.mysql.com/Downloads/Win32/myaccess2000_1_1.zip, MyAccess2000 1.1}
+@item @uref{http://www.mysql.com/Downloads/Win32/myaccess97_1_3.zip, MyAccess97 1.3}
+@item @uref{http://www.mysql.com/Downloads/Win32/myaccess2000_1_3.zip, MyAccess2000 1.3}
 
 MyAccess is an AddIn for MS Access 97/2000 which allows you to manage MySQL databases from within Access. Main functions are:
 @itemize @bullet
diff --git a/config.guess b/config.guess
index cd4de2b0090..eb88894019f 100755
--- a/config.guess
+++ b/config.guess
@@ -987,6 +987,9 @@ EOF
     *:Rhapsody:*:*)
 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
 	exit 0 ;;
+    *:Darwin:*:*)
+	echo `uname -p`-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
diff --git a/config.sub b/config.sub
index a5b9229f850..8f28d3f7be8 100755
--- a/config.sub
+++ b/config.sub
@@ -919,7 +919,7 @@ case $os in
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
-	      | -interix* | -uwin* | -rhapsody* | -openstep* | -oskit*)
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -openstep* | -oskit*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
diff --git a/configure.in b/configure.in
index 394b4f83a89..1842ac5d2fc 100644
--- a/configure.in
+++ b/configure.in
@@ -331,7 +331,13 @@ elif $PS $$ 2> /dev/null | grep $0 > /dev/null
 then
   FIND_PROC="$PS \$\$PID | grep mysqld > /dev/null"
 else
-  AC_MSG_ERROR([Could not find the right ps switches. Which OS is this ?. See the Installation chapter in the Reference Manual.])
+  case $SYSTEM_TYPE in
+    *darwin*)
+      FIND_PROC="$PS -uaxww | grep mysqld | grep \" \$\$PID \" > /dev/null"
+      ;;
+    *)
+      AC_MSG_ERROR([Could not find the right ps switches. Which OS is this ?. See the Installation chapter in the Reference Manual.])
+  esac
 fi
 AC_SUBST(FIND_PROC)
 AC_MSG_RESULT("$FIND_PROC")
@@ -619,6 +625,7 @@ int main()
 # Some system specific hacks
 #
 
+MAX_C_OPTIMIZE="-O6"
 case $SYSTEM_TYPE in
   *solaris2.7*)
     # Solaris 2.7 has a broken /usr/include/widec.h
@@ -674,6 +681,15 @@ case $SYSTEM_TYPE in
       fi
     fi
     ;;
+  *darwin*)
+    if test "$ac_cv_prog_gcc" = "yes"
+    then
+      CFLAGS="$CFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS"
+      CXXFLAGS="$CXXFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS"
+      MAX_C_OPTIMIZE="-O"
+      with_named_curses=""
+    fi
+    ;;
   *freebsd*)
     echo "Adding fix for interrupted reads"
     CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000"
@@ -1012,7 +1028,7 @@ if test "$ac_cv_prog_gcc" = "yes"
 then
   DEBUG_CFLAGS="-g"
   DEBUG_OPTIMIZE_CC="-O"
-  OPTIMIZE_CFLAGS="-O6"
+  OPTIMIZE_CFLAGS="$MAX_C_OPTIMIZE"
 else
   DEBUG_CFLAGS="-g"
   DEBUG_OPTIMIZE_CC=""
@@ -1221,7 +1237,7 @@ AC_CHECK_FUNCS(alarm bmove \
  getrusage getpwuid getcwd getrlimit getwd index stpcpy locking longjmp \
  perror pread realpath rename \
  socket strnlen madvise \
- strtoul strtoull snprintf tempnam thr_setconcurrency \
+ strtol strtoul strtoull snprintf tempnam thr_setconcurrency \
  gethostbyaddr_r gethostbyname_r getpwnam \
  bfill bzero bcmp strstr strpbrk strerror\
  tell atod memcpy memmove \
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index a6e67e4949e..01fc4108352 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -48,7 +48,7 @@ static void usage(my_bool version)
   puts("Prints all arguments that is give to some program using the default files");
   printf("Usage: %s [OPTIONS] groups\n",my_progname);
   printf("\n\
-  -c, --config-file=# --defaults-file=#\n\
+  -c, --config-file=#, --defaults-file=#\n\
 	                The config file to use (default '%s')\n\
   --no-defaults		Return an empty string (useful for scripts)\n\
   -?, --help		Display this help message and exit.\n\
diff --git a/include/my_pthread.h b/include/my_pthread.h
index e34fffbb239..2ecd4e20482 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -346,6 +346,19 @@ struct tm *localtime_r(const time_t *clock, struct tm *res);
 #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
 #endif
 
+#ifdef HAVE_DARWIN_THREADS
+#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
+#define pthread_kill(A,B) pthread_dummy(0)
+#define pthread_condattr_init(A) pthread_dummy(0)
+#define pthread_condattr_destroy(A) pthread_dummy(0)
+#define pthread_cond_init( A, B ) pthread_cond_init( (A), 0 )
+#define pthread_signal(A,B) pthread_dummy(0)
+#undef	pthread_detach_this_thread
+#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
+#undef sigset
+#define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
+#endif
+
 #if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
 /* This is set on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too) */
 #define pthread_key_create(A,B) \
diff --git a/ltconfig b/ltconfig
index a6d3dfd4567..aa2b5c02dd1 100755
--- a/ltconfig
+++ b/ltconfig
@@ -1798,7 +1798,7 @@ bsdi4*)
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
-  file_magic_cmd=/usr/bin/file
+  file_magic_cmd="/usr/bin/file -L"
   file_magic_test_file=/shlib/libc.so
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
   sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index f2787546a31..c6a07ff9c36 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -2922,8 +2922,10 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
       !(((ulonglong) 1 << (info->s->base.auto_key-1)
 	 & info->s->state.key_map)))
   {
-    mi_check_print_info(param,"Table: %s doesn't have an auto increment key\n",
-			param->isam_file_name);
+    if (!(param->testflag & T_VERY_SILENT))
+      mi_check_print_info(param,
+			  "Table: %s doesn't have an auto increment key\n",
+			  param->isam_file_name);
     return;
   }
   if (!(param->testflag & T_SILENT) &&
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 6697bfeeae4..6b38d9364f6 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -26,7 +26,8 @@ libmysys_a_SOURCES =	my_init.c my_getwd.c mf_getdate.c\
 			mf_path.c mf_loadpath.c\
 			my_open.c my_create.c my_seek.c my_read.c \
 			my_pread.c my_write.c \
-			mf_reccache.c mf_keycache.c mf_iocache.c mf_cache.c \
+			mf_reccache.c mf_keycache.c \
+			mf_iocache.c mf_cache.c mf_tempfile.c \
 			my_lock.c mf_brkhant.c my_alarm.c \
 			my_malloc.c my_realloc.c my_once.c mulalloc.c \
 			my_alloc.c safemalloc.c my_fopen.c my_fstream.c \
diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c
index 9017bf4f18c..2c197f6fd20 100644
--- a/mysys/mf_cache.c
+++ b/mysys/mf_cache.c
@@ -21,18 +21,6 @@
 #include <m_string.h>
 #include "my_static.h"
 #include "mysys_err.h"
-#include <paths.h>
-
-#define TMP_EXT ".tmp"				/* Extension of tempfile  */
-#if ! defined(P_tmpdir)
-#define P_tmpdir ""
-#endif
-
-#ifdef HAVE_TEMPNAM
-#ifndef MSDOS
-extern char **environ;
-#endif
-#endif
 
 	/*
 	  Remove an open tempfile so that it doesn't survive
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c
new file mode 100644
index 00000000000..a202dd13d8b
--- /dev/null
+++ b/mysys/mf_tempfile.c
@@ -0,0 +1,173 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+   
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+   
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+#include "mysys_priv.h"
+#include <m_string.h>
+#include "my_static.h"
+#include "mysys_err.h"
+#include <errno.h>
+#ifdef HAVE_PATH_H
+#include <paths.h>
+#endif
+
+#ifdef HAVE_TEMPNAM
+#ifndef MSDOS
+extern char **environ;
+#endif
+#endif
+
+/*
+  Create a temporary file in a given directory
+  This function should be used instead of my_tempnam() !
+*/
+
+File create_temp_file(char *to, const char *dir, const char *prefix,
+		      int mode, myf MyFlags)
+{
+  File file= -1;
+  DBUG_ENTER("open_temp_file");
+#if defined(_MSC_VER)
+  {
+    char *end,*res,**old_env,*temp_env[1];
+    old_env=environ;
+    if (dir)
+    {
+      end=strend(dir)-1;
+      if (!dir[0])
+      {				/* Change empty string to current dir */
+	to[0]= FN_CURLIB;
+	to[1]= 0;
+	dir=to;
+      }
+      else if (*end == FN_DEVCHAR)
+      {				/* Get current dir for drive */
+	_fullpath(temp,dir,FN_REFLEN);
+	dir=to;
+      }
+      else if (*end == FN_LIBCHAR && dir < end && end[-1] != FN_DEVCHAR)
+      {
+	strmake(to,dir,(uint) (end-dir));	/* Copy and remove last '\' */
+	dir=to;
+      }
+      environ=temp_env;		/* Force use of dir (dir not checked) */
+      temp_env[0]=0;
+    }
+    if ((res=tempnam((char*) dir,(char *) prefix)))
+    {
+      strnmov(to,res,FN_REFLEN);
+      (*free)(res);
+      file=my_create(to,0, mode, MyFlags);
+    }
+    environ=old_env;
+  }
+#elif defined(_ZTC__)
+  if (!dir)
+    dir=getenv("TMPDIR");
+  if ((res=tempnam((char*) dir,(char *) prefix)))
+  {
+    strnmov(to,res,FN_REFLEN);
+    (*free)(res);
+    file=my_create(to, 0, mode, MyFlags);
+  }
+#elif defined(HAVE_MKSTEMP)
+  {
+    char prefix[30];
+    uint pfx_len;
+
+    pfx_len=(strmov(strnmov(prefix,
+			    prefix ? prefix : "tmp.",
+			    sizeof(prefix)-7),"XXXXXX") - prefix);
+    if (!dir && ! (dir =getenv("TMPDIR")))
+      dir=P_tmpdir;
+    if (strlen(dir)+ pfx_len > FN_REFLEN-2)
+    {
+      errno=my_errno= ENAMETOOLONG;
+      return 1;
+    }
+    strmov(to,dir);
+    strmov(convert_dirname(to),prefix);
+    file=mkstemp(to);
+  }
+#elif defined(HAVE_TEMPNAM)
+  {
+    char *res,**old_env,*temp_env[1];
+    if (dir && !dir[0])
+    {				/* Change empty string to current dir */
+      to[0]= FN_CURLIB;
+      to[1]= 0;
+      dir=to;
+    }
+    old_env=environ;
+    if (dir)
+    {				/* Don't use TMPDIR if dir is given */
+      environ=temp_env;
+      temp_env[0]=0;
+    }
+    if ((res=tempnam((char*) dir, (char*) prefix)))
+    {    
+      strnmov(to,res,FN_REFLEN);
+      (*free)(res);
+      file=my_create(to,0,
+		     (int) (O_RDWR | O_BINARY | O_TRUNC |
+			    O_TEMPORARY | O_SHORT_LIVED),
+		     MYF(MY_WME));
+
+    }
+    else
+    {
+      DBUG_PRINT("error",("Got error: %d from tempnam",errno));
+    }
+    environ=old_env;
+  }
+#else
+  {
+    register long uniq;
+    register int length;
+    my_string pos,end_pos;
+    /* Make an unique number */
+    pthread_mutex_lock(&THR_LOCK_open);
+    uniq= ((long) getpid() << 20) + (long) _my_tempnam_used++ ;
+    pthread_mutex_unlock(&THR_LOCK_open);
+    if (!dir && !(dir=getenv("TMPDIR")))	/* Use this if possibly */
+      dir=P_tmpdir;			/* Use system default */
+    length=strlen(dir)+strlen(pfx)+1;
+
+    DBUG_PRINT("test",("mallocing %d byte",length+8+sizeof(TMP_EXT)+1));
+    if (length+8+sizeof(TMP_EXT)+1 > FN_REFLENGTH)
+      errno=my_errno= ENAMETOOLONG;
+    else
+    {
+      end_pos=strmov(to,dir);
+      if (end_pos != to && end_pos[-1] != FN_LIBCHAR)
+	*end_pos++=FN_LIBCHAR;
+      end_pos=strmov(end_pos,pfx);
+      
+      for (length=0 ; length < 8 && uniq ; length++)
+      {
+	*end_pos++= _dig_vec[(int) (uniq & 31)];
+	uniq >>= 5;
+      }
+      (void) strmov(end_pos,TMP_EXT);
+      file=my_create(to,0,
+		     (int) (O_RDWR | O_BINARY | O_TRUNC |
+			    O_TEMPORARY | O_SHORT_LIVED),
+		     MYF(MY_WME));
+    }
+  }
+#endif
+  DBUG_RETURN(file);
+}
diff --git a/sql/log.cc b/sql/log.cc
index 94cd553bfce..1f12bcacf6c 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -149,7 +149,8 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
     fn_format(index_file_name, name, mysql_data_home, ".index", 6);
   
   db[0]=0;
-  file=my_fopen(log_file_name,O_APPEND | O_WRONLY,MYF(MY_WME | ME_WAITTANG));
+  file=my_fopen(log_file_name,O_APPEND | O_WRONLY | O_BINARY,
+		MYF(MY_WME | ME_WAITTANG));
   if (!file)
   {
     my_free(name,MYF(0));    
@@ -188,7 +189,7 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
   {
     Start_log_event s;
     if(!index_file && 
-       !(index_file = my_fopen(index_file_name,O_APPEND | O_RDWR,
+       !(index_file = my_fopen(index_file_name,O_APPEND | O_BINARY | O_RDWR,
 			       MYF(MY_WME))))
     {
       my_fclose(file,MYF(MY_WME));
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 78053d0d3e3..09d436c0c9c 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -19,10 +19,10 @@
 #include <my_dir.h>
 #include <hash.h>
 
-#define SQL_CACHE_LENGTH 300
+#define SQL_CACHE_LENGTH 30			// 300 crashes apple gcc.
 
 HASH sql_cache;
-LEX lex_array_static[SQL_CACHE_LENGTH];
+static LEX lex_array_static[SQL_CACHE_LENGTH];
 LEX * lex_array = lex_array_static;
 int last_lex_array_item = SQL_CACHE_LENGTH - 1;
 
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index ea6e09f6cb5..83a53467426 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -476,6 +476,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
   DBUG_PRINT("enter",("db: %s  table: %s",table_list->db,
                       table_list->real_name));
 
+  /* Only one table for now */
   if (!(table = open_ltable(thd, table_list, TL_UNLOCK)))
   {
     send_error(&thd->net);
@@ -490,34 +491,32 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
     DBUG_RETURN(1);
 
   String *packet = &thd->packet;
-  for(;table; table = table->next)
-    {
-      packet->length(0);
-      net_store_data(packet, table->table_name);
-      // a hack - we need to reserve some space for the length before
-      // we know what it is - let's assume that the length of create table
-      // statement will fit into 3 bytes ( 16 MB max :-) )
-      ulong store_len_offset = packet->length();
-      packet->length(store_len_offset + 4);
-      if(store_create_info(thd, table, packet))
-        DBUG_RETURN(-1);
-      ulong create_len = packet->length() - store_len_offset - 4;
-      if(create_len > 0x00ffffff) // better readable in HEX ...
-        DBUG_RETURN(1);  // just in case somebody manages to create a table
-      // with *that* much stuff in the definition
+  {
+    packet->length(0);
+    net_store_data(packet, table->table_name);
+    // a hack - we need to reserve some space for the length before
+    // we know what it is - let's assume that the length of create table
+    // statement will fit into 3 bytes ( 16 MB max :-) )
+    ulong store_len_offset = packet->length();
+    packet->length(store_len_offset + 4);
+    if (store_create_info(thd, table, packet))
+      DBUG_RETURN(-1);
+    ulong create_len = packet->length() - store_len_offset - 4;
+    if (create_len > 0x00ffffff) // better readable in HEX ...
+      DBUG_RETURN(1);  // just in case somebody manages to create a table
+    // with *that* much stuff in the definition
 
-      // now we have to store the length in three bytes, even if it would fit
-      // into fewer, so we cannot use net_store_data() anymore,
-      // and do it ourselves
-      char* p = (char*)packet->ptr() + store_len_offset;
-      *p++ = (char) 253; // The client the length is stored using 3-bytes
-      int3store(p, create_len);
-
-      // now we are in business :-)
-      if(my_net_write(&thd->net, (char*)packet->ptr(), packet->length()))
-        DBUG_RETURN(1);
-    }
+    // now we have to store the length in three bytes, even if it would fit
+    // into fewer, so we cannot use net_store_data() anymore,
+    // and do it ourselves
+    char* p = (char*)packet->ptr() + store_len_offset;
+    *p++ = (char) 253; // The client the length is stored using 3-bytes
+    int3store(p, create_len);
 
+    // now we are in business :-)
+    if (my_net_write(&thd->net, (char*)packet->ptr(), packet->length()))
+      DBUG_RETURN(1);
+  }
   send_eof(&thd->net);
   DBUG_RETURN(0);
 }
diff --git a/strings/strtol.c b/strings/strtol.c
index ae3fdd0e2b3..87fe0d22cf3 100644
--- a/strings/strtol.c
+++ b/strings/strtol.c
@@ -18,6 +18,6 @@
 /* This defines strtol() if neaded */
 
 #include <global.h>
-#if !defined(MSDOS) && !defined(HAVE_STRTOUL) && !defined(__WIN__)
+#if !defined(MSDOS) && !defined(HAVE_STRTOL) && !defined(__WIN__)
 #include "strto.c"
 #endif
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index c36a268448c..15591c7156b 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -311,7 +311,7 @@ fi
 %attr(755, root, root) /usr/bin/safe_mysqld
 %attr(755, root, root) /usr/bin/my_print_defaults
 
-%attr(644, root, root) /usr/info/mysql.info
+%attr(644, root, root) /usr/info/mysql.info.gz
 
 %attr(755, root, root) /usr/sbin/mysqld
 
@@ -331,7 +331,7 @@ fi
 %attr(755, root, root) /usr/bin/mysqlshow
 %attr(755, root, root) /usr/bin/mysqlbinlog
 
-%attr(644, root, man) %doc /usr/man/man1/mysql.1
+%attr(644, root, man) %doc /usr/man/man1/mysql.1.gz
 
 %post shared
 /sbin/ldconfig