toast-columns.td 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # Test that we can ingest unchanged toasted values
  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 by generating 16kB of uncompressible data to force
  20. # TOASTed storage by concatenating 1024 random MD5 hashes, each being 128bit
  21. $ postgres-execute connection=postgres://postgres:postgres@postgres
  22. ALTER USER postgres WITH replication;
  23. DROP SCHEMA IF EXISTS public CASCADE;
  24. DROP PUBLICATION IF EXISTS mz_source;
  25. CREATE SCHEMA public;
  26. CREATE TABLE t1 (a int, b text);
  27. ALTER TABLE t1 REPLICA IDENTITY FULL;
  28. INSERT INTO t1 SELECT 1, string_agg(md5(random()::text), '') FROM generate_series(1, 1024);
  29. INSERT INTO t1 SELECT 2, string_agg(md5(random()::text), '') FROM generate_series(1, 1024);
  30. CREATE PUBLICATION mz_source FOR ALL TABLES;
  31. > CREATE SOURCE mz_source FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');
  32. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE t1);
  33. > SELECT a, length(b) FROM t1;
  34. 1 32768
  35. 2 32768
  36. # Update the rows without touching the TOASTed column
  37. $ postgres-execute connection=postgres://postgres:postgres@postgres
  38. UPDATE t1 SET a = 3;
  39. > SELECT a, length(b) FROM t1;
  40. 3 32768
  41. 3 32768