postgresql/src/test/regress/expected/pg_lsn.out

271 lines
4.9 KiB
Plaintext

--
-- 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');
ERROR: invalid input syntax for type pg_lsn: "G/0"
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('G/0');
^
INSERT INTO PG_LSN_TBL VALUES ('-1/0');
ERROR: invalid input syntax for type pg_lsn: "-1/0"
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('-1/0');
^
INSERT INTO PG_LSN_TBL VALUES (' 0/12345678');
ERROR: invalid input syntax for type pg_lsn: " 0/12345678"
LINE 1: INSERT INTO PG_LSN_TBL VALUES (' 0/12345678');
^
INSERT INTO PG_LSN_TBL VALUES ('ABCD/');
ERROR: invalid input syntax for type pg_lsn: "ABCD/"
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('ABCD/');
^
INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
ERROR: invalid input syntax for type pg_lsn: "/ABCD"
LINE 1: INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
^
-- Also try it with non-error-throwing API
SELECT pg_input_is_valid('16AE7F7', 'pg_lsn');
pg_input_is_valid
-------------------
f
(1 row)
SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn');
message | detail | hint | sql_error_code
-------------------------------------------------+--------+------+----------------
invalid input syntax for type pg_lsn: "16AE7F7" | | | 22P02
(1 row)
-- Min/Max aggregation
SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL;
min | max
-----+-------------------
0/0 | FFFFFFFF/FFFFFFFF
(1 row)
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)
SELECT '0/16AE7F7'::pg_lsn - '0/16AE7F8'::pg_lsn;
?column?
----------
-1
(1 row)
SELECT '0/16AE7F8'::pg_lsn - '0/16AE7F7'::pg_lsn;
?column?
----------
1
(1 row)
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
-- 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
WHERE i <= 10 AND j > 0 AND j <= 10
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
Filter: ((j > 0) AND (j <= 10))
-> Function Scan on generate_series i
Filter: (i <= 10)
(12 rows)
SELECT DISTINCT (i || '/' || j)::pg_lsn f
FROM generate_series(1, 10) i,
generate_series(1, 10) j,
generate_series(1, 5) k
WHERE i <= 10 AND j > 0 AND j <= 10
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
4/6
4/7
4/8
4/9
4/10
5/1
5/2
5/3
5/4
5/5
5/6
5/7
5/8
5/9
5/10
6/1
6/2
6/3
6/4
6/5
6/6
6/7
6/8
6/9
6/10
7/1
7/2
7/3
7/4
7/5
7/6
7/7
7/8
7/9
7/10
8/1
8/2
8/3
8/4
8/5
8/6
8/7
8/8
8/9
8/10
9/1
9/2
9/3
9/4
9/5
9/6
9/7
9/8
9/9
9/10
10/1
10/2
10/3
10/4
10/5
10/6
10/7
10/8
10/9
10/10
(100 rows)