mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +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:
@ -263,16 +263,20 @@ SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
|
||||
-- test non-error-throwing input API
|
||||
SELECT str as isn, typ as "type",
|
||||
pg_input_is_valid(str,typ) as ok,
|
||||
pg_input_error_message(str,typ) as errmsg
|
||||
errinfo.sql_error_code,
|
||||
errinfo.message,
|
||||
errinfo.detail,
|
||||
errinfo.hint
|
||||
FROM (VALUES ('9780123456786', 'UPC'),
|
||||
('postgresql...','EAN13'),
|
||||
('9771234567003','ISSN'))
|
||||
AS a(str,typ);
|
||||
isn | type | ok | errmsg
|
||||
---------------+-------+----+--------------------------------------------------------
|
||||
9780123456786 | UPC | f | cannot cast ISBN to UPC for number: "9780123456786"
|
||||
postgresql... | EAN13 | f | invalid input syntax for EAN13 number: "postgresql..."
|
||||
9771234567003 | ISSN | t |
|
||||
AS a(str,typ),
|
||||
LATERAL pg_input_error_info(a.str, a.typ) as errinfo;
|
||||
isn | type | ok | sql_error_code | message | detail | hint
|
||||
---------------+-------+----+----------------+--------------------------------------------------------+--------+------
|
||||
9780123456786 | UPC | f | 22P02 | cannot cast ISBN to UPC for number: "9780123456786" | |
|
||||
postgresql... | EAN13 | f | 22P02 | invalid input syntax for EAN13 number: "postgresql..." | |
|
||||
9771234567003 | ISSN | t | | | |
|
||||
(3 rows)
|
||||
|
||||
--
|
||||
|
@ -110,11 +110,15 @@ SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
|
||||
-- test non-error-throwing input API
|
||||
SELECT str as isn, typ as "type",
|
||||
pg_input_is_valid(str,typ) as ok,
|
||||
pg_input_error_message(str,typ) as errmsg
|
||||
errinfo.sql_error_code,
|
||||
errinfo.message,
|
||||
errinfo.detail,
|
||||
errinfo.hint
|
||||
FROM (VALUES ('9780123456786', 'UPC'),
|
||||
('postgresql...','EAN13'),
|
||||
('9771234567003','ISSN'))
|
||||
AS a(str,typ);
|
||||
AS a(str,typ),
|
||||
LATERAL pg_input_error_info(a.str, a.typ) as errinfo;
|
||||
|
||||
--
|
||||
-- cleanup
|
||||
|
Reference in New Issue
Block a user