PostgreSQL Source Code
git master
|
Go to the source code of this file.
Data Structures | |
struct | JsonbContainer |
struct | Jsonb |
struct | JsonbValue |
struct | JsonbPair |
struct | JsonbParseState |
struct | JsonbIterator |
Typedefs | |
typedef struct JsonbPair | JsonbPair |
typedef struct JsonbValue | JsonbValue |
typedef uint32 | JEntry |
typedef struct JsonbContainer | JsonbContainer |
typedef struct JsonbParseState | JsonbParseState |
typedef struct JsonbIterator | JsonbIterator |
Enumerations | |
enum | JsonbIteratorToken { WJB_DONE , WJB_KEY , WJB_VALUE , WJB_ELEM , WJB_BEGIN_ARRAY , WJB_END_ARRAY , WJB_BEGIN_OBJECT , WJB_END_OBJECT } |
enum | jbvType { jbvNull = 0x0 , jbvString , jbvNumeric , jbvBool , jbvArray = 0x10 , jbvObject , jbvBinary , jbvDatetime = 0x20 } |
enum | JsonbIterState { JBI_ARRAY_START , JBI_ARRAY_ELEM , JBI_OBJECT_START , JBI_OBJECT_KEY , JBI_OBJECT_VALUE } |
#define IsAJsonbScalar | ( | jsonbval | ) |
#define JB_ROOT_IS_OBJECT | ( | jbp_ | ) | ((*(uint32 *) VARDATA(jbp_) & JB_FOBJECT) != 0) |
#define JB_ROOT_IS_SCALAR | ( | jbp_ | ) | ((*(uint32 *) VARDATA(jbp_) & JB_FSCALAR) != 0) |
#define JBE_ADVANCE_OFFSET | ( | offset, | |
je | |||
) |
#define JBE_HAS_OFF | ( | je_ | ) | (((je_) & JENTRY_HAS_OFF) != 0) |
#define JBE_ISBOOL | ( | je_ | ) | (JBE_ISBOOL_TRUE(je_) || JBE_ISBOOL_FALSE(je_)) |
#define JBE_ISBOOL_FALSE | ( | je_ | ) | (((je_) & JENTRY_TYPEMASK) == JENTRY_ISBOOL_FALSE) |
#define JBE_ISBOOL_TRUE | ( | je_ | ) | (((je_) & JENTRY_TYPEMASK) == JENTRY_ISBOOL_TRUE) |
#define JBE_ISCONTAINER | ( | je_ | ) | (((je_) & JENTRY_TYPEMASK) == JENTRY_ISCONTAINER) |
#define JBE_ISNULL | ( | je_ | ) | (((je_) & JENTRY_TYPEMASK) == JENTRY_ISNULL) |
#define JBE_ISNUMERIC | ( | je_ | ) | (((je_) & JENTRY_TYPEMASK) == JENTRY_ISNUMERIC) |
#define JBE_ISSTRING | ( | je_ | ) | (((je_) & JENTRY_TYPEMASK) == JENTRY_ISSTRING) |
#define JBE_OFFLENFLD | ( | je_ | ) | ((je_) & JENTRY_OFFLENMASK) |
#define JsonContainerIsArray | ( | jc | ) | (((jc)->header & JB_FARRAY) != 0) |
#define JsonContainerIsObject | ( | jc | ) | (((jc)->header & JB_FOBJECT) != 0) |
#define JsonContainerIsScalar | ( | jc | ) | (((jc)->header & JB_FSCALAR) != 0) |
#define PG_GETARG_JSONB_P | ( | x | ) | DatumGetJsonbP(PG_GETARG_DATUM(x)) |
#define PG_GETARG_JSONB_P_COPY | ( | x | ) | DatumGetJsonbPCopy(PG_GETARG_DATUM(x)) |
#define PG_RETURN_JSONB_P | ( | x | ) | PG_RETURN_POINTER(x) |
typedef struct JsonbContainer JsonbContainer |
typedef struct JsonbIterator JsonbIterator |
typedef struct JsonbParseState JsonbParseState |
typedef struct JsonbValue JsonbValue |
enum jbvType |
enum JsonbIteratorToken |
enum JsonbIterState |
int compareJsonbContainers | ( | JsonbContainer * | a, |
JsonbContainer * | b | ||
) |
Definition at line 191 of file jsonb_util.c.
References a, Assert, b, compareJsonbScalarValue(), elog, ERROR, i, jbvArray, jbvBinary, jbvBool, jbvDatetime, jbvNull, jbvNumeric, jbvObject, jbvString, JsonbIteratorInit(), JsonbIteratorNext(), JsonbIterator::parent, pfree(), res, JsonbValue::type, JsonbValue::val, WJB_DONE, WJB_END_ARRAY, and WJB_END_OBJECT.
Referenced by jsonb_cmp(), jsonb_eq(), jsonb_ge(), jsonb_gt(), jsonb_le(), jsonb_lt(), and jsonb_ne().
Definition at line 374 of file jsonb.h.
References PG_DETOAST_DATUM.
Referenced by datum_to_jsonb_internal(), ExecEvalJsonIsPredicate(), json_populate_type(), jsonb_subscript_assign(), jsonb_subscript_fetch(), jsonb_subscript_fetch_old(), JsonItemFromDatum(), JsonPathExists(), JsonPathQuery(), JsonPathValue(), and JsonTableResetRowPattern().
JsonbValue* findJsonbValueFromContainer | ( | JsonbContainer * | container, |
uint32 | flags, | ||
JsonbValue * | key | ||
) |
Definition at line 344 of file jsonb_util.c.
References Assert, JsonbContainer::children, equalsJsonbScalarValue(), fillJsonbValue(), getKeyJsonValueFromContainer(), i, JB_FARRAY, JB_FOBJECT, JBE_ADVANCE_OFFSET, jbvString, JsonContainerIsArray, JsonContainerIsObject, JsonContainerSize, sort-test::key, palloc(), pfree(), and JsonbValue::type.
Referenced by executeItemOptUnwrapTarget(), getJsonPathVariableFromJsonb(), jsonb_exists(), jsonb_exists_all(), jsonb_exists_any(), and JsonbDeepContains().
JsonbValue* getIthJsonbValueFromContainer | ( | JsonbContainer * | container, |
uint32 | i | ||
) |
Definition at line 468 of file jsonb_util.c.
References JsonbContainer::children, elog, ERROR, fillJsonbValue(), getJsonbOffset(), i, if(), JsonContainerIsArray, JsonContainerSize, and palloc().
Referenced by executeItemOptUnwrapTarget(), jsonb_array_element(), jsonb_array_element_text(), and jsonb_get_element().
uint32 getJsonbLength | ( | const JsonbContainer * | jc, |
int | index | ||
) |
Definition at line 159 of file jsonb_util.c.
References JsonbContainer::children, getJsonbOffset(), JBE_HAS_OFF, JBE_OFFLENFLD, and len.
Referenced by fillJsonbValue(), and getKeyJsonValueFromContainer().
uint32 getJsonbOffset | ( | const JsonbContainer * | jc, |
int | index | ||
) |
Definition at line 134 of file jsonb_util.c.
References JsonbContainer::children, i, JBE_HAS_OFF, and JBE_OFFLENFLD.
Referenced by getIthJsonbValueFromContainer(), getJsonbLength(), getKeyJsonValueFromContainer(), and JsonbIteratorNext().
JsonbValue* getKeyJsonValueFromContainer | ( | JsonbContainer * | container, |
const char * | keyVal, | ||
int | keyLen, | ||
JsonbValue * | res | ||
) |
Definition at line 398 of file jsonb_util.c.
References Assert, JsonbContainer::children, difference(), fillJsonbValue(), getJsonbLength(), getJsonbOffset(), JsonContainerIsObject, JsonContainerSize, lengthCompareJsonbString(), palloc(), and res.
Referenced by findJsonbValueFromContainer(), JsObjectGetField(), jsonb_get_element(), jsonb_object_field(), jsonb_object_field_text(), and JsonbDeepContains().
Datum jsonb_build_array_worker | ( | int | nargs, |
const Datum * | args, | ||
const bool * | nulls, | ||
const Oid * | types, | ||
bool | absent_on_null | ||
) |
Definition at line 1210 of file jsonb.c.
References add_jsonb(), generate_unaccent_rules::args, i, JsonbPGetDatum(), JsonbValueToJsonb(), JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, types, WJB_BEGIN_ARRAY, and WJB_END_ARRAY.
Referenced by ExecEvalJsonConstructor(), and jsonb_build_array().
Datum jsonb_build_object_worker | ( | int | nargs, |
const Datum * | args, | ||
const bool * | nulls, | ||
const Oid * | types, | ||
bool | absent_on_null, | ||
bool | unique_keys | ||
) |
Definition at line 1125 of file jsonb.c.
References add_jsonb(), generate_unaccent_rules::args, ereport, errcode(), errhint(), errmsg(), ERROR, i, JsonbPGetDatum(), JsonbValueToJsonb(), JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, skip, JsonbParseState::skip_nulls, types, JsonbParseState::unique_keys, WJB_BEGIN_OBJECT, and WJB_END_OBJECT.
Referenced by ExecEvalJsonConstructor(), and jsonb_build_object().
Definition at line 1530 of file jsonfuncs.c.
References Assert, cstring_to_text(), DatumGetTextPP, elog, ERROR, getIthJsonbValueFromContainer(), getKeyJsonValueFromContainer(), i, IsAJsonbScalar, JB_ROOT_IS_ARRAY, JB_ROOT_IS_OBJECT, JB_ROOT_IS_SCALAR, jbvBinary, jbvNull, JsonbToCString(), JsonbValueAsText(), JsonbValueToJsonb(), JsonContainerIsArray, JsonContainerIsObject, JsonContainerIsScalar, JsonContainerSize, PG_RETURN_JSONB_P, PointerGetDatum(), res, Jsonb::root, strtoint(), TextDatumGetCString, JsonbValue::type, JsonbValue::val, VARDATA_ANY, VARSIZE, and VARSIZE_ANY_EXHDR.
Referenced by get_jsonb_path_all(), jsonb_subscript_fetch(), and jsonb_subscript_fetch_old().
Datum jsonb_set_element | ( | Jsonb * | jb, |
Datum * | path, | ||
int | path_len, | ||
JsonbValue * | newval | ||
) |
Definition at line 1678 of file jsonfuncs.c.
References JB_PATH_CONSISTENT_POSITION, JB_PATH_CREATE, JB_PATH_FILL_GAPS, jbvArray, JsonbIteratorInit(), JsonbValueToJsonb(), newval, palloc0(), pfree(), PG_RETURN_JSONB_P, res, Jsonb::root, and setPath().
Referenced by jsonb_subscript_assign().
bool JsonbDeepContains | ( | JsonbIterator ** | val, |
JsonbIterator ** | mContained | ||
) |
Definition at line 1062 of file jsonb_util.c.
References Assert, check_stack_depth(), elog, equalsJsonbScalarValue(), ERROR, findJsonbValueFromContainer(), getKeyJsonValueFromContainer(), i, IsAJsonbScalar, j, JB_FARRAY, jbvArray, jbvBinary, jbvObject, jbvString, JsonbIteratorInit(), JsonbIteratorNext(), palloc(), pfree(), JsonbValue::type, JsonbValue::val, val, WJB_BEGIN_ARRAY, WJB_BEGIN_OBJECT, WJB_ELEM, WJB_END_ARRAY, WJB_END_OBJECT, WJB_KEY, and WJB_VALUE.
Referenced by jsonb_contained(), and jsonb_contains().
bool JsonbExtractScalar | ( | JsonbContainer * | jbc, |
JsonbValue * | res | ||
) |
Definition at line 1968 of file jsonb.c.
References Assert, IsAJsonbScalar, jbvArray, jbvObject, JsonbIteratorInit(), JsonbIteratorNext(), JsonContainerIsArray, JsonContainerIsScalar, PG_USED_FOR_ASSERTS_ONLY, res, JsonbValue::val, WJB_BEGIN_ARRAY, WJB_DONE, WJB_ELEM, and WJB_END_ARRAY.
Referenced by executeJsonPath(), jsonb_bool(), jsonb_float4(), jsonb_float8(), jsonb_int2(), jsonb_int4(), jsonb_int8(), jsonb_numeric(), JsonbContainerTypeName(), JsonbUnquote(), JsonItemFromDatum(), and JsonPathValue().
void JsonbHashScalarValue | ( | const JsonbValue * | scalarVal, |
uint32 * | hash | ||
) |
Definition at line 1316 of file jsonb_util.c.
References DatumGetUInt32(), DirectFunctionCall1, elog, ERROR, hash(), hash_any(), hash_numeric(), jbvBool, jbvNull, jbvNumeric, jbvString, NumericGetDatum(), pg_rotate_left32(), JsonbValue::type, and JsonbValue::val.
Referenced by gin_extract_jsonb_path(), jsonb_hash(), jsonb_path_ops__add_path_item(), and jsonb_path_ops__extract_nodes().
void JsonbHashScalarValueExtended | ( | const JsonbValue * | scalarVal, |
uint64 * | hash, | ||
uint64 | seed | ||
) |
Definition at line 1359 of file jsonb_util.c.
References BoolGetDatum(), DatumGetUInt64(), DirectFunctionCall2, elog, ERROR, hash(), hash_any_extended(), hash_numeric_extended(), hashcharextended(), jbvBool, jbvNull, jbvNumeric, jbvString, NumericGetDatum(), ROTATE_HIGH_AND_LOW_32BITS, JsonbValue::type, UInt64GetDatum(), and JsonbValue::val.
Referenced by jsonb_hash_extended().
JsonbIterator* JsonbIteratorInit | ( | JsonbContainer * | container | ) |
Definition at line 817 of file jsonb_util.c.
References iteratorFromContainer().
Referenced by compareJsonbContainers(), datum_to_jsonb_internal(), each_worker_jsonb(), elements_worker_jsonb(), executeAnyItem(), executeKeyValueMethod(), gin_extract_jsonb(), gin_extract_jsonb_path(), iterate_jsonb_values(), jsonb_agg_transfn_worker(), jsonb_concat(), jsonb_contained(), jsonb_contains(), jsonb_delete(), jsonb_delete_array(), jsonb_delete_idx(), jsonb_delete_path(), jsonb_hash(), jsonb_hash_extended(), jsonb_insert(), jsonb_object_agg_transfn_worker(), jsonb_object_keys(), jsonb_set(), jsonb_set_element(), jsonb_strip_nulls(), Jsonb_to_SV(), JsonbDeepContains(), JsonbExtractScalar(), JsonbToCStringWorker(), parse_jsonb_index_flags(), PLyObject_FromJsonbContainer(), populate_array_dim_jsonb(), populate_recordset_worker(), pushJsonbValue(), and transform_jsonb_string_values().
JsonbIteratorToken JsonbIteratorNext | ( | JsonbIterator ** | it, |
JsonbValue * | val, | ||
bool | skipNested | ||
) |
Definition at line 853 of file jsonb_util.c.
References elog, ERROR, fillJsonbValue(), freeAndGetParent(), getJsonbOffset(), IsAJsonbScalar, iteratorFromContainer(), JBE_ADVANCE_OFFSET, JBI_ARRAY_ELEM, JBI_ARRAY_START, JBI_OBJECT_KEY, JBI_OBJECT_START, JBI_OBJECT_VALUE, jbvArray, jbvObject, jbvString, val, WJB_BEGIN_ARRAY, WJB_BEGIN_OBJECT, WJB_DONE, WJB_ELEM, WJB_END_ARRAY, WJB_END_OBJECT, WJB_KEY, and WJB_VALUE.
Referenced by compareJsonbContainers(), datum_to_jsonb_internal(), each_worker_jsonb(), elements_worker_jsonb(), executeAnyItem(), executeKeyValueMethod(), gin_extract_jsonb(), gin_extract_jsonb_path(), iterate_jsonb_values(), IteratorConcat(), jsonb_agg_transfn_worker(), jsonb_delete(), jsonb_delete_array(), jsonb_delete_idx(), jsonb_hash(), jsonb_hash_extended(), jsonb_object_agg_transfn_worker(), jsonb_object_keys(), jsonb_strip_nulls(), Jsonb_to_SV(), JsonbDeepContains(), JsonbExtractScalar(), JsonbToCStringWorker(), parse_jsonb_index_flags(), PLyObject_FromJsonbContainer(), populate_array_dim_jsonb(), populate_recordset_worker(), pushJsonbValue(), setPath(), setPathArray(), setPathObject(), and transform_jsonb_string_values().
Definition at line 386 of file jsonb.h.
References PointerGetDatum().
Referenced by datum_to_jsonb(), ExecEvalJsonExprPath(), ExecGetJsonValueItemString(), jsonb_build_array_worker(), jsonb_build_object_worker(), jsonb_path_query_internal(), JsonItemFromDatum(), JsonPathQuery(), JsonTablePlanScanNextRow(), and populate_scalar().
char* JsonbToCString | ( | StringInfo | out, |
JsonbContainer * | in, | ||
int | estimated_len | ||
) |
Definition at line 473 of file jsonb.c.
References JsonbToCStringWorker().
Referenced by jsonb_get_element(), jsonb_out(), jsonb_send(), JsonbUnquote(), JsonbValueAsText(), and populate_scalar().
char* JsonbToCStringIndent | ( | StringInfo | out, |
JsonbContainer * | in, | ||
int | estimated_len | ||
) |
Definition at line 482 of file jsonb.c.
References JsonbToCStringWorker().
Referenced by jsonb_pretty().
void JsonbToJsonbValue | ( | Jsonb * | jsonb, |
JsonbValue * | val | ||
) |
Definition at line 72 of file jsonb_util.c.
References jbvBinary, Jsonb::root, val, VARHDRSZ, and VARSIZE.
Referenced by jsonb_insert(), jsonb_set(), and jsonb_subscript_assign().
const char* JsonbTypeName | ( | JsonbValue * | val | ) |
Definition at line 180 of file jsonb.c.
References elog, ERROR, jbvArray, jbvBinary, jbvBool, jbvDatetime, jbvNull, jbvNumeric, jbvObject, jbvString, JsonbContainerTypeName(), and val.
Referenced by executeItemOptUnwrapTarget(), and JsonbContainerTypeName().
char* JsonbUnquote | ( | Jsonb * | jb | ) |
Definition at line 2166 of file jsonb.c.
References DatumGetCString(), DirectFunctionCall1, elog, ERROR, JB_ROOT_IS_SCALAR, jbvBool, jbvNull, jbvNumeric, jbvString, JsonbExtractScalar(), JsonbToCString(), numeric_out(), pnstrdup(), PointerGetDatum(), pstrdup(), Jsonb::root, JsonbValue::type, JsonbValue::val, and VARSIZE.
Referenced by json_populate_type().
Jsonb* JsonbValueToJsonb | ( | JsonbValue * | val | ) |
Definition at line 92 of file jsonb_util.c.
References Assert, convertToJsonb(), IsAJsonbScalar, jbvArray, jbvBinary, jbvObject, palloc(), pushJsonbValue(), res, SET_VARSIZE, JsonbValue::type, JsonbValue::val, val, VARDATA, VARHDRSZ, WJB_BEGIN_ARRAY, WJB_ELEM, and WJB_END_ARRAY.
Referenced by datum_to_jsonb(), each_worker_jsonb(), elements_worker_jsonb(), ExecEvalJsonExprPath(), ExecGetJsonValueItemString(), executeKeyValueMethod(), hstore_to_jsonb(), hstore_to_jsonb_loose(), jsonb_agg_finalfn(), jsonb_agg_transfn_worker(), jsonb_array_element(), jsonb_build_array_noargs(), jsonb_build_array_worker(), jsonb_build_object_noargs(), jsonb_build_object_worker(), jsonb_concat(), jsonb_delete(), jsonb_delete_array(), jsonb_delete_idx(), jsonb_delete_path(), jsonb_from_cstring(), jsonb_get_element(), jsonb_insert(), jsonb_object(), jsonb_object_agg_finalfn(), jsonb_object_agg_transfn_worker(), jsonb_object_field(), jsonb_object_two_arg(), jsonb_path_query_array_internal(), jsonb_path_query_first_internal(), jsonb_path_query_internal(), jsonb_set(), jsonb_set_element(), jsonb_strip_nulls(), jsonb_subscript_assign(), JsonPathQuery(), JsonTablePlanScanNextRow(), plperl_to_jsonb(), plpython_to_jsonb(), populate_scalar(), and transform_jsonb_string_values().
JsonbValue* pushJsonbValue | ( | JsonbParseState ** | pstate, |
JsonbIteratorToken | seq, | ||
JsonbValue * | jbval | ||
) |
Definition at line 566 of file jsonb_util.c.
References Assert, i, JB_FSCALAR, jbvArray, jbvBinary, jbvObject, JsonbIteratorInit(), JsonbIteratorNext(), pushJsonbValueScalar(), res, JsonbValue::type, JsonbValue::val, WJB_BEGIN_ARRAY, WJB_BEGIN_OBJECT, WJB_DONE, WJB_ELEM, WJB_END_ARRAY, WJB_END_OBJECT, WJB_KEY, and WJB_VALUE.
Referenced by array_dim_to_jsonb(), array_to_jsonb_internal(), AV_to_JsonbValue(), composite_to_jsonb(), datum_to_jsonb_internal(), executeKeyValueMethod(), hstore_to_jsonb(), hstore_to_jsonb_loose(), HV_to_JsonbValue(), IteratorConcat(), jsonb_agg_finalfn(), jsonb_agg_transfn_worker(), jsonb_build_array_noargs(), jsonb_build_array_worker(), jsonb_build_object_noargs(), jsonb_build_object_worker(), jsonb_delete(), jsonb_delete_array(), jsonb_delete_idx(), jsonb_in_array_end(), jsonb_in_array_start(), jsonb_in_object_end(), jsonb_in_object_field_start(), jsonb_in_object_start(), jsonb_in_scalar(), jsonb_object(), jsonb_object_agg_finalfn(), jsonb_object_agg_transfn_worker(), jsonb_object_two_arg(), jsonb_strip_nulls(), JsonbValueToJsonb(), PLyMapping_ToJsonbValue(), PLyObject_ToJsonbValue(), PLySequence_ToJsonbValue(), push_null_elements(), push_path(), setPath(), setPathArray(), setPathObject(), SV_to_JsonbValue(), transform_jsonb_string_values(), and wrapItemsInArray().
Definition at line 1049 of file jsonb.c.
References func_volatile(), json_categorize_type(), JSONTYPE_ARRAY, JSONTYPE_BOOL, JSONTYPE_CAST, JSONTYPE_COMPOSITE, JSONTYPE_DATE, JSONTYPE_JSON, JSONTYPE_JSONB, JSONTYPE_NULL, JSONTYPE_NUMERIC, JSONTYPE_OTHER, JSONTYPE_TIMESTAMP, and JSONTYPE_TIMESTAMPTZ.
Referenced by contain_mutable_functions_walker().