types-hstore.td 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. # HSTORE supported only as TEXT
  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. # Insert data pre-snapshot
  20. $ postgres-execute connection=postgres://postgres:postgres@postgres
  21. ALTER USER postgres WITH replication;
  22. DROP SCHEMA IF EXISTS public CASCADE;
  23. DROP PUBLICATION IF EXISTS mz_source;
  24. CREATE SCHEMA public;
  25. CREATE EXTENSION IF NOT EXISTS hstore;
  26. CREATE TABLE t1 (f1 hstore);
  27. ALTER TABLE t1 REPLICA IDENTITY FULL;
  28. INSERT INTO t1 VALUES (NULL), ('a=>1'::hstore);
  29. CREATE PUBLICATION mz_source FOR ALL TABLES;
  30. > CREATE SOURCE mz_source
  31. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source', TEXT COLUMNS (t1.f1))
  32. FOR ALL TABLES;
  33. > SELECT COUNT(*) > 0 FROM t1;
  34. true
  35. # Insert the same data post-snapshot
  36. $ postgres-execute connection=postgres://postgres:postgres@postgres
  37. INSERT INTO t1 SELECT * FROM t1;
  38. > SELECT pg_typeof(f1) FROM t1 LIMIT 1;
  39. "text"
  40. > SELECT * FROM t1;
  41. <null>
  42. <null>
  43. "\"a\"=>\"1\""
  44. "\"a\"=>\"1\""