PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "common/jsonapi.h"
#include "mb/pg_wchar.h"
#include "port/pg_lfind.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
Go to the source code of this file.
Data Structures | |
struct | JsonParserStack |
struct | JsonIncrementalState |
struct | td_entry |
#define FAIL_AT_CHAR_END | ( | code | ) |
#define FAIL_OR_INCOMPLETE_AT_CHAR_START | ( | code | ) |
#define FREE | ( | s | ) |
#define JSON_ALPHANUMERIC_CHAR | ( | c | ) |
#define JSON_NT_OFFSET JSON_NT_JSON |
#define JSON_TD_MAX_STACK |
#define json_token_error | ( | lex, | |
format | |||
) |
#define jsonapi_appendBinaryStringInfo appendBinaryStringInfo |
#define jsonapi_appendStringInfo appendStringInfo |
#define jsonapi_appendStringInfoChar appendStringInfoChar |
#define jsonapi_appendStringInfoCharMacro appendStringInfoCharMacro |
#define jsonapi_destroyStringInfo destroyStringInfo |
#define jsonapi_initStringInfo initStringInfo |
#define jsonapi_makeStringInfo makeStringInfo |
#define jsonapi_resetStringInfo resetStringInfo |
#define OFS | ( | NT | ) | (NT) - JSON_NT_OFFSET |
enum JsonNonTerminal |
enum JsonParseContext |
enum JsonParserSem |
|
static |
Definition at line 431 of file jsonapi.c.
References ALLOC, ALLOC0, failed_inc_oom, JsonParserStack::fnames, JsonParserStack::fnull, FREE, JsonLexContext::inc_state, JsonLexContext::incremental, JS_MAX_PROD_LEN, JS_STACK_CHUNK_SIZE, jsonapi_initStringInfo, JsonIncrementalState::partial_token, JsonParserStack::pred_index, JsonParserStack::prediction, JsonLexContext::pstack, and JsonParserStack::stack_size.
Referenced by makeJsonLexContextIncremental(), and pg_parse_json().
|
inlinestatic |
Definition at line 575 of file jsonapi.c.
References JsonLexContext::lex_level.
Referenced by pg_parse_json_incremental().
void freeJsonLexContext | ( | JsonLexContext * | lex | ) |
Definition at line 639 of file jsonapi.c.
References JsonLexContext::errormsg, failed_oom, JsonLexContext::flags, JsonParserStack::fnames, JsonParserStack::fnull, FREE, JsonLexContext::inc_state, JsonLexContext::incremental, jsonapi_destroyStringInfo, jsonapi_termStringInfo, JSONLEX_FREE_STRUCT, JSONLEX_FREE_STRVAL, JsonIncrementalState::partial_token, JsonParserStack::prediction, JsonLexContext::pstack, and JsonLexContext::strval.
Referenced by datum_to_jsonb_internal(), each_worker(), elements_worker(), get_json_object_as_hash(), get_worker(), iterate_json_values(), json_object_keys(), json_parse_manifest(), json_parse_manifest_incremental_shutdown(), json_validate(), main(), populate_array_json(), populate_recordset_worker(), and transform_json_string_values().
|
inlinestatic |
Definition at line 614 of file jsonapi.c.
References JsonParserStack::fnames, JsonLexContext::lex_level, and JsonLexContext::pstack.
Referenced by pg_parse_json_incremental().
|
inlinestatic |
Definition at line 626 of file jsonapi.c.
References JsonParserStack::fnull, JsonLexContext::lex_level, and JsonLexContext::pstack.
Referenced by pg_parse_json_incremental().
|
inlinestatic |
Definition at line 602 of file jsonapi.c.
References JsonParserStack::pred_index.
Referenced by pg_parse_json_incremental().
|
inlinestatic |
Definition at line 533 of file jsonapi.c.
References JsonParserStack::fnames, JsonParserStack::fnull, JsonLexContext::incremental, JS_MAX_PROD_LEN, JS_STACK_CHUNK_SIZE, JsonLexContext::lex_level, JsonParserStack::prediction, JsonLexContext::pstack, REALLOC, and JsonParserStack::stack_size.
Referenced by pg_parse_json_incremental().
bool IsValidJsonNumber | ( | const char * | str, |
size_t | len | ||
) |
Definition at line 337 of file jsonapi.c.
References JsonLexContext::input, JsonLexContext::input_length, json_lex_number(), len, str, and JsonLexContext::token_start.
Referenced by hstore_to_json_loose(), and hstore_to_jsonb_loose().
JsonParseErrorType json_count_array_elements | ( | JsonLexContext * | lex, |
int * | elements | ||
) |
Definition at line 744 of file jsonapi.c.
References failed_oom, json_lex(), JSON_OUT_OF_MEMORY, JSON_PARSE_ARRAY_NEXT, JSON_PARSE_ARRAY_START, JSON_SUCCESS, JSON_TOKEN_ARRAY_END, JSON_TOKEN_ARRAY_START, JSON_TOKEN_COMMA, lex_expect(), JsonLexContext::lex_level, lex_peek(), JsonLexContext::need_escapes, nullSemAction, parse_array_element(), and JsonLexContext::token_type.
Referenced by get_array_start().
char* json_errdetail | ( | JsonParseErrorType | error, |
JsonLexContext * | lex | ||
) |
Definition at line 2311 of file jsonapi.c.
References _, Assert, error(), JsonLexContext::errormsg, failed_oom, GetDatabaseEncodingName(), JsonLexContext::incremental, JSON_ESCAPING_INVALID, JSON_ESCAPING_REQUIRED, JSON_EXPECTED_ARRAY_FIRST, JSON_EXPECTED_ARRAY_NEXT, JSON_EXPECTED_COLON, JSON_EXPECTED_END, JSON_EXPECTED_JSON, JSON_EXPECTED_MORE, JSON_EXPECTED_OBJECT_FIRST, JSON_EXPECTED_OBJECT_NEXT, JSON_EXPECTED_STRING, JSON_INCOMPLETE, JSON_INVALID_LEXER_TYPE, JSON_INVALID_TOKEN, JSON_NESTING_TOO_DEEP, JSON_OUT_OF_MEMORY, JSON_SEM_ACTION_FAILED, JSON_SUCCESS, json_token_error, JSON_UNICODE_CODE_POINT_ZERO, JSON_UNICODE_ESCAPE_FORMAT, JSON_UNICODE_HIGH_ESCAPE, JSON_UNICODE_HIGH_SURROGATE, JSON_UNICODE_LOW_SURROGATE, JSON_UNICODE_UNTRANSLATABLE, jsonapi_appendStringInfo, jsonapi_makeStringInfo, jsonapi_resetStringInfo, PQExpBufferBroken, psprintf(), and JsonLexContext::token_terminator.
Referenced by json_errsave_error(), json_parse_manifest(), json_parse_manifest_incremental_chunk(), and main().
JsonParseErrorType json_lex | ( | JsonLexContext * | lex | ) |
Definition at line 1498 of file jsonapi.c.
References Assert, failed_inc_oom, failed_oom, i, JsonLexContext::inc_state, JsonLexContext::incremental, JsonLexContext::input, JsonLexContext::input_encoding, JsonLexContext::input_length, JsonIncrementalState::is_last_chunk, JSON_ALPHANUMERIC_CHAR, JSON_INCOMPLETE, JSON_INVALID_TOKEN, json_lex_number(), json_lex_string(), JSON_OUT_OF_MEMORY, JSON_SUCCESS, JSON_TOKEN_ARRAY_END, JSON_TOKEN_ARRAY_START, JSON_TOKEN_COLON, JSON_TOKEN_COMMA, JSON_TOKEN_END, JSON_TOKEN_FALSE, JSON_TOKEN_NULL, JSON_TOKEN_NUMBER, JSON_TOKEN_OBJECT_END, JSON_TOKEN_OBJECT_START, JSON_TOKEN_STRING, JSON_TOKEN_TRUE, jsonapi_appendBinaryStringInfo, jsonapi_appendStringInfoCharMacro, jsonapi_resetStringInfo, jsonapi_StrValType, JsonLexContext::line_number, JsonLexContext::line_start, JsonLexContext::need_escapes, JsonIncrementalState::partial_completed, JsonIncrementalState::partial_token, PQExpBufferDataBroken, JsonLexContext::prev_token_terminator, JsonLexContext::strval, JsonLexContext::token_start, JsonLexContext::token_terminator, and JsonLexContext::token_type.
Referenced by json_count_array_elements(), json_get_first_token(), json_typeof(), lex_expect(), parse_array(), parse_object(), parse_object_field(), parse_scalar(), pg_parse_json(), and pg_parse_json_incremental().
|
inlinestatic |
Definition at line 2157 of file jsonapi.c.
References error(), JsonLexContext::inc_state, JsonLexContext::incremental, JsonLexContext::input, JsonLexContext::input_length, JsonIncrementalState::is_last_chunk, JSON_ALPHANUMERIC_CHAR, JSON_INCOMPLETE, JSON_INVALID_TOKEN, JSON_SUCCESS, jsonapi_appendBinaryStringInfo, len, JsonIncrementalState::partial_token, JsonLexContext::prev_token_terminator, JsonLexContext::token_start, and JsonLexContext::token_terminator.
Referenced by IsValidJsonNumber(), and json_lex().
|
inlinestatic |
Definition at line 1873 of file jsonapi.c.
References appendStringInfoString(), Assert, FAIL_AT_CHAR_END, FAIL_OR_INCOMPLETE_AT_CHAR_START, i, JsonLexContext::input, JsonLexContext::input_encoding, JsonLexContext::input_length, is_utf16_surrogate_first(), is_utf16_surrogate_second(), JSON_ESCAPING_INVALID, JSON_ESCAPING_REQUIRED, JSON_INVALID_TOKEN, JSON_OUT_OF_MEMORY, JSON_SUCCESS, JSON_UNICODE_CODE_POINT_ZERO, JSON_UNICODE_ESCAPE_FORMAT, JSON_UNICODE_HIGH_ESCAPE, JSON_UNICODE_HIGH_SURROGATE, JSON_UNICODE_LOW_SURROGATE, JSON_UNICODE_UNTRANSLATABLE, jsonapi_appendBinaryStringInfo, jsonapi_appendStringInfoChar, jsonapi_resetStringInfo, MAX_UNICODE_EQUIVALENT_STRING, JsonLexContext::need_escapes, pg_lfind8(), pg_lfind8_le(), pg_unicode_to_server_noerror(), PG_UTF8, pg_utf_mblen, PQExpBufferBroken, JsonLexContext::prev_token_terminator, JsonLexContext::strval, surrogate_pair_to_codepoint(), JsonLexContext::token_start, JsonLexContext::token_terminator, and unicode_to_utf8().
Referenced by json_lex().
|
inlinestatic |
Definition at line 315 of file jsonapi.c.
References json_lex(), lex_peek(), report_parse_error(), and token.
Referenced by json_count_array_elements(), parse_array(), parse_object(), parse_object_field(), and pg_parse_json().
|
inlinestatic |
Definition at line 303 of file jsonapi.c.
References JsonLexContext::token_type.
Referenced by json_count_array_elements(), lex_expect(), parse_array(), parse_array_element(), parse_object(), parse_object_field(), parse_scalar(), pg_parse_json(), and pg_parse_json_incremental().
JsonLexContext* makeJsonLexContextCstringLen | ( | JsonLexContext * | lex, |
const char * | json, | ||
size_t | len, | ||
int | encoding, | ||
bool | need_escapes | ||
) |
Definition at line 390 of file jsonapi.c.
References ALLOC0, encoding, JsonLexContext::errormsg, failed_oom, JsonLexContext::flags, JsonLexContext::input, JsonLexContext::input_encoding, JsonLexContext::input_length, jsonapi_makeStringInfo, JSONLEX_FREE_STRUCT, JSONLEX_FREE_STRVAL, len, JsonLexContext::line_number, JsonLexContext::line_start, JsonLexContext::need_escapes, JsonLexContext::strval, and JsonLexContext::token_terminator.
Referenced by get_json_object_as_hash(), json_parse_manifest(), json_recv(), jsonb_from_cstring(), main(), makeJsonLexContext(), and populate_array_json().
JsonLexContext* makeJsonLexContextIncremental | ( | JsonLexContext * | lex, |
int | encoding, | ||
bool | need_escapes | ||
) |
Definition at line 488 of file jsonapi.c.
References ALLOC0, allocate_incremental_state(), encoding, failed_oom, JsonLexContext::flags, FREE, JsonLexContext::input_encoding, jsonapi_makeStringInfo, JSONLEX_FREE_STRUCT, JSONLEX_FREE_STRVAL, JsonLexContext::line_number, JsonLexContext::need_escapes, and JsonLexContext::strval.
Referenced by json_parse_manifest_incremental_init(), and main().
|
inlinestatic |
Definition at line 595 of file jsonapi.c.
References Assert, JsonParserStack::pred_index, and JsonParserStack::prediction.
Referenced by pg_parse_json_incremental().
|
static |
Definition at line 1421 of file jsonapi.c.
References JsonSemAction::array_end, JsonSemAction::array_start, check_stack_depth(), json_lex(), JSON_PARSE_ARRAY_NEXT, JSON_PARSE_ARRAY_START, JSON_SUCCESS, JSON_TOKEN_ARRAY_END, JSON_TOKEN_ARRAY_START, JSON_TOKEN_COMMA, lex_expect(), JsonLexContext::lex_level, lex_peek(), parse_array_element(), sem, and JsonSemAction::semstate.
Referenced by parse_array_element(), parse_object_field(), and pg_parse_json().
|
static |
Definition at line 1377 of file jsonapi.c.
References JsonSemAction::array_element_end, JsonSemAction::array_element_start, JSON_SUCCESS, JSON_TOKEN_ARRAY_START, JSON_TOKEN_NULL, JSON_TOKEN_OBJECT_START, lex_peek(), parse_array(), parse_object(), parse_scalar(), sem, and JsonSemAction::semstate.
Referenced by json_count_array_elements(), and parse_array().
|
static |
Definition at line 1298 of file jsonapi.c.
References Assert, check_stack_depth(), json_lex(), JSON_PARSE_OBJECT_NEXT, JSON_PARSE_OBJECT_START, JSON_SUCCESS, JSON_TOKEN_COMMA, JSON_TOKEN_OBJECT_END, JSON_TOKEN_OBJECT_START, JSON_TOKEN_STRING, lex_expect(), JsonLexContext::lex_level, lex_peek(), JsonSemAction::object_end, JsonSemAction::object_start, parse_object_field(), report_parse_error(), sem, and JsonSemAction::semstate.
Referenced by parse_array_element(), parse_object_field(), and pg_parse_json().
|
static |
Definition at line 1232 of file jsonapi.c.
References json_lex(), JSON_OUT_OF_MEMORY, JSON_PARSE_OBJECT_LABEL, JSON_PARSE_STRING, JSON_SUCCESS, JSON_TOKEN_ARRAY_START, JSON_TOKEN_COLON, JSON_TOKEN_NULL, JSON_TOKEN_OBJECT_START, JSON_TOKEN_STRING, lex_expect(), lex_peek(), JsonLexContext::need_escapes, JsonSemAction::object_field_end, JsonSemAction::object_field_start, parse_array(), parse_object(), parse_scalar(), report_parse_error(), sem, JsonSemAction::semstate, STRDUP, and JsonLexContext::strval.
Referenced by parse_object().
|
inlinestatic |
Definition at line 1181 of file jsonapi.c.
References ALLOC, json_lex(), JSON_OUT_OF_MEMORY, JSON_PARSE_VALUE, JSON_SUCCESS, JSON_TOKEN_FALSE, JSON_TOKEN_NULL, JSON_TOKEN_NUMBER, JSON_TOKEN_STRING, JSON_TOKEN_TRUE, len, lex_peek(), JsonLexContext::need_escapes, report_parse_error(), JsonSemAction::scalar, sem, JsonSemAction::semstate, STRDUP, JsonLexContext::strval, JsonLexContext::token_start, JsonLexContext::token_terminator, and val.
Referenced by parse_array_element(), parse_object_field(), and pg_parse_json().
JsonParseErrorType pg_parse_json | ( | JsonLexContext * | lex, |
const JsonSemAction * | sem | ||
) |
Definition at line 685 of file jsonapi.c.
References allocate_incremental_state(), failed_oom, JsonLexContext::incremental, JsonLexContext::input, JsonLexContext::input_length, JSON_INVALID_LEXER_TYPE, json_lex(), JSON_OUT_OF_MEMORY, JSON_PARSE_END, JSON_SUCCESS, JSON_TOKEN_ARRAY_START, JSON_TOKEN_END, JSON_TOKEN_OBJECT_START, lex_expect(), lex_peek(), parse_array(), parse_object(), parse_scalar(), pg_parse_json_incremental(), and sem.
Referenced by json_parse_manifest(), json_validate(), main(), and pg_parse_json_or_errsave().
JsonParseErrorType pg_parse_json_incremental | ( | JsonLexContext * | lex, |
const JsonSemAction * | sem, | ||
const char * | json, | ||
size_t | len, | ||
bool | is_last | ||
) |
Definition at line 809 of file jsonapi.c.
References ALLOC, JsonSemAction::array_element_end, JsonSemAction::array_element_start, JsonSemAction::array_end, JsonSemAction::array_start, Assert, dec_lex_level(), failed_inc_oom, failed_oom, get_fname(), get_fnull(), have_prediction(), inc_lex_level(), JsonLexContext::inc_state, JsonLexContext::incremental, JsonLexContext::input, JsonLexContext::input_length, JsonIncrementalState::is_last_chunk, IS_NT, IS_SEM, JSON_INVALID_LEXER_TYPE, json_lex(), JSON_NESTING_TOO_DEEP, JSON_NT_ARRAY_ELEMENTS, JSON_NT_KEY_PAIRS, JSON_NT_MORE_ARRAY_ELEMENTS, JSON_NT_MORE_KEY_PAIRS, JSON_OUT_OF_MEMORY, JSON_PARSE_ARRAY_NEXT, JSON_PARSE_ARRAY_START, JSON_PARSE_END, JSON_PARSE_OBJECT_LABEL, JSON_PARSE_OBJECT_NEXT, JSON_PARSE_OBJECT_START, JSON_PARSE_STRING, JSON_PARSE_VALUE, JSON_PROD_GOAL, JSON_SEM_AELEM_END, JSON_SEM_AELEM_START, JSON_SEM_AEND, JSON_SEM_ASTART, JSON_SEM_OEND, JSON_SEM_OFIELD_END, JSON_SEM_OFIELD_INIT, JSON_SEM_OFIELD_START, JSON_SEM_OSTART, JSON_SEM_SCALAR_CALL, JSON_SEM_SCALAR_INIT, JSON_SUCCESS, JSON_TD_MAX_STACK, JSON_TOKEN_ARRAY_END, JSON_TOKEN_ARRAY_START, JSON_TOKEN_COLON, JSON_TOKEN_COMMA, JSON_TOKEN_END, JSON_TOKEN_FALSE, JSON_TOKEN_NULL, JSON_TOKEN_NUMBER, JSON_TOKEN_OBJECT_END, JSON_TOKEN_OBJECT_START, JSON_TOKEN_STRING, JSON_TOKEN_TRUE, len, JsonLexContext::lex_level, lex_peek(), JsonLexContext::line_start, JsonLexContext::need_escapes, next_prediction(), JsonSemAction::object_end, JsonSemAction::object_field_end, JsonSemAction::object_field_start, JsonSemAction::object_start, OFS, pop_prediction(), JsonLexContext::pstack, push_prediction(), report_parse_error(), JsonSemAction::scalar, JsonParserStack::scalar_tok, JsonParserStack::scalar_val, sem, JsonSemAction::semstate, set_fname(), set_fnull(), STRDUP, JsonLexContext::strval, TD_ENTRY, td_parser_table, JsonLexContext::token_start, and JsonLexContext::token_terminator.
Referenced by json_parse_manifest_incremental_chunk(), main(), and pg_parse_json().
|
inlinestatic |
Definition at line 588 of file jsonapi.c.
References Assert, JsonParserStack::pred_index, and JsonParserStack::prediction.
Referenced by pg_parse_json_incremental().
|
inlinestatic |
Definition at line 581 of file jsonapi.c.
References td_entry::len, JsonParserStack::pred_index, JsonParserStack::prediction, and td_entry::prod.
Referenced by pg_parse_json_incremental().
|
static |
Definition at line 2267 of file jsonapi.c.
References Assert, JSON_EXPECTED_ARRAY_FIRST, JSON_EXPECTED_ARRAY_NEXT, JSON_EXPECTED_COLON, JSON_EXPECTED_END, JSON_EXPECTED_JSON, JSON_EXPECTED_MORE, JSON_EXPECTED_OBJECT_FIRST, JSON_EXPECTED_OBJECT_NEXT, JSON_EXPECTED_STRING, JSON_PARSE_ARRAY_NEXT, JSON_PARSE_ARRAY_START, JSON_PARSE_END, JSON_PARSE_OBJECT_COMMA, JSON_PARSE_OBJECT_LABEL, JSON_PARSE_OBJECT_NEXT, JSON_PARSE_OBJECT_START, JSON_PARSE_STRING, JSON_PARSE_VALUE, JSON_SUCCESS, JSON_TOKEN_END, JsonLexContext::token_start, and JsonLexContext::token_type.
Referenced by lex_expect(), parse_object(), parse_object_field(), parse_scalar(), and pg_parse_json_incremental().
|
inlinestatic |
Definition at line 608 of file jsonapi.c.
References JsonParserStack::fnames, JsonLexContext::lex_level, and JsonLexContext::pstack.
Referenced by pg_parse_json_incremental().
|
inlinestatic |
Definition at line 620 of file jsonapi.c.
References JsonParserStack::fnull, JsonLexContext::lex_level, and JsonLexContext::pstack.
Referenced by pg_parse_json_incremental().
|
static |
Definition at line 293 of file jsonapi.c.
Referenced by allocate_incremental_state(), json_lex(), and pg_parse_json_incremental().
|
static |
Definition at line 292 of file jsonapi.c.
Referenced by freeJsonLexContext(), json_count_array_elements(), json_errdetail(), json_lex(), makeJsonLexContextCstringLen(), makeJsonLexContextIncremental(), pg_parse_json(), and pg_parse_json_incremental().
|
static |
|
static |
|
static |
Definition at line 271 of file jsonapi.c.
Referenced by pg_parse_json_incremental().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
const JsonSemAction nullSemAction |
Definition at line 285 of file jsonapi.c.
Referenced by json_count_array_elements(), json_in(), json_recv(), json_validate(), and main().
|
static |
Definition at line 240 of file jsonapi.c.
Referenced by pg_parse_json_incremental().