Skip to content

Commit f152ff9

Browse files
committed
It's not OK for jsonpath_in() to PG_RETURN_NULL() on non-null (but invalid) input like " ".
1 parent 48e11b6 commit f152ff9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/backend/utils/adt/jsonpath.c

+12-10
Original file line numberDiff line numberDiff line change
@@ -310,20 +310,22 @@ jsonpath_in(PG_FUNCTION_ARGS)
310310

311311
appendStringInfoSpaces(&buf, JSONPATH_HDRSZ);
312312

313-
if (jsonpath != NULL)
313+
if (jsonpath == NULL)
314314
{
315-
flattenJsonPathParseItem(&buf, jsonpath->expr, false, false);
315+
ereport(ERROR,
316+
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
317+
errmsg("invalid input syntax for jsonpath: \"%s\"", in)));
318+
}
316319

317-
res = (JsonPath*)buf.data;
318-
SET_VARSIZE(res, buf.len);
319-
res->header = JSONPATH_VERSION;
320-
if (jsonpath->lax)
321-
res->header |= JSONPATH_LAX;
320+
flattenJsonPathParseItem(&buf, jsonpath->expr, false, false);
322321

323-
PG_RETURN_JSONPATH(res);
324-
}
322+
res = (JsonPath*)buf.data;
323+
SET_VARSIZE(res, buf.len);
324+
res->header = JSONPATH_VERSION;
325+
if (jsonpath->lax)
326+
res->header |= JSONPATH_LAX;
325327

326-
PG_RETURN_NULL();
328+
PG_RETURN_JSONPATH(res);
327329
}
328330

329331
static void

0 commit comments

Comments
 (0)