two-sources-one-publication.td 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 sources reading from one publication is OK
  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. CREATE TABLE t2 (f1 INTEGER);
  27. INSERT INTO t2 VALUES (5);
  28. > DROP SCHEMA IF EXISTS schema1
  29. > CREATE SCHEMA schema1
  30. > CREATE SOURCE mz_source1
  31. FROM MYSQL CONNECTION mysql_conn
  32. FOR TABLES (public.t1 AS t1_1, public.t2 AS t2_1);
  33. > CREATE SOURCE mz_source2
  34. FROM MYSQL CONNECTION mysql_conn
  35. FOR TABLES (public.t1 AS t1_2, public.t2 AS t2_2);
  36. > SELECT * FROM t1_1;
  37. 1
  38. > SELECT * FROM t2_1;
  39. 5
  40. > SELECT * FROM t1_2;
  41. 1
  42. > SELECT * FROM t2_2;
  43. 5
  44. $ mysql-execute name=mysql
  45. INSERT INTO t1 VALUES (2);
  46. INSERT INTO t1 VALUES (3);
  47. INSERT INTO t2 VALUES (6);
  48. INSERT INTO t2 VALUES (7);
  49. > SELECT * FROM t1_1;
  50. 1
  51. 2
  52. 3
  53. > SELECT * FROM t2_1;
  54. 5
  55. 6
  56. 7
  57. > SELECT * FROM t1_2;
  58. 1
  59. 2
  60. 3
  61. > SELECT * FROM t2_2;
  62. 5
  63. 6
  64. 7
  65. > DROP SCHEMA schema1 CASCADE;