PostgreSQL Source Code
git master
|
#include "access/htup.h"
#include "access/tupdesc.h"
#include "fmgr.h"
#include "utils/expandeddatum.h"
Go to the source code of this file.
Data Structures | |
struct | ExpandedRecordHeader |
struct | ExpandedRecordFieldInfo |
Macros | |
#define | ER_MAGIC 1384727874 /* ID for debugging crosschecks */ |
#define | ER_FLAG_FVALUE_VALID 0x0001 /* fvalue is up to date? */ |
#define | ER_FLAG_FVALUE_ALLOCED 0x0002 /* fvalue is local storage? */ |
#define | ER_FLAG_DVALUES_VALID 0x0004 /* dvalues/dnulls are up to date? */ |
#define | ER_FLAG_DVALUES_ALLOCED 0x0008 /* any field values local storage? */ |
#define | ER_FLAG_HAVE_EXTERNAL 0x0010 /* any field values are external? */ |
#define | ER_FLAG_TUPDESC_ALLOCED 0x0020 /* tupdesc is local storage? */ |
#define | ER_FLAG_IS_DOMAIN 0x0040 /* er_decltypeid is domain? */ |
#define | ER_FLAG_IS_DUMMY 0x0080 /* this header is dummy (see below) */ |
#define | ER_FLAGS_NON_DATA (ER_FLAG_TUPDESC_ALLOCED | ER_FLAG_IS_DOMAIN | ER_FLAG_IS_DUMMY) |
#define | PG_GETARG_EXPANDED_RECORD(n) DatumGetExpandedRecord(PG_GETARG_DATUM(n)) |
#define | PG_RETURN_EXPANDED_RECORD(x) PG_RETURN_DATUM(ExpandedRecordGetDatum(x)) |
#define | ExpandedRecordIsEmpty(erh) (((erh)->flags & (ER_FLAG_DVALUES_VALID | ER_FLAG_FVALUE_VALID)) == 0) |
#define | ExpandedRecordIsDomain(erh) (((erh)->flags & ER_FLAG_IS_DOMAIN) != 0) |
#define | TransferExpandedRecord(erh, cxt) MemoryContextSetParent((erh)->hdr.eoh_context, cxt) |
#define | expanded_record_set_field(erh, fnumber, newValue, isnull, expand_external) expanded_record_set_field_internal(erh, fnumber, newValue, isnull, expand_external, true) |
Typedefs | |
typedef struct ExpandedRecordHeader | ExpandedRecordHeader |
typedef struct ExpandedRecordFieldInfo | ExpandedRecordFieldInfo |
Definition at line 55 of file expandedrecord.h.
#define ER_FLAG_DVALUES_VALID 0x0004 /* dvalues/dnulls are up to date? */ |
Definition at line 54 of file expandedrecord.h.
#define ER_FLAG_FVALUE_ALLOCED 0x0002 /* fvalue is local storage? */ |
Definition at line 53 of file expandedrecord.h.
#define ER_FLAG_FVALUE_VALID 0x0001 /* fvalue is up to date? */ |
Definition at line 52 of file expandedrecord.h.
#define ER_FLAG_HAVE_EXTERNAL 0x0010 /* any field values are external? */ |
Definition at line 56 of file expandedrecord.h.
#define ER_FLAG_IS_DOMAIN 0x0040 /* er_decltypeid is domain? */ |
Definition at line 58 of file expandedrecord.h.
#define ER_FLAG_IS_DUMMY 0x0080 /* this header is dummy (see below) */ |
Definition at line 59 of file expandedrecord.h.
#define ER_FLAG_TUPDESC_ALLOCED 0x0020 /* tupdesc is local storage? */ |
Definition at line 57 of file expandedrecord.h.
#define ER_FLAGS_NON_DATA (ER_FLAG_TUPDESC_ALLOCED | ER_FLAG_IS_DOMAIN | ER_FLAG_IS_DUMMY) |
Definition at line 61 of file expandedrecord.h.
#define ER_MAGIC 1384727874 /* ID for debugging crosschecks */ |
Definition at line 40 of file expandedrecord.h.
#define expanded_record_set_field | ( | erh, | |
fnumber, | |||
newValue, | |||
isnull, | |||
expand_external | |||
) | expanded_record_set_field_internal(erh, fnumber, newValue, isnull, expand_external, true) |
Definition at line 208 of file expandedrecord.h.
#define ExpandedRecordIsDomain | ( | erh | ) | (((erh)->flags & ER_FLAG_IS_DOMAIN) != 0) |
Definition at line 160 of file expandedrecord.h.
#define ExpandedRecordIsEmpty | ( | erh | ) | (((erh)->flags & (ER_FLAG_DVALUES_VALID | ER_FLAG_FVALUE_VALID)) == 0) |
Definition at line 158 of file expandedrecord.h.
#define PG_GETARG_EXPANDED_RECORD | ( | n | ) | DatumGetExpandedRecord(PG_GETARG_DATUM(n)) |
Definition at line 154 of file expandedrecord.h.
#define PG_RETURN_EXPANDED_RECORD | ( | x | ) | PG_RETURN_DATUM(ExpandedRecordGetDatum(x)) |
Definition at line 155 of file expandedrecord.h.
#define TransferExpandedRecord | ( | erh, | |
cxt | |||
) | MemoryContextSetParent((erh)->hdr.eoh_context, cxt) |
Definition at line 164 of file expandedrecord.h.
typedef struct ExpandedRecordFieldInfo ExpandedRecordFieldInfo |
typedef struct ExpandedRecordHeader ExpandedRecordHeader |
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().
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().
|
inlinestatic |
Definition at line 228 of file expandedrecord.h.
References ExpandedRecordHeader::dnulls, ExpandedRecordHeader::dvalues, ER_FLAG_DVALUES_VALID, expanded_record_fetch_field(), ExpandedRecordHeader::flags, and likely.
Referenced by exec_eval_datum(), ExecEvalFieldSelect(), and plpgsql_param_eval_recfield().
|
inlinestatic |
Definition at line 218 of file expandedrecord.h.
References ExpandedRecordHeader::er_tupdesc, expanded_record_fetch_tupdesc(), and likely.
Referenced by build_dummy_expanded_header(), coerce_function_result_tuple(), deconstruct_expanded_record(), ER_flatten_into(), ER_get_flat_size(), exec_for_query(), exec_move_row(), exec_move_row_from_datum(), exec_move_row_from_fields(), exec_stmt_return_next(), ExecEvalFieldSelect(), expanded_record_lookup_field(), make_expanded_record_for_rec(), make_expanded_record_from_exprecord(), and plpgsql_exec_trigger().
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().
|
inlinestatic |
Definition at line 143 of file expandedrecord.h.
References EOHPGetRWDatum(), and ExpandedRecordHeader::hdr.
Referenced by assign_record_var(), exec_eval_datum(), exec_move_row(), and exec_stmt_return().
|
inlinestatic |
Definition at line 149 of file expandedrecord.h.
References EOHPGetRODatum(), and ExpandedRecordHeader::hdr.
Referenced by check_domain_for_new_field(), check_domain_for_new_tuple(), and expanded_record_set_fields().
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().