decode-errors.td 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. # Validate that decode errors are produced in the stream and can be
  10. # retracted if the offending row(s) are deleted
  11. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  12. > CREATE CONNECTION mysql_conn TO MYSQL (
  13. HOST mysql,
  14. USER root,
  15. PASSWORD SECRET mysqlpass
  16. )
  17. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  18. $ mysql-execute name=mysql
  19. DROP DATABASE IF EXISTS public;
  20. CREATE DATABASE public;
  21. USE public;
  22. # Start with an invalid snapshot and verify the source presents an error
  23. CREATE TABLE decode_err (f1 INTEGER, f2 TIME(6));
  24. INSERT INTO decode_err VALUES (1, TIME '12:00:00');
  25. INSERT INTO decode_err VALUES (2, TIME '29:59:59');
  26. > CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
  27. > CREATE TABLE decode_err FROM SOURCE mz_source (REFERENCE public.decode_err);
  28. ! SELECT * FROM decode_err;
  29. contains: error decoding value
  30. # Remove the invalid row and verify that the source is now showing the correct data
  31. $ mysql-execute name=mysql
  32. DELETE FROM decode_err WHERE f1 = 2;
  33. > SELECT * FROM decode_err;
  34. 1 "12:00:00"
  35. # Re-add an invalid row and we verify that replication also correctly puts the source into an errored state
  36. $ mysql-execute name=mysql
  37. INSERT INTO decode_err VALUES (3, TIME '39:59:59');
  38. ! SELECT * FROM decode_err;
  39. contains: error decoding value
  40. # Remove the invalid row and the source is good again
  41. $ mysql-execute name=mysql
  42. DELETE FROM decode_err WHERE f1 = 3;
  43. > SELECT * FROM decode_err;
  44. 1 "12:00:00"