diff options
| author | Michael Paquier | 2023-02-27 23:04:13 +0000 |
|---|---|---|
| committer | Michael Paquier | 2023-02-27 23:04:13 +0000 |
| commit | b8da37b3ada2e547983538b3e49f8079f85ce120 (patch) | |
| tree | d3ecf7af84a5b492e7a2b62b79df0398f3c8bccd /contrib/ltree | |
| parent | 728560db7d868b3ded9a8675742083ab89bcff7c (diff) | |
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
Diffstat (limited to 'contrib/ltree')
| -rw-r--r-- | contrib/ltree/expected/ltree.out | 28 | ||||
| -rw-r--r-- | contrib/ltree/sql/ltree.sql | 8 |
2 files changed, 22 insertions, 14 deletions
diff --git a/contrib/ltree/expected/ltree.out b/contrib/ltree/expected/ltree.out index d2a53b9f0c..27122153c7 100644 --- a/contrib/ltree/expected/ltree.out +++ b/contrib/ltree/expected/ltree.out @@ -8101,7 +8101,10 @@ SELECT count(*) FROM _ltreetest WHERE t ? '{23.*.1,23.*.2}' ; -- test non-error-throwing input SELECT str as "value", 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 ('.2.3', 'ltree'), ('1.2.', 'ltree'), ('1.2.3','ltree'), @@ -8110,16 +8113,17 @@ FROM (VALUES ('.2.3', 'ltree'), ('1.2.3','lquery'), ('$tree & aWdf@*','ltxtquery'), ('!tree & aWdf@*','ltxtquery')) - AS a(str,typ); - value | type | ok | errmsg -----------------+-----------+----+------------------------------------ - .2.3 | ltree | f | ltree syntax error at character 1 - 1.2. | ltree | f | ltree syntax error - 1.2.3 | ltree | t | - @.2.3 | lquery | f | lquery syntax error at character 1 - 2.3 | lquery | f | lquery syntax error at character 1 - 1.2.3 | lquery | t | - $tree & aWdf@* | ltxtquery | f | operand syntax error - !tree & aWdf@* | ltxtquery | t | + AS a(str,typ), + LATERAL pg_input_error_info(a.str, a.typ) as errinfo; + value | type | ok | sql_error_code | message | detail | hint +----------------+-----------+----+----------------+------------------------------------+--------------------------+------ + .2.3 | ltree | f | 42601 | ltree syntax error at character 1 | | + 1.2. | ltree | f | 42601 | ltree syntax error | Unexpected end of input. | + 1.2.3 | ltree | t | | | | + @.2.3 | lquery | f | 42601 | lquery syntax error at character 1 | | + 2.3 | lquery | f | 42601 | lquery syntax error at character 1 | | + 1.2.3 | lquery | t | | | | + $tree & aWdf@* | ltxtquery | f | 42601 | operand syntax error | | + !tree & aWdf@* | ltxtquery | t | | | | (8 rows) diff --git a/contrib/ltree/sql/ltree.sql b/contrib/ltree/sql/ltree.sql index 4a6e6266c3..4623b57f7b 100644 --- a/contrib/ltree/sql/ltree.sql +++ b/contrib/ltree/sql/ltree.sql @@ -393,7 +393,10 @@ SELECT count(*) FROM _ltreetest WHERE t ? '{23.*.1,23.*.2}' ; SELECT str as "value", 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 ('.2.3', 'ltree'), ('1.2.', 'ltree'), ('1.2.3','ltree'), @@ -402,4 +405,5 @@ FROM (VALUES ('.2.3', 'ltree'), ('1.2.3','lquery'), ('$tree & aWdf@*','ltxtquery'), ('!tree & aWdf@*','ltxtquery')) - AS a(str,typ); + AS a(str,typ), + LATERAL pg_input_error_info(a.str, a.typ) as errinfo; |
