summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2005-02-12 16:27:22 +0400
committerunknown <bar@mysql.com>2005-02-12 16:27:22 +0400
commit36a1d4e1dc2ac205e3abdf33f54bbd5c640f9514 (patch)
treeaa6d8694606f182775199d4d1e5895786acdaf32 /sql/field.cc
parent3aeaea557f327d69b69d8134a40fed4ff818ad50 (diff)
downloadmariadb-git-36a1d4e1dc2ac205e3abdf33f54bbd5c640f9514.tar.gz
Bug#8235 Connection collation change & table create with default result in crash
mysql-test/r/ctype_ucs.result: Test case mysql-test/t/ctype_ucs.test: Test case sql/field.cc: Fixed minus check to be UCS2-compatible strings/ctype-ucs2.c: Missing my_scan_ucs2() was added.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/field.cc b/sql/field.cc
index e2f75034e52..fa0e202d513 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1777,6 +1777,14 @@ void Field_medium::sql_type(String &res) const
****************************************************************************/
+static bool test_if_minus(CHARSET_INFO *cs,
+ const char *s, const char *e)
+{
+ my_wc_t wc;
+ return cs->cset->mb_wc(cs, &wc, (uchar*) s, (uchar*) e) > 0 && wc == '-';
+}
+
+
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{
long tmp;
@@ -1790,7 +1798,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
if (unsigned_flag)
{
- if (!len || *from == '-')
+ if (!len || test_if_minus(cs, from, from + len))
{
tmp=0; // Set negative to 0
my_errno=ERANGE;
@@ -2086,7 +2094,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
my_errno=0;
if (unsigned_flag)
{
- if (!len || *from == '-')
+ if (!len || test_if_minus(cs, from, from + len))
{
tmp=0; // Set negative to 0
my_errno= ERANGE;