[Pkg-mysql-commits] r1164 - in branches/sid-5.1/debian: . patches

Norbert Tretkowski nobse at alioth.debian.org
Thu Feb 28 09:14:57 UTC 2008


Author: nobse
Date: 2008-02-28 09:14:57 +0000 (Thu, 28 Feb 2008)
New Revision: 1164

Removed:
   branches/sid-5.1/debian/patches/85_NdbPool_create_instance.dpatch
   branches/sid-5.1/debian/patches/86_Ndb_connectors_utility_methods.dpatch
   branches/sid-5.1/debian/patches/99_TEMP_minmax.dpatch
Modified:
   branches/sid-5.1/debian/changelog
Log:
Update patches, second round.

Modified: branches/sid-5.1/debian/changelog
===================================================================
--- branches/sid-5.1/debian/changelog	2008-02-28 09:11:48 UTC (rev 1163)
+++ branches/sid-5.1/debian/changelog	2008-02-28 09:14:57 UTC (rev 1164)
@@ -21,10 +21,13 @@
 
   [ Norbert Tretkowski ]
   * Update patches:
-    + patches/41_scripts__mysql_install_db.sh__no_test.dpatch
+    + 41_scripts__mysql_install_db.sh__no_test.dpatch
   * Drop patches:
-    + patches/70_upstream_debian__configure.dpatch
-    + patches/71_upstream_debian__Makefile.in.dpatch
+    + 70_upstream_debian__configure.dpatch
+    + 71_upstream_debian__Makefile.in.dpatch
+    + 85_NdbPool_create_instance.dpatch
+    + 86_Ndb_connectors_utility_methods.dpatch
+    + 99_TEMP_minmax.dpatch
   * Disabled testsuite, I guess the reason why it currently fails is a bug in
     the testsuite itself.
 

Deleted: branches/sid-5.1/debian/patches/85_NdbPool_create_instance.dpatch
===================================================================
--- branches/sid-5.1/debian/patches/85_NdbPool_create_instance.dpatch	2008-02-28 09:11:48 UTC (rev 1163)
+++ branches/sid-5.1/debian/patches/85_NdbPool_create_instance.dpatch	2008-02-28 09:14:57 UTC (rev 1164)
@@ -1,20 +0,0 @@
-#! /bin/sh /usr/share/dpatch/dpatch-run
-## 85_NdbPool_create_instance.dpatch by  <monty at inaugust.com>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: No description.
-
- at DPATCH@
-diff -urNad sid-5.1~/storage/ndb/include/ndbapi/NdbPool.hpp sid-5.1/storage/ndb/include/ndbapi/NdbPool.hpp
---- sid-5.1~/storage/ndb/include/ndbapi/NdbPool.hpp	2007-09-24 03:30:24.000000000 -0700
-+++ sid-5.1/storage/ndb/include/ndbapi/NdbPool.hpp	2007-10-11 16:58:38.243998137 -0700
-@@ -17,7 +17,8 @@
- class NdbPool;
- 
- bool
--create_instance(Uint32 max_ndb_objects,
-+create_instance(Ndb_cluster_connection* cc,
-+                Uint32 max_ndb_objects,
-                 Uint32 no_conn_obj,
-                 Uint32 init_no_ndb_objects);
- 

Deleted: branches/sid-5.1/debian/patches/86_Ndb_connectors_utility_methods.dpatch
===================================================================
--- branches/sid-5.1/debian/patches/86_Ndb_connectors_utility_methods.dpatch	2008-02-28 09:11:48 UTC (rev 1163)
+++ branches/sid-5.1/debian/patches/86_Ndb_connectors_utility_methods.dpatch	2008-02-28 09:14:57 UTC (rev 1164)
@@ -1,76 +0,0 @@
-#! /bin/sh /usr/share/dpatch/dpatch-run
-## 86_Ndb_connectors_utility_methods.dpatch by  <mtaylor at mysql.com>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: Add accessor methods necessary for NDB/Connectors
-
- at DPATCH@
-diff -urNad sid-5.1~/storage/ndb/include/ndbapi/NdbOperation.hpp sid-5.1/storage/ndb/include/ndbapi/NdbOperation.hpp
---- sid-5.1~/storage/ndb/include/ndbapi/NdbOperation.hpp	2007-09-24 03:30:24.000000000 -0700
-+++ sid-5.1/storage/ndb/include/ndbapi/NdbOperation.hpp	2007-10-11 23:11:39.083409489 -0700
-@@ -842,6 +842,9 @@
-   virtual ~NdbOperation();
-   void	next(NdbOperation*);		// Set next pointer		      
-   NdbOperation*	    next();	        // Get next pointer		       
-+
-+  NdbTransaction* getNdbTransaction();
-+
- public:
- #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
-   const NdbOperation* next() const;
-diff -urNad sid-5.1~/storage/ndb/include/ndbapi/NdbScanFilter.hpp sid-5.1/storage/ndb/include/ndbapi/NdbScanFilter.hpp
---- sid-5.1~/storage/ndb/include/ndbapi/NdbScanFilter.hpp	2007-09-24 03:29:58.000000000 -0700
-+++ sid-5.1/storage/ndb/include/ndbapi/NdbScanFilter.hpp	2007-10-11 23:09:47.609056928 -0700
-@@ -166,6 +166,7 @@
-   /** @} *********************************************************************/
- #endif
- 
-+  NdbOperation * getNdbOperation();
- private:
- #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
-   friend class NdbScanFilterImpl;
-diff -urNad sid-5.1~/storage/ndb/include/ndbapi/NdbTransaction.hpp sid-5.1/storage/ndb/include/ndbapi/NdbTransaction.hpp
---- sid-5.1~/storage/ndb/include/ndbapi/NdbTransaction.hpp	2007-09-24 03:29:41.000000000 -0700
-+++ sid-5.1/storage/ndb/include/ndbapi/NdbTransaction.hpp	2007-10-11 23:09:47.609056928 -0700
-@@ -170,6 +170,13 @@
- #endif
-   };
- 
-+  /**
-+   * Convenience method to fetch this transactions Ndb* object 
-+   */
-+  Ndb * getNdb() { 
-+    return theNdb; 
-+  }
-+
- #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
-   /**
-    * Get an NdbOperation for a table.
-diff -urNad sid-5.1~/storage/ndb/src/ndbapi/NdbOperation.cpp sid-5.1/storage/ndb/src/ndbapi/NdbOperation.cpp
---- sid-5.1~/storage/ndb/src/ndbapi/NdbOperation.cpp	2007-09-24 03:29:31.000000000 -0700
-+++ sid-5.1/storage/ndb/src/ndbapi/NdbOperation.cpp	2007-10-11 23:10:43.332232410 -0700
-@@ -429,3 +429,10 @@
- {
-   return m_currentTable;
- }
-+
-+NdbTransaction* 
-+NdbOperation::getNdbTransaction()
-+{
-+  return theNdbCon; 
-+}
-+
-diff -urNad sid-5.1~/storage/ndb/src/ndbapi/NdbScanFilter.cpp sid-5.1/storage/ndb/src/ndbapi/NdbScanFilter.cpp
---- sid-5.1~/storage/ndb/src/ndbapi/NdbScanFilter.cpp	2007-09-24 03:30:25.000000000 -0700
-+++ sid-5.1/storage/ndb/src/ndbapi/NdbScanFilter.cpp	2007-10-11 23:09:47.609056928 -0700
-@@ -282,6 +282,10 @@
-   }
- }
- 
-+NdbOperation * 
-+NdbScanFilter::getNdbOperation(){
-+  return m_impl.m_operation; 
-+}
- 
- #define action(x, y, z)
- 

Deleted: branches/sid-5.1/debian/patches/99_TEMP_minmax.dpatch
===================================================================
--- branches/sid-5.1/debian/patches/99_TEMP_minmax.dpatch	2008-02-28 09:11:48 UTC (rev 1163)
+++ branches/sid-5.1/debian/patches/99_TEMP_minmax.dpatch	2008-02-28 09:14:57 UTC (rev 1164)
@@ -1,2156 +0,0 @@
-#! /bin/sh /usr/share/dpatch/dpatch-run
-## 99-unnamed.dpatch by  <ch at debian.org>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: Temporary patch for MySQL bug http://bugs.mysql.com/bug.php?id=30866
-## DP: Using:
-## DP: 
-## DP:   vi include/my_global.h
-## DP:   
-## DP:    /* Define some useful general macros */
-## DP:   -#if !defined(max)
-## DP:   -#define max(a, b)	((a) > (b) ? (a) : (b))
-## DP:   -#define min(a, b)	((a) < (b) ? (a) : (b))
-## DP:   +#if !defined(mysql_max)
-## DP:   +#define mysql_max(a, b)      ((a) > (b) ? (a) : (b))
-## DP:   +#define mysql_min(a, b)      ((a) < (b) ? (a) : (b))
-## DP:   +static __inline long min( long a, long b ) { return ( ( a < b ) ? a : b ); }
-## DP:   +static __inline long max( long a, long b ) { return ( ( a > b ) ? a : b ); }
-## DP:    #endif
-## DP:   
-## DP:   cd client/
-## DP:   find . -type f -exec sed -i -e 's|)min(|)mysql_min(|g' -e 's|)max(|)mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|>min(|>mysql_min(|g' -e 's|>max(|>mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|<min(|<mysql_min(|g' -e 's|<max(|<mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|,min(|,mysql_min(|g' -e 's|,max(|,mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|\[min(|\[mysql_min(|g' -e 's|\[max(|\[mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|(min(|(mysql_min(|g' -e 's|(max(|(mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|+min(|+mysql_min(|g' -e 's|+max(|+mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|-min(|-mysql_min(|g' -e 's|-max(|-mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's| min(| mysql_min(|g' -e 's| max(| mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|=min(|=mysql_min(|g' -e 's|=max(|=mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|*min(|*mysql_min(|g' -e 's|*max(|*mysql_max(|g' '{}' ';' 
-## DP:   
-## DP:   cd sql/
-## DP:   find . -type f -exec sed -i -e 's|)mysql_min(|)mysql_min(|g' -e 's|)mysql_max(|)mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|>mysql_min(|>mysql_min(|g' -e 's|>mysql_max(|>mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|<mysql_min(|<mysql_min(|g' -e 's|<mysql_max(|<mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|,mysql_min(|,mysql_min(|g' -e 's|,mysql_max(|,mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|\[mysql_min(|\[mysql_min(|g' -e 's|\[mysql_max(|\[mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|(mysql_min(|(mysql_min(|g' -e 's|(mysql_max(|(mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|+mysql_min(|+mysql_min(|g' -e 's|+mysql_max(|+mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|-mysql_min(|-mysql_min(|g' -e 's|-mysql_max(|-mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's| mysql_min(| mysql_min(|g' -e 's| mysql_max(| mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|=mysql_min(|=mysql_min(|g' -e 's|=mysql_max(|=mysql_max(|g' '{}' ';'
-## DP:   find . -type f -exec sed -i -e 's|*mysql_min(|*mysql_min(|g' -e 's|*mysql_max(|*mysql_max(|g' '{}' ';' 
-
- at DPATCH@
-
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/client/mysqlbinlog.cc mysql-dfsg-5.1-5.1.22rc/client/mysqlbinlog.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/client/mysqlbinlog.cc	2007-09-24 12:30:26.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/client/mysqlbinlog.cc	2007-10-02 23:35:08.000000000 +0200
-@@ -1465,7 +1465,7 @@ static int dump_local_log_entries(PRINT_
-       my_off_t length,tmp;
-       for (length= start_position_mot ; length > 0 ; length-=tmp)
-       {
--	tmp=min(length,sizeof(buff));
-+	tmp=mysql_min(length,sizeof(buff));
- 	if (my_b_read(file, buff, (uint) tmp))
-         {
-           error= 1;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/client/mysql.cc mysql-dfsg-5.1-5.1.22rc/client/mysql.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/client/mysql.cc	2007-09-24 12:29:43.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/client/mysql.cc	2007-10-02 23:35:08.000000000 +0200
-@@ -2398,9 +2398,9 @@ print_table_data(MYSQL_RES *result)
-   {
-     uint length= column_names ? field->name_length : 0;
-     if (quick)
--      length=max(length,field->length);
-+      length=mysql_max(length,field->length);
-     else
--      length=max(length,field->max_length);
-+      length=mysql_max(length,field->max_length);
-     if (length < 4 && !IS_NOT_NULL(field->flags))
-       length=4;					// Room for "NULL"
-     field->max_length=length;
-@@ -2420,7 +2420,7 @@ print_table_data(MYSQL_RES *result)
-                                                   field->name,
-                                                   field->name + name_length);
-       uint display_length= field->max_length + name_length - numcells;
--      tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+      tee_fprintf(PAGER, " %-*s |",(int) mysql_min(display_length,
-                                             MAX_COLUMN_LENGTH),
-                   field->name);
-       num_flag[off]= IS_NUM(field->type);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/client/mysqldump.c mysql-dfsg-5.1-5.1.22rc/client/mysqldump.c
---- mysql-dfsg-5.1-5.1.22rc.orig/client/mysqldump.c	2007-09-24 12:29:58.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/client/mysqldump.c	2007-10-02 23:35:08.000000000 +0200
-@@ -790,7 +790,7 @@ get_one_option(int optid, const struct m
-                                     &err_ptr, &err_len);
-       if (err_len)
-       {
--        strmake(buff, err_ptr, min(sizeof(buff), err_len));
-+        strmake(buff, err_ptr, mysql_min(sizeof(buff), err_len));
-         fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
-         exit(1);
-       }
-@@ -4389,7 +4389,7 @@ static ulong find_set(TYPELIB *lib, cons
- 
-       for (; pos != end && *pos != ','; pos++) ;
-       var_len= (uint) (pos - start);
--      strmake(buff, start, min(sizeof(buff), var_len));
-+      strmake(buff, start, mysql_min(sizeof(buff), var_len));
-       find= find_type(buff, lib, var_len);
-       if (!find)
-       {
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/client/mysqltest.c mysql-dfsg-5.1-5.1.22rc/client/mysqltest.c
---- mysql-dfsg-5.1-5.1.22rc.orig/client/mysqltest.c	2007-09-24 12:30:25.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/client/mysqltest.c	2007-10-02 23:35:08.000000000 +0200
-@@ -4099,9 +4099,9 @@ int read_line(char *buf, int size)
-       }
-       else if ((c == '{' &&
-                 (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
--                                      (uchar*) buf, min(5, p - buf), 0) ||
-+                                      (uchar*) buf, mysql_min(5, p - buf), 0) ||
-                  !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
--                                      (uchar*) buf, min(2, p - buf), 0))))
-+                                      (uchar*) buf, mysql_min(2, p - buf), 0))))
-       {
-         /* Only if and while commands can be terminated by { */
-         *p++= c;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/client/mysql_upgrade.c mysql-dfsg-5.1-5.1.22rc/client/mysql_upgrade.c
---- mysql-dfsg-5.1-5.1.22rc.orig/client/mysql_upgrade.c	2007-09-24 12:30:24.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/client/mysql_upgrade.c	2007-10-02 23:35:08.000000000 +0200
-@@ -401,7 +401,7 @@ static void find_tool(char *tool_path, c
-     DBUG_PRINT("enter", ("path: %s", path));
- 
-     /* Chop off last char(since it might be a /) */
--    path[max((strlen(path)-1), 0)]= 0;
-+    path[mysql_max((strlen(path)-1), 0)]= 0;
- 
-     /* Chop off last dir part */
-     dirname_part(path, path, &path_len);
-@@ -492,7 +492,7 @@ static int extract_variable_from_show(DY
-   if ((value_end= strchr(value_start, '\n')) == NULL)
-     return 1; /* Unexpected result */
- 
--  strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+  strncpy(value, value_start, mysql_min(FN_REFLEN, value_end-value_start));
-   return 0;
- }
- 
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/client/sql_string.cc mysql-dfsg-5.1-5.1.22rc/client/sql_string.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/client/sql_string.cc	2007-09-24 12:29:40.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/client/sql_string.cc	2007-10-02 23:35:08.000000000 +0200
-@@ -662,7 +662,7 @@ int String::reserve(uint32 space_needed,
- {
-   if (Alloced_length < str_length + space_needed)
-   {
--    if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+    if (realloc(Alloced_length + mysql_max(space_needed, grow_by) - 1))
-       return TRUE;
-   }
-   return FALSE;
-@@ -748,7 +748,7 @@ int sortcmp(const String *s,const String
- 
- int stringcmp(const String *s,const String *t)
- {
--  uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+  uint32 s_len=s->length(),t_len=t->length(),len=mysql_min(s_len,t_len);
-   int cmp= memcmp(s->ptr(), t->ptr(), len);
-   return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -765,7 +765,7 @@ String *copy_if_not_alloced(String *to,S
-   }
-   if (to->realloc(from_length))
-     return from;				// Actually an error
--  if ((to->str_length=min(from->str_length,from_length)))
-+  if ((to->str_length=mysql_min(from->str_length,from_length)))
-     memcpy(to->Ptr,from->Ptr,to->str_length);
-   to->str_charset=from->str_charset;
-   return to;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/include/my_global.h mysql-dfsg-5.1-5.1.22rc/include/my_global.h
---- mysql-dfsg-5.1-5.1.22rc.orig/include/my_global.h	2007-09-24 12:30:24.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/include/my_global.h	2007-10-02 23:33:01.000000000 +0200
-@@ -563,9 +563,11 @@ int	__void__;
- #endif
- 
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b)	((a) > (b) ? (a) : (b))
--#define min(a, b)	((a) < (b) ? (a) : (b))
-+#if !defined(mysql_max)
-+#define mysql_max(a, b)      ((a) > (b) ? (a) : (b))
-+#define mysql_min(a, b)      ((a) < (b) ? (a) : (b))
-+static __inline long min( long a, long b ) { return ( ( a < b ) ? a : b ); }
-+static __inline long max( long a, long b ) { return ( ( a > b ) ? a : b ); }
- #endif
- 
- #if !defined(HAVE_UINT)
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/client.c mysql-dfsg-5.1-5.1.22rc/sql/client.c
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/client.c	2007-09-24 12:29:33.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/client.c	2007-10-02 23:35:53.000000000 +0200
-@@ -625,7 +625,7 @@ cli_safe_read(MYSQL *mysql)
- 	pos+= SQLSTATE_LENGTH+1;
-       }
-       (void) strmake(net->last_error,(char*) pos,
--		     min((uint) len,(uint) sizeof(net->last_error)-1));
-+		     mysql_min((uint) len,(uint) sizeof(net->last_error)-1));
-     }
-     else
-       set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2021,7 +2021,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,cons
- 	goto error;
-       }
-       memcpy(&sock_addr.sin_addr, hp->h_addr,
--             min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+             mysql_min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-       my_gethostbyname_r_free();
-     }
-     sock_addr.sin_port = (ushort) htons((ushort) port);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/field.cc mysql-dfsg-5.1-5.1.22rc/sql/field.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/field.cc	2007-09-24 12:29:27.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/field.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -49,7 +49,7 @@ const char field_separator=',';
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << mysql_min(arg, 4) * 8) - LL(1)))
- 
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -1980,7 +1980,7 @@ int Field_decimal::store(const char *fro
-     tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
-   else if (expo_sign_char == '-') 
-   {
--    tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+    tmp_uint=mysql_min(exponent,(uint)(int_digits_end-int_digits_from));
-     frac_digits_added_zeros=exponent-tmp_uint;
-     int_digits_end -= tmp_uint;
-     frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -1988,7 +1988,7 @@ int Field_decimal::store(const char *fro
-   }
-   else // (expo_sign_char=='+') 
-   {
--    tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+    tmp_uint=mysql_min(exponent,(uint)(frac_digits_end-frac_digits_from));
-     int_digits_added_zeros=exponent-tmp_uint;
-     int_digits_tail_from=frac_digits_from;
-     frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2876,7 +2876,7 @@ String *Field_tiny::val_str(String *val_
-   ASSERT_COLUMN_MARKED_FOR_READ;
-   CHARSET_INFO *cs= &my_charset_bin;
-   uint length;
--  uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+  uint mlength=mysql_max(field_length+1,5*cs->mbmaxlen);
-   val_buffer->alloc(mlength);
-   char *to=(char*) val_buffer->ptr();
- 
-@@ -3088,7 +3088,7 @@ String *Field_short::val_str(String *val
-   ASSERT_COLUMN_MARKED_FOR_READ;
-   CHARSET_INFO *cs= &my_charset_bin;
-   uint length;
--  uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+  uint mlength=mysql_max(field_length+1,7*cs->mbmaxlen);
-   val_buffer->alloc(mlength);
-   char *to=(char*) val_buffer->ptr();
-   short j;
-@@ -3305,7 +3305,7 @@ String *Field_medium::val_str(String *va
-   ASSERT_COLUMN_MARKED_FOR_READ;
-   CHARSET_INFO *cs= &my_charset_bin;
-   uint length;
--  uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+  uint mlength=mysql_max(field_length+1,10*cs->mbmaxlen);
-   val_buffer->alloc(mlength);
-   char *to=(char*) val_buffer->ptr();
-   long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3524,7 +3524,7 @@ String *Field_long::val_str(String *val_
-   ASSERT_COLUMN_MARKED_FOR_READ;
-   CHARSET_INFO *cs= &my_charset_bin;
-   uint length;
--  uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+  uint mlength=mysql_max(field_length+1,12*cs->mbmaxlen);
-   val_buffer->alloc(mlength);
-   char *to=(char*) val_buffer->ptr();
-   int32 j;
-@@ -3765,7 +3765,7 @@ String *Field_longlong::val_str(String *
- {
-   CHARSET_INFO *cs= &my_charset_bin;
-   uint length;
--  uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+  uint mlength=mysql_max(field_length+1,22*cs->mbmaxlen);
-   val_buffer->alloc(mlength);
-   char *to=(char*) val_buffer->ptr();
-   longlong j;
-@@ -3947,7 +3947,7 @@ String *Field_float::val_str(String *val
- #endif
-     memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
- 
--  uint to_length=max(field_length,70);
-+  uint to_length=mysql_max(field_length,70);
-   val_buffer->alloc(to_length);
-   char *to=(char*) val_buffer->ptr();
- 
-@@ -4289,7 +4289,7 @@ String *Field_double::val_str(String *va
- #endif
-     doubleget(nr,ptr);
- 
--  uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+  uint to_length=mysql_max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-   val_buffer->alloc(to_length);
-   char *to=(char*) val_buffer->ptr();
- 
-@@ -6142,13 +6142,13 @@ int Field_str::store(double nr)
-   double anr= fabs(nr);
-   int neg= (nr < 0.0) ? 1 : 0;
-   if (local_char_length > 4 && local_char_length < 32 &&
--      (anr < 1.0 ? anr > 1/(log_10[max(0,(int) local_char_length-neg-2)]) /* -2 for "0." */
-+      (anr < 1.0 ? anr > 1/(log_10[mysql_max(0,(int) local_char_length-neg-2)]) /* -2 for "0." */
-        : anr < log_10[local_char_length-neg]-1))
-     use_scientific_notation= FALSE;
- 
-   length= (uint) my_sprintf(buff, (buff, "%-.*g",
-                                    (use_scientific_notation ?
--                                    max(0, (int)local_char_length-neg-5) :
-+                                    mysql_max(0, (int)local_char_length-neg-5) :
-                                     local_char_length),
-                                    nr));
-   /*
-@@ -6357,7 +6357,7 @@ void Field_string::sql_type(String &res)
- 
- uchar *Field_string::pack(uchar *to, const uchar *from, uint max_length)
- {
--  uint length=      min(field_length,max_length);
-+  uint length=      mysql_min(field_length,max_length);
-   uint local_char_length= max_length/field_charset->mbmaxlen;
-   if (length > local_char_length)
-     local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7292,7 +7292,7 @@ int Field_blob::store(const char *from,u
-     from= tmpstr.ptr();
-   }
- 
--  new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+  new_length= mysql_min(max_data_length(), field_charset->mbmaxlen * length);
-   if (value.alloc(new_length))
-     goto oom_error;
- 
-@@ -7447,7 +7447,7 @@ int Field_blob::cmp_binary(const uchar *
-   b_length=get_length(b_ptr);
-   if (b_length > max_length)
-     b_length=max_length;
--  diff=memcmp(a,b,min(a_length,b_length));
-+  diff=memcmp(a,b,mysql_min(a_length,b_length));
-   return diff ? diff : (int) (a_length - b_length);
- }
- 
-@@ -8569,7 +8569,7 @@ String *Field_bit::val_str(String *val_b
- {
-   ASSERT_COLUMN_MARKED_FOR_READ;
-   char buff[sizeof(longlong)];
--  uint length= min(pack_length(), sizeof(longlong));
-+  uint length= mysql_min(pack_length(), sizeof(longlong));
-   ulonglong bits= val_int();
-   mi_int8store(buff,bits);
- 
-@@ -8655,7 +8655,7 @@ uint Field_bit::get_key_image(uchar *buf
-     *buff++= bits;
-     length--;
-   }
--  uint data_length = min(length, bytes_in_rec);
-+  uint data_length = mysql_min(length, bytes_in_rec);
-   memcpy(buff, ptr, data_length);
-   return data_length + 1;
- }
-@@ -8698,7 +8698,7 @@ uchar *Field_bit::pack(uchar *to, const 
-     uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
-     *to++= bits;
-   }
--  length= min(bytes_in_rec, max_length - (bit_len > 0));
-+  length= mysql_min(bytes_in_rec, max_length - (bit_len > 0));
-   memcpy(to, from, length);
-   return to + length;
- }
-@@ -9146,7 +9146,7 @@ bool Create_field::init(THD *thd, char *
-         and 19 as length of 4.1 compatible representation.
-       */
-       length= ((length+1)/2)*2; /* purecov: inspected */
--      length= min(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
-+      length= mysql_min(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
-     }
-     flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
-     if (fld_default_value)
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/filesort.cc mysql-dfsg-5.1-5.1.22rc/sql/filesort.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/filesort.cc	2007-09-24 12:29:58.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/filesort.cc	2007-10-02 23:35:52.000000000 +0200
-@@ -181,7 +181,7 @@ ha_rows filesort(THD *thd, TABLE *table,
- #ifdef CAN_TRUST_RANGE
-   if (select && select->quick && select->quick->records > 0L)
-   {
--    records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+    records=mysql_min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- 		table->file->stats.records)+EXTRA_RECORDS;
-     selected_records_file=0;
-   }
-@@ -203,12 +203,12 @@ ha_rows filesort(THD *thd, TABLE *table,
-     goto err;
- 
-   memavl= thd->variables.sortbuff_size;
--  min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+  min_sort_memory= mysql_max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-   while (memavl >= min_sort_memory)
-   {
-     ulong old_memavl;
-     ulong keys= memavl/(param.rec_length+sizeof(char*));
--    param.keys=(uint) min(records+1, keys);
-+    param.keys=(uint) mysql_min(records+1, keys);
-     if ((table_sort.sort_keys=
- 	 (uchar **) make_char_array((char **) table_sort.sort_keys,
-                                     param.keys, param.rec_length, MYF(0))))
-@@ -1049,7 +1049,7 @@ uint read_to_buffer(IO_CACHE *fromfile, 
-   register uint count;
-   uint length;
- 
--  if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+  if ((count=(uint) mysql_min((ha_rows) buffpek->max_keys,buffpek->count)))
-   {
-     if (my_pread(fromfile->file,(uchar*) buffpek->base,
- 		 (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1312,7 +1312,7 @@ int merge_buffers(SORTPARAM *param, IO_C
-          != -1 && error != 0);
- 
- end:
--  lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+  lastbuff->count= mysql_min(org_max_rows-max_rows, param->max_rows);
-   lastbuff->file_pos= to_start_filepos;
- err:
-   delete_queue(&queue);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/ha_ndbcluster.cc mysql-dfsg-5.1-5.1.22rc/sql/ha_ndbcluster.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/ha_ndbcluster.cc	2007-09-24 12:29:40.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/ha_ndbcluster.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -804,7 +804,7 @@ int ha_ndbcluster::set_ndb_value(NdbOper
- 
-       DBUG_PRINT("value", ("set blob ptr: 0x%lx  len: %u",
-                            (long) blob_ptr, blob_len));
--      DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+      DBUG_DUMP("value", blob_ptr, mysql_min(blob_len, 26));
- 
-       if (set_blob_value)
-         *set_blob_value= TRUE;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/handler.h mysql-dfsg-5.1-5.1.22rc/sql/handler.h
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/handler.h	2007-09-24 12:29:59.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/handler.h	2007-10-02 23:35:53.000000000 +0200
-@@ -1565,15 +1565,15 @@ public:
-   { return (HA_ERR_WRONG_COMMAND); }
- 
-   uint max_record_length() const
--  { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+  { return mysql_min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-   uint max_keys() const
--  { return min(MAX_KEY, max_supported_keys()); }
-+  { return mysql_min(MAX_KEY, max_supported_keys()); }
-   uint max_key_parts() const
--  { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+  { return mysql_min(MAX_REF_PARTS, max_supported_key_parts()); }
-   uint max_key_length() const
--  { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+  { return mysql_min(MAX_KEY_LENGTH, max_supported_key_length()); }
-   uint max_key_part_length() const
--  { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+  { return mysql_min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
- 
-   virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
-   virtual uint max_supported_keys() const { return 0; }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/ha_partition.cc mysql-dfsg-5.1-5.1.22rc/sql/ha_partition.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/ha_partition.cc	2007-09-24 12:29:43.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/ha_partition.cc	2007-10-02 23:35:54.000000000 +0200
-@@ -2781,7 +2781,7 @@ int ha_partition::update_row(const uchar
-   /*
-     TODO:
-       set_internal_auto_increment=
--        max(set_internal_auto_increment, new_data->auto_increment)
-+        mysql_max(set_internal_auto_increment, new_data->auto_increment)
-   */
-   m_last_part= new_part_id;
-   if (new_part_id == old_part_id)
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/item_buff.cc mysql-dfsg-5.1-5.1.22rc/sql/item_buff.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/item_buff.cc	2007-09-24 12:30:11.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/item_buff.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -51,7 +51,7 @@ Cached_item::~Cached_item() {}
- */
- 
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
--  :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+  :item(arg), value(mysql_min(arg->max_length, thd->variables.max_sort_length))
- {}
- 
- bool Cached_item_str::cmp(void)
-@@ -60,7 +60,7 @@ bool Cached_item_str::cmp(void)
-   bool tmp;
- 
-   if ((res=item->val_str(&tmp_value)))
--    res->length(min(res->length(), value.alloced_length()));
-+    res->length(mysql_min(res->length(), value.alloced_length()));
-   if (null_value != item->null_value)
-   {
-     if ((null_value= item->null_value))
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/item.cc mysql-dfsg-5.1-5.1.22rc/sql/item.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/item.cc	2007-09-24 12:29:31.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/item.cc	2007-10-02 23:35:52.000000000 +0200
-@@ -73,7 +73,7 @@ void
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
-   item->decimals= arg->decimals;
--  item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+  item->max_length= mysql_min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-                         DECIMAL_MAX_STR_LENGTH);
- }
- 
-@@ -426,9 +426,9 @@ uint Item::decimal_precision() const
-   Item_result restype= result_type();
- 
-   if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT))
--    return min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
-+    return mysql_min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
-                DECIMAL_MAX_PRECISION);
--  return min(max_length, DECIMAL_MAX_PRECISION);
-+  return mysql_min(max_length, DECIMAL_MAX_PRECISION);
- }
- 
- 
-@@ -728,7 +728,7 @@ void Item::set_name(const char *str, uin
- 				   &res_length);
-   }
-   else
--    name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+    name= sql_strmake(str, (name_length= mysql_min(length,MAX_ALIAS_NAME)));
- }
- 
- 
-@@ -4805,7 +4805,7 @@ longlong Item_hex_string::val_int()
-   // following assert is redundant, because fixed=1 assigned in constructor
-   DBUG_ASSERT(fixed == 1);
-   char *end=(char*) str_value.ptr()+str_value.length(),
--       *ptr=end-min(str_value.length(),sizeof(longlong));
-+       *ptr=end-mysql_min(str_value.length(),sizeof(longlong));
- 
-   ulonglong value=0;
-   for (; ptr != end ; ptr++)
-@@ -6697,12 +6697,12 @@ bool Item_type_holder::join_types(THD *t
-     /* fix variable decimals which always is NOT_FIXED_DEC */
-     if (Field::result_merge_type(fld_type) == INT_RESULT)
-       item_decimals= 0;
--    decimals= max(decimals, item_decimals);
-+    decimals= mysql_max(decimals, item_decimals);
-   }
-   if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
-   {
--    decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
--    int precision= min(max(prev_decimal_int_part, item->decimal_int_part())
-+    decimals= mysql_min(mysql_max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+    int precision= mysql_min(mysql_max(prev_decimal_int_part, item->decimal_int_part())
-                        + decimals, DECIMAL_MAX_PRECISION);
-     unsigned_flag&= item->unsigned_flag;
-     max_length= my_decimal_precision_to_length(precision, decimals,
-@@ -6733,7 +6733,7 @@ bool Item_type_holder::join_types(THD *t
-      */
-     if (collation.collation != &my_charset_bin)
-     {
--      max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+      max_length= mysql_max(old_max_chars * collation.collation->mbmaxlen,
-                       display_length(item) /
-                       item->collation.collation->mbmaxlen *
-                       collation.collation->mbmaxlen);
-@@ -6748,7 +6748,7 @@ bool Item_type_holder::join_types(THD *t
-     {
-       int delta1= max_length_orig - decimals_orig;
-       int delta2= item->max_length - item->decimals;
--      max_length= max(delta1, delta2) + decimals;
-+      max_length= mysql_max(delta1, delta2) + decimals;
-       if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2) 
-       {
-         max_length= FLT_DIG + 6;
-@@ -6765,7 +6765,7 @@ bool Item_type_holder::join_types(THD *t
-     break;
-   }
-   default:
--    max_length= max(max_length, display_length(item));
-+    max_length= mysql_max(max_length, display_length(item));
-   };
-   maybe_null|= item->maybe_null;
-   get_full_info(item);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/item_cmpfunc.cc mysql-dfsg-5.1-5.1.22rc/sql/item_cmpfunc.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/item_cmpfunc.cc	2007-09-24 12:30:14.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/item_cmpfunc.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -560,7 +560,7 @@ int Arg_comparator::set_compare_func(Ite
-   {
-     if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
-     {
--      precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+      precision= 5 / log_10[mysql_max((*a)->decimals, (*b)->decimals) + 1];
-       if (func == &Arg_comparator::compare_real)
-         func= &Arg_comparator::compare_real_fixed;
-       else if (func == &Arg_comparator::compare_e_real)
-@@ -1032,7 +1032,7 @@ int Arg_comparator::compare_binary_strin
-       owner->null_value= 0;
-       uint res1_length= res1->length();
-       uint res2_length= res2->length();
--      int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+      int cmp= memcmp(res1->ptr(), res2->ptr(), mysql_min(res1_length,res2_length));
-       return cmp ? cmp : (int) (res1_length - res2_length);
-     }
-   }
-@@ -2045,11 +2045,11 @@ Item_func_ifnull::fix_length_and_dec()
- {
-   agg_result_type(&hybrid_type, args, 2);
-   maybe_null=args[1]->maybe_null;
--  decimals= max(args[0]->decimals, args[1]->decimals);
-+  decimals= mysql_max(args[0]->decimals, args[1]->decimals);
-   max_length= (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT) ?
--    (max(args[0]->max_length - args[0]->decimals,
-+    (mysql_max(args[0]->max_length - args[0]->decimals,
-          args[1]->max_length - args[1]->decimals) + decimals) :
--    max(args[0]->max_length, args[1]->max_length);
-+    mysql_max(args[0]->max_length, args[1]->max_length);
- 
-   switch (hybrid_type) {
-   case STRING_RESULT:
-@@ -2073,8 +2073,8 @@ Item_func_ifnull::fix_length_and_dec()
- 
- uint Item_func_ifnull::decimal_precision() const
- {
--  int max_int_part=max(args[0]->decimal_int_part(),args[1]->decimal_int_part());
--  return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+  int max_int_part=mysql_max(args[0]->decimal_int_part(),args[1]->decimal_int_part());
-+  return mysql_min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
- 
- 
-@@ -2203,7 +2203,7 @@ void
- Item_func_if::fix_length_and_dec()
- {
-   maybe_null=args[1]->maybe_null || args[2]->maybe_null;
--  decimals= max(args[1]->decimals, args[2]->decimals);
-+  decimals= mysql_max(args[1]->decimals, args[2]->decimals);
-   unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
- 
-   enum Item_result arg1_type=args[1]->result_type();
-@@ -2244,18 +2244,18 @@ Item_func_if::fix_length_and_dec()
-     int len2= args[2]->max_length - args[2]->decimals
-       - (args[2]->unsigned_flag ? 0 : 1);
- 
--    max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+    max_length=mysql_max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-   }
-   else
--    max_length= max(args[1]->max_length, args[2]->max_length);
-+    max_length= mysql_max(args[1]->max_length, args[2]->max_length);
- }
- 
- 
- uint Item_func_if::decimal_precision() const
- {
--  int precision=(max(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
-+  int precision=(mysql_max(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
-                  decimals);
--  return min(precision, DECIMAL_MAX_PRECISION);
-+  return mysql_min(precision, DECIMAL_MAX_PRECISION);
- }
- 
- 
-@@ -2641,7 +2641,7 @@ uint Item_func_case::decimal_precision()
- 
-   if (else_expr_num != -1) 
-     set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
--  return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+  return mysql_min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
- 
- 
-@@ -4489,7 +4489,7 @@ void Item_func_like::turboBM_compute_suf
-       else
-       {
- 	if (i < g)
--	  g = i; // g = min(i, g)
-+	  g = i; // g = mysql_min(i, g)
- 	f = i;
- 	while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- 	  g--;
-@@ -4508,7 +4508,7 @@ void Item_func_like::turboBM_compute_suf
-       else
-       {
- 	if (i < g)
--	  g = i; // g = min(i, g)
-+	  g = i; // g = mysql_min(i, g)
- 	f = i;
- 	while (g >= 0 &&
- 	       likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -4629,14 +4629,14 @@ bool Item_func_like::turboBM_matches(con
-       register const int v = plm1 - i;
-       turboShift = u - v;
-       bcShift    = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
--      shift      = max(turboShift, bcShift);
--      shift      = max(shift, bmGs[i]);
-+      shift      = mysql_max(turboShift, bcShift);
-+      shift      = mysql_max(shift, bmGs[i]);
-       if (shift == bmGs[i])
--	u = min(pattern_len - shift, v);
-+	u = mysql_min(pattern_len - shift, v);
-       else
-       {
- 	if (turboShift < bcShift)
--	  shift = max(shift, u + 1);
-+	  shift = mysql_max(shift, u + 1);
- 	u = 0;
-       }
-       j+= shift;
-@@ -4660,14 +4660,14 @@ bool Item_func_like::turboBM_matches(con
-       register const int v = plm1 - i;
-       turboShift = u - v;
-       bcShift    = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
--      shift      = max(turboShift, bcShift);
--      shift      = max(shift, bmGs[i]);
-+      shift      = mysql_max(turboShift, bcShift);
-+      shift      = mysql_max(shift, bmGs[i]);
-       if (shift == bmGs[i])
--	u = min(pattern_len - shift, v);
-+	u = mysql_min(pattern_len - shift, v);
-       else
-       {
- 	if (turboShift < bcShift)
--	  shift = max(shift, u + 1);
-+	  shift = mysql_max(shift, u + 1);
- 	u = 0;
-       }
-       j+= shift;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/item_func.cc mysql-dfsg-5.1-5.1.22rc/sql/item_func.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/item_func.cc	2007-09-24 12:30:26.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/item_func.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -542,7 +542,7 @@ void Item_func::count_decimal_length()
-     set_if_bigger(max_int_part, args[i]->decimal_int_part());
-     set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
-   }
--  int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+  int precision= mysql_min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-   max_length= my_decimal_precision_to_length(precision, decimals,
-                                              unsigned_flag);
- }
-@@ -1152,10 +1152,10 @@ my_decimal *Item_func_plus::decimal_op(m
- */
- void Item_func_additive_op::result_precision()
- {
--  decimals= max(args[0]->decimals, args[1]->decimals);
--  int max_int_part= max(args[0]->decimal_precision() - args[0]->decimals,
-+  decimals= mysql_max(args[0]->decimals, args[1]->decimals);
-+  int max_int_part= mysql_max(args[0]->decimal_precision() - args[0]->decimals,
-                         args[1]->decimal_precision() - args[1]->decimals);
--  int precision= min(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
-+  int precision= mysql_min(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
- 
-   /* Integer operations keep unsigned_flag if one of arguments is unsigned */
-   if (result_type() == INT_RESULT)
-@@ -1263,8 +1263,8 @@ void Item_func_mul::result_precision()
-     unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
-   else
-     unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
--  decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
--  int precision= min(args[0]->decimal_precision() + args[1]->decimal_precision(),
-+  decimals= mysql_min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+  int precision= mysql_min(args[0]->decimal_precision() + args[1]->decimal_precision(),
-                      DECIMAL_MAX_PRECISION);
-   max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag);
- }
-@@ -1312,14 +1312,14 @@ my_decimal *Item_func_div::decimal_op(my
- 
- void Item_func_div::result_precision()
- {
--  uint precision=min(args[0]->decimal_precision() + prec_increment,
-+  uint precision=mysql_min(args[0]->decimal_precision() + prec_increment,
-                      DECIMAL_MAX_PRECISION);
-   /* Integer operations keep unsigned_flag if one of arguments is unsigned */
-   if (result_type() == INT_RESULT)
-     unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
-   else
-     unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
--  decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+  decimals= mysql_min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-   max_length= my_decimal_precision_to_length(precision, decimals,
-                                              unsigned_flag);
- }
-@@ -1333,7 +1333,7 @@ void Item_func_div::fix_length_and_dec()
-   switch(hybrid_type) {
-   case REAL_RESULT:
-   {
--    decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+    decimals=mysql_max(args[0]->decimals,args[1]->decimals)+prec_increment;
-     set_if_smaller(decimals, NOT_FIXED_DEC);
-     max_length=args[0]->max_length - args[0]->decimals + decimals;
-     uint tmp=float_length(decimals);
-@@ -1451,8 +1451,8 @@ my_decimal *Item_func_mod::decimal_op(my
- 
- void Item_func_mod::result_precision()
- {
--  decimals= max(args[0]->decimals, args[1]->decimals);
--  max_length= max(args[0]->max_length, args[1]->max_length);
-+  decimals= mysql_max(args[0]->decimals, args[1]->decimals);
-+  max_length= mysql_max(args[0]->max_length, args[1]->max_length);
- }
- 
- 
-@@ -1970,7 +1970,7 @@ void Item_func_round::fix_length_and_dec
-   if (args[0]->decimals == NOT_FIXED_DEC)
-   {
-     max_length= args[0]->max_length;
--    decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+    decimals= mysql_min(decimals_to_set, NOT_FIXED_DEC);
-     hybrid_type= REAL_RESULT;
-     return;
-   }
-@@ -1979,7 +1979,7 @@ void Item_func_round::fix_length_and_dec
-   case REAL_RESULT:
-   case STRING_RESULT:
-     hybrid_type= REAL_RESULT;
--    decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+    decimals= mysql_min(decimals_to_set, NOT_FIXED_DEC);
-     max_length= float_length(decimals);
-     break;
-   case INT_RESULT:
-@@ -2102,7 +2102,7 @@ my_decimal *Item_func_round::decimal_op(
-   longlong dec= args[1]->val_int();
-   if (dec > 0 || (dec < 0 && args[1]->unsigned_flag))
-   {
--    dec= min((ulonglong) dec, DECIMAL_MAX_SCALE);
-+    dec= mysql_min((ulonglong) dec, DECIMAL_MAX_SCALE);
-     decimals= (uint8) dec; // to get correct output
-   }
-   else if (dec < INT_MIN)
-@@ -2950,10 +2950,10 @@ udf_handler::fix_fields(THD *thd, Item_r
-       free_udf(u_d);
-       DBUG_RETURN(TRUE);
-     }
--    func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+    func->max_length=mysql_min(initid.max_length,MAX_BLOB_WIDTH);
-     func->maybe_null=initid.maybe_null;
-     const_item_cache=initid.const_item;
--    func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+    func->decimals=mysql_min(initid.decimals,NOT_FIXED_DEC);
-   }
-   initialized=1;
-   if (error)
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/item_strfunc.cc mysql-dfsg-5.1-5.1.22rc/sql/item_strfunc.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/item_strfunc.cc	2007-09-24 12:30:00.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/item_strfunc.cc	2007-10-02 23:35:52.000000000 +0200
-@@ -1183,7 +1183,7 @@ String *Item_func_substr::val_str(String
- 
-   length= res->charpos((int) length, (uint32) start);
-   tmp_length= res->length() - start;
--  length= min(length, tmp_length);
-+  length= mysql_min(length, tmp_length);
- 
-   if (!start && (longlong) res->length() == length)
-     return res;
-@@ -1203,7 +1203,7 @@ void Item_func_substr::fix_length_and_de
-     if (start < 0)
-       max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
-     else
--      max_length-= min((uint)(start - 1), max_length);
-+      max_length-= mysql_min((uint)(start - 1), max_length);
-   }
-   if (arg_count == 3 && args[2]->const_item())
-   {
-@@ -1888,7 +1888,7 @@ String *Item_func_soundex::val_str(Strin
-   if ((null_value= args[0]->null_value))
-     return 0; /* purecov: inspected */
- 
--  if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+  if (tmp_value.alloc(mysql_max(res->length(), 4 * cs->mbminlen)))
-     return str; /* purecov: inspected */
-   char *to= (char *) tmp_value.ptr();
-   char *to_end= to + tmp_value.alloced_length();
-@@ -3009,11 +3009,11 @@ String* Item_func_export_set::val_str(St
- 
- void Item_func_export_set::fix_length_and_dec()
- {
--  uint length=max(args[1]->max_length,args[2]->max_length);
-+  uint length=mysql_max(args[1]->max_length,args[2]->max_length);
-   uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
-   max_length=length*64+sep_length*63;
- 
--  if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+  if (agg_arg_charsets(collation, args+1, mysql_min(4,arg_count)-1,
-                        MY_COLL_ALLOW_CONV, 1))
-     return;
- }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/item_sum.cc mysql-dfsg-5.1-5.1.22rc/sql/item_sum.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/item_sum.cc	2007-09-24 12:30:25.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/item_sum.cc	2007-10-02 23:35:54.000000000 +0200
-@@ -1071,7 +1071,7 @@ Item_sum_avg_distinct::fix_length_and_de
-     AVG() will divide val by count. We need to reserve digits
-     after decimal point as the result can be fractional.
-   */
--  decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+  decimals= mysql_min(decimals + prec_increment, NOT_FIXED_DEC);
- }
- 
- 
-@@ -1134,15 +1134,15 @@ void Item_sum_avg::fix_length_and_dec()
-   if (hybrid_type == DECIMAL_RESULT)
-   {
-     int precision= args[0]->decimal_precision() + prec_increment;
--    decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+    decimals= mysql_min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-     max_length= my_decimal_precision_to_length(precision, decimals,
-                                                unsigned_flag);
--    f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+    f_precision= mysql_min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-     f_scale=  args[0]->decimals;
-     dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
-   }
-   else {
--    decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+    decimals= mysql_min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-     max_length= args[0]->max_length + prec_increment;
-   }
- }
-@@ -1326,13 +1326,13 @@ void Item_sum_variance::fix_length_and_d
-   switch (args[0]->result_type()) {
-   case REAL_RESULT:
-   case STRING_RESULT:
--    decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+    decimals= mysql_min(args[0]->decimals + 4, NOT_FIXED_DEC);
-     break;
-   case INT_RESULT:
-   case DECIMAL_RESULT:
-   {
-     int precision= args[0]->decimal_precision()*2 + prec_increment;
--    decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+    decimals= mysql_min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-     max_length= my_decimal_precision_to_length(precision, decimals,
-                                                unsigned_flag);
- 
-@@ -3362,7 +3362,7 @@ bool Item_func_group_concat::setup(THD *
-       duplicate values (according to the syntax of this function). If there
-       is no DISTINCT or ORDER BY clauses, we don't create this tree.
-     */
--    init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+    init_tree(tree, (uint) mysql_min(thd->variables.max_heap_table_size,
-                                thd->variables.sortbuff_size/16), 0,
-               tree_key_length, compare_key, 0, NULL, (void*) this);
-   }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/item_timefunc.cc mysql-dfsg-5.1-5.1.22rc/sql/item_timefunc.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/item_timefunc.cc	2007-09-24 12:30:14.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/item_timefunc.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -306,14 +306,14 @@ static bool extract_date_time(DATE_TIME_
-       switch (*++ptr) {
- 	/* Year */
-       case 'Y':
--	tmp= (char*) val + min(4, val_len);
-+	tmp= (char*) val + mysql_min(4, val_len);
- 	l_time->year= (int) my_strtoll10(val, &tmp, &error);
-         if ((int) (tmp-val) <= 2)
-           l_time->year= year_2000_handling(l_time->year);
- 	val= tmp;
- 	break;
-       case 'y':
--	tmp= (char*) val + min(2, val_len);
-+	tmp= (char*) val + mysql_min(2, val_len);
- 	l_time->year= (int) my_strtoll10(val, &tmp, &error);
- 	val= tmp;
-         l_time->year= year_2000_handling(l_time->year);
-@@ -322,7 +322,7 @@ static bool extract_date_time(DATE_TIME_
- 	/* Month */
-       case 'm':
-       case 'c':
--	tmp= (char*) val + min(2, val_len);
-+	tmp= (char*) val + mysql_min(2, val_len);
- 	l_time->month= (int) my_strtoll10(val, &tmp, &error);
- 	val= tmp;
- 	break;
-@@ -339,15 +339,15 @@ static bool extract_date_time(DATE_TIME_
- 	/* Day */
-       case 'd':
-       case 'e':
--	tmp= (char*) val + min(2, val_len);
-+	tmp= (char*) val + mysql_min(2, val_len);
- 	l_time->day= (int) my_strtoll10(val, &tmp, &error);
- 	val= tmp;
- 	break;
-       case 'D':
--	tmp= (char*) val + min(2, val_len);
-+	tmp= (char*) val + mysql_min(2, val_len);
- 	l_time->day= (int) my_strtoll10(val, &tmp, &error);
- 	/* Skip 'st, 'nd, 'th .. */
--	val= tmp + min((int) (val_end-tmp), 2);
-+	val= tmp + mysql_min((int) (val_end-tmp), 2);
- 	break;
- 
- 	/* Hour */
-@@ -358,14 +358,14 @@ static bool extract_date_time(DATE_TIME_
- 	/* fall through */
-       case 'k':
-       case 'H':
--	tmp= (char*) val + min(2, val_len);
-+	tmp= (char*) val + mysql_min(2, val_len);
- 	l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- 	val= tmp;
- 	break;
- 
- 	/* Minute */
-       case 'i':
--	tmp= (char*) val + min(2, val_len);
-+	tmp= (char*) val + mysql_min(2, val_len);
- 	l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- 	val= tmp;
- 	break;
-@@ -373,7 +373,7 @@ static bool extract_date_time(DATE_TIME_
- 	/* Second */
-       case 's':
-       case 'S':
--	tmp= (char*) val + min(2, val_len);
-+	tmp= (char*) val + mysql_min(2, val_len);
- 	l_time->second= (int) my_strtoll10(val, &tmp, &error);
- 	val= tmp;
- 	break;
-@@ -425,7 +425,7 @@ static bool extract_date_time(DATE_TIME_
- 	val= tmp;
- 	break;
-       case 'j':
--	tmp= (char*) val + min(val_len, 3);
-+	tmp= (char*) val + mysql_min(val_len, 3);
- 	yearday= (int) my_strtoll10(val, &tmp, &error);
- 	val= tmp;
- 	break;
-@@ -437,7 +437,7 @@ static bool extract_date_time(DATE_TIME_
-       case 'u':
-         sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
-         strict_week_number= (*ptr=='V' || *ptr=='v');
--	tmp= (char*) val + min(val_len, 2);
-+	tmp= (char*) val + mysql_min(val_len, 2);
- 	if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
-             strict_week_number && !week_number ||
-             week_number > 53)
-@@ -449,7 +449,7 @@ static bool extract_date_time(DATE_TIME_
-       case 'X':
-       case 'x':
-         strict_week_number_year_type= (*ptr=='X');
--        tmp= (char*) val + min(4, val_len);
-+        tmp= (char*) val + mysql_min(4, val_len);
-         strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
-         val= tmp;
-         break;
-@@ -594,7 +594,7 @@ static bool extract_date_time(DATE_TIME_
- err:
-   {
-     char buff[128];
--    strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+    strmake(buff, val_begin, mysql_min(length, sizeof(buff)-1));
-     push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
-                         ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
-                         date_time_type, buff, "str_to_time");
-@@ -1711,7 +1711,7 @@ void Item_func_date_format::fix_length_a
-   else
-   {
-     fixed_length=0;
--    max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+    max_length=mysql_min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-                    collation.collation->mbmaxlen;
-     set_if_smaller(max_length,MAX_BLOB_WIDTH);
-   }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/key.cc mysql-dfsg-5.1-5.1.22rc/sql/key.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/key.cc	2007-09-24 12:29:42.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/key.cc	2007-10-02 23:35:54.000000000 +0200
-@@ -144,13 +144,13 @@ void key_copy(uchar *to_key, uchar *from
-         key_part->key_part_flag & HA_VAR_LENGTH_PART)
-     {
-       key_length-= HA_KEY_BLOB_LENGTH;
--      length= min(key_length, key_part->length);
-+      length= mysql_min(key_length, key_part->length);
-       key_part->field->get_key_image(to_key, length, Field::itRAW);
-       to_key+= HA_KEY_BLOB_LENGTH;
-     }
-     else
-     {
--      length= min(key_length, key_part->length);
-+      length= mysql_min(key_length, key_part->length);
-       Field *field= key_part->field;
-       CHARSET_INFO *cs= field->charset();
-       uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -237,7 +237,7 @@ void key_restore(uchar *to_record, uchar
-       my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
-       field->move_field_offset(ptrdiff);
-       key_length-= HA_KEY_BLOB_LENGTH;
--      length= min(key_length, key_part->length);
-+      length= mysql_min(key_length, key_part->length);
-       old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
-       field->set_key_image(from_key, length);
-       dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -246,7 +246,7 @@ void key_restore(uchar *to_record, uchar
-     }
-     else
-     {
--      length= min(key_length, key_part->length);
-+      length= mysql_min(key_length, key_part->length);
-       memcpy(to_record + key_part->offset, from_key, (size_t) length);
-     }
-     from_key+= length;
-@@ -306,7 +306,7 @@ bool key_cmp_if_same(TABLE *table,const 
- 	return 1;
-       continue;
-     }
--    length= min((uint) (key_end-key), store_length);
-+    length= mysql_min((uint) (key_end-key), store_length);
-     if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
-                                 FIELDFLAG_PACK)))
-     {
-@@ -372,7 +372,7 @@ void key_unpack(String *to,TABLE *table,
-     {
-       field->val_str(&tmp);
-       if (key_part->length < field->pack_length())
--	tmp.length(min(tmp.length(),key_part->length));
-+	tmp.length(mysql_min(tmp.length(),key_part->length));
-       to->append(tmp);
-     }
-     else
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/log.cc mysql-dfsg-5.1-5.1.22rc/sql/log.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/log.cc	2007-09-24 12:30:26.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/log.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -537,11 +537,11 @@ bool Log_to_csv_event_handler::
-     t.neg= 0;
- 
-     /* fill in query_time field */
--    calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+    calc_time_from_sec(&t, (long) mysql_min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-     if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
-       goto err;
-     /* lock_time */
--    calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+    calc_time_from_sec(&t, (long) mysql_min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-     if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
-       goto err;
-     /* rows_sent */
-@@ -2173,7 +2173,7 @@ const char *MYSQL_LOG::generate_name(con
-   {
-     char *p= fn_ext(log_name);
-     uint length= (uint) (p - log_name);
--    strmake(buff, log_name, min(length, FN_REFLEN));
-+    strmake(buff, log_name, mysql_min(length, FN_REFLEN));
-     return (const char*)buff;
-   }
-   return log_name;
-@@ -4285,7 +4285,7 @@ static void print_buffer_to_nt_eventlog(
-   DBUG_ENTER("print_buffer_to_nt_eventlog");
- 
-   /* Add ending CR/LF's to string, overwrite last chars if necessary */
--  strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+  strmov(buffptr+mysql_min(length, buffLen-5), "\r\n\r\n");
- 
-   setup_windows_event_source();
-   if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/log_event.cc mysql-dfsg-5.1-5.1.22rc/sql/log_event.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/log_event.cc	2007-09-24 12:30:13.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/log_event.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -828,7 +828,7 @@ Log_event* Log_event::read_log_event(IO_
-     of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
-     "minimal" over the set {MySQL >=4.0}).
-   */
--  uint header_size= min(description_event->common_header_len,
-+  uint header_size= mysql_min(description_event->common_header_len,
-                         LOG_EVENT_MINIMAL_HEADER_LEN);
- 
-   LOCK_MUTEX;
-@@ -4172,7 +4172,7 @@ bool User_var_log_event::write(IO_CACHE*
-   char buf[UV_NAME_LEN_SIZE];
-   char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE + 
- 	    UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
--  uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+  uchar buf2[mysql_max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-   uint buf1_length;
-   ulong event_length;
- 
-@@ -5853,7 +5853,7 @@ int Rows_log_event::do_add_row_data(ucha
-     trigger false warnings.
-    */
- #ifndef HAVE_purify
--  DBUG_DUMP("row_data", row_data, min(length, 32));
-+  DBUG_DUMP("row_data", row_data, mysql_min(length, 32));
- #endif
- 
-   DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/mysqld.cc mysql-dfsg-5.1-5.1.22rc/sql/mysqld.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/mysqld.cc	2007-09-24 12:29:40.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/mysqld.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -2817,7 +2817,7 @@ static int init_common_variables(const c
-       can't get max_connections*5 but still got no less than was
-       requested (value of wanted_files).
-     */
--    max_open_files= max(max(wanted_files, max_connections*5),
-+    max_open_files= mysql_max(mysql_max(wanted_files, max_connections*5),
-                         open_files_limit);
-     files= my_set_max_open_files(max_open_files);
- 
-@@ -2829,15 +2829,15 @@ static int init_common_variables(const c
-           If we have requested too much file handles than we bring
-           max_connections in supported bounds.
-         */
--        max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+        max_connections= (ulong) mysql_min(files-10-TABLE_OPEN_CACHE_MIN*2,
-                                      max_connections);
-         /*
-           Decrease table_cache_size according to max_connections, but
--          not below TABLE_OPEN_CACHE_MIN.  Outer min() ensures that we
-+          not below TABLE_OPEN_CACHE_MIN.  Outer mysql_min() ensures that we
-           never increase table_cache_size automatically (that could
-           happen if max_connections is decreased above).
-         */
--        table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+        table_cache_size= (ulong) mysql_min(mysql_max((files-10-max_connections)/2,
-                                           TABLE_OPEN_CACHE_MIN),
-                                       table_cache_size);    
- 	DBUG_PRINT("warning",
-@@ -4401,7 +4401,7 @@ pthread_handler_t handle_connections_soc
- {
-   my_socket sock,new_sock;
-   uint error_count=0;
--  uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+  uint max_used_connection= (uint) (mysql_max(ip_sock,unix_sock)+1);
-   fd_set readFDs,clientFDs;
-   THD *thd;
-   struct sockaddr_in cAddr;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/my_time.c mysql-dfsg-5.1-5.1.22rc/sql/my_time.c
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/my_time.c	2007-09-24 12:29:57.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/my_time.c	2007-10-02 23:35:53.000000000 +0200
-@@ -251,7 +251,7 @@ str_to_datetime(const char *str, uint le
-     2003-03-03 20:00:20 AM
-     20:00:20.000000 AM 03-03-2000
-   */
--  i= max((uint) format_position[0], (uint) format_position[1]);
-+  i= mysql_max((uint) format_position[0], (uint) format_position[1]);
-   set_if_bigger(i, (uint) format_position[2]);
-   allow_space= ((1 << i) | (1 << format_position[6]));
-   allow_space&= (1 | 2 | 4 | 8);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/net_serv.cc mysql-dfsg-5.1-5.1.22rc/sql/net_serv.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/net_serv.cc	2007-09-24 12:29:59.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/net_serv.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -762,7 +762,7 @@ static my_bool my_net_skip_rest(NET *net
-   {
-     while (remain > 0)
-     {
--      size_t length= min(remain, net->max_packet);
-+      size_t length= mysql_min(remain, net->max_packet);
-       if (net_safe_read(net, net->buff, length, alarmed))
- 	DBUG_RETURN(1);
-       update_statistics(thd_increment_bytes_received(length));
-@@ -936,7 +936,7 @@ my_real_read(NET *net, size_t *complen)
- 	len=uint3korr(net->buff+net->where_b);
- 	if (!len)				/* End of big multi-packet */
- 	  goto end;
--	helping = max(len,*complen) + net->where_b;
-+	helping = mysql_max(len,*complen) + net->where_b;
- 	/* The necessary size of net->buff */
- 	if (helping >= net->max_packet)
- 	{
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/opt_range.cc mysql-dfsg-5.1-5.1.22rc/sql/opt_range.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/opt_range.cc	2007-09-24 12:29:40.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/opt_range.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -2272,7 +2272,7 @@ int SQL_SELECT::test_quick_select(THD *t
-     group_trp= get_best_group_min_max(&param, tree);
-     if (group_trp)
-     {
--      param.table->quick_condition_rows= min(group_trp->records,
-+      param.table->quick_condition_rows= mysql_min(group_trp->records,
-                                              head->file->stats.records);
-       if (group_trp->read_cost < best_read_time)
-       {
-@@ -3737,7 +3737,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick
-     {
-       imerge_trp->read_cost= imerge_cost;
-       imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
--      imerge_trp->records= min(imerge_trp->records,
-+      imerge_trp->records= mysql_min(imerge_trp->records,
-                                param->table->file->stats.records);
-       imerge_trp->range_scans= range_scans;
-       imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7201,7 +7201,7 @@ check_quick_select(PARAM *param,uint idx
-       param->table->quick_key_parts[key]=param->max_key_part+1;
-       param->table->quick_n_ranges[key]= param->n_ranges;
-       param->table->quick_condition_rows=
--        min(param->table->quick_condition_rows, records);
-+        mysql_min(param->table->quick_condition_rows, records);
-     }
-     /*
-       Need to save quick_rows in any case as it is used when calculating
-@@ -7270,7 +7270,7 @@ check_quick_keys(PARAM *param, uint idx,
-   uchar *tmp_min_key, *tmp_max_key;
-   uint8 save_first_null_comp= param->first_null_comp;
- 
--  param->max_key_part=max(param->max_key_part,key_tree->part);
-+  param->max_key_part=mysql_max(param->max_key_part,key_tree->part);
-   if (key_tree->left != &null_element)
-   {
-     /*
-@@ -8170,13 +8170,13 @@ int QUICK_RANGE_SELECT::reset()
-   /* Do not allocate the buffers twice. */
-   if (multi_range_length)
-   {
--    DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+    DBUG_ASSERT(multi_range_length == mysql_min(multi_range_count, ranges.elements));
-     DBUG_RETURN(0);
-   }
- 
-   /* Allocate the ranges array. */
-   DBUG_ASSERT(ranges.elements);
--  multi_range_length= min(multi_range_count, ranges.elements);
-+  multi_range_length= mysql_min(multi_range_count, ranges.elements);
-   DBUG_ASSERT(multi_range_length > 0);
-   while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
-                                   my_malloc(multi_range_length *
-@@ -8195,7 +8195,7 @@ int QUICK_RANGE_SELECT::reset()
-   /* Allocate the handler buffer if necessary.  */
-   if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
-   {
--    mrange_bufsiz= min(multi_range_bufsiz,
-+    mrange_bufsiz= mysql_min(multi_range_bufsiz,
-                        (QUICK_SELECT_I::records + 1)* head->s->reclength);
- 
-     while (mrange_bufsiz &&
-@@ -8278,7 +8278,7 @@ int QUICK_RANGE_SELECT::get_next()
-         goto end;
-     }
- 
--    uint count= min(multi_range_length, ranges.elements -
-+    uint count= mysql_min(multi_range_length, ranges.elements -
-                     (cur_range - (QUICK_RANGE**) ranges.buffer));
-     if (count == 0)
-     {
-@@ -8391,13 +8391,13 @@ int QUICK_RANGE_SELECT::get_next_prefix(
-     last_range= *(cur_range++);
- 
-     start_key.key=    (const uchar*) last_range->min_key;
--    start_key.length= min(last_range->min_length, prefix_length);
-+    start_key.length= mysql_min(last_range->min_length, prefix_length);
-     start_key.keypart_map= last_range->min_keypart_map & keypart_map;
-     start_key.flag=   ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- 		       (last_range->flag & EQ_RANGE) ?
- 		       HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
-     end_key.key=      (const uchar*) last_range->max_key;
--    end_key.length=   min(last_range->max_length, prefix_length);
-+    end_key.length=   mysql_min(last_range->max_length, prefix_length);
-     end_key.keypart_map= last_range->max_keypart_map & keypart_map;
-     /*
-       We use READ_AFTER_KEY here because if we are reading on a key
-@@ -8695,7 +8695,7 @@ bool QUICK_SELECT_DESC::test_if_null_ran
-   KEY_PART *key_part = key_parts,
-            *key_part_end= key_part+used_key_parts;
- 
--  for (offset= 0,  end = min(range_arg->min_length, range_arg->max_length) ;
-+  for (offset= 0,  end = mysql_min(range_arg->min_length, range_arg->max_length) ;
-        offset < end && key_part != key_part_end ;
-        offset+= key_part++->store_length)
-   {
-@@ -9041,7 +9041,7 @@ cost_group_min_max(TABLE* table, KEY *in
- 
-   TODO
-   - What happens if the query groups by the MIN/MAX field, and there is no
--    other field as in: "select min(a) from t1 group by a" ?
-+    other field as in: "select mysql_min(a) from t1 group by a" ?
-   - We assume that the general correctness of the GROUP-BY query was checked
-     before this point. Is this correct, or do we have to check it completely?
-   - Lift the limitation in condition (B3), that is, make this access method 
-@@ -9262,7 +9262,7 @@ get_best_group_min_max(PARAM *param, SEL
-         cur_group_prefix_len+= cur_part->store_length;
-         cur_used_key_parts.set_bit(key_part_nr);
-         ++cur_group_key_parts;
--        max_key_part= max(max_key_part,key_part_nr);
-+        max_key_part= mysql_max(max_key_part,key_part_nr);
-       }
-       /*
-         Check that used key parts forms a prefix of the index.
-@@ -9869,9 +9869,9 @@ void cost_group_min_max(TABLE* table, KE
-     {
-       double blocks_per_group= (double) num_blocks / (double) num_groups;
-       p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
--      p_overlap= min(p_overlap, 1.0);
-+      p_overlap= mysql_min(p_overlap, 1.0);
-     }
--    io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+    io_cost= (double) mysql_min(num_groups * (1 + p_overlap), num_blocks);
-   }
-   else
-     io_cost= (keys_per_group > keys_per_block) ?
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/protocol.cc mysql-dfsg-5.1-5.1.22rc/sql/protocol.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/protocol.cc	2007-09-24 12:29:59.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/protocol.cc	2007-10-02 23:35:54.000000000 +0200
-@@ -190,7 +190,7 @@ net_printf_error(THD *thd, uint errcode,
-   length=sizeof(text_pos)-1;
- #endif
-   length=my_vsnprintf(my_const_cast(char*) (text_pos),
--                      min(length, sizeof(net->last_error)),
-+                      mysql_min(length, sizeof(net->last_error)),
-                       format,args);
-   va_end(args);
- 
-@@ -296,7 +296,7 @@ send_ok(THD *thd, ha_rows affected_rows,
-     pos+=2;
- 
-     /* We can only return up to 65535 warnings in two bytes */
--    uint tmp= min(thd->total_warn_count, 65535);
-+    uint tmp= mysql_min(thd->total_warn_count, 65535);
-     int2store(pos, tmp);
-     pos+= 2;
-   }
-@@ -371,7 +371,7 @@ static void write_eof_packet(THD *thd, N
-       Don't send warn count during SP execution, as the warn_list
-       is cleared between substatements, and mysqltest gets confused
-     */
--    uint tmp= (thd->spcont ? 0 : min(thd->total_warn_count, 65535));
-+    uint tmp= (thd->spcont ? 0 : mysql_min(thd->total_warn_count, 65535));
-     buff[0]= 254;
-     int2store(buff+1, tmp);
-     /*
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/rpl_record.cc mysql-dfsg-5.1-5.1.22rc/sql/rpl_record.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/rpl_record.cc	2007-09-24 12:30:12.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/rpl_record.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -264,7 +264,7 @@ unpack_row(RELAY_LOG_INFO const *rli,
-   /*
-     throw away master's extra fields
-   */
--  uint max_cols= min(tabledef->size(), cols->n_bits);
-+  uint max_cols= mysql_min(tabledef->size(), cols->n_bits);
-   for (; i < max_cols; i++)
-   {
-     if (bitmap_is_set(cols, i))
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/rpl_rli.cc mysql-dfsg-5.1-5.1.22rc/sql/rpl_rli.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/rpl_rli.cc	2007-09-24 12:29:57.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/rpl_rli.cc	2007-10-02 23:35:52.000000000 +0200
-@@ -645,7 +645,7 @@ int st_relay_log_info::wait_for_pos(THD*
-   ulong log_name_extension;
-   char log_name_tmp[FN_REFLEN]; //make a char[] from String
- 
--  strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+  strmake(log_name_tmp, log_name->ptr(), mysql_min(log_name->length(), FN_REFLEN-1));
- 
-   char *p= fn_ext(log_name_tmp);
-   char *p_end;
-@@ -655,7 +655,7 @@ int st_relay_log_info::wait_for_pos(THD*
-     goto err;
-   }
-   // Convert 0-3 to 4
--  log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+  log_pos= mysql_max(log_pos, BIN_LOG_HEADER_SIZE);
-   /* p points to '.' */
-   log_name_extension= strtoul(++p, &p_end, 10);
-   /*
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/rpl_utility.cc mysql-dfsg-5.1-5.1.22rc/sql/rpl_utility.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/rpl_utility.cc	2007-09-24 12:30:25.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/rpl_utility.cc	2007-10-02 23:35:54.000000000 +0200
-@@ -170,7 +170,7 @@ table_def::compatible_with(RELAY_LOG_INF
-   /*
-     We only check the initial columns for the tables.
-   */
--  uint const cols_to_check= min(table->s->fields, size());
-+  uint const cols_to_check= mysql_min(table->s->fields, size());
-   int error= 0;
-   RELAY_LOG_INFO const *rli= const_cast<RELAY_LOG_INFO*>(rli_arg);
- 
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/set_var.cc mysql-dfsg-5.1-5.1.22rc/sql/set_var.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/set_var.cc	2007-09-24 12:30:00.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/set_var.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -1405,7 +1405,7 @@ bool sys_var::check_set(THD *thd, set_va
- 					    &not_used));
-     if (error_len)
-     {
--      strmake(buff, error, min(sizeof(buff), error_len));
-+      strmake(buff, error, mysql_min(sizeof(buff), error_len));
-       goto err;
-     }
-   }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/slave.cc mysql-dfsg-5.1-5.1.22rc/sql/slave.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/slave.cc	2007-09-24 12:29:41.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/slave.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -1400,13 +1400,13 @@ bool show_master_info(THD* thd, MASTER_I
-         slave is 2. At SHOW SLAVE STATUS time, assume that the difference
-         between timestamp of slave and rli->last_master_timestamp is 0
-         (i.e. they are in the same second), then we get 0-(2-1)=-1 as a result.
--        This confuses users, so we don't go below 0: hence the max().
-+        This confuses users, so we don't go below 0: hence the mysql_max().
- 
-         last_master_timestamp == 0 (an "impossible" timestamp 1970) is a
-         special marker to say "consider we have caught up".
-       */
-       protocol->store((longlong)(mi->rli.last_master_timestamp ?
--                                 max(0, time_diff) : 0));
-+                                 mysql_max(0, time_diff) : 0));
-     }
-     else
-     {
-@@ -1937,7 +1937,7 @@ static int exec_relay_log_event(THD* thd
-             exec_res= 0;
-             end_trans(thd, ROLLBACK);
-             /* chance for concurrent connection to get more locks */
--            safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+            safe_sleep(thd, mysql_min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-                        (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
-             pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
-             rli->trans_retries++;
-@@ -3444,7 +3444,7 @@ static IO_CACHE *reopen_relay_log(RELAY_
-     relay_log_pos       Current log pos
-     pending             Number of bytes already processed from the event
-   */
--  rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+  rli->event_relay_log_pos= mysql_max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-   my_b_seek(cur_log,rli->event_relay_log_pos);
-   DBUG_RETURN(cur_log);
- }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/spatial.h mysql-dfsg-5.1-5.1.22rc/sql/spatial.h
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/spatial.h	2007-09-24 12:30:00.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/spatial.h	2007-10-02 23:35:53.000000000 +0200
-@@ -180,8 +180,8 @@ struct MBR
-     if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
-       return 0;
- 
--    MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
--                     min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+    MBR intersection(mysql_max(xmin, mbr->xmin), mysql_max(ymin, mbr->ymin),
-+                     mysql_min(xmax, mbr->xmax), mysql_min(ymax, mbr->ymax));
- 
-     return (d == intersection.dimension());
-   }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sp_head.cc mysql-dfsg-5.1-5.1.22rc/sql/sp_head.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sp_head.cc	2007-09-24 12:29:42.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sp_head.cc	2007-10-02 23:35:54.000000000 +0200
-@@ -2276,7 +2276,7 @@ sp_head::show_create_routine(THD *thd, i
- 
-     Item_empty_string *stmt_fld=
-       new Item_empty_string(col3_caption,
--                            max(m_defstr.length, 1024));
-+                            mysql_max(m_defstr.length, 1024));
- 
-     stmt_fld->maybe_null= TRUE;
- 
-@@ -2478,7 +2478,7 @@ sp_head::show_routine_code(THD *thd)
-   field_list.push_back(new Item_uint("Pos", 9));
-   // 1024 is for not to confuse old clients
-   field_list.push_back(new Item_empty_string("Instruction",
--					     max(buffer.length(), 1024)));
-+					     mysql_max(buffer.length(), 1024)));
-   if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
-                                          Protocol::SEND_EOF))
-     DBUG_RETURN(1);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_acl.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_acl.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_acl.cc	2007-09-24 12:29:59.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_acl.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -808,7 +808,7 @@ static ulong get_sort(uint count,...)
-         chars= 128;                             // Marker that chars existed
-       }
-     }
--    sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+    sort= (sort << 8) + (wild_pos ? mysql_min(wild_pos, 127) : chars);
-   }
-   va_end(args);
-   return sort;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_analyse.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_analyse.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_analyse.cc	2007-09-24 12:30:01.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_analyse.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -280,16 +280,16 @@ bool get_ev_num_info(EV_NUM_INFO *ev_inf
-   {
-     if (((longlong) info->ullval) < 0)
-       return 0; // Impossible to store as a negative number
--    ev_info->llval =  -(longlong) max((ulonglong) -ev_info->llval, 
-+    ev_info->llval =  -(longlong) mysql_max((ulonglong) -ev_info->llval, 
- 				      info->ullval);
--    ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+    ev_info->min_dval = (double) -mysql_max(-ev_info->min_dval, info->dval);
-   }
-   else		// ulonglong is as big as bigint in MySQL
-   {
-     if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
-       return 0;
--    ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
--    ev_info->max_dval =  (double) max(ev_info->max_dval, info->dval);
-+    ev_info->ullval = (ulonglong) mysql_max(ev_info->ullval, info->ullval);
-+    ev_info->max_dval =  (double) mysql_max(ev_info->max_dval, info->dval);
-   }
-   return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@ String *field_decimal::avg(String *s, ha
-   my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
-   /* TODO remove this after decimal_div returns proper frac */
-   my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
--                   min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+                   mysql_min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-                    FALSE,&rounded_avg);
-   my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
-   return s;
-@@ -1068,7 +1068,7 @@ String *field_decimal::std(String *s, ha
-   my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
-   my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
-   s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
--         min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+         mysql_min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
- 
-   return s;
- }
-@@ -1185,7 +1185,7 @@ bool analyse::change_columns(List<Item> 
-   func_items[8] = new Item_proc_string("Std", 255);
-   func_items[8]->maybe_null = 1;
-   func_items[9] = new Item_proc_string("Optimal_fieldtype",
--				       max(64, output_str_length));
-+				       mysql_max(64, output_str_length));
- 
-   for (uint i = 0; i < array_elements(func_items); i++)
-     field_list.push_back(func_items[i]);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_cache.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_cache.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_cache.cc	2007-09-24 12:30:14.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_cache.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -802,7 +802,7 @@ void query_cache_end_of_result(THD *thd)
- 
-     last_result_block= header->result()->prev;
-     allign_size= ALIGN_SIZE(last_result_block->used);
--    len= max(query_cache.min_allocation_unit, allign_size);
-+    len= mysql_max(query_cache.min_allocation_unit, allign_size);
-     if (last_result_block->length >= query_cache.min_allocation_unit + len)
-       query_cache.split_block(last_result_block,len);
- 
-@@ -2177,7 +2177,7 @@ Query_cache::write_block_data(ulong data
-   DBUG_ENTER("Query_cache::write_block_data");
-   DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- 		      data_len, header_len, all_headers_len));
--  Query_cache_block *block= allocate_block(max(align_len,
-+  Query_cache_block *block= allocate_block(mysql_max(align_len,
-                                            min_allocation_unit),1, 0);
-   if (block != 0)
-   {
-@@ -2240,7 +2240,7 @@ Query_cache::append_result_data(Query_ca
-   ulong append_min = get_min_append_result_data_size();
-   if (last_block_free_space < data_len &&
-       append_next_free_block(last_block,
--			     max(tail, append_min)))
-+			     mysql_max(tail, append_min)))
-     last_block_free_space = last_block->length - last_block->used;
-   // If no space in last block (even after join) allocate new block
-   if (last_block_free_space < data_len)
-@@ -2272,7 +2272,7 @@ Query_cache::append_result_data(Query_ca
-   // Now finally write data to the last block
-   if (success && last_block_free_space > 0)
-   {
--    ulong to_copy = min(data_len,last_block_free_space);
-+    ulong to_copy = mysql_min(data_len,last_block_free_space);
-     DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- 			last_block_free_space, (ulong)last_block, to_copy));
-     memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2360,8 +2360,8 @@ inline ulong Query_cache::get_min_first_
-   if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
-     return min_result_data_size;
-   ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
--  avg_result = min(avg_result, query_cache_limit);
--  return max(min_result_data_size, avg_result);
-+  avg_result = mysql_min(avg_result, query_cache_limit);
-+  return mysql_max(min_result_data_size, avg_result);
- }
- 
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2393,7 +2393,7 @@ my_bool Query_cache::allocate_data_chain
-     ulong len= data_len + all_headers_len;
-     ulong align_len= ALIGN_SIZE(len);
- 
--    if (!(new_block= allocate_block(max(min_size, align_len),
-+    if (!(new_block= allocate_block(mysql_max(min_size, align_len),
- 				    min_result_data_size == 0,
- 				    all_headers_len + min_result_data_size)))
-     {
-@@ -2402,7 +2402,7 @@ my_bool Query_cache::allocate_data_chain
-     }
- 
-     new_block->n_tables = 0;
--    new_block->used = min(len, new_block->length);
-+    new_block->used = mysql_min(len, new_block->length);
-     new_block->type = Query_cache_block::RES_INCOMPLETE;
-     new_block->next = new_block->prev = new_block;
-     Query_cache_result *header = new_block->result();
-@@ -2838,7 +2838,7 @@ Query_cache::allocate_block(ulong len, m
-   DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
-              len, not_less,min));
- 
--  if (len >= min(query_cache_size, query_cache_limit))
-+  if (len >= mysql_min(query_cache_size, query_cache_limit))
-   {
-     DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- 			query_cache_size, query_cache_limit));
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_class.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_class.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_class.cc	2007-09-24 12:30:24.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_class.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -342,7 +342,7 @@ char *thd_security_context(THD *thd, cha
-     if (max_query_len < 1)
-       len= thd->query_length;
-     else
--      len= min(thd->query_length, max_query_len);
-+      len= mysql_min(thd->query_length, max_query_len);
-     str.append('\n');
-     str.append(thd->query, len);
-   }
-@@ -1625,7 +1625,7 @@ bool select_export::send_data(List<Item>
-     else
-     {
-       if (fixed_row_size)
--	used_length=min(res->length(),item->max_length);
-+	used_length=mysql_min(res->length(),item->max_length);
-       else
- 	used_length=res->length();
-       if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_client.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_client.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_client.cc	2007-09-24 12:29:32.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_client.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -34,7 +34,7 @@ void my_net_local_init(NET *net)
-                            (uint)global_system_variables.net_write_timeout);
- 
-   net->retry_count=  (uint) global_system_variables.net_retry_count;
--  net->max_packet_size= max(global_system_variables.net_buffer_length,
-+  net->max_packet_size= mysql_max(global_system_variables.net_buffer_length,
- 			    global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_connect.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_connect.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_connect.cc	2007-09-24 12:29:32.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_connect.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -680,7 +680,7 @@ static int check_connection(THD *thd)
-       if (thd->main_security_ctx.host)
-       {
-         if (thd->main_security_ctx.host != my_localhost)
--          thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+          thd->main_security_ctx.host[mysql_min(strlen(thd->main_security_ctx.host),
-                                           HOSTNAME_LENGTH)]= 0;
-         thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
-       }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_load.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_load.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_load.cc	2007-09-24 12:30:12.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_load.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -907,7 +907,7 @@ READ_INFO::READ_INFO(File file_par, uint
- 
- 
-   /* Set of a stack for unget if long terminators */
--  uint length=max(field_term_length,line_term_length)+1;
-+  uint length=mysql_max(field_term_length,line_term_length)+1;
-   set_if_bigger(length,line_start.length());
-   stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
- 
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_parse.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_parse.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_parse.cc	2007-09-24 12:30:14.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_parse.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -5119,7 +5119,7 @@ bool check_stack_overrun(THD *thd, long 
-     return 1;
-   }
- #ifndef DBUG_OFF
--  max_stack_used= max(max_stack_used, stack_used);
-+  max_stack_used= mysql_max(max_stack_used, stack_used);
- #endif
-   return 0;
- }
-@@ -6554,7 +6554,7 @@ bool check_simple_select()
-     char command[80];
-     Lex_input_stream *lip= thd->m_lip;
-     strmake(command, lip->yylval->symbol.str,
--	    min(lip->yylval->symbol.length, sizeof(command)-1));
-+	    mysql_min(lip->yylval->symbol.length, sizeof(command)-1));
-     my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
-     return 1;
-   }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_partition.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_partition.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_partition.cc	2007-09-24 12:30:14.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_partition.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -4429,7 +4429,7 @@ that are reorganised.
-             */
-             start_part= 0;
-             end_part= new_total_partitions - (upper_2n + 1);
--            end_part= max(lower_2n - 1, end_part);
-+            end_part= mysql_max(lower_2n - 1, end_part);
-           }
-           else if (new_total_partitions <= upper_2n)
-           {
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_plugin.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_plugin.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_plugin.cc	2007-09-24 12:30:01.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_plugin.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -471,7 +471,7 @@ static st_plugin_dl *plugin_dl_add(const
-     for (i=0;
-          (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
-          i++)
--      memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+      memcpy(cur+i, old, mysql_min(sizeof(cur[i]), sizeof_st_plugin));
- 
-     sym= cur;
-   }
-@@ -1995,7 +1995,7 @@ static int check_func_set(THD *thd, stru
-                      &error, &error_len, &not_used);
-     if (error_len)
-     {
--      strmake(buff, error, min(sizeof(buff), error_len));
-+      strmake(buff, error, mysql_min(sizeof(buff), error_len));
-       strvalue= buff;
-       goto err;
-     }
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_prepare.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_prepare.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_prepare.cc	2007-09-24 12:30:25.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_prepare.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -238,7 +238,7 @@ static bool send_prep_stmt(Prepared_stat
-   int2store(buff+5, columns);
-   int2store(buff+7, stmt->param_count);
-   buff[9]= 0;                                   // Guard against a 4.1 client
--  tmp= min(stmt->thd->total_warn_count, 65535);
-+  tmp= mysql_min(stmt->thd->total_warn_count, 65535);
-   int2store(buff+10, tmp);
- 
-   /*
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_repl.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_repl.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_repl.cc	2007-09-24 12:29:58.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_repl.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -1191,12 +1191,12 @@ bool change_master(THD* thd, MASTER_INFO
-    {
-      /*
-        Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
--       not initialized), so we use a max().
-+       not initialized), so we use a mysql_max().
-        What happens to mi->rli.master_log_pos during the initialization stages
-        of replication is not 100% clear, so we guard against problems using
--       max().
-+       mysql_max().
-       */
--     mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+     mi->master_log_pos = mysql_max(BIN_LOG_HEADER_SIZE,
- 			      mi->rli.group_master_log_pos);
-      strmake(mi->master_log_name, mi->rli.group_master_log_name,
-              sizeof(mi->master_log_name)-1);
-@@ -1341,7 +1341,7 @@ bool mysql_show_binlog_events(THD* thd)
-     LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
-     SELECT_LEX_UNIT *unit= &thd->lex->unit;
-     ha_rows event_count, limit_start, limit_end;
--    my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+    my_off_t pos = mysql_max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-     char search_file_name[FN_REFLEN], *name;
-     const char *log_file_name = lex_mi->log_file_name;
-     pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_select.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_select.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_select.cc	2007-09-24 12:29:33.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_select.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -842,7 +842,7 @@ JOIN::optimize()
-   }
- #endif
- 
--  /* Optimize count(*), min() and max() */
-+  /* Optimize count(*), mysql_min() and mysql_max() */
-   if (tables_list && tmp_table_param.sum_func_count && ! group_list)
-   {
-     int res;
-@@ -2696,7 +2696,7 @@ make_join_statistics(JOIN *join, TABLE_L
-       This is can't be to high as otherwise we are likely to use
-       table scan.
-     */
--    s->worst_seeks= min((double) s->found_records / 10,
-+    s->worst_seeks= mysql_min((double) s->found_records / 10,
- 			(double) s->read_time*3);
-     if (s->worst_seeks < 2.0)			// Fix for small tables
-       s->worst_seeks=2.0;
-@@ -3562,7 +3562,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
-   uint	and_level,i,found_eq_constant;
-   KEY_FIELD *key_fields, *end, *field;
-   uint sz;
--  uint m= max(select_lex->max_equal_elems,1);
-+  uint m= mysql_max(select_lex->max_equal_elems,1);
-   
-   /* 
-     We use the same piece of memory to store both  KEY_FIELD 
-@@ -3585,7 +3585,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
-     can be not more than select_lex->max_equal_elems such 
-     substitutions.
-   */ 
--  sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+  sz= mysql_max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-       (((thd->lex->current_select->cond_count+1)*2 +
- 	thd->lex->current_select->between_count)*m+1);
-   if (!(key_fields=(KEY_FIELD*)	thd->alloc(sz)))
-@@ -3738,7 +3738,7 @@ static void optimize_keyuse(JOIN *join, 
-       if (map == 1)			// Only one table
-       {
- 	TABLE *tmp_table=join->all_tables[tablenr];
--	keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+	keyuse->ref_table_rows= mysql_max(tmp_table->file->stats.records, 100);
-       }
-     }
-     /*
-@@ -4063,7 +4063,7 @@ best_access_path(JOIN      *join,
-               tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
-             }
-             else
--              tmp= record_count*min(tmp,s->worst_seeks);
-+              tmp= record_count*mysql_min(tmp,s->worst_seeks);
-           }
-         }
-         else
-@@ -4230,7 +4230,7 @@ best_access_path(JOIN      *join,
-               tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
-             }
-             else
--              tmp= record_count*min(tmp,s->worst_seeks);
-+              tmp= record_count*mysql_min(tmp,s->worst_seeks);
-           }
-           else
-             tmp= best_time;                    // Do nothing
-@@ -5133,7 +5133,7 @@ static void calc_used_field_length(THD *
-   {
-     uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- 			     (join_tab->table->s->reclength- rec_length));
--    rec_length+=(uint) max(4,blob_length);
-+    rec_length+=(uint) mysql_max(4,blob_length);
-   }
-   join_tab->used_fields=fields;
-   join_tab->used_fieldlength=rec_length;
-@@ -6500,7 +6500,7 @@ void JOIN_TAB::cleanup()
-         a correlated subquery itself, but has subqueries, we can free it
-         fully and also free JOINs of all its subqueries. The exception
-         is a subquery in SELECT list, e.g:
--        SELECT a, (select max(b) from t1) group by c
-+        SELECT a, (select mysql_max(b) from t1) group by c
-         This subquery will not be evaluated at first sweep and its value will
-         not be inserted into the temporary table. Instead, it's evaluated
-         when selecting from the temporary table. Therefore, it can't be freed
-@@ -9877,7 +9877,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
-     share->max_rows= ~(ha_rows) 0;
-   else
-     share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
--                                 min(thd->variables.tmp_table_size,
-+                                 mysql_min(thd->variables.tmp_table_size,
-                                      thd->variables.max_heap_table_size) :
-                                  thd->variables.tmp_table_size) /
- 			         share->reclength);
-@@ -13283,7 +13283,7 @@ SORT_FIELD *make_unireg_sortorder(ORDER 
-     count++;
-   if (!sortorder)
-     sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
--                                       (max(count, *length) + 1));
-+                                       (mysql_max(count, *length) + 1));
-   pos= sort= sortorder;
- 
-   if (!pos)
-@@ -13401,7 +13401,7 @@ join_init_cache(THD *thd,JOIN_TAB *table
-   cache->length=length+blobs*sizeof(char*);
-   cache->blobs=blobs;
-   *blob_ptr=0;					/* End sequentel */
--  size=max(thd->variables.join_buff_size, cache->length);
-+  size=mysql_max(thd->variables.join_buff_size, cache->length);
-   if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
-     DBUG_RETURN(1);				/* Don't use cache */ /* purecov: inspected */
-   cache->end=cache->buff+size;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_show.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_show.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_show.cc	2007-09-24 12:29:57.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_show.cc	2007-10-02 23:35:52.000000000 +0200
-@@ -617,7 +617,7 @@ mysqld_show_create(THD *thd, TABLE_LIST 
-   {
-     field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
-     field_list.push_back(new Item_empty_string("Create View",
--                                               max(buffer.length(),1024)));
-+                                               mysql_max(buffer.length(),1024)));
-     field_list.push_back(new Item_empty_string("character_set_client",
-                                                MY_CS_NAME_SIZE));
-     field_list.push_back(new Item_empty_string("collation_connection",
-@@ -628,7 +628,7 @@ mysqld_show_create(THD *thd, TABLE_LIST 
-     field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
-     // 1024 is for not to confuse old clients
-     field_list.push_back(new Item_empty_string("Create Table",
--                                               max(buffer.length(),1024)));
-+                                               mysql_max(buffer.length(),1024)));
-   }
- 
-   if (protocol->send_fields(&field_list,
-@@ -1686,7 +1686,7 @@ void mysqld_list_processes(THD *thd,cons
- 	    the comment in sql_class.h why this prevents crashes in possible
-             races with query_length
-           */
--          uint length= min(max_query_length, tmp->query_length);
-+          uint length= mysql_min(max_query_length, tmp->query_length);
-           thd_info->query=(char*) thd->strmake(tmp->query,length);
-         }
-         thread_infos.append(thd_info);
-@@ -1814,7 +1814,7 @@ int fill_schema_processlist(THD* thd, TA
-       if (tmp->query)
-       {
-         table->field[7]->store(tmp->query,
--                               min(PROCESS_LIST_INFO_WIDTH,
-+                               mysql_min(PROCESS_LIST_INFO_WIDTH,
-                                    tmp->query_length), cs);
-         table->field[7]->set_notnull();
-       }
-@@ -6662,7 +6662,7 @@ static bool show_create_trigger_impl(THD
- 
-     Item_empty_string *stmt_fld=
-       new Item_empty_string("SQL Original Statement",
--                            max(trg_sql_original_stmt.length, 1024));
-+                            mysql_max(trg_sql_original_stmt.length, 1024));
- 
-     stmt_fld->maybe_null= TRUE;
- 
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_string.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_string.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_string.cc	2007-09-24 12:29:40.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_string.cc	2007-10-02 23:35:52.000000000 +0200
-@@ -654,7 +654,7 @@ int String::reserve(uint32 space_needed,
- {
-   if (Alloced_length < str_length + space_needed)
-   {
--    if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+    if (realloc(Alloced_length + mysql_max(space_needed, grow_by) - 1))
-       return TRUE;
-   }
-   return FALSE;
-@@ -740,7 +740,7 @@ int sortcmp(const String *s,const String
- 
- int stringcmp(const String *s,const String *t)
- {
--  uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+  uint32 s_len=s->length(),t_len=t->length(),len=mysql_min(s_len,t_len);
-   int cmp= memcmp(s->ptr(), t->ptr(), len);
-   return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -757,7 +757,7 @@ String *copy_if_not_alloced(String *to,S
-   }
-   if (to->realloc(from_length))
-     return from;				// Actually an error
--  if ((to->str_length=min(from->str_length,from_length)))
-+  if ((to->str_length=mysql_min(from->str_length,from_length)))
-     memcpy(to->Ptr,from->Ptr,to->str_length);
-   to->str_charset=from->str_charset;
-   return to;
-@@ -896,7 +896,7 @@ well_formed_copy_nchars(CHARSET_INFO *to
- 
-     if (to_cs == &my_charset_bin)
-     {
--      res= min(min(nchars, to_length), from_length);
-+      res= mysql_min(mysql_min(nchars, to_length), from_length);
-       memmove(to, from, res);
-       *from_end_pos= from + res;
-       *well_formed_error_pos= NULL;
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_table.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_table.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_table.cc	2007-09-24 12:29:59.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_table.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -2794,7 +2794,7 @@ mysql_prepare_create_table(THD *thd, HA_
- 	  if ((length=column->length) > max_key_length ||
- 	      length > file->max_key_part_length())
- 	  {
--	    length=min(max_key_length, file->max_key_part_length());
-+	    length=mysql_min(max_key_length, file->max_key_part_length());
- 	    if (key->type == Key::MULTIPLE)
- 	    {
- 	      /* not a critical problem */
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_yacc.cc mysql-dfsg-5.1-5.1.22rc/sql/sql_yacc.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_yacc.cc	2007-09-24 13:08:02.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_yacc.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -14925,7 +14925,7 @@ yyreduce:
-               from 0" (4 in fact), unspecified means "don't change the position
-               (keep the preceding value)").
-            */
--           Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+           Lex->mi.pos = mysql_max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-          }
-     break;
- 
-@@ -14941,7 +14941,7 @@ yyreduce:
-     {
-            Lex->mi.relay_log_pos = (yyvsp[0].ulong_num);
-            /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
--           Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+           Lex->mi.relay_log_pos = mysql_max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-          }
-     break;
- 
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_yacc.yy mysql-dfsg-5.1-5.1.22rc/sql/sql_yacc.yy
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/sql_yacc.yy	2007-09-24 12:30:00.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/sql_yacc.yy	2007-10-02 23:35:53.000000000 +0200
-@@ -1546,7 +1546,7 @@ master_file_def:
-               from 0" (4 in fact), unspecified means "don't change the position
-               (keep the preceding value)").
-            */
--           Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+           Lex->mi.pos = mysql_max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-          }
-        | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
-          {
-@@ -1556,7 +1556,7 @@ master_file_def:
-          {
-            Lex->mi.relay_log_pos = $3;
-            /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
--           Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+           Lex->mi.relay_log_pos = mysql_max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-          }
-        ;
- 
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/stacktrace.c mysql-dfsg-5.1-5.1.22rc/sql/stacktrace.c
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/stacktrace.c	2007-09-24 12:29:59.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/stacktrace.c	2007-10-02 23:35:54.000000000 +0200
-@@ -131,7 +131,7 @@ terribly wrong...\n");
- 
-   if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
-   {
--    ulong tmp= min(0x10000,thread_stack);
-+    ulong tmp= mysql_min(0x10000,thread_stack);
-     /* Assume that the stack starts at the previous even 65K */
-     stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- 			  ~(ulong) 0xFFFF);
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/thr_malloc.cc mysql-dfsg-5.1-5.1.22rc/sql/thr_malloc.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/thr_malloc.cc	2007-09-24 12:29:33.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/thr_malloc.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -102,7 +102,7 @@ char *sql_strmake_with_convert(const cha
-   if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
-   {
-     // Safety if to_cs->mbmaxlen > 0
--    new_length= min(arg_length, max_res_length);
-+    new_length= mysql_min(arg_length, max_res_length);
-     memcpy(pos, str, new_length);
-   }
-   else
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/tztime.cc mysql-dfsg-5.1-5.1.22rc/sql/tztime.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/tztime.cc	2007-09-24 12:30:26.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/tztime.cc	2007-10-02 23:35:54.000000000 +0200
-@@ -167,7 +167,7 @@ tz_load(const char *name, TIME_ZONE_INFO
-       uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
-                 TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
--               max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+               mysql_max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
-                sizeof(LS_INFO) * TZ_MAX_LEAPS];
-     } u;
-@@ -396,7 +396,7 @@ prepare_tz_info(TIME_ZONE_INFO *sp, MEM_
-       Let us choose end_t as point before next time type change or leap
-       second correction.
-     */
--    end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+    end_t= mysql_min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-                                                 MY_TIME_T_MAX,
-                (next_leap_idx < sp->leapcnt) ?
-                  sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1819,7 +1819,7 @@ tz_load_from_open_tables(const String *t
-   uchar types[TZ_MAX_TIMES];
-   TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
--  char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+  char chars[mysql_max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
-   DBUG_ENTER("tz_load_from_open_tables");
- 
-diff -Nurp mysql-dfsg-5.1-5.1.22rc.orig/sql/unireg.cc mysql-dfsg-5.1-5.1.22rc/sql/unireg.cc
---- mysql-dfsg-5.1-5.1.22rc.orig/sql/unireg.cc	2007-09-24 12:29:59.000000000 +0200
-+++ mysql-dfsg-5.1-5.1.22rc/sql/unireg.cc	2007-10-02 23:35:53.000000000 +0200
-@@ -435,7 +435,7 @@ static uchar *pack_screens(List<Create_f
-     }
-     cfield->row=(uint8) row;
-     cfield->col=(uint8) (length+1);
--    cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+    cfield->sc_length=(uint8) mysql_min(cfield->length,cols-(length+2));
-   }
-   length=(uint) (pos-start_screen);
-   int2store(start_screen,length);
-@@ -655,7 +655,7 @@ static bool pack_header(uchar *forminfo,
-     DBUG_RETURN(1);
-   }
-   /* Hack to avoid bugs with small static rows in MySQL */
--  reclength=max(file->min_record_length(table_options),reclength);
-+  reclength=mysql_max(file->min_record_length(table_options),reclength);
-   if (info_length+(ulong) create_fields.elements*FCOMP+288+
-       n_length+int_length+com_length > 65535L || int_count > 255)
-   {




More information about the Pkg-mysql-commits mailing list