two-sources-one-publication.td 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #
  10. # Test that two sources reading from one publication is OK
  11. #
  12. > CREATE SECRET pgpass AS 'postgres'
  13. > CREATE CONNECTION pg TO POSTGRES (
  14. HOST postgres,
  15. DATABASE postgres,
  16. USER postgres,
  17. PASSWORD SECRET pgpass
  18. )
  19. $ postgres-execute connection=postgres://postgres:postgres@postgres
  20. ALTER USER postgres WITH replication;
  21. DROP SCHEMA IF EXISTS public CASCADE;
  22. DROP PUBLICATION IF EXISTS mz_source;
  23. CREATE SCHEMA public;
  24. CREATE TABLE t1 (f1 INTEGER);
  25. ALTER TABLE t1 REPLICA IDENTITY FULL;
  26. INSERT INTO t1 VALUES (1);
  27. CREATE TABLE t2 (f1 INTEGER);
  28. ALTER TABLE t2 REPLICA IDENTITY FULL;
  29. INSERT INTO t2 VALUES (5);
  30. CREATE PUBLICATION mz_source FOR ALL TABLES;
  31. > DROP SCHEMA IF EXISTS schema1
  32. > CREATE SCHEMA schema1
  33. > CREATE SOURCE mz_source1
  34. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');
  35. > CREATE TABLE t1_1 FROM SOURCE mz_source1 (REFERENCE public.t1);
  36. > CREATE TABLE t2_1 FROM SOURCE mz_source1 (REFERENCE t2);
  37. > CREATE SOURCE mz_source2
  38. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');
  39. > CREATE TABLE t1_2 FROM SOURCE mz_source2 (REFERENCE t1);
  40. > CREATE TABLE t2_2 FROM SOURCE mz_source2 (REFERENCE t2);
  41. > SELECT * FROM t1_1;
  42. 1
  43. > SELECT * FROM t2_1;
  44. 5
  45. > SELECT * FROM t1_2;
  46. 1
  47. > SELECT * FROM t2_2;
  48. 5
  49. $ postgres-execute connection=postgres://postgres:postgres@postgres
  50. INSERT INTO t1 VALUES (2);
  51. INSERT INTO t1 VALUES (3);
  52. INSERT INTO t2 VALUES (6);
  53. INSERT INTO t2 VALUES (7);
  54. > SELECT * FROM t1_1;
  55. 1
  56. 2
  57. 3
  58. > SELECT * FROM t2_1;
  59. 5
  60. 6
  61. 7
  62. > SELECT * FROM t1_2;
  63. 1
  64. 2
  65. 3
  66. > SELECT * FROM t2_2;
  67. 5
  68. 6
  69. 7
  70. > DROP SCHEMA schema1 CASCADE;