diff options
author | Robert Haas <rhaas@postgresql.org> | 2020-01-27 11:22:13 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2020-01-27 11:22:13 -0500 |
commit | 73ce2a03f30b52d6bfb26bc28f1e3e1aa1637577 (patch) | |
tree | a6a19f146fb7281f146fec7d413a79032fd1557f /src/include/utils/jsonfuncs.h | |
parent | 1f3a021730be98b880d94cabbe21de7e4d8136f5 (diff) | |
download | postgresql-73ce2a03f30b52d6bfb26bc28f1e3e1aa1637577.tar.gz postgresql-73ce2a03f30b52d6bfb26bc28f1e3e1aa1637577.zip |
Move some code from jsonapi.c to jsonfuncs.c.
Specifically, move those functions that depend on ereport()
from jsonapi.c to jsonfuncs.c, in preparation for allowing
jsonapi.c to be used from frontend code.
A few cases where elog(ERROR, ...) is used for can't-happen
conditions are left alone; we can handle those in some other
way in frontend code.
Reviewed by Mark Dilger and Andrew Dunstan.
Discussion: http://postgr.es/m/CA+TgmoYfOXhd27MUDGioVh6QtpD0C1K-f6ObSA10AWiHBAL5bA@mail.gmail.com
Diffstat (limited to 'src/include/utils/jsonfuncs.h')
-rw-r--r-- | src/include/utils/jsonfuncs.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/include/utils/jsonfuncs.h b/src/include/utils/jsonfuncs.h index 19f087ccae9..b993f38409f 100644 --- a/src/include/utils/jsonfuncs.h +++ b/src/include/utils/jsonfuncs.h @@ -36,6 +36,15 @@ typedef void (*JsonIterateStringValuesAction) (void *state, char *elem_value, in /* an action that will be applied to each value in transform_json(b)_values functions */ typedef text *(*JsonTransformStringValuesAction) (void *state, char *elem_value, int elem_len); +/* build a JsonLexContext from a text datum */ +extern JsonLexContext *makeJsonLexContext(text *json, bool need_escapes); + +/* try to parse json, and ereport(ERROR) on failure */ +extern void pg_parse_json_or_ereport(JsonLexContext *lex, JsonSemAction *sem); + +/* report an error during json lexing or parsing */ +extern void json_ereport_error(JsonParseErrorType error, JsonLexContext *lex); + extern uint32 parse_jsonb_index_flags(Jsonb *jb); extern void iterate_jsonb_values(Jsonb *jb, uint32 flags, void *state, JsonIterateStringValuesAction action); |