From 8d2738367efc79a0adf5dfbb159de3d2ec84d6f1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 23 Mar 2011 13:31:06 +0100 Subject: [PATCH] lp:740173 5.1-micro reports incorrect Length metadata for TIME expressions --- mysql-test/r/metadata.result | 6 ++++++ mysql-test/t/metadata.test | 8 ++++++++ sql/item_timefunc.h | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result index 4fa3d2f56fc..e209193a2c0 100644 --- a/mysql-test/r/metadata.result +++ b/mysql-test/r/metadata.result @@ -210,3 +210,9 @@ f1 DROP VIEW v1; DROP TABLE t1; End of 5.0 tests +select cast('01:01:01' as time), cast('01:01:01' as time(2)); +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def cast('01:01:01' as time) 11 9 8 Y 128 0 63 +def cast('01:01:01' as time(2)) 11 12 11 Y 128 2 63 +cast('01:01:01' as time) cast('01:01:01' as time(2)) +01:01:01 01:01:01.00 diff --git a/mysql-test/t/metadata.test b/mysql-test/t/metadata.test index 9bfb47c53be..115c320003a 100644 --- a/mysql-test/t/metadata.test +++ b/mysql-test/t/metadata.test @@ -143,3 +143,11 @@ DROP VIEW v1; DROP TABLE t1; --echo End of 5.0 tests + +--enable_metadata + +# +# lp:740173 5.1-micro reports incorrect Length metadata for TIME expressions +# +select cast('01:01:01' as time), cast('01:01:01' as time(2)); + diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index df4491e61e6..68fd34aa29e 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -698,7 +698,7 @@ public: { collation.set(&my_charset_bin); maybe_null= 1; - max_length= MAX_TIME_WIDTH; + max_length= MIN_TIME_WIDTH; if (decimals == NOT_FIXED_DEC) decimals= args[0]->decimals; if (decimals && decimals != NOT_FIXED_DEC)