From 844c92364e04fb17371c4a71dee52f179f8ad253 Mon Sep 17 00:00:00 2001
From: unknown <monty@donna.mysql.com>
Date: Wed, 23 Aug 2000 15:02:27 +0300
Subject: [PATCH 1/2] Fixes for Ia64

Docs/manual.texi:
  Updated thread safe client chapter + new links
client/sql_string.cc:
  Update for Ia64
client/sql_string.h:
  Update for Ia64
extra/replace.c:
  Update for Ia64
include/config-win.h:
  Update for PHP
include/global.h:
  Update for PHP
isam/create.c:
  Update for Ia64
isam/delete.c:
  Update for Ia64
isam/write.c:
  Update for Ia64
libmysql/Makefile.shared:
  new file
libmysql/libmysql.c:
  Update for Ia64
libmysql/net.c:
  Update for Ia64
myisam/mi_delete.c:
  Update for Ia64
myisam/mi_search.c:
  Update for Ia64
sql/field.cc:
  Update for Ia64
sql/field.h:
  Update for Ia64
sql/item.h:
  Update for Ia64
sql/item_strfunc.cc:
  Update for Ia64
sql/lock.cc:
  Update for Ia64
sql/log.cc:
  Update for Ia64
sql/log_event.h:
  Update for Ia64
sql/net_serv.cc:
  Update for Ia64
sql/sql_list.h:
  Update for Ia64
sql/sql_parse.cc:
  Update for Ia64
sql/sql_rename.cc:
  Update for Ia64
sql/sql_select.cc:
  Update for Ia64
sql/sql_show.cc:
  Update for Ia64
sql/sql_string.cc:
  Update for Ia64
sql/sql_string.h:
  Update for Ia64
sql/time.cc:
  Update for Ia64
---
 Docs/manual.texi         | 114 +++++++++++++++++++--------------------
 client/sql_string.cc     |  33 ++++++++----
 client/sql_string.h      |   7 +--
 extra/replace.c          |   6 +--
 include/config-win.h     |  12 +++--
 include/global.h         |   4 +-
 isam/create.c            |   5 +-
 isam/delete.c            |  18 ++++---
 isam/write.c             |   2 +-
 libmysql/Makefile.shared |   1 +
 libmysql/libmysql.c      |   3 +-
 libmysql/net.c           |   2 +-
 myisam/mi_delete.c       |   8 +--
 myisam/mi_search.c       |   2 +-
 sql/field.cc             |   2 +-
 sql/field.h              |   2 +-
 sql/item.h               |   4 +-
 sql/item_strfunc.cc      |   6 +--
 sql/lock.cc              |   2 +-
 sql/log.cc               |   2 +-
 sql/log_event.h          |   4 +-
 sql/net_serv.cc          |   2 +-
 sql/sql_list.h           |   2 +-
 sql/sql_parse.cc         |   2 +-
 sql/sql_rename.cc        |   3 +-
 sql/sql_select.cc        |   4 +-
 sql/sql_show.cc          |   5 +-
 sql/sql_string.cc        |  33 ++++++------
 sql/sql_string.h         |  23 ++++----
 sql/time.cc              |   2 +-
 30 files changed, 173 insertions(+), 142 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index b661d78605a..2a466ddee47 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -5004,12 +5004,11 @@ and that provides output about what is happening.
 @xref{Debugging server}.
 
 @item
-If your client programs are using threads, you need to compile the
-@strong{MySQL} client library to be thread safe with
-@code{--with-thread-safe-client}; this forces the library to use thread
-safe functions calls for some functions that are not thread safe by
-default. You pay a very small performance penalty by doing this, but
-generally it's quite safe to use this option.
+If your client programs are using threads, you need to also compile a
+thread safe version of the @strong{MySQL} client library with the
+@code{--with-thread-safe-client} configure options. This will create a
+@code{libmysqlclient_r} library with which you should link your threaded
+applications. @xref{Thread-safe clients}.
 
 @item
 Options that pertain to particular systems can be found in the
@@ -30101,24 +30100,8 @@ The @strong{MySQL} server shrinks each communication buffer to
 the buffer associated with a connection is not decreased until the connection
 is closed, at which time client memory is reclaimed.
 
-If you are programming with threads, you should compile the
-@strong{MySQL} C API with @code{--with-thread-safe-client}.  This will make
-the C API thread safe per connection.   You can let two threads share the same
-connection as long as you do the following:
-
-@table @asis
-@item
-Two threads can't send a query to the @strong{MySQL} at the same time on
-the same connection.  In particular you have to ensure that between a
-@code{mysql_query()} and @code{mysql_store_result()} no other thread is using
-the same connection.
-@item
-Many threads can access different result sets that are retrieved with
-@code{mysql_store_result()}.
-@item
-If you use @code{mysql_use_result}, you have to ensure that no other thread
-is asking anything on the same connection until the result set is closed.
-@end table
+For programming with threads, consult the 'how to make a thread safe
+client' chapter. @xref{Thread-safe clients}.
 
 @node C API datatypes, C API function overview, C, Clients
 @section C API datatypes
@@ -32769,18 +32752,21 @@ have your own alarm that can break a long read to a server.  If you
 install an interrupt handlers for the @code{SIGPIPE} interrupt,
 the socket handling should be thread safe. 
 
-In the standard binaries we distribute on our web site, the client libraries
-are not normally compiled with the thread safe option.
+In the older binaries we distribute on our web site, the client
+libraries are not normally compiled with the thread safe option (the
+windows binaries are however by default compiled to be thread safe).
+Newer binary distributions should however have both a normal and a
+threadsafe client library.
 
 To get a really thread-safe client where you can interrupt the client
 from other threads and set timeouts when talking with the MySQL server,
 you should use the @code{-lmysys}, @code{-lstring} and @code{-ldbug}
 libraries and the @code{net_serv.o} code that the server uses.
 
-If you don't need interrupts or timeouts you can just compile the client
-library @code{(mysqlclient)} to be thread safe and use this.  In this
-case you don't have to worry about the @code{net_serv.o} object file or
-the other @strong{MySQL} libraries.
+If you don't need interrupts or timeouts you can just compile a tread
+safe client library @code{(mysqlclient_r)} and use this.  @xref{C,,
+MySQL C API}.  In this case you don't have to worry about the
+@code{net_serv.o} object file or the other @strong{MySQL} libraries.
 
 When using a threaded client and you want to use timeouts and interrupts,
 you can make great use of the routines in the @file{thr_alarm.c} file.
@@ -32798,36 +32784,43 @@ To make @code{mysql_real_connect()} thread-safe, you must recompile the
 client library with this command:
 
 @example
-shell> ./configure --enable-thread-safe-client
+shell> ./configure --with-thread-safe-client
 @end example
 
-This will ensure that the client library will use the header files required
-for thread safe programs and also that @code{mysql_real_connect()} will use
-a thread safe version of the @code{gethostbyname()} call.
+This will create a thread safe client library @code{libmysqlclient_r}.
+@code{--with-thread-safe-client}.  This library is is thread safe per
+connection.  You can let two threads share the same connection as long
+as you do the following:
 
-You may get some errors because of undefined symbols when linking the
-standard client, because the pthread libraries are not included by
-default.
-
-The resulting @file{libmysqlclient.a} library is now thread-safe.  What this
-means is that client code is thread-safe as long as two threads don't query
-the same connection handle returned by @code{mysql_real_connect()} at the
-same time; the client/server protocol allows only one request at a time on a
-given connection.  If you want to use multiple threads on the same
-connection, you must have a mutex lock around your @code{mysql_query()} and
+@table @asis
+@item
+Two threads can't send a query to the @strong{MySQL} at the same time on
+the same connection.  In particular you have to ensure that between a
+@code{mysql_query()} and @code{mysql_store_result()} no other thread is using
+the same connection.
+@item
+Many threads can access different result sets that are retrieved with
+@code{mysql_store_result()}.
+@item
+If you use @code{mysql_use_result}, you have to ensure that no other thread
+is asking anything on the same connection until the result set is closed.
+However, it really is best for threaded clients that share the same
+connection to use @code{mysql_use_result()}.
+@item
+If you want to use multiple threads on the same connection, you must
+have a mutex lock around your @code{mysql_query()} and
 @code{mysql_store_result()} call combination.  Once
 @code{mysql_store_result()} is ready, the lock can be released and other
-threads may query the same connection.  (In other words, different threads
-can use different @code{MYSQL_RES} pointers that were created with
-@code{mysql_store_result()}, as long as they use the proper locking
-protocol.) If you program with POSIX threads, you can use
-@code{pthread_mutex_lock()} and @code{pthread_mutex_unlock()} to establish
-and release a mutex lock.
+threads may query the same connection.
+@item
+If you program with POSIX threads, you can use
+@code{pthread_mutex_lock()} and @code{pthread_mutex_unlock()} to
+establish and release a mutex lock.
+@end table
 
-If you used @code{mysql_use_result()} rather than @code{mysql_store_result()},
-the lock would need to surround @code{mysql_use_result()} and the calls
-to @code{mysql_fetch_row()}.  However, it really is best for threaded
-clients not to use @code{mysql_use_result()}.
+You may get some errors because of undefined symbols when linking your
+client with @code{mysqlclient_r};  In most cases this is because you haven't
+included the thread libraries on the link/compile line.
 
 @node Perl, Eiffel, C API functions, Clients
 @section MySQL Perl API
@@ -34652,9 +34645,8 @@ The @strong{MySQL} GUI client homepage. By Sinisa at MySQL AB.
 An administration tool for the @strong{MySQL} server using QT / KDE.  Tested
 only on Linux.
 
-@item @uref{http://www.mysql.com/Downloads/Contrib/mysql-admin-using-java+swing.tar.gz, Java client
-using Swing} By Fredy Fischer, @email{se-afs@@dial.eunet.ch}. You can
-always find the latest version
+@item @uref{http://www.mysql.com/Downloads/Contrib/mysql-admin-using-java+swing.tar.gz, Java client using Swing} By Fredy Fischer, @email{se-afs@@dial.eunet.ch}.
+You can always find the latest version
 @uref{http://www.trash.net/~ffischer/admin/index.html, here}.
 
 @item @uref{http://www.mysql.com/Downloads/Contrib/mysqlwinadmn.zip, mysqlwinadmn.zip}
@@ -34676,6 +34668,14 @@ URL @url{http://www.it-netservice.de/pages/software/index.html}.
 Home page for this can be found at: @uref{http://www.artronic.hr}.
 @item @uref{http://www.mysql.com/Downloads/Win32/W9xstop.zip,Utility from Artronic to stop MySQL on win9x}
 
+@item @uref{http://dbtools.vila.bol.com.br/, Dbtools}
+A tool to manage @strong{MySQL} databases. Currently only for Win32.
+Some features:
+@itemize @bullet
+@item manage servers, databases, tables, columns, indexes and users
+@item import wizard to import structure and data from a MS Access, MS Excel, Dbase, FoxPro, Paradox and ODBC Databases.
+@end itemize
+
 @item @uref{http://www.mysql.com/Downloads/Contrib/xmysqladmin-1.0.tar.gz, xmysqladmin-1.0.tar.gz}
 An X based front end to the @strong{MySQL} database engine.  It allows reloads,
 status check, process control, myisamchk, grant/revoke privileges,
diff --git a/client/sql_string.cc b/client/sql_string.cc
index 5c3e1068649..67ce0f6ff54 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -1,6 +1,6 @@
 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
    
-   This library is free software; you can redistribute it and/or
+   This program file 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.
@@ -127,7 +127,7 @@ bool String::set(double num,uint decimals)
   if (decimals >= NOT_FIXED_DEC)
   {
     sprintf(buff,"%.14g",num);			// Enough for a DATETIME
-    return copy(buff,strlen(buff));
+    return copy(buff, (uint32) strlen(buff));
   }
 #ifdef HAVE_FCONVERT
   int decpt,sign;
@@ -142,7 +142,7 @@ bool String::set(double num,uint decimals)
       buff[0]='-';
       pos=buff;
     }
-    return copy(pos,strlen(pos));
+    return copy(pos,(uint32) strlen(pos));
   }
   if (alloc((uint32) ((uint32) decpt+3+decimals)))
     return TRUE;
@@ -186,12 +186,13 @@ end:
   str_length=(uint32) (to-Ptr);
   return FALSE;
 #else
-#ifdef HAVE_SNPRINTF_
-  snprintf(buff,sizeof(buff), "%.*f",(int) decimals,num);
+#ifdef HAVE_SNPRINTF
+  buff[sizeof(buff)-1]=0;			// Safety
+  snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num);
 #else
   sprintf(buff,"%.*f",(int) decimals,num);
 #endif
-  return copy(buff,strlen(buff));
+  return copy(buff,(uint32) strlen(buff));
 #endif
 }
 
@@ -260,7 +261,7 @@ bool String::append(const String &s)
 bool String::append(const char *s,uint32 arg_length)
 {
   if (!arg_length)				// Default argument
-    arg_length=strlen(s);
+    arg_length= (uint32) strlen(s);
   if (realloc(str_length+arg_length))
     return TRUE;
   memcpy(Ptr+str_length,s,arg_length);
@@ -268,6 +269,19 @@ bool String::append(const char *s,uint32 arg_length)
   return FALSE;
 }
 
+bool String::append(FILE* file, uint32 arg_length, myf my_flags)
+{
+  if (realloc(str_length+arg_length))
+    return TRUE;
+  if (my_fread(file, (byte*) Ptr + str_length, arg_length, my_flags))
+  {
+    shrink(str_length);
+    return TRUE;
+  }
+  str_length+=arg_length;
+  return FALSE;
+}
+
 uint32 String::numchars()
 {
 #ifdef USE_MB
@@ -305,7 +319,7 @@ int String::charpos(int i,uint32 offset)
     if ( INT_MAX32-i <= (int) (mbstr-Ptr-offset)) 
       return INT_MAX32;
     else 
-      return (mbstr-Ptr-offset)+i;
+      return (int) ((mbstr-Ptr-offset)+i);
   }
   else
 #endif
@@ -317,7 +331,7 @@ int String::strstr(const String &s,uint32 offset)
   if (s.length()+offset <= str_length)
   {
     if (!s.length())
-      return offset;				// Empty string is always found
+      return ((int) offset);	// Empty string is always found
 
     register const char *str = Ptr+offset;
     register const char *search=s.ptr();
@@ -587,6 +601,7 @@ static int wild_case_compare(const char *str,const char *str_end,
 #ifdef USE_MB
       const char* mb = wildstr;
       int mblen;
+      LINT_INIT(mblen);
       if (use_mb_flag)
         mblen = my_ismbchar(default_charset_info, wildstr, wildend);
 #endif
diff --git a/client/sql_string.h b/client/sql_string.h
index 56a0a9b4eb2..8711cf314ad 100644
--- a/client/sql_string.h
+++ b/client/sql_string.h
@@ -36,7 +36,7 @@ public:
   String(uint32 length_arg)
   { alloced=0; Alloced_length=0; (void) real_alloc(length_arg); }
   String(const char *str)
-  { Ptr=(char*) str; str_length=strlen(str); Alloced_length=0; alloced=0;}
+  { Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;}
   String(const char *str,uint32 len)
   { Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;}
   String(char *str,uint32 len)
@@ -45,7 +45,7 @@ public:
   { Ptr=str.Ptr ; str_length=str.str_length ;
     Alloced_length=str.Alloced_length; alloced=0; }
 
-  static void *operator new(size_t size) { return (void*) sql_alloc(size); }
+  static void *operator new(size_t size) { return (void*) sql_alloc((uint) size); }
   static void operator delete(void *ptr_arg,size_t size) /*lint -e715 */
     { sql_element_free(ptr_arg); }
   ~String() { free(); }
@@ -123,7 +123,7 @@ public:
     if (arg_length < Alloced_length)
     {
       char *new_ptr;
-      if (!(new_ptr=my_realloc(Ptr,arg_length,MYF(0))))
+      if (!(new_ptr=(char*) my_realloc(Ptr,arg_length,MYF(0))))
       {
 	(void) my_free(Ptr,MYF(0));
 	real_alloc(arg_length);
@@ -152,6 +152,7 @@ public:
   bool copy(const char *s,uint32 arg_length);	// Allocate new string
   bool append(const String &s);
   bool append(const char *s,uint32 arg_length=0);
+  bool append(FILE* file, uint32 arg_length, myf my_flags);
   int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
   int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
   bool replace(uint32 offset,uint32 arg_length,const String &to);
diff --git a/extra/replace.c b/extra/replace.c
index 44f117c7969..ef3abda5cc5 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -272,7 +272,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
     pa->max_length=PS_MALLOC-MALLOC_OVERHEAD;
     pa->array_allocs=1;
   }
-  length=strlen(name)+1;
+  length=(uint) strlen(name)+1;
   if (pa->length+length >= pa->max_length)
   {
     if (!(new_pos= (byte*) my_realloc((gptr) pa->str,
@@ -415,7 +415,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
       DBUG_RETURN(0);
     }
     states+=len+1;
-    result_len+=strlen(to[i])+1;
+    result_len+=(uint) strlen(to[i])+1;
     if (len > max_length)
       max_length=len;
   }
@@ -1021,7 +1021,7 @@ FILE *in,*out;
 	end_of_line++;
       if (end_of_line == buffer+bufbytes)
       {
-	retain=end_of_line - start_of_line;
+	retain= (int) (end_of_line - start_of_line);
 	break;				/* No end of line, read more */
       }
       save_char=end_of_line[0];
diff --git a/include/config-win.h b/include/config-win.h
index eca0de680d8..dc54895a5d9 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -32,11 +32,17 @@
 #define	SYSTEM_TYPE	"Win95/Win98"
 #endif
 
-#ifdef _WIN32
-#define MACHINE_TYPE	"i32"		/* Define to machine type name */
-#else
+#ifdef _WIN64
 #define MACHINE_TYPE	"i64"		/* Define to machine type name */
+#else
+#define MACHINE_TYPE	"i32"		/* Define to machine type name */
+#ifndef _WIN32
+#define _WIN32				/* Compatible with old source */
 #endif
+#ifndef __WIN32__
+#define __WIN32__
+#endif
+#endif /* _WIN64 */
 #ifndef __WIN__
 #define __WIN__                       /* To make it easier in VC++ */
 #endif
diff --git a/include/global.h b/include/global.h
index 9cffcbf477b..27a7c54ede0 100644
--- a/include/global.h
+++ b/include/global.h
@@ -21,7 +21,7 @@
 #ifndef _global_h
 #define _global_h
 
-#if defined(_WIN32) || defined(_WIN64)
+#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
 #include <config-win.h>
 #else
 #include <my_config.h>
@@ -54,7 +54,9 @@
 #endif
 
 #if defined(THREAD) && !defined(__WIN__)
+#ifndef _POSIX_PTHREAD_SEMANTICS
 #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
+#endif
 /* was #if defined(HAVE_LINUXTHREADS) || defined(HAVE_DEC_THREADS) || defined(HPUX) */
 #if !defined(SCO)
 #define _REENTRANT	1	/* Some thread libraries require this */
diff --git a/isam/create.c b/isam/create.c
index 9b5e9eaece4..bcdd6b0892a 100644
--- a/isam/create.c
+++ b/isam/create.c
@@ -241,11 +241,12 @@ int nisam_create(const char *name,uint keys,N_KEYDEF *keyinfo,
   share.base.keystart = share.state.key_file_length=MY_ALIGN(info_length,
 							  nisam_block_size);
   share.base.max_block=max_block;
-  share.base.max_key_length=ALIGN_SIZE(max_key_length+4);
+  share.base.max_key_length=(uint) ALIGN_SIZE(max_key_length+4);
   share.base.records=records;
   share.base.reloc=reloc;
   share.base.reclength=reclength;
-  share.base.pack_reclength=reclength+packed-share.base.blobs*sizeof(char*);
+  share.base.pack_reclength=
+    (uint) (reclength+packed-share.base.blobs*sizeof(char*));
   share.base.max_pack_length=pack_reclength;
   share.base.min_pack_length=min_pack_length;
   share.base.pack_bits=packed;
diff --git a/isam/delete.c b/isam/delete.c
index 9c66e241147..e50ad72c767 100644
--- a/isam/delete.c
+++ b/isam/delete.c
@@ -439,7 +439,7 @@ static int underflow(register N_INFO *info, register N_KEYDEF *keyinfo,
       t_length=(int) _nisam_get_pack_key_length(keyinfo,nod_flag,(uchar*) 0,
 					     (uchar*) 0, leaf_key,&s_temp);
       s_temp.n_length= *half_pos;	/* For _nisam_store_key */
-      length=(buff+getint(buff))-half_pos;
+      length=(uint) ((buff+getint(buff))-half_pos);
       bmove((byte*) buff+p_length+t_length,(byte*) half_pos,(size_t) length);
       _nisam_store_key(keyinfo,buff+p_length,&s_temp);
       putint(buff,length+t_length+p_length,nod_flag);
@@ -566,7 +566,7 @@ static uint remove_key(N_KEYDEF *keyinfo, uint nod_flag,
   else
   {					 /* Let keypos point at next key */
     VOID((*keyinfo->get_key)(keyinfo,nod_flag,&keypos,lastkey));
-    s_length=(keypos-start);
+    s_length=(uint) (keypos-start);
     if (keyinfo->base.flag & HA_PACK_KEY)
     {
       diff_flag= (keyinfo->seg[0].base.flag & HA_SPACE_PACK);
@@ -576,12 +576,12 @@ static uint remove_key(N_KEYDEF *keyinfo, uint nod_flag,
 	if ((r_length= *keypos++ & 127) == 0)
 	{				/* Same key after */
 	  if (first & 128)
-	    start++;			/* Skipp ref length */
+	    start++;			/* Skip ref length */
 	  if (diff_flag)
-	    start+= *start+1;		/* Skipp key length */
+	    start+= *start+1;		/* Skip key length */
 	  else
 	    start+=keyinfo->seg[0].base.length- (first & 127);
-	  s_length=(keypos-start);	/* Remove pointers and next-key-flag */
+	  s_length=(uint)(keypos-start); /* Remove pntrs and next-key-flag */
 	}
 	else if (! (first & 128))
 	{				/* Deleted key was not compressed */
@@ -589,12 +589,12 @@ static uint remove_key(N_KEYDEF *keyinfo, uint nod_flag,
 	  {
 	    *start= (uchar) (r_length+ *keypos);
 	    start+=r_length+1;		/* Let ref-part remain */
-	    s_length=(keypos-start)+1;	/* Skipp everything between */
+	    s_length=(uint) (keypos-start)+1;	/* Skip everything between */
 	  }
 	  else
 	  {
 	    start+=r_length+1;		/* Let ref-part remain */
-	    s_length=(keypos-start);	/* Skipp everything between */
+	    s_length=(uint) (keypos-start);	/* Skip everything between */
 	  }
 	}
 	else if ((first & 127) < r_length)
@@ -604,7 +604,7 @@ static uint remove_key(N_KEYDEF *keyinfo, uint nod_flag,
 	  if (diff_flag)
 	    *start++= (uchar) (*keypos++ + r_length);
 	  start+= r_length;
-	  s_length=(keypos-start);	/* Skipp everything between */
+	  s_length=(uint) (keypos-start);	/* Skip everything between */
 	}
       }
     }
@@ -613,3 +613,5 @@ static uint remove_key(N_KEYDEF *keyinfo, uint nod_flag,
 	(uint) (page_end-start-s_length));
   DBUG_RETURN((uint) s_length);
 } /* remove_key */
+
+
diff --git a/isam/write.c b/isam/write.c
index 110dc70fe53..49b0916afc4 100644
--- a/isam/write.c
+++ b/isam/write.c
@@ -247,7 +247,7 @@ int _nisam_insert(register N_INFO *info, register N_KEYDEF *keyinfo,
 		       s_temp.n_ref_length,s_temp.n_length,s_temp.key));
   }
 #endif
-  key_offset = (endpos-key_pos);
+  key_offset = (uint)(endpos-key_pos);
   if((int) t_length < 0)
     key_offset += (int) t_length;
   if (key_offset < 0)
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 67c92413d8c..223518e99d7 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -53,6 +53,7 @@ mysysobjects1 =		my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
 			mf_pack.lo my_messnc.lo mf_dirname.lo mf_fn_ext.lo\
 			mf_wcomp.lo typelib.lo safemalloc.lo my_alloc.lo \
 			mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \
+			my_fstream.lo \
 			mf_loadpath.lo my_pthread.lo my_thr_init.lo \
 			thr_mutex.lo mulalloc.lo string.lo default.lo \
 			my_compress.lo array.lo my_once.lo list.lo my_net.lo \
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index b81af161671..4049b1efa6d 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1269,7 +1269,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
       host=LOCAL_HOST;
     sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host);
     DBUG_PRINT("info",("Server name: '%s'.  TCP sock: %d", host,port));
-    if ((sock = socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
+    /* _WIN64 ;  Assume that the (int) range is enough for socket() */
+    if ((sock = (int) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
     {
       net->last_errno=CR_IPSOCK_ERROR;
       sprintf(net->last_error,ER(net->last_errno),ERRNO);
diff --git a/libmysql/net.c b/libmysql/net.c
index 643b5e031cf..dac1fe0bd68 100644
--- a/libmysql/net.c
+++ b/libmysql/net.c
@@ -326,7 +326,7 @@ net_real_write(NET *net,const char *packet,ulong len)
   pos=(char*) packet; end=pos+len;
   while (pos != end)
   {
-    if ((int) (length=vio_write(net->vio,pos,(size_t) (end-pos))) <= 0)
+    if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0)
     {
       my_bool interrupted = vio_should_retry(net->vio);
 #if (!defined(__WIN__) && !defined(__EMX__))
diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c
index 4c5f3c79e17..d014c07bc96 100644
--- a/myisam/mi_delete.c
+++ b/myisam/mi_delete.c
@@ -527,7 +527,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo,
 					  (uchar*) 0, (uchar *) 0,
 					  leaf_key, &s_temp);
       /* t_length will always be > 0 for a new page !*/
-      length=(buff+mi_getint(buff))-half_pos;
+      length=(uint) ((buff+mi_getint(buff))-half_pos);
       bmove((byte*) buff+p_length+t_length,(byte*) half_pos,(size_t) length);
       (*keyinfo->store_key)(keyinfo,buff+p_length,&s_temp);
       mi_putint(buff,length+t_length+p_length,nod_flag);
@@ -683,7 +683,7 @@ static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag,
       DBUG_RETURN(0);				/* Error */
     if (next_block && nod_flag)
       *next_block= _mi_kpos(nod_flag,keypos);
-    s_length=(keypos-start);
+    s_length=(int) (keypos-start);
     if (keypos != page_end)
     {
       if (keyinfo->flag & HA_BINARY_PACK_KEY)
@@ -699,7 +699,7 @@ static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag,
 		    (next_length-prev_length));
 	  keypos-=(next_length-prev_length)+prev_pack_length;
 	  store_key_length(keypos,prev_length);
-	  s_length=(keypos-start);
+	  s_length=(int) (keypos-start);
 	}
       }
       else
@@ -746,7 +746,7 @@ static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag,
 	    rest_length+=tmp;
 	    pack_length= prev_length ? get_pack_length(rest_length): 0;
 	    keypos-=tmp+pack_length+prev_pack_length;
-	    s_length=(keypos-start);
+	    s_length=(int) (keypos-start);
 	    if (prev_length)			/* Pack against prev key */
 	    {
 	      *keypos++= start[0];
diff --git a/myisam/mi_search.c b/myisam/mi_search.c
index e7a654c4da8..812982082af 100644
--- a/myisam/mi_search.c
+++ b/myisam/mi_search.c
@@ -1588,7 +1588,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
 	      key++; org_key++;
 	    }
 	  }
-	  if ((new_ref_length= (key - start)))
+	  if ((new_ref_length= (uint) (key - start)))
 	    new_ref_length+=pack_marker;
 	}
 
diff --git a/sql/field.cc b/sql/field.cc
index 0ac2b0c841e..5afa314b835 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -799,7 +799,7 @@ String *Field_tiny::val_str(String *val_buffer,
   if (unsigned_flag)
     length= (uint) (int10_to_str((long) *((uchar*) ptr),to,10)-to);
   else
-    length=(int10_to_str((long) *((signed char*) ptr),to,-10)-to);
+    length= (uint) (int10_to_str((long) *((signed char*) ptr),to,-10)-to);
   val_buffer->length(length);
   if (zerofill)
     prepend_zeros(val_buffer);
diff --git a/sql/field.h b/sql/field.h
index 1d819231bd2..12a4a48562f 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -33,7 +33,7 @@ class Field {
   Field(const Item &);				/* Prevent use of theese */
   void operator=(Field &);
 public:
-  static void *operator new(size_t size) {return (void*) sql_alloc(size); }
+  static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
   static void operator delete(void *ptr_arg, size_t size) {} /*lint -e715 */
 
   enum utype { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL,
diff --git a/sql/item.h b/sql/item.h
index bce9c6600ef..f7cc296a4b3 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -26,7 +26,7 @@ class Item {
   Item(const Item &);				/* Prevent use of theese */
   void operator=(Item &);
 public:
-  static void *operator new(size_t size) {return (void*) sql_alloc(size); }
+  static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
   static void operator delete(void *ptr,size_t size) {} /*lint -e715 */
 
   enum Type {FIELD_ITEM,FUNC_ITEM,SUM_FUNC_ITEM,STRING_ITEM,
@@ -167,7 +167,7 @@ public:
   Item_int(const char *str_arg) :
     value(str_arg[0] == '-' ? strtoll(str_arg,(char**) 0,10) :
 	  (longlong) strtoull(str_arg,(char**) 0,10))
-    { max_length=strlen(str_arg); name=(char*) str_arg;}
+    { max_length= (uint) strlen(str_arg); name=(char*) str_arg;}
   enum Type type() const { return INT_ITEM; }
   virtual enum Item_result result_type () const { return INT_RESULT; }
   longlong val_int() { return value; }
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index c839065eb45..b3494f7c81d 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -418,7 +418,7 @@ redo:
           i=(char*) ptr+1; j=(char*) search+1;
           while (j != search_end)
             if (*i++ != *j++) goto skipp;
-          offset=ptr-res->ptr();
+          offset= (int) (ptr-res->ptr());
           if (res->length()-from_length + to_length > max_allowed_packet)
             goto null;
           if (!alloced)
@@ -740,12 +740,12 @@ String *Item_func_substr_index::val_str(String *str)
         if (c) return res; /* Not found, return original string */
         if (count>0) /* return left part */
         {
-	  tmp_value.set(*res,0,ptr-res->ptr());
+	  tmp_value.set(*res,0,(ulong) (ptr-res->ptr()));
         }
         else /* return right part */
         {
 	  ptr+=delimeter_length;
-	  tmp_value.set(*res,ptr-res->ptr(),strend-ptr);
+	  tmp_value.set(*res,(ulong) (ptr-res->ptr()), (ulong) (strend-ptr));
         }
       }
     }
diff --git a/sql/lock.cc b/sql/lock.cc
index 228dff6b058..a2e4daa4590 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -262,7 +262,7 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table)
       if (locked->locks[i]->type != TL_UNLOCK)
 	*prev++ = locked->locks[i];
     }
-    locked->lock_count=(prev - locked->locks);
+    locked->lock_count=(uint) (prev - locked->locks);
   }
 }
 
diff --git a/sql/log.cc b/sql/log.cc
index e73f0c802a5..29ca0247a1b 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -51,7 +51,7 @@ static int find_uniq_filename(char *name)
   length=dirname_part(buff,name);
   char *start=name+length,*end=strend(start);
   *end='.';
-  length=end-start+1;
+  length= (uint) (end-start+1);
 
   if (!(dir_info = my_dir(buff,MYF(MY_DONT_SORT))))
   {						// This shouldn't happen
diff --git a/sql/log_event.h b/sql/log_event.h
index 13472938975..549f3831a60 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -99,7 +99,7 @@ public:
   {
     time_t end_time;
     time(&end_time);
-    exec_time = end_time  - thd->start_time;
+    exec_time = (ulong) (end_time  - thd->start_time);
     valid_exec_time = 1;
     db_len = (db) ? (uint) strlen(db) : 0;
   }
@@ -187,7 +187,7 @@ public:
   {
     time_t end_time;
     time(&end_time);
-    exec_time = end_time  - thd->start_time;
+    exec_time = (ulong) (end_time  - thd->start_time);
     valid_exec_time = 1;
     db_len = (db) ? (uint) strlen(db) : 0;
     table_name_len = (table_name) ? (uint) strlen(table_name) : 0;
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 643b5e031cf..dac1fe0bd68 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -326,7 +326,7 @@ net_real_write(NET *net,const char *packet,ulong len)
   pos=(char*) packet; end=pos+len;
   while (pos != end)
   {
-    if ((int) (length=vio_write(net->vio,pos,(size_t) (end-pos))) <= 0)
+    if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0)
     {
       my_bool interrupted = vio_should_retry(net->vio);
 #if (!defined(__WIN__) && !defined(__EMX__))
diff --git a/sql/sql_list.h b/sql/sql_list.h
index 725d506e62a..965d1ff9308 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -25,7 +25,7 @@
 class Sql_alloc
 {
 public:
-  static void *operator new(size_t size) {return (void*) sql_alloc(size); }
+  static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
   static void operator delete(void *ptr, size_t size) {} /*lint -e715 */
   inline Sql_alloc() {};
   inline ~Sql_alloc() {};
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index b4f16bbe201..8b7e16709c0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -323,7 +323,7 @@ pthread_handler_decl(handle_one_connection,arg)
 {
   THD *thd=(THD*) arg;
   uint launch_time  =
-    (thd->thr_create_time = time(NULL)) - thd->connect_time;
+    (uint) ((thd->thr_create_time = time(NULL)) - thd->connect_time);
   if (launch_time >= slow_launch_time)
     statistic_increment(slow_launch_threads,&LOCK_status );
 
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index ee6771d4b25..e1be78ada1c 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -32,8 +32,7 @@ static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list,
 bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
 {
   bool error=1,got_all_locks=1;
-  db_type table_type;
-  TABLE_LIST *lock_table,*ren_table=0,*new_table;
+  TABLE_LIST *lock_table,*ren_table=0;
   DBUG_ENTER("mysql_rename_tables");
   
   /* Avoid problems with a rename on a table that we have locked or
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9c509484b3c..c779b9f555a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2606,7 +2606,7 @@ static void clear_tables(JOIN *join)
 
 class COND_CMP :public ilink {
 public:
-  static void *operator new(size_t size) {return (void*) sql_alloc(size); }
+  static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
   static void operator delete(void *ptr __attribute__((unused)),
 			      size_t size __attribute__((unused))) {} /*lint -e715 */
 
@@ -3229,7 +3229,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
       *(reg_field++) =new_field;
     }
   }
-  field_count=reg_field - table->field;
+  field_count= (uint) (reg_field - table->field);
 
   /* If result table is small; use a heap */
   if (blob_count || using_unique_constraint ||
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 695c815a500..66141a8591c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -818,11 +818,12 @@ store_create_info(THD *thd, TABLE *table, String* packet)
 
 class thread_info :public ilink {
 public:
-  static void *operator new(size_t size) {return (void*) sql_alloc(size); }
+  static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
   static void operator delete(void *ptr __attribute__((unused)),
 			      size_t size __attribute__((unused))) {} /*lint -e715 */
 
-  ulong thread_id,start_time;
+  ulong thread_id;
+  time_t start_time;
   uint	 command;
   const char *user,*host,*db,*proc_info,*state_info;
   char *query;
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 83b21af87f5..67ce0f6ff54 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -1,18 +1,19 @@
 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
    
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   This program file 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 program is distributed in the hope that it will be useful,
+   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 General Public License for more details.
+   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 General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+   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 */
 
 /* This file is originally from the mysql distribution. Coded by monty */
 
@@ -126,7 +127,7 @@ bool String::set(double num,uint decimals)
   if (decimals >= NOT_FIXED_DEC)
   {
     sprintf(buff,"%.14g",num);			// Enough for a DATETIME
-    return copy(buff,(uint) strlen(buff));
+    return copy(buff, (uint32) strlen(buff));
   }
 #ifdef HAVE_FCONVERT
   int decpt,sign;
@@ -141,7 +142,7 @@ bool String::set(double num,uint decimals)
       buff[0]='-';
       pos=buff;
     }
-    return copy(pos,(uint) strlen(pos));
+    return copy(pos,(uint32) strlen(pos));
   }
   if (alloc((uint32) ((uint32) decpt+3+decimals)))
     return TRUE;
@@ -191,7 +192,7 @@ end:
 #else
   sprintf(buff,"%.*f",(int) decimals,num);
 #endif
-  return copy(buff,(uint) strlen(buff));
+  return copy(buff,(uint32) strlen(buff));
 #endif
 }
 
@@ -260,7 +261,7 @@ bool String::append(const String &s)
 bool String::append(const char *s,uint32 arg_length)
 {
   if (!arg_length)				// Default argument
-    arg_length=(uint) strlen(s);
+    arg_length= (uint32) strlen(s);
   if (realloc(str_length+arg_length))
     return TRUE;
   memcpy(Ptr+str_length,s,arg_length);
@@ -318,7 +319,7 @@ int String::charpos(int i,uint32 offset)
     if ( INT_MAX32-i <= (int) (mbstr-Ptr-offset)) 
       return INT_MAX32;
     else 
-      return (mbstr-Ptr-offset)+i;
+      return (int) ((mbstr-Ptr-offset)+i);
   }
   else
 #endif
@@ -330,7 +331,7 @@ int String::strstr(const String &s,uint32 offset)
   if (s.length()+offset <= str_length)
   {
     if (!s.length())
-      return offset;				// Empty string is always found
+      return ((int) offset);	// Empty string is always found
 
     register const char *str = Ptr+offset;
     register const char *search=s.ptr();
diff --git a/sql/sql_string.h b/sql/sql_string.h
index d421261f9e4..8711cf314ad 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -1,18 +1,19 @@
 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
    
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   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 program is distributed in the hope that it will be useful,
+   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 General Public License for more details.
+   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 General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+   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 */
 
 /* This file is originally from the mysql distribution. Coded by monty */
 
@@ -44,7 +45,7 @@ public:
   { Ptr=str.Ptr ; str_length=str.str_length ;
     Alloced_length=str.Alloced_length; alloced=0; }
 
-  static void *operator new(size_t size) { return (void*) sql_alloc(size); }
+  static void *operator new(size_t size) { return (void*) sql_alloc((uint) size); }
   static void operator delete(void *ptr_arg,size_t size) /*lint -e715 */
     { sql_element_free(ptr_arg); }
   ~String() { free(); }
diff --git a/sql/time.cc b/sql/time.cc
index 5cf7d0ee074..17603d93dd4 100644
--- a/sql/time.cc
+++ b/sql/time.cc
@@ -113,7 +113,7 @@ long my_gmt_sec(TIME *t)
   if ((my_time_zone >=0 ? my_time_zone: -my_time_zone) > 3600L*12)
     my_time_zone=0;			/* Wrong date */
   pthread_mutex_unlock(&LOCK_timezone);
-  return tmp;
+  return (long) tmp;
 } /* my_gmt_sec */
 
 

From 451ef26a31374f8b2e150b4b63e074d093eb3a56 Mon Sep 17 00:00:00 2001
From: unknown <jcole@tetra.spaceapes.com>
Date: Wed, 23 Aug 2000 07:07:24 -0500
Subject: [PATCH 2/2] Updated mysqlhotcopy to use the new ``FLUSH TABLES
 table_list'' syntax.

Docs/manual.texi:
  ChangeLog entry for mysqlhotcopy update.
scripts/mysqlhotcopy.sh:
  Updated to use the new ``FLUSH TABLES table_list'' syntax.
---
 Docs/manual.texi        |  3 +++
 scripts/mysqlhotcopy.sh | 10 ++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index b661d78605a..106fb911937 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -35402,6 +35402,9 @@ though, so 3.23 is not released as a stable version yet.
 @appendixsubsec Changes in release 3.23.23
 @itemize @bullet
 @item
+Updated mysqlhotcopy to use the new @code{FLUSH TABLES table_list} syntax. Only
+tables which are being backed up are flushed now.
+@item
 Changed behavior of @code{--enable-thread-safe-client} so
 that both non-threaded (@code{-lmysqlclient}) and threaded
 (@code{-lmysqlclient_r}) libraries are built.  Users who linked
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh
index bc150ff61a5..2084a0b2c02 100755
--- a/scripts/mysqlhotcopy.sh
+++ b/scripts/mysqlhotcopy.sh
@@ -25,7 +25,7 @@ WARNING: THIS IS VERY MUCH A FIRST-CUT ALPHA. Comments/patches welcome.
 
 # Documentation continued at end of file
 
-my $VERSION = "1.5";
+my $VERSION = "1.6";
 
 my $OPTIONS = <<"_OPTIONS";
 
@@ -180,6 +180,7 @@ if ( defined $opt{regexp} ) {
 # --- get list of tables to hotcopy ---
 
 my $hc_locks = "";
+my $hc_tables = "";
 my $num_tables = 0;
 my $num_files = 0;
 
@@ -208,6 +209,7 @@ foreach my $rdb ( @db_desc ) {
 
     $hc_locks .= ", "  if ( length $hc_locks && @hc_tables );
     $hc_locks .= join ", ", map { "$_ READ" } @hc_tables;
+    $hc_tables .= join ", ", @hc_tables;
 
     $num_tables += scalar @hc_tables;
     $num_files  += scalar @{$rdb->{files}};
@@ -286,7 +288,7 @@ my $hc_started = time;	# count from time lock is granted
 
 if ( $opt{dryrun} ) {
     print "LOCK TABLES $hc_locks\n";
-    print "FLUSH TABLES\n";
+    print "FLUSH TABLES /*!32323 $hc_tables */\n";
     print "FLUSH LOGS\n" if ( $opt{flushlog} );
 }
 else {
@@ -297,8 +299,8 @@ else {
 
     # flush tables to make on-disk copy uptodate
     $start = time;
-    $dbh->do("FLUSH TABLES");
-    printf "Flushed tables in %d seconds.\n", time-$start unless $opt{quiet};
+    $dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
+    printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
     $dbh->do( "FLUSH LOGS" ) if ( $opt{flushlog} );
 }