types-interval.td 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. # MySQL specifies that pg type INTERVAL is mapped to TIME in MySQL.
  10. #
  11. # Test the INTERVAL type
  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. # Insert data pre-snapshot
  25. CREATE TABLE t1 (f1 TIME(6));
  26. INSERT INTO t1 VALUES (TIME '23:59:59')
  27. > CREATE SOURCE mz_source
  28. FROM MYSQL CONNECTION mysql_conn
  29. FOR ALL TABLES;
  30. > SELECT COUNT(*) > 0 FROM t1;
  31. true
  32. # Insert the same data post-snapshot
  33. $ mysql-execute name=mysql
  34. INSERT INTO t1 SELECT * FROM t1;
  35. > SELECT pg_typeof(f1) FROM t1 LIMIT 1;
  36. time
  37. > SELECT * FROM t1;
  38. "23:59:59"
  39. "23:59:59"
  40. # Now insert an out-of-bounds time value that should
  41. # put us into an error state
  42. $ mysql-execute name=mysql
  43. INSERT INTO t1 VALUES (TIME '838:59:59')
  44. ! SELECT * FROM t1;
  45. contains: error decoding value
  46. # Drop and recreate the source to confirm the decoding
  47. # error is also encountered in the snapshot phase
  48. > DROP SOURCE mz_source CASCADE;
  49. > CREATE SOURCE mz_source
  50. FROM MYSQL CONNECTION mysql_conn
  51. FOR ALL TABLES;
  52. ! SELECT * FROM t1;
  53. contains: error decoding value
  54. > DROP SOURCE mz_source CASCADE;