]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix error reporting for SQL/JSON path type mismatches
authorAmit Langote <amitlan@postgresql.org>
Thu, 27 Nov 2025 01:40:19 +0000 (10:40 +0900)
committerAmit Langote <amitlan@postgresql.org>
Thu, 27 Nov 2025 02:59:36 +0000 (11:59 +0900)
commitb5511fed500eb526a547f38597307552fa7acd08
tree9e2f7b0ab16eaae0be1cb298a0959eadc5cabd50
parent2fc5c5062207a26b4ea4144a3d70099767eee523
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 <jian.universality@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/CACJufxHunVg81JMuNo8Yvv_hJD0DicgaVN2Wteu8aJbVJPBjZA@mail.gmail.com
Backpatch-through: 17
src/backend/parser/parse_expr.c
src/test/regress/expected/sqljson_queryfuncs.out
src/test/regress/sql/sqljson_queryfuncs.sql