mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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
This commit is contained in:
@@ -4278,6 +4278,7 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
|
||||
JsonPathVariable *var = palloc(sizeof(*var));
|
||||
|
||||
var->name = argname->sval;
|
||||
var->namelen = strlen(var->name);
|
||||
var->typid = exprType((Node *) argexpr);
|
||||
var->typmod = exprTypmod((Node *) argexpr);
|
||||
|
||||
|
Reference in New Issue
Block a user