PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/detoast.h"
#include "access/heaptoast.h"
#include "access/htup_details.h"
#include "catalog/heap.h"
#include "catalog/pg_type.h"
#include "utils/builtins.h"
#include "utils/datum.h"
#include "utils/expandedrecord.h"
#include "utils/memutils.h"
#include "utils/typcache.h"
Go to the source code of this file.
Variables | |
static const ExpandedObjectMethods | ER_methods |
|
static |
Definition at line 1402 of file expandedrecord.c.
References chunk, ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ExpandedObjectHeader::eoh_context, EOH_init_header(), ExpandedRecordHeader::er_decltypeid, ExpandedRecordHeader::er_dummy_header, ER_FLAG_IS_DUMMY, ER_MAGIC, ExpandedRecordHeader::er_magic, ER_methods, ExpandedRecordHeader::er_short_term_cxt, ExpandedRecordHeader::er_tupdesc, ExpandedRecordHeader::er_tupdesc_id, ExpandedRecordHeader::er_typeid, ExpandedRecordHeader::er_typmod, expanded_record_get_tupdesc(), ExpandedRecordHeader::fendptr, ExpandedRecordHeader::flags, ExpandedRecordHeader::flat_size, ExpandedRecordHeader::fstartptr, ExpandedRecordHeader::fvalue, get_short_term_cxt(), ExpandedRecordHeader::hdr, MAXALIGN, MemoryContextAlloc(), TupleDescData::natts, and ExpandedRecordHeader::nfields.
Referenced by check_domain_for_new_field(), and check_domain_for_new_tuple().
|
static |
Definition at line 1494 of file expandedrecord.c.
References build_dummy_expanded_header(), DatumGetPointer(), deconstruct_expanded_record(), ExpandedRecordHeader::dnulls, domain_check(), ExpandedRecordHeader::dvalues, elog, ExpandedObjectHeader::eoh_context, ExpandedRecordHeader::er_decltypeid, ExpandedRecordHeader::er_domaininfo, ExpandedRecordHeader::er_dummy_header, ER_FLAG_DVALUES_VALID, ER_FLAG_HAVE_EXTERNAL, ExpandedRecordHeader::er_short_term_cxt, ExpandedRecordHeader::er_tupdesc, ERROR, ExpandedRecordGetRODatum(), ExpandedRecordIsEmpty, ExpandedRecordHeader::flags, ExpandedRecordHeader::hdr, MemoryContextReset(), MemoryContextSwitchTo(), ExpandedRecordHeader::nfields, TupleDescAttr, unlikely, and VARATT_IS_EXTERNAL.
Referenced by expanded_record_set_field_internal().
|
static |
Definition at line 1576 of file expandedrecord.c.
References build_dummy_expanded_header(), domain_check(), ExpandedObjectHeader::eoh_context, ExpandedRecordHeader::er_decltypeid, ExpandedRecordHeader::er_domaininfo, ExpandedRecordHeader::er_dummy_header, ER_FLAG_FVALUE_VALID, ER_FLAG_HAVE_EXTERNAL, ExpandedRecordHeader::er_short_term_cxt, ExpandedRecordGetRODatum(), ExpandedRecordHeader::fendptr, ExpandedRecordHeader::flags, ExpandedRecordHeader::fstartptr, ExpandedRecordHeader::fvalue, get_short_term_cxt(), ExpandedRecordHeader::hdr, HeapTupleHasExternal, if(), MemoryContextReset(), MemoryContextSwitchTo(), HeapTupleData::t_data, and HeapTupleData::t_len.
Referenced by expanded_record_set_tuple().
ExpandedRecordHeader* DatumGetExpandedRecord | ( | Datum | d | ) |
Definition at line 927 of file expandedrecord.c.
References Assert, CurrentMemoryContext, DatumGetEOHP(), DatumGetPointer(), ER_MAGIC, ExpandedRecordHeader::er_magic, make_expanded_record_from_datum(), and VARATT_IS_EXTERNAL_EXPANDED_RW.
void deconstruct_expanded_record | ( | ExpandedRecordHeader * | erh | ) |
Definition at line 952 of file expandedrecord.c.
References chunk, ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ExpandedObjectHeader::eoh_context, ER_FLAG_DVALUES_VALID, ER_FLAG_FVALUE_VALID, expanded_record_get_tupdesc(), ExpandedRecordHeader::flags, ExpandedRecordHeader::fvalue, ExpandedRecordHeader::hdr, heap_deform_tuple(), MemoryContextAlloc(), TupleDescData::natts, and ExpandedRecordHeader::nfields.
Referenced by check_domain_for_new_field(), ER_get_flat_size(), exec_move_row(), exec_move_row_from_datum(), exec_stmt_return_next(), expanded_record_fetch_field(), expanded_record_set_field_internal(), and expanded_record_set_fields().
|
static |
Definition at line 764 of file expandedrecord.c.
References Assert, ExpandedRecordHeader::data_len, ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ER_FLAG_FVALUE_VALID, ER_FLAG_HAVE_EXTERNAL, ER_MAGIC, ExpandedRecordHeader::er_magic, ExpandedRecordHeader::er_typeid, ExpandedRecordHeader::er_typmod, expanded_record_get_tupdesc(), ExpandedRecordHeader::flags, ExpandedRecordHeader::flat_size, ExpandedRecordHeader::fvalue, ExpandedRecordHeader::hasnull, heap_fill_tuple(), HeapTupleHeaderSetDatumLength, HeapTupleHeaderSetNatts, HeapTupleHeaderSetTypeId, HeapTupleHeaderSetTypMod, ExpandedRecordHeader::hoff, ItemPointerSetInvalid(), TupleDescData::natts, HeapTupleHeaderData::t_bits, HeapTupleHeaderData::t_ctid, HeapTupleData::t_data, HeapTupleHeaderData::t_hoff, HeapTupleHeaderData::t_infomask, and HeapTupleData::t_len.
|
static |
Definition at line 652 of file expandedrecord.c.
References Assert, assign_record_type_typmod(), BITMAPLEN, ExpandedRecordHeader::data_len, DatumGetPointer(), deconstruct_expanded_record(), ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ER_FLAG_DVALUES_VALID, ER_FLAG_FVALUE_VALID, ER_FLAG_HAVE_EXTERNAL, ER_MAGIC, ExpandedRecordHeader::er_magic, ExpandedRecordHeader::er_tupdesc, ExpandedRecordHeader::er_typeid, ExpandedRecordHeader::er_typmod, expanded_record_get_tupdesc(), expanded_record_set_field_internal(), ExpandedRecordHeader::flags, ExpandedRecordHeader::flat_size, ExpandedRecordHeader::fvalue, ExpandedRecordHeader::hasnull, heap_compute_data_size(), ExpandedRecordHeader::hoff, i, len, MAXALIGN, TupleDescData::natts, ExpandedRecordHeader::nfields, HeapTupleData::t_len, TupleDescData::tdtypmod, TupleDescAttr, and VARATT_IS_EXTERNAL.
|
static |
Definition at line 902 of file expandedrecord.c.
References arg, ExpandedRecordHeader::er_tupdesc, FreeTupleDesc(), and TupleDescData::tdrefcount.
Referenced by expanded_record_fetch_tupdesc(), make_expanded_record_from_exprecord(), make_expanded_record_from_tupdesc(), and make_expanded_record_from_typeid().
Datum expanded_record_fetch_field | ( | ExpandedRecordHeader * | erh, |
int | fnumber, | ||
bool * | isnull | ||
) |
Definition at line 1063 of file expandedrecord.c.
References deconstruct_expanded_record(), ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ExpandedRecordIsEmpty, ExpandedRecordHeader::fvalue, heap_getsysattr(), ExpandedRecordHeader::nfields, and unlikely.
Referenced by expanded_record_get_field().
TupleDesc expanded_record_fetch_tupdesc | ( | ExpandedRecordHeader * | erh | ) |
Definition at line 824 of file expandedrecord.c.
References MemoryContextCallback::arg, assign_record_type_identifier(), ExpandedObjectHeader::eoh_context, ER_mc_callback(), ExpandedRecordHeader::er_mcb, ExpandedRecordHeader::er_tupdesc, ExpandedRecordHeader::er_tupdesc_id, ExpandedRecordHeader::er_typeid, ExpandedRecordHeader::er_typmod, MemoryContextCallback::func, ExpandedRecordHeader::hdr, lookup_rowtype_tupdesc(), MemoryContextRegisterResetCallback(), ReleaseTupleDesc, TupleDescData::tdrefcount, TupleDescData::tdtypeid, and TupleDescData::tdtypmod.
Referenced by expanded_record_get_tupdesc().
HeapTuple expanded_record_get_tuple | ( | ExpandedRecordHeader * | erh | ) |
Definition at line 884 of file expandedrecord.c.
References ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ER_FLAG_DVALUES_VALID, ER_FLAG_FVALUE_VALID, ExpandedRecordHeader::er_tupdesc, ExpandedRecordHeader::flags, ExpandedRecordHeader::fvalue, and heap_form_tuple().
Referenced by coerce_function_result_tuple(), exec_stmt_return_next(), and plpgsql_exec_trigger().
bool expanded_record_lookup_field | ( | ExpandedRecordHeader * | erh, |
const char * | fieldname, | ||
ExpandedRecordFieldInfo * | finfo | ||
) |
Definition at line 1017 of file expandedrecord.c.
References expanded_record_get_tupdesc(), ExpandedRecordFieldInfo::fcollation, ExpandedRecordFieldInfo::fnumber, FormData_pg_attribute, ExpandedRecordFieldInfo::ftypeid, ExpandedRecordFieldInfo::ftypmod, namestrcmp(), TupleDescData::natts, SystemAttributeByName(), and TupleDescAttr.
Referenced by exec_assign_value(), exec_eval_datum(), plpgsql_exec_get_datum_type(), plpgsql_exec_get_datum_type_info(), plpgsql_param_eval_recfield(), and plpgsql_param_fetch().
void expanded_record_set_field_internal | ( | ExpandedRecordHeader * | erh, |
int | fnumber, | ||
Datum | newValue, | ||
bool | isnull, | ||
bool | expand_external, | ||
bool | check_constraints | ||
) |
Definition at line 1112 of file expandedrecord.c.
References Assert, check_domain_for_new_field(), datumCopy(), DatumGetPointer(), deconstruct_expanded_record(), detoast_external_attr(), ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, elog, ExpandedObjectHeader::eoh_context, ER_FLAG_DVALUES_ALLOCED, ER_FLAG_DVALUES_VALID, ER_FLAG_FVALUE_VALID, ER_FLAG_HAVE_EXTERNAL, ER_FLAG_IS_DOMAIN, ER_FLAG_IS_DUMMY, ExpandedRecordHeader::er_short_term_cxt, ExpandedRecordHeader::er_tupdesc, ERROR, ExpandedRecordHeader::fendptr, ExpandedRecordHeader::flags, ExpandedRecordHeader::flat_size, get_short_term_cxt(), ExpandedRecordHeader::hdr, MemoryContextReset(), MemoryContextSwitchTo(), TupleDescData::natts, ExpandedRecordHeader::nfields, pfree(), PointerGetDatum(), TupleDescAttr, unlikely, and VARATT_IS_EXTERNAL.
Referenced by ER_get_flat_size(), and plpgsql_exec_trigger().
void expanded_record_set_fields | ( | ExpandedRecordHeader * | erh, |
const Datum * | newValues, | ||
const bool * | isnulls, | ||
bool | expand_external | ||
) |
Definition at line 1249 of file expandedrecord.c.
References Assert, datumCopy(), DatumGetPointer(), deconstruct_expanded_record(), detoast_external_attr(), ExpandedRecordHeader::dnulls, domain_check(), ExpandedRecordHeader::dvalues, ExpandedObjectHeader::eoh_context, ExpandedRecordHeader::er_decltypeid, ExpandedRecordHeader::er_domaininfo, ER_FLAG_DVALUES_ALLOCED, ER_FLAG_DVALUES_VALID, ER_FLAG_FVALUE_VALID, ER_FLAG_HAVE_EXTERNAL, ER_FLAG_IS_DOMAIN, ER_FLAG_IS_DUMMY, ExpandedRecordHeader::er_tupdesc, ExpandedRecordGetRODatum(), ExpandedRecordHeader::fendptr, ExpandedRecordHeader::flags, ExpandedRecordHeader::flat_size, get_short_term_cxt(), ExpandedRecordHeader::hdr, MemoryContextSwitchTo(), TupleDescData::natts, ExpandedRecordHeader::nfields, pfree(), PointerGetDatum(), TupleDescAttr, unlikely, and VARATT_IS_EXTERNAL.
Referenced by exec_move_row_from_fields().
void expanded_record_set_tuple | ( | ExpandedRecordHeader * | erh, |
HeapTuple | tuple, | ||
bool | copy, | ||
bool | expand_external | ||
) |
Definition at line 440 of file expandedrecord.c.
References Assert, attbyval, check_domain_for_new_tuple(), DatumGetPointer(), ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ExpandedObjectHeader::eoh_context, ER_FLAG_DVALUES_ALLOCED, ER_FLAG_FVALUE_ALLOCED, ER_FLAG_FVALUE_VALID, ER_FLAG_HAVE_EXTERNAL, ER_FLAG_IS_DOMAIN, ER_FLAG_IS_DUMMY, ER_FLAGS_NON_DATA, ExpandedRecordHeader::er_short_term_cxt, ExpandedRecordHeader::er_tupdesc, ExpandedRecordHeader::fendptr, ExpandedRecordHeader::flags, ExpandedRecordHeader::flat_size, ExpandedRecordHeader::fstartptr, ExpandedRecordHeader::fvalue, get_short_term_cxt(), ExpandedRecordHeader::hdr, heap_copytuple(), heap_freetuple(), HeapTupleHasExternal, i, if(), MemoryContextReset(), MemoryContextSwitchTo(), ExpandedRecordHeader::nfields, pfree(), HeapTupleData::t_data, HeapTupleData::t_len, toast_flatten_tuple(), and TupleDescAttr.
Referenced by exec_for_query(), exec_move_row(), exec_move_row_from_datum(), and plpgsql_exec_trigger().
|
static |
Definition at line 1379 of file expandedrecord.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, ExpandedObjectHeader::eoh_context, ExpandedRecordHeader::er_short_term_cxt, ExpandedRecordHeader::hdr, and MemoryContextReset().
Referenced by build_dummy_expanded_header(), check_domain_for_new_tuple(), expanded_record_set_field_internal(), expanded_record_set_fields(), and expanded_record_set_tuple().
Datum make_expanded_record_from_datum | ( | Datum | recorddatum, |
MemoryContext | parentcontext | ||
) |
Definition at line 580 of file expandedrecord.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, DatumGetHeapTupleHeader, EOH_init_header(), EOHPGetRWDatum(), ExpandedRecordHeader::er_decltypeid, ER_FLAG_FVALUE_ALLOCED, ER_FLAG_FVALUE_VALID, ER_MAGIC, ExpandedRecordHeader::er_magic, ER_methods, ExpandedRecordHeader::er_typeid, ExpandedRecordHeader::er_typmod, ExpandedRecordHeader::fendptr, ExpandedRecordHeader::flags, ExpandedRecordHeader::fstartptr, ExpandedRecordHeader::fvalue, ExpandedRecordHeader::hdr, heap_copytuple(), HeapTupleHeaderGetDatumLength, HeapTupleHeaderGetTypeId, HeapTupleHeaderGetTypMod, HeapTupleHeaderHasExternal, InvalidOid, ItemPointerSetInvalid(), MemoryContextAllocZero(), MemoryContextSwitchTo(), HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, and HeapTupleData::t_tableOid.
Referenced by DatumGetExpandedRecord().
ExpandedRecordHeader* make_expanded_record_from_exprecord | ( | ExpandedRecordHeader * | olderh, |
MemoryContext | parentcontext | ||
) |
Definition at line 329 of file expandedrecord.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, MemoryContextCallback::arg, chunk, CreateTupleDescCopy(), ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ExpandedObjectHeader::eoh_context, EOH_init_header(), ExpandedRecordHeader::er_decltypeid, ER_FLAG_IS_DOMAIN, ER_FLAG_TUPDESC_ALLOCED, ER_MAGIC, ExpandedRecordHeader::er_magic, ER_mc_callback(), ExpandedRecordHeader::er_mcb, ER_methods, ExpandedRecordHeader::er_tupdesc, ExpandedRecordHeader::er_tupdesc_id, ExpandedRecordHeader::er_typeid, ExpandedRecordHeader::er_typmod, expanded_record_get_tupdesc(), ExpandedRecordHeader::flags, MemoryContextCallback::func, ExpandedRecordHeader::hdr, MAXALIGN, MemoryContextAlloc(), MemoryContextRegisterResetCallback(), MemoryContextSwitchTo(), TupleDescData::natts, ExpandedRecordHeader::nfields, and TupleDescData::tdrefcount.
Referenced by make_expanded_record_for_rec(), and plpgsql_exec_trigger().
ExpandedRecordHeader* make_expanded_record_from_tupdesc | ( | TupleDesc | tupdesc, |
MemoryContext | parentcontext | ||
) |
Definition at line 205 of file expandedrecord.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, MemoryContextCallback::arg, assign_record_type_identifier(), chunk, CreateTupleDescCopy(), ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ExpandedObjectHeader::eoh_context, EOH_init_header(), ExpandedRecordHeader::er_decltypeid, ER_FLAG_TUPDESC_ALLOCED, ER_MAGIC, ExpandedRecordHeader::er_magic, ER_mc_callback(), ExpandedRecordHeader::er_mcb, ER_methods, ExpandedRecordHeader::er_tupdesc, ExpandedRecordHeader::er_tupdesc_id, ExpandedRecordHeader::er_typeid, ExpandedRecordHeader::er_typmod, ereport, errcode(), errmsg(), ERROR, ExpandedRecordHeader::flags, format_type_be(), MemoryContextCallback::func, ExpandedRecordHeader::hdr, lookup_type_cache(), MAXALIGN, MemoryContextAlloc(), MemoryContextRegisterResetCallback(), MemoryContextSwitchTo(), TupleDescData::natts, ExpandedRecordHeader::nfields, TupleDescData::tdrefcount, TupleDescData::tdtypeid, TupleDescData::tdtypmod, TypeCacheEntry::tupDesc, TypeCacheEntry::tupDesc_identifier, and TYPECACHE_TUPDESC.
Referenced by make_expanded_record_for_rec(), and plpgsql_exec_trigger().
ExpandedRecordHeader* make_expanded_record_from_typeid | ( | Oid | type_id, |
int32 | typmod, | ||
MemoryContext | parentcontext | ||
) |
Definition at line 69 of file expandedrecord.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, MemoryContextCallback::arg, assign_record_type_identifier(), chunk, ExpandedRecordHeader::dnulls, TypeCacheEntry::domainBaseType, ExpandedRecordHeader::dvalues, ExpandedObjectHeader::eoh_context, EOH_init_header(), ExpandedRecordHeader::er_decltypeid, ER_FLAG_IS_DOMAIN, ER_MAGIC, ExpandedRecordHeader::er_magic, ER_mc_callback(), ExpandedRecordHeader::er_mcb, ER_methods, ExpandedRecordHeader::er_tupdesc, ExpandedRecordHeader::er_tupdesc_id, ExpandedRecordHeader::er_typeid, ExpandedRecordHeader::er_typmod, ereport, errcode(), errmsg(), ERROR, ExpandedRecordHeader::flags, format_type_be(), MemoryContextCallback::func, ExpandedRecordHeader::hdr, lookup_rowtype_tupdesc(), lookup_type_cache(), MAXALIGN, MemoryContextAlloc(), MemoryContextRegisterResetCallback(), TupleDescData::natts, ExpandedRecordHeader::nfields, ReleaseTupleDesc, TupleDescData::tdrefcount, TupleDescData::tdtypeid, TupleDescData::tdtypmod, TypeCacheEntry::tupDesc, TypeCacheEntry::tupDesc_identifier, TYPECACHE_DOMAIN_BASE_INFO, TYPECACHE_TUPDESC, and TypeCacheEntry::typtype.
Referenced by exec_move_row_from_datum(), instantiate_empty_record_variable(), and make_expanded_record_for_rec().
|
static |
Definition at line 38 of file expandedrecord.c.
Referenced by build_dummy_expanded_header(), make_expanded_record_from_datum(), make_expanded_record_from_exprecord(), make_expanded_record_from_tupdesc(), and make_expanded_record_from_typeid().