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. #
  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. FOR TABLES (t1 AS t1_1, t2 AS t2_1);
  36. > CREATE SOURCE mz_source2
  37. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  38. FOR TABLES (t1 AS t1_2, t2 AS t2_2);
  39. > SELECT * FROM t1_1;
  40. 1
  41. > SELECT * FROM t2_1;
  42. 5
  43. > SELECT * FROM t1_2;
  44. 1
  45. > SELECT * FROM t2_2;
  46. 5
  47. $ postgres-execute connection=postgres://postgres:postgres@postgres
  48. INSERT INTO t1 VALUES (2);
  49. INSERT INTO t1 VALUES (3);
  50. INSERT INTO t2 VALUES (6);
  51. INSERT INTO t2 VALUES (7);
  52. > SELECT * FROM t1_1;
  53. 1
  54. 2
  55. 3
  56. > SELECT * FROM t2_1;
  57. 5
  58. 6
  59. 7
  60. > SELECT * FROM t1_2;
  61. 1
  62. 2
  63. 3
  64. > SELECT * FROM t2_2;
  65. 5
  66. 6
  67. 7
  68. > DROP SCHEMA schema1 CASCADE;