-- predictability SET synchronous_commit = on; DROP TABLE IF EXISTS xpto; NOTICE: table "xpto" does not exist, skipping SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding'); ?column? ---------- init (1 row) CREATE SEQUENCE xpto_rand_seq START 79 INCREMENT 1499; -- portable "random" CREATE TABLE xpto ( id serial primary key, toasted_col1 text, rand1 float8 DEFAULT nextval('xpto_rand_seq'), toasted_col2 text, rand2 float8 DEFAULT nextval('xpto_rand_seq') ); -- uncompressed external toast data INSERT INTO xpto (toasted_col1, toasted_col2) SELECT string_agg(g.i::text, ''), string_agg((g.i*2)::text, '') FROM generate_series(1, 2000) g(i); -- compressed external toast data INSERT INTO xpto (toasted_col2) SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i); -- update of existing column UPDATE xpto SET toasted_col1 = (SELECT string_agg(g.i::text, '') FROM generate_series(1, 2000) g(i)) WHERE id = 1; UPDATE xpto SET rand1 = 123.456 WHERE id = 1; -- updating external via INSERT ... ON CONFLICT DO UPDATE INSERT INTO xpto(id, toasted_col2) VALUES (2, 'toasted2-upsert') ON CONFLICT (id) DO UPDATE SET toasted_col2 = EXCLUDED.toasted_col2 || xpto.toasted_col2; DELETE FROM xpto WHERE id = 1; DROP TABLE IF EXISTS toasted_key; NOTICE: table "toasted_key" does not exist, skipping CREATE TABLE toasted_key ( id serial, toasted_key text PRIMARY KEY, toasted_col1 text, toasted_col2 text ); ALTER TABLE toasted_key ALTER COLUMN toasted_key SET STORAGE EXTERNAL; ALTER TABLE toasted_key ALTER COLUMN toasted_col1 SET STORAGE EXTERNAL; INSERT INTO toasted_key(toasted_key, toasted_col1) VALUES(repeat('1234567890', 200), repeat('9876543210', 200)); -- test update of a toasted key without changing it UPDATE toasted_key SET toasted_col2 = toasted_col1; -- test update of a toasted key, changing it UPDATE toasted_key SET toasted_key = toasted_key || '1'; DELETE FROM toasted_key; -- Test that HEAP2_MULTI_INSERT insertions with and without toasted -- columns are handled correctly CREATE TABLE toasted_copy ( id int primary key, -- no default, copy didn't use to handle that with multi inserts data text ); ALTER TABLE toasted_copy ALTER COLUMN data SET STORAGE EXTERNAL; \copy toasted_copy FROM STDIN SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); substr ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- BEGIN table public.xpto: INSERT: id[integer]:1 toasted_col1[text]:'1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 COMMIT BEGIN table public.xpto: INSERT: id[integer]:2 toasted_col1[text]:null rand1[double precision]:3077 toasted_col2[text]:'00010002000300040005000600070008000900100011001200130014001500160017001800190020002100 COMMIT BEGIN table public.xpto: UPDATE: id[integer]:1 toasted_col1[text]:'1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 COMMIT BEGIN table public.xpto: UPDATE: id[integer]:1 toasted_col1[text]:unchanged-toast-datum rand1[double precision]:123.456 toasted_col2[text]:unchanged-toast-datum rand2[double precision]:1578 COMMIT BEGIN table public.xpto: UPDATE: id[integer]:2 toasted_col1[text]:null rand1[double precision]:3077 toasted_col2[text]:'toasted2-upsert00010002000300040005000600070008000900100011001200130014001500160017001 COMMIT BEGIN table public.xpto: DELETE: id[integer]:1 COMMIT BEGIN table public.toasted_key: INSERT: id[integer]:1 toasted_key[text]:'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123 COMMIT BEGIN table public.toasted_key: UPDATE: old-key: toasted_key[text]:'123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 COMMIT BEGIN table public.toasted_key: UPDATE: old-key: toasted_key[text]:'123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 COMMIT BEGIN table public.toasted_key: DELETE: toasted_key[text]:'123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 COMMIT BEGIN table public.toasted_copy: INSERT: id[integer]:1 data[text]:'untoasted1' table public.toasted_copy: INSERT: id[integer]:2 data[text]:'toasted1-1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 table public.toasted_copy: INSERT: id[integer]:3 data[text]:'untoasted2' table public.toasted_copy: INSERT: id[integer]:4 data[text]:'toasted2-1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 table public.toasted_copy: INSERT: id[integer]:5 data[text]:'untoasted3' table public.toasted_copy: INSERT: id[integer]:6 data[text]:'untoasted4' table public.toasted_copy: INSERT: id[integer]:7 data[text]:'untoasted5' table public.toasted_copy: INSERT: id[integer]:8 data[text]:'untoasted6' table public.toasted_copy: INSERT: id[integer]:9 data[text]:'untoasted7' table public.toasted_copy: INSERT: id[integer]:10 data[text]:'untoasted8' table public.toasted_copy: INSERT: id[integer]:11 data[text]:'untoasted9' table public.toasted_copy: INSERT: id[integer]:12 data[text]:'untoasted10' table public.toasted_copy: INSERT: id[integer]:13 data[text]:'untoasted11' table public.toasted_copy: INSERT: id[integer]:14 data[text]:'untoasted12' table public.toasted_copy: INSERT: id[integer]:15 data[text]:'untoasted13' table public.toasted_copy: INSERT: id[integer]:16 data[text]:'untoasted14' table public.toasted_copy: INSERT: id[integer]:17 data[text]:'untoasted15' table public.toasted_copy: INSERT: id[integer]:18 data[text]:'untoasted16' table public.toasted_copy: INSERT: id[integer]:19 data[text]:'untoasted17' table public.toasted_copy: INSERT: id[integer]:20 data[text]:'untoasted18' table public.toasted_copy: INSERT: id[integer]:21 data[text]:'untoasted19' table public.toasted_copy: INSERT: id[integer]:22 data[text]:'untoasted20' table public.toasted_copy: INSERT: id[integer]:23 data[text]:'untoasted21' table public.toasted_copy: INSERT: id[integer]:24 data[text]:'untoasted22' table public.toasted_copy: INSERT: id[integer]:25 data[text]:'untoasted23' table public.toasted_copy: INSERT: id[integer]:26 data[text]:'untoasted24' table public.toasted_copy: INSERT: id[integer]:27 data[text]:'untoasted25' table public.toasted_copy: INSERT: id[integer]:28 data[text]:'untoasted26' table public.toasted_copy: INSERT: id[integer]:29 data[text]:'untoasted27' table public.toasted_copy: INSERT: id[integer]:30 data[text]:'untoasted28' table public.toasted_copy: INSERT: id[integer]:31 data[text]:'untoasted29' table public.toasted_copy: INSERT: id[integer]:32 data[text]:'untoasted30' table public.toasted_copy: INSERT: id[integer]:33 data[text]:'untoasted31' table public.toasted_copy: INSERT: id[integer]:34 data[text]:'untoasted32' table public.toasted_copy: INSERT: id[integer]:35 data[text]:'untoasted33' table public.toasted_copy: INSERT: id[integer]:36 data[text]:'untoasted34' table public.toasted_copy: INSERT: id[integer]:37 data[text]:'untoasted35' table public.toasted_copy: INSERT: id[integer]:38 data[text]:'untoasted36' table public.toasted_copy: INSERT: id[integer]:39 data[text]:'untoasted37' table public.toasted_copy: INSERT: id[integer]:40 data[text]:'untoasted38' table public.toasted_copy: INSERT: id[integer]:41 data[text]:'untoasted39' table public.toasted_copy: INSERT: id[integer]:42 data[text]:'untoasted40' table public.toasted_copy: INSERT: id[integer]:43 data[text]:'untoasted41' table public.toasted_copy: INSERT: id[integer]:44 data[text]:'untoasted42' table public.toasted_copy: INSERT: id[integer]:45 data[text]:'untoasted43' table public.toasted_copy: INSERT: id[integer]:46 data[text]:'untoasted44' table public.toasted_copy: INSERT: id[integer]:47 data[text]:'untoasted45' table public.toasted_copy: INSERT: id[integer]:48 data[text]:'untoasted46' table public.toasted_copy: INSERT: id[integer]:49 data[text]:'untoasted47' table public.toasted_copy: INSERT: id[integer]:50 data[text]:'untoasted48' table public.toasted_copy: INSERT: id[integer]:51 data[text]:'untoasted49' table public.toasted_copy: INSERT: id[integer]:52 data[text]:'untoasted50' table public.toasted_copy: INSERT: id[integer]:53 data[text]:'untoasted51' table public.toasted_copy: INSERT: id[integer]:54 data[text]:'untoasted52' table public.toasted_copy: INSERT: id[integer]:55 data[text]:'untoasted53' table public.toasted_copy: INSERT: id[integer]:56 data[text]:'untoasted54' table public.toasted_copy: INSERT: id[integer]:57 data[text]:'untoasted55' table public.toasted_copy: INSERT: id[integer]:58 data[text]:'untoasted56' table public.toasted_copy: INSERT: id[integer]:59 data[text]:'untoasted57' table public.toasted_copy: INSERT: id[integer]:60 data[text]:'untoasted58' table public.toasted_copy: INSERT: id[integer]:61 data[text]:'untoasted59' table public.toasted_copy: INSERT: id[integer]:62 data[text]:'untoasted60' table public.toasted_copy: INSERT: id[integer]:63 data[text]:'untoasted61' table public.toasted_copy: INSERT: id[integer]:64 data[text]:'untoasted62' table public.toasted_copy: INSERT: id[integer]:65 data[text]:'untoasted63' table public.toasted_copy: INSERT: id[integer]:66 data[text]:'untoasted64' table public.toasted_copy: INSERT: id[integer]:67 data[text]:'untoasted65' table public.toasted_copy: INSERT: id[integer]:68 data[text]:'untoasted66' table public.toasted_copy: INSERT: id[integer]:69 data[text]:'untoasted67' table public.toasted_copy: INSERT: id[integer]:70 data[text]:'untoasted68' table public.toasted_copy: INSERT: id[integer]:71 data[text]:'untoasted69' table public.toasted_copy: INSERT: id[integer]:72 data[text]:'untoasted70' table public.toasted_copy: INSERT: id[integer]:73 data[text]:'untoasted71' table public.toasted_copy: INSERT: id[integer]:74 data[text]:'untoasted72' table public.toasted_copy: INSERT: id[integer]:75 data[text]:'untoasted73' table public.toasted_copy: INSERT: id[integer]:76 data[text]:'untoasted74' table public.toasted_copy: INSERT: id[integer]:77 data[text]:'untoasted75' table public.toasted_copy: INSERT: id[integer]:78 data[text]:'untoasted76' table public.toasted_copy: INSERT: id[integer]:79 data[text]:'untoasted77' table public.toasted_copy: INSERT: id[integer]:80 data[text]:'untoasted78' table public.toasted_copy: INSERT: id[integer]:81 data[text]:'untoasted79' table public.toasted_copy: INSERT: id[integer]:82 data[text]:'untoasted80' table public.toasted_copy: INSERT: id[integer]:83 data[text]:'untoasted81' table public.toasted_copy: INSERT: id[integer]:84 data[text]:'untoasted82' table public.toasted_copy: INSERT: id[integer]:85 data[text]:'untoasted83' table public.toasted_copy: INSERT: id[integer]:86 data[text]:'untoasted84' table public.toasted_copy: INSERT: id[integer]:87 data[text]:'untoasted85' table public.toasted_copy: INSERT: id[integer]:88 data[text]:'untoasted86' table public.toasted_copy: INSERT: id[integer]:89 data[text]:'untoasted87' table public.toasted_copy: INSERT: id[integer]:90 data[text]:'untoasted88' table public.toasted_copy: INSERT: id[integer]:91 data[text]:'untoasted89' table public.toasted_copy: INSERT: id[integer]:92 data[text]:'untoasted90' table public.toasted_copy: INSERT: id[integer]:93 data[text]:'untoasted91' table public.toasted_copy: INSERT: id[integer]:94 data[text]:'untoasted92' table public.toasted_copy: INSERT: id[integer]:95 data[text]:'untoasted93' table public.toasted_copy: INSERT: id[integer]:96 data[text]:'untoasted94' table public.toasted_copy: INSERT: id[integer]:97 data[text]:'untoasted95' table public.toasted_copy: INSERT: id[integer]:98 data[text]:'untoasted96' table public.toasted_copy: INSERT: id[integer]:99 data[text]:'untoasted97' table public.toasted_copy: INSERT: id[integer]:100 data[text]:'untoasted98' table public.toasted_copy: INSERT: id[integer]:101 data[text]:'untoasted99' table public.toasted_copy: INSERT: id[integer]:102 data[text]:'untoasted100' table public.toasted_copy: INSERT: id[integer]:103 data[text]:'untoasted101' table public.toasted_copy: INSERT: id[integer]:104 data[text]:'untoasted102' table public.toasted_copy: INSERT: id[integer]:105 data[text]:'untoasted103' table public.toasted_copy: INSERT: id[integer]:106 data[text]:'untoasted104' table public.toasted_copy: INSERT: id[integer]:107 data[text]:'untoasted105' table public.toasted_copy: INSERT: id[integer]:108 data[text]:'untoasted106' table public.toasted_copy: INSERT: id[integer]:109 data[text]:'untoasted107' table public.toasted_copy: INSERT: id[integer]:110 data[text]:'untoasted108' table public.toasted_copy: INSERT: id[integer]:111 data[text]:'untoasted109' table public.toasted_copy: INSERT: id[integer]:112 data[text]:'untoasted110' table public.toasted_copy: INSERT: id[integer]:113 data[text]:'untoasted111' table public.toasted_copy: INSERT: id[integer]:114 data[text]:'untoasted112' table public.toasted_copy: INSERT: id[integer]:115 data[text]:'untoasted113' table public.toasted_copy: INSERT: id[integer]:116 data[text]:'untoasted114' table public.toasted_copy: INSERT: id[integer]:117 data[text]:'untoasted115' table public.toasted_copy: INSERT: id[integer]:118 data[text]:'untoasted116' table public.toasted_copy: INSERT: id[integer]:119 data[text]:'untoasted117' table public.toasted_copy: INSERT: id[integer]:120 data[text]:'untoasted118' table public.toasted_copy: INSERT: id[integer]:121 data[text]:'untoasted119' table public.toasted_copy: INSERT: id[integer]:122 data[text]:'untoasted120' table public.toasted_copy: INSERT: id[integer]:123 data[text]:'untoasted121' table public.toasted_copy: INSERT: id[integer]:124 data[text]:'untoasted122' table public.toasted_copy: INSERT: id[integer]:125 data[text]:'untoasted123' table public.toasted_copy: INSERT: id[integer]:126 data[text]:'untoasted124' table public.toasted_copy: INSERT: id[integer]:127 data[text]:'untoasted125' table public.toasted_copy: INSERT: id[integer]:128 data[text]:'untoasted126' table public.toasted_copy: INSERT: id[integer]:129 data[text]:'untoasted127' table public.toasted_copy: INSERT: id[integer]:130 data[text]:'untoasted128' table public.toasted_copy: INSERT: id[integer]:131 data[text]:'untoasted129' table public.toasted_copy: INSERT: id[integer]:132 data[text]:'untoasted130' table public.toasted_copy: INSERT: id[integer]:133 data[text]:'untoasted131' table public.toasted_copy: INSERT: id[integer]:134 data[text]:'untoasted132' table public.toasted_copy: INSERT: id[integer]:135 data[text]:'untoasted133' table public.toasted_copy: INSERT: id[integer]:136 data[text]:'untoasted134' table public.toasted_copy: INSERT: id[integer]:137 data[text]:'untoasted135' table public.toasted_copy: INSERT: id[integer]:138 data[text]:'untoasted136' table public.toasted_copy: INSERT: id[integer]:139 data[text]:'untoasted137' table public.toasted_copy: INSERT: id[integer]:140 data[text]:'untoasted138' table public.toasted_copy: INSERT: id[integer]:141 data[text]:'untoasted139' table public.toasted_copy: INSERT: id[integer]:142 data[text]:'untoasted140' table public.toasted_copy: INSERT: id[integer]:143 data[text]:'untoasted141' table public.toasted_copy: INSERT: id[integer]:144 data[text]:'untoasted142' table public.toasted_copy: INSERT: id[integer]:145 data[text]:'untoasted143' table public.toasted_copy: INSERT: id[integer]:146 data[text]:'untoasted144' table public.toasted_copy: INSERT: id[integer]:147 data[text]:'untoasted145' table public.toasted_copy: INSERT: id[integer]:148 data[text]:'untoasted146' table public.toasted_copy: INSERT: id[integer]:149 data[text]:'untoasted147' table public.toasted_copy: INSERT: id[integer]:150 data[text]:'untoasted148' table public.toasted_copy: INSERT: id[integer]:151 data[text]:'untoasted149' table public.toasted_copy: INSERT: id[integer]:152 data[text]:'untoasted150' table public.toasted_copy: INSERT: id[integer]:153 data[text]:'untoasted151' table public.toasted_copy: INSERT: id[integer]:154 data[text]:'untoasted152' table public.toasted_copy: INSERT: id[integer]:155 data[text]:'untoasted153' table public.toasted_copy: INSERT: id[integer]:156 data[text]:'untoasted154' table public.toasted_copy: INSERT: id[integer]:157 data[text]:'untoasted155' table public.toasted_copy: INSERT: id[integer]:158 data[text]:'untoasted156' table public.toasted_copy: INSERT: id[integer]:159 data[text]:'untoasted157' table public.toasted_copy: INSERT: id[integer]:160 data[text]:'untoasted158' table public.toasted_copy: INSERT: id[integer]:161 data[text]:'untoasted159' table public.toasted_copy: INSERT: id[integer]:162 data[text]:'untoasted160' table public.toasted_copy: INSERT: id[integer]:163 data[text]:'untoasted161' table public.toasted_copy: INSERT: id[integer]:164 data[text]:'untoasted162' table public.toasted_copy: INSERT: id[integer]:165 data[text]:'untoasted163' table public.toasted_copy: INSERT: id[integer]:166 data[text]:'untoasted164' table public.toasted_copy: INSERT: id[integer]:167 data[text]:'untoasted165' table public.toasted_copy: INSERT: id[integer]:168 data[text]:'untoasted166' table public.toasted_copy: INSERT: id[integer]:169 data[text]:'untoasted167' table public.toasted_copy: INSERT: id[integer]:170 data[text]:'untoasted168' table public.toasted_copy: INSERT: id[integer]:171 data[text]:'untoasted169' table public.toasted_copy: INSERT: id[integer]:172 data[text]:'untoasted170' table public.toasted_copy: INSERT: id[integer]:173 data[text]:'untoasted171' table public.toasted_copy: INSERT: id[integer]:174 data[text]:'untoasted172' table public.toasted_copy: INSERT: id[integer]:175 data[text]:'untoasted173' table public.toasted_copy: INSERT: id[integer]:176 data[text]:'untoasted174' table public.toasted_copy: INSERT: id[integer]:177 data[text]:'untoasted175' table public.toasted_copy: INSERT: id[integer]:178 data[text]:'untoasted176' table public.toasted_copy: INSERT: id[integer]:179 data[text]:'untoasted177' table public.toasted_copy: INSERT: id[integer]:180 data[text]:'untoasted178' table public.toasted_copy: INSERT: id[integer]:181 data[text]:'untoasted179' table public.toasted_copy: INSERT: id[integer]:182 data[text]:'untoasted180' table public.toasted_copy: INSERT: id[integer]:183 data[text]:'untoasted181' table public.toasted_copy: INSERT: id[integer]:184 data[text]:'untoasted182' table public.toasted_copy: INSERT: id[integer]:185 data[text]:'untoasted183' table public.toasted_copy: INSERT: id[integer]:186 data[text]:'untoasted184' table public.toasted_copy: INSERT: id[integer]:187 data[text]:'untoasted185' table public.toasted_copy: INSERT: id[integer]:188 data[text]:'untoasted186' table public.toasted_copy: INSERT: id[integer]:189 data[text]:'untoasted187' table public.toasted_copy: INSERT: id[integer]:190 data[text]:'untoasted188' table public.toasted_copy: INSERT: id[integer]:191 data[text]:'untoasted189' table public.toasted_copy: INSERT: id[integer]:192 data[text]:'untoasted190' table public.toasted_copy: INSERT: id[integer]:193 data[text]:'untoasted191' table public.toasted_copy: INSERT: id[integer]:194 data[text]:'untoasted192' table public.toasted_copy: INSERT: id[integer]:195 data[text]:'untoasted193' table public.toasted_copy: INSERT: id[integer]:196 data[text]:'untoasted194' table public.toasted_copy: INSERT: id[integer]:197 data[text]:'untoasted195' table public.toasted_copy: INSERT: id[integer]:198 data[text]:'untoasted196' table public.toasted_copy: INSERT: id[integer]:199 data[text]:'untoasted197' table public.toasted_copy: INSERT: id[integer]:200 data[text]:'untoasted198' table public.toasted_copy: INSERT: id[integer]:201 data[text]:'toasted3-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 table public.toasted_copy: INSERT: id[integer]:202 data[text]:'untoasted199' table public.toasted_copy: INSERT: id[integer]:203 data[text]:'untoasted200' COMMIT (235 rows) -- test we can decode "old" tuples bigger than the max heap tuple size correctly DROP TABLE IF EXISTS toasted_several; NOTICE: table "toasted_several" does not exist, skipping CREATE TABLE toasted_several ( id serial unique not null, toasted_key text primary key, toasted_col1 text, toasted_col2 text ); ALTER TABLE toasted_several REPLICA IDENTITY FULL; ALTER TABLE toasted_several ALTER COLUMN toasted_key SET STORAGE EXTERNAL; ALTER TABLE toasted_several ALTER COLUMN toasted_col1 SET STORAGE EXTERNAL; ALTER TABLE toasted_several ALTER COLUMN toasted_col2 SET STORAGE EXTERNAL; -- Change the storage of the index back to EXTENDED, separately from -- the table. This is currently not doable via DDL, but it is -- supported internally. UPDATE pg_attribute SET attstorage = 'x' WHERE attrelid = 'toasted_several_pkey'::regclass AND attname = 'toasted_key'; INSERT INTO toasted_several(toasted_key) VALUES(repeat('9876543210', 10000)); SELECT pg_column_size(toasted_key) > 2^16 FROM toasted_several; ?column? ---------- t (1 row) 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'); regexp_replace ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ BEGIN table public.toasted_several: INSERT: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..098765432109876543210987654321098765432109876543210' toasted_col1[text]:null toasted_col2[text]:null COMMIT (3 rows) -- test update of a toasted key without changing it UPDATE toasted_several SET toasted_col1 = toasted_key; UPDATE toasted_several SET toasted_col2 = toasted_col1; 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'); regexp_replace ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ BEGIN table public.toasted_several: INSERT: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..098765432109876543210987654321098765432109876543210' toasted_col1[text]:null toasted_col2[text]:null COMMIT BEGIN table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..432109876543210987654321098765432109876543210987654321098765432109876543210' toasted_col2[text]:null COMMIT BEGIN table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210' COMMIT (9 rows) /* * update with large tuplebuf, in a transaction large enough to force to spool to disk */ BEGIN; INSERT INTO toasted_several(toasted_key) SELECT * FROM generate_series(1, 10234); UPDATE toasted_several SET toasted_col1 = toasted_col2 WHERE id = 1; DELETE FROM toasted_several WHERE id = 1; COMMIT; DROP TABLE toasted_several; 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') WHERE data NOT LIKE '%INSERT: %'; regexp_replace ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ BEGIN table public.toasted_several: UPDATE: old-key: id[integer]:1 toasted_key[text]:'98765432109876543210..7654321098765432109876543210987654321098765432109876543210' toasted_col2[text]:unchanged-toast-datum table public.toasted_several: DELETE: id[integer]:1 toasted_key[text]:'98765432109876543210987654321..876543210987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210' COMMIT (4 rows) /* * Test decoding relation rewrite with toast. The insert into tbl2 within the * same transaction is there to check that there is no remaining toast_hash not * being reset. */ CREATE TABLE tbl1 (a INT, b TEXT); CREATE TABLE tbl2 (a INT); ALTER TABLE tbl1 ALTER COLUMN b SET STORAGE EXTERNAL; BEGIN; INSERT INTO tbl1 VALUES(1, repeat('a', 4000)) ; ALTER TABLE tbl1 ADD COLUMN id serial primary key; INSERT INTO tbl2 VALUES(1); commit; SELECT substr(data, 1, 200) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); substr ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- BEGIN table public.tbl1: INSERT: a[integer]:1 b[text]:'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa table public.tbl2: INSERT: a[integer]:1 COMMIT (4 rows) SELECT pg_drop_replication_slot('regression_slot'); pg_drop_replication_slot -------------------------- (1 row)