diff options
author | Amit Langote <amitlan@postgresql.org> | 2024-07-26 15:59:27 +0900 |
---|---|---|
committer | Amit Langote <amitlan@postgresql.org> | 2024-07-26 16:00:06 +0900 |
commit | 63e6c5f4a2eeb22e0dd446a62c2b4b417d2b51f0 (patch) | |
tree | 3ce786dcf32d88140630721cf051c32dd61033fa /src/test | |
parent | c7301c3b6fe2feaf96d52cbf35a85ac6b95374dc (diff) | |
download | postgresql-63e6c5f4a2eeb22e0dd446a62c2b4b417d2b51f0.tar.gz postgresql-63e6c5f4a2eeb22e0dd446a62c2b4b417d2b51f0.zip |
SQL/JSON: Fix error-handling of some JsonBehavior expressions
To ensure that the errors of executing a JsonBehavior expression that
is coerced in the parser are caught instead of being thrown directly,
pass ErrorSaveContext to ExecInitExprRec() when initializing it.
Also, add a EEOP_JSONEXPR_COERCION_FINISH step to handle the errors
that are caught that way.
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/sqljson_jsontable.out | 6 | ||||
-rw-r--r-- | src/test/regress/expected/sqljson_queryfuncs.out | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/test/regress/expected/sqljson_jsontable.out b/src/test/regress/expected/sqljson_jsontable.out index 5fd43be3677..19817b4be8c 100644 --- a/src/test/regress/expected/sqljson_jsontable.out +++ b/src/test/regress/expected/sqljson_jsontable.out @@ -227,7 +227,11 @@ SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo'::jsonb_test_domain ON EMPTY)); -ERROR: value for domain jsonb_test_domain violates check constraint "jsonb_test_domain_check" + js1 +----- + +(1 row) + SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo1'::jsonb_test_domain ON EMPTY)); js1 diff --git a/src/test/regress/expected/sqljson_queryfuncs.out b/src/test/regress/expected/sqljson_queryfuncs.out index 074aedb2dd1..ec8caee91c7 100644 --- a/src/test/regress/expected/sqljson_queryfuncs.out +++ b/src/test/regress/expected/sqljson_queryfuncs.out @@ -1232,7 +1232,11 @@ DROP TABLE test_jsonb_mutability; DROP FUNCTION ret_setint; CREATE DOMAIN queryfuncs_test_domain AS text CHECK (value <> 'foo'); SELECT JSON_VALUE(jsonb '{"d1": "H"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT 'foo'::queryfuncs_test_domain ON EMPTY); -ERROR: value for domain queryfuncs_test_domain violates check constraint "queryfuncs_test_domain_check" + json_value +------------ + +(1 row) + SELECT JSON_VALUE(jsonb '{"d1": "H"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT 'foo1'::queryfuncs_test_domain ON EMPTY); json_value ------------ |