two-publications-one-table.td 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 publications can replicate the same table
  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_source1;
  23. DROP PUBLICATION IF EXISTS mz_source2;
  24. CREATE SCHEMA public;
  25. CREATE TABLE t1 (f1 INTEGER);
  26. ALTER TABLE t1 REPLICA IDENTITY FULL;
  27. INSERT INTO t1 VALUES (1);
  28. CREATE PUBLICATION mz_source1 FOR ALL TABLES;
  29. CREATE PUBLICATION mz_source2 FOR ALL TABLES;
  30. > DROP SCHEMA IF EXISTS schema1
  31. > CREATE SCHEMA schema1
  32. > CREATE SOURCE mz_source1
  33. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source1')
  34. FOR TABLES (t1 AS t1_1);
  35. > CREATE SOURCE mz_source2
  36. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source2')
  37. FOR TABLES (t1 AS t1_2);
  38. > SELECT * FROM t1_1;
  39. 1
  40. > SELECT * FROM t1_2;
  41. 1
  42. $ postgres-execute connection=postgres://postgres:postgres@postgres
  43. INSERT INTO t1 VALUES (2);
  44. > SELECT * FROM t1_1;
  45. 1
  46. 2
  47. > SELECT * FROM t1_2;
  48. 1
  49. 2
  50. > DROP SCHEMA schema1 CASCADE;