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

Rework pg_input_error_message(), now renamed pg_input_error_info()

pg_input_error_info() is now a SQL function able to return a row with
more than just the error message generated for incorrect data type
inputs when these are able to handle soft failures, returning more
contents of ErrorData, as of:
- The error message (same as before).
- The error detail, if set.
- The error hint, if set.
- SQL error code.

All the regression tests that relied on pg_input_error_message() are
updated to reflect the effects of the rename.

Per discussion with Tom Lane and Andrew Dunstan.

Author: Nathan Bossart
Discussion: https://postgr.es/m/139a68e1-bd1f-a9a7-b5fe-0be9845c6311@dunslane.net
This commit is contained in:
Michael Paquier
2023-02-28 08:04:13 +09:00
parent 728560db7d
commit b8da37b3ad
117 changed files with 768 additions and 682 deletions

View File

@ -1276,20 +1276,24 @@ FROM test_seg WHERE s @> '11.2..11.3' OR s IS NULL ORDER BY s;
-- 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
errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
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
'1e700']) str,
LATERAL pg_input_error_info(str, 'seg') as errinfo;
seg | ok | sql_error_code | message | detail | hint
----------+----+----------------+---------------------------------------+------------------------------+------
-1 .. 1 | t | | | |
100(+-)1 | t | | | |
| f | 42601 | bad seg representation | syntax error at end of input |
ABC | f | 42601 | bad seg representation | syntax error at or near "A" |
1 e7 | f | 42601 | bad seg representation | syntax error at or near "e" |
1e700 | f | 22003 | "1e700" is out of range for type real | |
(6 rows)