PostgreSQL Source Code  git master
expandeddatum.c File Reference
#include "postgres.h"
#include "utils/expandeddatum.h"
#include "utils/memutils.h"
Include dependency graph for expandeddatum.c:

Go to the source code of this file.

Functions

ExpandedObjectHeaderDatumGetEOHP (Datum d)
 
void EOH_init_header (ExpandedObjectHeader *eohptr, const ExpandedObjectMethods *methods, MemoryContext obj_context)
 
Size EOH_get_flat_size (ExpandedObjectHeader *eohptr)
 
void EOH_flatten_into (ExpandedObjectHeader *eohptr, void *result, Size allocated_size)
 
Datum MakeExpandedObjectReadOnlyInternal (Datum d)
 
Datum TransferExpandedObject (Datum d, MemoryContext new_parent)
 
void DeleteExpandedObject (Datum d)
 

Function Documentation

◆ DatumGetEOHP()

ExpandedObjectHeader* DatumGetEOHP ( Datum  d)

Definition at line 29 of file expandeddatum.c.

30 {
32  varatt_expanded ptr;
33 
35  memcpy(&ptr, VARDATA_EXTERNAL(datum), sizeof(ptr));
37  return ptr.eohptr;
38 }
#define Assert(condition)
Definition: c.h:837
#define VARATT_IS_EXPANDED_HEADER(PTR)
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312
ExpandedObjectHeader * eohptr
Definition: varatt.h:76
#define VARATT_IS_EXTERNAL_EXPANDED(PTR)
Definition: varatt.h:298
#define VARDATA_EXTERNAL(PTR)
Definition: varatt.h:286

References Assert, DatumGetPointer(), varatt_expanded::eohptr, VARATT_IS_EXPANDED_HEADER, VARATT_IS_EXTERNAL_EXPANDED, and VARDATA_EXTERNAL.

Referenced by advance_windowaggregate(), advance_windowaggregate_base(), array_get_element_expanded(), coerce_function_result_tuple(), construct_empty_expanded_array(), datumCopy(), datumEstimateSpace(), DatumGetAnyArrayP(), DatumGetExpandedArray(), DatumGetExpandedArrayX(), DatumGetExpandedRecord(), datumSerialize(), DeleteExpandedObject(), detoast_external_attr(), exec_move_row_from_datum(), ExecAggCopyTransValue(), ExecEvalFieldSelect(), expand_array(), fill_val(), heap_compute_data_size(), MakeExpandedObjectReadOnlyInternal(), plpgsql_exec_trigger(), toast_datum_size(), toast_raw_datum_size(), TransferExpandedObject(), and tts_virtual_materialize().

◆ DeleteExpandedObject()

void DeleteExpandedObject ( Datum  d)

Definition at line 136 of file expandeddatum.c.

137 {
138  ExpandedObjectHeader *eohptr = DatumGetEOHP(d);
139 
140  /* Assert caller gave a R/W pointer */
142 
143  /* Kill it */
145 }
ExpandedObjectHeader * DatumGetEOHP(Datum d)
Definition: expandeddatum.c:29
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:454
MemoryContext eoh_context
#define VARATT_IS_EXTERNAL_EXPANDED_RW(PTR)
Definition: varatt.h:296

References Assert, DatumGetEOHP(), DatumGetPointer(), ExpandedObjectHeader::eoh_context, MemoryContextDelete(), and VARATT_IS_EXTERNAL_EXPANDED_RW.

Referenced by advance_windowaggregate(), advance_windowaggregate_base(), assign_record_var(), assign_simple_var(), exec_move_row(), and ExecAggCopyTransValue().

◆ EOH_flatten_into()

void EOH_flatten_into ( ExpandedObjectHeader eohptr,
void *  result,
Size  allocated_size 
)

Definition at line 81 of file expandeddatum.c.

83 {
84  eohptr->eoh_methods->flatten_into(eohptr, result, allocated_size);
85 }
const ExpandedObjectMethods * eoh_methods
EOM_flatten_into_method flatten_into
Definition: expandeddatum.h:77

References ExpandedObjectHeader::eoh_methods, and ExpandedObjectMethods::flatten_into.

Referenced by coerce_function_result_tuple(), datumCopy(), datumSerialize(), detoast_external_attr(), fill_val(), and tts_virtual_materialize().

◆ EOH_get_flat_size()

◆ EOH_init_header()

void EOH_init_header ( ExpandedObjectHeader eohptr,
const ExpandedObjectMethods methods,
MemoryContext  obj_context 
)

Definition at line 48 of file expandeddatum.c.

51 {
52  varatt_expanded ptr;
53 
54  eohptr->vl_len_ = EOH_HEADER_MAGIC;
55  eohptr->eoh_methods = methods;
56  eohptr->eoh_context = obj_context;
57 
58  ptr.eohptr = eohptr;
59 
61  memcpy(VARDATA_EXTERNAL(eohptr->eoh_rw_ptr), &ptr, sizeof(ptr));
62 
64  memcpy(VARDATA_EXTERNAL(eohptr->eoh_ro_ptr), &ptr, sizeof(ptr));
65 }
#define EOH_HEADER_MAGIC
char eoh_rw_ptr[EXPANDED_POINTER_SIZE]
char eoh_ro_ptr[EXPANDED_POINTER_SIZE]
#define SET_VARTAG_EXTERNAL(PTR, tag)
Definition: varatt.h:309
@ VARTAG_EXPANDED_RW
Definition: varatt.h:88
@ VARTAG_EXPANDED_RO
Definition: varatt.h:87

References ExpandedObjectHeader::eoh_context, EOH_HEADER_MAGIC, ExpandedObjectHeader::eoh_methods, ExpandedObjectHeader::eoh_ro_ptr, ExpandedObjectHeader::eoh_rw_ptr, varatt_expanded::eohptr, SET_VARTAG_EXTERNAL, VARDATA_EXTERNAL, VARTAG_EXPANDED_RO, VARTAG_EXPANDED_RW, and ExpandedObjectHeader::vl_len_.

Referenced by build_dummy_expanded_header(), expand_array(), make_expanded_record_from_datum(), make_expanded_record_from_exprecord(), make_expanded_record_from_tupdesc(), and make_expanded_record_from_typeid().

◆ MakeExpandedObjectReadOnlyInternal()

Datum MakeExpandedObjectReadOnlyInternal ( Datum  d)

Definition at line 95 of file expandeddatum.c.

96 {
97  ExpandedObjectHeader *eohptr;
98 
99  /* Nothing to do if not a read-write expanded-object pointer */
101  return d;
102 
103  /* Now safe to extract the object pointer */
104  eohptr = DatumGetEOHP(d);
105 
106  /* Return the built-in read-only pointer instead of given pointer */
107  return EOHPGetRODatum(eohptr);
108 }
static Datum EOHPGetRODatum(const struct ExpandedObjectHeader *eohptr)

References DatumGetEOHP(), DatumGetPointer(), EOHPGetRODatum(), and VARATT_IS_EXTERNAL_EXPANDED_RW.

Referenced by ExecInterpExpr().

◆ TransferExpandedObject()

Datum TransferExpandedObject ( Datum  d,
MemoryContext  new_parent 
)

Definition at line 118 of file expandeddatum.c.

119 {
120  ExpandedObjectHeader *eohptr = DatumGetEOHP(d);
121 
122  /* Assert caller gave a R/W pointer */
124 
125  /* Transfer ownership */
126  MemoryContextSetParent(eohptr->eoh_context, new_parent);
127 
128  /* Return the object's standard read-write pointer */
129  return EOHPGetRWDatum(eohptr);
130 }
static Datum EOHPGetRWDatum(const struct ExpandedObjectHeader *eohptr)
void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
Definition: mcxt.c:637

References Assert, DatumGetEOHP(), DatumGetPointer(), ExpandedObjectHeader::eoh_context, EOHPGetRWDatum(), MemoryContextSetParent(), and VARATT_IS_EXTERNAL_EXPANDED_RW.

Referenced by datumTransfer(), and plpgsql_exec_function().