4 CREATE TABLE PG_LSN_TBL (f1 pg_lsn);
5 -- Largest and smallest input
6 INSERT INTO PG_LSN_TBL VALUES ('0/0');
7 INSERT INTO PG_LSN_TBL VALUES ('FFFFFFFF/FFFFFFFF');
9 INSERT INTO PG_LSN_TBL VALUES ('G/0');
10 ERROR: invalid input syntax for type pg_lsn: "G/0"
11 LINE 1: INSERT INTO PG_LSN_TBL VALUES ('G/0');
13 INSERT INTO PG_LSN_TBL VALUES ('-1/0');
14 ERROR: invalid input syntax for type pg_lsn: "-1/0"
15 LINE 1: INSERT INTO PG_LSN_TBL VALUES ('-1/0');
17 INSERT INTO PG_LSN_TBL VALUES (' 0/12345678');
18 ERROR: invalid input syntax for type pg_lsn: " 0/12345678"
19 LINE 1: INSERT INTO PG_LSN_TBL VALUES (' 0/12345678');
21 INSERT INTO PG_LSN_TBL VALUES ('ABCD/');
22 ERROR: invalid input syntax for type pg_lsn: "ABCD/"
23 LINE 1: INSERT INTO PG_LSN_TBL VALUES ('ABCD/');
25 INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
26 ERROR: invalid input syntax for type pg_lsn: "/ABCD"
27 LINE 1: INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
29 -- Also try it with non-error-throwing API
30 SELECT pg_input_is_valid('16AE7F7', 'pg_lsn');
36 SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn');
37 message | detail | hint | sql_error_code
38 -------------------------------------------------+--------+------+----------------
39 invalid input syntax for type pg_lsn: "16AE7F7" | | | 22P02
42 -- Min/Max aggregation
43 SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL;
45 -----+-------------------
46 0/0 | FFFFFFFF/FFFFFFFF
49 DROP TABLE PG_LSN_TBL;
51 SELECT '0/16AE7F8' = '0/16AE7F8'::pg_lsn;
57 SELECT '0/16AE7F8'::pg_lsn != '0/16AE7F7';
63 SELECT '0/16AE7F7' < '0/16AE7F8'::pg_lsn;
69 SELECT '0/16AE7F8' > pg_lsn '0/16AE7F7';
75 SELECT '0/16AE7F7'::pg_lsn - '0/16AE7F8'::pg_lsn;
81 SELECT '0/16AE7F8'::pg_lsn - '0/16AE7F7'::pg_lsn;
87 SELECT '0/16AE7F7'::pg_lsn + 16::numeric;
93 SELECT 16::numeric + '0/16AE7F7'::pg_lsn;
99 SELECT '0/16AE7F7'::pg_lsn - 16::numeric;
105 SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 1::numeric;
111 SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 2::numeric; -- out of range error
112 ERROR: pg_lsn out of range
113 SELECT '0/1'::pg_lsn - 1::numeric;
119 SELECT '0/1'::pg_lsn - 2::numeric; -- out of range error
120 ERROR: pg_lsn out of range
121 SELECT '0/0'::pg_lsn + ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn);
127 SELECT 'FFFFFFFF/FFFFFFFF'::pg_lsn - ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn);
133 SELECT '0/16AE7F7'::pg_lsn + 'NaN'::numeric;
134 ERROR: cannot add NaN to pg_lsn
135 SELECT '0/16AE7F7'::pg_lsn - 'NaN'::numeric;
136 ERROR: cannot subtract NaN from pg_lsn
137 -- Check btree and hash opclasses
139 SELECT DISTINCT (i || '/' || j)::pg_lsn f
140 FROM generate_series(1, 10) i,
141 generate_series(1, 10) j,
142 generate_series(1, 5) k
143 WHERE i <= 10 AND j > 0 AND j <= 10
146 --------------------------------------------------------------------------
148 Sort Key: (((((i.i)::text || '/'::text) || (j.j)::text))::pg_lsn)
150 Group Key: ((((i.i)::text || '/'::text) || (j.j)::text))::pg_lsn
152 -> Function Scan on generate_series k
155 -> Function Scan on generate_series j
156 Filter: ((j > 0) AND (j <= 10))
157 -> Function Scan on generate_series i
161 SELECT DISTINCT (i || '/' || j)::pg_lsn f
162 FROM generate_series(1, 10) i,
163 generate_series(1, 10) j,
164 generate_series(1, 5) k
165 WHERE i <= 10 AND j > 0 AND j <= 10