PostgreSQL Source Code  git master
expandeddatum.h File Reference
#include "varatt.h"
Include dependency graph for expandeddatum.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ExpandedObjectMethods
 
struct  ExpandedObjectHeader
 

Macros

#define EXPANDED_POINTER_SIZE   (VARHDRSZ_EXTERNAL + sizeof(varatt_expanded))
 
#define EOH_HEADER_MAGIC   (-1)
 
#define VARATT_IS_EXPANDED_HEADER(PTR)    (((varattrib_4b *) (PTR))->va_4byte.va_header == (uint32) EOH_HEADER_MAGIC)
 
#define DatumIsReadWriteExpandedObject(d, isnull, typlen)
 
#define MakeExpandedObjectReadOnly(d, isnull, typlen)
 

Typedefs

typedef Size(* EOM_get_flat_size_method) (ExpandedObjectHeader *eohptr)
 
typedef void(* EOM_flatten_into_method) (ExpandedObjectHeader *eohptr, void *result, Size allocated_size)
 
typedef struct ExpandedObjectMethods ExpandedObjectMethods
 

Functions

static Datum EOHPGetRWDatum (const struct ExpandedObjectHeader *eohptr)
 
static Datum EOHPGetRODatum (const struct ExpandedObjectHeader *eohptr)
 
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)
 

Macro Definition Documentation

◆ DatumIsReadWriteExpandedObject

#define DatumIsReadWriteExpandedObject (   d,
  isnull,
  typlen 
)
Value:
(((isnull) || (typlen) != -1) ? false : \
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312
#define VARATT_IS_EXTERNAL_EXPANDED_RW(PTR)
Definition: varatt.h:296

Definition at line 151 of file expandeddatum.h.

◆ EOH_HEADER_MAGIC

#define EOH_HEADER_MAGIC   (-1)

Definition at line 129 of file expandeddatum.h.

◆ EXPANDED_POINTER_SIZE

#define EXPANDED_POINTER_SIZE   (VARHDRSZ_EXTERNAL + sizeof(varatt_expanded))

Definition at line 50 of file expandeddatum.h.

◆ MakeExpandedObjectReadOnly

#define MakeExpandedObjectReadOnly (   d,
  isnull,
  typlen 
)
Value:
(((isnull) || (typlen) != -1) ? (d) : \
MakeExpandedObjectReadOnlyInternal(d))

Definition at line 155 of file expandeddatum.h.

◆ VARATT_IS_EXPANDED_HEADER

#define VARATT_IS_EXPANDED_HEADER (   PTR)     (((varattrib_4b *) (PTR))->va_4byte.va_header == (uint32) EOH_HEADER_MAGIC)

Definition at line 130 of file expandeddatum.h.

Typedef Documentation

◆ EOM_flatten_into_method

typedef void(* EOM_flatten_into_method) (ExpandedObjectHeader *eohptr, void *result, Size allocated_size)

Definition at line 70 of file expandeddatum.h.

◆ EOM_get_flat_size_method

typedef Size(* EOM_get_flat_size_method) (ExpandedObjectHeader *eohptr)

Definition at line 69 of file expandeddatum.h.

◆ ExpandedObjectMethods

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:858
#define VARATT_IS_EXPANDED_HEADER(PTR)
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

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().

◆ EOHPGetRODatum()

static Datum EOHPGetRODatum ( const struct ExpandedObjectHeader eohptr)
inlinestatic

Definition at line 145 of file expandeddatum.h.

146 {
147  return PointerGetDatum(eohptr->eoh_ro_ptr);
148 }
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322

References ExpandedObjectHeader::eoh_ro_ptr, and PointerGetDatum().

Referenced by ExpandedRecordGetRODatum(), and MakeExpandedObjectReadOnlyInternal().

◆ EOHPGetRWDatum()

static Datum EOHPGetRWDatum ( const struct ExpandedObjectHeader eohptr)
inlinestatic

◆ 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().