summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/func_time_hires.result18
-rw-r--r--mysql-test/t/func_time_hires.test16
-rw-r--r--sql/item_timefunc.h2
3 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/r/func_time_hires.result b/mysql-test/r/func_time_hires.result
index 0fe79c65882..f96815a6977 100644
--- a/mysql-test/r/func_time_hires.result
+++ b/mysql-test/r/func_time_hires.result
@@ -149,3 +149,21 @@ select * from t1;
a
2011-01-01 01:01:01.123456
drop table t1;
+create table t1 (f1 timestamp(6));
+insert into t1 values ('2002-07-15 21:00:00');
+select time(f1) from t1;
+time(f1)
+21:00:00.000000
+select time(f1) from t1 union all select time(f1) from t1;
+time(f1)
+21:00:00.000000
+21:00:00.000000
+alter table t1 modify f1 varchar(100);
+select time(f1) from t1;
+time(f1)
+21:00:00
+select time(f1) from t1 union all select time(f1) from t1;
+time(f1)
+21:00:00.000000
+21:00:00.000000
+drop table t1;
diff --git a/mysql-test/t/func_time_hires.test b/mysql-test/t/func_time_hires.test
index 6c0f1085cf2..c651b4aa718 100644
--- a/mysql-test/t/func_time_hires.test
+++ b/mysql-test/t/func_time_hires.test
@@ -78,3 +78,19 @@ insert t1 values (now(6));
select * from t1;
drop table t1;
+#
+# lp:736358 Unexpected increased timestamp resolution with UNION
+#
+# timestamp(6) case is fixed:
+create table t1 (f1 timestamp(6));
+insert into t1 values ('2002-07-15 21:00:00');
+select time(f1) from t1;
+select time(f1) from t1 union all select time(f1) from t1;
+#alter table t1 modify f1 timestamp;
+#select time(f1) from t1;
+#select time(f1) from t1 union all select time(f1) from t1;
+# but the effect cannot be eliminated completely:
+alter table t1 modify f1 varchar(100);
+select time(f1) from t1;
+select time(f1) from t1 union all select time(f1) from t1;
+drop table t1;
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index b28daed202b..df4491e61e6 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -699,6 +699,8 @@ public:
collation.set(&my_charset_bin);
maybe_null= 1;
max_length= MAX_TIME_WIDTH;
+ if (decimals == NOT_FIXED_DEC)
+ decimals= args[0]->decimals;
if (decimals && decimals != NOT_FIXED_DEC)
max_length+= min(decimals, MAX_SEC_PART_DIGITS) + 1;
}