static inline Datum
get_path_all(FunctionCallInfo fcinfo, bool as_text)
{
- Oid val_type = get_fn_expr_argtype(fcinfo->flinfo, 0);
text *json;
ArrayType *path = PG_GETARG_ARRAYTYPE_P(1);
text *result;
long ind;
char *endptr;
- Assert(val_type == JSONOID || val_type == JSONBOID);
- if (val_type == JSONOID)
- {
- /* just get the text */
- json = PG_GETARG_TEXT_P(0);
- }
- else
- {
- Jsonb *jb = PG_GETARG_JSONB(0);
-
- json = cstring_to_text(JsonbToCString(NULL, VARDATA(jb), VARSIZE(jb)));
- }
+ json = PG_GETARG_TEXT_P(0);
if (array_contains_nulls(path))
ereport(ERROR,
result = get_worker(json, NULL, -1, tpath, ipath, npath, as_text);
if (result != NULL)
- {
- if (val_type == JSONOID || as_text)
PG_RETURN_TEXT_P(result);
- else
- PG_RETURN_JSONB(DirectFunctionCall1(jsonb_in, CStringGetDatum(text_to_cstring(result))));
- }
else
- {
/* null is NULL, regardless */
PG_RETURN_NULL();
- }
}
/*