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

Convert contrib/isn's input functions to report errors softly

This commit is contained in:
Andrew Dunstan
2022-12-24 15:28:13 -05:00
parent e37fe1db6e
commit 720e0327bc
3 changed files with 63 additions and 44 deletions

View File

@ -260,6 +260,21 @@ SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
t | t | t
(1 row)
-- 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
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 |
(3 rows)
--
-- cleanup
--