types-blob.td 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 BLOB 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. # needed for MySQL 5.7
  22. SET GLOBAL max_allowed_packet=67108864;
  23. # reconnect after setting the max_allowed_packet var
  24. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  25. $ mysql-execute name=mysql
  26. DROP DATABASE IF EXISTS public;
  27. CREATE DATABASE public;
  28. USE public;
  29. # Insert data pre-snapshot
  30. CREATE TABLE t1 (f1 BLOB, f2 TINYBLOB, f3 MEDIUMBLOB, f4 LONGBLOB) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
  31. INSERT INTO t1 VALUES ('abc ', 'abc ', 'abc ', 'abc ');
  32. # 4 bytes per character
  33. CREATE TABLE t2 (f1 LONGBLOB) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
  34. INSERT INTO t2 VALUES (REPEAT('abcdefg x ', 1000));
  35. UPDATE t2 SET f1 = CONCAT(f1, CONCAT(f1, CONCAT(f1, CONCAT(f1, f1))));
  36. UPDATE t2 SET f1 = CONCAT(f1, CONCAT(f1, CONCAT(f1, CONCAT(f1, f1))));
  37. UPDATE t2 SET f1 = CONCAT(f1, CONCAT(f1, CONCAT(f1, CONCAT(f1, f1))));
  38. UPDATE t2 SET f1 = CONCAT(f1, CONCAT(f1, CONCAT(f1, CONCAT(f1, f1))));
  39. UPDATE t2 SET f1 = CONCAT(f1, CONCAT(f1, CONCAT(f1, CONCAT(f1, f1))));
  40. UPDATE t2 SET f1 = CONCAT(f1, f1);
  41. > CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
  42. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE public.t1);
  43. > CREATE TABLE t2 FROM SOURCE mz_source (REFERENCE public.t2);
  44. > SELECT COUNT(*) > 0 FROM t1;
  45. true
  46. # Insert the same data post-snapshot
  47. $ mysql-execute name=mysql
  48. INSERT INTO t1 SELECT * FROM t1;
  49. # MySQL does not have a proper boolean type
  50. > SELECT pg_typeof(f1), pg_typeof(f2), pg_typeof(f3), pg_typeof(f4) FROM t1 LIMIT 1;
  51. bytea bytea bytea bytea
  52. > SELECT * FROM t1;
  53. "abc " "abc " "abc " "abc "
  54. "abc " "abc " "abc " "abc "
  55. > SELECT length(f1) FROM t2;
  56. 62500000