From 94eb819296c99b2f1d1a68a5a12eabe18e2f4874 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Fri, 4 Aug 2023 00:28:13 +0530 Subject: [PATCH] MDEV-31684 Add timezone information to DATE_FORMAT Before starting to go over the format string, prepare the current time zone information incase '%z' or '%Z' is encountered. This information can be obtained as given below: A) If timezone is not set ( meaning we are working with system timezone): Get the MYSQL_TIME representation for current time and GMT time using current thread variable for timezone and timezone variable for UTC respectively. This MYSQL_TIME variable will be used to calculate time difference. Also convert current time in second to tm structure to get system timezone information. B) If timezone is set as offset: Get timezone information using current timezone information and store in appropriate variable. C) If timezone is set as some place (example: Europe/Berlin) Get timezone information by searching the timezone. During internal timezone search, information like timeoffset from UTC and abbrevation is stored in another relevant structure. Hence use the same information. --- mysql-test/main/date_formats.result | 46 +++++++++++ mysql-test/main/date_formats.test | 48 +++++++++++ mysql-test/main/mysqldump-system,win.rdiff | 12 +-- mysql-test/main/mysqldump-system.result | 81 +++++++++++-------- .../suite/funcs_1/r/is_tables_mysql.result | 2 +- .../funcs_1/r/is_tables_mysql_embedded.result | 4 +- scripts/mariadb_test_data_timezone.sql | 10 +-- sql/item_timefunc.cc | 55 ++++++++++++- sql/tztime.cc | 78 ++++++++++++++++-- sql/tztime.h | 15 ++++ 10 files changed, 292 insertions(+), 59 deletions(-) diff --git a/mysql-test/main/date_formats.result b/mysql-test/main/date_formats.result index a9e400805ca..d26c07d7c96 100644 --- a/mysql-test/main/date_formats.result +++ b/mysql-test/main/date_formats.result @@ -555,3 +555,49 @@ time_format('01 02:02:02', '%T') select time_format('2001-01-01 02:02:02', '%T'); time_format('2001-01-01 02:02:02', '%T') 02:02:02 +# +# Beginning of 11.3 test +# +# MDEV-31684: Add timezone information to DATE_FORMAT +# +SET @old_timezone= @@time_zone; +# Using named timezones +SET TIME_ZONE='Japan'; +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; +current_timezone ++0900 JST +SET @@time_zone='Europe/Moscow'; +SELECT DATE_FORMAT('1965-02-17 22:23:00', '%z %Z') AS current_timezone; +current_timezone ++0300 MSK +SELECT DATE_FORMAT('1965-12-31 22:23:00', '%z %Z') AS current_timezone; +current_timezone ++0300 MSK +SELECT DATE_FORMAT('1985-06-01', '%z %Z'); +DATE_FORMAT('1985-06-01', '%z %Z') ++0400 MSD +# Using positive and negative offset +SET TIME_ZONE= '-05:30'; +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; +current_timezone +-0530 -05:30 +SET TIME_ZONE= '+04:30'; +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; +current_timezone ++0430 +04:30 +# Using UTC +SET TIME_ZONE='UTC'; +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; +current_timezone ++0000 UTC +# using system time +# +# output depends on system time information. Hence replacing +# to avoid result diff test failures. +# +SET @@time_zone= default; +SELECT DATE_FORMAT('2009-10+|-HH:MM ABC22:23:00', '%z %Z') AS current_timezone; +current_timezone ++|-HH:MM ABC +SET @@time_zone= @old_timezone; +# End of 11.3 test diff --git a/mysql-test/main/date_formats.test b/mysql-test/main/date_formats.test index 0e6f0f8ec85..08a1fa493ce 100644 --- a/mysql-test/main/date_formats.test +++ b/mysql-test/main/date_formats.test @@ -256,3 +256,51 @@ select time_format('2001-01-01 02:02:02', '%d %T'); select time_format('01 02:02:02', '%d %T'); select time_format('01 02:02:02', '%T'); select time_format('2001-01-01 02:02:02', '%T'); + +--echo # +--echo # Beginning of 11.3 test +--echo # +--echo # MDEV-31684: Add timezone information to DATE_FORMAT +--echo # + +SET @old_timezone= @@time_zone; + + +--echo # Using named timezones + +SET TIME_ZONE='Japan'; +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; + +SET @@time_zone='Europe/Moscow'; +SELECT DATE_FORMAT('1965-02-17 22:23:00', '%z %Z') AS current_timezone; +SELECT DATE_FORMAT('1965-12-31 22:23:00', '%z %Z') AS current_timezone; +SELECT DATE_FORMAT('1985-06-01', '%z %Z'); + +--echo # Using positive and negative offset + +SET TIME_ZONE= '-05:30'; +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; + +SET TIME_ZONE= '+04:30'; +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; + + +--echo # Using UTC + +SET TIME_ZONE='UTC'; +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; + +--echo # using system time +--echo # +--echo # output depends on system time information. Hence replacing +--echo # to avoid result diff test failures. +--echo # + +SET @@time_zone= default; + +--replace_regex /[+-][0-9]* [A-Z]*/+|-HH:MM ABC/ +SELECT DATE_FORMAT('2009-10-04 22:23:00', '%z %Z') AS current_timezone; + +SET @@time_zone= @old_timezone; + +--echo # End of 11.3 test diff --git a/mysql-test/main/mysqldump-system,win.rdiff b/mysql-test/main/mysqldump-system,win.rdiff index 57ce772a452..50c08438dcf 100644 --- a/mysql-test/main/mysqldump-system,win.rdiff +++ b/mysql-test/main/mysqldump-system,win.rdiff @@ -3,24 +3,24 @@ @@ -449,9 +449,9 @@ Table Checksum mysql.roles_mapping 2510045525 - mysql.time_zone_transition 3895294076 + mysql.time_zone_transition 3719776009 -mysql.plugin 1587119305 +mysql.plugin 2184891911 mysql.servers 2079085450 -mysql.func 3241572444 +mysql.func 310494789 - mysql.innodb_table_stats 347867921 - mysql.table_stats 664320059 + mysql.innodb_table_stats 1285726777 + mysql.table_stats 2836905944 # Opps.... @@ -484,9 +484,9 @@ Table Checksum mysql.roles_mapping 2510045525 - mysql.time_zone_transition 3895294076 + mysql.time_zone_transition 3719776009 -mysql.plugin 1587119305 +mysql.plugin 2184891911 mysql.servers 2079085450 -mysql.func 3241572444 +mysql.func 310494789 - mysql.innodb_table_stats 347867921 - mysql.table_stats 664320059 + mysql.innodb_table_stats 1285726777 + mysql.table_stats 2836905944 DROP FUNCTION IF EXISTS metaphon; diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result index 559f6f29f44..5186fbe7a08 100644 --- a/mysql-test/main/mysqldump-system.result +++ b/mysql-test/main/mysqldump-system.result @@ -96,29 +96,29 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; REPLACE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}'); +('mysql','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `index_stats` WRITE; /*!40000 ALTER TABLE `index_stats` DISABLE KEYS */; REPLACE INTO `index_stats` VALUES -('mysql','tz','PRIMARY',1,98.2500); +('mysql','tz','PRIMARY',1,78.8000); /*!40000 ALTER TABLE `index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `table_stats` WRITE; /*!40000 ALTER TABLE `table_stats` DISABLE KEYS */; REPLACE INTO `table_stats` VALUES -('mysql','tz',393); +('mysql','tz',394); /*!40000 ALTER TABLE `table_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_index_stats` WRITE; /*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */; REPLACE INTO `innodb_index_stats` VALUES -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'), +('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), +('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), ('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); /*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */; @@ -127,7 +127,7 @@ UNLOCK TABLES; LOCK TABLES `innodb_table_stats` WRITE; /*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */; REPLACE INTO `innodb_table_stats` VALUES -('mysql','tz','2019-12-31 21:00:00',393,1,0); +('mysql','tz','2019-12-31 21:00:00',394,1,0); /*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -140,7 +140,8 @@ REPLACE INTO `time_zone` VALUES (2,'N'), (3,'N'), (4,'Y'), -(5,'N'); +(5,'N'), +(6,'Y'); /*!40000 ALTER TABLE `time_zone` ENABLE KEYS */; UNLOCK TABLES; @@ -148,6 +149,7 @@ LOCK TABLES `time_zone_name` WRITE; /*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */; REPLACE INTO `time_zone_name` VALUES ('Europe/Moscow',3), +('India/Kolkata',6), ('Japan',5), ('leap/Europe/Moscow',4), ('MET',1), @@ -159,6 +161,7 @@ UNLOCK TABLES; LOCK TABLES `time_zone_leap_second` WRITE; /*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */; REPLACE INTO `time_zone_leap_second` VALUES +(174834660,1), (78796800,1), (94694401,2), (126230402,3), @@ -579,7 +582,8 @@ REPLACE INTO `time_zone_transition` VALUES (4,2108588422,8), (4,2121894022,9), (4,2140038022,8), -(5,-1009875600,1); +(5,-1009875600,1), +(6,174834660,1); /*!40000 ALTER TABLE `time_zone_transition` ENABLE KEYS */; UNLOCK TABLES; @@ -616,7 +620,8 @@ REPLACE INTO `time_zone_transition_type` VALUES (4,10,10800,1,'EEST'), (4,11,7200,0,'EET'), (5,0,32400,0,'CJT'), -(5,1,32400,0,'JST'); +(5,1,32400,0,'JST'), +(6,1,19800,0,'IST'); /*!40000 ALTER TABLE `time_zone_transition_type` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -710,29 +715,29 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; REPLACE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}'); +('mysql','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `index_stats` WRITE; /*!40000 ALTER TABLE `index_stats` DISABLE KEYS */; REPLACE INTO `index_stats` VALUES -('mysql','tz','PRIMARY',1,98.2500); +('mysql','tz','PRIMARY',1,78.8000); /*!40000 ALTER TABLE `index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `table_stats` WRITE; /*!40000 ALTER TABLE `table_stats` DISABLE KEYS */; REPLACE INTO `table_stats` VALUES -('mysql','tz',393); +('mysql','tz',394); /*!40000 ALTER TABLE `table_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_index_stats` WRITE; /*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */; REPLACE INTO `innodb_index_stats` VALUES -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'), +('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), +('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), ('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); /*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */; @@ -741,7 +746,7 @@ UNLOCK TABLES; LOCK TABLES `innodb_table_stats` WRITE; /*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */; REPLACE INTO `innodb_table_stats` VALUES -('mysql','tz','2019-12-31 21:00:00',393,1,0); +('mysql','tz','2019-12-31 21:00:00',394,1,0); /*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -754,7 +759,8 @@ REPLACE INTO `time_zone` VALUES (2,'N'), (3,'N'), (4,'Y'), -(5,'N'); +(5,'N'), +(6,'Y'); /*!40000 ALTER TABLE `time_zone` ENABLE KEYS */; UNLOCK TABLES; @@ -762,6 +768,7 @@ LOCK TABLES `time_zone_name` WRITE; /*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */; REPLACE INTO `time_zone_name` VALUES ('Europe/Moscow',3), +('India/Kolkata',6), ('Japan',5), ('leap/Europe/Moscow',4), ('MET',1), @@ -773,6 +780,7 @@ UNLOCK TABLES; LOCK TABLES `time_zone_leap_second` WRITE; /*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */; REPLACE INTO `time_zone_leap_second` VALUES +(174834660,1), (78796800,1), (94694401,2), (126230402,3), @@ -1193,7 +1201,8 @@ REPLACE INTO `time_zone_transition` VALUES (4,2108588422,8), (4,2121894022,9), (4,2140038022,8), -(5,-1009875600,1); +(5,-1009875600,1), +(6,174834660,1); /*!40000 ALTER TABLE `time_zone_transition` ENABLE KEYS */; UNLOCK TABLES; @@ -1230,7 +1239,8 @@ REPLACE INTO `time_zone_transition_type` VALUES (4,10,10800,1,'EEST'), (4,11,7200,0,'EET'), (5,0,32400,0,'CJT'), -(5,1,32400,0,'JST'); +(5,1,32400,0,'JST'), +(6,1,19800,0,'IST'); /*!40000 ALTER TABLE `time_zone_transition_type` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -1301,29 +1311,29 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; INSERT IGNORE INTO `column_stats` VALUES -('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}'); +('mysql','tz','Time_zone_id','1','6',0.0000,4.0000,78.8000,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340101523, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.327411168, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"6\", \"size\": 0.005076142, \"ndv\": 2}]}'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `index_stats` WRITE; /*!40000 ALTER TABLE `index_stats` DISABLE KEYS */; INSERT IGNORE INTO `index_stats` VALUES -('mysql','tz','PRIMARY',1,98.2500); +('mysql','tz','PRIMARY',1,78.8000); /*!40000 ALTER TABLE `index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `table_stats` WRITE; /*!40000 ALTER TABLE `table_stats` DISABLE KEYS */; INSERT IGNORE INTO `table_stats` VALUES -('mysql','tz',393); +('mysql','tz',394); /*!40000 ALTER TABLE `table_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_index_stats` WRITE; /*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */; INSERT IGNORE INTO `innodb_index_stats` VALUES -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'), -('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'), +('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',5,1,'Time_zone_id'), +('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',394,1,'Time_zone_id,Transition_time'), ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'), ('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); /*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */; @@ -1332,7 +1342,7 @@ UNLOCK TABLES; LOCK TABLES `innodb_table_stats` WRITE; /*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */; INSERT IGNORE INTO `innodb_table_stats` VALUES -('mysql','tz','2019-12-31 21:00:00',393,1,0); +('mysql','tz','2019-12-31 21:00:00',394,1,0); /*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -1345,7 +1355,8 @@ INSERT IGNORE INTO `time_zone` VALUES (2,'N'), (3,'N'), (4,'Y'), -(5,'N'); +(5,'N'), +(6,'Y'); /*!40000 ALTER TABLE `time_zone` ENABLE KEYS */; UNLOCK TABLES; @@ -1353,6 +1364,7 @@ LOCK TABLES `time_zone_name` WRITE; /*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */; INSERT IGNORE INTO `time_zone_name` VALUES ('Europe/Moscow',3), +('India/Kolkata',6), ('Japan',5), ('leap/Europe/Moscow',4), ('MET',1), @@ -1364,6 +1376,7 @@ UNLOCK TABLES; LOCK TABLES `time_zone_leap_second` WRITE; /*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */; INSERT IGNORE INTO `time_zone_leap_second` VALUES +(174834660,1), (78796800,1), (94694401,2), (126230402,3), @@ -1784,7 +1797,8 @@ INSERT IGNORE INTO `time_zone_transition` VALUES (4,2108588422,8), (4,2121894022,9), (4,2140038022,8), -(5,-1009875600,1); +(5,-1009875600,1), +(6,174834660,1); /*!40000 ALTER TABLE `time_zone_transition` ENABLE KEYS */; UNLOCK TABLES; @@ -1821,7 +1835,8 @@ INSERT IGNORE INTO `time_zone_transition_type` VALUES (4,10,10800,1,'EEST'), (4,11,7200,0,'EET'), (5,0,32400,0,'CJT'), -(5,1,32400,0,'JST'); +(5,1,32400,0,'JST'), +(6,1,19800,0,'IST'); /*!40000 ALTER TABLE `time_zone_transition_type` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -1845,12 +1860,12 @@ CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin, mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats; Table Checksum mysql.roles_mapping 2510045525 -mysql.time_zone_transition 3895294076 +mysql.time_zone_transition 3719776009 mysql.plugin 1587119305 mysql.servers 2079085450 mysql.func 3241572444 -mysql.innodb_table_stats 347867921 -mysql.table_stats 664320059 +mysql.innodb_table_stats 1285726777 +mysql.table_stats 2836905944 # Opps.... CREATE USER mariadb_test_restore IDENTIFIED BY 'getitback'; GRANT ALL ON *.* TO mariadb_test_restore WITH GRANT OPTION; @@ -1880,12 +1895,12 @@ CHECKSUM TABLE mysql.roles_mapping, mysql.time_zone_transition, mysql.plugin, mysql.servers, mysql.func, mysql.innodb_table_stats, mysql.table_stats; Table Checksum mysql.roles_mapping 2510045525 -mysql.time_zone_transition 3895294076 +mysql.time_zone_transition 3719776009 mysql.plugin 1587119305 mysql.servers 2079085450 mysql.func 3241572444 -mysql.innodb_table_stats 347867921 -mysql.table_stats 664320059 +mysql.innodb_table_stats 1285726777 +mysql.table_stats 2836905944 DROP FUNCTION IF EXISTS metaphon; DROP SERVER s1; DELETE FROM mysql.column_stats WHERE db_name='mysql' and table_name in ('tz', 'gtid_slave_pos'); diff --git a/mysql-test/suite/funcs_1/r/is_tables_mysql.result b/mysql-test/suite/funcs_1/r/is_tables_mysql.result index 7cfef92c09d..177b7150559 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_tables_mysql.result @@ -623,7 +623,7 @@ DATA_LENGTH #DL# MAX_DATA_LENGTH #MDL# INDEX_LENGTH #IL# DATA_FREE #DF# -AUTO_INCREMENT 6 +AUTO_INCREMENT 7 CREATE_TIME #CRT# UPDATE_TIME #UT# CHECK_TIME #CT# diff --git a/mysql-test/suite/funcs_1/r/is_tables_mysql_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_mysql_embedded.result index 450f0f5fe3d..9ee806bfdeb 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_mysql_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_tables_mysql_embedded.result @@ -623,7 +623,7 @@ DATA_LENGTH #DL# MAX_DATA_LENGTH #MDL# INDEX_LENGTH #IL# DATA_FREE #DF# -AUTO_INCREMENT 6 +AUTO_INCREMENT 7 CREATE_TIME #CRT# UPDATE_TIME #UT# CHECK_TIME #CT# @@ -1412,7 +1412,7 @@ DATA_LENGTH #DL# MAX_DATA_LENGTH #MDL# INDEX_LENGTH #IL# DATA_FREE #DF# -AUTO_INCREMENT 6 +AUTO_INCREMENT 7 CREATE_TIME #CRT# UPDATE_TIME #UT# CHECK_TIME #CT# diff --git a/scripts/mariadb_test_data_timezone.sql b/scripts/mariadb_test_data_timezone.sql index 8d07d413cef..83bb548478d 100644 --- a/scripts/mariadb_test_data_timezone.sql +++ b/scripts/mariadb_test_data_timezone.sql @@ -14,8 +14,8 @@ -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA -INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES ('MET', 1), ('UTC', 2), ('Universal', 2), ('Europe/Moscow',3), ('leap/Europe/Moscow',4), ('Japan', 5); -INSERT INTO time_zone (Time_zone_id, Use_leap_seconds) VALUES (1,'N'), (2,'N'), (3,'N'), (4,'Y'), (5,'N'); -INSERT INTO time_zone_transition (Time_zone_id, Transition_time, Transition_type_id) VALUES (1, -1693706400, 0) ,(1, -1680483600, 1) ,(1, -1663455600, 2) ,(1, -1650150000, 3) ,(1, -1632006000, 2) ,(1, -1618700400, 3) ,(1, -938905200, 2) ,(1, -857257200, 3) ,(1, -844556400, 2) ,(1, -828226800, 3) ,(1, -812502000, 2) ,(1, -796777200, 3) ,(1, 228877200, 2) ,(1, 243997200, 3) ,(1, 260326800, 2) ,(1, 276051600, 3) ,(1, 291776400, 2) ,(1, 307501200, 3) ,(1, 323830800, 2) ,(1, 338950800, 3) ,(1, 354675600, 2) ,(1, 370400400, 3) ,(1, 386125200, 2) ,(1, 401850000, 3) ,(1, 417574800, 2) ,(1, 433299600, 3) ,(1, 449024400, 2) ,(1, 465354000, 3) ,(1, 481078800, 2) ,(1, 496803600, 3) ,(1, 512528400, 2) ,(1, 528253200, 3) ,(1, 543978000, 2) ,(1, 559702800, 3) ,(1, 575427600, 2) ,(1, 591152400, 3) ,(1, 606877200, 2) ,(1, 622602000, 3) ,(1, 638326800, 2) ,(1, 654656400, 3) ,(1, 670381200, 2) ,(1, 686106000, 3) ,(1, 701830800, 2) ,(1, 717555600, 3) ,(1, 733280400, 2) ,(1, 749005200, 3) ,(1, 764730000, 2) ,(1, 780454800, 3) ,(1, 796179600, 2) ,(1, 811904400, 3) ,(1, 828234000, 2) ,(1, 846378000, 3) ,(1, 859683600, 2) ,(1, 877827600, 3) ,(1, 891133200, 2) ,(1, 909277200, 3) ,(1, 922582800, 2) ,(1, 941331600, 3) ,(1, 954032400, 2) ,(1, 972781200, 3) ,(1, 985482000, 2) ,(1, 1004230800, 3) ,(1, 1017536400, 2) ,(1, 1035680400, 3) ,(1, 1048986000, 2) ,(1, 1067130000, 3) ,(1, 1080435600, 2) ,(1, 1099184400, 3) ,(1, 1111885200, 2) ,(1, 1130634000, 3) ,(1, 1143334800, 2) ,(1, 1162083600, 3) ,(1, 1174784400, 2) ,(1, 1193533200, 3) ,(1, 1206838800, 2) ,(1, 1224982800, 3) ,(1, 1238288400, 2) ,(1, 1256432400, 3) ,(1, 1269738000, 2) ,(1, 1288486800, 3) ,(1, 1301187600, 2) ,(1, 1319936400, 3) ,(1, 1332637200, 2) ,(1, 1351386000, 3) ,(1, 1364691600, 2) ,(1, 1382835600, 3) ,(1, 1396141200, 2) ,(1, 1414285200, 3) ,(1, 1427590800, 2) ,(1, 1445734800, 3) ,(1, 1459040400, 2) ,(1, 1477789200, 3) ,(1, 1490490000, 2) ,(1, 1509238800, 3) ,(1, 1521939600, 2) ,(1, 1540688400, 3) ,(1, 1553994000, 2) ,(1, 1572138000, 3) ,(1, 1585443600, 2) ,(1, 1603587600, 3) ,(1, 1616893200, 2) ,(1, 1635642000, 3) ,(1, 1648342800, 2) ,(1, 1667091600, 3) ,(1, 1679792400, 2) ,(1, 1698541200, 3) ,(1, 1711846800, 2) ,(1, 1729990800, 3) ,(1, 1743296400, 2) ,(1, 1761440400, 3) ,(1, 1774746000, 2) ,(1, 1792890000, 3) ,(1, 1806195600, 2) ,(1, 1824944400, 3) ,(1, 1837645200, 2) ,(1, 1856394000, 3) ,(1, 1869094800, 2) ,(1, 1887843600, 3) ,(1, 1901149200, 2) ,(1, 1919293200, 3) ,(1, 1932598800, 2) ,(1, 1950742800, 3) ,(1, 1964048400, 2) ,(1, 1982797200, 3) ,(1, 1995498000, 2) ,(1, 2014246800, 3) ,(1, 2026947600, 2) ,(1, 2045696400, 3) ,(1, 2058397200, 2) ,(1, 2077146000, 3) ,(1, 2090451600, 2) ,(1, 2108595600, 3) ,(1, 2121901200, 2) ,(1, 2140045200, 3) ,(3, -1688265000, 2) ,(3, -1656819048, 1) ,(3, -1641353448, 2) ,(3, -1627965048, 3) ,(3, -1618716648, 1) ,(3, -1596429048, 3) ,(3, -1593829848, 5) ,(3, -1589860800, 4) ,(3, -1542427200, 5) ,(3, -1539493200, 6) ,(3, -1525323600, 5) ,(3, -1522728000, 4) ,(3, -1491188400, 7) ,(3, -1247536800, 4) ,(3, 354920400, 5) ,(3, 370728000, 4) ,(3, 386456400, 5) ,(3, 402264000, 4) ,(3, 417992400, 5) ,(3, 433800000, 4) ,(3, 449614800, 5) ,(3, 465346800, 8) ,(3, 481071600, 9) ,(3, 496796400, 8) ,(3, 512521200, 9) ,(3, 528246000, 8) ,(3, 543970800, 9) ,(3, 559695600, 8) ,(3, 575420400, 9) ,(3, 591145200, 8) ,(3, 606870000, 9) ,(3, 622594800, 8) ,(3, 638319600, 9) ,(3, 654649200, 8) ,(3, 670374000, 10) ,(3, 686102400, 11) ,(3, 695779200, 8) ,(3, 701812800, 5) ,(3, 717534000, 4) ,(3, 733273200, 9) ,(3, 748998000, 8) ,(3, 764722800, 9) ,(3, 780447600, 8) ,(3, 796172400, 9) ,(3, 811897200, 8) ,(3, 828226800, 9) ,(3, 846370800, 8) ,(3, 859676400, 9) ,(3, 877820400, 8) ,(3, 891126000, 9) ,(3, 909270000, 8) ,(3, 922575600, 9) ,(3, 941324400, 8) ,(3, 954025200, 9) ,(3, 972774000, 8) ,(3, 985474800, 9) ,(3, 1004223600, 8) ,(3, 1017529200, 9) ,(3, 1035673200, 8) ,(3, 1048978800, 9) ,(3, 1067122800, 8) ,(3, 1080428400, 9) ,(3, 1099177200, 8) ,(3, 1111878000, 9) ,(3, 1130626800, 8) ,(3, 1143327600, 9) ,(3, 1162076400, 8) ,(3, 1174777200, 9) ,(3, 1193526000, 8) ,(3, 1206831600, 9) ,(3, 1224975600, 8) ,(3, 1238281200, 9) ,(3, 1256425200, 8) ,(3, 1269730800, 9) ,(3, 1288479600, 8) ,(3, 1301180400, 9) ,(3, 1319929200, 8) ,(3, 1332630000, 9) ,(3, 1351378800, 8) ,(3, 1364684400, 9) ,(3, 1382828400, 8) ,(3, 1396134000, 9) ,(3, 1414278000, 8) ,(3, 1427583600, 9) ,(3, 1445727600, 8) ,(3, 1459033200, 9) ,(3, 1477782000, 8) ,(3, 1490482800, 9) ,(3, 1509231600, 8) ,(3, 1521932400, 9) ,(3, 1540681200, 8) ,(3, 1553986800, 9) ,(3, 1572130800, 8) ,(3, 1585436400, 9) ,(3, 1603580400, 8) ,(3, 1616886000, 9) ,(3, 1635634800, 8) ,(3, 1648335600, 9) ,(3, 1667084400, 8) ,(3, 1679785200, 9) ,(3, 1698534000, 8) ,(3, 1711839600, 9) ,(3, 1729983600, 8) ,(3, 1743289200, 9) ,(3, 1761433200, 8) ,(3, 1774738800, 9) ,(3, 1792882800, 8) ,(3, 1806188400, 9) ,(3, 1824937200, 8) ,(3, 1837638000, 9) ,(3, 1856386800, 8) ,(3, 1869087600, 9) ,(3, 1887836400, 8) ,(3, 1901142000, 9) ,(3, 1919286000, 8) ,(3, 1932591600, 9) ,(3, 1950735600, 8) ,(3, 1964041200, 9) ,(3, 1982790000, 8) ,(3, 1995490800, 9) ,(3, 2014239600, 8) ,(3, 2026940400, 9) ,(3, 2045689200, 8) ,(3, 2058390000, 9) ,(3, 2077138800, 8) ,(3, 2090444400, 9) ,(3, 2108588400, 8) ,(3, 2121894000, 9) ,(3, 2140038000, 8) ,(4, -1688265000, 2) ,(4, -1656819048, 1) ,(4, -1641353448, 2) ,(4, -1627965048, 3) ,(4, -1618716648, 1) ,(4, -1596429048, 3) ,(4, -1593829848, 5) ,(4, -1589860800, 4) ,(4, -1542427200, 5) ,(4, -1539493200, 6) ,(4, -1525323600, 5) ,(4, -1522728000, 4) ,(4, -1491188400, 7) ,(4, -1247536800, 4) ,(4, 354920409, 5) ,(4, 370728010, 4) ,(4, 386456410, 5) ,(4, 402264011, 4) ,(4, 417992411, 5) ,(4, 433800012, 4) ,(4, 449614812, 5) ,(4, 465346812, 8) ,(4, 481071612, 9) ,(4, 496796413, 8) ,(4, 512521213, 9) ,(4, 528246013, 8) ,(4, 543970813, 9) ,(4, 559695613, 8) ,(4, 575420414, 9) ,(4, 591145214, 8) ,(4, 606870014, 9) ,(4, 622594814, 8) ,(4, 638319615, 9) ,(4, 654649215, 8) ,(4, 670374016, 10) ,(4, 686102416, 11) ,(4, 695779216, 8) ,(4, 701812816, 5) ,(4, 717534017, 4) ,(4, 733273217, 9) ,(4, 748998018, 8) ,(4, 764722818, 9) ,(4, 780447619, 8) ,(4, 796172419, 9) ,(4, 811897219, 8) ,(4, 828226820, 9) ,(4, 846370820, 8) ,(4, 859676420, 9) ,(4, 877820421, 8) ,(4, 891126021, 9) ,(4, 909270021, 8) ,(4, 922575622, 9) ,(4, 941324422, 8) ,(4, 954025222, 9) ,(4, 972774022, 8) ,(4, 985474822, 9) ,(4, 1004223622, 8) ,(4, 1017529222, 9) ,(4, 1035673222, 8) ,(4, 1048978822, 9) ,(4, 1067122822, 8) ,(4, 1080428422, 9) ,(4, 1099177222, 8) ,(4, 1111878022, 9) ,(4, 1130626822, 8) ,(4, 1143327622, 9) ,(4, 1162076422, 8) ,(4, 1174777222, 9) ,(4, 1193526022, 8) ,(4, 1206831622, 9) ,(4, 1224975622, 8) ,(4, 1238281222, 9) ,(4, 1256425222, 8) ,(4, 1269730822, 9) ,(4, 1288479622, 8) ,(4, 1301180422, 9) ,(4, 1319929222, 8) ,(4, 1332630022, 9) ,(4, 1351378822, 8) ,(4, 1364684422, 9) ,(4, 1382828422, 8) ,(4, 1396134022, 9) ,(4, 1414278022, 8) ,(4, 1427583622, 9) ,(4, 1445727622, 8) ,(4, 1459033222, 9) ,(4, 1477782022, 8) ,(4, 1490482822, 9) ,(4, 1509231622, 8) ,(4, 1521932422, 9) ,(4, 1540681222, 8) ,(4, 1553986822, 9) ,(4, 1572130822, 8) ,(4, 1585436422, 9) ,(4, 1603580422, 8) ,(4, 1616886022, 9) ,(4, 1635634822, 8) ,(4, 1648335622, 9) ,(4, 1667084422, 8) ,(4, 1679785222, 9) ,(4, 1698534022, 8) ,(4, 1711839622, 9) ,(4, 1729983622, 8) ,(4, 1743289222, 9) ,(4, 1761433222, 8) ,(4, 1774738822, 9) ,(4, 1792882822, 8) ,(4, 1806188422, 9) ,(4, 1824937222, 8) ,(4, 1837638022, 9) ,(4, 1856386822, 8) ,(4, 1869087622, 9) ,(4, 1887836422, 8) ,(4, 1901142022, 9) ,(4, 1919286022, 8) ,(4, 1932591622, 9) ,(4, 1950735622, 8) ,(4, 1964041222, 9) ,(4, 1982790022, 8) ,(4, 1995490822, 9) ,(4, 2014239622, 8) ,(4, 2026940422, 9) ,(4, 2045689222, 8) ,(4, 2058390022, 9) ,(4, 2077138822, 8) ,(4, 2090444422, 9) ,(4, 2108588422, 8) ,(4, 2121894022, 9) ,(4, 2140038022, 8) ,(5, -1009875600, 1); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES (1, 0, 7200, 1, 'MEST') ,(1, 1, 3600, 0, 'MET') ,(1, 2, 7200, 1, 'MEST') ,(1, 3, 3600, 0, 'MET') ,(2, 0, 0, 0, 'UTC') ,(3, 0, 9000, 0, 'MMT') ,(3, 1, 12648, 1, 'MST') ,(3, 2, 9048, 0, 'MMT') ,(3, 3, 16248, 1, 'MDST') ,(3, 4, 10800, 0, 'MSK') ,(3, 5, 14400, 1, 'MSD') ,(3, 6, 18000, 1, 'MSD') ,(3, 7, 7200, 0, 'EET') ,(3, 8, 10800, 0, 'MSK') ,(3, 9, 14400, 1, 'MSD') ,(3, 10, 10800, 1, 'EEST') ,(3, 11, 7200, 0, 'EET') ,(4, 0, 9000, 0, 'MMT') ,(4, 1, 12648, 1, 'MST') ,(4, 2, 9048, 0, 'MMT') ,(4, 3, 16248, 1, 'MDST') ,(4, 4, 10800, 0, 'MSK') ,(4, 5, 14400, 1, 'MSD') ,(4, 6, 18000, 1, 'MSD') ,(4, 7, 7200, 0, 'EET') ,(4, 8, 10800, 0, 'MSK') ,(4, 9, 14400, 1, 'MSD') ,(4, 10, 10800, 1, 'EEST') ,(4, 11, 7200, 0, 'EET') ,(5, 0, 32400, 0, 'CJT') ,(5, 1, 32400, 0, 'JST'); -INSERT INTO time_zone_leap_second (Transition_time, Correction) VALUES (78796800, 1) ,(94694401, 2) ,(126230402, 3) ,(157766403, 4) ,(189302404, 5) ,(220924805, 6) ,(252460806, 7) ,(283996807, 8) ,(315532808, 9) ,(362793609, 10) ,(394329610, 11) ,(425865611, 12) ,(489024012, 13) ,(567993613, 14) ,(631152014, 15) ,(662688015, 16) ,(709948816, 17) ,(741484817, 18) ,(773020818, 19) ,(820454419, 20) ,(867715220, 21) ,(915148821, 22); +INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES ('MET', 1), ('UTC', 2), ('Universal', 2), ('Europe/Moscow',3), ('leap/Europe/Moscow',4), ('Japan', 5), ('India/Kolkata', 6); +INSERT INTO time_zone (Time_zone_id, Use_leap_seconds) VALUES (1,'N'), (2,'N'), (3,'N'), (4,'Y'), (5,'N'), (6, 'Y'); +INSERT INTO time_zone_transition (Time_zone_id, Transition_time, Transition_type_id) VALUES (1, -1693706400, 0) ,(1, -1680483600, 1) ,(1, -1663455600, 2) ,(1, -1650150000, 3) ,(1, -1632006000, 2) ,(1, -1618700400, 3) ,(1, -938905200, 2) ,(1, -857257200, 3) ,(1, -844556400, 2) ,(1, -828226800, 3) ,(1, -812502000, 2) ,(1, -796777200, 3) ,(1, 228877200, 2) ,(1, 243997200, 3) ,(1, 260326800, 2) ,(1, 276051600, 3) ,(1, 291776400, 2) ,(1, 307501200, 3) ,(1, 323830800, 2) ,(1, 338950800, 3) ,(1, 354675600, 2) ,(1, 370400400, 3) ,(1, 386125200, 2) ,(1, 401850000, 3) ,(1, 417574800, 2) ,(1, 433299600, 3) ,(1, 449024400, 2) ,(1, 465354000, 3) ,(1, 481078800, 2) ,(1, 496803600, 3) ,(1, 512528400, 2) ,(1, 528253200, 3) ,(1, 543978000, 2) ,(1, 559702800, 3) ,(1, 575427600, 2) ,(1, 591152400, 3) ,(1, 606877200, 2) ,(1, 622602000, 3) ,(1, 638326800, 2) ,(1, 654656400, 3) ,(1, 670381200, 2) ,(1, 686106000, 3) ,(1, 701830800, 2) ,(1, 717555600, 3) ,(1, 733280400, 2) ,(1, 749005200, 3) ,(1, 764730000, 2) ,(1, 780454800, 3) ,(1, 796179600, 2) ,(1, 811904400, 3) ,(1, 828234000, 2) ,(1, 846378000, 3) ,(1, 859683600, 2) ,(1, 877827600, 3) ,(1, 891133200, 2) ,(1, 909277200, 3) ,(1, 922582800, 2) ,(1, 941331600, 3) ,(1, 954032400, 2) ,(1, 972781200, 3) ,(1, 985482000, 2) ,(1, 1004230800, 3) ,(1, 1017536400, 2) ,(1, 1035680400, 3) ,(1, 1048986000, 2) ,(1, 1067130000, 3) ,(1, 1080435600, 2) ,(1, 1099184400, 3) ,(1, 1111885200, 2) ,(1, 1130634000, 3) ,(1, 1143334800, 2) ,(1, 1162083600, 3) ,(1, 1174784400, 2) ,(1, 1193533200, 3) ,(1, 1206838800, 2) ,(1, 1224982800, 3) ,(1, 1238288400, 2) ,(1, 1256432400, 3) ,(1, 1269738000, 2) ,(1, 1288486800, 3) ,(1, 1301187600, 2) ,(1, 1319936400, 3) ,(1, 1332637200, 2) ,(1, 1351386000, 3) ,(1, 1364691600, 2) ,(1, 1382835600, 3) ,(1, 1396141200, 2) ,(1, 1414285200, 3) ,(1, 1427590800, 2) ,(1, 1445734800, 3) ,(1, 1459040400, 2) ,(1, 1477789200, 3) ,(1, 1490490000, 2) ,(1, 1509238800, 3) ,(1, 1521939600, 2) ,(1, 1540688400, 3) ,(1, 1553994000, 2) ,(1, 1572138000, 3) ,(1, 1585443600, 2) ,(1, 1603587600, 3) ,(1, 1616893200, 2) ,(1, 1635642000, 3) ,(1, 1648342800, 2) ,(1, 1667091600, 3) ,(1, 1679792400, 2) ,(1, 1698541200, 3) ,(1, 1711846800, 2) ,(1, 1729990800, 3) ,(1, 1743296400, 2) ,(1, 1761440400, 3) ,(1, 1774746000, 2) ,(1, 1792890000, 3) ,(1, 1806195600, 2) ,(1, 1824944400, 3) ,(1, 1837645200, 2) ,(1, 1856394000, 3) ,(1, 1869094800, 2) ,(1, 1887843600, 3) ,(1, 1901149200, 2) ,(1, 1919293200, 3) ,(1, 1932598800, 2) ,(1, 1950742800, 3) ,(1, 1964048400, 2) ,(1, 1982797200, 3) ,(1, 1995498000, 2) ,(1, 2014246800, 3) ,(1, 2026947600, 2) ,(1, 2045696400, 3) ,(1, 2058397200, 2) ,(1, 2077146000, 3) ,(1, 2090451600, 2) ,(1, 2108595600, 3) ,(1, 2121901200, 2) ,(1, 2140045200, 3) ,(3, -1688265000, 2) ,(3, -1656819048, 1) ,(3, -1641353448, 2) ,(3, -1627965048, 3) ,(3, -1618716648, 1) ,(3, -1596429048, 3) ,(3, -1593829848, 5) ,(3, -1589860800, 4) ,(3, -1542427200, 5) ,(3, -1539493200, 6) ,(3, -1525323600, 5) ,(3, -1522728000, 4) ,(3, -1491188400, 7) ,(3, -1247536800, 4) ,(3, 354920400, 5) ,(3, 370728000, 4) ,(3, 386456400, 5) ,(3, 402264000, 4) ,(3, 417992400, 5) ,(3, 433800000, 4) ,(3, 449614800, 5) ,(3, 465346800, 8) ,(3, 481071600, 9) ,(3, 496796400, 8) ,(3, 512521200, 9) ,(3, 528246000, 8) ,(3, 543970800, 9) ,(3, 559695600, 8) ,(3, 575420400, 9) ,(3, 591145200, 8) ,(3, 606870000, 9) ,(3, 622594800, 8) ,(3, 638319600, 9) ,(3, 654649200, 8) ,(3, 670374000, 10) ,(3, 686102400, 11) ,(3, 695779200, 8) ,(3, 701812800, 5) ,(3, 717534000, 4) ,(3, 733273200, 9) ,(3, 748998000, 8) ,(3, 764722800, 9) ,(3, 780447600, 8) ,(3, 796172400, 9) ,(3, 811897200, 8) ,(3, 828226800, 9) ,(3, 846370800, 8) ,(3, 859676400, 9) ,(3, 877820400, 8) ,(3, 891126000, 9) ,(3, 909270000, 8) ,(3, 922575600, 9) ,(3, 941324400, 8) ,(3, 954025200, 9) ,(3, 972774000, 8) ,(3, 985474800, 9) ,(3, 1004223600, 8) ,(3, 1017529200, 9) ,(3, 1035673200, 8) ,(3, 1048978800, 9) ,(3, 1067122800, 8) ,(3, 1080428400, 9) ,(3, 1099177200, 8) ,(3, 1111878000, 9) ,(3, 1130626800, 8) ,(3, 1143327600, 9) ,(3, 1162076400, 8) ,(3, 1174777200, 9) ,(3, 1193526000, 8) ,(3, 1206831600, 9) ,(3, 1224975600, 8) ,(3, 1238281200, 9) ,(3, 1256425200, 8) ,(3, 1269730800, 9) ,(3, 1288479600, 8) ,(3, 1301180400, 9) ,(3, 1319929200, 8) ,(3, 1332630000, 9) ,(3, 1351378800, 8) ,(3, 1364684400, 9) ,(3, 1382828400, 8) ,(3, 1396134000, 9) ,(3, 1414278000, 8) ,(3, 1427583600, 9) ,(3, 1445727600, 8) ,(3, 1459033200, 9) ,(3, 1477782000, 8) ,(3, 1490482800, 9) ,(3, 1509231600, 8) ,(3, 1521932400, 9) ,(3, 1540681200, 8) ,(3, 1553986800, 9) ,(3, 1572130800, 8) ,(3, 1585436400, 9) ,(3, 1603580400, 8) ,(3, 1616886000, 9) ,(3, 1635634800, 8) ,(3, 1648335600, 9) ,(3, 1667084400, 8) ,(3, 1679785200, 9) ,(3, 1698534000, 8) ,(3, 1711839600, 9) ,(3, 1729983600, 8) ,(3, 1743289200, 9) ,(3, 1761433200, 8) ,(3, 1774738800, 9) ,(3, 1792882800, 8) ,(3, 1806188400, 9) ,(3, 1824937200, 8) ,(3, 1837638000, 9) ,(3, 1856386800, 8) ,(3, 1869087600, 9) ,(3, 1887836400, 8) ,(3, 1901142000, 9) ,(3, 1919286000, 8) ,(3, 1932591600, 9) ,(3, 1950735600, 8) ,(3, 1964041200, 9) ,(3, 1982790000, 8) ,(3, 1995490800, 9) ,(3, 2014239600, 8) ,(3, 2026940400, 9) ,(3, 2045689200, 8) ,(3, 2058390000, 9) ,(3, 2077138800, 8) ,(3, 2090444400, 9) ,(3, 2108588400, 8) ,(3, 2121894000, 9) ,(3, 2140038000, 8) ,(4, -1688265000, 2) ,(4, -1656819048, 1) ,(4, -1641353448, 2) ,(4, -1627965048, 3) ,(4, -1618716648, 1) ,(4, -1596429048, 3) ,(4, -1593829848, 5) ,(4, -1589860800, 4) ,(4, -1542427200, 5) ,(4, -1539493200, 6) ,(4, -1525323600, 5) ,(4, -1522728000, 4) ,(4, -1491188400, 7) ,(4, -1247536800, 4) ,(4, 354920409, 5) ,(4, 370728010, 4) ,(4, 386456410, 5) ,(4, 402264011, 4) ,(4, 417992411, 5) ,(4, 433800012, 4) ,(4, 449614812, 5) ,(4, 465346812, 8) ,(4, 481071612, 9) ,(4, 496796413, 8) ,(4, 512521213, 9) ,(4, 528246013, 8) ,(4, 543970813, 9) ,(4, 559695613, 8) ,(4, 575420414, 9) ,(4, 591145214, 8) ,(4, 606870014, 9) ,(4, 622594814, 8) ,(4, 638319615, 9) ,(4, 654649215, 8) ,(4, 670374016, 10) ,(4, 686102416, 11) ,(4, 695779216, 8) ,(4, 701812816, 5) ,(4, 717534017, 4) ,(4, 733273217, 9) ,(4, 748998018, 8) ,(4, 764722818, 9) ,(4, 780447619, 8) ,(4, 796172419, 9) ,(4, 811897219, 8) ,(4, 828226820, 9) ,(4, 846370820, 8) ,(4, 859676420, 9) ,(4, 877820421, 8) ,(4, 891126021, 9) ,(4, 909270021, 8) ,(4, 922575622, 9) ,(4, 941324422, 8) ,(4, 954025222, 9) ,(4, 972774022, 8) ,(4, 985474822, 9) ,(4, 1004223622, 8) ,(4, 1017529222, 9) ,(4, 1035673222, 8) ,(4, 1048978822, 9) ,(4, 1067122822, 8) ,(4, 1080428422, 9) ,(4, 1099177222, 8) ,(4, 1111878022, 9) ,(4, 1130626822, 8) ,(4, 1143327622, 9) ,(4, 1162076422, 8) ,(4, 1174777222, 9) ,(4, 1193526022, 8) ,(4, 1206831622, 9) ,(4, 1224975622, 8) ,(4, 1238281222, 9) ,(4, 1256425222, 8) ,(4, 1269730822, 9) ,(4, 1288479622, 8) ,(4, 1301180422, 9) ,(4, 1319929222, 8) ,(4, 1332630022, 9) ,(4, 1351378822, 8) ,(4, 1364684422, 9) ,(4, 1382828422, 8) ,(4, 1396134022, 9) ,(4, 1414278022, 8) ,(4, 1427583622, 9) ,(4, 1445727622, 8) ,(4, 1459033222, 9) ,(4, 1477782022, 8) ,(4, 1490482822, 9) ,(4, 1509231622, 8) ,(4, 1521932422, 9) ,(4, 1540681222, 8) ,(4, 1553986822, 9) ,(4, 1572130822, 8) ,(4, 1585436422, 9) ,(4, 1603580422, 8) ,(4, 1616886022, 9) ,(4, 1635634822, 8) ,(4, 1648335622, 9) ,(4, 1667084422, 8) ,(4, 1679785222, 9) ,(4, 1698534022, 8) ,(4, 1711839622, 9) ,(4, 1729983622, 8) ,(4, 1743289222, 9) ,(4, 1761433222, 8) ,(4, 1774738822, 9) ,(4, 1792882822, 8) ,(4, 1806188422, 9) ,(4, 1824937222, 8) ,(4, 1837638022, 9) ,(4, 1856386822, 8) ,(4, 1869087622, 9) ,(4, 1887836422, 8) ,(4, 1901142022, 9) ,(4, 1919286022, 8) ,(4, 1932591622, 9) ,(4, 1950735622, 8) ,(4, 1964041222, 9) ,(4, 1982790022, 8) ,(4, 1995490822, 9) ,(4, 2014239622, 8) ,(4, 2026940422, 9) ,(4, 2045689222, 8) ,(4, 2058390022, 9) ,(4, 2077138822, 8) ,(4, 2090444422, 9) ,(4, 2108588422, 8) ,(4, 2121894022, 9) ,(4, 2140038022, 8) ,(5, -1009875600, 1), (6, 174834660, 1); +INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES (1, 0, 7200, 1, 'MEST') ,(1, 1, 3600, 0, 'MET') ,(1, 2, 7200, 1, 'MEST') ,(1, 3, 3600, 0, 'MET') ,(2, 0, 0, 0, 'UTC') ,(3, 0, 9000, 0, 'MMT') ,(3, 1, 12648, 1, 'MST') ,(3, 2, 9048, 0, 'MMT') ,(3, 3, 16248, 1, 'MDST') ,(3, 4, 10800, 0, 'MSK') ,(3, 5, 14400, 1, 'MSD') ,(3, 6, 18000, 1, 'MSD') ,(3, 7, 7200, 0, 'EET') ,(3, 8, 10800, 0, 'MSK') ,(3, 9, 14400, 1, 'MSD') ,(3, 10, 10800, 1, 'EEST') ,(3, 11, 7200, 0, 'EET') ,(4, 0, 9000, 0, 'MMT') ,(4, 1, 12648, 1, 'MST') ,(4, 2, 9048, 0, 'MMT') ,(4, 3, 16248, 1, 'MDST') ,(4, 4, 10800, 0, 'MSK') ,(4, 5, 14400, 1, 'MSD') ,(4, 6, 18000, 1, 'MSD') ,(4, 7, 7200, 0, 'EET') ,(4, 8, 10800, 0, 'MSK') ,(4, 9, 14400, 1, 'MSD') ,(4, 10, 10800, 1, 'EEST') ,(4, 11, 7200, 0, 'EET') ,(5, 0, 32400, 0, 'CJT') ,(5, 1, 32400, 0, 'JST'), (6, 1, 19800, 0, 'IST'); +INSERT INTO time_zone_leap_second (Transition_time, Correction) VALUES (174834660, 1), (78796800, 1) ,(94694401, 2) ,(126230402, 3) ,(157766403, 4) ,(189302404, 5) ,(220924805, 6) ,(252460806, 7) ,(283996807, 8) ,(315532808, 9) ,(362793609, 10) ,(394329610, 11) ,(425865611, 12) ,(489024012, 13) ,(567993613, 14) ,(631152014, 15) ,(662688015, 16) ,(709948816, 17) ,(741484817, 18) ,(773020818, 19) ,(820454419, 20) ,(867715220, 21) ,(915148821, 22); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 26adc4eddaa..7c2b7df697e 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -473,15 +473,24 @@ err: Create a formatted date/time value in a string. */ -static bool make_date_time(const String *format, const MYSQL_TIME *l_time, - timestamp_type type, const MY_LOCALE *locale, - String *str) +static bool make_date_time(THD *thd, const String *format, + const MYSQL_TIME *l_time, timestamp_type type, + const MY_LOCALE *locale, String *str) { char intbuff[15]; uint hours_i; uint weekday; ulong length; const char *ptr, *end; + int diff_hr=0, diff_min=0; + char abbrevation[8]; + struct tz tmp; + tmp.is_inited= false; + + Time_zone* curr_timezone= my_tz_find(thd, + thd->variables.time_zone->get_name()); + memset(abbrevation, 0, sizeof(abbrevation)); + str->length(0); @@ -699,6 +708,44 @@ static bool make_date_time(const String *format, const MYSQL_TIME *l_time, str->append_with_prefill(intbuff, length, 1, '0'); break; + case 'z': + { + if (!tmp.is_inited) + { + curr_timezone->get_timezone_information(&tmp, l_time); + tmp.is_inited= true; + } + ulonglong seconds= abs(tmp.seconds_offset); + diff_hr= (int)(seconds/3600L); + int temp= (int)(seconds%3600L); + diff_min= temp/60L; + + if (tmp.is_behind) + str->append("-", 1); + else + str->append("+", 1); + + if (diff_hr/10 == 0) + str->append("0", 1); + length= (uint) (int10_to_str(diff_hr, intbuff, 10) - intbuff); + str->append(intbuff, length); + if (diff_min/10 == 0) + str->append("0", 1); + length= (uint) (int10_to_str(diff_min, intbuff, 10) - intbuff); + str->append(intbuff, length); + } + break; + + case 'Z': + { + if (!tmp.is_inited) + { + curr_timezone->get_timezone_information(&tmp, l_time); + tmp.is_inited= true; + } + str->append(tmp.abbrevation, strlen(tmp.abbrevation)); + } + break; default: str->append(*ptr); break; @@ -1912,7 +1959,7 @@ String *Item_func_date_format::val_str(String *str) /* Create the result string */ str->set_charset(collation.collation); - if (!make_date_time(format, &l_time, + if (!make_date_time(thd, format, &l_time, is_time_format ? MYSQL_TIMESTAMP_TIME : MYSQL_TIMESTAMP_DATE, lc, str)) diff --git a/sql/tztime.cc b/sql/tztime.cc index e77a7529332..b18457ff5c0 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -55,15 +55,10 @@ /* Now we don't use abbreviations in server but we will do this in future. + Edit: Started needing abbrevation in server as part of task MDEV-31684. */ -#if defined(TZINFO2SQL) || defined(TESTTIME) -#define ABBR_ARE_USED -#else -#if !defined(DBUG_OFF) -/* Let use abbreviations for debug purposes */ -#undef ABBR_ARE_USED -#define ABBR_ARE_USED -#endif /* !defined(DBUG_OFF) */ +#ifndef ABBR_ARE_USED +#define ABBR_ARE_USED #endif /* defined(TZINFO2SQL) || defined(TESTTIME) */ /* Structure describing local time type (e.g. Moscow summer time (MSD)) */ @@ -1031,6 +1026,7 @@ public: virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const; virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; + virtual void get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const; }; @@ -1097,6 +1093,25 @@ Time_zone_system::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const adjust_leap_second(tmp); } +void +Time_zone_system::get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const +{ + uint error; + struct tm tm_local_time; + + time_t time_sec= this->TIME_to_gmt_sec(local_TIME, &error); + + localtime_r(&time_sec, &tm_local_time); +# ifdef __USE_MISC + int len= strlen((tm_local_time.tm_zone)); + strmake(curr_tz->abbrevation, tm_local_time.tm_zone, sizeof(tm_local_time.tm_zone)-1); + curr_tz->abbrevation[len]= '\0'; +# endif + curr_tz->seconds_offset= tm_local_time.tm_gmtoff; + curr_tz->is_behind= tm_local_time.tm_gmtoff < 0; + +} + /* Get name of time zone @@ -1128,6 +1143,7 @@ public: uint *error_code) const; virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; + virtual void get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const; }; @@ -1175,6 +1191,22 @@ Time_zone_utc::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const adjust_leap_second(tmp); } +void +Time_zone_utc::get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const +{ + uint error; + struct tm tm_local_time; + + time_t time_sec= this->TIME_to_gmt_sec(local_TIME, &error); + + localtime_r(&time_sec, &tm_local_time); +# ifdef __USE_MISC + strmake(curr_tz->abbrevation, "UTC", 3); +# endif + curr_tz->seconds_offset= tm_local_time.tm_gmtoff; + curr_tz->is_behind= tm_local_time.tm_gmtoff < 0; +} + /* Get name of time zone @@ -1210,6 +1242,7 @@ public: virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const; virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; + virtual void get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const; private: TIME_ZONE_INFO *tz_info; const String *tz_name; @@ -1280,6 +1313,24 @@ Time_zone_db::gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const adjust_leap_second(tmp); } +void +Time_zone_db::get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const +{ + uint error; + my_time_t sec_in_utc; + const TRAN_TYPE_INFO *ttisp; + + /* Get seconds since epoch. */ + sec_in_utc= this->TIME_to_gmt_sec(local_TIME, &error); + /* Get local timezone information. */ + ttisp= find_transition_type(sec_in_utc, tz_info); + + curr_tz->seconds_offset= ttisp->tt_gmtoff; + curr_tz->is_behind= tz_info->revtis->rt_offset < 0 ? true : false; + + strmake(curr_tz->abbrevation, &(tz_info->chars[ttisp->tt_abbrind]), tz_info->charcnt-1); +} + /* Get name of time zone @@ -1309,6 +1360,7 @@ public: uint *error_code) const; virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; + virtual void get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const; /* This have to be public because we want to be able to access it from my_offset_tzs_get_key() function @@ -1434,6 +1486,15 @@ Time_zone_offset::get_name() const return &name; } +void +Time_zone_offset::get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const +{ + curr_tz->seconds_offset= offset; + const char *name= get_name()->ptr(); + curr_tz->is_behind= name[0] == '+' ? false : true; + strmake(curr_tz->abbrevation, name, sizeof(curr_tz->abbrevation)-1); +} + static Time_zone_utc tz_UTC; static Time_zone_system tz_SYSTEM; @@ -1881,6 +1942,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) */ TIME_ZONE_INFO tmp_tz_info; memset(&tmp_tz_info, 0, sizeof(TIME_ZONE_INFO)); + memset(ttis, 0, sizeof(ttis)); DBUG_ENTER("tz_load_from_open_tables"); diff --git a/sql/tztime.h b/sql/tztime.h index 6d8af62ecd4..75f8a7b3ef2 100644 --- a/sql/tztime.h +++ b/sql/tztime.h @@ -38,6 +38,19 @@ class THD; Actual time zones which are specified by DB, or via offset or use system functions are its descendants. */ + +/* + Has only offset from UTC, bool value to denote if it is + ahead (+), behind(-) of UTC and abbrevation. +*/ +struct tz +{ + long seconds_offset; + bool is_behind; + char abbrevation[8]; + bool is_inited; +}; + class Time_zone: public Sql_alloc { public: @@ -62,6 +75,8 @@ public: */ virtual const String * get_name() const = 0; + virtual void get_timezone_information(struct tz* curr_tz, const MYSQL_TIME *local_TIME) const = 0; + /** We need this only for surpressing warnings, objects of this type are allocated on MEM_ROOT and should not require destruction.