From: Christoph Berg Date: Thu, 6 Jun 2024 16:19:08 +0000 (+0200) Subject: Add regression test for toast X-Git-Tag: REL_17_0~4 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=78df2aeee8de961b8187aa855fff30b4324dc2ce;p=pg_filedump.git Add regression test for toast --- diff --git a/.gitignore b/.gitignore index e6f9ad5..433987f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ /*.bc /*.heap +/[1-9]*[0-9] /*.o /pg_filedump /regression.* /results/ +/tmp_check/ testfile* diff --git a/Makefile b/Makefile index a39bfca..d703df5 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ PROGRAM = pg_filedump OBJS = pg_filedump.o decode.o stringinfo.o REGRESS = datatypes float numeric xml toast TAP_TESTS = 1 -EXTRA_CLEAN = *.heap +EXTRA_CLEAN = *.heap $(wildcard [1-9]???[0-9]) # testsuite leftovers PG_CONFIG ?= pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) diff --git a/expected/toast.out b/expected/toast.out new file mode 100644 index 0000000..084abb4 --- /dev/null +++ b/expected/toast.out @@ -0,0 +1,107 @@ +-- PG14+ output in toast.out; PG13- output in toast_1.out +create table toast ( + description text, + data text +); +insert into toast values ('short inline', 'xxx'); +insert into toast values ('long inline uncompressed', repeat('x', 200)); +alter table toast alter column data set storage external; +insert into toast values ('external uncompressed', repeat('0123456789 8< ', 200)); +alter table toast alter column data set storage extended; +insert into toast values ('inline compressed pglz', repeat('0123456789 8< ', 200)); +insert into toast values ('extended compressed pglz', repeat('0123456789 8< ', 20000)); +alter table toast alter column data set compression lz4; +insert into toast values ('inline compressed lz4', repeat('0123456789 8< ', 200)); +insert into toast values ('extended compressed lz4', repeat('0123456789 8< ', 50000)); +vacuum toast; +checkpoint; +-- copy tables where client can read it +\set relname 'toast' +select oid as datoid from pg_database where datname = current_database() \gset +select relfilenode, reltoastrelid from pg_class where relname = :'relname' \gset +select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as loid \gset +\set output :relname '.heap' +\lo_export :loid :output +select lo_import(format('base/%s/%s', :'datoid', :'reltoastrelid')) as toast_loid \gset +\set output :reltoastrelid +\lo_export :toast_loid :output +\setenv relname :relname +\! pg_filedump -D text,text $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" + +******************************************************************* +* PostgreSQL File/Block Formatted Dump Utility +* +* File: toast.heap +* Options used: -D text,text +******************************************************************* + +Block 0 ******************************************************** +
----- + Block Offset: 0x00000000 Offsets: Lower 52 (0x0034) + Block: Size 8192 Version 4 Upper 7472 (0x1d30) + LSN: logid . recoff 0x........ Special 8192 (0x2000) + Items: 7 Free Space: 7420 + Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) + Length (including item array): 52 + + ----- + Item 1 -- Length: 41 Offset: 8144 (0x1fd0) Flags: NORMAL +COPY: short inline xxx + Item 2 -- Length: 256 Offset: 7888 (0x1ed0) Flags: NORMAL +COPY: long inline uncompressed xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + Item 3 -- Length: 64 Offset: 7824 (0x1e90) Flags: NORMAL +COPY: external uncompressed (TOASTED,uncompressed) + Item 4 -- Length: 107 Offset: 7712 (0x1e20) Flags: NORMAL +COPY: inline compressed pglz 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< + Item 5 -- Length: 67 Offset: 7640 (0x1dd8) Flags: NORMAL +COPY: extended compressed pglz (TOASTED,pglz) + Item 6 -- Length: 90 Offset: 7544 (0x1d78) Flags: NORMAL +COPY: inline compressed lz4 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< + Item 7 -- Length: 66 Offset: 7472 (0x1d30) Flags: NORMAL +COPY: extended compressed lz4 (TOASTED,lz4) + + +*** End of File Encountered. Last Block Read: 0 *** +\! pg_filedump -D text,text -t $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" -e 's/id: ...../id: ...../g' -e 's/ 8< .*//' + +******************************************************************* +* PostgreSQL File/Block Formatted Dump Utility +* +* File: toast.heap +* Options used: -D text,text -t +******************************************************************* + +Block 0 ******************************************************** +
----- + Block Offset: 0x00000000 Offsets: Lower 52 (0x0034) + Block: Size 8192 Version 4 Upper 7472 (0x1d30) + LSN: logid . recoff 0x........ Special 8192 (0x2000) + Items: 7 Free Space: 7420 + Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) + Length (including item array): 52 + + ----- + Item 1 -- Length: 41 Offset: 8144 (0x1fd0) Flags: NORMAL +COPY: short inline xxx + Item 2 -- Length: 256 Offset: 7888 (0x1ed0) Flags: NORMAL +COPY: long inline uncompressed xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + Item 3 -- Length: 64 Offset: 7824 (0x1e90) Flags: NORMAL + TOAST value. Raw size: 2804, external size: 2800, value id: ....., toast relation id: ..... + Number of chunks: 2 +COPY: external uncompressed 0123456789 + Item 4 -- Length: 107 Offset: 7712 (0x1e20) Flags: NORMAL +COPY: inline compressed pglz 0123456789 + Item 5 -- Length: 67 Offset: 7640 (0x1dd8) Flags: NORMAL + TOAST value. Raw size: 280004, external size: 3226, value id: ....., toast relation id: ..... + Number of chunks: 2 +COPY: extended compressed pglz 0123456789 + Item 6 -- Length: 90 Offset: 7544 (0x1d78) Flags: NORMAL +COPY: inline compressed lz4 0123456789 + Item 7 -- Length: 66 Offset: 7472 (0x1d30) Flags: NORMAL + TOAST value. Raw size: 700004, external size: 2772, value id: ....., toast relation id: ..... + Number of chunks: 2 + +COPY: extended compressed lz4 0123456789 + + +*** End of File Encountered. Last Block Read: 0 *** diff --git a/expected/toast_1.out b/expected/toast_1.out new file mode 100644 index 0000000..ac673c2 --- /dev/null +++ b/expected/toast_1.out @@ -0,0 +1,68 @@ +-- PG14+ output in toast.out; PG13- output in toast_1.out +create table toast ( + description text, + data text +); +insert into toast values ('short inline', 'xxx'); +insert into toast values ('long inline uncompressed', repeat('x', 200)); +alter table toast alter column data set storage external; +insert into toast values ('external uncompressed', repeat('0123456789 8< ', 200)); +alter table toast alter column data set storage extended; +insert into toast values ('inline compressed pglz', repeat('0123456789 8< ', 200)); +insert into toast values ('extended compressed pglz', repeat('0123456789 8< ', 20000)); +alter table toast alter column data set compression lz4; +ERROR: syntax error at or near "compression" +LINE 1: alter table toast alter column data set compression lz4; + ^ +insert into toast values ('inline compressed lz4', repeat('0123456789 8< ', 200)); +insert into toast values ('extended compressed lz4', repeat('0123456789 8< ', 50000)); +vacuum toast; +checkpoint; +-- copy tables where client can read it +\set relname 'toast' +select oid as datoid from pg_database where datname = current_database() \gset +select relfilenode, reltoastrelid from pg_class where relname = :'relname' \gset +select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as loid \gset +\set output :relname '.heap' +\lo_export :loid :output +select lo_import(format('base/%s/%s', :'datoid', :'reltoastrelid')) as toast_loid \gset +\set output :reltoastrelid +\lo_export :toast_loid :output +\setenv relname :relname +\! pg_filedump -D text,text $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" + +******************************************************************* +* PostgreSQL File/Block Formatted Dump Utility +* +* File: toast.heap +* Options used: -D text,text +******************************************************************* + +Block 0 ******************************************************** +
----- + Block Offset: 0x00000000 Offsets: Lower 52 (0x0034) + Block: Size 8192 Version 4 Upper 7456 (0x1d20) + LSN: logid . recoff 0x........ Special 8192 (0x2000) + Items: 7 Free Space: 7404 + Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) + Length (including item array): 52 + + ----- + Item 1 -- Length: 41 Offset: 8144 (0x1fd0) Flags: NORMAL +COPY: short inline xxx + Item 2 -- Length: 256 Offset: 7888 (0x1ed0) Flags: NORMAL +COPY: long inline uncompressed xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + Item 3 -- Length: 64 Offset: 7824 (0x1e90) Flags: NORMAL +COPY: external uncompressed (TOASTED,uncompressed) + Item 4 -- Length: 107 Offset: 7712 (0x1e20) Flags: NORMAL +COPY: inline compressed pglz 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< + Item 5 -- Length: 67 Offset: 7640 (0x1dd8) Flags: NORMAL +COPY: extended compressed pglz (TOASTED,pglz) + Item 6 -- Length: 107 Offset: 7528 (0x1d68) Flags: NORMAL +COPY: inline compressed lz4 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< 0123456789 8< + Item 7 -- Length: 66 Offset: 7456 (0x1d20) Flags: NORMAL +COPY: extended compressed lz4 (TOASTED,pglz) + + +*** End of File Encountered. Last Block Read: 0 *** +\! pg_filedump -D text,text -t $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" -e 's/id: ...../id: ...../g' -e 's/ 8< .*//' diff --git a/sql/toast.sql b/sql/toast.sql new file mode 100644 index 0000000..3356596 --- /dev/null +++ b/sql/toast.sql @@ -0,0 +1,38 @@ +-- PG14+ output in toast.out; PG13- output in toast_1.out + +create table toast ( + description text, + data text +); + +insert into toast values ('short inline', 'xxx'); +insert into toast values ('long inline uncompressed', repeat('x', 200)); + +alter table toast alter column data set storage external; +insert into toast values ('external uncompressed', repeat('0123456789 8< ', 200)); + +alter table toast alter column data set storage extended; +insert into toast values ('inline compressed pglz', repeat('0123456789 8< ', 200)); +insert into toast values ('extended compressed pglz', repeat('0123456789 8< ', 20000)); + +alter table toast alter column data set compression lz4; +insert into toast values ('inline compressed lz4', repeat('0123456789 8< ', 200)); +insert into toast values ('extended compressed lz4', repeat('0123456789 8< ', 50000)); + +vacuum toast; +checkpoint; + +-- copy tables where client can read it +\set relname 'toast' +select oid as datoid from pg_database where datname = current_database() \gset +select relfilenode, reltoastrelid from pg_class where relname = :'relname' \gset +select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as loid \gset +\set output :relname '.heap' +\lo_export :loid :output +select lo_import(format('base/%s/%s', :'datoid', :'reltoastrelid')) as toast_loid \gset +\set output :reltoastrelid +\lo_export :toast_loid :output + +\setenv relname :relname +\! pg_filedump -D text,text $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" +\! pg_filedump -D text,text -t $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" -e 's/id: ...../id: ...../g' -e 's/ 8< .*//'