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 "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 49 of file jsonfuncs.c.
Referenced by jsonb_set_element(), and setPathArray().
#define JB_PATH_CREATE 0x0001 |
Definition at line 41 of file jsonfuncs.c.
Referenced by jsonb_set(), jsonb_set_element(), and setPathArray().
#define JB_PATH_CREATE_OR_INSERT (JB_PATH_INSERT_BEFORE | JB_PATH_INSERT_AFTER | JB_PATH_CREATE) |
Definition at line 46 of file jsonfuncs.c.
Referenced by setPathArray(), and setPathObject().
#define JB_PATH_DELETE 0x0002 |
Definition at line 42 of file jsonfuncs.c.
Referenced by jsonb_delete_path(), and setPathObject().
#define JB_PATH_FILL_GAPS 0x0020 |
Definition at line 48 of file jsonfuncs.c.
Referenced by jsonb_set_element(), setPath(), setPathArray(), and setPathObject().
#define JB_PATH_INSERT_AFTER 0x0010 |
Definition at line 45 of file jsonfuncs.c.
Referenced by jsonb_insert(), setPathArray(), and setPathObject().
#define JB_PATH_INSERT_BEFORE 0x0008 |
Definition at line 44 of file jsonfuncs.c.
Referenced by jsonb_insert(), setPathArray(), and setPathObject().
#define JB_PATH_REPLACE 0x0004 |
Definition at line 43 of file jsonfuncs.c.
Referenced by jsonb_set(), and setPathArray().
#define JsObjectFree | ( | jso | ) |
Definition at line 330 of file jsonfuncs.c.
Referenced by populate_composite().
#define JsObjectIsEmpty | ( | jso | ) |
Definition at line 324 of file jsonfuncs.c.
Referenced by populate_record().
#define JsValueIsNull | ( | jsv | ) |
Definition at line 315 of file jsonfuncs.c.
Referenced by populate_record_field().
#define JsValueIsString | ( | jsv | ) |
Definition at line 320 of file jsonfuncs.c.
Referenced by populate_record_field().
typedef struct ArrayIOData ArrayIOData |
typedef struct ColumnIOData ColumnIOData |
Definition at line 159 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 160 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 196 of file jsonfuncs.c.
|
static |
Definition at line 1862 of file jsonfuncs.c.
References AlenState::count, AlenState::lex, and JsonLexContext::lex_level.
Referenced by json_array_length().
|
static |
Definition at line 1838 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, AlenState::lex, and JsonLexContext::lex_level.
Referenced by json_array_length().
|
static |
Definition at line 1850 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, AlenState::lex, and JsonLexContext::lex_level.
Referenced by json_array_length().
|
static |
Definition at line 3249 of file jsonfuncs.c.
References RecordIOData::columns, InvalidOid, MemoryContextAlloc(), MemSet, RecordIOData::ncolumns, offsetof, RecordIOData::record_type, and RecordIOData::record_typmod.
Referenced by populate_record().
|
static |
Definition at line 2154 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, EachState::lex, and JsonLexContext::lex_level.
Referenced by each_worker().
|
static |
Definition at line 2108 of file jsonfuncs.c.
References cstring_to_text_with_len(), CStringGetTextDatum, heap_form_tuple(), 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 2088 of file jsonfuncs.c.
References 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 2166 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, EachState::lex, JsonLexContext::lex_level, EachState::next_scalar, and EachState::normalized_scalar.
Referenced by each_worker().
|
static |
Definition at line 2024 of file jsonfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ReturnSetInfo::allowedModes, JsonSemAction::array_start, BlessTupleDesc(), CreateTupleDescCopy(), CurrentMemoryContext, each_array_start(), each_object_field_end(), each_object_field_start(), each_scalar(), ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errmsg(), ERROR, ReturnSetInfo::expectedDesc, get_call_result_type(), IsA, OkeysState::lex, EachState::lex, makeJsonLexContext(), MemoryContextDelete(), MemoryContextSwitchTo(), EachState::next_scalar, EachState::normalize_results, JsonSemAction::object_field_end, JsonSemAction::object_field_start, palloc0(), PG_GETARG_TEXT_PP, pg_parse_json_or_ereport(), PG_RETURN_NULL, FunctionCallInfoBaseData::resultinfo, EachState::ret_tdesc, ReturnSetInfo::returnMode, JsonSemAction::scalar, JsonSemAction::semstate, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Random, EachState::tmp_cxt, EachState::tuple_store, tuplestore_begin_heap(), and work_mem.
Referenced by json_each(), and json_each_text().
|
static |
Definition at line 1906 of file jsonfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ReturnSetInfo::allowedModes, Assert, BlessTupleDesc(), CreateTupleDescCopy(), cstring_to_text_with_len(), CurrentMemoryContext, ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errmsg(), ERROR, ReturnSetInfo::expectedDesc, get_call_result_type(), heap_form_tuple(), IsA, JB_ROOT_IS_OBJECT, jbvNull, JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueAsText(), JsonbValueToJsonb(), sort-test::key, MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), PG_GETARG_JSONB_P, PG_RETURN_NULL, PointerGetDatum, FunctionCallInfoBaseData::resultinfo, ReturnSetInfo::returnMode, Jsonb::root, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Random, tuplestore_begin_heap(), tuplestore_puttuple(), JsonbValue::type, TYPEFUNC_COMPOSITE, JsonbValue::val, val, values, WJB_DONE, WJB_KEY, and work_mem.
Referenced by jsonb_each(), and jsonb_each_text().
|
static |
Definition at line 2406 of file jsonfuncs.c.
References cstring_to_text_with_len(), CStringGetTextDatum, heap_form_tuple(), 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 2386 of file jsonfuncs.c.
References 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 2450 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, ElementsState::function_name, ElementsState::lex, and JsonLexContext::lex_level.
Referenced by elements_worker().
|
static |
Definition at line 2463 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, ElementsState::function_name, ElementsState::lex, JsonLexContext::lex_level, ElementsState::next_scalar, and ElementsState::normalized_scalar.
Referenced by elements_worker().
|
static |
Definition at line 2320 of file jsonfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ReturnSetInfo::allowedModes, JsonSemAction::array_element_end, JsonSemAction::array_element_start, BlessTupleDesc(), CreateTupleDescCopy(), CurrentMemoryContext, ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, elements_array_element_end(), elements_array_element_start(), elements_object_start(), elements_scalar(), ereport, errcode(), errmsg(), ERROR, ReturnSetInfo::expectedDesc, ElementsState::function_name, IsA, OkeysState::lex, ElementsState::lex, makeJsonLexContext(), MemoryContextDelete(), MemoryContextSwitchTo(), ElementsState::next_scalar, ElementsState::normalize_results, JsonSemAction::object_start, palloc0(), PG_GETARG_TEXT_PP, pg_parse_json_or_ereport(), PG_RETURN_NULL, FunctionCallInfoBaseData::resultinfo, ElementsState::ret_tdesc, ReturnSetInfo::returnMode, JsonSemAction::scalar, JsonSemAction::semstate, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Random, ElementsState::tmp_cxt, ElementsState::tuple_store, tuplestore_begin_heap(), and work_mem.
Referenced by json_array_elements(), and json_array_elements_text().
|
static |
Definition at line 2202 of file jsonfuncs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ReturnSetInfo::allowedModes, BlessTupleDesc(), CreateTupleDescCopy(), CurrentMemoryContext, ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errmsg(), ERROR, ReturnSetInfo::expectedDesc, heap_form_tuple(), IsA, JB_ROOT_IS_ARRAY, JB_ROOT_IS_SCALAR, jbvNull, JsonbIteratorInit(), JsonbIteratorNext(), JsonbValueAsText(), JsonbValueToJsonb(), MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), PG_GETARG_JSONB_P, PG_RETURN_NULL, PointerGetDatum, FunctionCallInfoBaseData::resultinfo, ReturnSetInfo::returnMode, Jsonb::root, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Random, tuplestore_begin_heap(), tuplestore_puttuple(), JsonbValue::type, val, values, WJB_DONE, WJB_ELEM, and work_mem.
Referenced by jsonb_array_elements(), and jsonb_array_elements_text().
|
static |
Definition at line 1342 of file jsonfuncs.c.
References GetState::array_cur_index, cstring_to_text_with_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 1296 of file jsonfuncs.c.
References GetState::array_cur_index, 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 1280 of file jsonfuncs.c.
References cstring_to_text_with_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 1242 of file jsonfuncs.c.
References GetState::array_cur_index, error(), json_count_array_elements(), json_ereport_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 3574 of file jsonfuncs.c.
References JsonSemAction::array_start, CurrentMemoryContext, HASHCTL::entrysize, JHashState::function_name, GetDatabaseEncoding(), JHashState::hash, 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, OkeysState::lex, JHashState::lex, 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 1437 of file jsonfuncs.c.
References array_contains_nulls(), deconstruct_array(), jsonb_get_element(), PG_GETARG_ARRAYTYPE_P, PG_GETARG_JSONB_P, PG_RETURN_DATUM, and PG_RETURN_NULL.
Referenced by jsonb_extract_path(), and jsonb_extract_path_text().
|
static |
Definition at line 1132 of file jsonfuncs.c.
References cstring_to_text_with_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 1193 of file jsonfuncs.c.
References cstring_to_text_with_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 1148 of file jsonfuncs.c.
References 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 1115 of file jsonfuncs.c.
References GetState::lex, JsonLexContext::lex_level, GetState::npath, GetState::result_start, and JsonLexContext::token_start.
Referenced by get_worker().
|
static |
Definition at line 979 of file jsonfuncs.c.
References array_contains_nulls(), Assert, deconstruct_array(), get_worker(), i, palloc(), PG_GETARG_ARRAYTYPE_P, PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, OkeysState::result, strtoint(), and TextDatumGetCString.
Referenced by json_extract_path(), and json_extract_path_text().
|
static |
Definition at line 3406 of file jsonfuncs.c.
References PopulateRecordCache::argtype, PopulateRecordCache::c, ereport, errcode(), errmsg(), ERROR, FunctionCallInfoBaseData::flinfo, PopulateRecordCache::fn_mcxt, 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 3432 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(), 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 1384 of file jsonfuncs.c.
References cstring_to_text(), cstring_to_text_with_len(), JsonLexContext::input, JSON_TOKEN_NULL, JSON_TOKEN_STRING, GetState::lex, JsonLexContext::lex_level, GetState::next_scalar, GetState::normalize_results, GetState::npath, JsonLexContext::prev_token_terminator, and GetState::tresult.
Referenced by get_worker().
|
static |
Definition at line 1059 of file jsonfuncs.c.
References GetState::array_cur_index, 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(), OkeysState::lex, GetState::lex, makeJsonLexContext(), GetState::normalize_results, GetState::npath, JsonSemAction::object_end, JsonSemAction::object_field_end, JsonSemAction::object_field_start, JsonSemAction::object_start, palloc(), palloc0(), GetState::path_indexes, GetState::path_names, GetState::pathok, pg_parse_json_or_ereport(), JsonSemAction::scalar, JsonSemAction::semstate, and GetState::tresult.
Referenced by get_path_all(), json_array_element(), json_array_element_text(), json_object_field(), and json_object_field_text().
|
static |
Definition at line 3682 of file jsonfuncs.c.
References ereport, errcode(), errmsg(), ERROR, JHashState::function_name, JHashState::lex, and JsonLexContext::lex_level.
Referenced by get_json_object_as_hash().
|
static |
Definition at line 3633 of file jsonfuncs.c.
References Assert, JHashState::hash, HASH_ENTER, hash_search(), JSON_TOKEN_NULL, 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 3609 of file jsonfuncs.c.
References 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 3693 of file jsonfuncs.c.
References Assert, ereport, errcode(), errmsg(), ERROR, JHashState::function_name, JHashState::lex, JsonLexContext::lex_level, JHashState::saved_scalar, and JHashState::saved_token_type.
Referenced by get_json_object_as_hash().
void iterate_json_values | ( | text * | json, |
uint32 | flags, | ||
void * | action_state, | ||
JsonIterateStringValuesAction | action | ||
) |
Definition at line 5422 of file jsonfuncs.c.
References IterateJsonStringValuesState::action, generate_unaccent_rules::action, IterateJsonStringValuesState::action_state, IterateJsonStringValuesState::flags, iterate_values_object_field_start(), iterate_values_scalar(), OkeysState::lex, IterateJsonStringValuesState::lex, 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 5354 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, JsonbValue::type, generate_unaccent_rules::type, JsonbValue::val, val, WJB_DONE, WJB_ELEM, WJB_KEY, and WJB_VALUE.
Referenced by jsonb_to_tsvector_worker().
|
static |
Definition at line 5472 of file jsonfuncs.c.
References IterateJsonStringValuesState::action, IterateJsonStringValuesState::action_state, IterateJsonStringValuesState::flags, jtiKey, pstrdup(), and val.
Referenced by iterate_json_values().
|
static |
Definition at line 5446 of file jsonfuncs.c.
References IterateJsonStringValuesState::action, IterateJsonStringValuesState::action_state, IterateJsonStringValuesState::flags, JSON_TOKEN_FALSE, JSON_TOKEN_NUMBER, JSON_TOKEN_STRING, JSON_TOKEN_TRUE, jtiBool, jtiNumeric, and jtiString.
Referenced by iterate_json_values().
|
static |
Definition at line 4772 of file jsonfuncs.c.
References Assert, JsonbIteratorNext(), pushJsonbValue(), WJB_BEGIN_ARRAY, WJB_BEGIN_OBJECT, WJB_DONE, WJB_ELEM, WJB_END_ARRAY, and WJB_END_OBJECT.
Referenced by jsonb_concat().
Definition at line 3265 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 877 of file jsonfuncs.c.
References element(), get_worker(), PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, and OkeysState::result.
Datum json_array_element_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 920 of file jsonfuncs.c.
References element(), get_worker(), PG_GETARG_INT32, PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, and OkeysState::result.
Datum json_array_elements | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2308 of file jsonfuncs.c.
References elements_worker().
Datum json_array_elements_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2314 of file jsonfuncs.c.
References elements_worker().
Datum json_array_length | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1788 of file jsonfuncs.c.
References alen_array_element_start(), alen_object_start(), alen_scalar(), JsonSemAction::array_element_start, AlenState::count, OkeysState::lex, AlenState::lex, makeJsonLexContext(), JsonSemAction::object_start, palloc0(), PG_GETARG_TEXT_PP, pg_parse_json_or_ereport(), PG_RETURN_INT32, JsonSemAction::scalar, and JsonSemAction::semstate.
Datum json_each | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1882 of file jsonfuncs.c.
References each_worker().
Datum json_each_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1894 of file jsonfuncs.c.
References each_worker().
void json_ereport_error | ( | JsonParseErrorType | error, |
JsonLexContext * | lex | ||
) |
Definition at line 611 of file jsonfuncs.c.
References ereport, errcode(), errdetail(), errmsg(), ERROR, json_errdetail(), JSON_UNICODE_CODE_POINT_ZERO, JSON_UNICODE_HIGH_ESCAPE, and report_json_context().
Referenced by get_array_start(), json_typeof(), and pg_parse_json_or_ereport().
Datum json_extract_path | ( | PG_FUNCTION_ARGS | ) |
Definition at line 964 of file jsonfuncs.c.
References get_path_all().
Datum json_extract_path_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 970 of file jsonfuncs.c.
References get_path_all().
Datum json_object_field | ( | PG_FUNCTION_ARGS | ) |
Definition at line 801 of file jsonfuncs.c.
References get_worker(), PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, OkeysState::result, and text_to_cstring().
Datum json_object_field_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 839 of file jsonfuncs.c.
References get_worker(), PG_GETARG_TEXT_PP, PG_RETURN_NULL, PG_RETURN_TEXT_P, OkeysState::result, and text_to_cstring().
Datum json_object_keys | ( | PG_FUNCTION_ARGS | ) |
Definition at line 691 of file jsonfuncs.c.
References JsonSemAction::array_start, CStringGetTextDatum, StringInfoData::data, OkeysState::lex, 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(), OkeysState::result, OkeysState::result_count, OkeysState::result_size, JsonSemAction::scalar, JsonSemAction::semstate, OkeysState::sent_count, 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 2506 of file jsonfuncs.c.
References populate_record_worker().
Datum json_populate_recordset | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3736 of file jsonfuncs.c.
References populate_recordset_worker().
Datum json_strip_nulls | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4207 of file jsonfuncs.c.
References JsonSemAction::array_element_start, JsonSemAction::array_end, JsonSemAction::array_start, cstring_to_text_with_len(), StringInfoData::data, StringInfoData::len, OkeysState::lex, StripnullState::lex, 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, StripnullState::skip_next_null, sn_array_element_start(), sn_array_end(), sn_array_start(), sn_object_end(), sn_object_field_start(), sn_object_start(), sn_scalar(), and StripnullState::strval.
Datum json_to_record | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2513 of file jsonfuncs.c.
References populate_record_worker().
Datum json_to_recordset | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3743 of file jsonfuncs.c.
References populate_recordset_worker().
Datum jsonb_array_element | ( | PG_FUNCTION_ARGS | ) |
Definition at line 892 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 935 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 2190 of file jsonfuncs.c.
References elements_worker_jsonb().
Datum jsonb_array_elements_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2196 of file jsonfuncs.c.
References elements_worker_jsonb().
Datum jsonb_array_length | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1816 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 4316 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, and Jsonb::root.
Datum jsonb_delete | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4357 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(), 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 4410 of file jsonfuncs.c.
References ARR_NDIM, Assert, deconstruct_array(), 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(), 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 4497 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(), Jsonb::root, JsonbValue::val, WJB_BEGIN_ARRAY, WJB_DONE, and WJB_ELEM.
Datum jsonb_delete_path | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4678 of file jsonfuncs.c.
References ARR_NDIM, Assert, deconstruct_array(), 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, Jsonb::root, and setPath().
Referenced by jsonb_set_lax().
Datum jsonb_each | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1888 of file jsonfuncs.c.
References each_worker_jsonb().
Datum jsonb_each_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1900 of file jsonfuncs.c.
References each_worker_jsonb().
Datum jsonb_extract_path | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1425 of file jsonfuncs.c.
References get_jsonb_path_all().
Datum jsonb_extract_path_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1431 of file jsonfuncs.c.
References get_jsonb_path_all().
Definition at line 1469 of file jsonfuncs.c.
References Assert, cstring_to_text(), 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, Jsonb::root, strtoint(), TextDatumGetCString, JsonbValue::type, JsonbValue::val, VARDATA, VARHDRSZ, and VARSIZE.
Referenced by get_jsonb_path_all(), jsonb_subscript_fetch(), and jsonb_subscript_fetch_old().
Datum jsonb_insert | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4722 of file jsonfuncs.c.
References ARR_NDIM, Assert, deconstruct_array(), 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, Jsonb::root, and setPath().