Fix error reporting for SQL/JSON path type mismatches transformJsonFuncExpr() used exprType()/exprLocation() on the possibly coerced path expression, which could be NULL when coercion to jsonpath failed, leading to "cache lookup failed for type 0" errors.
Preserve the original expression node so that type and location in the "must be of type jsonpath" error are reported correctly. Add regression tests to cover these cases. Reported-by: Jian He <[email protected]> Author: Jian He <[email protected]> Reviewed-by: Kirill Reshke <[email protected]> Discussion: https://postgr.es/m/cacjufxhunvg81jmuno8yvv_hjd0dicgavn2wteu8ajbvjpb...@mail.gmail.com Backpatch-through: 17 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/15ba0702c1ae9d46f49a6e1f80db99167d3aedf7 Modified Files -------------- src/backend/parser/parse_expr.c | 23 +++++++++++++++-------- src/test/regress/expected/sqljson_queryfuncs.out | 8 ++++++++ src/test/regress/sql/sqljson_queryfuncs.sql | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-)
