diff options
| author | Tom Lane | 2022-03-04 01:03:47 +0000 |
|---|---|---|
| committer | Tom Lane | 2022-03-04 01:04:35 +0000 |
| commit | f7ea240aa7491b6ed2985bb50888bd432f3341df (patch) | |
| tree | 87d14901c88ddb3457c63af8264579e50b5f1188 /src/test | |
| parent | b3c8aae00850384b1cec5311eb1864e2f5e80a44 (diff) | |
Tighten overflow checks in tidin().
This code seems to have been written on the assumption that
"unsigned long" is 32 bits; or at any rate it ignored the
possibility of conversion overflow. Rewrite, borrowing some
logic from oidin().
Discussion: https://postgr.es/m/3441768.1646343914@sss.pgh.pa.us
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/tid.out | 19 | ||||
| -rw-r--r-- | src/test/regress/sql/tid.sql | 12 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/regress/expected/tid.out b/src/test/regress/expected/tid.out index 8da1a455761..7d8957bd6f7 100644 --- a/src/test/regress/expected/tid.out +++ b/src/test/regress/expected/tid.out @@ -1,3 +1,22 @@ +-- basic tests for the TID data type +SELECT + '(0,0)'::tid as tid00, + '(0,1)'::tid as tid01, + '(-1,0)'::tid as tidm10, + '(4294967295,65535)'::tid as tidmax; + tid00 | tid01 | tidm10 | tidmax +-------+-------+----------------+-------------------- + (0,0) | (0,1) | (4294967295,0) | (4294967295,65535) +(1 row) + +SELECT '(4294967296,1)'::tid; -- error +ERROR: invalid input syntax for type tid: "(4294967296,1)" +LINE 1: SELECT '(4294967296,1)'::tid; + ^ +SELECT '(1,65536)'::tid; -- error +ERROR: invalid input syntax for type tid: "(1,65536)" +LINE 1: SELECT '(1,65536)'::tid; + ^ -- tests for functions related to TID handling CREATE TABLE tid_tab (a int); -- min() and max() for TIDs diff --git a/src/test/regress/sql/tid.sql b/src/test/regress/sql/tid.sql index 34546a3cb7a..990d314a5f8 100644 --- a/src/test/regress/sql/tid.sql +++ b/src/test/regress/sql/tid.sql @@ -1,3 +1,15 @@ +-- basic tests for the TID data type + +SELECT + '(0,0)'::tid as tid00, + '(0,1)'::tid as tid01, + '(-1,0)'::tid as tidm10, + '(4294967295,65535)'::tid as tidmax; + +SELECT '(4294967296,1)'::tid; -- error +SELECT '(1,65536)'::tid; -- error + + -- tests for functions related to TID handling CREATE TABLE tid_tab (a int); |
