PostgreSQL Source Code
git master
|
#include "lib/stringinfo.h"
Go to the source code of this file.
Data Structures | |
struct | JsonLexContext |
struct | JsonSemAction |
Macros | |
#define | JSONLEX_FREE_STRUCT (1 << 0) |
#define | JSONLEX_FREE_STRVAL (1 << 1) |
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 | 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 |
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 36 of file jsonapi.h.
enum JsonTokenType |
void freeJsonLexContext | ( | JsonLexContext * | lex | ) |
Definition at line 482 of file jsonapi.c.
References StringInfoData::data, destroyStringInfo(), JsonLexContext::errormsg, JsonLexContext::flags, JsonParserStack::fnames, JsonParserStack::fnull, JsonLexContext::inc_state, JsonLexContext::incremental, JSONLEX_FREE_STRUCT, JSONLEX_FREE_STRVAL, JsonIncrementalState::partial_token, pfree(), 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().
bool IsValidJsonNumber | ( | const char * | str, |
size_t | len | ||
) |
Definition at line 272 of file jsonapi.c.
References JsonLexContext::inc_state, JsonLexContext::incremental, JsonLexContext::input, JsonLexContext::input_length, json_lex_number(), len, JsonLexContext::pstack, 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 587 of file jsonapi.c.
References 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(), nullSemAction, parse_array_element(), JsonLexContext::strval, and JsonLexContext::token_type.
Referenced by get_array_start().
char* json_errdetail | ( | JsonParseErrorType | error, |
JsonLexContext * | lex | ||
) |
Definition at line 2096 of file jsonapi.c.
References _, appendStringInfo(), Assert, StringInfoData::data, error(), JsonLexContext::errormsg, 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_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, StringInfoData::len, makeStringInfo(), psprintf(), resetStringInfo(), 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 1308 of file jsonapi.c.
References appendBinaryStringInfo(), appendStringInfoCharMacro, Assert, StringInfoData::data, 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_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, StringInfoData::len, JsonLexContext::line_number, JsonLexContext::line_start, JsonIncrementalState::partial_completed, JsonIncrementalState::partial_token, JsonLexContext::prev_token_terminator, resetStringInfo(), 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 326 of file jsonapi.c.
References encoding, JsonLexContext::errormsg, JsonLexContext::flags, JsonLexContext::input, JsonLexContext::input_encoding, JsonLexContext::input_length, JSONLEX_FREE_STRUCT, JSONLEX_FREE_STRVAL, len, JsonLexContext::line_number, JsonLexContext::line_start, makeStringInfo(), palloc0(), 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 366 of file jsonapi.c.
References encoding, JsonLexContext::flags, JsonParserStack::fnames, JsonParserStack::fnull, JsonLexContext::inc_state, JsonLexContext::incremental, initStringInfo(), JsonLexContext::input_encoding, JS_MAX_PROD_LEN, JS_STACK_CHUNK_SIZE, JSONLEX_FREE_STRUCT, JSONLEX_FREE_STRVAL, JsonLexContext::line_number, makeStringInfo(), palloc(), palloc0(), JsonIncrementalState::partial_token, JsonParserStack::pred_index, JsonParserStack::prediction, JsonLexContext::pstack, JsonParserStack::stack_size, and JsonLexContext::strval.
Referenced by json_parse_manifest_incremental_init(), and main().
JsonParseErrorType pg_parse_json | ( | JsonLexContext * | lex, |
const JsonSemAction * | sem | ||
) |
Definition at line 521 of file jsonapi.c.
References JsonParserStack::fnames, JsonParserStack::fnull, JsonLexContext::inc_state, JsonLexContext::incremental, initStringInfo(), JsonLexContext::input, JsonLexContext::input_length, JS_MAX_PROD_LEN, JS_STACK_CHUNK_SIZE, JSON_INVALID_LEXER_TYPE, json_lex(), JSON_PARSE_END, JSON_SUCCESS, JSON_TOKEN_ARRAY_START, JSON_TOKEN_END, JSON_TOKEN_OBJECT_START, lex_expect(), lex_peek(), palloc(), palloc0(), parse_array(), parse_object(), parse_scalar(), JsonIncrementalState::partial_token, pg_parse_json_incremental(), JsonParserStack::pred_index, JsonParserStack::prediction, JsonLexContext::pstack, sem, and JsonParserStack::stack_size.
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 649 of file jsonapi.c.
References JsonSemAction::array_element_end, JsonSemAction::array_element_start, JsonSemAction::array_end, JsonSemAction::array_start, Assert, StringInfoData::data, dec_lex_level(), 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_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, next_prediction(), JsonSemAction::object_end, JsonSemAction::object_field_end, JsonSemAction::object_field_start, JsonSemAction::object_start, OFS, palloc(), pop_prediction(), JsonLexContext::pstack, pstrdup(), push_prediction(), report_parse_error(), JsonSemAction::scalar, JsonParserStack::scalar_tok, JsonParserStack::scalar_val, sem, JsonSemAction::semstate, set_fname(), set_fnull(), 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().
|
extern |
Definition at line 224 of file jsonapi.c.
Referenced by json_count_array_elements(), json_in(), json_recv(), json_validate(), and main().