2014-02-19 14:35:23 +01:00
|
|
|
--
|
|
|
|
-- PG_LSN
|
|
|
|
--
|
|
|
|
CREATE TABLE PG_LSN_TBL (f1 pg_lsn);
|
|
|
|
-- Largest and smallest input
|
|
|
|
INSERT INTO PG_LSN_TBL VALUES ('0/0');
|
|
|
|
INSERT INTO PG_LSN_TBL VALUES ('FFFFFFFF/FFFFFFFF');
|
|
|
|
-- Incorrect input
|
|
|
|
INSERT INTO PG_LSN_TBL VALUES ('G/0');
|
2014-02-19 16:06:59 +01:00
|
|
|
ERROR: invalid input syntax for type pg_lsn: "G/0"
|
2014-02-19 14:35:23 +01:00
|
|
|
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('G/0');
|
|
|
|
^
|
|
|
|
INSERT INTO PG_LSN_TBL VALUES ('-1/0');
|
2014-02-19 16:06:59 +01:00
|
|
|
ERROR: invalid input syntax for type pg_lsn: "-1/0"
|
2014-02-19 14:35:23 +01:00
|
|
|
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('-1/0');
|
|
|
|
^
|
|
|
|
INSERT INTO PG_LSN_TBL VALUES (' 0/12345678');
|
2014-02-19 16:06:59 +01:00
|
|
|
ERROR: invalid input syntax for type pg_lsn: " 0/12345678"
|
2014-02-19 14:35:23 +01:00
|
|
|
LINE 1: INSERT INTO PG_LSN_TBL VALUES (' 0/12345678');
|
|
|
|
^
|
|
|
|
INSERT INTO PG_LSN_TBL VALUES ('ABCD/');
|
2014-02-19 16:06:59 +01:00
|
|
|
ERROR: invalid input syntax for type pg_lsn: "ABCD/"
|
2014-02-19 14:35:23 +01:00
|
|
|
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('ABCD/');
|
|
|
|
^
|
|
|
|
INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
|
2014-02-19 16:06:59 +01:00
|
|
|
ERROR: invalid input syntax for type pg_lsn: "/ABCD"
|
2014-02-19 14:35:23 +01:00
|
|
|
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
|
|
|
|
^
|
Convert a few more datatype input functions to report errors softly.
Convert assorted internal-ish datatypes, namely aclitemin,
int2vectorin, oidin, oidvectorin, pg_lsn_in, pg_snapshot_in,
and tidin to the new style.
(Some others you might expect to find in this group, such as
cidin and xidin, need no changes because they never throw
errors at all. That seems a little cheesy ... but it is not in
the charter of this patch series to add new error conditions.)
Amul Sul, minor mods by me
Discussion: https://postgr.es/m/CAAJ_b97KeDWUdpTKGOaFYPv0OicjOu6EW+QYWj-Ywrgj_aEy1g@mail.gmail.com
2022-12-14 23:50:24 +01:00
|
|
|
-- Also try it with non-error-throwing API
|
|
|
|
SELECT pg_input_is_valid('16AE7F7', 'pg_lsn');
|
|
|
|
pg_input_is_valid
|
|
|
|
-------------------
|
|
|
|
f
|
|
|
|
(1 row)
|
|
|
|
|
2023-02-28 00:04:13 +01:00
|
|
|
SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn');
|
|
|
|
message | detail | hint | sql_error_code
|
|
|
|
-------------------------------------------------+--------+------+----------------
|
|
|
|
invalid input syntax for type pg_lsn: "16AE7F7" | | | 22P02
|
Convert a few more datatype input functions to report errors softly.
Convert assorted internal-ish datatypes, namely aclitemin,
int2vectorin, oidin, oidvectorin, pg_lsn_in, pg_snapshot_in,
and tidin to the new style.
(Some others you might expect to find in this group, such as
cidin and xidin, need no changes because they never throw
errors at all. That seems a little cheesy ... but it is not in
the charter of this patch series to add new error conditions.)
Amul Sul, minor mods by me
Discussion: https://postgr.es/m/CAAJ_b97KeDWUdpTKGOaFYPv0OicjOu6EW+QYWj-Ywrgj_aEy1g@mail.gmail.com
2022-12-14 23:50:24 +01:00
|
|
|
(1 row)
|
|
|
|
|
2019-07-05 05:21:11 +02:00
|
|
|
-- Min/Max aggregation
|
|
|
|
SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL;
|
|
|
|
min | max
|
|
|
|
-----+-------------------
|
|
|
|
0/0 | FFFFFFFF/FFFFFFFF
|
|
|
|
(1 row)
|
|
|
|
|
2014-02-19 14:35:23 +01:00
|
|
|
DROP TABLE PG_LSN_TBL;
|
|
|
|
-- Operators
|
|
|
|
SELECT '0/16AE7F8' = '0/16AE7F8'::pg_lsn;
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '0/16AE7F8'::pg_lsn != '0/16AE7F7';
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '0/16AE7F7' < '0/16AE7F8'::pg_lsn;
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '0/16AE7F8' > pg_lsn '0/16AE7F7';
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
t
|
|
|
|
(1 row)
|
|
|
|
|
2014-02-24 15:32:21 +01:00
|
|
|
SELECT '0/16AE7F7'::pg_lsn - '0/16AE7F8'::pg_lsn;
|
2014-02-19 15:34:15 +01:00
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
-1
|
|
|
|
(1 row)
|
|
|
|
|
2014-02-24 15:32:21 +01:00
|
|
|
SELECT '0/16AE7F8'::pg_lsn - '0/16AE7F7'::pg_lsn;
|
2014-02-19 14:35:23 +01:00
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
1
|
|
|
|
(1 row)
|
|
|
|
|
2020-06-30 16:55:07 +02:00
|
|
|
SELECT '0/16AE7F7'::pg_lsn + 16::numeric;
|
|
|
|
?column?
|
|
|
|
-----------
|
|
|
|
0/16AE807
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT 16::numeric + '0/16AE7F7'::pg_lsn;
|
|
|
|
?column?
|
|
|
|
-----------
|
|
|
|
0/16AE807
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '0/16AE7F7'::pg_lsn - 16::numeric;
|
|
|
|
?column?
|
|
|
|
-----------
|
|
|
|
0/16AE7E7
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 1::numeric;
|
|
|
|
?column?
|
|
|
|
-------------------
|
|
|
|
FFFFFFFF/FFFFFFFF
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 2::numeric; -- out of range error
|
|
|
|
ERROR: pg_lsn out of range
|
|
|
|
SELECT '0/1'::pg_lsn - 1::numeric;
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
0/0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '0/1'::pg_lsn - 2::numeric; -- out of range error
|
|
|
|
ERROR: pg_lsn out of range
|
|
|
|
SELECT '0/0'::pg_lsn + ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn);
|
|
|
|
?column?
|
|
|
|
-------------------
|
|
|
|
FFFFFFFF/FFFFFFFF
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT 'FFFFFFFF/FFFFFFFF'::pg_lsn - ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn);
|
|
|
|
?column?
|
|
|
|
----------
|
|
|
|
0/0
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT '0/16AE7F7'::pg_lsn + 'NaN'::numeric;
|
|
|
|
ERROR: cannot add NaN to pg_lsn
|
|
|
|
SELECT '0/16AE7F7'::pg_lsn - 'NaN'::numeric;
|
|
|
|
ERROR: cannot subtract NaN from pg_lsn
|
2014-06-05 02:45:56 +02:00
|
|
|
-- Check btree and hash opclasses
|
|
|
|
EXPLAIN (COSTS OFF)
|
|
|
|
SELECT DISTINCT (i || '/' || j)::pg_lsn f
|
|
|
|
FROM generate_series(1, 10) i,
|
|
|
|
generate_series(1, 10) j,
|
|
|
|
generate_series(1, 5) k
|
2014-06-05 03:31:41 +02:00
|
|
|
WHERE i <= 10 AND j > 0 AND j <= 10
|
2014-06-05 02:45:56 +02:00
|
|
|
ORDER BY f;
|
|
|
|
QUERY PLAN
|
|
|
|
--------------------------------------------------------------------------
|
|
|
|
Sort
|
|
|
|
Sort Key: (((((i.i)::text || '/'::text) || (j.j)::text))::pg_lsn)
|
|
|
|
-> HashAggregate
|
|
|
|
Group Key: ((((i.i)::text || '/'::text) || (j.j)::text))::pg_lsn
|
|
|
|
-> Nested Loop
|
|
|
|
-> Function Scan on generate_series k
|
|
|
|
-> Materialize
|
|
|
|
-> Nested Loop
|
|
|
|
-> Function Scan on generate_series j
|
2014-06-05 03:31:41 +02:00
|
|
|
Filter: ((j > 0) AND (j <= 10))
|
|
|
|
-> Function Scan on generate_series i
|
|
|
|
Filter: (i <= 10)
|
|
|
|
(12 rows)
|
2014-06-05 02:45:56 +02:00
|
|
|
|
|
|
|
SELECT DISTINCT (i || '/' || j)::pg_lsn f
|
|
|
|
FROM generate_series(1, 10) i,
|
|
|
|
generate_series(1, 10) j,
|
|
|
|
generate_series(1, 5) k
|
2014-06-05 03:31:41 +02:00
|
|
|
WHERE i <= 10 AND j > 0 AND j <= 10
|
2014-06-05 02:45:56 +02:00
|
|
|
ORDER BY f;
|
|
|
|
f
|
|
|
|
-------
|
|
|
|
1/1
|
|
|
|
1/2
|
|
|
|
1/3
|
|
|
|
1/4
|
|
|
|
1/5
|
|
|
|
1/6
|
|
|
|
1/7
|
|
|
|
1/8
|
|
|
|
1/9
|
|
|
|
1/10
|
|
|
|
2/1
|
|
|
|
2/2
|
|
|
|
2/3
|
|
|
|
2/4
|
|
|
|
2/5
|
|
|
|
2/6
|
|
|
|
2/7
|
|
|
|
2/8
|
|
|
|
2/9
|
|
|
|
2/10
|
|
|
|
3/1
|
|
|
|
3/2
|
|
|
|
3/3
|
|
|
|
3/4
|
|
|
|
3/5
|
|
|
|
3/6
|
|
|
|
3/7
|
|
|
|
3/8
|
|
|
|
3/9
|
|
|
|
3/10
|
|
|
|
4/1
|
|
|
|
4/2
|
|
|
|
4/3
|
|
|
|
4/4
|
|
|
|
4/5
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