13 #ifndef EXPANDEDRECORD_H
14 #define EXPANDEDRECORD_H
40 #define ER_MAGIC 1384727874
52 #define ER_FLAG_FVALUE_VALID 0x0001
53 #define ER_FLAG_FVALUE_ALLOCED 0x0002
54 #define ER_FLAG_DVALUES_VALID 0x0004
55 #define ER_FLAG_DVALUES_ALLOCED 0x0008
56 #define ER_FLAG_HAVE_EXTERNAL 0x0010
57 #define ER_FLAG_TUPDESC_ALLOCED 0x0020
58 #define ER_FLAG_IS_DOMAIN 0x0040
59 #define ER_FLAG_IS_DUMMY 0x0080
61 #define ER_FLAGS_NON_DATA \
62 (ER_FLAG_TUPDESC_ALLOCED | ER_FLAG_IS_DOMAIN | ER_FLAG_IS_DUMMY)
154 #define PG_GETARG_EXPANDED_RECORD(n) DatumGetExpandedRecord(PG_GETARG_DATUM(n))
155 #define PG_RETURN_EXPANDED_RECORD(x) PG_RETURN_DATUM(ExpandedRecordGetDatum(x))
158 #define ExpandedRecordIsEmpty(erh) \
159 (((erh)->flags & (ER_FLAG_DVALUES_VALID | ER_FLAG_FVALUE_VALID)) == 0)
160 #define ExpandedRecordIsDomain(erh) \
161 (((erh)->flags & ER_FLAG_IS_DOMAIN) != 0)
164 #define TransferExpandedRecord(erh, cxt) \
165 MemoryContextSetParent((erh)->hdr.eoh_context, cxt)
186 HeapTuple tuple,
bool copy,
bool expand_external);
194 const char *fieldname,
200 Datum newValue,
bool isnull,
201 bool expand_external,
202 bool check_constraints);
204 const Datum *newValues,
const bool *isnulls,
205 bool expand_external);
208 #define expanded_record_set_field(erh, fnumber, newValue, isnull, expand_external) \
209 expanded_record_set_field_internal(erh, fnumber, newValue, isnull, expand_external, true)
232 likely(fnumber > 0 && fnumber <= erh->nfields))
234 *isnull = erh->
dnulls[fnumber - 1];
235 return erh->
dvalues[fnumber - 1];
static Datum EOHPGetRWDatum(const struct ExpandedObjectHeader *eohptr)
static Datum EOHPGetRODatum(const struct ExpandedObjectHeader *eohptr)
ExpandedRecordHeader * make_expanded_record_from_tupdesc(TupleDesc tupdesc, MemoryContext parentcontext)
ExpandedRecordHeader * make_expanded_record_from_typeid(Oid type_id, int32 typmod, MemoryContext parentcontext)
struct ExpandedRecordFieldInfo ExpandedRecordFieldInfo
static Datum ExpandedRecordGetDatum(const ExpandedRecordHeader *erh)
static Datum expanded_record_get_field(ExpandedRecordHeader *erh, int fnumber, bool *isnull)
static Datum ExpandedRecordGetRODatum(const ExpandedRecordHeader *erh)
void expanded_record_set_field_internal(ExpandedRecordHeader *erh, int fnumber, Datum newValue, bool isnull, bool expand_external, bool check_constraints)
bool expanded_record_lookup_field(ExpandedRecordHeader *erh, const char *fieldname, ExpandedRecordFieldInfo *finfo)
Datum expanded_record_fetch_field(ExpandedRecordHeader *erh, int fnumber, bool *isnull)
#define ER_FLAG_DVALUES_VALID
static TupleDesc expanded_record_get_tupdesc(ExpandedRecordHeader *erh)
Datum make_expanded_record_from_datum(Datum recorddatum, MemoryContext parentcontext)
ExpandedRecordHeader * make_expanded_record_from_exprecord(ExpandedRecordHeader *olderh, MemoryContext parentcontext)
TupleDesc expanded_record_fetch_tupdesc(ExpandedRecordHeader *erh)
void expanded_record_set_tuple(ExpandedRecordHeader *erh, HeapTuple tuple, bool copy, bool expand_external)
HeapTuple expanded_record_get_tuple(ExpandedRecordHeader *erh)
struct ExpandedRecordHeader ExpandedRecordHeader
ExpandedRecordHeader * DatumGetExpandedRecord(Datum d)
void deconstruct_expanded_record(ExpandedRecordHeader *erh)
void expanded_record_set_fields(ExpandedRecordHeader *erh, const Datum *newValues, const bool *isnulls, bool expand_external)
MemoryContext er_short_term_cxt
MemoryContextCallback er_mcb
struct ExpandedRecordHeader * er_dummy_header