diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result index dd08c8fe157..ba9da20264e 100644 --- a/mysql-test/main/func_time.result +++ b/mysql-test/main/func_time.result @@ -48,7 +48,7 @@ now()-curdate()*1000000-curtime() select strcmp(current_timestamp(),concat(current_date()," ",current_time())) as exp; exp 0 -select strcmp(localtime(),concat(current_date()," ",current_time())) as exp; +select strcmp(localtime(),current_time()) as exp; exp 0 select strcmp(localtimestamp(),concat(current_date()," ",current_time())) as exp; @@ -6397,3 +6397,32 @@ SET @@timestamp= DEFAULT; # # End of 10.5 tests # +# +# Start of 11.6 tests +# +# +# MDEV-34829 LOCALTIME returns a wrong data type +# +SET timestamp=UNIX_TIMESTAMP('2024-08-28 14:47:00'); +SELECT LOCALTIME; +LOCALTIME +14:47:00 +EXPLAIN EXTENDED SELECT LOCALTIME; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select curtime() AS `LOCALTIME` +CREATE TABLE t1 AS SELECT LOCALTIME; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `LOCALTIME` time NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +SELECT * FROM t1; +LOCALTIME +14:47:00 +DROP TABLE t1; +SET timestamp=DEFAULT; +# +# End of 11.6 tests +# diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 757dafb55c8..99f1820e9f6 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -25,7 +25,7 @@ select sec_to_time(90011e-1), sec_to_time(1234567890123e30); select sec_to_time(1234567890123), sec_to_time('99999999999999999999999999999'); select now()-curdate()*1000000-curtime(); select strcmp(current_timestamp(),concat(current_date()," ",current_time())) as exp; -select strcmp(localtime(),concat(current_date()," ",current_time())) as exp; +select strcmp(localtime(),current_time()) as exp; select strcmp(localtimestamp(),concat(current_date()," ",current_time())) as exp; select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w") as exp; select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w")) as exp; @@ -3249,3 +3249,24 @@ SET @@timestamp= DEFAULT; --echo # --echo # End of 10.5 tests --echo # + +--echo # +--echo # Start of 11.6 tests +--echo # + +--echo # +--echo # MDEV-34829 LOCALTIME returns a wrong data type +--echo # + +SET timestamp=UNIX_TIMESTAMP('2024-08-28 14:47:00'); +SELECT LOCALTIME; +EXPLAIN EXTENDED SELECT LOCALTIME; +CREATE TABLE t1 AS SELECT LOCALTIME; +SHOW CREATE TABLE t1; +SELECT * FROM t1; +DROP TABLE t1; +SET timestamp=DEFAULT; + +--echo # +--echo # End of 11.6 tests +--echo # diff --git a/mysql-test/main/func_time_hires.result b/mysql-test/main/func_time_hires.result index 6b65b25289e..02c095b83c9 100644 --- a/mysql-test/main/func_time_hires.result +++ b/mysql-test/main/func_time_hires.result @@ -13,7 +13,7 @@ utc_timestamp(1) 2010-12-31 22:01:01.1 utc_time(2) 22:01:01.12 current_time(3) 01:01:01.123 current_timestamp(4) 2011-01-01 01:01:01.1234 -localtime(5) 2011-01-01 01:01:01.12345 +localtime(5) 01:01:01.12345 localtimestamp(6) 2011-01-01 01:01:01.123456 time_to_sec('12:34:56') 45296 time_to_sec('12:34:56.789') 45296.789 @@ -45,7 +45,7 @@ t1 CREATE TABLE `t1` ( `utc_time(2)` time(2) NOT NULL, `current_time(3)` time(3) NOT NULL, `current_timestamp(4)` datetime(4) NOT NULL, - `localtime(5)` datetime(5) NOT NULL, + `localtime(5)` time(5) NOT NULL, `localtimestamp(6)` datetime(6) NOT NULL, `time_to_sec(123456)` bigint(17) DEFAULT NULL, `time_to_sec('12:34:56.789')` decimal(19,3) DEFAULT NULL @@ -60,7 +60,7 @@ utc_timestamp(1) 2010-12-31 22:01:01.1 utc_time(2) 22:01:01.12 current_time(3) 01:01:01.123 current_timestamp(4) 2011-01-01 01:01:01.1234 -localtime(5) 2011-01-01 01:01:01.12345 +localtime(5) 01:01:01.12345 localtimestamp(6) 2011-01-01 01:01:01.123456 time_to_sec(123456) 45296 time_to_sec('12:34:56.789') 45296.789 diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index 9f1e24dec06..fe5af9333e8 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -2627,7 +2627,7 @@ a 16:46:40 1970-01-12 16:46:40 16:46:40 -1970-01-12 16:46:40 +16:46:40 1970-01-12 16:46:40 1970-01-12 16:46:40 1000000 diff --git a/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result b/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result index 31ea8f776e6..14dd5208aed 100644 --- a/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result +++ b/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result @@ -38,9 +38,9 @@ create or replace table t1 (a datetime as (curtime()) PERSISTENT); ERROR HY000: Function or expression 'curtime()' cannot be used in the GENERATED ALWAYS AS clause of `a` # LOCALTIME(), LOCALTIME create or replace table t1 (a datetime, b varchar(10) as (localtime()) PERSISTENT); -ERROR HY000: Function or expression 'current_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b` +ERROR HY000: Function or expression 'curtime()' cannot be used in the GENERATED ALWAYS AS clause of `b` create or replace table t1 (a datetime, b varchar(10) as (localtime) PERSISTENT); -ERROR HY000: Function or expression 'current_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b` +ERROR HY000: Function or expression 'curtime()' cannot be used in the GENERATED ALWAYS AS clause of `b` # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6) create or replace table t1 (a datetime, b varchar(10) as (localtimestamp()) PERSISTENT); ERROR HY000: Function or expression 'current_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b` diff --git a/sql/lex.h b/sql/lex.h index 38b0039a6cf..3cf4db19f07 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -352,7 +352,7 @@ SYMBOL symbols[] = { { "LIST", SYM(LIST_SYM)}, { "LOAD", SYM(LOAD)}, { "LOCAL", SYM(LOCAL_SYM)}, - { "LOCALTIME", SYM(NOW_SYM)}, + { "LOCALTIME", SYM(CURTIME)}, { "LOCALTIMESTAMP", SYM(NOW_SYM)}, { "LOCK", SYM(LOCK_SYM)}, { "LOCKED", SYM(LOCKED_SYM)},