two-publications-one-table.td 1.4 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. $ set-sql-timeout duration=1s
  10. #
  11. # Test that two publications can replicate the same table
  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. CREATE TABLE t1 (f1 INTEGER);
  25. INSERT INTO t1 VALUES (1);
  26. > DROP SCHEMA IF EXISTS schema1
  27. > CREATE SCHEMA schema1
  28. > CREATE SOURCE mz_source1
  29. FROM MYSQL CONNECTION mysql_conn;
  30. > CREATE TABLE t1_1 FROM SOURCE mz_source1 (REFERENCE public.t1);
  31. > CREATE SOURCE mz_source2
  32. FROM MYSQL CONNECTION mysql_conn;
  33. > CREATE TABLE t1_2 FROM SOURCE mz_source2 (REFERENCE public.t1);
  34. > SELECT * FROM t1_1;
  35. 1
  36. > SELECT * FROM t1_2;
  37. 1
  38. $ mysql-execute name=mysql
  39. INSERT INTO t1 VALUES (2);
  40. > SELECT * FROM t1_1;
  41. 1
  42. 2
  43. > SELECT * FROM t1_2;
  44. 1
  45. 2
  46. > DROP SCHEMA schema1 CASCADE;