types-temporal-with-tz.td 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. $ set-sql-timeout duration=1s
  10. #
  11. # Test the timezone handling
  12. #
  13. > SHOW TIMEZONE
  14. UTC
  15. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  16. > CREATE CONNECTION mysql_conn TO MYSQL (
  17. HOST mysql,
  18. USER root,
  19. PASSWORD SECRET mysqlpass
  20. )
  21. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  22. $ mysql-execute name=mysql
  23. DROP DATABASE IF EXISTS public;
  24. CREATE DATABASE public;
  25. USE public;
  26. SET GLOBAL time_zone = 'US/Eastern';
  27. # reconnect for global variable change to take effect
  28. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  29. $ mysql-execute name=mysql
  30. USE public;
  31. SET SESSION time_zone = 'US/Alaska';
  32. # MySQL 5.7 needs a default value for timestamp_col
  33. CREATE TABLE t1 (date_col DATE, date_time_col DATETIME, timestamp_col TIMESTAMP DEFAULT '2000-01-01');
  34. INSERT INTO t1 VALUES ('1000-01-01', '1000-01-01 00:00:00', '1970-01-01 00:00:01');
  35. INSERT INTO t1 VALUES ('9999-12-31', '9999-12-31 23:59:59', '2038-01-18 03:14:17');
  36. > CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
  37. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE public.t1);
  38. > SELECT date_col, date_time_col, timestamp_col AT TIME ZONE 'UTC' FROM t1;
  39. "1000-01-01" "1000-01-01 00:00:00" "1970-01-01 10:00:01 UTC"
  40. "9999-12-31" "9999-12-31 23:59:59" "2038-01-18 12:14:17 UTC"
  41. $ mysql-execute name=mysql
  42. SET GLOBAL time_zone = 'US/Pacific';
  43. # reconnect for global variable change to take effect
  44. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  45. $ mysql-execute name=mysql
  46. USE public;
  47. SET SESSION time_zone = 'Australia/Sydney';
  48. # MySQL 5.7 needs a default value for timestamp_col
  49. INSERT INTO t1 VALUES ('1000-01-01', '1000-01-01 00:00:00', '1970-01-05 16:00:01');
  50. > SELECT date_col, date_time_col, timestamp_col AT TIME ZONE 'UTC' FROM t1;
  51. "1000-01-01" "1000-01-01 00:00:00" "1970-01-01 10:00:01 UTC"
  52. "9999-12-31" "9999-12-31 23:59:59" "2038-01-18 12:14:17 UTC"
  53. "1000-01-01" "1000-01-01 00:00:00" "1970-01-05 06:00:01 UTC"
  54. # reset not to influence other tests
  55. $ mysql-execute name=mysql
  56. SET GLOBAL time_zone = 'SYSTEM';