summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/union.result16
-rw-r--r--mysql-test/t/union.test14
-rw-r--r--sql/item.cc3
3 files changed, 32 insertions, 1 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 97c1a8b4d49..c0b364d0fde 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1860,3 +1860,19 @@ DROP TABLE t17059925, t2, t3;
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= @old_log_output;
SET @@global.slow_query_log= @old_slow_query_log;
+#
+# Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
+# WRONG VALUES
+#
+SET NAMES utf8;
+SET @advertAcctId = 1000003;
+select @advertAcctId as a from dual union all select 1.0 from dual;
+a
+1000003.0
+1.0
+SET NAMES latin1;
+SET @advertAcctId = 1000003;
+select @advertAcctId as a from dual union all select 1.0 from dual;
+a
+1000003.0
+1.0
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index 147c1d3834b..d7e362558e3 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -1256,3 +1256,17 @@ SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= @old_log_output;
SET @@global.slow_query_log= @old_slow_query_log;
+--echo #
+--echo # Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
+--echo # WRONG VALUES
+--echo #
+
+let $old_charset= `SELECT @@character_set_client`;
+
+SET NAMES utf8;
+SET @advertAcctId = 1000003;
+select @advertAcctId as a from dual union all select 1.0 from dual;
+
+eval SET NAMES $old_charset;
+SET @advertAcctId = 1000003;
+select @advertAcctId as a from dual union all select 1.0 from dual;
diff --git a/sql/item.cc b/sql/item.cc
index a37a61453e8..07d64881eeb 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -8266,6 +8266,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
}
if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
{
+ collation.set_numeric();
decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
int item_int_part= item->decimal_int_part();
int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;