From a4b27db1b00247fa646f284b31a5190d1461f330 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Thu, 14 Sep 2023 13:35:56 +0200 Subject: [PATCH] Support testing numeric with PG 13 and 14 Close #9. --- .github/workflows/ci.yml | 2 ++ Makefile | 2 +- expected/datatypes.out | 52 ------------------------------------ expected/datatypes_3.out | 52 ------------------------------------ expected/numeric.out | 57 ++++++++++++++++++++++++++++++++++++++++ expected/numeric_1.out | 56 +++++++++++++++++++++++++++++++++++++++ expected/numeric_3.out | 57 ++++++++++++++++++++++++++++++++++++++++ expected/numeric_4.out | 56 +++++++++++++++++++++++++++++++++++++++ sql/datatypes.sql | 5 ---- sql/numeric.sql | 12 +++++++++ 10 files changed, 241 insertions(+), 110 deletions(-) create mode 100644 expected/numeric.out create mode 100644 expected/numeric_1.out create mode 100644 expected/numeric_3.out create mode 100644 expected/numeric_4.out create mode 100644 sql/numeric.sql diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f188352..d1b5b6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,8 @@ jobs: - 15 - 14 # versions before 14 no not support Infinity in numeric + - 13 + - 12 # versions before 12 have a different output format for floats (inf/Infinity, nan/NaN) name: 🐘 PostgreSQL ${{ matrix.pg }} diff --git a/Makefile b/Makefile index 0982f5c..83fe0a4 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ FD_VERSION=14.1 PROGRAM = pg_filedump OBJS = pg_filedump.o decode.o stringinfo.o -REGRESS = datatypes +REGRESS = datatypes numeric EXTRA_CLEAN = *.heap PG_CONFIG = pg_config diff --git a/expected/datatypes.out b/expected/datatypes.out index dcd63e2..14be537 100644 --- a/expected/datatypes.out +++ b/expected/datatypes.out @@ -579,58 +579,6 @@ COPY: 123456789012345678901234567890123456789012345678901234567890123 COPY: \N -*** End of File Encountered. Last Block Read: 0 *** --- ----------------------------------------------------------------------------------------------- --- -create table numeric (x numeric); -insert into numeric values (0), ('12341234'), ('-567890'), ('-Infinity'), ('Infinity'), ('NaN'), (null); -\set relname numeric -\ir run_test.sql -\echo Testing :relname -Testing numeric -vacuum :"relname"; -checkpoint; -select relfilenode from pg_class where relname = :'relname' \gset -select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as oid \gset -\set output :relname '.heap' -\lo_export :oid :output -\setenv relname :relname -\! pg_filedump -D $relname $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" - -******************************************************************* -* PostgreSQL File/Block Formatted Dump Utility -* -* File: numeric.heap -* Options used: -D numeric -******************************************************************* - -Block 0 ******************************************************** -
----- - Block Offset: 0x00000000 Offsets: Lower 52 (0x0034) - Block: Size 8192 Version 4 Upper 7976 (0x1f28) - LSN: logid . recoff 0x........ Special 8192 (0x2000) - Items: 7 Free Space: 7924 - Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) - Length (including item array): 52 - - ----- - Item 1 -- Length: 27 Offset: 8160 (0x1fe0) Flags: NORMAL -COPY: 0 - Item 2 -- Length: 31 Offset: 8128 (0x1fc0) Flags: NORMAL -COPY: 12341234 - Item 3 -- Length: 31 Offset: 8096 (0x1fa0) Flags: NORMAL -COPY: -567890 - Item 4 -- Length: 27 Offset: 8064 (0x1f80) Flags: NORMAL -COPY: -Infinity - Item 5 -- Length: 27 Offset: 8032 (0x1f60) Flags: NORMAL -COPY: Infinity - Item 6 -- Length: 27 Offset: 8000 (0x1f40) Flags: NORMAL -COPY: NaN - Item 7 -- Length: 24 Offset: 7976 (0x1f28) Flags: NORMAL -COPY: \N - - *** End of File Encountered. Last Block Read: 0 *** -- ---------------------------------------------------------------------------------------------- diff --git a/expected/datatypes_3.out b/expected/datatypes_3.out index 8bd4760..5b956fa 100644 --- a/expected/datatypes_3.out +++ b/expected/datatypes_3.out @@ -579,58 +579,6 @@ COPY: 123456789012345678901234567890123456789012345678901234567890123 COPY: \N -*** End of File Encountered. Last Block Read: 0 *** --- ----------------------------------------------------------------------------------------------- --- -create table numeric (x numeric); -insert into numeric values (0), ('12341234'), ('-567890'), ('-Infinity'), ('Infinity'), ('NaN'), (null); -\set relname numeric -\ir run_test.sql -\echo Testing :relname -Testing numeric -vacuum :"relname"; -checkpoint; -select relfilenode from pg_class where relname = :'relname' \gset -select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as oid \gset -\set output :relname '.heap' -\lo_export :oid :output -\setenv relname :relname -\! pg_filedump -D $relname $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" - -******************************************************************* -* PostgreSQL File/Block Formatted Dump Utility -* -* File: numeric.heap -* Options used: -D numeric -******************************************************************* - -Block 0 ******************************************************** -
----- - Block Offset: 0x00000000 Offsets: Lower 52 (0x0034) - Block: Size 8192 Version 4 Upper 7992 (0x1f38) - LSN: logid . recoff 0x........ Special 8192 (0x2000) - Items: 7 Free Space: 7940 - Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) - Length (including item array): 52 - - ----- - Item 1 -- Length: 27 Offset: 8164 (0x1fe4) Flags: NORMAL -COPY: 0 - Item 2 -- Length: 31 Offset: 8132 (0x1fc4) Flags: NORMAL -COPY: 12341234 - Item 3 -- Length: 31 Offset: 8100 (0x1fa4) Flags: NORMAL -COPY: -567890 - Item 4 -- Length: 27 Offset: 8072 (0x1f88) Flags: NORMAL -COPY: -Infinity - Item 5 -- Length: 27 Offset: 8044 (0x1f6c) Flags: NORMAL -COPY: Infinity - Item 6 -- Length: 27 Offset: 8016 (0x1f50) Flags: NORMAL -COPY: NaN - Item 7 -- Length: 24 Offset: 7992 (0x1f38) Flags: NORMAL -COPY: \N - - *** End of File Encountered. Last Block Read: 0 *** -- ---------------------------------------------------------------------------------------------- diff --git a/expected/numeric.out b/expected/numeric.out new file mode 100644 index 0000000..5b24dcb --- /dev/null +++ b/expected/numeric.out @@ -0,0 +1,57 @@ +-- 64 bit output in *.out, 32 bit output in *_3.out +-- PG14+ output in *.out/*_3.out, earlier in *_1.out/*_4.out +select oid as datoid from pg_database where datname = current_database() \gset +---------------------------------------------------------------------------------------------- +create table numeric (x numeric); +insert into numeric values (0), ('12341234'), ('-567890'), ('NaN'), (null); +insert into numeric values ('-Infinity'), ('Infinity'); -- needs PG 14 +\set relname numeric +\ir run_test.sql +\echo Testing :relname +Testing numeric +vacuum :"relname"; +checkpoint; +select relfilenode from pg_class where relname = :'relname' \gset +select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as oid \gset +\set output :relname '.heap' +\lo_export :oid :output +\setenv relname :relname +\! pg_filedump -D $relname $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" + +******************************************************************* +* PostgreSQL File/Block Formatted Dump Utility +* +* File: numeric.heap +* Options used: -D numeric +******************************************************************* + +Block 0 ******************************************************** +
----- + Block Offset: 0x00000000 Offsets: Lower 52 (0x0034) + Block: Size 8192 Version 4 Upper 7976 (0x1f28) + LSN: logid . recoff 0x........ Special 8192 (0x2000) + Items: 7 Free Space: 7924 + Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) + Length (including item array): 52 + + ----- + Item 1 -- Length: 27 Offset: 8160 (0x1fe0) Flags: NORMAL +COPY: 0 + Item 2 -- Length: 31 Offset: 8128 (0x1fc0) Flags: NORMAL +COPY: 12341234 + Item 3 -- Length: 31 Offset: 8096 (0x1fa0) Flags: NORMAL +COPY: -567890 + Item 4 -- Length: 27 Offset: 8064 (0x1f80) Flags: NORMAL +COPY: NaN + Item 5 -- Length: 24 Offset: 8040 (0x1f68) Flags: NORMAL +COPY: \N + Item 6 -- Length: 27 Offset: 8008 (0x1f48) Flags: NORMAL +COPY: -Infinity + Item 7 -- Length: 27 Offset: 7976 (0x1f28) Flags: NORMAL +COPY: Infinity + + +*** End of File Encountered. Last Block Read: 0 *** +-- +---------------------------------------------------------------------------------------------- +-- diff --git a/expected/numeric_1.out b/expected/numeric_1.out new file mode 100644 index 0000000..1ba9896 --- /dev/null +++ b/expected/numeric_1.out @@ -0,0 +1,56 @@ +-- 64 bit output in *.out, 32 bit output in *_3.out +-- PG14+ output in *.out/*_3.out, earlier in *_1.out/*_4.out +select oid as datoid from pg_database where datname = current_database() \gset +---------------------------------------------------------------------------------------------- +create table numeric (x numeric); +insert into numeric values (0), ('12341234'), ('-567890'), ('NaN'), (null); +insert into numeric values ('-Infinity'), ('Infinity'); -- needs PG 14 +ERROR: invalid input syntax for type numeric: "-Infinity" +LINE 1: insert into numeric values ('-Infinity'), ('Infinity'); + ^ +\set relname numeric +\ir run_test.sql +\echo Testing :relname +Testing numeric +vacuum :"relname"; +checkpoint; +select relfilenode from pg_class where relname = :'relname' \gset +select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as oid \gset +\set output :relname '.heap' +\lo_export :oid :output +\setenv relname :relname +\! pg_filedump -D $relname $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" + +******************************************************************* +* PostgreSQL File/Block Formatted Dump Utility +* +* File: numeric.heap +* Options used: -D numeric +******************************************************************* + +Block 0 ******************************************************** +
----- + Block Offset: 0x00000000 Offsets: Lower 44 (0x002c) + Block: Size 8192 Version 4 Upper 8040 (0x1f68) + LSN: logid . recoff 0x........ Special 8192 (0x2000) + Items: 5 Free Space: 7996 + Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) + Length (including item array): 44 + + ----- + Item 1 -- Length: 27 Offset: 8160 (0x1fe0) Flags: NORMAL +COPY: 0 + Item 2 -- Length: 31 Offset: 8128 (0x1fc0) Flags: NORMAL +COPY: 12341234 + Item 3 -- Length: 31 Offset: 8096 (0x1fa0) Flags: NORMAL +COPY: -567890 + Item 4 -- Length: 27 Offset: 8064 (0x1f80) Flags: NORMAL +COPY: NaN + Item 5 -- Length: 24 Offset: 8040 (0x1f68) Flags: NORMAL +COPY: \N + + +*** End of File Encountered. Last Block Read: 0 *** +-- +---------------------------------------------------------------------------------------------- +-- diff --git a/expected/numeric_3.out b/expected/numeric_3.out new file mode 100644 index 0000000..8a29621 --- /dev/null +++ b/expected/numeric_3.out @@ -0,0 +1,57 @@ +-- 64 bit output in *.out, 32 bit output in *_3.out +-- PG14+ output in *.out/*_3.out, earlier in *_1.out/*_4.out +select oid as datoid from pg_database where datname = current_database() \gset +---------------------------------------------------------------------------------------------- +create table numeric (x numeric); +insert into numeric values (0), ('12341234'), ('-567890'), ('NaN'), (null); +insert into numeric values ('-Infinity'), ('Infinity'); -- needs PG 14 +\set relname numeric +\ir run_test.sql +\echo Testing :relname +Testing numeric +vacuum :"relname"; +checkpoint; +select relfilenode from pg_class where relname = :'relname' \gset +select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as oid \gset +\set output :relname '.heap' +\lo_export :oid :output +\setenv relname :relname +\! pg_filedump -D $relname $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" + +******************************************************************* +* PostgreSQL File/Block Formatted Dump Utility +* +* File: numeric.heap +* Options used: -D numeric +******************************************************************* + +Block 0 ******************************************************** +
----- + Block Offset: 0x00000000 Offsets: Lower 52 (0x0034) + Block: Size 8192 Version 4 Upper 7992 (0x1f38) + LSN: logid . recoff 0x........ Special 8192 (0x2000) + Items: 7 Free Space: 7940 + Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) + Length (including item array): 52 + + ----- + Item 1 -- Length: 27 Offset: 8164 (0x1fe4) Flags: NORMAL +COPY: 0 + Item 2 -- Length: 31 Offset: 8132 (0x1fc4) Flags: NORMAL +COPY: 12341234 + Item 3 -- Length: 31 Offset: 8100 (0x1fa4) Flags: NORMAL +COPY: -567890 + Item 4 -- Length: 27 Offset: 8072 (0x1f88) Flags: NORMAL +COPY: NaN + Item 5 -- Length: 24 Offset: 8048 (0x1f70) Flags: NORMAL +COPY: \N + Item 6 -- Length: 27 Offset: 8020 (0x1f54) Flags: NORMAL +COPY: -Infinity + Item 7 -- Length: 27 Offset: 7992 (0x1f38) Flags: NORMAL +COPY: Infinity + + +*** End of File Encountered. Last Block Read: 0 *** +-- +---------------------------------------------------------------------------------------------- +-- diff --git a/expected/numeric_4.out b/expected/numeric_4.out new file mode 100644 index 0000000..2065fe0 --- /dev/null +++ b/expected/numeric_4.out @@ -0,0 +1,56 @@ +-- 64 bit output in *.out, 32 bit output in *_3.out +-- PG14+ output in *.out/*_3.out, earlier in *_1.out/*_4.out +select oid as datoid from pg_database where datname = current_database() \gset +---------------------------------------------------------------------------------------------- +create table numeric (x numeric); +insert into numeric values (0), ('12341234'), ('-567890'), ('NaN'), (null); +insert into numeric values ('-Infinity'), ('Infinity'); -- needs PG 14 +ERROR: invalid input syntax for type numeric: "-Infinity" +LINE 1: insert into numeric values ('-Infinity'), ('Infinity'); + ^ +\set relname numeric +\ir run_test.sql +\echo Testing :relname +Testing numeric +vacuum :"relname"; +checkpoint; +select relfilenode from pg_class where relname = :'relname' \gset +select lo_import(format('base/%s/%s', :'datoid', :'relfilenode')) as oid \gset +\set output :relname '.heap' +\lo_export :oid :output +\setenv relname :relname +\! pg_filedump -D $relname $relname.heap | sed -e "s/logid ./logid ./" -e "s/recoff 0x......../recoff 0x......../" + +******************************************************************* +* PostgreSQL File/Block Formatted Dump Utility +* +* File: numeric.heap +* Options used: -D numeric +******************************************************************* + +Block 0 ******************************************************** +
----- + Block Offset: 0x00000000 Offsets: Lower 44 (0x002c) + Block: Size 8192 Version 4 Upper 8048 (0x1f70) + LSN: logid . recoff 0x........ Special 8192 (0x2000) + Items: 5 Free Space: 8004 + Checksum: 0x0000 Prune XID: 0x00000000 Flags: 0x0004 (ALL_VISIBLE) + Length (including item array): 44 + + ----- + Item 1 -- Length: 27 Offset: 8164 (0x1fe4) Flags: NORMAL +COPY: 0 + Item 2 -- Length: 31 Offset: 8132 (0x1fc4) Flags: NORMAL +COPY: 12341234 + Item 3 -- Length: 31 Offset: 8100 (0x1fa4) Flags: NORMAL +COPY: -567890 + Item 4 -- Length: 27 Offset: 8072 (0x1f88) Flags: NORMAL +COPY: NaN + Item 5 -- Length: 24 Offset: 8048 (0x1f70) Flags: NORMAL +COPY: \N + + +*** End of File Encountered. Last Block Read: 0 *** +-- +---------------------------------------------------------------------------------------------- +-- diff --git a/sql/datatypes.sql b/sql/datatypes.sql index 8f96d9f..4aa50d7 100644 --- a/sql/datatypes.sql +++ b/sql/datatypes.sql @@ -69,11 +69,6 @@ insert into name values ('name'), ('12345678901234567890123456789012345678901234 \set relname name \ir run_test.sql -create table numeric (x numeric); -insert into numeric values (0), ('12341234'), ('-567890'), ('-Infinity'), ('Infinity'), ('NaN'), (null); -\set relname numeric -\ir run_test.sql - create table oid (x oid); insert into oid values (-1), (0), (1), (null); \set relname oid diff --git a/sql/numeric.sql b/sql/numeric.sql new file mode 100644 index 0000000..59f2376 --- /dev/null +++ b/sql/numeric.sql @@ -0,0 +1,12 @@ +-- 64 bit output in *.out, 32 bit output in *_3.out +-- PG14+ output in *.out/*_3.out, earlier in *_1.out/*_4.out + +select oid as datoid from pg_database where datname = current_database() \gset + +---------------------------------------------------------------------------------------------- + +create table numeric (x numeric); +insert into numeric values (0), ('12341234'), ('-567890'), ('NaN'), (null); +insert into numeric values ('-Infinity'), ('Infinity'); -- needs PG 14 +\set relname numeric +\ir run_test.sql -- 2.39.5