diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index cf3a1739710..bad52e39b60 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1826,3 +1826,8 @@ ERROR 42S21: Duplicate column name 's1' drop table t1; create view v1(k, K) as select 1,2; ERROR 42S21: Duplicate column name 'K' +create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t; +select * from v1; +t +01:00 +drop view v1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index a59c882359d..13a5f8cef1f 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1599,6 +1599,7 @@ drop table t1; create view v1 as select cast(1 as decimal); select * from v1; drop view v1; + # # Bug#11298 insert into select from VIEW produces incorrect result when # using ORDER BY @@ -1665,3 +1666,10 @@ drop table t1; # set names differ by case only -- error 1060 create view v1(k, K) as select 1,2; + +# +# using time_format in view (BUG#7521) +# +create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t; +select * from v1; +drop view v1; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 5c172b4698b..a6dd9f7da91 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -503,7 +503,8 @@ public: Item_func_date_format(Item *a,Item *b,bool is_time_format_arg) :Item_str_func(a,b),is_time_format(is_time_format_arg) {} String *val_str(String *str); - const char *func_name() const { return "date_format"; } + const char *func_name() const + { return is_time_format ? "time_format" : "date_format"; } void fix_length_and_dec(); uint format_length(const String *format); };