26-types-bytea.td 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 the BYTEA type is replicated correctly
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE bytea_type (f1 BYTEA, f2 INTEGER PRIMARY KEY);
  14. ALTER TABLE bytea_type REPLICA IDENTITY FULL;
  15. INSERT INTO bytea_type VALUES (NULL, 0), ('', 1), (E'\\x00', 2), (E'\\xABCDEF1234', 3);
  16. $ schema-registry-wait topic=postgres.public.bytea_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 bytea_type
  22. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.bytea_type');
  23. > CREATE TABLE bytea_type_tbl FROM SOURCE bytea_type (REFERENCE "postgres.public.bytea_type")
  24. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  25. ENVELOPE DEBEZIUM;
  26. # There is \\x124 below instead of \x1234 but apparently this is outside of Mz
  27. # as Mz returns the correct length and the correct output in the psql client
  28. > SELECT f1, length(f1), f1 = E'\\xABCDEF1234' FROM bytea_type_tbl;
  29. "" 0 false
  30. <null> <null> <null>
  31. "\\x00" 1 false
  32. "\\xab\\xcd\\xef\\x124" 5 true
  33. $ postgres-execute connection=postgres://postgres:postgres@postgres
  34. UPDATE bytea_type SET f1 = E'\\xFFFF' WHERE f1 IS NULL;
  35. UPDATE bytea_type SET f1 = NULL WHERE f1 = E'\\xABCDEF1234';
  36. UPDATE bytea_type SET f1 = E'\\x0000' WHERE f1 = E'\\x00';
  37. > SELECT f1, length(f1) FROM bytea_type_tbl;
  38. "" "0"
  39. <null> <null>
  40. "\\x00\\x00" 2
  41. "\\xff\\xff" 2