PostgreSQL Source Code
git master
|
Go to the source code of this file.
Data Structures | |
struct | JsonLexContext |
struct | JsonSemAction |
Macros | |
#define | jsonapi_StrValType StringInfoData |
#define | JSONLEX_FREE_STRUCT (1 << 0) |
#define | JSONLEX_FREE_STRVAL (1 << 1) |
#define | JSONLEX_CTX_OWNS_TOKENS (1 << 2) |
Typedefs | |
typedef enum JsonTokenType | JsonTokenType |
typedef enum JsonParseErrorType | JsonParseErrorType |
typedef struct JsonParserStack | JsonParserStack |
typedef struct JsonIncrementalState | JsonIncrementalState |
typedef struct JsonLexContext | JsonLexContext |
typedef JsonParseErrorType(* | json_struct_action) (void *state) |
typedef JsonParseErrorType(* | json_ofield_action) (void *state, char *fname, bool isnull) |
typedef JsonParseErrorType(* | json_aelem_action) (void *state, bool isnull) |
typedef JsonParseErrorType(* | json_scalar_action) (void *state, char *token, JsonTokenType tokentype) |
typedef struct JsonSemAction | JsonSemAction |
Functions | |
JsonParseErrorType | pg_parse_json (JsonLexContext *lex, const JsonSemAction *sem) |
JsonParseErrorType | pg_parse_json_incremental (JsonLexContext *lex, const JsonSemAction *sem, const char *json, size_t len, bool is_last) |
JsonParseErrorType | json_count_array_elements (JsonLexContext *lex, int *elements) |
JsonLexContext * | makeJsonLexContextCstringLen (JsonLexContext *lex, const char *json, size_t len, int encoding, bool need_escapes) |
JsonLexContext * | makeJsonLexContextIncremental (JsonLexContext *lex, int encoding, bool need_escapes) |
void | setJsonLexContextOwnsTokens (JsonLexContext *lex, bool owned_by_context) |
void | freeJsonLexContext (JsonLexContext *lex) |
JsonParseErrorType | json_lex (JsonLexContext *lex) |
char * | json_errdetail (JsonParseErrorType error, JsonLexContext *lex) |
bool | IsValidJsonNumber (const char *str, size_t len) |
Variables | |
PGDLLIMPORT const JsonSemAction | nullSemAction |
#define jsonapi_StrValType StringInfoData |
typedef JsonParseErrorType(* json_aelem_action) (void *state, bool isnull) |
typedef JsonParseErrorType(* json_ofield_action) (void *state, char *fname, bool isnull) |
typedef JsonParseErrorType(* json_scalar_action) (void *state, char *token, JsonTokenType tokentype) |
typedef JsonParseErrorType(* json_struct_action) (void *state) |
typedef struct JsonIncrementalState JsonIncrementalState |
typedef struct JsonLexContext JsonLexContext |
typedef enum JsonParseErrorType JsonParseErrorType |
typedef struct JsonParserStack JsonParserStack |
typedef struct JsonSemAction JsonSemAction |
typedef enum JsonTokenType JsonTokenType |
enum JsonParseErrorType |
Definition at line 34 of file jsonapi.h.
enum JsonTokenType |
void freeJsonLexContext | ( | JsonLexContext * | lex | ) |
Definition at line 687 of file jsonapi.c.
References JsonLexContext::errormsg, failed_oom, JsonLexContext::flags, JsonParserStack::fnames, JsonParserStack::fnull, FREE, i, JsonLexContext::inc_state, JsonLexContext::incremental, jsonapi_destroyStringInfo, jsonapi_termStringInfo, JSONLEX_CTX_OWNS_TOKENS, JSONLEX_FREE_STRUCT, JSONLEX_FREE_STRVAL, JsonLexContext::lex_level, JsonIncrementalState::partial_token, JsonParserStack::prediction, JsonLexContext::pstack, JsonParserStack::scalar_val, 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().
bool IsValidJsonNumber | ( | const char * | str, |
size_t | len | ||
) |
Definition at line 339 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 803 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 2397 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 1584 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().
JsonLexContext* makeJsonLexContextCstringLen | ( | JsonLexContext * | lex, |
const char * | json, | ||
size_t | len, | ||
int | encoding, | ||
bool | need_escapes | ||
) |
Definition at line 392 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 497 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().
JsonParseErrorType pg_parse_json | ( | JsonLexContext * | lex, |
const JsonSemAction * | sem | ||
) |
Definition at line 744 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 868 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, JsonLexContext::flags, FREE, 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, JSONLEX_CTX_OWNS_TOKENS, 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(), JsonIncrementalState::started, 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().
void setJsonLexContextOwnsTokens | ( | JsonLexContext * | lex, |
bool | owned_by_context | ||
) |
Definition at line 542 of file jsonapi.c.
References Assert, JsonLexContext::flags, JsonLexContext::inc_state, JsonLexContext::incremental, JSONLEX_CTX_OWNS_TOKENS, and JsonIncrementalState::started.
Referenced by main().
|
extern |
Definition at line 287 of file jsonapi.c.
Referenced by json_count_array_elements(), json_in(), json_recv(), json_validate(), and main().