#At file:///home/bzr/mkindahl/w5223-trunk/ based on revid:alexander.nozdrin@stripped
3364 Mats Kindahl 2011-05-12
WL#5825: Using C++ Standard Library with MySQL code
This patch will make it possible to use the C++
Standard Library by removing the min/max macros
from the code.
The patch makes the following changes:
- Define macros MY_MIN and MY_MAX instead of min and max.
- Use MY_MIN/MY_MAX in C code
- Use MY_MIN/MY_MAX in array declarations
- Include <algorithm> to get min/max from std
- Add using-declarations in source files
- Use std:: prefix for min/max in header files
- Turning some constant declarations unsigned
- Removing an overloaded use of 'min' as both
macro name and variable.
@ sql/sql_cache.cc
Renaming parameter 'min' to 'minimum' in
Query_cache::allocate_block to avoid clash
with function 'min'.
modified:
client/mysql.cc
client/mysql_upgrade.c
client/mysqlbinlog.cc
client/mysqldump.c
client/mysqltest.cc
client/sql_string.cc
config.h.cmake
dbug/dbug.c
include/m_string.h
include/my_global.h
libmysql/libmysql.c
libmysqld/lib_sql.cc
mysys/array.c
mysys/default.c
mysys/lf_alloc-pin.c
mysys/lf_dynarray.c
mysys/mf_format.c
mysys/mf_iocache.c
mysys/my_alloc.c
mysys/my_bitmap.c
mysys/my_compare.c
mysys/my_compress.c
mysys/my_file.c
mysys/stacktrace.c
sql-common/client.c
sql-common/my_time.c
sql/binlog.cc
sql/debug_sync.cc
sql/field.cc
sql/filesort.cc
sql/ha_partition.cc
sql/handler.cc
sql/handler.h
sql/item.cc
sql/item_buff.cc
sql/item_cmpfunc.cc
sql/item_func.cc
sql/item_func.h
sql/item_strfunc.cc
sql/item_strfunc.h
sql/item_sum.cc
sql/item_timefunc.cc
sql/item_timefunc.h
sql/key.cc
sql/log.cc
sql/log_event.cc
sql/log_event.h
sql/log_event_old.cc
sql/mdl.h
sql/mysqld.cc
sql/net_serv.cc
sql/opt_range.cc
sql/opt_range.h
sql/protocol.cc
sql/rpl_mi.cc
sql/rpl_record.cc
sql/rpl_rli.cc
sql/rpl_slave.cc
sql/rpl_utility.cc
sql/rpl_utility.h
sql/sp_head.cc
sql/spatial.h
sql/sql_acl.cc
sql/sql_analyse.cc
sql/sql_cache.cc
sql/sql_class.cc
sql/sql_client.cc
sql/sql_connect.cc
sql/sql_const.h
sql/sql_error.cc
sql/sql_join_cache.cc
sql/sql_load.cc
sql/sql_plugin.cc
sql/sql_prepare.cc
sql/sql_profile.cc
sql/sql_select.cc
sql/sql_select.h
sql/sql_show.cc
sql/sql_string.cc
sql/sql_yacc.yy
sql/thr_malloc.cc
sql/tztime.cc
sql/unireg.cc
storage/csv/ha_tina.cc
storage/federated/ha_federated.cc
storage/heap/hp_create.c
storage/heap/hp_test2.c
storage/myisam/ha_myisam.cc
storage/myisam/mi_cache.c
storage/myisam/mi_check.c
storage/myisam/mi_create.c
storage/myisam/mi_dynrec.c
storage/myisam/mi_extra.c
storage/myisam/mi_open.c
storage/myisam/mi_packrec.c
storage/myisam/myisamlog.c
storage/myisam/myisampack.c
storage/myisam/rt_mbr.c
storage/myisam/sort.c
storage/myisammrg/ha_myisammrg.cc
strings/ctype-big5.c
strings/ctype-bin.c
strings/ctype-gbk.c
strings/ctype-mb.c
strings/ctype-simple.c
strings/ctype-tis620.c
strings/ctype-uca.c
strings/ctype-ucs2.c
strings/ctype-utf8.c
strings/ctype.c
strings/decimal.c
strings/dtoa.c
strings/my_vsnprintf.c
tests/mysql_client_test.c
vio/viosocket.c
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc 2011-03-09 20:54:55 +0000
+++ b/client/mysql.cc 2011-05-12 12:35:00 +0000
@@ -39,6 +39,11 @@
#include <signal.h>
#include <violite.h>
+#include <algorithm>
+
+using std::min;
+using std::max;
+
#if defined(USE_LIBEDIT_INTERFACE) && defined(HAVE_LOCALE_H)
#include <locale.h>
#endif
@@ -3324,9 +3329,9 @@ print_table_data(MYSQL_RES *result)
{
uint length= column_names ? field->name_length : 0;
if (quick)
- length=max(length,field->length);
+ length= max<size_t>(length, field->length);
else
- length=max(length,field->max_length);
+ length= max<size_t>(length, field->max_length);
if (length < 4 && !IS_NOT_NULL(field->flags))
length=4; // Room for "NULL"
field->max_length=length;
@@ -3346,8 +3351,8 @@ 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,
- MAX_COLUMN_LENGTH),
+ tee_fprintf(PAGER, " %-*s |",
+ min<size_t>(display_length, MAX_COLUMN_LENGTH),
field->name);
num_flag[off]= IS_NUM(field->type);
}
@@ -3436,9 +3441,9 @@ static int get_field_disp_length(MYSQL_F
uint length= column_names ? field->name_length : 0;
if (quick)
- length= max(length, field->length);
+ length= max<uint>(length, field->length);
else
- length= max(length, field->max_length);
+ length= max<uint>(length, field->max_length);
if (length < 4 && !IS_NOT_NULL(field->flags))
length= 4; /* Room for "NULL" */
=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c 2011-01-16 04:02:29 +0000
+++ b/client/mysql_upgrade.c 2011-05-12 12:35:00 +0000
@@ -546,7 +546,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, MY_MIN(FN_REFLEN, value_end - value_start));
return 0;
}
=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc 2011-03-29 13:56:27 +0000
+++ b/client/mysqlbinlog.cc 2011-05-12 12:35:00 +0000
@@ -39,7 +39,12 @@
#include "sql_common.h"
#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
-#define BIN_LOG_HEADER_SIZE 4
+#include <algorithm>
+
+using std::min;
+using std::max;
+
+#define BIN_LOG_HEADER_SIZE 4U
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
@@ -2073,7 +2078,7 @@ static Exit_status dump_local_log_entrie
my_off_t length,tmp;
for (length= start_position_mot ; length > 0 ; length-=tmp)
{
- tmp=min(length,sizeof(buff));
+ tmp= min<size_t>(length, sizeof(buff));
if (my_b_read(file, buff, (uint) tmp))
{
error("Failed reading from file.");
=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c 2011-03-17 09:47:50 +0000
+++ b/client/mysqldump.c 2011-05-12 12:35:00 +0000
@@ -845,7 +845,7 @@ get_one_option(int optid, const struct m
&err_ptr, &err_len);
if (err_len)
{
- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
+ strmake(buff, err_ptr, MY_MIN(sizeof(buff) - 1, err_len));
fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
exit(1);
}
@@ -4668,7 +4668,7 @@ static ulong find_set(TYPELIB *lib, cons
for (; pos != end && *pos != ','; pos++) ;
var_len= (uint) (pos - start);
- strmake(buff, start, min(sizeof(buff) - 1, var_len));
+ strmake(buff, start, MY_MIN(sizeof(buff) - 1, var_len));
find= find_type(buff, lib, FIND_TYPE_BASIC);
if (!find)
{
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc 2011-04-11 14:57:47 +0000
+++ b/client/mysqltest.cc 2011-05-12 12:35:00 +0000
@@ -54,6 +54,11 @@
#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
+#include <algorithm>
+
+using std::min;
+using std::max;
+
#ifdef __WIN__
#include <crtdbg.h>
#define SIGNAL_FMT "exception 0x%x"
=== modified file 'client/sql_string.cc'
--- a/client/sql_string.cc 2011-03-22 11:44:40 +0000
+++ b/client/sql_string.cc 2011-05-12 12:35:00 +0000
@@ -23,6 +23,11 @@
#include "sql_string.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
/*****************************************************************************
** String functions
*****************************************************************************/
=== modified file 'config.h.cmake'
--- a/config.h.cmake 2011-04-30 05:36:44 +0000
+++ b/config.h.cmake 2011-05-12 12:35:00 +0000
@@ -381,7 +381,7 @@
#cmakedefine HAVE_MBSTATE_T
-#define MAX_INDEXES 64
+#define MAX_INDEXES 64U
#cmakedefine QSORT_TYPE_IS_VOID 1
#cmakedefine RETQSORTTYPE @RETQSORTTYPE@
=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c 2011-03-08 19:14:42 +0000
+++ b/dbug/dbug.c 2011-05-12 12:35:00 +0000
@@ -1323,7 +1323,7 @@ void _db_dump_(uint _line_, const char *
if (TRACING)
{
Indent(cs, cs->level + 1);
- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
+ pos= MY_MIN(MY_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
}
else
{
@@ -1743,7 +1743,7 @@ static void Indent(CODE_STATE *cs, int i
{
REGISTER int count;
- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
+ indent= MY_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
for (count= 0; count < indent ; count++)
{
if ((count % INDENT) == 0)
=== modified file 'include/m_string.h'
--- a/include/m_string.h 2010-11-22 10:02:01 +0000
+++ b/include/m_string.h 2011-05-12 12:35:00 +0000
@@ -156,7 +156,7 @@ size_t my_gcvt(double x, my_gcvt_arg_typ
(DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
*/
-#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + max(5, MAX_DECPT_FOR_F_FORMAT)) \
+#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + MY_MAX(5, MAX_DECPT_FOR_F_FORMAT)) \
extern char *llstr(longlong value,char *buff);
extern char *ullstr(longlong value,char *buff);
=== modified file 'include/my_global.h'
--- a/include/my_global.h 2011-04-13 19:16:45 +0000
+++ b/include/my_global.h 2011-05-12 12:35:00 +0000
@@ -1376,10 +1376,8 @@ do { doubleget_union _tmp; \
#define MY_INT64_NUM_DECIMAL_DIGITS 21U
/* Define some useful general macros (should be done after all headers). */
-#if !defined(max)
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
+#define MY_MAX(a, b) ((a) > (b) ? (a) : (b))
+#define MY_MIN(a, b) ((a) < (b) ? (a) : (b))
/*
Only Linux is known to need an explicit sync of the directory to make sure a
=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c 2011-04-15 09:33:58 +0000
+++ b/libmysql/libmysql.c 2011-05-12 12:35:00 +0000
@@ -1104,7 +1104,7 @@ void my_net_local_init(NET *net)
my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
net->retry_count= 1;
- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
+ net->max_packet_size= MY_MAX(net_buffer_length, max_allowed_packet);
}
/*
@@ -3163,7 +3163,7 @@ static void fetch_string_with_conversion
copy_length= end - start;
/* We've got some data beyond offset: copy up to buffer_length bytes */
if (param->buffer_length)
- memcpy(buffer, start, min(copy_length, param->buffer_length));
+ memcpy(buffer, start, MY_MIN(copy_length, param->buffer_length));
}
else
copy_length= 0;
@@ -3389,7 +3389,7 @@ static void fetch_float_with_conversion(
size_t len;
if (field->decimals >= NOT_FIXED_DEC)
len= my_gcvt(value, type,
- (int) min(sizeof(buff)-1, param->buffer_length),
+ (int) MY_MIN(sizeof(buff)-1, param->buffer_length),
buff, NULL);
else
len= my_fcvt(value, (int) field->decimals, buff, NULL);
@@ -3699,7 +3699,7 @@ static void fetch_result_bin(MYSQL_BIND
uchar **row)
{
ulong length= net_field_length(row);
- ulong copy_length= min(length, param->buffer_length);
+ ulong copy_length= MY_MIN(length, param->buffer_length);
memcpy(param->buffer, (char *)*row, copy_length);
*param->length= length;
*param->error= copy_length < length;
@@ -3711,7 +3711,7 @@ static void fetch_result_str(MYSQL_BIND
uchar **row)
{
ulong length= net_field_length(row);
- ulong copy_length= min(length, param->buffer_length);
+ ulong copy_length= MY_MIN(length, param->buffer_length);
memcpy(param->buffer, (char *)*row, copy_length);
/* Add an end null if there is room in the buffer */
if (copy_length != param->buffer_length)
=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc 2011-03-09 20:54:55 +0000
+++ b/libmysqld/lib_sql.cc 2011-05-12 12:35:00 +0000
@@ -37,6 +37,11 @@ C_MODE_START
#include "errmsg.h"
#include "embedded_priv.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
extern unsigned int mysql_server_last_errno;
extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
static my_bool emb_read_query_result(MYSQL *mysql);
@@ -863,7 +868,7 @@ write_eof_packet(THD *thd, uint server_s
is cleared between substatements, and mysqltest gets confused
*/
thd->cur_data->embedded_info->warning_count=
- (thd->spcont ? 0 : min(statement_warn_count, 65535));
+ (thd->spcont ? 0 : min(statement_warn_count, 65535U));
return FALSE;
}
=== modified file 'mysys/array.c'
--- a/mysys/array.c 2010-11-05 22:14:29 +0000
+++ b/mysys/array.c 2011-05-12 12:35:00 +0000
@@ -47,7 +47,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRA
DBUG_ENTER("init_dynamic_array");
if (!alloc_increment)
{
- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
+ alloc_increment=MY_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
if (init_alloc > 8 && alloc_increment > init_alloc * 2)
alloc_increment=init_alloc*2;
}
@@ -340,7 +340,7 @@ void delete_dynamic_element(DYNAMIC_ARRA
void freeze_size(DYNAMIC_ARRAY *array)
{
- uint elements=max(array->elements,1);
+ uint elements=MY_MAX(array->elements,1);
/*
Do nothing if we are using a static buffer
=== modified file 'mysys/default.c'
--- a/mysys/default.c 2011-04-26 00:21:47 +0000
+++ b/mysys/default.c 2011-05-12 12:35:00 +0000
@@ -901,7 +901,7 @@ static int search_default_file_with_ext(
for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
end[0]=0;
- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
+ strmake(curr_gr, ptr, MY_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
/* signal that a new group is found */
opt_handler(handler_ctx, curr_gr, NULL);
=== modified file 'mysys/lf_alloc-pin.c'
--- a/mysys/lf_alloc-pin.c 2010-07-23 20:59:42 +0000
+++ b/mysys/lf_alloc-pin.c 2011-05-12 12:35:00 +0000
@@ -278,7 +278,7 @@ struct st_harvester {
static int harvest_pins(LF_PINS *el, struct st_harvester *hv)
{
int i;
- LF_PINS *el_end= el+min(hv->npins, LF_DYNARRAY_LEVEL_LENGTH);
+ LF_PINS *el_end= el + MY_MIN(hv->npins, LF_DYNARRAY_LEVEL_LENGTH);
for (; el < el_end; el++)
{
for (i= 0; i < LF_PINBOX_PINS; i++)
=== modified file 'mysys/lf_dynarray.c'
--- a/mysys/lf_dynarray.c 2010-07-08 21:20:08 +0000
+++ b/mysys/lf_dynarray.c 2011-05-12 12:35:00 +0000
@@ -124,8 +124,8 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *a
{
uchar *alloc, *data;
alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
- max(array->size_of_element, sizeof(void *)),
- MYF(MY_WME|MY_ZEROFILL));
+ MY_MAX(array->size_of_element, sizeof(void *)),
+ MYF(MY_WME|MY_ZEROFILL));
if (unlikely(!alloc))
return(NULL);
/* reserve the space for free() address */
=== modified file 'mysys/mf_format.c'
--- a/mysys/mf_format.c 2011-02-09 22:34:20 +0000
+++ b/mysys/mf_format.c 2011-05-12 12:35:00 +0000
@@ -85,7 +85,7 @@ char * fn_format(char * to, const char *
tmp_length= strlength(startpos);
DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
(uint) length));
- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
+ (void) strmake(to, startpos, MY_MIN(tmp_length, FN_REFLEN-1));
}
else
{
=== modified file 'mysys/mf_iocache.c'
--- a/mysys/mf_iocache.c 2011-01-11 09:09:21 +0000
+++ b/mysys/mf_iocache.c 2011-05-12 12:35:00 +0000
@@ -1128,7 +1128,7 @@ static void copy_to_read_buffer(IO_CACHE
*/
while (write_length)
{
- size_t copy_length= min(write_length, write_cache->buffer_length);
+ size_t copy_length= MY_MIN(write_length, write_cache->buffer_length);
int __attribute__((unused)) rc;
rc= lock_io_cache(write_cache, write_cache->pos_in_file);
@@ -1286,7 +1286,7 @@ read_append_buffer:
TODO: figure out if the assert below is needed or correct.
*/
DBUG_ASSERT(pos_in_file == info->end_of_file);
- copy_len=min(Count, len_in_buff);
+ copy_len= MY_MIN(Count, len_in_buff);
memcpy(Buffer, info->append_read_pos, copy_len);
info->append_read_pos += copy_len;
Count -= copy_len;
@@ -1395,7 +1395,7 @@ int _my_b_async_read(register IO_CACHE *
}
#endif
/* Copy found bytes to buffer */
- length=min(Count,read_length);
+ length= MY_MIN(Count, read_length);
memcpy(Buffer,info->read_pos,(size_t) length);
Buffer+=length;
Count-=length;
@@ -1429,7 +1429,7 @@ int _my_b_async_read(register IO_CACHE *
if ((read_length=mysql_file_read(info->file,info->request_pos,
read_length, info->myflags)) == (size_t) -1)
return info->error= -1;
- use_length=min(Count,read_length);
+ use_length= MY_MIN(Count, read_length);
memcpy(Buffer,info->request_pos,(size_t) use_length);
info->read_pos=info->request_pos+Count;
info->read_end=info->request_pos+read_length;
=== modified file 'mysys/my_alloc.c'
--- a/mysys/my_alloc.c 2010-07-08 21:20:08 +0000
+++ b/mysys/my_alloc.c 2011-05-12 12:35:00 +0000
@@ -212,7 +212,7 @@ void *alloc_root(MEM_ROOT *mem_root, siz
{ /* Time to alloc new block */
block_size= mem_root->block_size * (mem_root->block_num >> 2);
get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
- get_size= max(get_size, block_size);
+ get_size= MY_MAX(get_size, block_size);
if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME | ME_FATALERROR))))
{
=== modified file 'mysys/my_bitmap.c'
--- a/mysys/my_bitmap.c 2011-02-16 16:19:28 +0000
+++ b/mysys/my_bitmap.c 2011-05-12 12:35:00 +0000
@@ -415,7 +415,7 @@ void bitmap_intersect(MY_BITMAP *map, co
DBUG_ASSERT(map->bitmap && map2->bitmap);
- end= to+min(len,len2);
+ end= to + MY_MIN(len, len2);
for (; to < end; to++, from++)
*to &= *from;
=== modified file 'mysys/my_compare.c'
--- a/mysys/my_compare.c 2011-03-29 12:56:34 +0000
+++ b/mysys/my_compare.c 2011-05-12 12:35:00 +0000
@@ -36,7 +36,7 @@ int ha_compare_text(const CHARSET_INFO *
static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
my_bool part_key, my_bool skip_end_space)
{
- uint length= min(a_length,b_length);
+ uint length= MY_MIN(a_length, b_length);
uchar *end= a+ length;
int flag;
@@ -164,7 +164,7 @@ int ha_key_cmp(register HA_KEYSEG *keyse
continue; /* To next key part */
}
}
- end= a+ min(keyseg->length,key_length);
+ end= a + MY_MIN(keyseg->length, key_length);
next_key_length=key_length-keyseg->length;
switch ((enum ha_base_keytype) keyseg->type) {
=== modified file 'mysys/my_compress.c'
--- a/mysys/my_compress.c 2010-07-08 21:20:08 +0000
+++ b/mysys/my_compress.c 2011-05-12 12:35:00 +0000
@@ -244,7 +244,7 @@ int unpackfrm(uchar **unpack_data, size_
if (ver != 1)
DBUG_RETURN(1);
- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
+ if (!(data= my_malloc(MY_MAX(orglen, complen), MYF(MY_WME))))
DBUG_RETURN(2);
memcpy(data, pack_data + BLOB_HEADER, complen);
=== modified file 'mysys/my_file.c'
--- a/mysys/my_file.c 2010-07-08 21:20:08 +0000
+++ b/mysys/my_file.c 2011-05-12 12:35:00 +0000
@@ -98,7 +98,7 @@ uint my_set_max_open_files(uint files)
DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
files+= MY_FILE_MIN;
- files= set_max_open_files(min(files, OS_FILE_LIMIT));
+ files= set_max_open_files(MY_MIN(files, OS_FILE_LIMIT));
if (files <= MY_NFILE)
DBUG_RETURN(files);
@@ -108,9 +108,9 @@ uint my_set_max_open_files(uint files)
/* Copy any initialized files */
memcpy((char*) tmp, (char*) my_file_info,
- sizeof(*tmp) * min(my_file_limit, files));
+ sizeof(*tmp) * MY_MIN(my_file_limit, files));
bzero((char*) (tmp + my_file_limit),
- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
+ MY_MAX((int) (files - my_file_limit), 0) * sizeof(*tmp));
my_free_open_file_info(); /* Free if already allocated */
my_file_info= tmp;
my_file_limit= files;
=== modified file 'mysys/stacktrace.c'
--- a/mysys/stacktrace.c 2011-03-02 23:04:54 +0000
+++ b/mysys/stacktrace.c 2011-05-12 12:35:00 +0000
@@ -93,7 +93,7 @@ static int safe_print_str(const char *ad
/* Read up to the maximum number of bytes. */
while (total)
{
- count= min(sizeof(buf), total);
+ count= MY_MIN(sizeof(buf), total);
if ((nbytes= pread(fd, buf, count, offset)) < 0)
{
@@ -321,7 +321,7 @@ void my_print_stacktrace(uchar* stack_bo
if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
{
- ulong tmp= min(0x10000,thread_stack);
+ ulong tmp= MY_MIN(0x10000, thread_stack);
/* Assume that the stack starts at the previous even 65K */
stack_bottom= (uchar*) (((ulong) &fp + tmp) &
~(ulong) 0xFFFF);
=== modified file 'sql-common/client.c'
--- a/sql-common/client.c 2011-04-29 21:53:46 +0000
+++ b/sql-common/client.c 2011-05-12 12:35:00 +0000
@@ -769,7 +769,7 @@ cli_safe_read(MYSQL *mysql)
}
(void) strmake(net->last_error,(char*) pos,
- min((uint) len,(uint) sizeof(net->last_error)-1));
+ MY_MIN((uint) len,(uint) sizeof(net->last_error)-1));
}
else
set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
=== modified file 'sql-common/my_time.c'
--- a/sql-common/my_time.c 2011-04-27 07:46:23 +0000
+++ b/sql-common/my_time.c 2011-05-12 12:35:00 +0000
@@ -249,7 +249,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= MY_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);
=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc 2011-04-04 08:47:25 +0000
+++ b/sql/binlog.cc 2011-05-12 12:35:00 +0000
@@ -24,6 +24,9 @@
#include "rpl_handler.h"
#include "rpl_info_factory.h"
+using std::max;
+using std::min;
+
#define MY_OFF_T_UNDEF (~(my_off_t)0UL)
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
@@ -1389,7 +1392,7 @@ bool show_binlog_events(THD *thd, MYSQL_
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 = max<my_off_t>(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;
mysql_mutex_t *log_lock = binary_log->get_log_lock();
=== modified file 'sql/debug_sync.cc'
--- a/sql/debug_sync.cc 2011-04-19 03:29:06 +0000
+++ b/sql/debug_sync.cc 2011-05-12 12:35:00 +0000
@@ -329,6 +329,9 @@
#include "sql_priv.h"
#include "sql_parse.h"
+using std::max;
+using std::min;
+
/*
Action to perform at a synchronization point.
NOTE: This structure is moved around in memory by realloc(), qsort(),
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2011-04-12 10:31:30 +0000
+++ b/sql/field.cc 2011-05-12 12:35:00 +0000
@@ -37,6 +37,9 @@
#include <m_ctype.h>
#include <errno.h>
+using std::max;
+using std::min;
+
// Maximum allowed exponent value for converting string to decimal
#define MAX_EXPONENT 1024
@@ -50,7 +53,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) << MY_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)))
@@ -1054,7 +1057,7 @@ static void push_numerical_conversion_wa
const char* field_name="UNKNOWN",
ulong row_num=0)
{
- char buf[max(max(DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE,
+ char buf[MY_MAX(MY_MAX(DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE,
LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE),
DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE)];
@@ -2514,7 +2517,7 @@ Field *Field_new_decimal::create_from_it
{
signed int overflow;
- dec= min(dec, DECIMAL_MAX_SCALE);
+ dec= min<int>(dec, DECIMAL_MAX_SCALE);
/*
If the value still overflows the field with the corrected dec,
@@ -9493,7 +9496,7 @@ bool Create_field::init(THD *thd, char *
DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
length= ((length+1)/2)*2;
- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
+ length= min<ulong>(length, MAX_DATETIME_COMPRESSED_WIDTH);
}
flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
/*
=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc 2011-04-04 08:47:25 +0000
+++ b/sql/filesort.cc 2011-05-12 12:35:00 +0000
@@ -37,6 +37,9 @@
#include "sql_select.h"
#include "debug_sync.h"
+using std::min;
+using std::max;
+
/* functions defined in this file */
static void make_char_array(FILESORT_INFO *info, uint fields, uint length);
@@ -240,11 +243,11 @@ ha_rows filesort(THD *thd, TABLE *table,
DBUG_PRINT("info", ("filesort PQ is not applicable"));
const ulong min_sort_memory=
- max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
+ max<uint>(MIN_SORT_MEMORY, param.sort_length * MERGEBUFF2);
while (memory_available >= min_sort_memory)
{
ulong keys= memory_available / (param.rec_length + sizeof(char*));
- param.max_keys_per_buffer= (uint) min(num_rows, keys);
+ param.max_keys_per_buffer= min<uint>(num_rows, keys);
make_char_array(&table_sort, param.max_keys_per_buffer, param.rec_length);
if (table_sort.sort_keys)
break;
@@ -1334,7 +1337,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= min<uint>((ha_rows) buffpek->max_keys,buffpek->count)))
{
if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base,
(length= rec_length*count),
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc 2011-04-29 08:19:16 +0000
+++ b/sql/ha_partition.cc 2011-05-12 12:35:00 +0000
@@ -64,6 +64,9 @@
#include "debug_sync.h"
+using std::min;
+using std::max;
+
#define PAR_FILE_ENGINE_OFFSET 12
static const char *ha_par_ext= ".par";
@@ -6459,7 +6462,7 @@ const key_map *ha_partition::keys_to_use
DBUG_RETURN(m_file[first_used_partition]->keys_to_use_for_scanning());
}
-#define MAX_PARTS_FOR_OPTIMIZER_CALLS 10
+#define MAX_PARTS_FOR_OPTIMIZER_CALLS 10U
/*
Prepare start variables for estimating optimizer costs.
@@ -6473,7 +6476,8 @@ void ha_partition::partitions_optimizer_
{
*first= bitmap_get_first_set(&(m_part_info->read_partitions));
*num_used_parts= bitmap_bits_set(&(m_part_info->read_partitions));
- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
+ *check_min_num= min<uint>(MAX_PARTS_FOR_OPTIMIZER_CALLS,
+ *num_used_parts);
}
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2011-04-28 08:28:18 +0000
+++ b/sql/handler.cc 2011-05-12 12:35:00 +0000
@@ -42,6 +42,9 @@
#include "ha_partition.h"
#endif
+using std::min;
+using std::max;
+
// This is a temporary backporting fix.
#ifndef HAVE_LOG2
/*
@@ -5262,9 +5265,9 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost
else
{
cost->zero();
- *buffer_size= max(*buffer_size,
- (size_t)(1.2*rows_in_last_step) * elem_size +
- h->ref_length + table->key_info[keynr].key_length);
+ *buffer_size= max<ulong>(*buffer_size,
+ (size_t)(1.2*rows_in_last_step) * elem_size +
+ h->ref_length + table->key_info[keynr].key_length);
}
COST_VECT last_step_cost;
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2011-04-26 08:49:10 +0000
+++ b/sql/handler.h 2011-05-12 12:35:00 +0000
@@ -25,6 +25,7 @@
#include "sql_cache.h"
#include "structs.h" /* SHOW_COMP_OPTION */
+#include <algorithm>
#include <my_global.h>
#include <my_compare.h>
#include <ft_global.h>
@@ -285,7 +286,7 @@
#define HA_LEX_CREATE_TABLE_LIKE 4
#define HA_OPTION_NO_CHECKSUM (1L << 17)
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
-#define HA_MAX_REC_LENGTH 65535
+#define HA_MAX_REC_LENGTH 65535U
/* Table caching type */
#define HA_CACHE_TBL_NONTRANSACT 0
@@ -2055,15 +2056,15 @@ public:
{ return (HA_ERR_WRONG_COMMAND); }
uint max_record_length() const
- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
+ { return std::min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
uint max_keys() const
- { return min(MAX_KEY, max_supported_keys()); }
+ { return std::min(MAX_KEY, max_supported_keys()); }
uint max_key_parts() const
- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
+ { return std::min(MAX_REF_PARTS, max_supported_key_parts()); }
uint max_key_length() const
- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
+ { return std::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 std::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; }
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2011-04-28 08:28:18 +0000
+++ b/sql/item.cc 2011-05-12 12:35:00 +0000
@@ -39,6 +39,9 @@
#include "log_event.h" // append_query_string
#include "sql_test.h" // print_where
+using std::min;
+using std::max;
+
const String my_null_string("NULL", 4, default_charset_info);
/****************************************************************************/
@@ -87,8 +90,8 @@ 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,
- DECIMAL_MAX_STR_LENGTH);
+ item->max_length= min<uint32>(arg->max_length + DECIMAL_LONGLONG_DIGITS,
+ DECIMAL_MAX_STR_LENGTH);
}
@@ -487,9 +490,9 @@ uint Item::decimal_precision() const
uint prec=
my_decimal_length_to_precision(max_char_length(), decimals,
unsigned_flag);
- return min(prec, DECIMAL_MAX_PRECISION);
+ return min<uint>(prec, DECIMAL_MAX_PRECISION);
}
- return min(max_char_length(), DECIMAL_MAX_PRECISION);
+ return min<uint>(max_char_length(), DECIMAL_MAX_PRECISION);
}
@@ -804,7 +807,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= min<size_t>(length, MAX_ALIAS_NAME)));
}
@@ -5801,7 +5804,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 - min(str_value.length(), sizeof(longlong));
ulonglong value=0;
for (; ptr != end ; ptr++)
@@ -8229,14 +8232,14 @@ 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= max<int>(decimals, item_decimals);
}
if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
{
- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
+ decimals= min<int>(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
int item_int_part= item->decimal_int_part();
int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
+ int precision= min<uint>(item_prec, DECIMAL_MAX_PRECISION);
unsigned_flag&= item->unsigned_flag;
max_length= my_decimal_precision_to_length_no_truncation(precision,
decimals,
=== modified file 'sql/item_buff.cc'
--- a/sql/item_buff.cc 2011-04-04 08:47:25 +0000
+++ b/sql/item_buff.cc 2011-05-12 12:35:00 +0000
@@ -30,6 +30,9 @@
#include "sql_class.h" // THD
#include "set_var.h" // Cached_item, Cached_item_field, ...
+using std::min;
+using std::max;
+
/**
Create right type of Cached_item for an item.
*/
@@ -71,7 +74,7 @@ Cached_item::~Cached_item() {}
Cached_item_str::Cached_item_str(THD *thd, Item *arg)
:item(arg),
- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
+ value_max_length(min<uint32>(arg->max_length, thd->variables.max_sort_length)),
value(value_max_length)
{}
=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc 2011-04-26 08:49:10 +0000
+++ b/sql/item_cmpfunc.cc 2011-05-12 12:35:00 +0000
@@ -27,6 +27,9 @@
#include "sql_parse.h" // check_stack_overrun
#include "sql_time.h" // make_truncated_value_warning
+using std::min;
+using std::max;
+
static bool convert_constant_item(THD *, Item_field *, Item **);
static longlong
get_year_value(THD *thd, Item ***item_arg, Item **cache_arg,
@@ -627,7 +630,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[MY_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)
@@ -2584,7 +2587,7 @@ uint Item_func_ifnull::decimal_precision
int arg1_int_part= args[1]->decimal_int_part();
int max_int_part= max(arg0_int_part, arg1_int_part);
int precision= max_int_part + decimals;
- return min(precision, DECIMAL_MAX_PRECISION);
+ return min<uint>(precision, DECIMAL_MAX_PRECISION);
}
@@ -2773,7 +2776,7 @@ uint Item_func_if::decimal_precision() c
int arg1_prec= args[1]->decimal_int_part();
int arg2_prec= args[2]->decimal_int_part();
int precision=max(arg1_prec,arg2_prec) + decimals;
- return min(precision, DECIMAL_MAX_PRECISION);
+ return min<uint>(precision, DECIMAL_MAX_PRECISION);
}
@@ -3232,7 +3235,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 min<uint>(max_int_part + decimals, DECIMAL_MAX_PRECISION);
}
@@ -5276,8 +5279,8 @@ void Item_func_like::turboBM_compute_bad
bool Item_func_like::turboBM_matches(const char* text, int text_len) const
{
- register int bcShift;
- register int turboShift;
+ int bcShift;
+ int turboShift;
int shift = pattern_len;
int j = 0;
int u = 0;
@@ -5291,7 +5294,7 @@ bool Item_func_like::turboBM_matches(con
{
while (j <= tlmpl)
{
- register int i= plm1;
+ int i= plm1;
while (i >= 0 && pattern[i] == text[i + j])
{
i--;
@@ -5301,7 +5304,7 @@ bool Item_func_like::turboBM_matches(con
if (i < 0)
return 1;
- register const int v = plm1 - i;
+ const int v = plm1 - i;
turboShift = u - v;
bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
shift = max(turboShift, bcShift);
@@ -5322,7 +5325,7 @@ bool Item_func_like::turboBM_matches(con
{
while (j <= tlmpl)
{
- register int i = plm1;
+ int i = plm1;
while (i >= 0 && likeconv(cs,pattern[i]) == likeconv(cs,text[i + j]))
{
i--;
@@ -5332,7 +5335,7 @@ bool Item_func_like::turboBM_matches(con
if (i < 0)
return 1;
- register const int v = plm1 - i;
+ const int v = plm1 - i;
turboShift = u - v;
bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
shift = max(turboShift, bcShift);
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2011-04-26 20:35:24 +0000
+++ b/sql/item_func.cc 2011-05-12 12:35:00 +0000
@@ -48,6 +48,9 @@
#include "set_var.h"
#include "debug_sync.h"
+using std::min;
+using std::max;
+
#ifdef NO_EMBEDDED_ACCESS_CHECKS
#define sp_restore_security_context(A,B) while (0) {}
#endif
@@ -1482,7 +1485,7 @@ void Item_func_mul::result_precision()
unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
+ uint precision= min<uint>(est_prec, DECIMAL_MAX_PRECISION);
max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
unsigned_flag);
}
@@ -1534,16 +1537,16 @@ my_decimal *Item_func_div::decimal_op(my
void Item_func_div::result_precision()
{
- uint precision=min(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
+ uint precision= min<uint>(args[0]->decimal_precision() +
+ args[1]->decimals + 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= min<uint>(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
unsigned_flag);
}
@@ -2413,7 +2416,7 @@ my_decimal *Item_func_round::decimal_op(
my_decimal val, *value= args[0]->val_decimal(&val);
longlong dec= args[1]->val_int();
if (dec >= 0 || args[1]->unsigned_flag)
- dec= min((ulonglong) dec, decimals);
+ dec= min<ulonglong>(dec, decimals);
else if (dec < INT_MIN)
dec= INT_MIN;
@@ -3301,7 +3304,7 @@ 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= min<size_t>(initid.max_length, MAX_BLOB_WIDTH);
func->maybe_null=initid.maybe_null;
const_item_cache=initid.const_item;
/*
@@ -3310,7 +3313,7 @@ udf_handler::fix_fields(THD *thd, Item_r
*/
if (!const_item_cache && !used_tables_cache)
used_tables_cache= RAND_TABLE_BIT;
- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
+ func->decimals= min<uint>(initid.decimals, NOT_FIXED_DEC);
}
initialized=1;
if (error)
=== modified file 'sql/item_func.h'
--- a/sql/item_func.h 2011-04-15 09:04:21 +0000
+++ b/sql/item_func.h 2011-05-12 12:35:00 +0000
@@ -502,8 +502,8 @@ public:
const char *func_name() const { return "cast_as_unsigned"; }
void fix_length_and_dec()
{
- fix_char_length(min(args[0]->max_char_length(),
- DECIMAL_MAX_PRECISION + 2));
+ fix_char_length(std::min<uint32>(args[0]->max_char_length(),
+ DECIMAL_MAX_PRECISION + 2));
unsigned_flag=1;
}
longlong val_int();
=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc 2011-04-15 09:04:21 +0000
+++ b/sql/item_strfunc.cc 2011-05-12 12:35:00 +0000
@@ -53,6 +53,9 @@ C_MODE_START
#include "../mysys/my_static.h" // For soundex_map
C_MODE_END
+using std::min;
+using std::max;
+
/**
@todo Remove this. It is not safe to use a shared String object.
*/
@@ -3508,7 +3511,7 @@ void Item_func_export_set::fix_length_an
uint32 sep_length= (arg_count > 3 ? args[3]->max_char_length() : 1);
if (agg_arg_charsets_for_string_result(collation,
- args + 1, min(4, arg_count) - 1))
+ args + 1, min(4U, arg_count) - 1))
return;
fix_char_length(length * 64 + sep_length * 63);
}
@@ -3929,7 +3932,7 @@ String *Item_func_uuid::val_str(String *
/*
-1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
*/
- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
+ ulong delta= min<ulong>(nanoseq, (ulong) (tv - uuid_time -1));
tv-= delta;
nanoseq-= delta;
}
=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h 2011-04-15 09:04:21 +0000
+++ b/sql/item_strfunc.h 2011-05-12 12:35:00 +0000
@@ -792,7 +792,7 @@ public:
collation.set(args[0]->collation);
ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 +
2 * collation.collation->mbmaxlen;
- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
+ max_length= std::min<uint32>(max_result_length, MAX_BLOB_WIDTH);
}
};
=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc 2011-04-12 10:31:30 +0000
+++ b/sql/item_sum.cc 2011-05-12 12:35:00 +0000
@@ -24,6 +24,9 @@
#include "sql_priv.h"
#include "sql_select.h"
+using std::min;
+using std::max;
+
/**
Calculate the affordable RAM limit for structures like TREE or Unique
used in Item_sum_*
@@ -1523,7 +1526,7 @@ 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= min<uint>(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
max_length= my_decimal_precision_to_length_no_truncation(precision,
decimals,
unsigned_flag);
@@ -1532,7 +1535,7 @@ void Item_sum_avg::fix_length_and_dec()
dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
}
else {
- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
+ decimals= min<uint>(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
max_length= args[0]->max_length + prec_increment;
}
}
@@ -1735,7 +1738,7 @@ void Item_sum_variance::fix_length_and_d
case DECIMAL_RESULT:
{
int precision= args[0]->decimal_precision()*2 + prec_increment;
- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
+ decimals= min<uint>(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
max_length= my_decimal_precision_to_length_no_truncation(precision,
decimals,
unsigned_flag);
@@ -3370,7 +3373,7 @@ bool Item_func_group_concat::setup(THD *
syntax of this function). If there is no ORDER BY clause, we don't
create this tree.
*/
- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
+ init_tree(tree, min<uint>(thd->variables.max_heap_table_size,
thd->variables.sortbuff_size/16), 0,
tree_key_length,
group_concat_key_cmp_with_order , 0, NULL, (void*) this);
=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc 2011-04-27 07:55:04 +0000
+++ b/sql/item_timefunc.cc 2011-05-12 12:35:00 +0000
@@ -49,6 +49,9 @@
#include <m_ctype.h>
#include <time.h>
+using std::min;
+using std::max;
+
/** Day number for Dec 31st, 9999. */
#define MAX_DAY_NUMBER 3652424L
@@ -1887,8 +1890,8 @@ void Item_func_date_format::fix_length_a
else
{
fixed_length=0;
- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
+ max_length= min<uint32>(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
+ collation.collation->mbmaxlen;
set_if_smaller(max_length,MAX_BLOB_WIDTH);
}
maybe_null=1; // If wrong date
=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h 2011-03-30 07:42:03 +0000
+++ b/sql/item_timefunc.h 2011-05-12 12:35:00 +0000
@@ -98,7 +98,7 @@ public:
{
int *input_version= (int*)int_arg;
/* This function was introduced in 5.5 */
- int output_version= max(*input_version, 50500);
+ int output_version= std::max(*input_version, 50500);
*input_version= output_version;
return 0;
}
=== modified file 'sql/key.cc'
--- a/sql/key.cc 2011-03-09 20:54:55 +0000
+++ b/sql/key.cc 2011-05-12 12:35:00 +0000
@@ -21,6 +21,9 @@
#include "key.h" // key_rec_cmp
#include "field.h" // Field
+using std::min;
+using std::max;
+
/*
Search after a key that starts with 'field'
@@ -128,13 +131,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= min<uint>(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= min<uint>(key_length, key_part->length);
Field *field= key_part->field;
const CHARSET_INFO *cs= field->charset();
uint bytes= field->get_key_image(to_key, length, Field::itRAW);
@@ -241,7 +244,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= min<uint>(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);
@@ -250,7 +253,7 @@ void key_restore(uchar *to_record, uchar
}
else
{
- length= min(key_length, key_part->length);
+ length= min<uint>(key_length, key_part->length);
/* skip the byte with 'uneven' bits, if used */
memcpy(to_record + key_part->offset, from_key + used_uneven_bits
, (size_t) length - used_uneven_bits);
@@ -403,7 +406,7 @@ void key_unpack(String *to,TABLE *table,
tmp.length(charpos);
}
if (key_part->length < field->pack_length())
- tmp.length(min(tmp.length(),key_part->length));
+ tmp.length(min<uint32>(tmp.length(),key_part->length));
ErrConvString err(&tmp);
to->append(err.ptr());
}
=== modified file 'sql/log.cc'
--- a/sql/log.cc 2011-03-17 17:39:31 +0000
+++ b/sql/log.cc 2011-05-12 12:35:00 +0000
@@ -44,6 +44,9 @@
#include "message.h"
#endif
+using std::min;
+using std::max;
+
/* max size of the log message */
#define MAX_LOG_BUFFER_SIZE 1024
#define MAX_TIME_SIZE 32
@@ -618,11 +621,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, min<long>(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
if (table->field[SQLT_FIELD_QUERY_TIME]->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, min<long>(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
if (table->field[SQLT_FIELD_LOCK_TIME]->store_time(&t, MYSQL_TIMESTAMP_TIME))
goto err;
/* rows_sent */
@@ -2020,7 +2023,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-1));
+ strmake(buff, log_name, min<size_t>(length, FN_REFLEN-1));
return (const char*)buff;
}
return log_name;
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2011-03-25 12:15:56 +0000
+++ b/sql/log_event.cc 2011-05-12 12:35:00 +0000
@@ -47,6 +47,8 @@
#include <my_bitmap.h>
#include "rpl_utility.h"
+using std::min;
+using std::max;
/**
BINLOG_CHECKSUM variable.
@@ -1248,8 +1250,8 @@ 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,
- LOG_EVENT_MINIMAL_HEADER_LEN);
+ uint header_size= min<uint>(description_event->common_header_len,
+ LOG_EVENT_MINIMAL_HEADER_LEN);
LOCK_MUTEX;
DBUG_PRINT("info", ("my_b_tell: %lu", (ulong) my_b_tell(file)));
@@ -1274,8 +1276,10 @@ failed my_b_read"));
uint max_allowed_packet= thd ? thd->variables.max_allowed_packet : ~(ulong)0;
#endif
- if (data_len > max(max_allowed_packet,
- opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER))
+ ulong const max_size=
+ max<ulong>(max_allowed_packet,
+ opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER);
+ if (data_len > max_size)
{
error = "Event too big";
goto err;
@@ -3001,7 +3005,7 @@ Query_log_event::Query_log_event(const c
be even bigger, but this will suffice to catch most corruption
errors that can lead to a crash.
*/
- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
+ if (status_vars_len > min<ulong>(data_len, MAX_SIZE_LOG_EVENT_STATUS))
{
DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
status_vars_len, data_len));
@@ -7812,7 +7816,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, min<size_t>(length, 32));
#endif
DBUG_ASSERT(m_rows_buf <= m_rows_cur);
=== modified file 'sql/log_event.h'
--- a/sql/log_event.h 2011-03-22 11:44:40 +0000
+++ b/sql/log_event.h 2011-05-12 12:35:00 +0000
@@ -216,8 +216,8 @@ struct sql_ex_info
****************************************************************************/
-#define LOG_EVENT_HEADER_LEN 19 /* the fixed header length */
-#define OLD_HEADER_LEN 13 /* the fixed header length in 3.23 */
+#define LOG_EVENT_HEADER_LEN 19U /* the fixed header length */
+#define OLD_HEADER_LEN 13U /* the fixed header length in 3.23 */
/*
Fixed header length, where 4.x and 5.0 agree. That is, 5.0 may have a longer
header (it will for sure when we have the unique event's ID), but at least
@@ -225,7 +225,7 @@ struct sql_ex_info
event's ID, LOG_EVENT_HEADER_LEN will be something like 26, but
LOG_EVENT_MINIMAL_HEADER_LEN will remain 19.
*/
-#define LOG_EVENT_MINIMAL_HEADER_LEN 19
+#define LOG_EVENT_MINIMAL_HEADER_LEN 19U
/* event-specific post-header sizes */
// where 3.23, 4.x and 5.0 agree
@@ -259,17 +259,17 @@ struct sql_ex_info
packet (i.e. a query) sent from client to master;
First, an auxiliary log_event status vars estimation:
*/
-#define MAX_SIZE_LOG_EVENT_STATUS (1 + 4 /* type, flags2 */ + \
- 1 + 8 /* type, sql_mode */ + \
- 1 + 1 + 255 /* type, length, catalog */ + \
- 1 + 4 /* type, auto_increment */ + \
- 1 + 6 /* type, charset */ + \
- 1 + 1 + 255 /* type, length, time_zone */ + \
- 1 + 2 /* type, lc_time_names_number */ + \
- 1 + 2 /* type, charset_database_number */ + \
- 1 + 8 /* type, table_map_for_update */ + \
- 1 + 4 /* type, master_data_written */ + \
- 1 + 16 + 1 + 60/* type, user_len, user, host_len, host */)
+#define MAX_SIZE_LOG_EVENT_STATUS (1U + 4 /* type, flags2 */ + \
+ 1U + 8 /* type, sql_mode */ + \
+ 1U + 1 + 255 /* type, length, catalog */ + \
+ 1U + 4 /* type, auto_increment */ + \
+ 1U + 6 /* type, charset */ + \
+ 1U + 1 + 255 /* type, length, time_zone */ + \
+ 1U + 2 /* type, lc_time_names_number */ + \
+ 1U + 2 /* type, charset_database_number */ + \
+ 1U + 8 /* type, table_map_for_update */ + \
+ 1U + 4 /* type, master_data_written */ + \
+ 1U + 16 + 1 + 60/* type, user_len, user, host_len, host */)
#define MAX_LOG_EVENT_HEADER ( /* in order of Query_log_event::write */ \
LOG_EVENT_HEADER_LEN + /* write_header */ \
QUERY_HEADER_LEN + /* write_data */ \
=== modified file 'sql/log_event_old.cc'
--- a/sql/log_event_old.cc 2010-11-01 05:40:27 +0000
+++ b/sql/log_event_old.cc 2011-05-12 12:35:00 +0000
@@ -32,6 +32,11 @@
#include "rpl_record_old.h"
#include "transaction.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
// Old implementation of do_apply_event()
@@ -1411,7 +1416,7 @@ int Old_rows_log_event::do_add_row_data(
trigger false warnings.
*/
#ifndef HAVE_purify
- DBUG_DUMP("row_data", row_data, min(length, 32));
+ DBUG_DUMP("row_data", row_data, min<size_t>(length, 32));
#endif
DBUG_ASSERT(m_rows_buf <= m_rows_cur);
=== modified file 'sql/mdl.h'
--- a/sql/mdl.h 2011-04-11 11:52:24 +0000
+++ b/sql/mdl.h 2011-05-12 12:35:00 +0000
@@ -29,13 +29,14 @@
#include <m_string.h>
#include <mysql_com.h>
+#include <algorithm>
+
class THD;
class MDL_context;
class MDL_lock;
class MDL_ticket;
-
/**
An interface to separate the MDL module from the THD, and the rest of the
server code.
@@ -287,7 +288,7 @@ public:
character set is utf-8, we can safely assume that no
character starts with a zero byte.
*/
- return memcmp(m_ptr, rhs->m_ptr, min(m_length, rhs->m_length));
+ return memcmp(m_ptr, rhs->m_ptr, std::min(m_length, rhs->m_length));
}
MDL_key(const MDL_key *rhs)
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2011-04-28 16:50:10 +0000
+++ b/sql/mysqld.cc 2011-05-12 12:35:00 +0000
@@ -92,6 +92,9 @@
#include <poll.h>
#endif
+using std::min;
+using std::max;
+
#define mysqld_charset &my_charset_latin1
/* We have HAVE_purify below as this speeds up the shutdown of MySQL */
@@ -2469,7 +2472,7 @@ the thread stack. Please read http://dev
fprintf(stderr, "\nTrying to get some variables.\n"
"Some pointers may be invalid and cause the dump to abort.\n");
fprintf(stderr, "Query (%p): ", thd->query());
- my_safe_print_str(thd->query(), min(1024, thd->query_length()));
+ my_safe_print_str(thd->query(), min(1024U, thd->query_length()));
fprintf(stderr, "Connection ID (thread ID): %lu\n", (ulong) thd->thread_id);
fprintf(stderr, "Status: %s\n", kreason);
fputc('\n', stderr);
@@ -3421,7 +3424,7 @@ int init_common_variables()
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= max(max<ulong>(wanted_files, max_connections*5),
open_files_limit);
files= my_set_max_open_files(max_open_files);
@@ -3433,17 +3436,17 @@ int init_common_variables()
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);
+ max_connections= min<ulong>(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
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_OPEN_CACHE_MIN),
- table_cache_size);
+ table_cache_size= min<ulong>(max<ulong>((files-10-max_connections)/2,
+ TABLE_OPEN_CACHE_MIN),
+ table_cache_size);
DBUG_PRINT("warning",
("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld",
files, max_connections, table_cache_size));
@@ -5425,7 +5428,7 @@ void handle_connections_sockets()
struct pollfd fds[2]; // for ip_sock and unix_sock
#else
fd_set readFDs,clientFDs;
- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
+ uint max_used_connection= max<uint>(ip_sock,unix_sock) + 1;
#endif
DBUG_ENTER("handle_connections_sockets");
=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc 2011-02-08 15:54:12 +0000
+++ b/sql/net_serv.cc 2011-05-12 12:35:00 +0000
@@ -45,6 +45,11 @@
#include <errno.h>
#include "probes_mysql.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
#ifdef EMBEDDED_LIBRARY
#undef MYSQL_SERVER
#undef MYSQL_CLIENT
@@ -961,7 +966,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 = max<ulonglong>(len,*complen) + net->where_b;
/* The necessary size of net->buff */
if (helping >= net->max_packet)
{
=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc 2011-04-23 20:44:45 +0000
+++ b/sql/opt_range.cc 2011-05-12 12:35:00 +0000
@@ -113,6 +113,9 @@
#include <m_ctype.h>
#include "sql_select.h"
+using std::min;
+using std::max;
+
#ifndef EXTRA_DEBUG
#define test_rb_tree(A,B) {}
#define test_use_count(A) {}
@@ -970,7 +973,7 @@ SEL_TREE::SEL_TREE(SEL_TREE *arg, RANGE_
{
keys_map= arg->keys_map;
type= arg->type;
- for (int idx= 0; idx < MAX_KEY; idx++)
+ for (unsigned int idx= 0; idx < MAX_KEY; idx++)
{
if ((keys[idx]= arg->keys[idx]))
keys[idx]->increment_use_count(1);
@@ -7775,7 +7778,8 @@ walk_up_n_right:
}
}
seq->param->range_count++;
- seq->param->max_key_part=max(seq->param->max_key_part,key_tree->part);
+ seq->param->max_key_part= max<uint>(seq->param->max_key_part,
+ key_tree->part);
return 0;
}
@@ -10516,7 +10520,7 @@ void cost_group_min_max(TABLE* table, KE
p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
p_overlap= min(p_overlap, 1.0);
}
- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
+ io_cost= min<double>(num_groups * (1 + p_overlap), num_blocks);
}
else
io_cost= (keys_per_group > keys_per_block) ?
=== modified file 'sql/opt_range.h'
--- a/sql/opt_range.h 2011-04-01 14:04:52 +0000
+++ b/sql/opt_range.h 2011-05-12 12:35:00 +0000
@@ -30,6 +30,9 @@
#include "sql_class.h" // set_var.h: THD
#include "set_var.h" /* Item */
+using std::min;
+using std::max;
+
class JOIN;
class Item_sum;
=== modified file 'sql/protocol.cc'
--- a/sql/protocol.cc 2011-03-22 11:44:40 +0000
+++ b/sql/protocol.cc 2011-05-12 12:35:00 +0000
@@ -26,6 +26,9 @@
#include "sql_class.h" // THD
#include <stdarg.h>
+using std::min;
+using std::max;
+
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
/* Declared non-static only because of the embedded library. */
bool net_send_error_packet(THD *, uint, const char *, const char *);
@@ -230,7 +233,7 @@ net_send_ok(THD *thd,
pos+=2;
/* We can only return up to 65535 warnings in two bytes */
- uint tmp= min(statement_warn_count, 65535);
+ uint tmp= min(statement_warn_count, 65535U);
int2store(pos, tmp);
pos+= 2;
}
@@ -326,7 +329,7 @@ static bool 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= min(statement_warn_count, 65535);
+ uint tmp= min(statement_warn_count, 65535U);
buff[0]= 254;
int2store(buff+1, tmp);
/*
=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc 2011-04-28 16:50:10 +0000
+++ b/sql/rpl_mi.cc 2011-05-12 12:35:00 +0000
@@ -20,6 +20,9 @@
#include "rpl_mi.h"
#include "rpl_slave.h" // SLAVE_MAX_HEARTBEAT_PERIOD
+using std::min;
+using std::max;
+
#ifdef HAVE_REPLICATION
enum {
@@ -167,8 +170,8 @@ void Master_info::init_master_log_pos()
if CHANGE MASTER did not specify it. (no data loss in conversion
as hb period has a max)
*/
- heartbeat_period= (float) min(SLAVE_MAX_HEARTBEAT_PERIOD,
- (slave_net_timeout/2.0));
+ heartbeat_period= min<float>(SLAVE_MAX_HEARTBEAT_PERIOD,
+ (slave_net_timeout/2.0));
DBUG_ASSERT(heartbeat_period > (float) 0.001
|| heartbeat_period == 0);
=== modified file 'sql/rpl_record.cc'
--- a/sql/rpl_record.cc 2010-12-21 10:39:20 +0000
+++ b/sql/rpl_record.cc 2011-05-12 12:35:00 +0000
@@ -21,6 +21,9 @@
#include "rpl_utility.h"
#include "rpl_rli.h"
+using std::min;
+using std::max;
+
/**
Pack a record of data for a table into a format suitable for
transfer via the binary log.
@@ -392,7 +395,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= min<ulong>(tabledef->size(), cols->n_bits);
for (; i < max_cols; i++)
{
if (bitmap_is_set(cols, i))
=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc 2011-04-28 16:50:10 +0000
+++ b/sql/rpl_rli.cc 2011-05-12 12:35:00 +0000
@@ -28,6 +28,9 @@
#include "sql_parse.h" // end_trans, ROLLBACK
#include "rpl_slave.h"
+using std::min;
+using std::max;
+
/*
Please every time you add a new field to the relay log info, update
what follows. For now, this is just used to get the number of
@@ -448,7 +451,7 @@ int Relay_log_info::wait_for_pos(THD* th
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(), min<uint32>(log_name->length(), FN_REFLEN-1));
char *p= fn_ext(log_name_tmp);
char *p_end;
@@ -458,7 +461,7 @@ int Relay_log_info::wait_for_pos(THD* th
goto err;
}
// Convert 0-3 to 4
- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
+ log_pos= max<ulong>(log_pos, BIN_LOG_HEADER_SIZE);
/* p points to '.' */
log_name_extension= strtoul(++p, &p_end, 10);
/*
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc 2011-04-28 16:50:10 +0000
+++ b/sql/rpl_slave.cc 2011-05-12 12:35:00 +0000
@@ -57,6 +57,9 @@
#include "rpl_tblmap.h"
#include "debug_sync.h"
+using std::min;
+using std::max;
+
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
#define MAX_SLAVE_RETRY_PAUSE 5
@@ -358,8 +361,8 @@ int init_recovery(Master_info* mi, const
const char *group_master_log_name= rli->get_group_master_log_name();
if (group_master_log_name[0])
{
- mi->set_master_log_pos(max(BIN_LOG_HEADER_SIZE,
- rli->get_group_master_log_pos()));
+ mi->set_master_log_pos(max<ulonglong>(BIN_LOG_HEADER_SIZE,
+ rli->get_group_master_log_pos()));
mi->set_master_log_name(rli->get_group_master_log_name());
sql_print_warning("Recovery from master pos %ld and file %s.",
@@ -2168,7 +2171,7 @@ bool show_master_info(THD* thd, Master_i
special marker to say "consider we have caught up".
*/
protocol->store((longlong)(mi->rli->last_master_timestamp ?
- max(0, time_diff) : 0));
+ max(0L, time_diff) : 0));
}
else
{
@@ -2922,7 +2925,7 @@ static int exec_relay_log_event(THD* thd
exec_res= 0;
rli->cleanup_context(thd, 1);
/* chance for concurrent connection to get more locks */
- slave_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
+ slave_sleep(thd, min<ulong>(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
sql_slave_killed, rli);
mysql_mutex_lock(&rli->data_lock); // because of SHOW STATUS
rli->trans_retries++;
@@ -4881,8 +4884,8 @@ static IO_CACHE *reopen_relay_log(Relay_
relay_log_pos Current log pos
pending Number of bytes already processed from the event
*/
- rli->set_event_relay_log_pos(max(rli->get_event_relay_log_pos(),
- BIN_LOG_HEADER_SIZE));
+ rli->set_event_relay_log_pos(max<ulonglong>(rli->get_event_relay_log_pos(),
+ BIN_LOG_HEADER_SIZE));
my_b_seek(cur_log,rli->get_event_relay_log_pos());
DBUG_RETURN(cur_log);
}
@@ -5857,8 +5860,8 @@ bool change_master(THD* thd, Master_info
if (lex_mi->heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED)
mi->heartbeat_period = lex_mi->heartbeat_period;
else
- mi->heartbeat_period= (float) min(SLAVE_MAX_HEARTBEAT_PERIOD,
- (slave_net_timeout/2.0));
+ mi->heartbeat_period= min<float>(SLAVE_MAX_HEARTBEAT_PERIOD,
+ (slave_net_timeout/2.0));
mi->received_heartbeats= LL(0); // counter lives until master is CHANGEd
/*
reset the last time server_id list if the current CHANGE MASTER
@@ -5958,8 +5961,8 @@ bool change_master(THD* thd, Master_info
of replication is not 100% clear, so we guard against problems using
max().
*/
- mi->set_master_log_pos(max(BIN_LOG_HEADER_SIZE,
- mi->rli->get_group_master_log_pos()));
+ mi->set_master_log_pos(max<ulonglong>(BIN_LOG_HEADER_SIZE,
+ mi->rli->get_group_master_log_pos()));
mi->set_master_log_name(mi->rli->get_group_master_log_name());
}
/*
=== modified file 'sql/rpl_utility.cc'
--- a/sql/rpl_utility.cc 2011-03-09 20:54:55 +0000
+++ b/sql/rpl_utility.cc 2011-05-12 12:35:00 +0000
@@ -20,6 +20,11 @@
#include "rpl_rli.h"
#include "sql_select.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
/**
Function to compare two size_t integers for their relative
order. Used below.
@@ -780,7 +785,7 @@ table_def::compatible_with(THD *thd, Rel
/*
We only check the initial columns for the tables.
*/
- uint const cols_to_check= min(table->s->fields, size());
+ uint const cols_to_check= min<ulong>(table->s->fields, size());
TABLE *tmp_table= NULL;
for (uint col= 0 ; col < cols_to_check ; ++col)
=== modified file 'sql/rpl_utility.h'
--- a/sql/rpl_utility.h 2010-07-02 18:15:21 +0000
+++ b/sql/rpl_utility.h 2011-05-12 12:35:00 +0000
@@ -268,7 +268,7 @@ CPP_UNNAMED_NS_END
do { \
char buf[256]; \
uint i; \
- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
+ for (i = 0 ; i < MY_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
buf[i] = '\0'; \
DBUG_PRINT((N), ((FRM), buf)); \
=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc 2011-04-15 12:14:35 +0000
+++ b/sql/sp_head.cc 2011-05-12 12:35:00 +0000
@@ -37,6 +37,11 @@
#include "sql_base.h" // close_thread_tables
#include "transaction.h" // trans_commit_stmt
+#include <algorithm>
+
+using std::min;
+using std::max;
+
/*
Sufficient max length of printed destinations and frame offsets (all uints).
*/
@@ -2638,8 +2643,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));
+ new Item_empty_string(col3_caption, max(m_defstr.length, 1024U));
stmt_fld->maybe_null= TRUE;
@@ -2839,7 +2843,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)));
+ max(buffer.length(), 1024U)));
if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF))
DBUG_RETURN(1);
=== modified file 'sql/spatial.h'
--- a/sql/spatial.h 2010-10-04 11:59:19 +0000
+++ b/sql/spatial.h 2011-05-12 12:35:00 +0000
@@ -23,6 +23,8 @@
#include "gcalc_tools.h"
+#include <algorithm>
+
const uint SRID_SIZE= 4;
const uint SIZEOF_STORED_DOUBLE= 8;
const uint POINT_DATA_SIZE= SIZEOF_STORED_DOUBLE*2;
@@ -185,8 +187,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(std::max(xmin, mbr->xmin), std::max(ymin, mbr->ymin),
+ std::min(xmax, mbr->xmax), std::min(ymax, mbr->ymax));
return (d == intersection.dimension());
}
=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc 2011-04-19 03:29:06 +0000
+++ b/sql/sql_acl.cc 2011-05-12 12:35:00 +0000
@@ -50,6 +50,9 @@
#include "hostname.h"
#include "sql_db.h"
+using std::min;
+using std::max;
+
bool mysql_user_table_is_in_short_password_format= false;
static const
@@ -1267,7 +1270,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 ? min(wild_pos, 127U) : chars);
}
va_end(args);
return sort;
=== modified file 'sql/sql_analyse.cc'
--- a/sql/sql_analyse.cc 2011-03-22 11:44:40 +0000
+++ b/sql/sql_analyse.cc 2011-05-12 12:35:00 +0000
@@ -29,6 +29,9 @@
#include "sql_analyse.h"
#include <m_ctype.h>
+using std::min;
+using std::max;
+
#define MAX_TREEMEM 8192
#define MAX_TREE_ELEMENTS 256
@@ -276,16 +279,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,
- info->ullval);
- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
+ ev_info->llval = - max<longlong>((ulonglong) -ev_info->llval,
+ info->ullval);
+ ev_info->min_dval = - max<double>(-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 = max<ulonglong>(ev_info->ullval, info->ullval);
+ ev_info->max_dval = max<double>(ev_info->max_dval, info->dval);
}
return 1;
} // get_ev_num_info
@@ -1176,7 +1179,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));
+ max(64U, output_str_length));
for (uint i = 0; i < array_elements(func_items); i++)
field_list.push_back(func_items[i]);
=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc 2011-02-15 17:14:15 +0000
+++ b/sql/sql_cache.cc 2011-05-12 12:35:00 +0000
@@ -348,6 +348,9 @@ TODO list:
#include "emb_qcache.h"
#endif
+using std::min;
+using std::max;
+
#if !defined(EXTRA_DBUG) && !defined(DBUG_OFF)
#define RW_WLOCK(M) {DBUG_PRINT("lock", ("rwlock wlock 0x%lx",(ulong)(M))); \
if (!mysql_rwlock_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \
@@ -3131,11 +3134,11 @@ void Query_cache::unlink_table(Query_cac
*****************************************************************************/
Query_cache_block *
-Query_cache::allocate_block(ulong len, my_bool not_less, ulong min)
+Query_cache::allocate_block(ulong len, my_bool not_less, ulong minimum)
{
DBUG_ENTER("Query_cache::allocate_block");
DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
+ len, not_less, minimum));
if (len >= min(query_cache_size, query_cache_limit))
{
@@ -3148,7 +3151,7 @@ Query_cache::allocate_block(ulong len, m
Query_cache_block *block;
do
{
- block= get_free_block(len, not_less, min);
+ block= get_free_block(len, not_less, minimum);
}
while (block == 0 && !free_old_query());
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2011-04-26 20:35:24 +0000
+++ b/sql/sql_class.cc 2011-05-12 12:35:00 +0000
@@ -57,6 +57,9 @@
#include <mysql/psi/mysql_statement.h>
+using std::min;
+using std::max;
+
/*
The following is used to initialise Table_ident with a internal
table name
=== modified file 'sql/sql_client.cc'
--- a/sql/sql_client.cc 2010-07-02 18:15:21 +0000
+++ b/sql/sql_client.cc 2011-05-12 12:35:00 +0000
@@ -20,6 +20,11 @@
#include "sql_priv.h"
#include "sql_class.h" // system_variables
+#include <algorithm>
+
+using std::min;
+using std::max;
+
/*
Function called by my_net_init() to set some check variables
*/
@@ -35,8 +40,8 @@ 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,
- global_system_variables.max_allowed_packet);
+ net->max_packet_size= max<size_t>(global_system_variables.net_buffer_length,
+ global_system_variables.max_allowed_packet);
#endif
}
}
=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc 2011-04-15 09:33:58 +0000
+++ b/sql/sql_connect.cc 2011-05-12 12:35:00 +0000
@@ -34,6 +34,11 @@
#include "sql_acl.h" // acl_getroot, NO_ACCESS, SUPER_ACL
#include "sql_callback.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
/*
Without SSL the handshake consists of one packet. This packet
@@ -482,8 +487,8 @@ 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),
- HOSTNAME_LENGTH)]= 0;
+ thd->main_security_ctx.host[min<size_t>(strlen(thd->main_security_ctx.host),
+ HOSTNAME_LENGTH)]= 0;
thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
}
if (connect_errors > max_connect_errors)
=== modified file 'sql/sql_const.h'
--- a/sql/sql_const.h 2010-12-17 09:41:21 +0000
+++ b/sql/sql_const.h 2011-05-12 12:35:00 +0000
@@ -30,8 +30,8 @@
#define MAX_FIELD_NAME 34 /* Max colum name length +2 */
#define MAX_SYS_VAR_LENGTH 32
#define MAX_KEY MAX_INDEXES /* Max used keys */
-#define MAX_REF_PARTS 16 /* Max parts used as ref */
-#define MAX_KEY_LENGTH 3072 /* max possible key */
+#define MAX_REF_PARTS 16U /* Max parts used as ref */
+#define MAX_KEY_LENGTH 3072U /* max possible key */
#if SIZEOF_OFF_T > 4
#define MAX_REFLENGTH 8 /* Max length for record ref */
#else
=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc 2011-04-15 12:14:35 +0000
+++ b/sql/sql_error.cc 2011-05-12 12:35:00 +0000
@@ -46,6 +46,9 @@ This file contains the implementation of
#include "sql_error.h"
#include "sp_rcontext.h"
+using std::min;
+using std::max;
+
/*
Design notes about MYSQL_ERROR::m_message_text.
=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc 2011-04-26 08:49:10 +0000
+++ b/sql/sql_join_cache.cc 2011-05-12 12:35:00 +0000
@@ -418,7 +418,7 @@ void JOIN_CACHE::set_constants()
uint len= length + fields*sizeof(uint)+blobs*sizeof(uchar *) +
(prev_cache ? prev_cache->get_size_of_rec_offset() : 0) +
sizeof(ulong);
- buff_size= max(join->thd->variables.join_buff_size, 2*len);
+ buff_size= max<size_t>(join->thd->variables.join_buff_size, 2*len);
size_of_rec_ofs= offset_size(buff_size);
size_of_rec_len= blobs ? size_of_rec_ofs : offset_size(len);
size_of_fld_ofs= size_of_rec_len;
@@ -2549,7 +2549,7 @@ int JOIN_CACHE_BKA_UNIQUE::init()
pack_length+= get_size_of_rec_offset();
/* Calculate the minimal possible value of size_of_key_ofs greater than 1 */
- uint max_size_of_key_ofs= max(2, get_size_of_rec_offset());
+ uint max_size_of_key_ofs= max(2U, get_size_of_rec_offset());
for (size_of_key_ofs= 2;
size_of_key_ofs <= max_size_of_key_ofs;
size_of_key_ofs+= 2)
=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc 2011-04-26 10:12:32 +0000
+++ b/sql/sql_load.cc 2011-05-12 12:35:00 +0000
@@ -38,6 +38,11 @@
#include "sp_head.h"
#include "sql_trigger.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
class XML_TAG {
public:
int level;
=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc 2011-04-19 03:29:06 +0000
+++ b/sql/sql_plugin.cc 2011-05-12 12:35:00 +0000
@@ -32,6 +32,12 @@
#include "sql_audit.h"
#include <mysql/plugin_auth.h>
#include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT
+
+#include <algorithm>
+
+using std::min;
+using std::max;
+
#define REPORT_TO_LOG 1
#define REPORT_TO_USER 2
=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc 2011-04-15 12:14:35 +0000
+++ b/sql/sql_prepare.cc 2011-05-12 12:35:00 +0000
@@ -339,7 +339,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->warning_info->statement_warn_count(), 65535);
+ tmp= min(stmt->thd->warning_info->statement_warn_count(), 65535UL);
int2store(buff+10, tmp);
/*
=== modified file 'sql/sql_profile.cc'
--- a/sql/sql_profile.cc 2010-07-08 21:42:23 +0000
+++ b/sql/sql_profile.cc 2011-05-12 12:35:00 +0000
@@ -36,11 +36,16 @@
#include "sql_show.h" // schema_table_store_record
#include "sql_class.h" // THD
+#include <algorithm>
+
+using std::min;
+using std::max;
+
#define TIME_FLOAT_DIGITS 9
/** two vals encoded: (dec*100)+len */
#define TIME_I_S_DECIMAL_SIZE (TIME_FLOAT_DIGITS*100)+(TIME_FLOAT_DIGITS-3)
-#define MAX_QUERY_LENGTH 300
+#define MAX_QUERY_LENGTH 300U
/**
Connects Information_Schema and Profiling.
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2011-05-03 06:46:06 +0000
+++ b/sql/sql_select.cc 2011-05-12 12:35:00 +0000
@@ -6320,7 +6320,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= max(select_lex->max_equal_elems, 1U);
/*
We use the same piece of memory to store both KEY_FIELD
@@ -6514,7 +6514,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= max<ha_rows>(tmp_table->file->stats.records, 100);
}
}
/*
@@ -8540,7 +8540,7 @@ void calc_used_field_length(THD *thd, JO
{
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+= max<uint>(4U, blob_length);
}
/**
@todo why don't we count the rowids that we might need to store
=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h 2011-05-02 11:51:41 +0000
+++ b/sql/sql_select.h 2011-05-12 12:35:00 +0000
@@ -30,6 +30,7 @@
#include "records.h" /* READ_RECORD */
#include "opt_range.h" /* SQL_SELECT, QUICK_SELECT_I */
+#include <algorithm>
/* Values in optimize */
#define KEY_OPTIMIZE_EXISTS 1
@@ -868,7 +869,7 @@ protected:
/* Shall calculate how much space is remaining in the join buffer */
virtual ulong rem_space()
{
- return max(buff_size-(end_pos-buff)-aux_buff_size,0);
+ return std::max(buff_size-(end_pos-buff)-aux_buff_size, 0UL);
}
/* Shall skip record from the join buffer if its match flag is on */
@@ -1350,7 +1351,7 @@ protected:
*/
ulong rem_space()
{
- return max(last_key_entry-end_pos-aux_buff_size,0);
+ return std::max(last_key_entry-end_pos-aux_buff_size, 0UL);
}
/*
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2011-05-02 11:16:36 +0000
+++ b/sql/sql_show.cc 2011-05-12 12:35:00 +0000
@@ -720,7 +720,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)));
+ max(buffer.length(), 1024U)));
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",
@@ -731,7 +731,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)));
+ max(buffer.length(), 1024U)));
}
if (protocol->send_result_set_metadata(&field_list,
@@ -1844,7 +1844,7 @@ void mysqld_list_processes(THD *thd,cons
/* Lock THD mutex that protects its data when looking at it. */
if (tmp->query())
{
- uint length= min(max_query_length, tmp->query_length());
+ uint length= min<uint>(max_query_length, tmp->query_length());
char *q= thd->strmake(tmp->query(),length);
/* Safety: in case strmake failed, we set length to 0. */
thd_info->query_string=
@@ -1967,9 +1967,9 @@ int fill_schema_processlist(THD* thd, TA
mysql_mutex_lock(&tmp->LOCK_thd_data);
if (tmp->query())
{
- table->field[7]->store(tmp->query(),
- min(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
+ size_t const width=
+ min<size_t>(PROCESS_LIST_INFO_WIDTH, tmp->query_length());
+ table->field[7]->store(tmp->query(), width, cs);
table->field[7]->set_notnull();
}
mysql_mutex_unlock(&tmp->LOCK_thd_data);
@@ -7784,7 +7784,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));
+ max<size_t>(trg_sql_original_stmt.length, 1024));
stmt_fld->maybe_null= TRUE;
=== modified file 'sql/sql_string.cc'
--- a/sql/sql_string.cc 2011-03-22 11:44:40 +0000
+++ b/sql/sql_string.cc 2011-05-12 12:35:00 +0000
@@ -23,6 +23,11 @@
#include "sql_string.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
/*****************************************************************************
** String functions
*****************************************************************************/
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2011-03-09 20:54:55 +0000
+++ b/sql/sql_yacc.yy 2011-05-12 12:35:00 +0000
@@ -68,6 +68,9 @@
#pragma warning (disable : 4065)
#endif
+using std::min;
+using std::max;
+
int yylex(void *yylval, void *yythd);
#define yyoverflow(A,B,C,D,E,F) \
@@ -2031,7 +2034,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 = max<ulonglong>(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
}
| RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
{
@@ -2041,7 +2044,8 @@ 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 = max<ulong>(BIN_LOG_HEADER_SIZE,
+ Lex->mi.relay_log_pos);
}
;
=== modified file 'sql/thr_malloc.cc'
--- a/sql/thr_malloc.cc 2011-03-09 20:54:55 +0000
+++ b/sql/thr_malloc.cc 2011-05-12 12:35:00 +0000
@@ -21,6 +21,11 @@
#include "thr_malloc.h"
#include "sql_class.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
extern "C" void sql_alloc_error_handler(void);
void init_sql_alloc(MEM_ROOT *mem_root, uint block_size, uint pre_alloc)
=== modified file 'sql/tztime.cc'
--- a/sql/tztime.cc 2011-04-19 03:29:06 +0000
+++ b/sql/tztime.cc 2011-05-12 12:35:00 +0000
@@ -44,6 +44,8 @@
#include <mysql/psi/mysql_file.h>
#include "lock.h" // MYSQL_LOCK_IGNORE_FLUSH,
// MYSQL_LOCK_IGNORE_TIMEOUT
+using std::min;
+using std::max;
/*
Now we don't use abbreviations in server but we will do this in future.
@@ -171,7 +173,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))) +
+ MY_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
#endif
sizeof(LS_INFO) * TZ_MAX_LEAPS];
} u;
=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc 2011-03-25 13:28:19 +0000
+++ b/sql/unireg.cc 2011-05-12 12:35:00 +0000
@@ -31,6 +31,11 @@
#include <m_ctype.h>
#include <assert.h>
+#include <algorithm>
+
+using std::min;
+using std::max;
+
#define FCOMP 17 /* Bytes for a packed field */
static uchar * pack_screens(List<Create_field> &create_fields,
@@ -602,7 +607,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= min<uint8>(cfield->length, cols - (length + 2));
}
length=(uint) (pos-start_screen);
int2store(start_screen,length);
@@ -835,7 +840,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= max<size_t>(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)
{
=== modified file 'storage/csv/ha_tina.cc'
--- a/storage/csv/ha_tina.cc 2011-04-19 03:29:06 +0000
+++ b/storage/csv/ha_tina.cc 2011-05-12 12:35:00 +0000
@@ -49,6 +49,10 @@ TODO:
#include "ha_tina.h"
#include "probes_mysql.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
/*
uchar + uchar + ulonglong + ulonglong + ulonglong + ulonglong + uchar
@@ -1313,8 +1317,7 @@ bool ha_tina::get_write_pos(my_off_t *en
if (closest_hole == chain_ptr) /* no more chains */
*end_pos= file_buff->end();
else
- *end_pos= min(file_buff->end(),
- closest_hole->begin);
+ *end_pos= min(file_buff->end(), closest_hole->begin);
return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
}
=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc 2011-04-19 03:29:06 +0000
+++ b/storage/federated/ha_federated.cc 2011-05-12 12:35:00 +0000
@@ -386,6 +386,11 @@
#include <mysql/plugin.h>
+#include <algorithm>
+
+using std::min;
+using std::max;
+
/* Variables for federated share methods */
static HASH federated_open_tables; // To track open tables
mysql_mutex_t federated_mutex; // To init the hash
@@ -572,8 +577,8 @@ static int parse_url_error(FEDERATED_SHA
size_t buf_len;
DBUG_ENTER("ha_federated parse_url_error");
- buf_len= min(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
+ buf_len= min<size_t>(table->s->connect_string.length,
+ FEDERATED_QUERY_BUFFER_SIZE-1);
strmake(buf, table->s->connect_string.str, buf_len);
my_error(error_num, MYF(0), buf);
DBUG_RETURN(error_num);
=== modified file 'storage/heap/hp_create.c'
--- a/storage/heap/hp_create.c 2011-01-11 09:09:21 +0000
+++ b/storage/heap/hp_create.c 2011-05-12 12:35:00 +0000
@@ -232,7 +232,7 @@ static void init_block(HP_BLOCK *block,
{
uint i,recbuffer,records_in_block;
- max_records= max(min_records,max_records);
+ max_records= MY_MAX(min_records, max_records);
if (!max_records)
max_records= 1000; /* As good as quess as anything */
recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
=== modified file 'storage/heap/hp_test2.c'
--- a/storage/heap/hp_test2.c 2011-01-11 09:09:21 +0000
+++ b/storage/heap/hp_test2.c 2011-05-12 12:35:00 +0000
@@ -132,7 +132,9 @@ int main(int argc, char *argv[])
for (i=0 ; i < recant ; i++)
{
- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
+ n1= rnd(1000);
+ n2= rnd(100);
+ n3= rnd(MY_MIN(recant * 5, MAX_RECORDS));
make_record(record,n1,n2,n3,"Pos",write_count);
if (heap_write(file,record))
@@ -208,7 +210,9 @@ int main(int argc, char *argv[])
printf("- Update\n");
for (i=0 ; i < write_count/10 ; i++)
{
- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
+ n1= rnd(1000);
+ n2= rnd(100);
+ n3= rnd(MY_MIN(recant * 2, MAX_RECORDS));
make_record(record2, n1, n2, n3, "XXX", update);
if (rnd(2) == 1)
{
=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc 2011-04-23 20:44:45 +0000
+++ b/storage/myisam/ha_myisam.cc 2011-05-12 12:35:00 +0000
@@ -29,6 +29,11 @@
#include "sql_table.h" // tablename_to_filename
#include "sql_class.h" // THD
+#include <algorithm>
+
+using std::min;
+using std::max;
+
ulonglong myisam_recover_options;
static ulong opt_myisam_block_size;
=== modified file 'storage/myisam/mi_cache.c'
--- a/storage/myisam/mi_cache.c 2009-12-05 01:26:15 +0000
+++ b/storage/myisam/mi_cache.c 2011-05-12 12:35:00 +0000
@@ -61,7 +61,7 @@ int _mi_read_cache(IO_CACHE *info, uchar
(my_off_t) (info->read_end - info->request_pos))
{
in_buff_pos=info->request_pos+(uint) offset;
- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
+ in_buff_length= MY_MIN(length, (size_t) (info->read_end-in_buff_pos));
memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
if (!(length-=in_buff_length))
DBUG_RETURN(0);
=== modified file 'storage/myisam/mi_check.c'
--- a/storage/myisam/mi_check.c 2011-03-29 12:56:34 +0000
+++ b/storage/myisam/mi_check.c 2011-05-12 12:35:00 +0000
@@ -2170,7 +2170,7 @@ int filecopy(MI_CHECK *param, File to,Fi
ulong buff_length;
DBUG_ENTER("filecopy");
- buff_length=(ulong) min(param->write_buffer_length,length);
+ buff_length=(ulong) MY_MIN(param->write_buffer_length,length);
if (!(buff=my_malloc(buff_length,MYF(0))))
{
buff=tmp_buff; buff_length=IO_SIZE;
@@ -2324,7 +2324,7 @@ int mi_repair_by_sort(MI_CHECK *param, r
init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
if (share->data_file_type == DYNAMIC_RECORD)
- length=max(share->base.min_pack_length+1,share->base.min_block_length);
+ length= MY_MAX(share->base.min_pack_length + 1, share->base.min_block_length);
else if (share->data_file_type == COMPRESSED_RECORD)
length=share->base.min_block_length;
else
@@ -2413,7 +2413,7 @@ int mi_repair_by_sort(MI_CHECK *param, r
(see _create_index_by_sort)
*/
sort_info.max_records= 10 *
- max(param->sort_buffer_length, MIN_SORT_BUFFER) /
+ MY_MAX(param->sort_buffer_length, MIN_SORT_BUFFER) /
sort_param.key_length;
}
@@ -2770,7 +2770,7 @@ int mi_repair_parallel(MI_CHECK *param,
mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0));
if (share->data_file_type == DYNAMIC_RECORD)
- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
+ rec_length= MY_MAX(share->base.min_pack_length + 1, share->base.min_block_length);
else if (share->data_file_type == COMPRESSED_RECORD)
rec_length=share->base.min_block_length;
else
@@ -4322,7 +4322,7 @@ int recreate_table(MI_CHECK *param, MI_I
(void) mi_close(*org_info);
bzero((char*) &create_info,sizeof(create_info));
- create_info.max_rows=max(max_records,share.base.records);
+ create_info.max_rows= MY_MAX(max_records, share.base.records);
create_info.reloc_rows=share.base.reloc;
create_info.old_options=(share.options |
(unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
=== modified file 'storage/myisam/mi_create.c'
--- a/storage/myisam/mi_create.c 2011-02-15 12:04:52 +0000
+++ b/storage/myisam/mi_create.c 2011-05-12 12:35:00 +0000
@@ -434,8 +434,8 @@ int mi_create(const char *name,uint keys
block_length= (keydef->block_length ?
my_round_up_to_next_power(keydef->block_length) :
myisam_block_size);
- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
+ block_length= MY_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
+ block_length= MY_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
pointer,MI_MAX_KEYPTR_SIZE,
@@ -524,7 +524,7 @@ int mi_create(const char *name,uint keys
got from MYI file header (see also myisampack.c:save_state)
*/
share.base.key_reflength=
- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
+ mi_get_pointer_length(MY_MAX(ci->key_file_length, tmp), 3);
share.base.keys= share.state.header.keys= keys;
share.state.header.uniques= uniques;
share.state.header.fulltext_keys= fulltext_keys;
@@ -557,7 +557,7 @@ int mi_create(const char *name,uint keys
share.base.min_block_length=
(share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
! share.base.blobs) ?
- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
+ MY_MAX(share.base.pack_reclength, MI_MIN_BLOCK_LENGTH) :
MI_EXTEND_BLOCK_LENGTH;
if (! (flags & HA_DONT_TOUCH_DATA))
share.state.create_time= (long) time((time_t*) 0);
=== modified file 'storage/myisam/mi_dynrec.c'
--- a/storage/myisam/mi_dynrec.c 2011-01-11 09:09:21 +0000
+++ b/storage/myisam/mi_dynrec.c 2011-05-12 12:35:00 +0000
@@ -864,7 +864,7 @@ static int update_dynamic_record(MI_INFO
uint tmp=MY_ALIGN(reclength - length + 3 +
test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
/* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
+ tmp= MY_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
/* Check if we can extend this block */
if (block_info.filepos + block_info.block_len ==
info->state->data_file_length &&
=== modified file 'storage/myisam/mi_extra.c'
--- a/storage/myisam/mi_extra.c 2010-06-21 16:58:57 +0000
+++ b/storage/myisam/mi_extra.c 2011-05-12 12:35:00 +0000
@@ -99,8 +99,8 @@ int mi_extra(MI_INFO *info, enum ha_extr
cache_size= (extra_arg ? *(ulong*) extra_arg :
my_default_record_cache_size);
if (!(init_io_cache(&info->rec_cache,info->dfile,
- (uint) min(info->state->data_file_length+1,
- cache_size),
+ (uint) MY_MIN(info->state->data_file_length + 1,
+ cache_size),
READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
MYF(share->write_flag & MY_WAIT_IF_FULL))))
{
=== modified file 'storage/myisam/mi_open.c'
--- a/storage/myisam/mi_open.c 2011-01-11 09:09:21 +0000
+++ b/storage/myisam/mi_open.c 2011-05-12 12:35:00 +0000
@@ -304,7 +304,7 @@ MI_INFO *mi_open(const char *name, int m
strmov(share->index_file_name, index_name);
strmov(share->data_file_name, data_name);
- share->blocksize=min(IO_SIZE,myisam_block_size);
+ share->blocksize= MY_MIN(IO_SIZE, myisam_block_size);
{
HA_KEYSEG *pos=share->keyparts;
uint32 ftkey_nr= 1;
@@ -477,7 +477,7 @@ MI_INFO *mi_open(const char *name, int m
share->base.margin_key_file_length=(share->base.max_key_file_length -
(keys ? MI_INDEX_BLOCK_MARGIN *
share->blocksize * keys : 0));
- share->blocksize=min(IO_SIZE,myisam_block_size);
+ share->blocksize= MY_MIN(IO_SIZE, myisam_block_size);
share->data_file_type=STATIC_RECORD;
if (share->options & HA_OPTION_COMPRESS_RECORD)
{
@@ -688,10 +688,10 @@ uchar *mi_alloc_rec_buff(MI_INFO *info,
if (length == (ulong) -1)
{
if (info->s->options & HA_OPTION_COMPRESS_RECORD)
- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
+ length= MY_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
else
length= info->s->base.pack_reclength;
- length= max(length, info->s->base.max_key_length);
+ length= MY_MAX(length, info->s->base.max_key_length);
/* Avoid unnecessary realloc */
if (newptr && length == old_length)
return newptr;
=== modified file 'storage/myisam/mi_packrec.c'
--- a/storage/myisam/mi_packrec.c 2010-07-26 11:34:07 +0000
+++ b/storage/myisam/mi_packrec.c 2011-05-12 12:35:00 +0000
@@ -684,7 +684,7 @@ static uint find_longest_bitstream(uint1
return OFFSET_TABLE_SIZE;
}
length2= find_longest_bitstream(next, end) + 1;
- length=max(length,length2);
+ length= MY_MAX(length, length2);
}
return length;
}
@@ -1398,7 +1398,7 @@ uint _mi_pack_get_block_info(MI_INFO *my
info->filepos=filepos+head_length;
if (file > 0)
{
- info->offset=min(info->rec_len, ref_length - head_length);
+ info->offset= MY_MIN(info->rec_len, ref_length - head_length);
memcpy(*rec_buff_p, header + head_length, info->offset);
}
return 0;
=== modified file 'storage/myisam/myisamlog.c'
--- a/storage/myisam/myisamlog.c 2010-07-23 20:17:55 +0000
+++ b/storage/myisam/myisamlog.c 2011-05-12 12:35:00 +0000
@@ -90,7 +90,7 @@ int main(int argc, char **argv)
log_filename=myisam_log_filename;
get_options(&argc,&argv);
/* Number of MyISAM files we can have open at one time */
- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
+ max_files= (my_set_max_open_files(MY_MIN(max_files, 8)) - 6) / 2;
if (update)
printf("Trying to %s MyISAM files according to log '%s'\n",
(recover ? "recover" : "update"),log_filename);
=== modified file 'storage/myisam/myisampack.c'
--- a/storage/myisam/myisampack.c 2010-12-29 00:26:31 +0000
+++ b/storage/myisam/myisampack.c 2011-05-12 12:35:00 +0000
@@ -1269,8 +1269,8 @@ static void check_counts(HUFF_COUNTS *hu
{
if (huff_counts->field_length > 2 &&
huff_counts->empty_fields + (records - huff_counts->empty_fields)*
- (1+max_bit(max(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
+ (1+max_bit(MY_MAX(huff_counts->max_pre_space,
+ huff_counts->max_end_space))) <
records * max_bit(huff_counts->field_length))
{
huff_counts->pack_type |= PACK_TYPE_SPACE_FIELDS;
@@ -3030,7 +3030,7 @@ static int save_state_mrg(File file,PACK
if (mrg->src_file_has_indexes_disabled)
{
isam_file->s->state.state.key_file_length=
- max(isam_file->s->state.state.key_file_length, new_length);
+ MY_MAX(isam_file->s->state.state.key_file_length, new_length);
}
state.dellink= HA_OFFSET_ERROR;
state.version=(ulong) time((time_t*) 0);
=== modified file 'storage/myisam/rt_mbr.c'
--- a/storage/myisam/rt_mbr.c 2007-10-05 10:43:15 +0000
+++ b/storage/myisam/rt_mbr.c 2011-05-12 12:35:00 +0000
@@ -325,8 +325,8 @@ int rtree_d_mbr(HA_KEYSEG *keyseg, uchar
bmin = korr_func(b); \
amax = korr_func(a+len); \
bmax = korr_func(b+len); \
- amin = min(amin, bmin); \
- amax = max(amax, bmax); \
+ amin = MY_MIN(amin, bmin); \
+ amax = MY_MAX(amax, bmax); \
store_func(c, amin); \
store_func(c+len, amax); \
}
@@ -338,8 +338,8 @@ int rtree_d_mbr(HA_KEYSEG *keyseg, uchar
get_func(bmin, b); \
get_func(amax, a+len); \
get_func(bmax, b+len); \
- amin = min(amin, bmin); \
- amax = max(amax, bmax); \
+ amin = MY_MIN(amin, bmin); \
+ amax = MY_MAX(amax, bmax); \
store_func(c, amin); \
store_func(c+len, amax); \
}
@@ -417,8 +417,8 @@ int rtree_combine_rect(HA_KEYSEG *keyseg
bmin = korr_func(b); \
amax = korr_func(a+len); \
bmax = korr_func(b+len); \
- amin = max(amin, bmin); \
- amax = min(amax, bmax); \
+ amin = MY_MAX(amin, bmin); \
+ amax = MY_MIN(amax, bmax); \
if (amin >= amax) \
return 0; \
res *= amax - amin; \
@@ -431,8 +431,8 @@ int rtree_combine_rect(HA_KEYSEG *keyseg
get_func(bmin, b); \
get_func(amax, a+len); \
get_func(bmax, b+len); \
- amin = max(amin, bmin); \
- amax = min(amax, bmax); \
+ amin = MY_MAX(amin, bmin); \
+ amax = MY_MIN(amax, bmax); \
if (amin >= amax) \
return 0; \
res *= amax - amin; \
@@ -508,7 +508,7 @@ double rtree_overlapping_area(HA_KEYSEG
amax = korr_func(a+len); \
bmax = korr_func(b+len); \
a_area *= (((double)amax) - ((double)amin)); \
- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
+ loc_ab_area *= ((double)MY_MAX(amax, bmax) - (double)MY_MIN(amin, bmin)); \
}
#define RT_AREA_INC_GET(type, get_func, len)\
@@ -519,7 +519,7 @@ double rtree_overlapping_area(HA_KEYSEG
get_func(amax, a+len); \
get_func(bmax, b+len); \
a_area *= (((double)amax) - ((double)amin)); \
- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
+ loc_ab_area *= ((double)MY_MAX(amax, bmax) - (double)MY_MIN(amin, bmin)); \
}
/*
@@ -604,7 +604,7 @@ safe_end:
amax = korr_func(a+len); \
bmax = korr_func(b+len); \
a_perim+= (((double)amax) - ((double)amin)); \
- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
+ *ab_perim+= ((double)MY_MAX(amax, bmax) - (double)MY_MIN(amin, bmin)); \
}
#define RT_PERIM_INC_GET(type, get_func, len)\
@@ -615,7 +615,7 @@ safe_end:
get_func(amax, a+len); \
get_func(bmax, b+len); \
a_perim+= (((double)amax) - ((double)amin)); \
- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
+ *ab_perim+= ((double)MY_MAX(amax, bmax) - (double)MY_MIN(amin, bmin)); \
}
/*
=== modified file 'storage/myisam/sort.c'
--- a/storage/myisam/sort.c 2011-01-11 09:09:21 +0000
+++ b/storage/myisam/sort.c 2011-05-12 12:35:00 +0000
@@ -129,7 +129,7 @@ int _create_index_by_sort(MI_SORT_PARAM
sort_keys= (uchar **) NULL; error= 1;
maxbuffer=1;
- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
+ memavl= MY_MAX(sortbuff_size, MIN_SORT_BUFFER);
records= info->sort_info->max_records;
sort_length= info->key_length;
LINT_INIT(keys);
@@ -344,7 +344,7 @@ pthread_handler_t thr_find_all_keys(void
bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
sort_keys= (uchar **) NULL;
- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
+ memavl= MY_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
idx= (uint)sort_param->sort_info->max_records;
sort_length= sort_param->key_length;
maxbuffer= 1;
@@ -813,7 +813,7 @@ static uint read_to_buffer(IO_CACHE *fro
register uint count;
uint length;
- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
+ if ((count=(uint) MY_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
{
if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base,
(length= sort_length*count),
@@ -835,7 +835,7 @@ static uint read_to_buffer_varlen(IO_CAC
uint idx;
uchar *buffp;
- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
+ if ((count=(uint) MY_MIN((ha_rows) buffpek->max_keys, buffpek->count)))
{
buffp = buffpek->base;
=== modified file 'storage/myisammrg/ha_myisammrg.cc'
--- a/storage/myisammrg/ha_myisammrg.cc 2011-04-23 20:44:45 +0000
+++ b/storage/myisammrg/ha_myisammrg.cc 2011-05-12 12:35:00 +0000
@@ -101,6 +101,11 @@
#include "sql_class.h" // THD
#include "debug_sync.h"
+#include <algorithm>
+
+using std::min;
+using std::max;
+
static handler *myisammrg_create_handler(handlerton *hton,
TABLE_SHARE *table,
MEM_ROOT *mem_root)
=== modified file 'strings/ctype-big5.c'
--- a/strings/ctype-big5.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-big5.c 2011-05-12 12:35:00 +0000
@@ -877,7 +877,7 @@ static int my_strnncoll_big5(const CHARS
const uchar *b, size_t b_length,
my_bool b_is_prefix)
{
- size_t length= min(a_length, b_length);
+ size_t length= MY_MIN(a_length, b_length);
int res= my_strnncoll_big5_internal(&a, &b, length);
return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
}
@@ -890,7 +890,7 @@ static int my_strnncollsp_big5(const CHA
const uchar *b, size_t b_length,
my_bool diff_if_only_endspace_difference)
{
- size_t length= min(a_length, b_length);
+ size_t length= MY_MIN(a_length, b_length);
int res= my_strnncoll_big5_internal(&a, &b, length);
#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
=== modified file 'strings/ctype-bin.c'
--- a/strings/ctype-bin.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-bin.c 2011-05-12 12:35:00 +0000
@@ -79,7 +79,7 @@ static int my_strnncoll_binary(const CHA
const uchar *t, size_t tlen,
my_bool t_is_prefix)
{
- size_t len=min(slen,tlen);
+ size_t len= MY_MIN(slen,tlen);
int cmp= memcmp(s,t,len);
return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
}
@@ -132,7 +132,7 @@ static int my_strnncoll_8bit_bin(const C
const uchar *t, size_t tlen,
my_bool t_is_prefix)
{
- size_t len=min(slen,tlen);
+ size_t len=MY_MIN(slen,tlen);
int cmp= memcmp(s,t,len);
return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
}
@@ -177,7 +177,7 @@ static int my_strnncollsp_8bit_bin(const
diff_if_only_endspace_difference= 0;
#endif
- end= a + (length= min(a_length, b_length));
+ end= a + (length= MY_MIN(a_length, b_length));
while (a < end)
{
if (*a++ != *b++)
=== modified file 'strings/ctype-gbk.c'
--- a/strings/ctype-gbk.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-gbk.c 2011-05-12 12:35:00 +0000
@@ -3480,7 +3480,7 @@ int my_strnncoll_gbk(const CHARSET_INFO
const uchar *b, size_t b_length,
my_bool b_is_prefix)
{
- size_t length= min(a_length, b_length);
+ size_t length= MY_MIN(a_length, b_length);
int res= my_strnncoll_gbk_internal(&a, &b, length);
return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
}
@@ -3491,7 +3491,7 @@ static int my_strnncollsp_gbk(const CHAR
const uchar *b, size_t b_length,
my_bool diff_if_only_endspace_difference)
{
- size_t length= min(a_length, b_length);
+ size_t length= MY_MIN(a_length, b_length);
int res= my_strnncoll_gbk_internal(&a, &b, length);
#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
=== modified file 'strings/ctype-mb.c'
--- a/strings/ctype-mb.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-mb.c 2011-05-12 12:35:00 +0000
@@ -473,7 +473,7 @@ my_strnncoll_mb_bin(const CHARSET_INFO *
const uchar *t, size_t tlen,
my_bool t_is_prefix)
{
- size_t len=min(slen,tlen);
+ size_t len= MY_MIN(slen,tlen);
int cmp= memcmp(s,t,len);
return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
}
@@ -518,7 +518,7 @@ my_strnncollsp_mb_bin(const CHARSET_INFO
diff_if_only_endspace_difference= 0;
#endif
- end= a + (length= min(a_length, b_length));
+ end= a + (length= MY_MIN(a_length, b_length));
while (a < end)
{
if (*a++ != *b++)
=== modified file 'strings/ctype-simple.c'
--- a/strings/ctype-simple.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-simple.c 2011-05-12 12:35:00 +0000
@@ -79,7 +79,7 @@ my_strnxfrm_simple(const CHARSET_INFO *c
uchar *map= cs->sort_order;
uchar *d0= dst;
uint frmlen;
- if ((frmlen= min(dstlen, nweights)) > srclen)
+ if ((frmlen= MY_MIN(dstlen, nweights)) > srclen)
frmlen= srclen;
if (dst != src)
{
@@ -161,7 +161,7 @@ int my_strnncollsp_simple(const CHARSET_
diff_if_only_endspace_difference= 0;
#endif
- end= a + (length= min(a_length, b_length));
+ end= a + (length= MY_MIN(a_length, b_length));
while (a < end)
{
if (map[*a++] != map[*b++])
@@ -766,7 +766,7 @@ size_t my_long10_to_str_8bit(const CHARS
val= new_val;
}
- len= min(len, (size_t) (e-p));
+ len= MY_MIN(len, (size_t) (e-p));
memcpy(dst, p, len);
return len+sign;
}
@@ -821,7 +821,7 @@ size_t my_longlong10_to_str_8bit(const C
long_val= quo;
}
- len= min(len, (size_t) (e-p));
+ len= MY_MIN(len, (size_t) (e-p));
cnv:
memcpy(dst, p, len);
return len+sign;
@@ -1053,7 +1053,7 @@ size_t my_well_formed_len_8bit(const CHA
{
size_t nbytes= (size_t) (end-start);
*error= 0;
- return min(nbytes, nchars);
+ return MY_MIN(nbytes, nchars);
}
@@ -1715,7 +1715,7 @@ uint my_strxfrm_flag_normalize(uint flag
uint src_bit= 1 << i;
if (flag_lev & src_bit)
{
- uint dst_bit= 1 << min(i, maximum);
+ uint dst_bit= 1 << MY_MIN(i, maximum);
flags|= dst_bit;
flags|= (flag_dsc & dst_bit) << MY_STRXFRM_DESC_SHIFT;
flags|= (flag_rev & dst_bit) << MY_STRXFRM_REVERSE_SHIFT;
@@ -1797,7 +1797,7 @@ my_strxfrm_pad_desc_and_reverse(const CH
{
if (nweights && frmend < strend && (flags & MY_STRXFRM_PAD_WITH_SPACE))
{
- uint fill_length= min((uint) (strend - frmend), nweights * cs->mbminlen);
+ uint fill_length= MY_MIN((uint) (strend - frmend), nweights * cs->mbminlen);
cs->cset->fill(cs, (char*) frmend, fill_length, cs->pad_char);
frmend+= fill_length;
}
=== modified file 'strings/ctype-tis620.c'
--- a/strings/ctype-tis620.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-tis620.c 2011-05-12 12:35:00 +0000
@@ -581,7 +581,7 @@ int my_strnncollsp_tis620(const CHARSET_
a_length= thai2sortable(a, a_length);
b_length= thai2sortable(b, b_length);
- end= a + (length= min(a_length, b_length));
+ end= a + (length= MY_MIN(a_length, b_length));
while (a < end)
{
if (*a++ != *b++)
@@ -638,7 +638,7 @@ my_strnxfrm_tis620(const CHARSET_INFO *c
const uchar *src, size_t srclen, uint flags)
{
size_t len, dstlen0= dstlen;
- len= (uint) (strmake((char*) dst, (char*) src, min(dstlen, srclen)) -
+ len= (uint) (strmake((char*) dst, (char*) src, MY_MIN(dstlen, srclen)) -
(char*) dst);
len= thai2sortable(dst, len);
set_if_smaller(dstlen, nweights);
=== modified file 'strings/ctype-uca.c'
--- a/strings/ctype-uca.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-uca.c 2011-05-12 12:35:00 +0000
@@ -20283,7 +20283,7 @@ my_strnxfrm_uca(const CHARSET_INFO *cs,
if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
{
- uint space_count= min((uint) (de - dst) / 2, nweights);
+ uint space_count= MY_MIN((uint) (de - dst) / 2, nweights);
s_res= my_space_weight(cs);
for (; space_count ; space_count--)
{
@@ -20645,7 +20645,7 @@ static void my_coll_lexem_print_error(MY
{
char tail[30];
size_t len= lexem->end - lexem->prev;
- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
+ strmake (tail, lexem->prev, (size_t) MY_MIN(len, sizeof(tail)-1));
errstr[errsize-1]= '\0';
my_snprintf(errstr, errsize - 1,
"%s at '%s'", txt[0] ? txt : "Syntax error", tail);
=== modified file 'strings/ctype-ucs2.c'
--- a/strings/ctype-ucs2.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-ucs2.c 2011-05-12 12:35:00 +0000
@@ -57,7 +57,7 @@ my_bincmp(const uchar *s, const uchar *s
const uchar *t, const uchar *te)
{
int slen= (int) (se - s), tlen= (int) (te - t);
- int len= min(slen, tlen);
+ int len= MY_MIN(slen, tlen);
int cmp= memcmp(s, t, len);
return cmp ? cmp : slen - tlen;
}
@@ -2649,7 +2649,7 @@ my_strnncollsp_utf32_bin(const CHARSET_I
se= s + slen;
te= t + tlen;
- for (minlen= min(slen, tlen); minlen; minlen-= 4)
+ for (minlen= MY_MIN(slen, tlen); minlen; minlen-= 4)
{
my_wc_t s_wc= my_utf32_get(s);
my_wc_t t_wc= my_utf32_get(t);
@@ -3109,7 +3109,7 @@ static int my_strnncollsp_ucs2(const CHA
se= s + slen;
te= t + tlen;
- for (minlen= min(slen, tlen); minlen; minlen-= 2)
+ for (minlen= MY_MIN(slen, tlen); minlen; minlen-= 2)
{
int s_wc = uni_plane->page[s[0]] ? (int) uni_plane->page[s[0]][s[1]].sort :
(((int) s[0]) << 8) + (int) s[1];
@@ -3186,7 +3186,7 @@ size_t my_well_formed_len_ucs2(const CHA
size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
*error= 0;
nchars*= 2;
- return min(nbytes, nchars);
+ return MY_MIN(nbytes, nchars);
}
@@ -3262,7 +3262,7 @@ static int my_strnncollsp_ucs2_bin(const
se= s + slen;
te= t + tlen;
- for (minlen= min(slen, tlen); minlen; minlen-= 2)
+ for (minlen= MY_MIN(slen, tlen); minlen; minlen-= 2)
{
int s_wc= s[0] * 256 + s[1];
int t_wc= t[0] * 256 + t[1];
=== modified file 'strings/ctype-utf8.c'
--- a/strings/ctype-utf8.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype-utf8.c 2011-05-12 12:35:00 +0000
@@ -5082,7 +5082,7 @@ static inline int bincmp(const uchar *s,
const uchar *t, const uchar *te)
{
int slen= (int) (se-s), tlen= (int) (te-t);
- int len=min(slen,tlen);
+ int len= MY_MIN(slen,tlen);
int cmp= memcmp(s,t,len);
return cmp ? cmp : slen-tlen;
}
@@ -7539,7 +7539,7 @@ bincmp_utf8mb4(const uchar *s, const uch
const uchar *t, const uchar *te)
{
int slen= (int) (se - s), tlen= (int) (te - t);
- int len= min(slen, tlen);
+ int len= MY_MIN(slen, tlen);
int cmp= memcmp(s, t, len);
return cmp ? cmp : slen - tlen;
}
=== modified file 'strings/ctype.c'
--- a/strings/ctype.c 2011-03-09 20:54:55 +0000
+++ b/strings/ctype.c 2011-05-12 12:35:00 +0000
@@ -1035,7 +1035,7 @@ my_convert(char *to, uint32 to_length, c
return my_convert_internal(to, to_length, to_cs,
from, from_length, from_cs, errors);
- length= length2= min(to_length, from_length);
+ length= length2= MY_MIN(to_length, from_length);
#if defined(__i386__)
/*
=== modified file 'strings/decimal.c'
--- a/strings/decimal.c 2011-03-03 14:25:41 +0000
+++ b/strings/decimal.c 2011-05-12 12:35:00 +0000
@@ -395,7 +395,7 @@ int decimal2string(const decimal_t *from
for (; frac>0; frac-=DIG_PER_DEC1)
{
dec1 x=*buf++;
- for (i=min(frac, DIG_PER_DEC1); i; i--)
+ for (i= MY_MIN(frac, DIG_PER_DEC1); i; i--)
{
dec1 y=x/DIG_MASK;
*s1++='0'+(uchar)y;
@@ -418,7 +418,7 @@ int decimal2string(const decimal_t *from
for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
{
dec1 x=*--buf;
- for (i=min(intg, DIG_PER_DEC1); i; i--)
+ for (i= MY_MIN(intg, DIG_PER_DEC1); i; i--)
{
dec1 y=x/10;
*--s='0'+(uchar)(x-y*10);
@@ -1498,8 +1498,8 @@ decimal_round(const decimal_t *from, dec
if (to != from || intg1>intg0)
{
- dec1 *p0= buf0+intg0+max(frac1, frac0);
- dec1 *p1= buf1+intg1+max(frac1, frac0);
+ dec1 *p0= buf0 + intg0 + MY_MAX(frac1, frac0);
+ dec1 *p1= buf1 + intg1 + MY_MAX(frac1, frac0);
while (buf0 < p0)
*(--p1) = *(--p0);
@@ -1510,7 +1510,7 @@ decimal_round(const decimal_t *from, dec
buf0=to->buf;
buf1=to->buf;
to->sign=from->sign;
- to->intg=min(intg0, len)*DIG_PER_DEC1;
+ to->intg= MY_MIN(intg0, len) * DIG_PER_DEC1;
}
if (frac0 > frac1)
@@ -1612,7 +1612,7 @@ decimal_round(const decimal_t *from, dec
scale=frac0*DIG_PER_DEC1;
error=E_DEC_TRUNCATED; /* XXX */
}
- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
+ for (buf1=to->buf + intg0 + MY_MAX(frac0, 0); buf1 > to->buf; buf1--)
{
buf1[0]=buf1[-1];
}
@@ -1631,7 +1631,7 @@ decimal_round(const decimal_t *from, dec
/* making 'zero' with the proper scale */
dec1 *p0= to->buf + frac0 + 1;
to->intg=1;
- to->frac= max(scale, 0);
+ to->frac= MY_MAX(scale, 0);
to->sign= 0;
for (buf1= to->buf; buf1<p0; buf1++)
*buf1= 0;
@@ -1680,11 +1680,11 @@ int decimal_result_size(decimal_t *from1
{
switch (op) {
case '-':
- return ROUND_UP(max(from1->intg, from2->intg)) +
- ROUND_UP(max(from1->frac, from2->frac));
+ return ROUND_UP(MY_MAX(from1->intg, from2->intg)) +
+ ROUND_UP(MY_MAX(from1->frac, from2->frac));
case '+':
- return ROUND_UP(max(from1->intg, from2->intg)+1) +
- ROUND_UP(max(from1->frac, from2->frac));
+ return ROUND_UP(MY_MAX(from1->intg, from2->intg)+1) +
+ ROUND_UP(MY_MAX(from1->frac, from2->frac));
case '*':
return ROUND_UP(from1->intg+from2->intg)+
ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
@@ -1699,7 +1699,7 @@ static int do_add(const decimal_t *from1
{
int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
+ frac0= MY_MAX(frac1, frac2), intg0= MY_MAX(intg1, intg2), error;
dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
sanity(to);
@@ -1724,7 +1724,7 @@ static int do_add(const decimal_t *from1
buf0=to->buf+intg0+frac0;
to->sign=from1->sign;
- to->frac=max(from1->frac, from2->frac);
+ to->frac= MY_MAX(from1->frac, from2->frac);
to->intg=intg0*DIG_PER_DEC1;
if (unlikely(error))
{
@@ -1781,7 +1781,7 @@ static int do_sub(const decimal_t *from1
{
int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
- int frac0=max(frac1, frac2), error;
+ int frac0= MY_MAX(frac1, frac2), error;
dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
/* let carry:=1 if from2 > from1 */
@@ -1856,7 +1856,7 @@ static int do_sub(const decimal_t *from1
FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
buf0=to->buf+intg1+frac0;
- to->frac=max(from1->frac, from2->frac);
+ to->frac= MY_MAX(from1->frac, from2->frac);
to->intg=intg1*DIG_PER_DEC1;
if (unlikely(error))
{
@@ -2158,7 +2158,7 @@ static int do_div_mod(const decimal_t *f
intg=intg2
*/
to->sign=from1->sign;
- to->frac=max(from1->frac, from2->frac);
+ to->frac= MY_MAX(from1->frac, from2->frac);
frac0=0;
}
else
@@ -2323,7 +2323,7 @@ static int do_div_mod(const decimal_t *f
}
DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
stop1=start1+frac0+intg0;
- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
+ to->intg= MY_MIN(intg0 * DIG_PER_DEC1, from2->intg);
}
if (unlikely(intg0+frac0 > to->len))
{
=== modified file 'strings/dtoa.c'
--- a/strings/dtoa.c 2011-01-19 13:35:54 +0000
+++ b/strings/dtoa.c 2011-05-12 12:35:00 +0000
@@ -133,7 +133,7 @@ size_t my_fcvt(double x, int precision,
if (len <= decpt)
*dst++= '.';
- for (i= precision - max(0, (len - decpt)); i > 0; i--)
+ for (i= precision - MY_MAX(0, (len - decpt)); i > 0; i--)
*dst++= '0';
}
@@ -222,7 +222,7 @@ size_t my_gcvt(double x, my_gcvt_arg_typ
if (x < 0.)
width--;
- res= dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : min(width, FLT_DIG),
+ res= dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : MY_MIN(width, FLT_DIG),
&decpt, &sign, &end, buf, sizeof(buf));
if (decpt == DTOA_OVERFLOW)
{
=== modified file 'strings/my_vsnprintf.c'
--- a/strings/my_vsnprintf.c 2011-03-09 20:54:55 +0000
+++ b/strings/my_vsnprintf.c 2011-05-12 12:35:00 +0000
@@ -231,7 +231,7 @@ static char *process_dbl_arg(char *to, c
width= FLT_DIG; /* width not set, use default */
else if (width >= NOT_FIXED_DEC)
width= NOT_FIXED_DEC - 1; /* max.precision for my_fcvt() */
- width= min(width, (size_t)(end-to) - 1);
+ width= MY_MIN(width, (size_t)(end-to) - 1);
if (arg_type == 'f')
to+= my_fcvt(par, (int)width , to, NULL);
@@ -280,7 +280,7 @@ static char *process_int_arg(char *to, c
/* If %#d syntax was used, we have to pre-zero/pre-space the string */
if (store_start == buff)
{
- length= min(length, to_length);
+ length= MY_MIN(length, to_length);
if (res_length < length)
{
size_t diff= (length- res_length);
@@ -344,7 +344,7 @@ start:
DBUG_ASSERT(*fmt == '$' && print_arr[idx].length < MAX_ARGS);
args_arr[print_arr[idx].length].arg_type= 'd';
print_arr[idx].flags|= LENGTH_ARG;
- arg_count= max(arg_count, print_arr[idx].length + 1);
+ arg_count= MY_MAX(arg_count, print_arr[idx].length + 1);
fmt++;
}
else
@@ -362,7 +362,7 @@ start:
DBUG_ASSERT(*fmt == '$' && print_arr[idx].width < MAX_ARGS);
args_arr[print_arr[idx].width].arg_type= 'd';
print_arr[idx].flags|= WIDTH_ARG;
- arg_count= max(arg_count, print_arr[idx].width + 1);
+ arg_count= MY_MAX(arg_count, print_arr[idx].width + 1);
fmt++;
}
else
@@ -490,7 +490,7 @@ start:
if (to == end)
break;
- length= min(end - to , print_arr[i].end - print_arr[i].begin);
+ length= MY_MIN(end - to , print_arr[i].end - print_arr[i].begin);
if (to + length < end)
length++;
to= strnmov(to, print_arr[i].begin, length);
@@ -510,7 +510,7 @@ start:
fmt= get_width(fmt, &arg_index);
DBUG_ASSERT(*fmt == '$');
fmt++;
- arg_count= max(arg_count, arg_index);
+ arg_count= MY_MAX(arg_count, arg_index);
goto start;
}
=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c 2011-03-22 12:06:52 +0000
+++ b/tests/mysql_client_test.c 2011-05-12 12:35:00 +0000
@@ -625,7 +625,7 @@ static int my_process_stmt_result(MYSQL_
return row_count;
}
- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
+ field_count= MY_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
bzero((char*) buffer, sizeof(buffer));
bzero((char*) length, sizeof(length));
=== modified file 'vio/viosocket.c'
--- a/vio/viosocket.c 2011-04-29 21:48:23 +0000
+++ b/vio/viosocket.c 2011-05-12 12:35:00 +0000
@@ -73,7 +73,7 @@ size_t vio_read_buff(Vio *vio, uchar* bu
if (vio->read_pos < vio->read_end)
{
- rc= min((size_t) (vio->read_end - vio->read_pos), size);
+ rc= MY_MIN((size_t) (vio->read_end - vio->read_pos), size);
memcpy(buf, vio->read_pos, rc);
vio->read_pos+= rc;
/*
Attachment: [text/bzr-bundle] bzr/mats.kindahl@oracle.com-20110512123500-bcw365wcgggdpy6c.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk branch (mats.kindahl:3364) WL#5825 | Mats Kindahl | 12 May |