two-destination-schemas.td 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 identically-named tables in two destination schemas can be
  11. # successfully disambiguated and replicated
  12. #
  13. > CREATE SECRET pgpass AS 'postgres'
  14. > CREATE CONNECTION pg TO POSTGRES (
  15. HOST postgres,
  16. DATABASE postgres,
  17. USER postgres,
  18. PASSWORD SECRET pgpass
  19. )
  20. $ postgres-execute connection=postgres://postgres:postgres@postgres
  21. ALTER USER postgres WITH replication;
  22. DROP PUBLICATION IF EXISTS mz_source;
  23. DROP TABLE IF EXISTS t1 CASCADE;
  24. DROP TABLE IF EXISTS t2 CASCADE;
  25. CREATE TABLE t1 (f1 INTEGER);
  26. ALTER TABLE t1 REPLICA IDENTITY FULL;
  27. INSERT INTO t1 VALUES (1);
  28. CREATE TABLE t2 (f1 INTEGER);
  29. ALTER TABLE t2 REPLICA IDENTITY FULL;
  30. INSERT INTO t2 VALUES (2);
  31. CREATE PUBLICATION mz_source FOR ALL TABLES;
  32. > DROP SCHEMA IF EXISTS schema1 CASCADE;
  33. > DROP SCHEMA IF EXISTS schema2 CASCADE;
  34. > CREATE SCHEMA schema1;
  35. > CREATE SCHEMA schema2;
  36. > DROP SOURCE IF EXISTS mz_source CASCADE;
  37. > CREATE SOURCE mz_source FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');
  38. > CREATE TABLE schema1.t1 FROM SOURCE mz_source (REFERENCE t1);
  39. > CREATE TABLE schema2.t1 FROM SOURCE mz_source (REFERENCE t2);
  40. > SELECT * FROM schema1.t1;
  41. 1
  42. > SELECT * FROM schema2.t1;
  43. 2
  44. $ postgres-execute connection=postgres://postgres:postgres@postgres
  45. INSERT INTO t1 SELECT * FROM t1;
  46. INSERT INTO t2 SELECT * FROM t2;
  47. > SELECT * FROM schema1.t1;
  48. 1
  49. 1
  50. > SELECT * FROM schema2.t1;
  51. 2
  52. 2
  53. $ postgres-execute connection=postgres://postgres:postgres@postgres
  54. DROP TABLE t1;
  55. DROP TABLE t2;
  56. > DROP SOURCE mz_source CASCADE;
  57. > DROP SCHEMA schema1 CASCADE;
  58. > DROP SCHEMA schema2 CASCADE;