29-types-char-varchar.td 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. # Make sure that CHAR/VARCHAR is replicated correctly
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE char_varchar_type (char_col CHAR(5), varchar_col VARCHAR(5), f3 INTEGER PRIMARY KEY);
  14. ALTER TABLE char_varchar_type REPLICA IDENTITY FULL;
  15. INSERT INTO char_varchar_type VALUES ('a ', 'a ', 0);
  16. $ schema-registry-wait topic=postgres.public.char_varchar_type
  17. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  18. URL '${testdrive.schema-registry-url}'
  19. );
  20. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  21. > CREATE SOURCE char_varchar_type
  22. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.char_varchar_type');
  23. > CREATE TABLE char_varchar_type_tbl FROM SOURCE char_varchar_type (REFERENCE "postgres.public.char_varchar_type")
  24. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  25. ENVELOPE DEBEZIUM;
  26. # Type information is not carried over as the AVRO protocol does not have CHAR/VARCHAR
  27. > SELECT pg_typeof(char_col), pg_typeof(varchar_col) FROM char_varchar_type_tbl;
  28. text text
  29. > SELECT char_col, varchar_col FROM char_varchar_type_tbl;
  30. "a " "a "
  31. $ postgres-execute connection=postgres://postgres:postgres@postgres
  32. UPDATE char_varchar_type SET char_col = 'a ', varchar_col = 'a ';
  33. > SELECT char_col, varchar_col FROM char_varchar_type_tbl;
  34. "a " "a "