pg-source.td 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. # Test creating a Postgres source using SSH
  10. > CREATE SECRET pgpass AS 'postgres'
  11. ! CREATE CONNECTION pg TO POSTGRES (
  12. HOST postgres,
  13. HOST postgres2,
  14. DATABASE postgres,
  15. USER postgres,
  16. PASSWORD SECRET pgpass,
  17. SSH TUNNEL thancred
  18. );
  19. contains: HOST specified more than once
  20. > CREATE CONNECTION pg TO POSTGRES (
  21. HOST postgres,
  22. DATABASE postgres,
  23. USER postgres,
  24. PASSWORD SECRET pgpass,
  25. SSH TUNNEL thancred
  26. );
  27. $ postgres-execute connection=postgres://postgres:postgres@postgres
  28. ALTER USER postgres WITH replication;
  29. DROP SCHEMA IF EXISTS public CASCADE;
  30. DROP PUBLICATION IF EXISTS mz_source;
  31. CREATE SCHEMA public;
  32. CREATE TABLE t1 (f1 INTEGER);
  33. ALTER TABLE t1 REPLICA IDENTITY FULL;
  34. INSERT INTO t1 VALUES (1);
  35. CREATE PUBLICATION mz_source FOR ALL TABLES;
  36. > CREATE SOURCE mz_source
  37. FROM POSTGRES CONNECTION pg
  38. (PUBLICATION 'mz_source');
  39. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE t1);
  40. > SELECT COUNT(*) = 1 FROM t1;
  41. true
  42. > SELECT f1 FROM t1;
  43. 1
  44. $ postgres-execute connection=postgres://postgres:postgres@postgres
  45. INSERT INTO t1 VALUES (1), (2);
  46. > SELECT f1 FROM t1 ORDER BY f1 ASC;
  47. 1
  48. 1
  49. 2