SQL/JSON: Correct jsonpath variable name matching
Amit Langote <amitlan@postgresql.org>
SQL/JSON: Correct jsonpath variable name matching Previously, GetJsonPathVar() allowed a jsonpath expression to reference any prefix of a PASSING variable's name. For example, the following query would incorrectly work: SELECT JSON_QUERY(context_item, jsonpath '$xy' PASSING val AS xyz); The fix ensures that the length of the variable name mentioned in a jsonpath expression matches exactly with the name of the PASSING variable before comparing the strings using strncmp(). Reported-by: Alvaro Herrera (off-list) Discussion: https://postgr.es/m/CA+HiwqFGkLWMvELBH6E4SQ45qUHthgcRH6gCJL20OsYDRtFx_w@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/executor/execExpr.c | modified | +1 −0 |
| src/backend/utils/adt/jsonpath_exec.c | modified | +3 −1 |
| src/include/utils/jsonpath.h | modified | +1 −0 |
| src/test/regress/expected/sqljson_queryfuncs.out | modified | +11 −0 |
| src/test/regress/sql/sqljson_queryfuncs.sql | modified | +5 −0 |
Discussion
- Incorrect matching of sql/json PASSING variable names 3 messages · 2024-06-06 → 2024-06-19