mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Fix jsonpath existense checking of missing variables
The current jsonpath code assumes that the referenced variable always exists. It could only throw an error at the value valuation time. At the same time existence checking assumes variable is present without valuation, and error suppression doesn't work for missing variables. This commit makes existense checking trigger an error for missing variables. This makes the overall behavior consistent. Backpatch to 12 where jsonpath was introduced. Reported-by: David G. Johnston Discussion: https://postgr.es/m/CAKFQuwbeytffJkVnEqDyLZ%3DrQsznoTh1OgDoOF3VmOMkxcTMjA%40mail.gmail.com Author: Alexander Korotkov, David G. Johnston Backpatch-through: 12
This commit is contained in:
@ -959,9 +959,13 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
|
||||
JsonbValue *v;
|
||||
bool hasNext = jspGetNext(jsp, &elem);
|
||||
|
||||
if (!hasNext && !found)
|
||||
if (!hasNext && !found && jsp->type != jpiVariable)
|
||||
{
|
||||
res = jperOk; /* skip evaluation */
|
||||
/*
|
||||
* Skip evaluation, but not for variables. We must
|
||||
* trigger an error for the missing variable.
|
||||
*/
|
||||
res = jperOk;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user