two-sources-one-publication.td 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. > CREATE TABLE t1_1 FROM SOURCE mz_source1 (REFERENCE public.t1);
  33. > CREATE TABLE t2_1 FROM SOURCE mz_source1 (REFERENCE public.t2);
  34. > CREATE SOURCE mz_source2
  35. FROM MYSQL CONNECTION mysql_conn;
  36. > CREATE TABLE t1_2 FROM SOURCE mz_source2 (REFERENCE public.t1);
  37. > CREATE TABLE t2_2 FROM SOURCE mz_source2 (REFERENCE public.t2);
  38. > SELECT * FROM t1_1;
  39. 1
  40. > SELECT * FROM t2_1;
  41. 5
  42. > SELECT * FROM t1_2;
  43. 1
  44. > SELECT * FROM t2_2;
  45. 5
  46. $ mysql-execute name=mysql
  47. INSERT INTO t1 VALUES (2);
  48. INSERT INTO t1 VALUES (3);
  49. INSERT INTO t2 VALUES (6);
  50. INSERT INTO t2 VALUES (7);
  51. > SELECT * FROM t1_1;
  52. 1
  53. 2
  54. 3
  55. > SELECT * FROM t2_1;
  56. 5
  57. 6
  58. 7
  59. > SELECT * FROM t1_2;
  60. 1
  61. 2
  62. 3
  63. > SELECT * FROM t2_2;
  64. 5
  65. 6
  66. 7
  67. > DROP SCHEMA schema1 CASCADE;