PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/htup_details.h"
#include "access/transam.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "parser/parse_coerce.h"
#include "utils/builtins.h"
#include "utils/date.h"
#include "utils/datetime.h"
#include "utils/json.h"
#include "utils/jsonapi.h"
#include "utils/jsonb.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
Go to the source code of this file.
Data Structures | |
struct | JsonbInState |
struct | JsonbAggState |
Typedefs | |
typedef struct JsonbInState | JsonbInState |
typedef struct JsonbAggState | JsonbAggState |
typedef struct JsonbAggState JsonbAggState |
typedef struct JsonbInState JsonbInState |
enum JsonbTypeCategory |
Definition at line 39 of file jsonb.c.
|
static |
Definition at line 602 of file jsonb.c.
References appendBinaryStringInfo(), appendStringInfoCharMacro, and i.
Referenced by JsonbToCStringWorker().
|
static |
Definition at line 1106 of file jsonb.c.
References datum_to_jsonb(), ereport, errcode(), errmsg(), ERROR, InvalidOid, jsonb_categorize_type(), and JSONBTYPE_NULL.
Referenced by jsonb_build_array(), and jsonb_build_object().
|
static |
Definition at line 954 of file jsonb.c.
References Assert, datum_to_jsonb(), i, JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, WJB_BEGIN_ARRAY, and WJB_END_ARRAY.
Referenced by array_to_jsonb_internal().
|
static |
Definition at line 986 of file jsonb.c.
References ARR_DIMS, ARR_ELEMTYPE, ARR_NDIM, array_dim_to_jsonb(), ArrayGetNItems(), DatumGetArrayTypeP, deconstruct_array(), get_typlenbyvalalign(), jsonb_categorize_type(), JsonbInState::parseState, pfree(), pushJsonbValue(), JsonbInState::res, typalign, WJB_BEGIN_ARRAY, and WJB_END_ARRAY.
Referenced by datum_to_jsonb().
|
static |
Definition at line 1935 of file jsonb.c.
References elog, ereport, errcode(), errmsg(), ERROR, gettext_noop, i, jbvArray, jbvBinary, jbvBool, jbvNull, jbvNumeric, jbvObject, jbvString, lengthof, and generate_unaccent_rules::type.
Referenced by jsonb_bool(), jsonb_float4(), jsonb_float8(), jsonb_int2(), jsonb_int4(), jsonb_int8(), and jsonb_numeric().
|
static |
Definition at line 282 of file jsonb.c.
References ereport, errcode(), errdetail(), errmsg(), ERROR, and JENTRY_OFFLENMASK.
Referenced by datum_to_jsonb(), jsonb_in_object_field_start(), and jsonb_in_scalar().
|
static |
Definition at line 1477 of file jsonb.c.
References JsonbParseState::contVal, JsonbParseState::next, palloc(), and JsonbParseState::size.
Referenced by jsonb_agg_finalfn(), and jsonb_object_agg_finalfn().
|
static |
Definition at line 1034 of file jsonb.c.
References attname, datum_to_jsonb(), DatumGetHeapTupleHeader, heap_getattr, HeapTupleHeaderGetDatumLength, HeapTupleHeaderGetTypeId, HeapTupleHeaderGetTypMod, i, InvalidOid, jbvString, jsonb_categorize_type(), JSONBTYPE_NULL, lookup_rowtype_tupdesc(), NameStr, TupleDescData::natts, JsonbInState::parseState, pushJsonbValue(), ReleaseTupleDesc, JsonbInState::res, HeapTupleData::t_data, HeapTupleData::t_len, TupleDescAttr, JsonbValue::type, JsonbValue::val, val, WJB_BEGIN_OBJECT, WJB_END_OBJECT, and WJB_KEY.
Referenced by datum_to_jsonb().
|
static |
Definition at line 731 of file jsonb.c.
References JsonSemAction::array_end, JsonSemAction::array_start, array_to_jsonb_internal(), Assert, check_stack_depth(), checkStringLen(), composite_to_jsonb(), JsonbParseState::contVal, CStringGetDatum, DatumGetBool, DatumGetJsonbP, DatumGetNumeric, DatumGetTextPP, DirectFunctionCall3, elog, ereport, errcode(), errmsg(), ERROR, Int32GetDatum, InvalidOid, JB_ROOT_IS_SCALAR, jbvArray, jbvBool, jbvNull, jbvNumeric, jbvObject, jbvString, jsonb_in_array_end(), jsonb_in_array_start(), jsonb_in_object_end(), jsonb_in_object_field_start(), jsonb_in_object_start(), jsonb_in_scalar(), JsonbIteratorInit(), JsonbIteratorNext(), JSONBTYPE_ARRAY, JSONBTYPE_BOOL, JSONBTYPE_COMPOSITE, JSONBTYPE_DATE, JSONBTYPE_JSON, JSONBTYPE_JSONB, JSONBTYPE_JSONCAST, JSONBTYPE_NUMERIC, JSONBTYPE_TIMESTAMP, JSONBTYPE_TIMESTAMPTZ, JsonEncodeDateTime(), makeJsonLexContext(), numeric_in(), JsonSemAction::object_end, JsonSemAction::object_field_start, JsonSemAction::object_start, ObjectIdGetDatum, OidFunctionCall1, OidOutputFunctionCall(), JsonbInState::parseState, pfree(), pg_parse_json(), pushJsonbValue(), JsonbInState::res, Jsonb::root, JsonSemAction::scalar, JsonSemAction::semstate, JsonbValue::type, generate_unaccent_rules::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 add_jsonb(), array_dim_to_jsonb(), composite_to_jsonb(), jsonb_agg_transfn(), jsonb_object_agg_transfn(), and to_jsonb().
Datum jsonb_agg_finalfn | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1627 of file jsonb.c.
References AggCheckCallContext(), arg, Assert, clone_parse_state(), JsonbValueToJsonb(), JsonbInState::parseState, PG_ARGISNULL, PG_GETARG_POINTER, PG_RETURN_NULL, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, JsonbAggState::res, and WJB_END_ARRAY.
Datum jsonb_agg_transfn | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1509 of file jsonb.c.
References AggCheckCallContext(), buf, datum_to_jsonb(), DatumGetNumeric, DirectFunctionCall1, elog, ereport, errcode(), errmsg(), ERROR, get_fn_expr_argtype(), InvalidOid, jbvNumeric, jbvString, jsonb_categorize_type(), JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueToJsonb(), MemoryContextSwitchTo(), numeric_uplus(), NumericGetDatum, palloc(), palloc0(), JsonbInState::parseState, PG_ARGISNULL, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, JsonbAggState::res, Jsonb::root, snprintf, JsonbValue::type, generate_unaccent_rules::type, JsonbValue::val, val, JsonbAggState::val_category, JsonbAggState::val_output_func, WJB_BEGIN_ARRAY, WJB_BEGIN_OBJECT, WJB_DONE, WJB_ELEM, WJB_END_ARRAY, WJB_END_OBJECT, WJB_KEY, and WJB_VALUE.
Datum jsonb_bool | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1965 of file jsonb.c.
References cannotCastJsonbValue(), jbvBool, JsonbExtractScalar(), PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_RETURN_BOOL, Jsonb::root, JsonbValue::type, and JsonbValue::val.
Datum jsonb_build_array | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1226 of file jsonb.c.
References add_jsonb(), generate_unaccent_rules::args, extract_variadic_args(), i, JsonbValueToJsonb(), JsonbInState::parseState, PG_RETURN_NULL, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, types, WJB_BEGIN_ARRAY, and WJB_END_ARRAY.
Datum jsonb_build_array_noargs | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1257 of file jsonb.c.
References JsonbValueToJsonb(), JsonbInState::parseState, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, WJB_BEGIN_ARRAY, and WJB_END_ARRAY.
Datum jsonb_build_object | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1160 of file jsonb.c.
References add_jsonb(), generate_unaccent_rules::args, ereport, errcode(), errhint(), errmsg(), ERROR, extract_variadic_args(), i, JsonbValueToJsonb(), JsonbInState::parseState, PG_RETURN_NULL, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, types, WJB_BEGIN_OBJECT, and WJB_END_OBJECT.
Datum jsonb_build_object_noargs | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1210 of file jsonb.c.
References JsonbValueToJsonb(), JsonbInState::parseState, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, WJB_BEGIN_OBJECT, and WJB_END_OBJECT.
|
static |
Definition at line 623 of file jsonb.c.
References COERCION_EXPLICIT, COERCION_PATH_FUNC, find_coercion_pathway(), FirstNormalObjectId, get_element_type(), getBaseType(), getTypeOutputInfo(), InvalidOid, JSONBTYPE_ARRAY, JSONBTYPE_BOOL, JSONBTYPE_COMPOSITE, JSONBTYPE_DATE, JSONBTYPE_JSON, JSONBTYPE_JSONB, JSONBTYPE_JSONCAST, JSONBTYPE_NUMERIC, JSONBTYPE_OTHER, JSONBTYPE_TIMESTAMP, JSONBTYPE_TIMESTAMPTZ, OidIsValid, and type_is_rowtype().
Referenced by add_jsonb(), array_to_jsonb_internal(), composite_to_jsonb(), jsonb_agg_transfn(), jsonb_object_agg_transfn(), and to_jsonb().
Datum jsonb_float4 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2054 of file jsonb.c.
References cannotCastJsonbValue(), DirectFunctionCall1, jbvNumeric, JsonbExtractScalar(), numeric_float4(), NumericGetDatum, PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_RETURN_DATUM, Jsonb::root, JsonbValue::type, and JsonbValue::val.
Datum jsonb_float8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2072 of file jsonb.c.
References cannotCastJsonbValue(), DirectFunctionCall1, jbvNumeric, JsonbExtractScalar(), numeric_float8(), NumericGetDatum, PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_RETURN_DATUM, Jsonb::root, JsonbValue::type, and JsonbValue::val.
|
inlinestatic |
Definition at line 256 of file jsonb.c.
References JsonSemAction::array_end, JsonSemAction::array_start, jsonb_in_array_end(), jsonb_in_array_start(), jsonb_in_object_end(), jsonb_in_object_field_start(), jsonb_in_object_start(), jsonb_in_scalar(), JsonbValueToJsonb(), makeJsonLexContextCstringLen(), JsonSemAction::object_end, JsonSemAction::object_field_start, JsonSemAction::object_start, pg_parse_json(), PG_RETURN_POINTER, JsonbInState::res, JsonSemAction::scalar, and JsonSemAction::semstate.
Referenced by jsonb_in(), and jsonb_recv().
Datum jsonb_in | ( | PG_FUNCTION_ARGS | ) |
|
static |
Definition at line 319 of file jsonb.c.
References JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, and WJB_END_ARRAY.
Referenced by datum_to_jsonb(), and jsonb_from_cstring().
|
static |
Definition at line 311 of file jsonb.c.
References JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, and WJB_BEGIN_ARRAY.
Referenced by datum_to_jsonb(), and jsonb_from_cstring().
|
static |
Definition at line 303 of file jsonb.c.
References JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, and WJB_END_OBJECT.
Referenced by datum_to_jsonb(), and jsonb_from_cstring().
|
static |
Definition at line 327 of file jsonb.c.
References Assert, checkStringLen(), jbvString, JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, JsonbValue::type, JsonbValue::val, and WJB_KEY.
Referenced by datum_to_jsonb(), and jsonb_from_cstring().
|
static |
Definition at line 295 of file jsonb.c.
References JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, and WJB_BEGIN_OBJECT.
Referenced by datum_to_jsonb(), and jsonb_from_cstring().
|
static |
Definition at line 371 of file jsonb.c.
References Assert, checkStringLen(), JsonbParseState::contVal, CStringGetDatum, DatumGetNumeric, DirectFunctionCall3, elog, ERROR, Int32GetDatum, InvalidOid, jbvArray, jbvBool, jbvNull, jbvNumeric, jbvObject, jbvString, JSON_TOKEN_FALSE, JSON_TOKEN_NULL, JSON_TOKEN_NUMBER, JSON_TOKEN_STRING, JSON_TOKEN_TRUE, numeric_in(), ObjectIdGetDatum, JsonbInState::parseState, pushJsonbValue(), JsonbInState::res, JsonbValue::type, JsonbValue::val, WJB_BEGIN_ARRAY, WJB_ELEM, WJB_END_ARRAY, and WJB_VALUE.
Referenced by datum_to_jsonb(), and jsonb_from_cstring().
Datum jsonb_int2 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2000 of file jsonb.c.
References cannotCastJsonbValue(), DirectFunctionCall1, jbvNumeric, JsonbExtractScalar(), numeric_int2(), NumericGetDatum, PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_RETURN_DATUM, Jsonb::root, JsonbValue::type, and JsonbValue::val.
Datum jsonb_int4 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2018 of file jsonb.c.
References cannotCastJsonbValue(), DirectFunctionCall1, jbvNumeric, JsonbExtractScalar(), numeric_int4(), NumericGetDatum, PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_RETURN_DATUM, Jsonb::root, JsonbValue::type, and JsonbValue::val.
Datum jsonb_int8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2036 of file jsonb.c.
References cannotCastJsonbValue(), DirectFunctionCall1, jbvNumeric, JsonbExtractScalar(), numeric_int8(), NumericGetDatum, PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_RETURN_DATUM, Jsonb::root, JsonbValue::type, and JsonbValue::val.
Datum jsonb_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1979 of file jsonb.c.
References cannotCastJsonbValue(), DatumGetNumericCopy, jbvNumeric, JsonbExtractScalar(), NumericGetDatum, PG_FREE_IF_COPY, PG_GETARG_JSONB_P, PG_RETURN_NUMERIC, Jsonb::root, JsonbValue::type, and JsonbValue::val.
Datum jsonb_object | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1278 of file jsonb.c.
References ARR_DIMS, ARR_NDIM, deconstruct_array(), ereport, errcode(), errmsg(), ERROR, i, jbvNull, jbvString, JsonbValueToJsonb(), JsonbInState::parseState, pfree(), PG_GETARG_ARRAYTYPE_P, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, generate_unaccent_rules::str, TextDatumGetCString, JsonbValue::type, JsonbValue::val, WJB_BEGIN_OBJECT, WJB_END_OBJECT, WJB_KEY, and WJB_VALUE.
Datum jsonb_object_agg_finalfn | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1858 of file jsonb.c.
References AggCheckCallContext(), arg, Assert, clone_parse_state(), JsonbValueToJsonb(), JsonbInState::parseState, PG_ARGISNULL, PG_GETARG_POINTER, PG_RETURN_NULL, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, JsonbAggState::res, and WJB_END_OBJECT.
Datum jsonb_object_agg_transfn | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1662 of file jsonb.c.
References AggCheckCallContext(), buf, datum_to_jsonb(), DatumGetNumeric, DirectFunctionCall1, elog, ereport, errcode(), errmsg(), ERROR, get_fn_expr_argtype(), InvalidOid, jbvNumeric, jbvString, jsonb_categorize_type(), JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueToJsonb(), JsonbAggState::key_category, JsonbAggState::key_output_func, MemoryContextSwitchTo(), numeric_uplus(), NumericGetDatum, palloc(), palloc0(), JsonbInState::parseState, PG_ARGISNULL, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, JsonbAggState::res, Jsonb::root, snprintf, JsonbValue::type, generate_unaccent_rules::type, JsonbValue::val, val, JsonbAggState::val_category, JsonbAggState::val_output_func, WJB_BEGIN_ARRAY, WJB_BEGIN_OBJECT, WJB_DONE, WJB_ELEM, WJB_END_ARRAY, WJB_END_OBJECT, WJB_KEY, and WJB_VALUE.
Datum jsonb_object_two_arg | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1380 of file jsonb.c.
References ARR_NDIM, deconstruct_array(), ereport, errcode(), errmsg(), ERROR, i, jbvNull, jbvString, JsonbValueToJsonb(), JsonbInState::parseState, pfree(), PG_GETARG_ARRAYTYPE_P, PG_RETURN_POINTER, pushJsonbValue(), JsonbInState::res, generate_unaccent_rules::str, TextDatumGetCString, JsonbValue::type, JsonbValue::val, WJB_BEGIN_OBJECT, WJB_END_OBJECT, WJB_KEY, and WJB_VALUE.
Datum jsonb_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 132 of file jsonb.c.
References JsonbToCString(), PG_GETARG_JSONB_P, PG_RETURN_CSTRING, Jsonb::root, and VARSIZE.
|
static |
Definition at line 341 of file jsonb.c.
References appendBinaryStringInfo(), appendStringInfoString(), DatumGetCString, DirectFunctionCall1, elog, ERROR, escape_json(), jbvBool, jbvNull, jbvNumeric, jbvString, numeric_out(), pnstrdup(), PointerGetDatum, JsonbValue::type, and JsonbValue::val.
Referenced by JsonbToCStringWorker().
Datum jsonb_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 113 of file jsonb.c.
References buf, StringInfoData::cursor, elog, ERROR, jsonb_from_cstring(), StringInfoData::len, PG_GETARG_POINTER, pq_getmsgint(), pq_getmsgtext(), and generate_unaccent_rules::str.
Datum jsonb_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 148 of file jsonb.c.
References buf, StringInfoData::data, JsonbToCString(), StringInfoData::len, makeStringInfo(), pfree(), PG_GETARG_JSONB_P, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), pq_sendint8(), pq_sendtext(), Jsonb::root, and VARSIZE.
Datum jsonb_typeof | ( | PG_FUNCTION_ARGS | ) |
Definition at line 240 of file jsonb.c.
References cstring_to_text(), JsonbContainerTypeName(), PG_GETARG_JSONB_P, PG_RETURN_TEXT_P, and Jsonb::root.
|
static |
Definition at line 170 of file jsonb.c.
References elog, ERROR, JsonbContainer::header, JsonbExtractScalar(), JsonbTypeName(), JsonContainerIsArray, and JsonContainerIsObject.
Referenced by jsonb_typeof(), and JsonbTypeName().
bool JsonbExtractScalar | ( | JsonbContainer * | jbc, |
JsonbValue * | res | ||
) |
Definition at line 1895 of file jsonb.c.
References Assert, IsAJsonbScalar, jbvArray, jbvObject, JsonbIteratorInit(), JsonbIteratorNext(), JsonContainerIsArray, JsonContainerIsScalar, PG_USED_FOR_ASSERTS_ONLY, JsonbValue::type, 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(), and JsonbContainerTypeName().
char* JsonbToCString | ( | StringInfo | out, |
JsonbContainer * | in, | ||
int | estimated_len | ||
) |
Definition at line 460 of file jsonb.c.
References JsonbToCStringWorker().
Referenced by get_jsonb_path_all(), jsonb_out(), jsonb_send(), JsonbValueAsText(), and populate_scalar().
char* JsonbToCStringIndent | ( | StringInfo | out, |
JsonbContainer * | in, | ||
int | estimated_len | ||
) |
Definition at line 469 of file jsonb.c.
References JsonbToCStringWorker().
Referenced by jsonb_pretty().
|
static |
Definition at line 478 of file jsonb.c.
References add_indent(), appendBinaryStringInfo(), appendStringInfoCharMacro, Assert, StringInfoData::data, elog, enlargeStringInfo(), ERROR, jsonb_put_escaped_value(), JsonbIteratorInit(), JsonbIteratorNext(), makeStringInfo(), generate_unaccent_rules::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 JsonbToCString(), and JsonbToCStringIndent().
const char* JsonbTypeName | ( | JsonbValue * | jbv | ) |
Definition at line 191 of file jsonb.c.
References elog, ERROR, jbvArray, jbvBinary, jbvBool, jbvDatetime, jbvNull, jbvNumeric, jbvObject, jbvString, JsonbContainerTypeName(), JsonbValue::type, and JsonbValue::val.
Referenced by executeItemOptUnwrapTarget(), and JsonbContainerTypeName().
Datum to_jsonb | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1133 of file jsonb.c.
References datum_to_jsonb(), ereport, errcode(), errmsg(), ERROR, get_fn_expr_argtype(), InvalidOid, jsonb_categorize_type(), JsonbValueToJsonb(), PG_GETARG_DATUM, PG_RETURN_POINTER, JsonbInState::res, and val.