From a1017b09b4a76f3cb827bae318ab8785e65b341b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jun 2006 13:40:21 +0500 Subject: [PATCH 01/15] Bug#8663 cant use bgint unsigned as input to cast Problem: cast to unsigned limited result to max signed bigint 9223372036854775808, instead of max unsigned bigint 18446744073709551615. Fix: don't use args[0]->val_int() when casting from a floating point number, use val() instead, with range checkings, special to unsigned data type. item_func.cc: Special handling of cast from REAL_RESULT to unsigned int: we cannot execute args[0]->val_int() because it cuts max allowed value to LONGLONG_INT, instead of ULONGLONG_INT required. count_distinct3.test: Getting rid of "Data truncated; out of range ..." warnings. cast.test, cast.result: Adding test case. ps.result: Fixing that cast from 6570515219.6535 to unsigned didn't round to 6570515220, and returned 6570515219 instead. mysql-test/r/cast.result: Adding test case. mysql-test/r/ps.result: Fixing that cast from 6570515219.6535 to unsigned didn't round to 6570515220, and returned 6570515219 instead. mysql-test/t/cast.test: Adding test case. mysql-test/t/count_distinct3.test: Get rid of "wring unsigned value" warnings. sql/item_func.cc: Special handling of cast from REAL)RESULT to unsigned int: we cannot execute args[0]->val_int() because it cuts max allowed value to LONGLONG_INT, instead of ULONGLONG_INT required. --- mysql-test/r/cast.result | 3 +++ mysql-test/r/ps.result | 14 +++++++------- mysql-test/t/cast.test | 6 ++++++ mysql-test/t/count_distinct3.test | 2 ++ sql/item_func.cc | 20 ++++++++++++++++++++ 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 68687670e17..101b9ac3f7e 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -264,6 +264,9 @@ cast(repeat('1',20) as signed) -7335632962598440505 Warnings: Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement +select cast(19999999999999999999 as unsigned); +cast(19999999999999999999 as unsigned) +18446744073709551615 select cast(1.0e+300 as signed int); cast(1.0e+300 as signed int) 9223372036854775807 diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 2be5366b180..9a2e7bd262a 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -340,7 +340,7 @@ set @precision=10000000000; select rand(), cast(rand(10)*@precision as unsigned integer) from t1; rand() cast(rand(10)*@precision as unsigned integer) -- 6570515219 +- 6570515220 - 1282061302 - 6698761160 - 9647622201 @@ -351,23 +351,23 @@ prepare stmt from set @var=1; execute stmt using @var; rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer) -- 6570515219 - +- 6570515220 - - 1282061302 - - 6698761160 - - 9647622201 - set @var=2; execute stmt using @var; rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer) -- 6570515219 6555866465 -- 1282061302 1223466192 -- 6698761160 6449731873 +- 6570515220 6555866465 +- 1282061302 1223466193 +- 6698761160 6449731874 - 9647622201 8578261098 set @var=3; execute stmt using @var; rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer) -- 6570515219 9057697559 +- 6570515220 9057697560 - 1282061302 3730790581 -- 6698761160 1480860534 +- 6698761160 1480860535 - 9647622201 6211931236 drop table t1; deallocate prepare stmt; diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 4d73783dd52..b214cef10fa 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -147,6 +147,12 @@ select cast(concat('184467440','73709551615') as signed); select cast(repeat('1',20) as unsigned); select cast(repeat('1',20) as signed); +# +# Bug#8663 cant use bgint unsigned as input to cast +# +select cast(19999999999999999999 as unsigned); + + # # Bug #13344: cast of large decimal to signed int not handled correctly # diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test index 52a4f271dac..9c3e7f439c2 100644 --- a/mysql-test/t/count_distinct3.test +++ b/mysql-test/t/count_distinct3.test @@ -9,6 +9,7 @@ DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER); +--disable_warnings --disable_query_log SET @rnd_max= 2147483647; let $1 = 1000; @@ -43,6 +44,7 @@ INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; DROP TABLE t2; --enable_query_log +--enable_warnings SELECT COUNT(*) FROM t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index 66300d129d4..2ceedaa51c6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -508,6 +508,26 @@ longlong Item_func_unsigned::val_int() longlong value; int error; + if (args[0]->result_type() == REAL_RESULT) + { + double dvalue= args[0]->val(); + if ((null_value= args[0]->null_value)) + return 0; + if (dvalue <= (double) LONGLONG_MIN) + { + return LONGLONG_MIN; + } + if (dvalue >= (double) (ulonglong) ULONGLONG_MAX) + { + return (longlong) ULONGLONG_MAX; + } + if (dvalue >= (double) (ulonglong) LONGLONG_MAX) + { + return (ulonglong) (dvalue + (dvalue > 0 ? 0.5 : -0.5)); + } + return (longlong) (dvalue + (dvalue > 0 ? 0.5 : -0.5)); + } + if (args[0]->cast_to_int_type() != STRING_RESULT) { value= args[0]->val_int(); From 03d411b1d14560ca3b982c7cab2cb78530964806 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Jul 2006 13:41:12 +0500 Subject: [PATCH 02/15] Bug#6147: Traditional: Assigning a string to a numeric column has unexpected results The problem was that when converting a string to an exact number, rounding didn't work, because conversion didn't understand approximate numbers notation. Fix: a new function for string-to-number conversion was implemented, which is aware of approxinate number notation (with decimal point and exponent, e.g. -19.55e-1) include/m_ctype.h: Adding new function into MY_CHARSET_HANDLER Adding prototypes for 8bit and ucs2 functions. mysql-test/r/loaddata.result: Fixing results mysql-test/r/ps_2myisam.result: Fixing results mysql-test/r/ps_3innodb.result: Fixing results mysql-test/r/ps_4heap.result: Fixing results mysql-test/r/ps_5merge.result: Fixing results mysql-test/r/ps_6bdb.result: Fixing results mysql-test/r/rpl_rewrite_db.result: Fixing results mysql-test/r/select.result: Fixing results mysql-test/r/sp-vars.result: Fixing results mysql-test/r/strict.result: Fixing results mysql-test/r/view.result: Fixing results mysql-test/r/warnings.result: Fixing results mysql-test/t/strict.test: Fixing results sql/field.cc: Using new function strings/ctype-big5.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-bin.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-cp932.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-euc_kr.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-eucjpms.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-gb2312.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-gbk.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-latin1.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-simple.c: Implementing my_strntoull10_8bit Adding new function into MY_CHARSET_HANDLER strings/ctype-sjis.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-tis620.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-ucs2.c: Implementing UCS2 wrapper for 8bit version Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-ujis.c: Adding new function into the MY_CHARSET_HANDLER structure strings/ctype-utf8.c: Adding new function into the MY_CHARSET_HANDLER structure mysql-test/r/round.result: New BitKeeper file ``mysql-test/r/round.result'' mysql-test/t/round.test: New BitKeeper file ``mysql-test/t/round.test'' --- include/m_ctype.h | 10 + mysql-test/r/loaddata.result | 7 +- mysql-test/r/ps_2myisam.result | 48 ++-- mysql-test/r/ps_3innodb.result | 48 ++-- mysql-test/r/ps_4heap.result | 48 ++-- mysql-test/r/ps_5merge.result | 96 ++++---- mysql-test/r/ps_6bdb.result | 48 ++-- mysql-test/r/round.result | 272 +++++++++++++++++++++++ mysql-test/r/rpl_rewrite_db.result | 7 +- mysql-test/r/select.result | 2 +- mysql-test/r/sp-vars.result | 2 +- mysql-test/r/strict.result | 8 +- mysql-test/r/view.result | 4 +- mysql-test/r/warnings.result | 60 ++--- mysql-test/t/round.test | 145 +++++++++++++ mysql-test/t/strict.test | 8 +- sql/field.cc | 193 +++++++---------- strings/ctype-big5.c | 1 + strings/ctype-bin.c | 1 + strings/ctype-cp932.c | 1 + strings/ctype-euc_kr.c | 1 + strings/ctype-eucjpms.c | 1 + strings/ctype-gb2312.c | 1 + strings/ctype-gbk.c | 1 + strings/ctype-latin1.c | 1 + strings/ctype-simple.c | 337 +++++++++++++++++++++++++++++ strings/ctype-sjis.c | 1 + strings/ctype-tis620.c | 1 + strings/ctype-ucs2.c | 30 +++ strings/ctype-ujis.c | 1 + strings/ctype-utf8.c | 1 + 31 files changed, 1083 insertions(+), 302 deletions(-) create mode 100644 mysql-test/r/round.result create mode 100644 mysql-test/t/round.test diff --git a/include/m_ctype.h b/include/m_ctype.h index 54ae41bf2e0..9dbe277bf82 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -205,6 +205,9 @@ typedef struct my_charset_handler_st int *err); longlong (*strtoll10)(struct charset_info_st *cs, const char *nptr, char **endptr, int *error); + ulonglong (*strntoull10rnd)(struct charset_info_st *cs, + const char *str, uint length, int unsigned_fl, + char **endptr, int *error); ulong (*scan)(struct charset_info_st *, const char *b, const char *e, int sq); } MY_CHARSET_HANDLER; @@ -341,6 +344,13 @@ longlong my_strtoll10_8bit(CHARSET_INFO *cs, longlong my_strtoll10_ucs2(CHARSET_INFO *cs, const char *nptr, char **endptr, int *error); +ulonglong my_strntoull10rnd_8bit(CHARSET_INFO *cs, + const char *str, uint length, int unsigned_fl, + char **endptr, int *error); +ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs, + const char *str, uint length, int unsigned_fl, + char **endptr, int *error); + void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill); my_bool my_like_range_simple(CHARSET_INFO *cs, diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 17e1966dbc9..d415bd468e0 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -43,9 +43,9 @@ drop table t1; create table t1 (a int, b char(10)); load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 3 +Warning 1366 Incorrect integer value: 'error ' for column 'a' at row 3 Warning 1262 Row 3 was truncated; it contained more data than there were input columns -Warning 1264 Out of range value adjusted for column 'a' at row 5 +Warning 1366 Incorrect integer value: 'wrong end ' for column 'a' at row 5 Warning 1262 Row 5 was truncated; it contained more data than there were input columns select * from t1; a b @@ -57,7 +57,8 @@ a b truncate table t1; load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 4 +Warning 1366 Incorrect integer value: ' +' for column 'a' at row 4 Warning 1261 Row 4 doesn't contain data for all columns select * from t1; a b diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 207d9ea7475..92dc7c342d3 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -2689,21 +2689,21 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 1 -c2 1 -c3 1 -c4 1 -c5 1 -c6 1 +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 c7 3.40282e+38 c8 1.11111111111111e+50 c9 1.11111111111111e+50 @@ -2739,21 +2739,21 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 -1 -c2 -1 -c3 -1 -c4 -1 -c5 -1 -c6 -1 +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 c7 -3.40282e+38 c8 -1.11111111111111e+50 c9 -1.11111111111111e+50 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 13aa549949c..243e6fcd3bf 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -2672,21 +2672,21 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 1 -c2 1 -c3 1 -c4 1 -c5 1 -c6 1 +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 c7 3.40282e+38 c8 1.11111111111111e+50 c9 1.11111111111111e+50 @@ -2722,21 +2722,21 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 -1 -c2 -1 -c3 -1 -c4 -1 -c5 -1 -c6 -1 +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 c7 -3.40282e+38 c8 -1.11111111111111e+50 c9 -1.11111111111111e+50 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index a08dae945bd..524e8b4ff68 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -2673,21 +2673,21 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 1 -c2 1 -c3 1 -c4 1 -c5 1 -c6 1 +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 c7 3.40282e+38 c8 1.11111111111111e+50 c9 1.11111111111111e+50 @@ -2723,21 +2723,21 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 -1 -c2 -1 -c3 -1 -c4 -1 -c5 -1 -c6 -1 +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 c7 -3.40282e+38 c8 -1.11111111111111e+50 c9 -1.11111111111111e+50 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 6682b085097..831037496af 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -2609,21 +2609,21 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 1 -c2 1 -c3 1 -c4 1 -c5 1 -c6 1 +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 c7 3.40282e+38 c8 1.11111111111111e+50 c9 1.11111111111111e+50 @@ -2659,21 +2659,21 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 -1 -c2 -1 -c3 -1 -c4 -1 -c5 -1 -c6 -1 +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 c7 -3.40282e+38 c8 -1.11111111111111e+50 c9 -1.11111111111111e+50 @@ -5623,21 +5623,21 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 1 -c2 1 -c3 1 -c4 1 -c5 1 -c6 1 +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 c7 3.40282e+38 c8 1.11111111111111e+50 c9 1.11111111111111e+50 @@ -5673,21 +5673,21 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 -1 -c2 -1 -c3 -1 -c4 -1 -c5 -1 -c6 -1 +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 c7 -3.40282e+38 c8 -1.11111111111111e+50 c9 -1.11111111111111e+50 diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index dc3b984949d..4d7b4b81fd6 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -2672,21 +2672,21 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 1 -c2 1 -c3 1 -c4 1 -c5 1 -c6 1 +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 c7 3.40282e+38 c8 1.11111111111111e+50 c9 1.11111111111111e+50 @@ -2722,21 +2722,21 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 -1 -c2 -1 -c3 -1 -c4 -1 -c5 -1 -c6 -1 +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 c7 -3.40282e+38 c8 -1.11111111111111e+50 c9 -1.11111111111111e+50 diff --git a/mysql-test/r/round.result b/mysql-test/r/round.result new file mode 100644 index 00000000000..e9a80df0f49 --- /dev/null +++ b/mysql-test/r/round.result @@ -0,0 +1,272 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (sint8 tinyint not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('127.4'); +INSERT INTO t1 VALUES ('127.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'sint8' at row 1 +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('-127.4'); +INSERT INTO t1 VALUES ('-127.5'); +INSERT INTO t1 VALUES ('-128.4'); +INSERT INTO t1 VALUES ('-128.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'sint8' at row 1 +SELECT * FROM t1; +sint8 +0 +1 +127 +127 +0 +-1 +-127 +-128 +-128 +-128 +DROP TABLE t1; +CREATE TABLE t1 (uint8 tinyint unsigned not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('127.4'); +INSERT INTO t1 VALUES ('127.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'uint8' at row 1 +INSERT INTO t1 VALUES ('255.4'); +INSERT INTO t1 VALUES ('255.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'uint8' at row 1 +SELECT * FROM t1; +uint8 +0 +1 +127 +128 +0 +0 +255 +255 +DROP TABLE t1; +CREATE TABLE t1 (sint16 smallint not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('32767.4'); +INSERT INTO t1 VALUES ('32767.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'sint16' at row 1 +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('-32767.4'); +INSERT INTO t1 VALUES ('-32767.5'); +INSERT INTO t1 VALUES ('-32768.4'); +INSERT INTO t1 VALUES ('-32768.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'sint16' at row 1 +SELECT * FROM t1; +sint16 +0 +1 +32767 +32767 +0 +-1 +-32767 +-32768 +-32768 +-32768 +DROP TABLE t1; +CREATE TABLE t1 (uint16 smallint unsigned not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('32767.4'); +INSERT INTO t1 VALUES ('32767.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'uint16' at row 1 +INSERT INTO t1 VALUES ('65535.4'); +INSERT INTO t1 VALUES ('65535.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'uint16' at row 1 +SELECT * FROM t1; +uint16 +0 +1 +32767 +32768 +0 +0 +65535 +65535 +DROP TABLE t1; +CREATE TABLE t1 (sint24 mediumint not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('8388607.4'); +INSERT INTO t1 VALUES ('8388607.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'sint24' at row 1 +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('-8388607.4'); +INSERT INTO t1 VALUES ('-8388607.5'); +INSERT INTO t1 VALUES ('-8388608.4'); +INSERT INTO t1 VALUES ('-8388608.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'sint24' at row 1 +SELECT * FROM t1; +sint24 +0 +1 +8388607 +8388607 +0 +-1 +-8388607 +-8388608 +-8388608 +-8388608 +DROP TABLE t1; +CREATE TABLE t1 (uint24 mediumint unsigned not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('8388607.4'); +INSERT INTO t1 VALUES ('8388607.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'uint24' at row 1 +INSERT INTO t1 VALUES ('16777215.4'); +INSERT INTO t1 VALUES ('16777215.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'uint24' at row 1 +SELECT * FROM t1; +uint24 +0 +1 +8388607 +8388608 +0 +0 +16777215 +16777215 +DROP TABLE t1; +CREATE TABLE t1 (sint64 bigint not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('9223372036854775807.4'); +INSERT INTO t1 VALUES ('9223372036854775807.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'sint64' at row 1 +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('-9223372036854775807.4'); +INSERT INTO t1 VALUES ('-9223372036854775807.5'); +INSERT INTO t1 VALUES ('-9223372036854775808.4'); +INSERT INTO t1 VALUES ('-9223372036854775808.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'sint64' at row 1 +SELECT * FROM t1; +sint64 +0 +1 +9223372036854775807 +9223372036854775807 +0 +-1 +-9223372036854775807 +-9223372036854775808 +-9223372036854775808 +-9223372036854775808 +DROP TABLE t1; +CREATE TABLE t1 (uint64 bigint unsigned not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('9223372036854775807.4'); +INSERT INTO t1 VALUES ('9223372036854775807.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'uint64' at row 1 +INSERT INTO t1 VALUES ('18446744073709551615.4'); +INSERT INTO t1 VALUES ('18446744073709551615.5'); +Warnings: +Warning 1264 Out of range value adjusted for column 'uint64' at row 1 +INSERT INTO t1 VALUES ('1844674407370955161.0'); +INSERT INTO t1 VALUES ('1844674407370955161.1'); +INSERT INTO t1 VALUES ('1844674407370955161.2'); +INSERT INTO t1 VALUES ('1844674407370955161.3'); +INSERT INTO t1 VALUES ('1844674407370955161.4'); +INSERT INTO t1 VALUES ('1844674407370955161.5'); +INSERT INTO t1 VALUES ('1844674407370955161.0e1'); +INSERT INTO t1 VALUES ('1844674407370955161.1e1'); +INSERT INTO t1 VALUES ('1844674407370955161.2e1'); +INSERT INTO t1 VALUES ('1844674407370955161.3e1'); +INSERT INTO t1 VALUES ('1844674407370955161.4e1'); +INSERT INTO t1 VALUES ('1844674407370955161.5e1'); +INSERT INTO t1 VALUES ('18446744073709551610e-1'); +INSERT INTO t1 VALUES ('18446744073709551611e-1'); +INSERT INTO t1 VALUES ('18446744073709551612e-1'); +INSERT INTO t1 VALUES ('18446744073709551613e-1'); +INSERT INTO t1 VALUES ('18446744073709551614e-1'); +INSERT INTO t1 VALUES ('18446744073709551615e-1'); +SELECT * FROM t1; +uint64 +0 +1 +9223372036854775807 +9223372036854775808 +0 +0 +18446744073709551615 +18446744073709551615 +1844674407370955161 +1844674407370955161 +1844674407370955161 +1844674407370955161 +1844674407370955161 +1844674407370955162 +18446744073709551610 +18446744073709551611 +18446744073709551612 +18446744073709551613 +18446744073709551614 +18446744073709551615 +1844674407370955161 +1844674407370955161 +1844674407370955161 +1844674407370955161 +1844674407370955161 +1844674407370955162 +DROP TABLE t1; +CREATE TABLE t1 (str varchar(128), sint64 bigint not null default 0); +INSERT INTO t1 (str) VALUES ('1.5'); +INSERT INTO t1 (str) VALUES ('1.00005e4'); +INSERT INTO t1 (str) VALUES ('1.0005e3'); +INSERT INTO t1 (str) VALUES ('1.005e2'); +INSERT INTO t1 (str) VALUES ('1.05e1'); +INSERT INTO t1 (str) VALUES ('1.5e0'); +INSERT INTO t1 (str) VALUES ('100005e-1'); +INSERT INTO t1 (str) VALUES ('100050e-2'); +INSERT INTO t1 (str) VALUES ('100500e-3'); +INSERT INTO t1 (str) VALUES ('105000e-4'); +INSERT INTO t1 (str) VALUES ('150000e-5'); +UPDATE t1 SET sint64=str; +SELECT * FROM t1; +str sint64 +1.5 2 +1.00005e4 10001 +1.0005e3 1001 +1.005e2 101 +1.05e1 11 +1.5e0 2 +100005e-1 10001 +100050e-2 1001 +100500e-3 101 +105000e-4 11 +150000e-5 2 +DROP TABLE t1; diff --git a/mysql-test/r/rpl_rewrite_db.result b/mysql-test/r/rpl_rewrite_db.result index 71ac39010b5..1b843bffdca 100644 --- a/mysql-test/r/rpl_rewrite_db.result +++ b/mysql-test/r/rpl_rewrite_db.result @@ -67,9 +67,9 @@ drop table t1; create table t1 (a int, b char(10)); load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 3 +Warning 1366 Incorrect integer value: 'error ' for column 'a' at row 3 Warning 1262 Row 3 was truncated; it contained more data than there were input columns -Warning 1264 Out of range value adjusted for column 'a' at row 5 +Warning 1366 Incorrect integer value: 'wrong end ' for column 'a' at row 5 Warning 1262 Row 5 was truncated; it contained more data than there were input columns select * from rewrite.t1; a b @@ -81,7 +81,8 @@ a b truncate table t1; load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 4 +Warning 1366 Incorrect integer value: ' +' for column 'a' at row 4 Warning 1261 Row 4 doesn't contain data for all columns select * from rewrite.t1; a b diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index e6c590489a0..280df0bdd89 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2734,7 +2734,7 @@ CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); INSERT INTO t1 VALUES (10); SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') -0 1 1 1 +1 1 1 1 DROP TABLE t1; CREATE TABLE t1 ( K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', diff --git a/mysql-test/r/sp-vars.result b/mysql-test/r/sp-vars.result index 83ee188bfa4..14040f8420e 100644 --- a/mysql-test/r/sp-vars.result +++ b/mysql-test/r/sp-vars.result @@ -896,7 +896,7 @@ sp_var @user_var 0 Warnings: -Warning 1264 Out of range value adjusted for column 'sp_var' at row 1 +Warning 1366 Incorrect integer value: 'Hello, world!' for column 'sp_var' at row 1 DROP PROCEDURE p1; DROP TABLE t1; diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index d0cf11d0511..16464d67301 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -611,9 +611,9 @@ ERROR 22012: Division by 0 UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; ERROR 22012: Division by 0 INSERT INTO t1 (col1) VALUES (''); -ERROR 22003: Out of range value adjusted for column 'col1' at row 1 +ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES ('a59b'); -ERROR 22003: Out of range value adjusted for column 'col1' at row 1 +ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES ('1a'); ERROR 01000: Data truncated for column 'col1' at row 1 INSERT IGNORE INTO t1 (col1) VALUES ('2a'); @@ -693,9 +693,9 @@ ERROR 22012: Division by 0 UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; ERROR 22012: Division by 0 INSERT INTO t1 (col1) VALUES (''); -ERROR 22003: Out of range value adjusted for column 'col1' at row 1 +ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES ('a59b'); -ERROR 22003: Out of range value adjusted for column 'col1' at row 1 +ERROR HY000: Incorrect integer value: 'a59b' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES ('1a'); ERROR 01000: Data truncated for column 'col1' at row 1 INSERT IGNORE INTO t1 (col1) VALUES ('2a'); diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 72cffb9531c..281cd473c2c 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1306,9 +1306,9 @@ a b delete from t1; load data infile '../std_data_ln/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 3 +Warning 1366 Incorrect integer value: 'error ' for column 'a' at row 3 Error 1369 CHECK OPTION failed 'test.v1' -Warning 1264 Out of range value adjusted for column 'a' at row 4 +Warning 1366 Incorrect integer value: 'wrong end ' for column 'a' at row 4 Error 1369 CHECK OPTION failed 'test.v1' select * from t1; a b diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index f9006ebca37..d66a26ec8c1 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -31,19 +31,19 @@ Error 1064 You have an error in your SQL syntax; check the manual that correspon insert into t1 values (1); insert into t1 values ("hej"); Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'hej' for column 'a' at row 1 insert into t1 values ("hej"),("då"); Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 1 -Warning 1264 Out of range value adjusted for column 'a' at row 2 +Warning 1366 Incorrect integer value: 'hej' for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'd?' for column 'a' at row 2 set SQL_WARNINGS=1; insert into t1 values ("hej"); Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'hej' for column 'a' at row 1 insert into t1 values ("hej"),("då"); Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 1 -Warning 1264 Out of range value adjusted for column 'a' at row 2 +Warning 1366 Incorrect integer value: 'hej' for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'd?' for column 'a' at row 2 drop table t1; set SQL_WARNINGS=0; drop temporary table if exists not_exists; @@ -187,44 +187,44 @@ create table t1 (a int); insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); update t1 set a='abc'; Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 1 -Warning 1264 Out of range value adjusted for column 'a' at row 2 -Warning 1264 Out of range value adjusted for column 'a' at row 3 -Warning 1264 Out of range value adjusted for column 'a' at row 4 -Warning 1264 Out of range value adjusted for column 'a' at row 5 -Warning 1264 Out of range value adjusted for column 'a' at row 6 -Warning 1264 Out of range value adjusted for column 'a' at row 7 -Warning 1264 Out of range value adjusted for column 'a' at row 8 -Warning 1264 Out of range value adjusted for column 'a' at row 9 -Warning 1264 Out of range value adjusted for column 'a' at row 10 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 2 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 3 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 4 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 5 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 6 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 7 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 8 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 9 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 10 show warnings limit 2, 1; Level Code Message -Warning 1264 Out of range value adjusted for column 'a' at row 3 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 3 show warnings limit 0, 10; Level Code Message -Warning 1264 Out of range value adjusted for column 'a' at row 1 -Warning 1264 Out of range value adjusted for column 'a' at row 2 -Warning 1264 Out of range value adjusted for column 'a' at row 3 -Warning 1264 Out of range value adjusted for column 'a' at row 4 -Warning 1264 Out of range value adjusted for column 'a' at row 5 -Warning 1264 Out of range value adjusted for column 'a' at row 6 -Warning 1264 Out of range value adjusted for column 'a' at row 7 -Warning 1264 Out of range value adjusted for column 'a' at row 8 -Warning 1264 Out of range value adjusted for column 'a' at row 9 -Warning 1264 Out of range value adjusted for column 'a' at row 10 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 2 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 3 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 4 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 5 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 6 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 7 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 8 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 9 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 10 show warnings limit 9, 1; Level Code Message -Warning 1264 Out of range value adjusted for column 'a' at row 10 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 10 show warnings limit 10, 1; Level Code Message show warnings limit 9, 2; Level Code Message -Warning 1264 Out of range value adjusted for column 'a' at row 10 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 10 show warnings limit 0, 0; Level Code Message show warnings limit 1; Level Code Message -Warning 1264 Out of range value adjusted for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'abc' for column 'a' at row 1 show warnings limit 0; Level Code Message show warnings limit 1, 0; diff --git a/mysql-test/t/round.test b/mysql-test/t/round.test new file mode 100644 index 00000000000..d018fa7e34e --- /dev/null +++ b/mysql-test/t/round.test @@ -0,0 +1,145 @@ +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (sint8 tinyint not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('127.4'); +INSERT INTO t1 VALUES ('127.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('-127.4'); +INSERT INTO t1 VALUES ('-127.5'); +INSERT INTO t1 VALUES ('-128.4'); +INSERT INTO t1 VALUES ('-128.5'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (uint8 tinyint unsigned not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('127.4'); +INSERT INTO t1 VALUES ('127.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('255.4'); +INSERT INTO t1 VALUES ('255.5'); +SELECT * FROM t1; +DROP TABLE t1; + + +CREATE TABLE t1 (sint16 smallint not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('32767.4'); +INSERT INTO t1 VALUES ('32767.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('-32767.4'); +INSERT INTO t1 VALUES ('-32767.5'); +INSERT INTO t1 VALUES ('-32768.4'); +INSERT INTO t1 VALUES ('-32768.5'); +SELECT * FROM t1; +DROP TABLE t1; + + +CREATE TABLE t1 (uint16 smallint unsigned not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('32767.4'); +INSERT INTO t1 VALUES ('32767.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('65535.4'); +INSERT INTO t1 VALUES ('65535.5'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (sint24 mediumint not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('8388607.4'); +INSERT INTO t1 VALUES ('8388607.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('-8388607.4'); +INSERT INTO t1 VALUES ('-8388607.5'); +INSERT INTO t1 VALUES ('-8388608.4'); +INSERT INTO t1 VALUES ('-8388608.5'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (uint24 mediumint unsigned not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('8388607.4'); +INSERT INTO t1 VALUES ('8388607.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('16777215.4'); +INSERT INTO t1 VALUES ('16777215.5'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (sint64 bigint not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('9223372036854775807.4'); +INSERT INTO t1 VALUES ('9223372036854775807.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('-9223372036854775807.4'); +INSERT INTO t1 VALUES ('-9223372036854775807.5'); +INSERT INTO t1 VALUES ('-9223372036854775808.4'); +INSERT INTO t1 VALUES ('-9223372036854775808.5'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (uint64 bigint unsigned not null); +INSERT INTO t1 VALUES ('0.1'); +INSERT INTO t1 VALUES ('0.5'); +INSERT INTO t1 VALUES ('9223372036854775807.4'); +INSERT INTO t1 VALUES ('9223372036854775807.5'); +INSERT INTO t1 VALUES ('-0.1'); +INSERT INTO t1 VALUES ('-0.5'); +INSERT INTO t1 VALUES ('18446744073709551615.4'); +INSERT INTO t1 VALUES ('18446744073709551615.5'); +INSERT INTO t1 VALUES ('1844674407370955161.0'); +INSERT INTO t1 VALUES ('1844674407370955161.1'); +INSERT INTO t1 VALUES ('1844674407370955161.2'); +INSERT INTO t1 VALUES ('1844674407370955161.3'); +INSERT INTO t1 VALUES ('1844674407370955161.4'); +INSERT INTO t1 VALUES ('1844674407370955161.5'); +INSERT INTO t1 VALUES ('1844674407370955161.0e1'); +INSERT INTO t1 VALUES ('1844674407370955161.1e1'); +INSERT INTO t1 VALUES ('1844674407370955161.2e1'); +INSERT INTO t1 VALUES ('1844674407370955161.3e1'); +INSERT INTO t1 VALUES ('1844674407370955161.4e1'); +INSERT INTO t1 VALUES ('1844674407370955161.5e1'); +INSERT INTO t1 VALUES ('18446744073709551610e-1'); +INSERT INTO t1 VALUES ('18446744073709551611e-1'); +INSERT INTO t1 VALUES ('18446744073709551612e-1'); +INSERT INTO t1 VALUES ('18446744073709551613e-1'); +INSERT INTO t1 VALUES ('18446744073709551614e-1'); +INSERT INTO t1 VALUES ('18446744073709551615e-1'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (str varchar(128), sint64 bigint not null default 0); +INSERT INTO t1 (str) VALUES ('1.5'); +INSERT INTO t1 (str) VALUES ('1.00005e4'); +INSERT INTO t1 (str) VALUES ('1.0005e3'); +INSERT INTO t1 (str) VALUES ('1.005e2'); +INSERT INTO t1 (str) VALUES ('1.05e1'); +INSERT INTO t1 (str) VALUES ('1.5e0'); +INSERT INTO t1 (str) VALUES ('100005e-1'); +INSERT INTO t1 (str) VALUES ('100050e-2'); +INSERT INTO t1 (str) VALUES ('100500e-3'); +INSERT INTO t1 (str) VALUES ('105000e-4'); +INSERT INTO t1 (str) VALUES ('150000e-5'); +UPDATE t1 SET sint64=str; +SELECT * FROM t1; +DROP TABLE t1; + + diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index ce269b42ee9..75ac0be7aff 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -635,9 +635,9 @@ UPDATE t1 SET col2 =col2 + 50 WHERE col2 > 0; UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0; --error 1365 UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; ---error 1264 +--error 1366 INSERT INTO t1 (col1) VALUES (''); ---error 1264 +--error 1366 INSERT INTO t1 (col1) VALUES ('a59b'); --error 1265 INSERT INTO t1 (col1) VALUES ('1a'); @@ -696,9 +696,9 @@ INSERT INTO t1 (col2) VALUES(18446744073709551616.0); UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0; --error 1365 UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0; ---error 1264 +--error 1366 INSERT INTO t1 (col1) VALUES (''); ---error 1264 +--error 1366 INSERT INTO t1 (col1) VALUES ('a59b'); --error 1265 INSERT INTO t1 (col1) VALUES ('1a'); diff --git a/sql/field.cc b/sql/field.cc index 946351efe36..2b6af888dd4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2580,30 +2580,27 @@ void Field_new_decimal::sql_type(String &str) const int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs) { - int not_used; // We can ignore result from str2int char *end; - long tmp= my_strntol(cs, from, len, 10, &end, ¬_used); - int error= 0; + int error; if (unsigned_flag) { - if (tmp < 0) + ulonglong tmp= cs->cset->strntoull10rnd(cs, from, len, 1, &end, &error); + if (error == MY_ERRNO_ERANGE || tmp > 255) { - tmp=0; /* purecov: inspected */ - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); - error= 1; - } - else if (tmp > 255) - { - tmp= 255; + set_if_smaller(tmp, 255); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) error= 1; + else + error= 0; + ptr[0]= (char) tmp; } else { + longlong tmp= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error); if (tmp < -128) { tmp= -128; @@ -2618,8 +2615,10 @@ int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs) } else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) error= 1; + else + error= 0; + ptr[0]= (char) tmp; } - ptr[0]= (char) tmp; return error; } @@ -2784,30 +2783,34 @@ void Field_tiny::sql_type(String &res) const int Field_short::store(const char *from,uint len,CHARSET_INFO *cs) { - int not_used; // We can ignore result from str2int char *end; - long tmp= my_strntol(cs, from, len, 10, &end, ¬_used); - int error= 0; + int error; if (unsigned_flag) { - if (tmp < 0) + ulonglong tmp= cs->cset->strntoull10rnd(cs, from, len, 1, &end, &error); + if (error == MY_ERRNO_ERANGE || tmp > UINT_MAX16) { - tmp=0; - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); - error= 1; - } - else if (tmp > UINT_MAX16) - { - tmp=UINT_MAX16; + set_if_smaller(tmp, UINT_MAX16); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) error= 1; + else + error= 0; +#ifdef WORDS_BIGENDIAN + if (table->s->db_low_byte_first) + { + int2store(ptr,tmp); + } + else +#endif + shortstore(ptr,(short) tmp); } else { + longlong tmp= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error); if (tmp < INT_MIN16) { tmp= INT_MIN16; @@ -2822,15 +2825,17 @@ int Field_short::store(const char *from,uint len,CHARSET_INFO *cs) } else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) error= 1; - } + else + error= 0; #ifdef WORDS_BIGENDIAN - if (table->s->db_low_byte_first) - { - int2store(ptr,tmp); - } - else + if (table->s->db_low_byte_first) + { + int2store(ptr,tmp); + } + else #endif - shortstore(ptr,(short) tmp); + shortstore(ptr,(short) tmp); + } return error; } @@ -3058,30 +3063,27 @@ void Field_short::sql_type(String &res) const int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs) { - int not_used; // We can ignore result from str2int char *end; - long tmp= my_strntol(cs, from, len, 10, &end, ¬_used); - int error= 0; + int error; if (unsigned_flag) { - if (tmp < 0) + ulonglong tmp= cs->cset->strntoull10rnd(cs, from, len, 1, &end, &error); + if (error == MY_ERRNO_ERANGE || tmp > UINT_MAX24) { - tmp=0; - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); - error= 1; - } - else if (tmp >= (long) (1L << 24)) - { - tmp=(long) (1L << 24)-1L; + set_if_smaller(tmp, UINT_MAX24); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) error= 1; + else + error= 0; + int3store(ptr,tmp); } else { + longlong tmp= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error); if (tmp < INT_MIN24) { tmp= INT_MIN24; @@ -3096,9 +3098,10 @@ int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs) } else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) error= 1; + else + error= 0; + int3store(ptr,tmp); } - - int3store(ptr,tmp); return error; } @@ -3294,64 +3297,47 @@ static bool test_if_minus(CHARSET_INFO *cs, int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) { - ulong tmp_scan; - longlong tmp; long store_tmp; int error; char *end; - tmp_scan= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES); - len-= tmp_scan; - from+= tmp_scan; - - end= (char*) from+len; - tmp= cs->cset->strtoll10(cs, from, &end, &error); - - if (error != MY_ERRNO_EDOM) + if (unsigned_flag) { - if (unsigned_flag) + ulonglong tmp= cs->cset->strntoull10rnd(cs, from, len, 1, &end, &error); + if (error == MY_ERRNO_ERANGE || tmp > (ulonglong) UINT_MAX32) { - if (error < 0) - { - error= 1; - tmp= 0; - } - else if ((ulonglong) tmp > (ulonglong) UINT_MAX32) - { - tmp= UINT_MAX32; - error= 1; - } - else - error= 0; + set_if_smaller(tmp, (ulonglong) UINT_MAX32); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + error= 1; } + else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) + error= 1; else - { - if (error < 0) - { - error= 0; - if (tmp < INT_MIN32) - { - tmp= INT_MIN32; - error= 1; - } - } - else if (tmp > INT_MAX32) - { - tmp= INT_MAX32; - error= 1; - } - } + error= 0; + store_tmp= (long) tmp; } - if (error) + else { - error= error != MY_ERRNO_EDOM ? 1 : 2; - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + longlong tmp= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error); + if (tmp < INT_MIN32) + { + tmp= INT_MIN32; + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + error= 1; + } + else if (tmp > INT_MAX32) + { + tmp=INT_MAX32; + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + error= 1; + } + else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) + error= 1; + else + error= 0; + store_tmp= (long) tmp; } - else if (from+len != end && table->in_use->count_cuted_fields && - check_int(from,len,end,cs)) - error= 2; - store_tmp= (long) tmp; #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) { @@ -3587,33 +3573,20 @@ void Field_long::sql_type(String &res) const int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) { - longlong tmp; - int error= 0; + int error; char *end; + ulonglong tmp; - tmp= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES); - len-= (uint)tmp; - from+= tmp; - if (unsigned_flag) - { - if (!len || test_if_minus(cs, from, from + len)) - { - tmp=0; // Set negative to 0 - error= 1; - } - else - tmp=(longlong) my_strntoull(cs,from,len,10,&end,&error); - } - else - tmp=my_strntoll(cs,from,len,10,&end,&error); - if (error) + tmp= cs->cset->strntoull10rnd(cs,from,len,unsigned_flag,&end,&error); + if (error == MY_ERRNO_ERANGE) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); error= 1; } - else if (from+len != end && table->in_use->count_cuted_fields && - check_int(from,len,end,cs)) - error= 2; + else if (table->in_use->count_cuted_fields && check_int(from,len,end,cs)) + error= 1; + else + error= 0; #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) { diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 0ca1cf21129..479fb789816 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6370,6 +6370,7 @@ static MY_CHARSET_HANDLER my_charset_big5_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 54c35c82652..0bd5a1fda76 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -517,6 +517,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 5f8a93b1c2b..b4e9ba16d92 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5492,6 +5492,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index d6df46f7e05..40e0f4e3d2d 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8711,6 +8711,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 348eb2f6e87..65fef2dfc4c 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -8677,6 +8677,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 29ecafc3527..c2fc1e2c190 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5762,6 +5762,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index ef1b33fd82c..c4d06d67eb9 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -10015,6 +10015,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index a3f5aec9605..1298b66bb7e 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -411,6 +411,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 12ef77c59b1..e40a1948dcf 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -17,6 +17,7 @@ #include #include "m_string.h" #include "m_ctype.h" +#include "my_sys.h" /* Needed for MY_ERRNO_ERANGE */ #include #include "stdarg.h" @@ -1354,6 +1355,341 @@ longlong my_strtoll10_8bit(CHARSET_INFO *cs __attribute__((unused)), } +#undef ULONGLONG_MAX +/* + Needed under MetroWerks Compiler, since MetroWerks compiler does not + properly handle a constant expression containing a mod operator +*/ +#if defined(__NETWARE__) && defined(__MWERKS__) +static ulonglong ulonglong_max= ~(ulonglong) 0; +#define ULONGLONG_MAX ulonglong_max +#else +#define ULONGLONG_MAX (~(ulonglong) 0) +#endif /* __NETWARE__ && __MWERKS__ */ + + +#define CUTOFF (ULONGLONG_MAX / 10) +#define CUTLIM (ULONGLONG_MAX % 10) +#define DIGITS_IN_ULONGLONG 20 + +static ulonglong d10[DIGITS_IN_ULONGLONG]= +{ + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, + 10000000000ULL, + 100000000000ULL, + 1000000000000ULL, + 10000000000000ULL, + 100000000000000ULL, + 1000000000000000ULL, + 10000000000000000ULL, + 100000000000000000ULL, + 1000000000000000000ULL, + 10000000000000000000ULL +}; + + +/* + + Convert a string to unsigned long long integer value + with rounding. + + SYNOPSYS + my_strntoull10_8bit() + cs in pointer to character set + str in pointer to the string to be converted + length in string length + unsigned_flag in whether the number is unsigned + endptr out pointer to the stop character + error out returned error code + + DESCRIPTION + This function takes the decimal representation of integer number + from string str and converts it to an signed or unsigned + long long integer value. + Space characters and tab are ignored. + A sign character might precede the digit characters. + The number may have any number of pre-zero digits. + The number may have decimal point and exponent. + Rounding is always done in "away from zero" style: + 0.5 -> 1 + -0.5 -> -1 + + The function stops reading the string str after "length" bytes + or at the first character that is not a part of correct number syntax: + + ::= + [ ] [ E [ ] ] + + ::= + [ [ ] ] + | + ::= ... + + RETURN VALUES + Value of string as a signed/unsigned longlong integer + + endptr cannot be NULL. The function will store the end pointer + to the stop character here. + + The error parameter contains information how things went: + 0 ok + ERANGE If the the value of the converted number is out of range + In this case the return value is: + - ULONGLONG_MAX if unsigned_flag and the number was too big + - 0 if unsigned_flag and the number was negative + - LONGLONG_MAX if no unsigned_flag and the number is too big + - LONGLONG_MIN if no unsigned_flag and the number it too big negative + + EDOM If the string didn't contain any digits. + In this case the return value is 0. +*/ + +ulonglong +my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *str, uint length, int unsigned_flag, + char **endptr, int *error) +{ + const char *dot, *end9, *beg, *end= str + length; + ulonglong ull; + ulong ul; + unsigned char ch; + int shift= 0, digits= 0, negative, addon; + + /* Skip leading spaces and tabs */ + for ( ; str < end && (*str == ' ' || *str == '\t') ; str++); + + if (str >= end) + goto ret_edom; + + if ((negative= (*str == '-')) || *str=='+') /* optional sign */ + { + if (++str == end) + goto ret_edom; + } + + beg= str; + end9= (str + 9) > end ? end : (str + 9); + /* Accumulate small number into ulong, for performance purposes */ + for (ul= 0 ; str < end9 && (ch= (unsigned char) (*str - '0')) < 10; str++) + { + ul= ul * 10 + ch; + } + + if (str >= end) /* Small number without dots and expanents */ + { + *endptr= (char*) str; + if (negative) + { + if (unsigned_flag) + { + *error= ul ? MY_ERRNO_ERANGE : 0; + return 0; + } + else + { + *error= 0; + return (ulonglong) (longlong) (long) -ul; + } + } + else + { + *error=0; + return (ulonglong) ul; + } + } + + digits= str - beg; + + /* Continue to accumulate into ulonglong */ + for (dot= NULL, ull= ul; str < end; str++) + { + if ((ch= (unsigned char) (*str - '0')) < 10) + { + if (ull < CUTOFF || (ull == CUTOFF && ch <= CUTLIM)) + { + ull= ull * 10 + ch; + digits++; + continue; + } + /* + Adding the next digit would overflow. + Remember the next digit in "addon", for rounding. + Scan all digits with an optional single dot. + */ + if (ull == CUTOFF) + { + ull= ULONGLONG_MAX; + addon= 1; + str++; + } + else + addon= (*str >= '5'); + for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++) + { + if (!dot) + shift++; + } + if (str < end && *str == '.' && !dot) + { + str++; + for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++); + } + goto exp; + } + + if (*str == '.') + { + if (dot) + { + /* The second dot character */ + addon= 0; + goto exp; + } + else + { + dot= str + 1; + } + continue; + } + + /* Unknown character, exit the loop */ + break; + } + shift= dot ? dot - str : 0; /* Right shift */ + addon= 0; + +exp: /* [ E [ ] ] */ + + if (!digits) + { + str= beg; + goto ret_edom; + } + + if (str < end && (*str == 'e' || *str == 'E')) + { + str++; + if (str < end) + { + int negative_exp, exp; + if ((negative_exp= (*str == '-')) || *str=='+') + { + if (++str == end) + goto ret_sign; + } + for (exp= 0 ; + str < end && (ch= (unsigned char) (*str - '0')) < 10; + str++) + { + exp= exp * 10 + ch; + } + shift+= negative_exp ? -exp : exp; + } + } + + if (shift == 0) /* No shift, check addon digit */ + { + if (addon) + { + if (ull == ULONGLONG_MAX) + goto ret_too_big; + ull++; + } + goto ret_sign; + } + + if (shift < 0) /* Right shift */ + { + ulonglong d, r; + + if (-shift >= DIGITS_IN_ULONGLONG) + goto ret_zero; /* Exponent is a big negative number, return 0 */ + + d= d10[-shift]; + r= (ull % d) * 2; + ull /= d; + if (r >= d) + ull++; + goto ret_sign; + } + + if (shift > DIGITS_IN_ULONGLONG) /* Huge left shift */ + { + if (!ull) + goto ret_sign; + goto ret_too_big; + } + + for ( ; shift > 0; shift--, ull*= 10) /* Left shift */ + { + if (ull > CUTOFF) + goto ret_too_big; /* Overflow, number too big */ + } + +ret_sign: + *endptr= (char*) str; + + if (!unsigned_flag) + { + if (negative) + { + if (ull > (ulonglong) LONGLONG_MIN) + { + *error= MY_ERRNO_ERANGE; + return (ulonglong) LONGLONG_MIN; + } + *error= 0; + return (ulonglong) -ull; + } + else + { + if (ull > (ulonglong) LONGLONG_MAX) + { + *error= MY_ERRNO_ERANGE; + return (ulonglong) LONGLONG_MAX; + } + *error= 0; + return ull; + } + } + + /* Unsigned number */ + if (negative && ull) + { + *error= MY_ERRNO_ERANGE; + return 0; + } + *error= 0; + return ull; + +ret_zero: + *endptr= (char*) str; + *error= 0; + return 0; + +ret_edom: + *endptr= (char*) str; + *error= MY_ERRNO_EDOM; + return 0; + +ret_too_big: + *endptr= (char*) str; + *error= MY_ERRNO_ERANGE; + return unsigned_flag ? + ULONGLONG_MAX : + negative ? (ulonglong) LONGLONG_MIN : (ulonglong) LONGLONG_MAX; +} + + /* Check if a constant can be propagated @@ -1434,6 +1770,7 @@ MY_CHARSET_HANDLER my_charset_8bit_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 57d6d8bae2b..3854837e09a 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4663,6 +4663,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index dc4f18b516b..85ebbe82731 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -891,6 +891,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 97dca79e84b..4a60220f73e 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -974,6 +974,35 @@ double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), } +ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *nptr, uint length, int unsign_fl, + char **endptr, int *err) +{ + char buf[256], *b= buf; + ulonglong res; + const uchar *end, *s= (const uchar*) nptr; + my_wc_t wc; + int cnv; + + /* Cut too long strings */ + if (length >= sizeof(buf)) + length= sizeof(buf)-1; + end= s + length; + + while ((cnv= cs->cset->mb_wc(cs,&wc,s,end)) > 0) + { + s+= cnv; + if (wc > (int) (uchar) 'e' || !wc) + break; /* Can't be a number part */ + *b++= (char) wc; + } + + res= my_strntoull10rnd_8bit(cs, buf, b - buf, unsign_fl, endptr, err); + *endptr= (char*) nptr + 2 * (uint) (*endptr- buf); + return res; +} + + /* This is a fast version optimized for the case of radix 10 / -10 */ @@ -1629,6 +1658,7 @@ MY_CHARSET_HANDLER my_charset_ucs2_handler= my_strntoull_ucs2, my_strntod_ucs2, my_strtoll10_ucs2, + my_strntoull10rnd_ucs2, my_scan_ucs2 }; diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index ca27b4bef6b..675ac918e2c 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8545,6 +8545,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 3594ab954c6..3a5c01a2861 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2548,6 +2548,7 @@ MY_CHARSET_HANDLER my_charset_utf8_handler= my_strntoull_8bit, my_strntod_8bit, my_strtoll10_8bit, + my_strntoull10rnd_8bit, my_scan_8bit }; From 32ede45dd416e3ddbcf26ed0704cd86886f5bbd4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Sep 2006 11:47:19 +0500 Subject: [PATCH 03/15] Bug#20854 XML functions: wrong result in ExtractValue mysql-test/r/xml.result: - Adding test case - Fixing error message mysql-test/t/xml.test: Adding test case sql/item_xmlfunc.cc: For grammar rules with loops like: AdditiveExpr ::= MultiplicativeExpr ('+' MultiplicativeExpr)* If we scanned scanned '+' and then met an error when parsing MultiplicativeExpr, then we should fully stop parsing - without trying to apply any other rules. Fix: add "error" member into MY_XPATH structure, and make my_xpath_parse_term() never return success as soon as error set. strings/xml.c: Adding my_xml_ctype map for flags, indicating whether a character is a space character, is a valid identifier start character, is a valid identifier body character. Using this map to properly scan identifiers. Also, using this map to scan spaces faster (instead of strchr). --- mysql-test/r/xml.result | 28 ++++++++++++++++- mysql-test/t/xml.test | 16 ++++++++++ sql/item_xmlfunc.cc | 66 ++++++++++++++++++++++++++++++++++++----- strings/xml.c | 60 +++++++++++++++++++++++++++++++------ 4 files changed, 153 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result index 780be01d7ce..efe7d14095d 100644 --- a/mysql-test/r/xml.result +++ b/mysql-test/r/xml.result @@ -570,7 +570,7 @@ select extractvalue('aB','a|/b'); extractvalue('aB','a|/b') a select extractvalue('A','/'); -ERROR HY000: XPATH syntax error: '' +ERROR HY000: XPATH error: comparison of two nodesets is not supported: '' select extractvalue('bb!','//b!'); ERROR HY000: XPATH syntax error: '!' select extractvalue('ABC','/a/descendant::*'); @@ -710,3 +710,29 @@ Data select extractValue('DataOtherdata','/foo/something'); extractValue('DataOtherdata','/foo/something') Otherdata +select extractValue('<01>10:39:15<02>140','/zot/tim0/02'); +ERROR HY000: XPATH syntax error: '02' +select extractValue('<01>10:39:15<02>140','//*'); +extractValue('<01>10:39:15<02>140','//*') +NULL +Warnings: +Warning 1512 Incorrect XML value: 'parse error at line 1 pos 13: unknown token unexpected (ident or '/' wanted)' +select extractValue('<.>test','//*'); +extractValue('<.>test','//*') +NULL +Warnings: +Warning 1512 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' +select extractValue('<->test','//*'); +extractValue('<->test','//*') +NULL +Warnings: +Warning 1512 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)' +select extractValue('<:>test','//*'); +extractValue('<:>test','//*') +test +select extractValue('<_>test','//*'); +extractValue('<_>test','//*') +test +select extractValue('test','//*'); +extractValue('test','//*') +test diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test index d510a61f04d..3347573b4b7 100644 --- a/mysql-test/t/xml.test +++ b/mysql-test/t/xml.test @@ -360,3 +360,19 @@ select extractValue('a','/ns:element/@x # select extractValue('DataOtherdata','/foo/foo.bar'); select extractValue('DataOtherdata','/foo/something'); + +# +# Bug#20854 XML functions: wrong result in ExtractValue +# +--error 1105 +select extractValue('<01>10:39:15<02>140','/zot/tim0/02'); +select extractValue('<01>10:39:15<02>140','//*'); +# dot and dash are bad identtifier start character +select extractValue('<.>test','//*'); +select extractValue('<->test','//*'); +# semicolon is good identifier start character +select extractValue('<:>test','//*'); +# underscore is good identifier start character +select extractValue('<_>test','//*'); +# dot, dash, underscore and semicolon are good identifier middle characters +select extractValue('test','//*'); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index dfa2d2a7325..44a2b690bac 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -105,6 +105,7 @@ typedef struct my_xpath_st String *context_cache; /* last context provider */ String *pxml; /* Parsed XML, an array of MY_XML_NODE */ CHARSET_INFO *cs; /* character set/collation string comparison */ + int error; } MY_XPATH; @@ -913,7 +914,9 @@ static Item *eq_func_reverse(int oper, Item *a, Item *b) RETURN The newly created item. */ -static Item *create_comparator(MY_XPATH *xpath, int oper, Item *a, Item *b) +static Item *create_comparator(MY_XPATH *xpath, + int oper, MY_XPATH_LEX *context, + Item *a, Item *b) { if (a->type() != Item::XPATH_NODESET && b->type() != Item::XPATH_NODESET) @@ -923,6 +926,13 @@ static Item *create_comparator(MY_XPATH *xpath, int oper, Item *a, Item *b) else if (a->type() == Item::XPATH_NODESET && b->type() == Item::XPATH_NODESET) { + uint len= context->end - context->beg; + set_if_bigger(len, 32); + my_printf_error(ER_UNKNOWN_ERROR, + "XPATH error: " + "comparison of two nodesets is not supported: '%.*s'", + MYF(0), len, context->beg); + return 0; // TODO: Comparison of two nodesets } else @@ -1430,7 +1440,7 @@ my_xpath_lex_scan(MY_XPATH *xpath, static int my_xpath_parse_term(MY_XPATH *xpath, int term) { - if (xpath->lasttok.term == term) + if (xpath->lasttok.term == term && !xpath->error) { xpath->prevtok= xpath->lasttok; my_xpath_lex_scan(xpath, &xpath->lasttok, @@ -1558,8 +1568,9 @@ static int my_xpath_parse_AbsoluteLocationPath(MY_XPATH *xpath) return my_xpath_parse_RelativeLocationPath(xpath); } - return my_xpath_parse_term(xpath, MY_XPATH_LEX_EOF) || - my_xpath_parse_RelativeLocationPath(xpath); + my_xpath_parse_RelativeLocationPath(xpath); + + return (xpath->error == 0); } @@ -1596,7 +1607,10 @@ static int my_xpath_parse_RelativeLocationPath(MY_XPATH *xpath) "*", 1, xpath->pxml, 1); if (!my_xpath_parse_Step(xpath)) + { + xpath->error= 1; return 0; + } } return 1; } @@ -1633,10 +1647,16 @@ my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(MY_XPATH *xpath) xpath->context_cache= context_cache; if(!my_xpath_parse_PredicateExpr(xpath)) + { + xpath->error= 1; return 0; + } if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_RB)) + { + xpath->error= 1; return 0; + } xpath->item= nodeset2bool(xpath, xpath->item); @@ -1893,7 +1913,10 @@ static int my_xpath_parse_UnionExpr(MY_XPATH *xpath) if (!my_xpath_parse_PathExpr(xpath) || xpath->item->type() != Item::XPATH_NODESET) + { + xpath->error= 1; return 0; + } xpath->item= new Item_nodeset_func_union(prev, xpath->item, xpath->pxml); } return 1; @@ -1929,6 +1952,7 @@ static int my_xpath_parse_PathExpr(MY_XPATH *xpath) { return my_xpath_parse_LocationPath(xpath) || my_xpath_parse_FilterExpr_opt_slashes_RelativeLocationPath(xpath); + } @@ -1975,7 +1999,10 @@ static int my_xpath_parse_OrExpr(MY_XPATH *xpath) { Item *prev= xpath->item; if (!my_xpath_parse_AndExpr(xpath)) + { return 0; + xpath->error= 1; + } xpath->item= new Item_cond_or(nodeset2bool(xpath, prev), nodeset2bool(xpath, xpath->item)); } @@ -2003,7 +2030,10 @@ static int my_xpath_parse_AndExpr(MY_XPATH *xpath) { Item *prev= xpath->item; if (!my_xpath_parse_EqualityExpr(xpath)) + { + xpath->error= 1; return 0; + } xpath->item= new Item_cond_and(nodeset2bool(xpath,prev), nodeset2bool(xpath,xpath->item)); @@ -2057,17 +2087,26 @@ static int my_xpath_parse_EqualityOperator(MY_XPATH *xpath) } static int my_xpath_parse_EqualityExpr(MY_XPATH *xpath) { + MY_XPATH_LEX operator_context; if (!my_xpath_parse_RelationalExpr(xpath)) return 0; + + operator_context= xpath->lasttok; while (my_xpath_parse_EqualityOperator(xpath)) { Item *prev= xpath->item; int oper= xpath->extra; if (!my_xpath_parse_RelationalExpr(xpath)) + { + xpath->error= 1; + return 0; + } + + if (!(xpath->item= create_comparator(xpath, oper, &operator_context, + prev, xpath->item))) return 0; - if (!(xpath->item= create_comparator(xpath, oper, prev, xpath->item))) - return 0; + operator_context= xpath->lasttok; } return 1; } @@ -2109,18 +2148,25 @@ static int my_xpath_parse_RelationalOperator(MY_XPATH *xpath) } static int my_xpath_parse_RelationalExpr(MY_XPATH *xpath) { + MY_XPATH_LEX operator_context; if (!my_xpath_parse_AdditiveExpr(xpath)) return 0; + operator_context= xpath->lasttok; while (my_xpath_parse_RelationalOperator(xpath)) { Item *prev= xpath->item; int oper= xpath->extra; if (!my_xpath_parse_AdditiveExpr(xpath)) + { + xpath->error= 1; return 0; + } - if (!(xpath->item= create_comparator(xpath, oper, prev, xpath->item))) + if (!(xpath->item= create_comparator(xpath, oper, &operator_context, + prev, xpath->item))) return 0; + operator_context= xpath->lasttok; } return 1; } @@ -2153,7 +2199,10 @@ static int my_xpath_parse_AdditiveExpr(MY_XPATH *xpath) int oper= xpath->prevtok.term; Item *prev= xpath->item; if (!my_xpath_parse_MultiplicativeExpr(xpath)) + { + xpath->error= 1; return 0; + } if (oper == MY_XPATH_LEX_PLUS) xpath->item= new Item_func_plus(prev, xpath->item); @@ -2198,7 +2247,10 @@ static int my_xpath_parse_MultiplicativeExpr(MY_XPATH *xpath) int oper= xpath->prevtok.term; Item *prev= xpath->item; if (!my_xpath_parse_UnaryExpr(xpath)) + { + xpath->error= 1; return 0; + } switch (oper) { case MY_XPATH_LEX_ASTERISK: diff --git a/strings/xml.c b/strings/xml.c index 51649dcb343..7f7c531d051 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -19,6 +19,7 @@ #include "my_xml.h" +#define MY_XML_UNKNOWN 'U' #define MY_XML_EOF 'E' #define MY_XML_STRING 'S' #define MY_XML_IDENT 'I' @@ -39,6 +40,46 @@ typedef struct xml_attr_st } MY_XML_ATTR; +/* + XML ctype: +*/ +#define MY_XML_ID0 0x01 /* Identifier initial character */ +#define MY_XML_ID1 0x02 /* Identifier medial character */ +#define MY_XML_SPC 0x08 /* Spacing character */ + + +/* + http://www.w3.org/TR/REC-xml/ + [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | + CombiningChar | Extender + [5] Name ::= (Letter | '_' | ':') (NameChar)* +*/ + +static char my_xml_ctype[256]= +{ +/*00*/ 0,0,0,0,0,0,0,0,0,8,8,0,0,8,0,0, +/*10*/ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +/*20*/ 8,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0, /* !"#$%&'()*+,-./ */ +/*30*/ 2,2,2,2,2,2,2,2,2,2,3,0,0,0,0,0, /* 0123456789:;<=>? */ +/*40*/ 0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, /* @ABCDEFGHIJKLMNO */ +/*50*/ 3,3,3,3,3,3,3,3,3,3,3,0,0,0,0,3, /* PQRSTUVWXYZ[\]^_ */ +/*60*/ 0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, /* `abcdefghijklmno */ +/*70*/ 3,3,3,3,3,3,3,3,3,3,3,0,0,0,0,0, /* pqrstuvwxyz{|}~ */ +/*80*/ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, +/*90*/ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, +/*A0*/ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, +/*B0*/ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, +/*C0*/ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, +/*D0*/ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, +/*E0*/ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, +/*F0*/ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 +}; + +#define my_xml_is_space(c) (my_xml_ctype[(uchar) (c)] & MY_XML_SPC) +#define my_xml_is_id0(c) (my_xml_ctype[(uchar) (c)] & MY_XML_ID0) +#define my_xml_is_id1(c) (my_xml_ctype[(uchar) (c)] & MY_XML_ID1) + + static const char *lex2str(int lex) { switch(lex) @@ -56,13 +97,13 @@ static const char *lex2str(int lex) case MY_XML_QUESTION: return "'?'"; case MY_XML_EXCLAM: return "'!'"; } - return "UNKNOWN"; + return "unknown token"; } static void my_xml_norm_text(MY_XML_ATTR *a) { - for ( ; (a->beg < a->end) && strchr(" \t\r\n",a->beg[0]) ; a->beg++ ); - for ( ; (a->beg < a->end) && strchr(" \t\r\n",a->end[-1]) ; a->end-- ); + for ( ; (a->beg < a->end) && my_xml_is_space(a->beg[0]) ; a->beg++ ); + for ( ; (a->beg < a->end) && my_xml_is_space(a->end[-1]) ; a->end-- ); } @@ -70,7 +111,7 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) { int lex; - for( ; ( p->cur < p->end) && strchr(" \t\r\n",p->cur[0]) ; p->cur++); + for( ; ( p->cur < p->end) && my_xml_is_space(p->cur[0]) ; p->cur++); if (p->cur >= p->end) { @@ -124,16 +165,17 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) my_xml_norm_text(a); lex=MY_XML_STRING; } - else + else if (my_xml_is_id0(p->cur[0])) { - for(; - (p->cur < p->end) && !strchr("?'\"=/<> \t\r\n", p->cur[0]); - p->cur++) - {} + p->cur++; + while (p->cur < p->end && my_xml_is_id1(p->cur[0])) + p->cur++; a->end=p->cur; my_xml_norm_text(a); lex=MY_XML_IDENT; } + else + lex= MY_XML_UNKNOWN; #if 0 printf("LEX=%s[%d]\n",lex2str(lex),a->end-a->beg); From 99f8d0a4a82b6816345fabf5b9570435b80930a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 23 Sep 2006 15:24:45 +0300 Subject: [PATCH 04/15] binlog_row_binlog test gained some indeterministic checks with changes due to ChangeSet@1.2309.1.12, 2006-09-12 15:42:13+02:00, guilhem@gbichot3.local +14 -0 Fixing problems I identified in my auto_increment work pushed in July (as part of the auto_increment cleanup of WL #3146; ... The problem is in that show binlog events in indeterministic, row events can be compressed, so that 2 seconds original delay does not guard from inconsistency. We syncronize test's current inserted rows counter with system insert delayed thread per each query. From another side there is no requirement for binlog to be event per row and then to verify if binlog has recorded what was recently inserted is better via reading from it instead of 'show binlog events'. mysql-test/extra/binlog_tests/binlog_insert_delayed.test: removing sleeps, syncronizing with system delayed thread per each statement, note that an insert statement is performed atomically including writing to binlog, so that concurrent selects are waiting. That's why the wait macro is safe. mysql-test/r/binlog_row_binlog.result: new result mysql-test/include/wait_until_rows_count.inc: macro implements waiting until a targeted table has a prescribed rows number. --- .../binlog_tests/binlog_insert_delayed.test | 32 ++++++++---- mysql-test/include/wait_until_rows_count.inc | 52 +++++++++++++++++++ mysql-test/r/binlog_row_binlog.result | 1 + 3 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 mysql-test/include/wait_until_rows_count.inc diff --git a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test index 6f504fded96..29c2c477960 100644 --- a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test +++ b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test @@ -4,23 +4,33 @@ create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; # Verify that only one INSERT_ID event is binlogged. # Note, that because of WL#3368 mixed mode binlog records RBR events for the delayed +let $table=t1; +let $rows_inserted=11; # total number of inserted rows in this test insert delayed into t1 values (207); +let $count=1; -# We use sleeps between statements, that's the only way to get a -# repeatable binlog in a normal test run and under Valgrind. The -# reason is that without sleeps, rows of different INSERT DELAYEDs -# sometimes group together and sometimes not, so the table may be -# unlocked/relocked causing a different number of table map log -# events. -sleep 2; +# use this macro instead of sleeps. + +--source include/wait_until_rows_count.inc insert delayed into t1 values (null); -sleep 2; +inc $count; +--source include/wait_until_rows_count.inc + insert delayed into t1 values (300); -sleep 2; # time for the delayed queries to reach disk +inc $count; +--source include/wait_until_rows_count.inc + insert delayed into t1 values (null),(null),(null),(null); -sleep 2; +inc $count; inc $count; inc $count; inc $count; +--source include/wait_until_rows_count.inc + insert delayed into t1 values (null),(null),(400),(null); -sleep 2; +inc $count; inc $count; inc $count; inc $count; +--source include/wait_until_rows_count.inc + +#check this assertion about $count calculation +--echo $count == $rows_inserted + select * from t1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ diff --git a/mysql-test/include/wait_until_rows_count.inc b/mysql-test/include/wait_until_rows_count.inc new file mode 100644 index 00000000000..cf2a21d335a --- /dev/null +++ b/mysql-test/include/wait_until_rows_count.inc @@ -0,0 +1,52 @@ +# include/wait_until_rows_count.inc +# inspired by wait_for_slave_status by Matthias Leich +# +# SUMMARY +# +# Waits until SELECT count(*)-$count from $table returns zero +# +# USAGE +# +# Set vars like +# let $count=11; +# let $table=t1; +# # invoke the macro +# --include wait_until_rows_count.inc +# +# EXAMPLE +# extra/binlog/binlog_insert_delayed.test +# +# +# TODO: generalize up to wait_[until|while] with arbitrary select or even query and +# a condition to wait or get awakened +# It's impossible to implement such a "most" general macro without +# extending mysqltest. Just no way to pass a query as an argument and +# evaluate it here, like eval "$quuery". One is bound +# to specify it inside of the macro + +--disable_query_log + +let $wait_counter= 300; # max wait in 0.1 seconds +while ($wait_counter) +{ + eval select count(*)-$count from $table into @rez; + let $rez=`select @rez`; + let $success=`SELECT @rez = 0`; + let $no_success=1; + if ($success) + { + let $wait_counter= 1; # droppping counter to leave loop + let $no_success=0; + } + if ($no_success) + { + --sleep 0.1 + } + dec $wait_counter; +} + +--enable_query_log +if ($no_success) +{ + --die Timeout in wait_until_rows_count.inc, required table never had a prescribed number of rows. +} diff --git a/mysql-test/r/binlog_row_binlog.result b/mysql-test/r/binlog_row_binlog.result index 8d5025f7602..5eef5d9cbf3 100644 --- a/mysql-test/r/binlog_row_binlog.result +++ b/mysql-test/r/binlog_row_binlog.result @@ -252,6 +252,7 @@ insert delayed into t1 values (null); insert delayed into t1 values (300); insert delayed into t1 values (null),(null),(null),(null); insert delayed into t1 values (null),(null),(400),(null); +11 == 11 select * from t1; a 207 From 1ac90c6a5016befef168a0a84a97f5925e986429 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Sep 2006 16:58:07 +0300 Subject: [PATCH 05/15] Result of a binlog_statement_insert_delayed was affected by recent fixing of binlog_row_binlog.test failure in team tree. Fixing the result. --- mysql-test/r/binlog_statement_insert_delayed.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/binlog_statement_insert_delayed.result b/mysql-test/r/binlog_statement_insert_delayed.result index 3cf6ba14e02..af10aa8ed4e 100644 --- a/mysql-test/r/binlog_statement_insert_delayed.result +++ b/mysql-test/r/binlog_statement_insert_delayed.result @@ -5,6 +5,7 @@ insert delayed into t1 values (null); insert delayed into t1 values (300); insert delayed into t1 values (null),(null),(null),(null); insert delayed into t1 values (null),(null),(400),(null); +11 == 11 select * from t1; a 207 From a365817a99e3d99358d1d145ddce8cd0b47ed47c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Sep 2006 13:05:29 +0300 Subject: [PATCH 06/15] One more fix for binlog_row_binlog due to interminism of checking with SHOW BINLOG event. The latter should be either fixed or replaced to favor reading from binlog as the check. mysql-test/extra/binlog_tests/binlog_insert_delayed.test: interminism of binlogging of multi-row insert delayed forced to relocate the show mysql-test/r/binlog_row_binlog.result: new results --- .../binlog_tests/binlog_insert_delayed.test | 10 ++++-- mysql-test/r/binlog_row_binlog.result | 34 +++++++------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test index 29c2c477960..4da883b9e60 100644 --- a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test +++ b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test @@ -20,6 +20,13 @@ insert delayed into t1 values (300); inc $count; --source include/wait_until_rows_count.inc +# moving binlog check affront of multi-rows queries which work is indeterministic (extra table_maps) +# todo: better check is to substitute SHOW BINLOG with reading from binlog, probably bug#19459 is in +# the way +--replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ +show binlog events from 102; + insert delayed into t1 values (null),(null),(null),(null); inc $count; inc $count; inc $count; inc $count; --source include/wait_until_rows_count.inc @@ -32,7 +39,4 @@ inc $count; inc $count; inc $count; inc $count; --echo $count == $rows_inserted select * from t1; ---replace_column 2 # 5 # ---replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; drop table t1; diff --git a/mysql-test/r/binlog_row_binlog.result b/mysql-test/r/binlog_row_binlog.result index 5eef5d9cbf3..7cbfa525798 100644 --- a/mysql-test/r/binlog_row_binlog.result +++ b/mysql-test/r/binlog_row_binlog.result @@ -250,6 +250,19 @@ set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; insert delayed into t1 values (207); insert delayed into t1 values (null); insert delayed into t1 values (300); +show binlog events from 102; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key) +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # use `test`; drop table t1 +master-bin.000001 # Query 1 # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F insert delayed into t1 values (null),(null),(null),(null); insert delayed into t1 values (null),(null),(400),(null); 11 == 11 @@ -266,25 +279,4 @@ a 306 400 401 -show binlog events from 102; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key) -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Query 1 # use `test`; drop table t1 -master-bin.000001 # Query 1 # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F drop table t1; From 277b80da67146c99f1a27a9f415454dcf244e3da Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Sep 2006 17:55:45 +0300 Subject: [PATCH 07/15] the results of binlog_statement_insert_delayed in STATEMENT - non-recommended mode i.e not checked by make test - got changed due to show binlog events relocation to deterministic position at extra/binlog_tests/binlog_insert_delayed.test. mysql-test/r/binlog_statement_insert_delayed.result: results changed due to moving a binlog check affront of indetermistic queries. --- .../r/binlog_statement_insert_delayed.result | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/binlog_statement_insert_delayed.result b/mysql-test/r/binlog_statement_insert_delayed.result index af10aa8ed4e..7a1b9a7ec9b 100644 --- a/mysql-test/r/binlog_statement_insert_delayed.result +++ b/mysql-test/r/binlog_statement_insert_delayed.result @@ -3,6 +3,13 @@ set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; insert delayed into t1 values (207); insert delayed into t1 values (null); insert delayed into t1 values (300); +show binlog events from 102; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam +master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (207) +master-bin.000001 # Intvar 1 # INSERT_ID=208 +master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (null) +master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (300) insert delayed into t1 values (null),(null),(null),(null); insert delayed into t1 values (null),(null),(400),(null); 11 == 11 @@ -19,15 +26,4 @@ a 306 400 401 -show binlog events from 102; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query 1 # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam -master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (207) -master-bin.000001 # Intvar 1 # INSERT_ID=208 -master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (null) -master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (300) -master-bin.000001 # Intvar 1 # INSERT_ID=301 -master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (null),(null),(null),(null) -master-bin.000001 # Intvar 1 # INSERT_ID=305 -master-bin.000001 # Query 1 # use `test`; insert delayed into t1 values (null),(null),(400),(null) drop table t1; From cd1eb67292e93fe0fd2643ff8b036f9c0e39e390 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Sep 2006 18:42:41 +0300 Subject: [PATCH 08/15] Result of a binlog_statement_insert_delayed was affected by recent fixing of binlog_row_binlog.test failure in team tree. Fixing the result that gets wrong with --binlog-format=mixed (so that skipped on pushbuild currently) mysql-test/r/binlog_stm_binlog.result: Fixing the result. --- mysql-test/r/binlog_stm_binlog.result | 39 +++++++++++---------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/mysql-test/r/binlog_stm_binlog.result b/mysql-test/r/binlog_stm_binlog.result index 6589392fe79..eed2df28d1f 100644 --- a/mysql-test/r/binlog_stm_binlog.result +++ b/mysql-test/r/binlog_stm_binlog.result @@ -160,21 +160,6 @@ set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; insert delayed into t1 values (207); insert delayed into t1 values (null); insert delayed into t1 values (300); -insert delayed into t1 values (null),(null),(null),(null); -insert delayed into t1 values (null),(null),(400),(null); -select * from t1; -a -207 -208 -300 -301 -302 -303 -304 -305 -306 -400 -401 show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key) @@ -188,12 +173,20 @@ master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map 1 # table_id: # (test.t1) -master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +insert delayed into t1 values (null),(null),(null),(null); +insert delayed into t1 values (null),(null),(400),(null); +11 == 11 +select * from t1; +a +207 +208 +300 +301 +302 +303 +304 +305 +306 +400 +401 drop table t1; From 695bcb9e7b39c50bbc4bdba8e12aaa4375be3bee Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Sep 2006 16:15:57 +0500 Subject: [PATCH 09/15] Bug#19960 Inconsistent results when joining InnoDB tables using partial UTF8 indexes Adding a multibyte-aware VARCHAR copying function, to put correct column prefix, taking in account number of characters (instead just limiting on number of bytes). For example, for a KEY(col(3)) on a UTF8 column when copying the string 'foo bar foo', we should put only 3 leftmost characters: 'foo'. 9 characters were incorrectly put before this fix. mysql-test/r/ctype_utf8.result: Adding test case mysql-test/t/ctype_utf8.test: Adding test case sql/field_conv.cc: Adding multibyte aware copy function for VARCHAR --- mysql-test/r/ctype_utf8.result | 18 ++++++++++++++++++ mysql-test/t/ctype_utf8.test | 20 ++++++++++++++++++++ sql/field_conv.cc | 18 +++++++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 51f361349e6..4267df8d176 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1462,3 +1462,21 @@ set @a:=null; execute my_stmt using @a; a b drop table if exists t1; +CREATE TABLE t1 ( +colA int(11) NOT NULL, +colB varchar(255) character set utf8 NOT NULL, +PRIMARY KEY (colA) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar'); +CREATE TABLE t2 ( +colA int(11) NOT NULL, +colB varchar(255) character set utf8 NOT NULL, +KEY bad (colA,colB(3)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); +SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB +WHERE t1.colA < 3; +colA colB colA colB +1 foo 1 foo +2 foo bar 2 foo bar +DROP TABLE t1, t2; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index b6137d5f084..67ca6f45188 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1164,3 +1164,23 @@ execute my_stmt using @a; set @a:=null; execute my_stmt using @a; drop table if exists t1; + +# +# Bug#19960: Inconsistent results when joining +# InnoDB tables using partial UTF8 indexes +# +CREATE TABLE t1 ( + colA int(11) NOT NULL, + colB varchar(255) character set utf8 NOT NULL, + PRIMARY KEY (colA) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar'); +CREATE TABLE t2 ( + colA int(11) NOT NULL, + colB varchar(255) character set utf8 NOT NULL, + KEY bad (colA,colB(3)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); +SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB +WHERE t1.colA < 3; +DROP TABLE t1, t2; diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 3200f2ca9b2..95ff985376d 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -428,6 +428,21 @@ static void do_varstring2(Copy_field *copy) length); } + +static void do_varstring2_mb(Copy_field *copy) +{ + int well_formed_error; + CHARSET_INFO *cs= copy->from_field->charset(); + uint char_length= (copy->to_length - HA_KEY_BLOB_LENGTH) / cs->mbmaxlen; + uint from_length= uint2korr(copy->from_ptr); + const char *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH; + uint length= cs->cset->well_formed_len(cs, from_beg, from_beg + from_length, + char_length, &well_formed_error); + int2store(copy->to_ptr, length); + memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, length); +} + + /*************************************************************************** ** The different functions that fills in a Copy_field class ***************************************************************************/ @@ -587,7 +602,8 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*) return do_field_string; if (to_length != from_length) return (((Field_varstring*) to)->length_bytes == 1 ? - do_varstring1 : do_varstring2); + do_varstring1 : (from->charset()->mbmaxlen == 1 ? + do_varstring2 : do_varstring2_mb)); } else if (to_length < from_length) return (from->charset()->mbmaxlen == 1 ? From 880c9b2a8b5c5239701b60bdb5f6cc8559be3470 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Sep 2006 16:24:11 +0500 Subject: [PATCH 10/15] Bug#21620 ALTER TABLE affects other columns Problem: for character sets having mbmaxlen==2, any ALTER TABLE changed TEXT column type to MEDIUMTEXT, due to wrong "internal length to create length" formula. Fix: removing rounding code introduced in early 4.1 time, which is not correct anymore. mysql-test/r/ctype_gbk.result: Adding test case mysql-test/t/ctype_gbk.test: Adding test case sql/field.cc: Fixing "internal length to create length" formula. --- mysql-test/r/ctype_gbk.result | 10 ++++++++++ mysql-test/t/ctype_gbk.test | 10 ++++++++++ sql/field.cc | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index 241539ecf42..3f5d8b0d8c6 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -168,3 +168,13 @@ DROP TABLE t1; select hex(convert(_gbk 0xA14041 using ucs2)); hex(convert(_gbk 0xA14041 using ucs2)) 003F0041 +create table t1 (c1 text not null, c2 text not null) character set gbk; +alter table t1 change c1 c1 mediumtext character set gbk not null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` mediumtext NOT NULL, + `c2` text NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=gbk +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test index 7aec48586d8..5ff138fa97b 100644 --- a/mysql-test/t/ctype_gbk.test +++ b/mysql-test/t/ctype_gbk.test @@ -42,3 +42,13 @@ DROP TABLE t1; select hex(convert(_gbk 0xA14041 using ucs2)); # End of 4.1 tests + +# +# Bug#21620 ALTER TABLE affects other columns +# +create table t1 (c1 text not null, c2 text not null) character set gbk; +alter table t1 change c1 c1 mediumtext character set gbk not null; +show create table t1; +drop table t1; + +--echo End of 5.0 tests diff --git a/sql/field.cc b/sql/field.cc index 4860f6ea3da..53ef96a04d7 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8877,7 +8877,7 @@ create_field::create_field(Field *old_field,Field *orig_field) case 3: sql_type= FIELD_TYPE_MEDIUM_BLOB; break; default: sql_type= FIELD_TYPE_LONG_BLOB; break; } - length=(length+charset->mbmaxlen-1) / charset->mbmaxlen; + length/= charset->mbmaxlen; key_length/= charset->mbmaxlen; break; case MYSQL_TYPE_STRING: From 1b4d6a055a6407f1e446b8333c9d31e5c2868886 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Sep 2006 16:29:39 +0500 Subject: [PATCH 11/15] Bug#21263 mysql client XML output does not distinguish between NULL and string 'NULL' Fix: "mysql --xml" now print NULL values the same way that "mysqldump --xml" does: to distinguish from empty strings: and from string "NULL": NULL client/mysql.cc: Fixing to print NULLs differently from empty strings mysql-test/r/client_xml.result: Fixing test result accordingly --- client/mysql.cc | 11 ++++++++--- mysql-test/r/client_xml.result | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 5e09c309917..f1a140a6c5a 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2509,9 +2509,14 @@ print_table_data_xml(MYSQL_RES *result) { tee_fprintf(PAGER, "\t"); - xmlencode_print(cur[i], lengths[i]); - tee_fprintf(PAGER, "\n"); + if (cur[i]) + { + tee_fprintf(PAGER, "\">"); + xmlencode_print(cur[i], lengths[i]); + tee_fprintf(PAGER, "\n"); + } + else + tee_fprintf(PAGER, "\" xsi:nil=\"true\" />\n"); } (void) tee_fputs(" \n", PAGER); } diff --git a/mysql-test/r/client_xml.result b/mysql-test/r/client_xml.result index 24c05c7f9d6..7395b2433e8 100644 --- a/mysql-test/r/client_xml.result +++ b/mysql-test/r/client_xml.result @@ -68,7 +68,7 @@ insert into t1 values (1, 2, 'a&b ab'); - NULL + drop table t1; From 2a6e8817a27278ac811d72d14777f99c7dc80aa7 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Oct 2006 14:17:41 +0500 Subject: [PATCH 12/15] bug#6147 - fixing ndb test results (forgot to include into the main commit) --- mysql-test/r/ps_7ndb.result | 48 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index b1986ca62dc..c84cced15f5 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -2672,21 +2672,21 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 1 -c2 1 -c3 1 -c4 1 -c5 1 -c6 1 +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 c7 3.40282e+38 c8 1.11111111111111e+50 c9 1.11111111111111e+50 @@ -2722,21 +2722,21 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1265 Data truncated for column 'c2' at row 1 -Warning 1265 Data truncated for column 'c3' at row 1 -Warning 1265 Data truncated for column 'c4' at row 1 -Warning 1265 Data truncated for column 'c5' at row 1 -Warning 1265 Data truncated for column 'c6' at row 1 +Warning 1264 Out of range value adjusted for column 'c1' at row 1 +Warning 1264 Out of range value adjusted for column 'c2' at row 1 +Warning 1264 Out of range value adjusted for column 'c3' at row 1 +Warning 1264 Out of range value adjusted for column 'c4' at row 1 +Warning 1264 Out of range value adjusted for column 'c5' at row 1 +Warning 1264 Out of range value adjusted for column 'c6' at row 1 Warning 1264 Out of range value adjusted for column 'c7' at row 1 Warning 1264 Out of range value adjusted for column 'c12' at row 1 execute my_select ; -c1 -1 -c2 -1 -c3 -1 -c4 -1 -c5 -1 -c6 -1 +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 c7 -3.40282e+38 c8 -1.11111111111111e+50 c9 -1.11111111111111e+50 From a613b341184df8a8d842c8e8d2da5d0ae32e27ef Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Oct 2006 13:38:06 +0200 Subject: [PATCH 13/15] BUG#22550 (Replication of BIT column failing): Adding test case. mysql-test/extra/rpl_tests/rpl_row_basic.test: Rename: mysql-test/include/rpl_row_basic.inc -> mysql-test/extra/rpl_tests/rpl_row_basic.test mysql-test/r/rpl_row_basic_11bugs.result: Result change mysql-test/t/rpl_row_basic_11bugs.test: Adding test case for bug. mysql-test/t/rpl_row_basic_2myisam.test: Moving test include file to extra/rpl_tests mysql-test/t/rpl_row_basic_3innodb.test: Moving test include file to extra/rpl_tests mysql-test/t/rpl_row_basic_7ndb.test: Moving test include file to extra/rpl_tests --- .../rpl_tests/rpl_row_basic.test} | 0 mysql-test/r/rpl_row_basic_11bugs.result | 22 ++++++++++++++++++- mysql-test/t/rpl_row_basic_11bugs.test | 22 ++++++++++++++++++- mysql-test/t/rpl_row_basic_2myisam.test | 2 +- mysql-test/t/rpl_row_basic_3innodb.test | 2 +- mysql-test/t/rpl_row_basic_7ndb.test | 2 +- 6 files changed, 45 insertions(+), 5 deletions(-) rename mysql-test/{include/rpl_row_basic.inc => extra/rpl_tests/rpl_row_basic.test} (100%) diff --git a/mysql-test/include/rpl_row_basic.inc b/mysql-test/extra/rpl_tests/rpl_row_basic.test similarity index 100% rename from mysql-test/include/rpl_row_basic.inc rename to mysql-test/extra/rpl_tests/rpl_row_basic.test diff --git a/mysql-test/r/rpl_row_basic_11bugs.result b/mysql-test/r/rpl_row_basic_11bugs.result index d768797717b..e49facd2d70 100644 --- a/mysql-test/r/rpl_row_basic_11bugs.result +++ b/mysql-test/r/rpl_row_basic_11bugs.result @@ -99,4 +99,24 @@ a 7 8 9 -DROP TABLE t1; +================ Test for BUG#22550 ================ +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +CREATE TABLE t1 (a BIT(1), b INT) ENGINE=MYISAM; +INSERT INTO t1 VALUES(1,2); +SELECT HEX(a),b FROM t1; +HEX(a) b +1 2 +SELECT HEX(a),b FROM t1; +HEX(a) b +1 2 +UPDATE t1 SET a=0 WHERE b=2; +SELECT HEX(a),b FROM t1; +HEX(a) b +0 2 +SELECT HEX(a),b FROM t1; +HEX(a) b +0 2 diff --git a/mysql-test/t/rpl_row_basic_11bugs.test b/mysql-test/t/rpl_row_basic_11bugs.test index e636824284d..37bfd01e260 100644 --- a/mysql-test/t/rpl_row_basic_11bugs.test +++ b/mysql-test/t/rpl_row_basic_11bugs.test @@ -93,4 +93,24 @@ INSERT INTO t1 VALUES (7),(8),(9); sync_slave_with_master; SELECT * FROM t1; -DROP TABLE t1; +# Bug#22550: Replication of BIT columns failing +--echo ================ Test for BUG#22550 ================ +--disable_query_log +--source include/master-slave-reset.inc +--enable_query_log + +connection master; +CREATE TABLE t1 (a BIT(1), b INT) ENGINE=MYISAM; +sync_slave_with_master; + +connection master; +INSERT INTO t1 VALUES(1,2); +SELECT HEX(a),b FROM t1; +sync_slave_with_master; +SELECT HEX(a),b FROM t1; + +connection master; +UPDATE t1 SET a=0 WHERE b=2; +SELECT HEX(a),b FROM t1; +sync_slave_with_master; +SELECT HEX(a),b FROM t1; diff --git a/mysql-test/t/rpl_row_basic_2myisam.test b/mysql-test/t/rpl_row_basic_2myisam.test index 471f4d6dbc5..c2cef800ec8 100644 --- a/mysql-test/t/rpl_row_basic_2myisam.test +++ b/mysql-test/t/rpl_row_basic_2myisam.test @@ -1,3 +1,3 @@ let $type= 'MYISAM' ; let $extra_index= ; --- source include/rpl_row_basic.inc +-- source extra/rpl_tests/rpl_row_basic.test diff --git a/mysql-test/t/rpl_row_basic_3innodb.test b/mysql-test/t/rpl_row_basic_3innodb.test index b97f1543cc3..89effc4b3bb 100644 --- a/mysql-test/t/rpl_row_basic_3innodb.test +++ b/mysql-test/t/rpl_row_basic_3innodb.test @@ -2,5 +2,5 @@ let $type= 'INNODB' ; let $extra_index= ; --- source include/rpl_row_basic.inc +-- source extra/rpl_tests/rpl_row_basic.test diff --git a/mysql-test/t/rpl_row_basic_7ndb.test b/mysql-test/t/rpl_row_basic_7ndb.test index 464600c590a..1ec2fb333ae 100644 --- a/mysql-test/t/rpl_row_basic_7ndb.test +++ b/mysql-test/t/rpl_row_basic_7ndb.test @@ -1,5 +1,5 @@ -- source include/have_ndb.inc let $type= 'NDB' ; let $extra_index= ; --- source include/rpl_row_basic.inc +-- source extra/rpl_tests/rpl_row_basic.test -- source include/master-slave-end.inc From fd5ea175a32281319f41e64132d4a60040e8e8b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Oct 2006 17:05:33 +0500 Subject: [PATCH 14/15] sql_yacc.yy: After merge fix. field.cc: After merge fix sql/field.cc: After merge fix sql/sql_yacc.yy: After merge fix. --- sql/field.cc | 1 - sql/sql_yacc.yy | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 63b516b992b..0eed60a344f 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3574,7 +3574,6 @@ void Field_long::sql_type(String &res) const int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) { ASSERT_COLUMN_MARKED_FOR_WRITE; - longlong tmp; int error= 0; char *end; ulonglong tmp; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d55e32a2c42..e48c7d5fad6 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1353,7 +1353,7 @@ event_tail: Lex->sql_command= SQLCOM_CREATE_EVENT; Lex->expr_allows_subselect= TRUE; } - + ; ev_schedule_time: EVERY_SYM expr interval { From dc4418edcfd468a8f612aa04045abfe8fe3f0e1e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Oct 2006 18:48:50 +0500 Subject: [PATCH 15/15] Automerge fix: "Out of range value" error message adjusted to 5.1. --- mysql-test/r/log_tables.result | 4 +-- mysql-test/r/ps_2myisam.result | 24 ++++++------- mysql-test/r/ps_3innodb.result | 24 ++++++------- mysql-test/r/ps_4heap.result | 24 ++++++------- mysql-test/r/ps_5merge.result | 48 ++++++++++++------------- mysql-test/r/ps_7ndb.result | 24 ++++++------- mysql-test/r/round.result | 32 ++++++++--------- mysql-test/r/select.result | 12 +------ mysql-test/r/strict_autoinc_4bdb.result | 6 ++-- 9 files changed, 94 insertions(+), 104 deletions(-) diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index 33f6c0c7af2..a9683cc7c56 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -112,8 +112,8 @@ slow_log CREATE TABLE `slow_log` ( alter table mysql.general_log engine=myisam; alter table mysql.slow_log engine=myisam; Warnings: -Warning 1264 Out of range value for column 'last_insert_id' at row 0 -Warning 1264 Out of range value for column 'insert_id' at row 0 +Warning 1366 Incorrect integer value: '' for column 'last_insert_id' at row 0 +Warning 1366 Incorrect integer value: '' for column 'insert_id' at row 0 show create table mysql.general_log; Table Create Table general_log CREATE TABLE `general_log` ( diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 597310e58b3..2bfd6d31ac9 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -2689,12 +2689,12 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; @@ -2739,12 +2739,12 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index fc32d0a62ab..607a0426bd7 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -2672,12 +2672,12 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; @@ -2722,12 +2722,12 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index f327c4ad3be..f4eec0c610c 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -2673,12 +2673,12 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; @@ -2723,12 +2723,12 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 6c9a9af69ab..38e4626d59c 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -2609,12 +2609,12 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; @@ -2659,12 +2659,12 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; @@ -5623,12 +5623,12 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; @@ -5673,12 +5673,12 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index 678a0d63b3d..9e0577f8ae2 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -2672,12 +2672,12 @@ set @arg00= '1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; @@ -2722,12 +2722,12 @@ set @arg00= '-1.11111111111111111111e+50' ; execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -Warning 1264 Out of range value adjusted for column 'c3' at row 1 -Warning 1264 Out of range value adjusted for column 'c4' at row 1 -Warning 1264 Out of range value adjusted for column 'c5' at row 1 -Warning 1264 Out of range value adjusted for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 Warning 1264 Out of range value for column 'c7' at row 1 Warning 1264 Out of range value for column 'c12' at row 1 execute my_select ; diff --git a/mysql-test/r/round.result b/mysql-test/r/round.result index e9a80df0f49..49a00885f34 100644 --- a/mysql-test/r/round.result +++ b/mysql-test/r/round.result @@ -5,7 +5,7 @@ INSERT INTO t1 VALUES ('0.5'); INSERT INTO t1 VALUES ('127.4'); INSERT INTO t1 VALUES ('127.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'sint8' at row 1 +Warning 1264 Out of range value for column 'sint8' at row 1 INSERT INTO t1 VALUES ('-0.1'); INSERT INTO t1 VALUES ('-0.5'); INSERT INTO t1 VALUES ('-127.4'); @@ -13,7 +13,7 @@ INSERT INTO t1 VALUES ('-127.5'); INSERT INTO t1 VALUES ('-128.4'); INSERT INTO t1 VALUES ('-128.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'sint8' at row 1 +Warning 1264 Out of range value for column 'sint8' at row 1 SELECT * FROM t1; sint8 0 @@ -35,11 +35,11 @@ INSERT INTO t1 VALUES ('127.5'); INSERT INTO t1 VALUES ('-0.1'); INSERT INTO t1 VALUES ('-0.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'uint8' at row 1 +Warning 1264 Out of range value for column 'uint8' at row 1 INSERT INTO t1 VALUES ('255.4'); INSERT INTO t1 VALUES ('255.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'uint8' at row 1 +Warning 1264 Out of range value for column 'uint8' at row 1 SELECT * FROM t1; uint8 0 @@ -57,7 +57,7 @@ INSERT INTO t1 VALUES ('0.5'); INSERT INTO t1 VALUES ('32767.4'); INSERT INTO t1 VALUES ('32767.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'sint16' at row 1 +Warning 1264 Out of range value for column 'sint16' at row 1 INSERT INTO t1 VALUES ('-0.1'); INSERT INTO t1 VALUES ('-0.5'); INSERT INTO t1 VALUES ('-32767.4'); @@ -65,7 +65,7 @@ INSERT INTO t1 VALUES ('-32767.5'); INSERT INTO t1 VALUES ('-32768.4'); INSERT INTO t1 VALUES ('-32768.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'sint16' at row 1 +Warning 1264 Out of range value for column 'sint16' at row 1 SELECT * FROM t1; sint16 0 @@ -87,11 +87,11 @@ INSERT INTO t1 VALUES ('32767.5'); INSERT INTO t1 VALUES ('-0.1'); INSERT INTO t1 VALUES ('-0.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'uint16' at row 1 +Warning 1264 Out of range value for column 'uint16' at row 1 INSERT INTO t1 VALUES ('65535.4'); INSERT INTO t1 VALUES ('65535.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'uint16' at row 1 +Warning 1264 Out of range value for column 'uint16' at row 1 SELECT * FROM t1; uint16 0 @@ -109,7 +109,7 @@ INSERT INTO t1 VALUES ('0.5'); INSERT INTO t1 VALUES ('8388607.4'); INSERT INTO t1 VALUES ('8388607.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'sint24' at row 1 +Warning 1264 Out of range value for column 'sint24' at row 1 INSERT INTO t1 VALUES ('-0.1'); INSERT INTO t1 VALUES ('-0.5'); INSERT INTO t1 VALUES ('-8388607.4'); @@ -117,7 +117,7 @@ INSERT INTO t1 VALUES ('-8388607.5'); INSERT INTO t1 VALUES ('-8388608.4'); INSERT INTO t1 VALUES ('-8388608.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'sint24' at row 1 +Warning 1264 Out of range value for column 'sint24' at row 1 SELECT * FROM t1; sint24 0 @@ -139,11 +139,11 @@ INSERT INTO t1 VALUES ('8388607.5'); INSERT INTO t1 VALUES ('-0.1'); INSERT INTO t1 VALUES ('-0.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'uint24' at row 1 +Warning 1264 Out of range value for column 'uint24' at row 1 INSERT INTO t1 VALUES ('16777215.4'); INSERT INTO t1 VALUES ('16777215.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'uint24' at row 1 +Warning 1264 Out of range value for column 'uint24' at row 1 SELECT * FROM t1; uint24 0 @@ -161,7 +161,7 @@ INSERT INTO t1 VALUES ('0.5'); INSERT INTO t1 VALUES ('9223372036854775807.4'); INSERT INTO t1 VALUES ('9223372036854775807.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'sint64' at row 1 +Warning 1264 Out of range value for column 'sint64' at row 1 INSERT INTO t1 VALUES ('-0.1'); INSERT INTO t1 VALUES ('-0.5'); INSERT INTO t1 VALUES ('-9223372036854775807.4'); @@ -169,7 +169,7 @@ INSERT INTO t1 VALUES ('-9223372036854775807.5'); INSERT INTO t1 VALUES ('-9223372036854775808.4'); INSERT INTO t1 VALUES ('-9223372036854775808.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'sint64' at row 1 +Warning 1264 Out of range value for column 'sint64' at row 1 SELECT * FROM t1; sint64 0 @@ -191,11 +191,11 @@ INSERT INTO t1 VALUES ('9223372036854775807.5'); INSERT INTO t1 VALUES ('-0.1'); INSERT INTO t1 VALUES ('-0.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'uint64' at row 1 +Warning 1264 Out of range value for column 'uint64' at row 1 INSERT INTO t1 VALUES ('18446744073709551615.4'); INSERT INTO t1 VALUES ('18446744073709551615.5'); Warnings: -Warning 1264 Out of range value adjusted for column 'uint64' at row 1 +Warning 1264 Out of range value for column 'uint64' at row 1 INSERT INTO t1 VALUES ('1844674407370955161.0'); INSERT INTO t1 VALUES ('1844674407370955161.1'); INSERT INTO t1 VALUES ('1844674407370955161.2'); diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 254f91d27d9..8800ce248d5 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2730,16 +2730,6 @@ ERROR 42000: Key 'a' doesn't exist in table 't1' EXPLAIN SELECT * FROM t1 FORCE INDEX (a); ERROR 42000: Key 'a' doesn't exist in table 't1' DROP TABLE t1; -ERROR HY000: Key 'a' doesn't exist in table 't1' -EXPLAIN SELECT * FROM t1 FORCE INDEX (a); -ERROR HY000: Key 'a' doesn't exist in table 't1' -DROP TABLE t1; -CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); -INSERT INTO t1 VALUES (10); -SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; -i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') -1 1 1 1 -DROP TABLE t1; CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (1,1), (2,1), (4,10); CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b)); @@ -2819,7 +2809,7 @@ CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); INSERT INTO t1 VALUES (10); SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1; i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01') -0 1 1 1 +1 1 1 1 DROP TABLE t1; CREATE TABLE t1 ( K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', diff --git a/mysql-test/r/strict_autoinc_4bdb.result b/mysql-test/r/strict_autoinc_4bdb.result index 73683b645e2..48ebe196baf 100644 --- a/mysql-test/r/strict_autoinc_4bdb.result +++ b/mysql-test/r/strict_autoinc_4bdb.result @@ -6,21 +6,21 @@ primary key (`a`) ) engine = 'BDB' ; set @@sql_mode='strict_all_tables'; insert into t1 values(1000); -ERROR 22003: Out of range value adjusted for column 'a' at row 1 +ERROR 22003: Out of range value for column 'a' at row 1 select count(*) from t1; count(*) 0 set auto_increment_increment=1000; set auto_increment_offset=700; insert into t1 values(null); -ERROR 22003: Out of range value adjusted for column 'a' at row 1 +ERROR 22003: Out of range value for column 'a' at row 1 select count(*) from t1; count(*) 0 set @@sql_mode=@org_mode; insert into t1 values(null); Warnings: -Warning 1264 Out of range value adjusted for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 1 select * from t1; a 127