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

Go to the source code of this file.

Macros

#define fetchatt(A, T)   fetch_att(T, (A)->attbyval, (A)->attlen)
 
#define att_align_datum(cur_offset, attalign, attlen, attdatum)
 
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
 
#define att_align_nominal(cur_offset, attalign)
 
#define att_addlength_datum(cur_offset, attlen, attdatum)    att_addlength_pointer(cur_offset, attlen, DatumGetPointer(attdatum))
 
#define att_addlength_pointer(cur_offset, attlen, attptr)
 

Functions

static bool att_isnull (int ATT, const bits8 *BITS)
 
static Datum fetch_att (const void *T, bool attbyval, int attlen)
 
static void store_att_byval (void *T, Datum newdatum, int attlen)
 

Macro Definition Documentation

◆ att_addlength_datum

#define att_addlength_datum (   cur_offset,
  attlen,
  attdatum 
)     att_addlength_pointer(cur_offset, attlen, DatumGetPointer(attdatum))

Definition at line 145 of file tupmacs.h.

◆ att_addlength_pointer

#define att_addlength_pointer (   cur_offset,
  attlen,
  attptr 
)
Value:
( \
((attlen) > 0) ? \
( \
(cur_offset) + (attlen) \
) \
: (((attlen) == -1) ? \
( \
(cur_offset) + VARSIZE_ANY(attptr) \
) \
: \
( \
AssertMacro((attlen) == -2), \
(cur_offset) + (strlen((char *) (attptr)) + 1) \
)) \
)
#define AssertMacro(condition)
Definition: c.h:795
int16 attlen
Definition: pg_attribute.h:68
#define VARSIZE_ANY(PTR)
Definition: postgres.h:349

Definition at line 157 of file tupmacs.h.

◆ att_align_datum

#define att_align_datum (   cur_offset,
  attalign,
  attlen,
  attdatum 
)
Value:
( \
((attlen) == -1 && VARATT_IS_SHORT(DatumGetPointer(attdatum))) ? \
(uintptr_t) (cur_offset) : \
att_align_nominal(cur_offset, attalign) \
)
char attalign
Definition: pg_attribute.h:118
#define VARATT_IS_SHORT(PTR)
Definition: postgres.h:340
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:660

Definition at line 86 of file tupmacs.h.

◆ att_align_nominal

#define att_align_nominal (   cur_offset,
  attalign 
)
Value:
( \
((attalign) == TYPALIGN_INT) ? INTALIGN(cur_offset) : \
(((attalign) == TYPALIGN_CHAR) ? (uintptr_t) (cur_offset) : \
(((attalign) == TYPALIGN_DOUBLE) ? DOUBLEALIGN(cur_offset) : \
( \
AssertMacro((attalign) == TYPALIGN_SHORT), \
SHORTALIGN(cur_offset) \
))) \
)
#define DOUBLEALIGN(LEN)
Definition: c.h:746
#define INTALIGN(LEN)
Definition: c.h:744
#define SHORTALIGN(LEN)
Definition: c.h:743

Definition at line 129 of file tupmacs.h.

◆ att_align_pointer

#define att_align_pointer (   cur_offset,
  attalign,
  attlen,
  attptr 
)
Value:
( \
((attlen) == -1 && VARATT_NOT_PAD_BYTE(attptr)) ? \
(uintptr_t) (cur_offset) : \
att_align_nominal(cur_offset, attalign) \
)
#define VARATT_NOT_PAD_BYTE(PTR)
Definition: postgres.h:259
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:129

Definition at line 107 of file tupmacs.h.

◆ fetchatt

#define fetchatt (   A,
  T 
)    fetch_att(T, (A)->attbyval, (A)->attlen)

Definition at line 46 of file tupmacs.h.

Function Documentation

◆ att_isnull()

static bool att_isnull ( int  ATT,
const bits8 BITS 
)
inlinestatic

◆ fetch_att()

static Datum fetch_att ( const void *  T,
bool  attbyval,
int  attlen 
)
inlinestatic

Definition at line 52 of file tupmacs.h.

53 {
54  if (attbyval)
55  {
56  switch (attlen)
57  {
58  case sizeof(char):
59  return CharGetDatum(*((const char *) T));
60  case sizeof(int16):
61  return Int16GetDatum(*((const int16 *) T));
62  case sizeof(int32):
63  return Int32GetDatum(*((const int32 *) T));
64 #if SIZEOF_DATUM == 8
65  case sizeof(Datum):
66  return *((const Datum *) T);
67 #endif
68  default:
69  elog(ERROR, "unsupported byval length: %d", attlen);
70  return 0;
71  }
72  }
73  else
74  return PointerGetDatum(T);
75 }
signed short int16
Definition: c.h:429
signed int int32
Definition: c.h:430
#define ERROR
Definition: elog.h:39
static const uint32 T[65]
Definition: md5.c:119
bool attbyval
Definition: pg_attribute.h:112
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:670
uintptr_t Datum
Definition: postgres.h:412
static Datum Int16GetDatum(int16 X)
Definition: postgres.h:520
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:560
static Datum CharGetDatum(char X)
Definition: postgres.h:470

References attbyval, attlen, CharGetDatum(), elog(), ERROR, Int16GetDatum(), Int32GetDatum(), PointerGetDatum(), and T.

Referenced by array_iter_next(), array_iterate(), array_replace_internal(), array_to_text_internal(), ArrayCast(), brin_range_deserialize(), deconstruct_array(), ExecEvalHashedScalarArrayOp(), ExecEvalScalarArrayOp(), multirange_get_bounds(), PLyList_FromArray_recurse(), range_deserialize(), statext_mcv_deserialize(), width_bucket_array_fixed(), and width_bucket_array_variable().

◆ store_att_byval()

static void store_att_byval ( void *  T,
Datum  newdatum,
int  attlen 
)
inlinestatic

Definition at line 183 of file tupmacs.h.

184 {
185  switch (attlen)
186  {
187  case sizeof(char):
188  *(char *) T = DatumGetChar(newdatum);
189  break;
190  case sizeof(int16):
191  *(int16 *) T = DatumGetInt16(newdatum);
192  break;
193  case sizeof(int32):
194  *(int32 *) T = DatumGetInt32(newdatum);
195  break;
196 #if SIZEOF_DATUM == 8
197  case sizeof(Datum):
198  *(Datum *) T = newdatum;
199  break;
200 #endif
201  default:
202  elog(ERROR, "unsupported byval length: %d", attlen);
203  }
204 }
static char DatumGetChar(Datum X)
Definition: postgres.h:460
static int16 DatumGetInt16(Datum X)
Definition: postgres.h:510
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:550

References attlen, DatumGetChar(), DatumGetInt16(), DatumGetInt32(), elog(), ERROR, and T.

Referenced by ArrayCastAndSet(), brin_range_serialize(), datum_write(), fill_val(), and statext_mcv_serialize().