From: Date: March 29 2006 4:31pm Subject: bk commit into 5.0 tree (bar:1.2108) BUG#15098 List-Archive: http://lists.mysql.com/commits/4278 X-Bug: 15098 Message-Id: <200603291431.k2TEVNKK084157@bar.intranet.mysql.r18.ru> Below is the list of changes that have just been committed into a local 5.0 repository of bar. When bar does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2108 06/03/29 19:31:16 bar@stripped +2 -0 Additional 5.0 fix for Bug#15098: CAST(column double TO signed int), wrong result which was fixed originally in 4.1. sql/field.cc 1.302 06/03/29 19:31:06 bar@stripped +21 -2 Adding a "truncated value" warning. mysql-test/r/cast.result 1.42 06/03/29 19:31:06 bar@stripped +3 -0 Fixing test results # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: bar # Host: bar.intranet.mysql.r18.ru # Root: /usr/home/bar/mysql-5.0 --- 1.301/sql/field.cc 2006-03-28 17:07:19 +05:00 +++ 1.302/sql/field.cc 2006-03-29 19:31:06 +05:00 @@ -4232,6 +4232,7 @@ longlong Field_double::val_int(void) { double j; + longlong res; #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) { @@ -4242,10 +4243,28 @@ doubleget(j,ptr); /* Check whether we fit into longlong range */ if (j <= (double) LONGLONG_MIN) - return (longlong) LONGLONG_MIN; + { + res= (longlong) LONGLONG_MIN; + goto warn; + } if (j >= (double) (ulonglong) LONGLONG_MAX) - return (longlong) LONGLONG_MAX; + { + res= (longlong) LONGLONG_MAX; + goto warn; + } return (longlong) rint(j); + +warn: + { + char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; + String tmp(buf, sizeof(buf), &my_charset_latin1), *str; + str= val_str(&tmp, 0); + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER", + str->c_ptr()); + } + return res; } --- 1.41/mysql-test/r/cast.result 2006-03-28 18:20:37 +05:00 +++ 1.42/mysql-test/r/cast.result 2006-03-29 19:31:06 +05:00 @@ -344,6 +344,9 @@ double_val cast_val -1e+30 -9223372036854775808 1e+30 9223372036854775807 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '-1e+30' +Warning 1292 Truncated incorrect INTEGER value: '1e+30' DROP TABLE t1; select cast('1.2' as decimal(3,2)); cast('1.2' as decimal(3,2))