From ae6970e6bc4cf01a2c91ddaabf8ec31b4377e04c Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Tue, 20 Jun 2006 23:05:55 +0400 Subject: [PATCH] select.result: Added test case for bug#18759 Incorrect string to numeric conversion. select.test: Added test case for bug#18759 Incorrect string to numeric conversion. item_cmpfunc.cc: Cleanup after fix for bug#18360 removal --- mysql-test/r/select.result | 6 ++++++ mysql-test/t/select.test | 19 +++++++++++++++++++ sql/item_cmpfunc.cc | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 7808e787e39..c7df11ab018 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2738,3 +2738,9 @@ 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), i in ('1e+01') FROM t1; +i='1e+01' i=1e+01 i in (1e+01) i in ('1e+01') +0 1 1 1 +DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index f7b5a2fbcb6..4cdfc220350 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2278,4 +2278,23 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX (a); DROP TABLE t1; +# +# Bug #18759 "Incorrect string to numeric conversion" +# +# This test is here so that the behavior will not be changed to 4.1 +# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string +# will be converted internally to real (double) value and it is not +# as accurate as bigint (longlong) for integers. Thus the results may +# vary. In 5.1 internally it is decimal, which is a string type and +# will be more accurate. Due to rather big changes needed to fix this +# in 4.1 or 5.0 it is not desired to do it in the stable versions. +# +# This test is here only to make sure that behavior is not changed in +# 4.1 and 5.0 +# +CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL); +INSERT INTO t1 VALUES (10); +SELECT i='1e+01',i=1e+01, i in (1e+01), i in ('1e+01') FROM t1; +DROP TABLE t1; + # End of 4.1 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 5055b5f4197..f14efc7187b 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -136,7 +136,8 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) } continue; } - if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM) + if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM && + items[i]->result_type() != INT_RESULT) { field= ((Item_field *)items[i]->real_item())->field; break;