PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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_datum_alignby(cur_offset, attalignby, attlen, attdatum)
 
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
 
#define att_pointer_alignby(cur_offset, attalignby, attlen, attptr)
 
#define att_align_nominal(cur_offset, attalign)
 
#define att_nominal_alignby(cur_offset, attalignby)    TYPEALIGN(attalignby, cur_offset)
 
#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

Definition at line 168 of file tupmacs.h.

185 : (((attlen) == -1) ? \
186 ( \
188 ) \
189 : \
190 ( \
191 AssertMacro((attlen) == -2), \
192 (cur_offset) + (strlen((const char *) (attptr)) + 1) \
193 )) \
194)
195
197/*
198 * store_att_byval is a partial inverse of fetch_att: store a given Datum
199 * value into a tuple data area at the specified address. However, it only
200 * handles the byval case, because in typical usage the caller needs to
201 * distinguish by-val and by-ref cases anyway, and so a do-it-all function
202 * wouldn't be convenient.
203 */
206{
207 switch (attlen)
208 {
209 case sizeof(char):
210 *(char *) T = DatumGetChar(newdatum);
211 break;
212 case sizeof(int16):
214 break;
215 case sizeof(int32):
217 break;
218 case sizeof(int64):
220 break;
221 default:
222 elog(ERROR, "unsupported byval length: %d", attlen);
223 }
224}
225#endif /* FRONTEND */
226
227#endif /* TUPMACS_H */
#define FRONTEND
#define AssertMacro(condition)
Definition c.h:874
int64_t int64
Definition c.h:543
int16_t int16
Definition c.h:541
int32_t int32
Definition c.h:542
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
static const uint32 T[65]
Definition md5.c:119
int16 attlen
static int64 DatumGetInt64(Datum X)
Definition postgres.h:413
uint64_t Datum
Definition postgres.h:70
static char DatumGetChar(Datum X)
Definition postgres.h:122
static int16 DatumGetInt16(Datum X)
Definition postgres.h:172
static int32 DatumGetInt32(Datum X)
Definition postgres.h:212
static int fb(int x)
static void store_att_byval(void *T, Datum newdatum, int attlen)
Definition tupmacs.h:206
static Size VARSIZE_ANY(const void *PTR)
Definition varatt.h:460

◆ att_addlength_pointer

#define att_addlength_pointer (   cur_offset,
  attlen,
  attptr 
)
Value:
( \
((attlen) > 0) ? \
( \
) \
: (((attlen) == -1) ? \
( \
) \
: \
( \
AssertMacro((attlen) == -2), \
(cur_offset) + (strlen((const char *) (attptr)) + 1) \
)) \
)

Definition at line 180 of file tupmacs.h.

186 : (((attlen) == -1) ? \
187 ( \
189 ) \
190 : \
191 ( \
192 AssertMacro((attlen) == -2), \
193 (cur_offset) + (strlen((const char *) (attptr)) + 1) \
194 )) \
195)

◆ att_align_datum

#define att_align_datum (   cur_offset,
  attalign,
  attlen,
  attdatum 
)
Value:
( \
)
char attalign
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:342
static bool VARATT_IS_SHORT(const void *PTR)
Definition varatt.h:403

Definition at line 82 of file tupmacs.h.

◆ att_align_nominal

#define att_align_nominal (   cur_offset,
  attalign 
)
Value:
( \
( \
))) \
)
#define DOUBLEALIGN(LEN)
Definition c.h:825
#define INTALIGN(LEN)
Definition c.h:823
#define SHORTALIGN(LEN)
Definition c.h:822

Definition at line 145 of file tupmacs.h.

147 : \
150 ( \
153 ))) \
154)

◆ att_align_pointer

#define att_align_pointer (   cur_offset,
  attalign,
  attlen,
  attptr 
)
Value:
( \
((attlen) == -1 && VARATT_NOT_PAD_BYTE(attptr)) ? \
)
#define att_align_nominal(cur_offset, attalign)
Definition tupmacs.h:145
#define VARATT_NOT_PAD_BYTE(PTR)
Definition varatt.h:238

Definition at line 113 of file tupmacs.h.

◆ att_datum_alignby

#define att_datum_alignby (   cur_offset,
  attalignby,
  attlen,
  attdatum 
)
Value:

Definition at line 93 of file tupmacs.h.

96 : \
97 TYPEALIGN(attalignby, cur_offset))

◆ att_nominal_alignby

#define att_nominal_alignby (   cur_offset,
  attalignby 
)     TYPEALIGN(attalignby, cur_offset)

Definition at line 160 of file tupmacs.h.

◆ att_pointer_alignby

#define att_pointer_alignby (   cur_offset,
  attalignby,
  attlen,
  attptr 
)
Value:
( \
((attlen) == -1 && VARATT_NOT_PAD_BYTE(attptr)) ? \
TYPEALIGN(attalignby, cur_offset))
#define TYPEALIGN(ALIGNVAL, LEN)
Definition c.h:819

Definition at line 124 of file tupmacs.h.

127 : \
128 TYPEALIGN(attalignby, cur_offset))

◆ fetchatt

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

Definition at line 44 of file tupmacs.h.

Function Documentation

◆ att_isnull()

◆ fetch_att()

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

Definition at line 50 of file tupmacs.h.

51{
52 if (attbyval)
53 {
54 switch (attlen)
55 {
56 case sizeof(char):
58 case sizeof(int16):
60 case sizeof(int32):
62 case sizeof(int64):
64 default:
65 elog(ERROR, "unsupported byval length: %d", attlen);
66 return 0;
67 }
68 }
69 else
70 return PointerGetDatum(T);
71}
bool attbyval
static Datum Int64GetDatum(int64 X)
Definition postgres.h:423
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
static Datum Int16GetDatum(int16 X)
Definition postgres.h:182
static Datum Int32GetDatum(int32 X)
Definition postgres.h:222
static Datum CharGetDatum(char X)
Definition postgres.h:132

References attbyval, attlen, CharGetDatum(), elog, ERROR, fb(), Int16GetDatum(), Int32GetDatum(), Int64GetDatum(), 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 206 of file tupmacs.h.

207{
208 switch (attlen)
209 {
210 case sizeof(char):
211 *(char *) T = DatumGetChar(newdatum);
212 break;
213 case sizeof(int16):
215 break;
216 case sizeof(int32):
218 break;
219 case sizeof(int64):
221 break;
222 default:
223 elog(ERROR, "unsupported byval length: %d", attlen);
224 }
225}

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

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