@@ -292,6 +292,64 @@ SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot',
292292 COMMIT
293293(235 rows)
294294
295+ -- test we can decode "old" tuples bigger than the max heap tuple size correctly
296+ DROP TABLE IF EXISTS toasted_several;
297+ NOTICE: table "toasted_several" does not exist, skipping
298+ CREATE TABLE toasted_several (
299+ id serial unique not null,
300+ toasted_key text primary key,
301+ toasted_col1 text,
302+ toasted_col2 text
303+ );
304+ ALTER TABLE toasted_several REPLICA IDENTITY FULL;
305+ ALTER TABLE toasted_several ALTER COLUMN toasted_key SET STORAGE EXTERNAL;
306+ ALTER TABLE toasted_several ALTER COLUMN toasted_col1 SET STORAGE EXTERNAL;
307+ ALTER TABLE toasted_several ALTER COLUMN toasted_col2 SET STORAGE EXTERNAL;
308+ INSERT INTO toasted_several(toasted_key) VALUES(repeat('9876543210', 2000));
309+ SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
310+ regexp_replace
311+ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
312+ BEGIN
313+ table public.toasted_several: INSERT: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..098765432109876543210987654321098765432109876543210' toasted_col1[text]:null toasted_col2[text]:null
314+ COMMIT
315+ (3 rows)
316+
317+ -- test update of a toasted key without changing it
318+ UPDATE toasted_several SET toasted_col1 = toasted_key;
319+ UPDATE toasted_several SET toasted_col2 = toasted_col1;
320+ SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');
321+ regexp_replace
322+ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
323+ BEGIN
324+ table public.toasted_several: INSERT: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..098765432109876543210987654321098765432109876543210' toasted_col1[text]:null toasted_col2[text]:null
325+ COMMIT
326+ BEGIN
327+ table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..432109876543210987654321098765432109876543210987654321098765432109876543210' toasted_col2[text]:null
328+ COMMIT
329+ BEGIN
330+ table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210'
331+ COMMIT
332+ (9 rows)
333+
334+ /*
335+ * update with large tuplebuf, in a transaction large enough to force to spool to disk
336+ */
337+ BEGIN;
338+ INSERT INTO toasted_several(toasted_key) SELECT * FROM generate_series(1, 10234);
339+ UPDATE toasted_several SET toasted_col1 = toasted_col2 WHERE id = 1;
340+ DELETE FROM toasted_several WHERE id = 1;
341+ COMMIT;
342+ DROP TABLE toasted_several;
343+ SELECT regexp_replace(data, '^(.{100}).*(.{100})$', '\1..\2') FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1')
344+ WHERE data NOT LIKE '%INSERT: %';
345+ regexp_replace
346+ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
347+ BEGIN
348+ table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..7654321098765432109876543210987654321098765432109876543210' toasted_col2[text]:unchanged-toast-datum
349+ table public.toasted_several: DELETE: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210'
350+ COMMIT
351+ (4 rows)
352+
295353SELECT pg_drop_replication_slot('regression_slot');
296354 pg_drop_replication_slot
297355--------------------------