Adjust pg_parse_json() so that it does not directly ereport().
Robert Haas <rhaas@postgresql.org>
Adjust pg_parse_json() so that it does not directly ereport(). Instead, it now returns a value indicating either success or the type of error which occurred. The old behavior is still available by calling pg_parse_json_or_ereport(). If the new interface is used, an error can be thrown by passing the return value of pg_parse_json() to json_ereport_error(). pg_parse_json() can still elog() in can't-happen cases, but it seems like that issue is best handled separately. Adjust json_lex() and json_count_array_elements() to return an error code, too. This is all in preparation for making the backend's json parser available to frontend code. Reviewed and/or tested by Mark Dilger and Andrew Dunstan. Discussion: http://postgr.es/m/CA+TgmoYfOXhd27MUDGioVh6QtpD0C1K-f6ObSA10AWiHBAL5bA@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/jsonapi.c | modified | +274 −263 |
| src/backend/utils/adt/jsonb.c | modified | +2 −2 |
| src/backend/utils/adt/json.c | modified | +6 −3 |
| src/backend/utils/adt/jsonfuncs.c | modified | +17 −12 |
| src/include/utils/jsonapi.h | modified | +43 −3 |
Discussion
- making the backend's json parser work in frontend code 101 messages · 2020-01-15 → 2020-01-30