Skip to content
Snippets Groups Projects
Commit 28dd6647 authored by Michael Paquier's avatar Michael Paquier
Browse files

wal_utils: Add more error checks for parsing

parent 8ae10f0c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -25,4 +25,26 @@ SELECT parse_wal_history(data) FROM history_data;
(7,0/189BEB38,0/249BEB38)
(6 rows)
 
-- Sanity checks with some failures
-- Timeline number is not an integer.
TRUNCATE history_data;
INSERT INTO history_data VALUES ('not_integer_tli 0/249BEB38 string');
SELECT parse_wal_history(data) FROM history_data;
ERROR: syntax error in history file: not_integer_tli 0/249BEB38 string
HINT: Expected a numeric timeline ID.
-- Not three fields
TRUNCATE history_data;
INSERT INTO history_data VALUES ('1 not_lsn');
SELECT parse_wal_history(data) FROM history_data;
ERROR: syntax error in history file: 1 not_lsn
HINT: Expected a write-ahead log switchpoint location.
-- Timelines need to be increasing
TRUNCATE history_data;
INSERT INTO history_data VALUES (
'2 0/117BEB70 no recovery target specified
1 0/09D4F390 no recovery target specified
');
SELECT parse_wal_history(data) FROM history_data;
ERROR: invalid data in history file: 1 0/09D4F390 no recovery target specified
HINT: Timeline IDs must be in increasing sequence.
DROP TABLE history_data;
Loading
Loading
@@ -17,4 +17,22 @@ INSERT INTO history_data VALUES (
7 0/249BEB38 no recovery target specified
');
SELECT parse_wal_history(data) FROM history_data;
-- Sanity checks with some failures
-- Timeline number is not an integer.
TRUNCATE history_data;
INSERT INTO history_data VALUES ('not_integer_tli 0/249BEB38 string');
SELECT parse_wal_history(data) FROM history_data;
-- Not three fields
TRUNCATE history_data;
INSERT INTO history_data VALUES ('1 not_lsn');
SELECT parse_wal_history(data) FROM history_data;
-- Timelines need to be increasing
TRUNCATE history_data;
INSERT INTO history_data VALUES (
'2 0/117BEB70 no recovery target specified
1 0/09D4F390 no recovery target specified
');
SELECT parse_wal_history(data) FROM history_data;
DROP TABLE history_data;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment