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

Go to the source code of this file.

Data Structures

struct  array_iter
 

Typedefs

typedef struct array_iter array_iter
 

Functions

static void array_iter_setup (array_iter *it, AnyArrayType *a)
 
static Datum array_iter_next (array_iter *it, bool *isnull, int i, int elmlen, bool elmbyval, char elmalign)
 

Typedef Documentation

◆ array_iter

Function Documentation

◆ array_iter_next()

static Datum array_iter_next ( array_iter it,
bool isnull,
int  i,
int  elmlen,
bool  elmbyval,
char  elmalign 
)
inlinestatic

Definition at line 81 of file arrayaccess.h.

References att_addlength_pointer, att_align_nominal, array_iter::bitmapptr, array_iter::bitmask, array_iter::dataptr, array_iter::datumptr, fetch_att, i, and array_iter::isnullptr.

Referenced by array_cmp(), array_contain_compare(), array_eq(), array_map(), array_out(), array_send(), array_unnest(), hash_array(), and hash_array_extended().

83 {
84  Datum ret;
85 
86  if (it->datumptr)
87  {
88  ret = it->datumptr[i];
89  *isnull = it->isnullptr ? it->isnullptr[i] : false;
90  }
91  else
92  {
93  if (it->bitmapptr && (*(it->bitmapptr) & it->bitmask) == 0)
94  {
95  *isnull = true;
96  ret = (Datum) 0;
97  }
98  else
99  {
100  *isnull = false;
101  ret = fetch_att(it->dataptr, elmbyval, elmlen);
102  it->dataptr = att_addlength_pointer(it->dataptr, elmlen,
103  it->dataptr);
104  it->dataptr = (char *) att_align_nominal(it->dataptr, elmalign);
105  }
106  it->bitmask <<= 1;
107  if (it->bitmask == 0x100)
108  {
109  if (it->bitmapptr)
110  it->bitmapptr++;
111  it->bitmask = 1;
112  }
113  }
114 
115  return ret;
116 }
bits8 * bitmapptr
Definition: arrayaccess.h:43
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:144
char * dataptr
Definition: arrayaccess.h:42
#define att_addlength_pointer(cur_offset, attlen, attptr)
Definition: tupmacs.h:172
Datum * datumptr
Definition: arrayaccess.h:38
uintptr_t Datum
Definition: postgres.h:372
bool * isnullptr
Definition: arrayaccess.h:39
#define fetch_att(T, attbyval, attlen)
Definition: tupmacs.h:71
int i

◆ array_iter_setup()

static void array_iter_setup ( array_iter it,
AnyArrayType a 
)
inlinestatic

Definition at line 49 of file arrayaccess.h.

References ARR_DATA_PTR, ARR_NULLBITMAP, array_iter::bitmapptr, array_iter::bitmask, array_iter::dataptr, array_iter::datumptr, ExpandedArrayHeader::dnulls, ExpandedArrayHeader::dvalues, AnyArrayType::flt, ExpandedArrayHeader::fvalue, array_iter::isnullptr, VARATT_IS_EXPANDED_HEADER, and AnyArrayType::xpn.

Referenced by array_cmp(), array_contain_compare(), array_eq(), array_map(), array_out(), array_send(), array_unnest(), hash_array(), and hash_array_extended().

50 {
52  {
53  if (a->xpn.dvalues)
54  {
55  it->datumptr = a->xpn.dvalues;
56  it->isnullptr = a->xpn.dnulls;
57  /* we must fill all fields to prevent compiler warnings */
58  it->dataptr = NULL;
59  it->bitmapptr = NULL;
60  }
61  else
62  {
63  /* Work with flat array embedded in the expanded datum */
64  it->datumptr = NULL;
65  it->isnullptr = NULL;
66  it->dataptr = ARR_DATA_PTR(a->xpn.fvalue);
68  }
69  }
70  else
71  {
72  it->datumptr = NULL;
73  it->isnullptr = NULL;
74  it->dataptr = ARR_DATA_PTR(&a->flt);
75  it->bitmapptr = ARR_NULLBITMAP(&a->flt);
76  }
77  it->bitmask = 1;
78 }
bits8 * bitmapptr
Definition: arrayaccess.h:43
char * dataptr
Definition: arrayaccess.h:42
ExpandedArrayHeader xpn
Definition: array.h:165
Datum * dvalues
Definition: array.h:134
#define ARR_DATA_PTR(a)
Definition: array.h:307
Datum * datumptr
Definition: arrayaccess.h:38
ArrayType * fvalue
Definition: array.h:153
bool * isnullptr
Definition: arrayaccess.h:39
#define VARATT_IS_EXPANDED_HEADER(PTR)
ArrayType flt
Definition: array.h:164
#define ARR_NULLBITMAP(a)
Definition: array.h:285