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

typedef struct array_iter 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.

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 }
int i
Definition: isn.c:72
uintptr_t Datum
Definition: postgres.h:64
Datum * datumptr
Definition: arrayaccess.h:38
bits8 * bitmapptr
Definition: arrayaccess.h:43
bool * isnullptr
Definition: arrayaccess.h:39
char * dataptr
Definition: arrayaccess.h:42
#define att_align_nominal(cur_offset, attalign)
Definition: tupmacs.h:129
#define att_addlength_pointer(cur_offset, attlen, attptr)
Definition: tupmacs.h:157
static Datum fetch_att(const void *T, bool attbyval, int attlen)
Definition: tupmacs.h:52

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

◆ array_iter_setup()

static void array_iter_setup ( array_iter it,
AnyArrayType a 
)
inlinestatic

Definition at line 49 of file arrayaccess.h.

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);
67  it->bitmapptr = ARR_NULLBITMAP(a->xpn.fvalue);
68  }
69  }
70  else
71  {
72  it->datumptr = NULL;
73  it->isnullptr = NULL;
74  it->dataptr = ARR_DATA_PTR((ArrayType *) a);
76  }
77  it->bitmask = 1;
78 }
#define ARR_DATA_PTR(a)
Definition: array.h:322
#define ARR_NULLBITMAP(a)
Definition: array.h:300
#define VARATT_IS_EXPANDED_HEADER(PTR)
int a
Definition: isn.c:68

References a, ARR_DATA_PTR, ARR_NULLBITMAP, array_iter::bitmapptr, array_iter::bitmask, array_iter::dataptr, array_iter::datumptr, array_iter::isnullptr, and VARATT_IS_EXPANDED_HEADER.

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