Index: driver/results.c =================================================================== --- driver/results.c (revision 1027) +++ driver/results.c (working copy) @@ -1107,7 +1107,7 @@ uint length= 0; DESCREC *irrec, *arrec; - for (i= 0; i < min(stmt->ird->count, stmt->ard->count); ++i, ++values) + for (i= 0; i < myodbc_min(stmt->ird->count, stmt->ard->count); ++i, ++values) { irrec= desc_get_rec(stmt->ird, i, FALSE); arrec= desc_get_rec(stmt->ard, i, FALSE); @@ -1294,7 +1294,7 @@ } stmt->current_row= cur_row; - rows_to_fetch= min(max_row-cur_row, (long)stmt->ard->array_size); + rows_to_fetch= myodbc_min(max_row-cur_row, (long)stmt->ard->array_size); if ( !rows_to_fetch ) { *pcrow= 0; Index: driver/execute.c =================================================================== --- driver/execute.c (revision 1027) +++ driver/execute.c (working copy) @@ -281,7 +281,7 @@ if (!octet_length_ptr && aprec->octet_length > 0 && aprec->octet_length != SQL_SETPARAM_VALUE_MAX) - length= min(length, aprec->octet_length); + length= myodbc_min(length, aprec->octet_length); } else { Index: driver/utility.c =================================================================== --- driver/utility.c (revision 1027) +++ driver/utility.c (working copy) @@ -138,7 +138,7 @@ irrec->precision= (SQLSMALLINT) irrec->length; break; } - irrec->scale= max(0, (SQLSMALLINT) get_decimal_digits(stmt, field)); + irrec->scale= myodbc_max(0, (SQLSMALLINT) get_decimal_digits(stmt, field)); if ((field->flags & NOT_NULL_FLAG) && !(field->flags & TIMESTAMP_FLAG) && !(field->flags & AUTO_INCREMENT_FLAG)) @@ -314,7 +314,7 @@ if ( rgbValue ) strmake((char*) rgbValue, src, cbValueMax); - if ( min(*pcbValue , cbValueMax) != *pcbValue ) + if ( myodbc_min(*pcbValue , cbValueMax) != *pcbValue ) return SQL_SUCCESS_WITH_INFO; return SQL_SUCCESS; } @@ -364,7 +364,7 @@ return SQL_NO_DATA_FOUND; } - copy_bytes= min((unsigned long)result_bytes, src_bytes); + copy_bytes= myodbc_min((unsigned long)result_bytes, src_bytes); if (result) memcpy(result, src, copy_bytes); @@ -439,7 +439,7 @@ field, src, src_bytes); if (SQL_SUCCEEDED(rc) && result) - result[min(*avail_bytes, result_bytes)]= '\0'; + result[myodbc_min(*avail_bytes, result_bytes)]= '\0'; return rc; } @@ -478,8 +478,9 @@ */ if (stmt->getdata.latest_bytes) { - int new_bytes= min(stmt->getdata.latest_bytes - stmt->getdata.latest_used, - result_end - result); + int new_bytes= myodbc_min(stmt->getdata.latest_bytes - + stmt->getdata.latest_used, + result_end - result); memcpy(result, stmt->getdata.latest + stmt->getdata.latest_used, new_bytes); if (new_bytes + stmt->getdata.latest_used == stmt->getdata.latest_bytes) stmt->getdata.latest_bytes= 0; @@ -569,8 +570,8 @@ stmt->getdata.latest + sizeof(stmt->getdata.latest)); - stmt->getdata.latest_used= min(stmt->getdata.latest_bytes, - result_end - result); + stmt->getdata.latest_used= myodbc_min(stmt->getdata.latest_bytes, + result_end - result); memcpy(result, stmt->getdata.latest, stmt->getdata.latest_used); result+= stmt->getdata.latest_used; *result= '\0'; @@ -611,8 +612,9 @@ *avail_bytes= used_bytes; } - stmt->getdata.dst_offset+= min((ulong)(result_bytes ? result_bytes - 1 : 0), - used_bytes); + stmt->getdata.dst_offset+= myodbc_min((ulong)(result_bytes ? + result_bytes - 1 : 0), + used_bytes); /* Did we truncate the data? */ if (!result_bytes || stmt->getdata.dst_bytes > stmt->getdata.dst_offset) @@ -829,8 +831,9 @@ *avail_bytes= used_chars * sizeof(SQLWCHAR); } - stmt->getdata.dst_offset+= min((ulong)(result_len ? result_len - 1 : 0), - used_chars) * sizeof(SQLWCHAR); + stmt->getdata.dst_offset+= myodbc_min((ulong)(result_len ? + result_len - 1 : 0), + used_chars) * sizeof(SQLWCHAR); /* Did we truncate the data? */ if (!result_len || stmt->getdata.dst_bytes > stmt->getdata.dst_offset) @@ -885,7 +888,7 @@ src+= *offset; src_length-= *offset; length= cbValueMax ? (ulong)(cbValueMax-1)/2 : 0; - length= min(src_length,length); + length= myodbc_min(src_length,length); (*offset)+= length; /* Fix for next call */ if ( pcbValue ) *pcbValue= src_length*2; Index: driver/unicode.c =================================================================== --- driver/unicode.c (revision 1027) +++ driver/unicode.c (working copy) @@ -102,7 +102,7 @@ if (char_attr_max > 0) { - len= min(len, char_attr_max - 1); + len= myodbc_min(len, char_attr_max - 1); (void)memcpy((char *)char_attr, (const char *)wvalue, len * sizeof(SQLWCHAR)); ((SQLWCHAR *)char_attr)[len]= 0; @@ -275,7 +275,7 @@ if (name_max > 0) { - len= min(len, name_max - 1); + len= myodbc_min(len, name_max - 1); (void)memcpy((char *)name, (const char *)wvalue, len * sizeof(SQLWCHAR)); ((SQLWCHAR *)name)[len]= 0; @@ -432,7 +432,7 @@ if (value_max > 0) { - len= min(len, value_max - 1); + len= myodbc_min(len, value_max - 1); (void)memcpy((char *)value, (const char *)wvalue, len * sizeof(SQLWCHAR)); ((SQLWCHAR *)value)[len]= 0; @@ -481,7 +481,7 @@ if (cursor_max > 0) { - len= min(len, cursor_max - 1); + len= myodbc_min(len, cursor_max - 1); (void)memcpy((char *)cursor, (const char *)name, len * sizeof(SQLWCHAR)); cursor[len]= 0; } @@ -539,7 +539,7 @@ if (info_max > 0) { - len= min(len, info_max - 1); + len= myodbc_min(len, info_max - 1); (void)memcpy((char *)info, (const char *)wvalue, len * sizeof(SQLWCHAR)); ((SQLWCHAR *)info)[len]= 0; @@ -611,7 +611,7 @@ if (message_max > 0) { - len= min(len, message_max - 1); + len= myodbc_min(len, message_max - 1); (void)memcpy((char *)message, (const char *)wvalue, len * sizeof(SQLWCHAR)); ((SQLWCHAR *)message)[len]= 0; @@ -679,7 +679,7 @@ if (value && value_max > 0) { - len= min(len, value_max - 1); + len= myodbc_min(len, value_max - 1); (void)memcpy((char *)value, (const char *)wvalue, len * sizeof(SQLWCHAR)); ((SQLWCHAR *)value)[len]= 0; Index: driver/connect.c =================================================================== --- driver/connect.c (revision 1027) +++ driver/connect.c (working copy) @@ -783,7 +783,7 @@ if (!bPrompt) { size_t inlen= (sqlwcharlen(szConnStrIn) + 1) * sizeof(SQLWCHAR); - size_t copylen= min((size_t)cbConnStrOutMax, inlen); + size_t copylen= myodbc_min((size_t)cbConnStrOutMax, inlen); memcpy(szConnStrOut, szConnStrIn, copylen); if (pcbConnStrOut) *pcbConnStrOut= copylen / sizeof(SQLWCHAR); Index: util/stringutil.h =================================================================== --- util/stringutil.h (revision 1027) +++ util/stringutil.h (working copy) @@ -42,6 +42,9 @@ #define x_free(A) { void *tmp= (A); if (tmp) my_free((char *) tmp,MYF(MY_WME+MY_FAE)); } #endif +#define myodbc_min(a, b) ((a) < (b) ? (a) : (b)) +#define myodbc_max(a, b) ((a) > (b) ? (a) : (b)) + #define MAX_BYTES_PER_UTF8_CP 4 /* max 4 bytes per utf8 codepoint */ /* Unicode transcoding */ Index: util/MYODBCUtilReadDataSourceStr.c =================================================================== --- util/MYODBCUtilReadDataSourceStr.c (revision 1027) +++ util/MYODBCUtilReadDataSourceStr.c (working copy) @@ -29,7 +29,7 @@ if ( !s ) return 0; - nAvail = min( strlen(s) + 1, n + 1 ); + nAvail = myodbc_min( strlen(s) + 1, n + 1 ); if ( nAvail < 1 ) return 0; @@ -63,7 +63,7 @@ if ( !s ) return 0; - nAvail = min( strlen(s) + 1, n + 1 ); + nAvail = myodbc_min( strlen(s) + 1, n + 1 ); if ( nAvail < 1 ) return 0; Index: util/MYODBCUtil.h =================================================================== --- util/MYODBCUtil.h (revision 1027) +++ util/MYODBCUtil.h (working copy) @@ -56,9 +56,9 @@ #define TRUE 1 #endif -#ifndef max -#define max( a, b ) (((a) > (b)) ? (a) : (b)) -#define min( a, b ) (((a) < (b)) ? (a) : (b)) +#ifndef myodbc_max +#define myodbc_max( a, b ) (((a) > (b)) ? (a) : (b)) +#define myodbc_min( a, b ) (((a) < (b)) ? (a) : (b)) #endif /* Could use DRIVER_NAME but trying to keep dependency upon driver specific code to a min */