summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2004-08-11 23:43:41 +0200
committerunknown <serg@serg.mylan>2004-08-11 23:43:41 +0200
commitab64eb64af00da22dad43bb4ea4f0d2dfe51438a (patch)
treecb3466f5256ace6feed99a096cd0650291457637 /sql
parentc7a29120ee1a3100d5cbb66775e0ffea1bab0f9d (diff)
downloadmariadb-git-ab64eb64af00da22dad43bb4ea4f0d2dfe51438a.tar.gz
Bug #4797 - 32 bit and 64 bit builds behave differently on int32 overflow
include/my_global.h: uint_max constants moved from sql_analyse.cc sql/sql_analyse.cc: cleanup
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc29
-rw-r--r--sql/sql_analyse.cc3
2 files changed, 27 insertions, 5 deletions
diff --git a/sql/field.cc b/sql/field.cc
index e3bdf78e718..946f5ed8621 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1504,7 +1504,7 @@ void Field_long::store(const char *from,uint len)
{
len--; from++;
}
- long tmp;
+ long tmp, cuted_fields=0;
String tmp_str(from,len);
from= tmp_str.c_ptr(); // Add end null if needed
errno=0;
@@ -1520,9 +1520,34 @@ void Field_long::store(const char *from,uint len)
}
else
tmp=strtol(from, &end, 10);
- if (errno ||
+ if (errno ||
(from+len != end && current_thd->count_cuted_fields &&
!test_if_int(from,len)))
+ cuted_fields=1;
+#if SIZEOF_LONG > 4
+ if (unsigned_flag)
+ {
+ if (tmp > UINT_MAX32)
+ {
+ tmp= UINT_MAX32;
+ cuted_fields=1;
+ }
+ }
+ else
+ {
+ if (tmp > INT_MAX32)
+ {
+ tmp= INT_MAX32;
+ cuted_fields=1;
+ }
+ else if (tmp < INT_MIN32)
+ {
+ tmp= INT_MIN32;
+ cuted_fields=1;
+ }
+ }
+#endif
+ if (cuted_fields)
current_thd->cuted_fields++;
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index bd8c0e5ba87..3847849d6a7 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -34,9 +34,6 @@
#define MAX_TREEMEM 8192
#define MAX_TREE_ELEMENTS 256
-#define UINT_MAX16 0xffff
-#define UINT_MAX24 0xffffff
-#define UINT_MAX32 0xffffffff
int sortcmp2(void* cmp_arg __attribute__((unused)),
const String *a,const String *b)