1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Convert contrib/seg's input function to report errors softly

Reviewed by Tom Lane

Discussion: https://postgr.es/m/a8dc5700-c341-3ba8-0507-cc09881e6200@dunslane.net
This commit is contained in:
Andrew Dunstan
2022-12-23 09:17:24 -05:00
parent 7a310338f4
commit 878ce16056
6 changed files with 70 additions and 18 deletions

View File

@ -1273,3 +1273,23 @@ FROM test_seg WHERE s @> '11.2..11.3' OR s IS NULL ORDER BY s;
| |
(144 rows)
-- test non error throwing API
SELECT str as seg,
pg_input_is_valid(str,'seg') as ok,
pg_input_error_message(str,'seg') as errmsg
FROM unnest(ARRAY['-1 .. 1'::text,
'100(+-)1',
'',
'ABC',
'1 e7',
'1e700']) str;
seg | ok | errmsg
----------+----+---------------------------------------
-1 .. 1 | t |
100(+-)1 | t |
| f | bad seg representation
ABC | f | bad seg representation
1 e7 | f | bad seg representation
1e700 | f | "1e700" is out of range for type real
(6 rows)