33-toasted-values.td 2.1 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 TOAST-ed values are handled correctly.
  11. #
  12. # TOAST-ed values are values larger than around 8Kb
  13. # see https://debezium.io/documentation/reference/connectors/postgresql.html#postgresql-toasteds
  14. # and https://www.postgresql.org/docs/current/storage-toast.html
  15. #
  16. $ postgres-execute connection=postgres://postgres:postgres@postgres
  17. CREATE TABLE toasted_full (f1 text, f2 INTEGER PRIMARY KEY);
  18. ALTER TABLE toasted_full REPLICA IDENTITY FULL;
  19. INSERT INTO toasted_full VALUES (NULL, 0), (REPEAT('a', 32 * 1024) || 'b', 1);
  20. $ schema-registry-wait topic=postgres.public.toasted_full
  21. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  22. URL '${testdrive.schema-registry-url}'
  23. );
  24. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  25. > CREATE SOURCE toasted_full
  26. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.toasted_full');
  27. > CREATE TABLE toasted_full_tbl FROM SOURCE toasted_full (REFERENCE "postgres.public.toasted_full")
  28. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  29. ENVELOPE DEBEZIUM;
  30. > SELECT length(f1) = (32 * 1024) + 1, substr(f1, 1, 2), substr(f1, 32 * 1024, 2) FROM toasted_full_tbl;
  31. <null> <null> <null>
  32. true aa ab
  33. $ postgres-execute connection=postgres://postgres:postgres@postgres
  34. UPDATE toasted_full SET f1 = (REPEAT('c', 32 * 1024) || 'd') WHERE f1 IS NULL;
  35. UPDATE toasted_full SET f1 = (REPEAT('e', 32 * 1024) || 'f') WHERE f1 = REPEAT('a', 32 * 1024) || 'b';
  36. > SELECT length(f1), substr(f1, 1, 2), substr(f1, 32 * 1024, 2) FROM toasted_full_tbl;
  37. 32769 cc cd
  38. 32769 ee ef
  39. # The documentation says that we do not support REPLICA IDENTITY DEFAULT, which is the more interesting
  40. # case, so we are not testing that here.