From d32c4314ed5935e7a03f443e3f26bae47e572600 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Aug 2005 22:42:50 +0400 Subject: [PATCH] Fix bug #12298 Typo in timestampdiff() function name results in erroneous view being created. Item_func_timestamp_diff::func_name() were returning function name as "timestamp_diff" thus when view was executed function parameters wasn't properly recognized and error was raised. mysql-test/r/func_time.result: Fix test result after bugfix #12298 sql/item_timefunc.h: Fix bug #12298 Typo in timestampdiff() function name results in wrong view being created. mysql-test/t/view.test: Test case for bug #12298 Typo in timestampdiff() function name results in erroneous view being created. mysql-test/r/view.result: Test case for bug #12298 Typo in timestampdiff() function name results in erroneous view being created. --- mysql-test/r/func_time.result | 2 +- mysql-test/r/view.result | 5 +++++ mysql-test/t/view.test | 7 ++++++- sql/item_timefunc.h | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 63da5589c57..28eb48790e0 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -687,7 +687,7 @@ timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select timestamp_diff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestamp_diff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2` +Note 1003 select timestampdiff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2` select last_day('2005-00-00'); last_day('2005-00-00') NULL diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 87e80a03c08..2af2f06ad52 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2092,3 +2092,8 @@ SELECT a FROM v1; a DROP VIEW v1; DROP TABLE t1,t2,t3,t4,t5; +create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1; +select * from v1; +f1 +1 +drop view v1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 961b8ec13d6..ceff7af401c 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1936,4 +1936,9 @@ SELECT a FROM v1; DROP VIEW v1; DROP TABLE t1,t2,t3,t4,t5; - +# +# Bug #12298 Typo in function name results in erroneous view being created. +# +create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1; +select * from v1; +drop view v1; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index e79bc25030b..d9300451fe7 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -860,7 +860,7 @@ class Item_func_timestamp_diff :public Item_int_func public: Item_func_timestamp_diff(Item *a,Item *b,interval_type type_arg) :Item_int_func(a,b), int_type(type_arg) {} - const char *func_name() const { return "timestamp_diff"; } + const char *func_name() const { return "timestampdiff"; } longlong val_int(); void fix_length_and_dec() {