PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include "access/htup_details.h"
#include "catalog/pg_type.h"
#include "common/jsonapi.h"
#include "common/string.h"
#include "fmgr.h"
#include "funcapi.h"
#include "lib/stringinfo.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/miscnodes.h"
#include "parser/parse_coerce.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/hsearch.h"
#include "utils/json.h"
#include "utils/jsonb.h"
#include "utils/jsonfuncs.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
Go to the source code of this file.
Data Structures | |
struct | OkeysState |
struct | IterateJsonStringValuesState |
struct | TransformJsonStringValuesState |
struct | GetState |
struct | AlenState |
struct | EachState |
struct | ElementsState |
struct | JHashState |
struct | JsonHashEntry |
struct | ScalarIOData |
struct | ArrayIOData |
struct | CompositeIOData |
struct | DomainIOData |
struct | ColumnIOData |
struct | RecordIOData |
struct | PopulateRecordCache |
struct | PopulateRecordsetState |
struct | PopulateArrayContext |
struct | PopulateArrayState |
struct | StripnullState |
struct | JsValue |
struct | JsObject |
Macros | |
#define | JB_PATH_CREATE 0x0001 |
#define | JB_PATH_DELETE 0x0002 |
#define | JB_PATH_REPLACE 0x0004 |
#define | JB_PATH_INSERT_BEFORE 0x0008 |
#define | JB_PATH_INSERT_AFTER 0x0010 |
#define | JB_PATH_CREATE_OR_INSERT (JB_PATH_INSERT_BEFORE | JB_PATH_INSERT_AFTER | JB_PATH_CREATE) |
#define | JB_PATH_FILL_GAPS 0x0020 |
#define | JB_PATH_CONSISTENT_POSITION 0x0040 |
#define | JsValueIsNull(jsv) |
#define | JsValueIsString(jsv) |
#define | JsObjectIsEmpty(jso) |
#define | JsObjectFree(jso) |
Enumerations | |
enum | TypeCat { TYPECAT_SCALAR = 's' , TYPECAT_ARRAY = 'a' , TYPECAT_COMPOSITE = 'c' , TYPECAT_COMPOSITE_DOMAIN = 'C' , TYPECAT_DOMAIN = 'd' } |
#define JB_PATH_CONSISTENT_POSITION 0x0040 |
Definition at line 51 of file jsonfuncs.c.
#define JB_PATH_CREATE 0x0001 |
Definition at line 43 of file jsonfuncs.c.
#define JB_PATH_CREATE_OR_INSERT (JB_PATH_INSERT_BEFORE | JB_PATH_INSERT_AFTER | JB_PATH_CREATE) |
Definition at line 48 of file jsonfuncs.c.
#define JB_PATH_DELETE 0x0002 |
Definition at line 44 of file jsonfuncs.c.
#define JB_PATH_FILL_GAPS 0x0020 |
Definition at line 50 of file jsonfuncs.c.
#define JB_PATH_INSERT_AFTER 0x0010 |
Definition at line 47 of file jsonfuncs.c.
#define JB_PATH_INSERT_BEFORE 0x0008 |
Definition at line 46 of file jsonfuncs.c.
#define JB_PATH_REPLACE 0x0004 |
Definition at line 45 of file jsonfuncs.c.
#define JsObjectFree | ( | jso | ) |
Definition at line 332 of file jsonfuncs.c.
#define JsObjectIsEmpty | ( | jso | ) |
Definition at line 326 of file jsonfuncs.c.
#define JsValueIsNull | ( | jsv | ) |
Definition at line 317 of file jsonfuncs.c.
#define JsValueIsString | ( | jsv | ) |
Definition at line 322 of file jsonfuncs.c.
typedef struct ArrayIOData ArrayIOData |
typedef struct ColumnIOData ColumnIOData |
Definition at line 1 of file jsonfuncs.c.
typedef struct CompositeIOData CompositeIOData |
typedef struct DomainIOData DomainIOData |
typedef struct ElementsState ElementsState |
typedef struct IterateJsonStringValuesState IterateJsonStringValuesState |
typedef struct JHashState JHashState |
typedef struct JsonHashEntry JsonHashEntry |
typedef struct OkeysState OkeysState |
typedef struct PopulateArrayContext PopulateArrayContext |
typedef struct PopulateArrayState PopulateArrayState |
typedef struct PopulateRecordCache PopulateRecordCache |
typedef struct PopulateRecordsetState PopulateRecordsetState |
typedef struct RecordIOData RecordIOData |
Definition at line 1 of file jsonfuncs.c.
typedef struct ScalarIOData ScalarIOData |
typedef struct StripnullState StripnullState |
typedef struct TransformJsonStringValuesState TransformJsonStringValuesState |
enum TypeCat |
Enumerator | |
---|---|
TYPECAT_SCALAR | |
TYPECAT_ARRAY | |
TYPECAT_COMPOSITE | |
TYPECAT_COMPOSITE_DOMAIN | |
TYPECAT_DOMAIN |
Definition at line 198 of file jsonfuncs.c.
|
static |
Definition at line 1919 of file jsonfuncs.c.
References AlenState::count, JSON_SUCCESS, AlenState::lex, and JsonLexContext::lex_level.
Referenced by json_array_length().
|
static |
Definition at line 1891 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JSON_SUCCESS, AlenState::lex, and JsonLexContext::lex_level.
Referenced by json_array_length().
|
static |
Definition at line 1905 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JSON_SUCCESS, AlenState::lex, and JsonLexContext::lex_level.
Referenced by json_array_length().
|
static |
Definition at line 3220 of file jsonfuncs.c.
References data, InvalidOid, MemoryContextAlloc(), and MemSet.
Referenced by populate_record().
|
static |
Definition at line 2159 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JSON_SUCCESS, EachState::lex, and JsonLexContext::lex_level.
Referenced by each_worker().
|
static |
Definition at line 2111 of file jsonfuncs.c.
References cstring_to_text_with_len(), CStringGetTextDatum, heap_form_tuple(), JSON_SUCCESS, len, EachState::lex, JsonLexContext::lex_level, MemoryContextReset(), MemoryContextSwitchTo(), EachState::next_scalar, EachState::normalize_results, EachState::normalized_scalar, PointerGetDatum(), JsonLexContext::prev_token_terminator, EachState::result_start, EachState::ret_tdesc, EachState::tmp_cxt, EachState::tuple_store, tuplestore_puttuple(), val, and values.
Referenced by each_worker().
|
static |
Definition at line 2089 of file jsonfuncs.c.
References JSON_SUCCESS, JSON_TOKEN_STRING, EachState::lex, JsonLexContext::lex_level, EachState::next_scalar, EachState::normalize_results, EachState::result_start, JsonLexContext::token_start, and JsonLexContext::token_type.
Referenced by each_worker().
|
static |
Definition at line 2173 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JSON_SUCCESS, EachState::lex, JsonLexContext::lex_level, EachState::next_scalar, EachState::normalized_scalar, and token.
Referenced by each_worker().
|
static |
Definition at line 2049 of file jsonfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, JsonSemAction::array_start, CurrentMemoryContext, each_array_start(), each_object_field_end(), each_object_field_start(), each_scalar(), InitMaterializedSRF(), makeJsonLexContext(), MAT_SRF_BLESS, MemoryContextDelete(), JsonSemAction::object_field_end, JsonSemAction::object_field_start, palloc0(), PG_GETARG_TEXT_PP, pg_parse_json_or_ereport, PG_RETURN_NULL, FunctionCallInfoBaseData::resultinfo, JsonSemAction::scalar, JsonSemAction::semstate, ReturnSetInfo::setDesc, and ReturnSetInfo::setResult.
Referenced by json_each(), and json_each_text().
|
static |
Definition at line 1965 of file jsonfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), cstring_to_text_with_len(), CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, funcname, InitMaterializedSRF(), JB_ROOT_IS_OBJECT, jbvNull, JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueAsText(), JsonbValueToJsonb(), sort-test::key, MAT_SRF_BLESS, MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), PG_GETARG_JSONB_P, PG_RETURN_NULL, PointerGetDatum(), FunctionCallInfoBaseData::resultinfo, Jsonb::root, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, tuplestore_putvalues(), JsonbValue::type, JsonbValue::val, val, values, WJB_DONE, and WJB_KEY.
Referenced by jsonb_each(), and jsonb_each_text().
|
static |
Definition at line 2361 of file jsonfuncs.c.
References cstring_to_text_with_len(), CStringGetTextDatum, heap_form_tuple(), JSON_SUCCESS, len, ElementsState::lex, JsonLexContext::lex_level, MemoryContextReset(), MemoryContextSwitchTo(), ElementsState::next_scalar, ElementsState::normalize_results, ElementsState::normalized_scalar, PointerGetDatum(), JsonLexContext::prev_token_terminator, ElementsState::result_start, ElementsState::ret_tdesc, ElementsState::tmp_cxt, ElementsState::tuple_store, tuplestore_puttuple(), val, and values.
Referenced by elements_worker().
|
static |
Definition at line 2339 of file jsonfuncs.c.
References JSON_SUCCESS, JSON_TOKEN_STRING, ElementsState::lex, JsonLexContext::lex_level, ElementsState::next_scalar, ElementsState::normalize_results, ElementsState::result_start, JsonLexContext::token_start, and JsonLexContext::token_type.
Referenced by elements_worker().
|
static |
Definition at line 2407 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, ElementsState::function_name, JSON_SUCCESS, ElementsState::lex, and JsonLexContext::lex_level.
Referenced by elements_worker().
|
static |
Definition at line 2422 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, ElementsState::function_name, JSON_SUCCESS, ElementsState::lex, JsonLexContext::lex_level, ElementsState::next_scalar, ElementsState::normalized_scalar, and token.
Referenced by elements_worker().
|
static |
Definition at line 2299 of file jsonfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, JsonSemAction::array_element_end, JsonSemAction::array_element_start, CurrentMemoryContext, elements_array_element_end(), elements_array_element_start(), elements_object_start(), elements_scalar(), funcname, InitMaterializedSRF(), makeJsonLexContext(), MAT_SRF_BLESS, MAT_SRF_USE_EXPECTED_DESC, MemoryContextDelete(), JsonSemAction::object_start, palloc0(), PG_GETARG_TEXT_PP, pg_parse_json_or_ereport, PG_RETURN_NULL, FunctionCallInfoBaseData::resultinfo, JsonSemAction::scalar, JsonSemAction::semstate, ReturnSetInfo::setDesc, and ReturnSetInfo::setResult.
Referenced by json_array_elements(), and json_array_elements_text().
|
static |
Definition at line 2211 of file jsonfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, InitMaterializedSRF(), JB_ROOT_IS_ARRAY, JB_ROOT_IS_SCALAR, jbvNull, JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueAsText(), JsonbValueToJsonb(), MAT_SRF_BLESS, MAT_SRF_USE_EXPECTED_DESC, MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), PG_GETARG_JSONB_P, PG_RETURN_NULL, PointerGetDatum(), FunctionCallInfoBaseData::resultinfo, Jsonb::root, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, tuplestore_putvalues(), JsonbValue::type, val, values, WJB_DONE, and WJB_ELEM.
Referenced by jsonb_array_elements(), and jsonb_array_elements_text().
|
static |
Definition at line 1390 of file jsonfuncs.c.
References GetState::array_cur_index, cstring_to_text_with_len(), JSON_SUCCESS, len, GetState::lex, JsonLexContext::lex_level, GetState::normalize_results, GetState::path_indexes, GetState::pathok, JsonLexContext::prev_token_terminator, GetState::result_start, and GetState::tresult.
Referenced by get_worker().
|
static |
Definition at line 1342 of file jsonfuncs.c.
References GetState::array_cur_index, JSON_SUCCESS, JSON_TOKEN_STRING, GetState::lex, JsonLexContext::lex_level, GetState::next_scalar, GetState::normalize_results, GetState::path_indexes, GetState::pathok, GetState::result_start, JsonLexContext::token_start, JsonLexContext::token_type, and GetState::tresult.
Referenced by get_worker().
|
static |
Definition at line 1324 of file jsonfuncs.c.
References cstring_to_text_with_len(), JSON_SUCCESS, len, GetState::lex, JsonLexContext::lex_level, GetState::npath, JsonLexContext::prev_token_terminator, GetState::result_start, and GetState::tresult.
Referenced by get_worker().
|
static |
Definition at line 1284 of file jsonfuncs.c.
References GetState::array_cur_index, error(), json_count_array_elements(), json_errsave_error(), JSON_SUCCESS, GetState::lex, JsonLexContext::lex_level, GetState::npath, GetState::path_indexes, GetState::result_start, and JsonLexContext::token_start.
Referenced by get_worker().
|
static |
Definition at line 3545 of file jsonfuncs.c.
References JsonSemAction::array_start, CurrentMemoryContext, HASHCTL::entrysize, funcname, GetDatabaseEncoding(), hash_array_start(), HASH_CONTEXT, hash_create(), HASH_ELEM, hash_object_field_end(), hash_object_field_start(), hash_scalar(), HASH_STRINGS, HASHCTL::hcxt, HASHCTL::keysize, len, makeJsonLexContextCstringLen(), NAMEDATALEN, JsonSemAction::object_field_end, JsonSemAction::object_field_start, palloc0(), pg_parse_json_or_ereport, JsonSemAction::scalar, and JsonSemAction::semstate.
Referenced by JsValueToJsObject().
|
static |
Definition at line 1489 of file jsonfuncs.c.
References array_contains_nulls(), deconstruct_array_builtin(), jsonb_get_element(), PG_GETARG_ARRAYTYPE_P, PG_GETARG_JSONB_P, PG_RETURN_DATUM, PG_RETURN_NULL, and res.
Referenced by jsonb_extract_path(), and jsonb_extract_path_text().
|
static |
Definition at line 1168 of file jsonfuncs.c.
References cstring_to_text_with_len(), JSON_SUCCESS, len, GetState::lex, JsonLexContext::lex_level, GetState::npath, JsonLexContext::prev_token_terminator, GetState::result_start, and GetState::tresult.
Referenced by get_worker().
|
static |
Definition at line 1233 of file jsonfuncs.c.
References cstring_to_text_with_len(), JSON_SUCCESS, len, GetState::lex, JsonLexContext::lex_level, GetState::normalize_results, GetState::path_names, GetState::pathok, JsonLexContext::prev_token_terminator, GetState::result_start, and GetState::tresult.
Referenced by get_worker().
|
static |
Definition at line 1186 of file jsonfuncs.c.
References JSON_SUCCESS, JSON_TOKEN_STRING, GetState::lex, JsonLexContext::lex_level, GetState::next_scalar, GetState::normalize_results, GetState::path_names, GetState::pathok, GetState::result_start, JsonLexContext::token_start, JsonLexContext::token_type, and GetState::tresult.
Referenced by get_worker().
|
static |
Definition at line 1149 of file jsonfuncs.c.
References JSON_SUCCESS, GetState::lex, JsonLexContext::lex_level, GetState::npath, GetState::result_start, and JsonLexContext::token_start.
Referenced by get_worker().
|
static |
Definition at line 1014 of file jsonfuncs.c.
References array_contains_nulls(), Assert(), deconstruct_array_builtin(), get_worker(), i, palloc(), PG_GETARG_ARRAYTYPE_P, PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, strtoint(), and TextDatumGetCString.
Referenced by json_extract_path(), and json_extract_path_text().
|
static |
Definition at line 3377 of file jsonfuncs.c.
References PopulateRecordCache::argtype, PopulateRecordCache::c, ereport, errcode(), errmsg(), ERROR, FunctionCallInfoBaseData::flinfo, PopulateRecordCache::fn_mcxt, funcname, get_fn_expr_argtype(), prepare_column_cache(), ColumnIOData::typcat, TYPECAT_COMPOSITE, and TYPECAT_COMPOSITE_DOMAIN.
Referenced by populate_record_worker(), and populate_recordset_worker().
|
static |
Definition at line 3403 of file jsonfuncs.c.
References PopulateRecordCache::argtype, Assert(), CompositeIOData::base_typid, CompositeIOData::base_typmod, PopulateRecordCache::c, ColumnIOData::composite, CreateTupleDescCopy(), ereport, errcode(), errhint(), errmsg(), ERROR, PopulateRecordCache::fn_mcxt, FreeTupleDesc(), funcname, get_call_result_type(), ColumnIOData::io, MemoryContextSwitchTo(), TupleDescData::tdtypeid, TupleDescData::tdtypmod, CompositeIOData::tupdesc, and TYPEFUNC_COMPOSITE.
Referenced by populate_record_worker(), and populate_recordset_worker().
|
static |
Definition at line 1434 of file jsonfuncs.c.
References cstring_to_text(), cstring_to_text_with_len(), JsonLexContext::input, JSON_SUCCESS, JSON_TOKEN_NULL, JSON_TOKEN_STRING, len, GetState::lex, JsonLexContext::lex_level, GetState::next_scalar, GetState::normalize_results, GetState::npath, JsonLexContext::prev_token_terminator, token, and GetState::tresult.
Referenced by get_worker().
|
static |
Definition at line 1093 of file jsonfuncs.c.
References JsonSemAction::array_element_end, JsonSemAction::array_element_start, JsonSemAction::array_end, JsonSemAction::array_start, Assert(), get_array_element_end(), get_array_element_start(), get_array_end(), get_array_start(), get_object_end(), get_object_field_end(), get_object_field_start(), get_object_start(), get_scalar(), makeJsonLexContext(), JsonSemAction::object_end, JsonSemAction::object_field_end, JsonSemAction::object_field_start, JsonSemAction::object_start, palloc(), palloc0(), pg_parse_json_or_ereport, JsonSemAction::scalar, and JsonSemAction::semstate.
Referenced by get_path_all(), json_array_element(), json_array_element_text(), json_object_field(), and json_object_field_text().
|
static |
Definition at line 3657 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JHashState::function_name, JSON_SUCCESS, JHashState::lex, and JsonLexContext::lex_level.
Referenced by get_json_object_as_hash().
|
static |
Definition at line 3606 of file jsonfuncs.c.
References Assert(), JHashState::hash, HASH_ENTER, hash_search(), JSON_SUCCESS, JSON_TOKEN_NULL, len, JHashState::lex, JsonLexContext::lex_level, NAMEDATALEN, palloc(), JsonLexContext::prev_token_terminator, JHashState::save_json_start, JHashState::saved_scalar, JHashState::saved_token_type, JsonHashEntry::type, JsonHashEntry::val, and val.
Referenced by get_json_object_as_hash().
|
static |
Definition at line 3580 of file jsonfuncs.c.
References JSON_SUCCESS, JSON_TOKEN_ARRAY_START, JSON_TOKEN_OBJECT_START, JHashState::lex, JsonLexContext::lex_level, JHashState::save_json_start, JHashState::saved_token_type, JsonLexContext::token_start, and JsonLexContext::token_type.
Referenced by get_json_object_as_hash().
|
static |
Definition at line 3670 of file jsonfuncs.c.
References Assert(), ereport, errcode(), errmsg(), ERROR, JHashState::function_name, JSON_SUCCESS, JHashState::lex, JsonLexContext::lex_level, JHashState::saved_scalar, JHashState::saved_token_type, and token.
Referenced by get_json_object_as_hash().
void iterate_json_values | ( | text * | json, |
uint32 | flags, | ||
void * | action_state, | ||
JsonIterateStringValuesAction | action | ||
) |
Definition at line 5433 of file jsonfuncs.c.
References generate_unaccent_rules::action, iterate_values_object_field_start(), iterate_values_scalar(), makeJsonLexContext(), JsonSemAction::object_field_start, palloc0(), pg_parse_json_or_ereport, JsonSemAction::scalar, and JsonSemAction::semstate.
Referenced by json_to_tsvector_worker().
void iterate_jsonb_values | ( | Jsonb * | jb, |
uint32 | flags, | ||
void * | state, | ||
JsonIterateStringValuesAction | action | ||
) |
Definition at line 5365 of file jsonfuncs.c.
References generate_unaccent_rules::action, DatumGetCString(), DirectFunctionCall1, jbvBool, jbvNumeric, jbvString, JsonbIteratorInit(), JsonbIteratorNext(), jtiBool, jtiKey, jtiNumeric, jtiString, numeric_out(), NumericGetDatum(), pfree(), Jsonb::root, type, JsonbValue::type, JsonbValue::val, val, WJB_DONE, WJB_ELEM, WJB_KEY, and WJB_VALUE.
Referenced by jsonb_to_tsvector_worker().
|
static |
Definition at line 5485 of file jsonfuncs.c.
References IterateJsonStringValuesState::action, IterateJsonStringValuesState::action_state, IterateJsonStringValuesState::flags, JSON_SUCCESS, jtiKey, pstrdup(), and val.
Referenced by iterate_json_values().
|
static |
Definition at line 5457 of file jsonfuncs.c.
References IterateJsonStringValuesState::action, IterateJsonStringValuesState::action_state, IterateJsonStringValuesState::flags, JSON_SUCCESS, JSON_TOKEN_FALSE, JSON_TOKEN_NUMBER, JSON_TOKEN_STRING, JSON_TOKEN_TRUE, jtiBool, jtiNumeric, jtiString, and token.
Referenced by iterate_json_values().
|
static |
Definition at line 4777 of file jsonfuncs.c.
References Assert(), JsonbIteratorNext(), pushJsonbValue(), res, WJB_BEGIN_ARRAY, WJB_BEGIN_OBJECT, WJB_DONE, WJB_ELEM, WJB_END_ARRAY, and WJB_END_OBJECT.
Referenced by jsonb_concat().
Definition at line 3236 of file jsonfuncs.c.
References getKeyJsonValueFromContainer(), HASH_FIND, hash_search(), JsValue::is_json, JsObject::is_json, JsValue::json, JsObject::json_hash, JSON_TOKEN_NULL, JsValue::jsonb, JsObject::jsonb_cont, JsonHashEntry::type, JsonHashEntry::val, JsValue::val, and JsObject::val.
Referenced by populate_record().
Datum json_array_element | ( | PG_FUNCTION_ARGS | ) |
Definition at line 912 of file jsonfuncs.c.
References element(), get_worker(), PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_NULL, and PG_RETURN_TEXT_P.
Datum json_array_element_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 955 of file jsonfuncs.c.
References element(), get_worker(), PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_NULL, and PG_RETURN_TEXT_P.
Datum json_array_elements | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2287 of file jsonfuncs.c.
References elements_worker().
Datum json_array_elements_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2293 of file jsonfuncs.c.
References elements_worker().
Datum json_array_length | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1841 of file jsonfuncs.c.
References alen_array_element_start(), alen_object_start(), alen_scalar(), JsonSemAction::array_element_start, makeJsonLexContext(), JsonSemAction::object_start, palloc0(), PG_GETARG_TEXT_PP, pg_parse_json_or_ereport, PG_RETURN_INT32, JsonSemAction::scalar, and JsonSemAction::semstate.
void json_categorize_type | ( | Oid | typoid, |
bool | is_jsonb, | ||
JsonTypeCategory * | tcategory, | ||
Oid * | outfuncoid | ||
) |
Definition at line 5698 of file jsonfuncs.c.
References COERCION_EXPLICIT, COERCION_PATH_FUNC, find_coercion_pathway(), FirstNormalObjectId, get_element_type(), getBaseType(), getTypeOutputInfo(), InvalidOid, JSONTYPE_ARRAY, JSONTYPE_BOOL, JSONTYPE_CAST, JSONTYPE_COMPOSITE, JSONTYPE_DATE, JSONTYPE_JSON, JSONTYPE_JSONB, JSONTYPE_NUMERIC, JSONTYPE_OTHER, JSONTYPE_TIMESTAMP, JSONTYPE_TIMESTAMPTZ, OidIsValid, and type_is_rowtype().
Referenced by add_json(), add_jsonb(), array_to_json_internal(), array_to_jsonb_internal(), composite_to_json(), composite_to_jsonb(), ExecInitExprRec(), json_agg_transfn_worker(), json_object_agg_transfn_worker(), jsonb_agg_transfn_worker(), jsonb_object_agg_transfn_worker(), to_json(), to_json_is_immutable(), to_jsonb(), and to_jsonb_is_immutable().
Datum json_each | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1941 of file jsonfuncs.c.
References each_worker().
Datum json_each_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1953 of file jsonfuncs.c.
References each_worker().
void json_errsave_error | ( | JsonParseErrorType | error, |
JsonLexContext * | lex, | ||
Node * | escontext | ||
) |
Definition at line 629 of file jsonfuncs.c.
References elog(), errcode(), errdetail_internal(), errmsg(), ERROR, error(), errsave, json_errdetail(), JSON_SEM_ACTION_FAILED, JSON_UNICODE_CODE_POINT_ZERO, JSON_UNICODE_HIGH_ESCAPE, JSON_UNICODE_UNTRANSLATABLE, report_json_context(), and SOFT_ERROR_OCCURRED.
Referenced by get_array_start(), json_get_first_token(), json_typeof(), json_validate(), and pg_parse_json_or_errsave().
Datum json_extract_path | ( | PG_FUNCTION_ARGS | ) |
Definition at line 999 of file jsonfuncs.c.
References get_path_all().
Datum json_extract_path_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1005 of file jsonfuncs.c.
References get_path_all().
JsonTokenType json_get_first_token | ( | text * | json, |
bool | throw_error | ||
) |
Definition at line 5671 of file jsonfuncs.c.
References json_errsave_error(), json_lex(), JSON_SUCCESS, JSON_TOKEN_INVALID, makeJsonLexContext(), and JsonLexContext::token_type.
Referenced by ExecEvalJsonIsPredicate().
Datum json_object_field | ( | PG_FUNCTION_ARGS | ) |
Definition at line 836 of file jsonfuncs.c.
References get_worker(), PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, and text_to_cstring().
Datum json_object_field_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 874 of file jsonfuncs.c.
References get_worker(), PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, and text_to_cstring().
Datum json_object_keys | ( | PG_FUNCTION_ARGS | ) |
Definition at line 720 of file jsonfuncs.c.
References JsonSemAction::array_start, CStringGetTextDatum, StringInfoData::data, if(), makeJsonLexContext(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, JsonSemAction::object_field_start, okeys_array_start(), okeys_object_field_start(), okeys_scalar(), palloc(), palloc0(), pfree(), PG_GETARG_TEXT_PP, pg_parse_json_or_ereport, JsonSemAction::scalar, JsonSemAction::semstate, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, JsonLexContext::strval, and FuncCallContext::user_fctx.
Datum json_populate_record | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2467 of file jsonfuncs.c.
References populate_record_worker().
Datum json_populate_recordset | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3715 of file jsonfuncs.c.
References populate_recordset_worker().
Datum json_strip_nulls | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4216 of file jsonfuncs.c.
References JsonSemAction::array_element_start, JsonSemAction::array_end, JsonSemAction::array_start, cstring_to_text_with_len(), makeJsonLexContext(), makeStringInfo(), JsonSemAction::object_end, JsonSemAction::object_field_start, JsonSemAction::object_start, palloc0(), PG_GETARG_TEXT_PP, pg_parse_json_or_ereport, PG_RETURN_TEXT_P, JsonSemAction::scalar, JsonSemAction::semstate, sn_array_element_start(), sn_array_end(), sn_array_start(), sn_object_end(), sn_object_field_start(), sn_object_start(), and sn_scalar().
Datum json_to_record | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2474 of file jsonfuncs.c.
References populate_record_worker().
Datum json_to_recordset | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3722 of file jsonfuncs.c.
References populate_recordset_worker().
Datum jsonb_array_element | ( | PG_FUNCTION_ARGS | ) |
Definition at line 927 of file jsonfuncs.c.
References element(), getIthJsonbValueFromContainer(), JB_ROOT_COUNT, JB_ROOT_IS_ARRAY, JsonbValueToJsonb(), PG_GETARG_INT32, PG_GETARG_JSONB_P, PG_RETURN_JSONB_P, PG_RETURN_NULL, and Jsonb::root.
Datum jsonb_array_element_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 970 of file jsonfuncs.c.
References element(), getIthJsonbValueFromContainer(), JB_ROOT_COUNT, JB_ROOT_IS_ARRAY, jbvNull, JsonbValueAsText(), PG_GETARG_INT32, PG_GETARG_JSONB_P, PG_RETURN_NULL, PG_RETURN_TEXT_P, Jsonb::root, and JsonbValue::type.
Datum jsonb_array_elements | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2199 of file jsonfuncs.c.
References elements_worker_jsonb().
Datum jsonb_array_elements_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2205 of file jsonfuncs.c.
References elements_worker_jsonb().
Datum jsonb_array_length | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1869 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JB_ROOT_COUNT, JB_ROOT_IS_ARRAY, JB_ROOT_IS_SCALAR, PG_GETARG_JSONB_P, and PG_RETURN_INT32.
Datum jsonb_concat | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4324 of file jsonfuncs.c.
References Assert(), IteratorConcat(), JB_ROOT_COUNT, JB_ROOT_IS_OBJECT, JB_ROOT_IS_SCALAR, JsonbIteratorInit(), JsonbValueToJsonb(), PG_GETARG_JSONB_P, PG_RETURN_JSONB_P, res, and Jsonb::root.
Datum jsonb_delete | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4365 of file jsonfuncs.c.
References Assert(), ereport, errcode(), errmsg(), ERROR, JB_ROOT_COUNT, JB_ROOT_IS_SCALAR, jbvString, JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueToJsonb(), sort-test::key, PG_GETARG_JSONB_P, PG_GETARG_TEXT_PP, PG_RETURN_JSONB_P, pushJsonbValue(), res, Jsonb::root, JsonbValue::type, JsonbValue::val, VARDATA_ANY, VARSIZE_ANY_EXHDR, WJB_BEGIN_ARRAY, WJB_DONE, WJB_ELEM, and WJB_KEY.
Datum jsonb_delete_array | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4418 of file jsonfuncs.c.
References ARR_NDIM, Assert(), deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, i, JB_ROOT_COUNT, JB_ROOT_IS_SCALAR, jbvString, JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueToJsonb(), PG_GETARG_ARRAYTYPE_P, PG_GETARG_JSONB_P, PG_RETURN_JSONB_P, pushJsonbValue(), res, Jsonb::root, JsonbValue::type, JsonbValue::val, VARDATA_ANY, VARSIZE_ANY_EXHDR, WJB_BEGIN_ARRAY, WJB_DONE, WJB_ELEM, and WJB_KEY.
Datum jsonb_delete_idx | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4505 of file jsonfuncs.c.
References Assert(), ereport, errcode(), errmsg(), ERROR, i, idx(), JB_ROOT_COUNT, JB_ROOT_IS_OBJECT, JB_ROOT_IS_SCALAR, JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueToJsonb(), PG_GETARG_INT32, PG_GETARG_JSONB_P, PG_RETURN_JSONB_P, pushJsonbValue(), res, Jsonb::root, JsonbValue::val, WJB_BEGIN_ARRAY, WJB_DONE, and WJB_ELEM.
Datum jsonb_delete_path | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4685 of file jsonfuncs.c.
References ARR_NDIM, Assert(), deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, JB_PATH_DELETE, JB_ROOT_COUNT, JB_ROOT_IS_SCALAR, JsonbIteratorInit(), JsonbValueToJsonb(), PG_GETARG_ARRAYTYPE_P, PG_GETARG_JSONB_P, PG_RETURN_JSONB_P, res, Jsonb::root, and setPath().
Referenced by jsonb_set_lax().
Datum jsonb_each | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1947 of file jsonfuncs.c.
References each_worker_jsonb().
Datum jsonb_each_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1959 of file jsonfuncs.c.
References each_worker_jsonb().
Datum jsonb_extract_path | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1477 of file jsonfuncs.c.
References get_jsonb_path_all().
Datum jsonb_extract_path_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1483 of file jsonfuncs.c.
References get_jsonb_path_all().
Definition at line 1520 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_insert | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4728 of file jsonfuncs.c.
References ARR_NDIM, Assert(), deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, JB_PATH_INSERT_AFTER, JB_PATH_INSERT_BEFORE, JB_ROOT_IS_SCALAR, JsonbIteratorInit(), JsonbToJsonbValue(), JsonbValueToJsonb(), newval, PG_GETARG_ARRAYTYPE_P, PG_GETARG_BOOL, PG_GETARG_JSONB_P, PG_RETURN_JSONB_P, res, Jsonb::root, and setPath().
Datum jsonb_object_field | ( | PG_FUNCTION_ARGS | ) |
Definition at line 852 of file jsonfuncs.c.
References getKeyJsonValueFromContainer(), JB_ROOT_IS_OBJECT, JsonbValueToJsonb(), sort-test::key, PG_GETARG_JSONB_P, PG_GETARG_TEXT_PP, PG_RETURN_JSONB_P, PG_RETURN_NULL, Jsonb::root, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum jsonb_object_field_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 890 of file jsonfuncs.c.
References getKeyJsonValueFromContainer(), JB_ROOT_IS_OBJECT, jbvNull, JsonbValueAsText(), sort-test::key, PG_GETARG_JSONB_P, PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, Jsonb::root, JsonbValue::type, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum jsonb_object_keys | ( | PG_FUNCTION_ARGS | ) |
Definition at line 556 of file jsonfuncs.c.
References CStringGetTextDatum, ereport, errcode(), errmsg(), ERROR, if(), JB_ROOT_COUNT, JB_ROOT_IS_ARRAY, JB_ROOT_IS_SCALAR, JsonbIteratorInit(), JsonbIteratorNext(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, palloc(), PG_GETARG_JSONB_P, Jsonb::root, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, FuncCallContext::user_fctx, JsonbValue::val, WJB_DONE, and WJB_KEY.
Datum jsonb_populate_record | ( | PG_FUNCTION_ARGS | ) |
Datum jsonb_populate_recordset | ( | PG_FUNCTION_ARGS | ) |
Datum jsonb_pretty | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4308 of file jsonfuncs.c.
References cstring_to_text_with_len(), JsonbToCStringIndent(), makeStringInfo(), PG_GETARG_JSONB_P, PG_RETURN_TEXT_P, Jsonb::root, generate_unaccent_rules::str, and VARSIZE.
Datum jsonb_set | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4569 of file jsonfuncs.c.
References ARR_NDIM, Assert(), deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, JB_PATH_CREATE, JB_PATH_REPLACE, JB_ROOT_COUNT, JB_ROOT_IS_SCALAR, JsonbIteratorInit(), JsonbToJsonbValue(), JsonbValueToJsonb(), newval, PG_GETARG_ARRAYTYPE_P, PG_GETARG_BOOL, PG_GETARG_JSONB_P, PG_RETURN_JSONB_P, res, Jsonb::root, and setPath().
Referenced by jsonb_set_lax().
Datum jsonb_set_element | ( | Jsonb * | jb, |
Datum * | path, | ||
int | path_len, | ||
JsonbValue * | newval | ||
) |
Definition at line 1668 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().
Datum jsonb_set_lax | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4618 of file jsonfuncs.c.
References CStringGetDatum(), DirectFunctionCall1, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, jsonb_delete_path(), jsonb_in(), jsonb_set(), newval, PG_ARGISNULL, PG_GETARG_JSONB_P, PG_GETARG_TEXT_P, PG_RETURN_JSONB_P, PG_RETURN_NULL, and text_to_cstring().
Datum jsonb_strip_nulls | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4250 of file jsonfuncs.c.
References Assert(), JB_ROOT_IS_SCALAR, jbvNull, JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueToJsonb(), PG_GETARG_JSONB_P, PG_RETURN_POINTER, pushJsonbValue(), res, Jsonb::root, type, JsonbValue::type, WJB_DONE, WJB_ELEM, WJB_KEY, and WJB_VALUE.
Datum jsonb_to_record | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2460 of file jsonfuncs.c.
References populate_record_worker().
Datum jsonb_to_recordset | ( | PG_FUNCTION_ARGS | ) |
|
static |
Definition at line 1794 of file jsonfuncs.c.
References cstring_to_text(), cstring_to_text_with_len(), StringInfoData::data, DatumGetCString(), DirectFunctionCall1, elog(), ERROR, initStringInfo(), jbvBinary, jbvBool, jbvNull, jbvNumeric, jbvString, JsonbToCString(), StringInfoData::len, numeric_out(), PointerGetDatum(), JsonbValue::type, and JsonbValue::val.
Referenced by each_worker_jsonb(), elements_worker_jsonb(), jsonb_array_element_text(), jsonb_get_element(), and jsonb_object_field_text().
Definition at line 2849 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, get_json_object_as_hash(), JsValue::is_json, JsObject::is_json, IsAJsonbScalar, jbvBinary, JsValue::json, JsObject::json_hash, JsValue::jsonb, JsObject::jsonb_cont, JsonContainerIsObject, JsonContainerIsScalar, JsonbValue::type, JsValue::val, JsObject::val, and JsonbValue::val.
Referenced by populate_composite().
JsonLexContext* makeJsonLexContext | ( | text * | json, |
bool | need_escapes | ||
) |
Definition at line 529 of file jsonfuncs.c.
References GetDatabaseEncoding(), makeJsonLexContextCstringLen(), pg_detoast_datum_packed(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by datum_to_jsonb_internal(), each_worker(), elements_worker(), get_worker(), iterate_json_values(), json_array_length(), json_get_first_token(), json_in(), json_object_keys(), json_strip_nulls(), json_typeof(), json_validate(), populate_recordset_worker(), and transform_json_string_values().
|
static |
Definition at line 799 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JSON_SUCCESS, OkeysState::lex, and JsonLexContext::lex_level.
Referenced by json_object_keys().
|
static |
Definition at line 776 of file jsonfuncs.c.
References JSON_SUCCESS, OkeysState::lex, JsonLexContext::lex_level, pstrdup(), repalloc(), OkeysState::result, OkeysState::result_count, and OkeysState::result_size.
Referenced by json_object_keys().
|
static |
Definition at line 814 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JSON_SUCCESS, OkeysState::lex, and JsonLexContext::lex_level.
Referenced by json_object_keys().
Definition at line 5297 of file jsonfuncs.c.
References elog(), ereport, errcode(), errhint(), errmsg(), ERROR, jbvString, JsonbIteratorInit(), JsonbIteratorNext(), jtiAll, jtiBool, jtiKey, jtiNumeric, jtiString, pg_strncasecmp(), pnstrdup(), Jsonb::root, type, JsonbValue::type, JsonbValue::val, WJB_BEGIN_ARRAY, WJB_DONE, WJB_ELEM, and WJB_END_ARRAY.
Referenced by json_to_tsvector(), json_to_tsvector_byid(), jsonb_to_tsvector(), and jsonb_to_tsvector_byid().
bool pg_parse_json_or_errsave | ( | JsonLexContext * | lex, |
JsonSemAction * | sem, | ||
Node * | escontext | ||
) |
Definition at line 508 of file jsonfuncs.c.
References json_errsave_error(), JSON_SUCCESS, and pg_parse_json().
Referenced by json_in(), and jsonb_from_cstring().
|
static |
Definition at line 2802 of file jsonfuncs.c.
References PopulateArrayContext::acxt, PopulateArrayContext::aio, Assert(), PopulateArrayContext::astate, PopulateArrayContext::colname, CurrentMemoryContext, PopulateArrayContext::dims, ArrayIOData::element_type, i, initArrayResult(), JsValue::is_json, JsValue::json, JsValue::jsonb, makeMdArrayResult(), PopulateArrayContext::mcxt, PopulateArrayContext::ndims, palloc(), pfree(), populate_array_dim_jsonb(), populate_array_json(), PopulateArrayContext::sizes, and JsValue::val.
Referenced by populate_record_field().
|
static |
Definition at line 2602 of file jsonfuncs.c.
References JSON_SUCCESS, PopulateArrayContext::ndims, populate_array_assign_ndims(), and populate_array_check_dimension().
Referenced by populate_array_json().
|
static |
Definition at line 2525 of file jsonfuncs.c.
References Assert(), PopulateArrayContext::dims, i, PopulateArrayContext::ndims, palloc(), palloc0(), populate_array_report_expected_array(), and PopulateArrayContext::sizes.
Referenced by populate_array_array_end(), populate_array_dim_jsonb(), populate_array_object_start(), and populate_array_scalar().
|
static |
Definition at line 2544 of file jsonfuncs.c.
References PopulateArrayContext::dims, ereport, errcode(), errdetail(), errmsg(), ERROR, and PopulateArrayContext::sizes.
Referenced by populate_array_array_end(), and populate_array_dim_jsonb().
|
static |
Definition at line 2731 of file jsonfuncs.c.