types-temporal.td 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 temporal data types (DATE, DATETIME, TIME, TIMESTAMP)
  12. #
  13. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  14. > CREATE CONNECTION mysql_conn TO MYSQL (
  15. HOST mysql,
  16. USER root,
  17. PASSWORD SECRET mysqlpass
  18. )
  19. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  20. $ mysql-execute name=mysql
  21. DROP DATABASE IF EXISTS public;
  22. CREATE DATABASE public;
  23. USE public;
  24. # MySQL 5.7 needs a default value for timestamp_trunc_col
  25. CREATE TABLE t1 (date_col DATE, time_col TIME(6), time_trunc_col TIME, datetime_col DATETIME(6), datetime_trunc_col DATETIME, timestamp_col TIMESTAMP(6), timestamp_trunc_col TIMESTAMP DEFAULT '2000-01-01');
  26. INSERT INTO t1 VALUES ('2011-11-11', '11:11:11.123456', '11:11:11.123456', '2011-11-11 11:11:11.123456', '2011-11-11 11:11:11.123456', '2011-11-11 11:11:11.123456', '2011-11-11 11:11:11.123456');
  27. > CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
  28. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE public.t1);
  29. > SELECT * FROM t1;
  30. 2011-11-11 11:11:11.123456 11:11:11 "2011-11-11 11:11:11.123456" "2011-11-11 11:11:11" "2011-11-11 11:11:11.123456" "2011-11-11 11:11:11"
  31. # Insert the same data post-snapshot
  32. $ mysql-execute name=mysql
  33. INSERT INTO t1 SELECT * FROM t1;
  34. > SELECT pg_typeof(date_col), pg_typeof(datetime_col), pg_typeof(time_col), pg_typeof(timestamp_col) FROM t1 LIMIT 1;
  35. date "timestamp without time zone" time "timestamp without time zone"
  36. > SELECT * FROM t1;
  37. 2011-11-11 11:11:11.123456 11:11:11 "2011-11-11 11:11:11.123456" "2011-11-11 11:11:11" "2011-11-11 11:11:11.123456" "2011-11-11 11:11:11"
  38. 2011-11-11 11:11:11.123456 11:11:11 "2011-11-11 11:11:11.123456" "2011-11-11 11:11:11" "2011-11-11 11:11:11.123456" "2011-11-11 11:11:11"