types-binary.td 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 BINARY data 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 BINARY(4), f2 VARBINARY(4));
  26. INSERT INTO t1 VALUES ('abc ', 'abc ');
  27. INSERT INTO t1 VALUES (HEX('ab'), HEX('ab'));
  28. INSERT INTO t1 VALUES ('abc ', 'abc ');
  29. INSERT INTO t1 VALUES ('a\0\0b', 'a\0\0b');
  30. > CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
  31. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE public.t1);
  32. > SELECT COUNT(*) > 0 FROM t1;
  33. true
  34. # Insert the same data post-snapshot
  35. $ mysql-execute name=mysql
  36. INSERT INTO t1 SELECT * FROM t1;
  37. # MySQL does not have a proper boolean type
  38. > SELECT pg_typeof(f1), pg_typeof(f2) FROM t1 LIMIT 1;
  39. bytea bytea
  40. > SELECT * FROM t1;
  41. "6162" "6162"
  42. "6162" "6162"
  43. "a\\x00\\x00b" "a\\x00\\x00b"
  44. "a\\x00\\x00b" "a\\x00\\x00b"
  45. "abc " "abc "
  46. "abc " "abc "
  47. "abc " "abc "
  48. "abc " "abc "