PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
brin_tuple.h File Reference
Include dependency graph for brin_tuple.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BrinValues
 
struct  BrinMemTuple
 
struct  BrinTuple
 

Macros

#define SizeOfBrinTuple   (offsetof(BrinTuple, bt_info) + sizeof(uint8))
 
#define BRIN_OFFSET_MASK   0x1F
 
#define BRIN_PLACEHOLDER_MASK   0x40
 
#define BRIN_NULLS_MASK   0x80
 
#define BrinTupleDataOffset(tup)   ((Size) (((BrinTuple *) (tup))->bt_info & BRIN_OFFSET_MASK))
 
#define BrinTupleHasNulls(tup)   (((((BrinTuple *) (tup))->bt_info & BRIN_NULLS_MASK)) != 0)
 
#define BrinTupleIsPlaceholder(tup)   (((((BrinTuple *) (tup))->bt_info & BRIN_PLACEHOLDER_MASK)) != 0)
 

Typedefs

typedef struct BrinValues BrinValues
 
typedef struct BrinMemTuple BrinMemTuple
 
typedef struct BrinTuple BrinTuple
 

Functions

BrinTuplebrin_form_tuple (BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple, Size *size)
 
BrinTuplebrin_form_placeholder_tuple (BrinDesc *brdesc, BlockNumber blkno, Size *size)
 
void brin_free_tuple (BrinTuple *tuple)
 
BrinTuplebrin_copy_tuple (BrinTuple *tuple, Size len, BrinTuple *dest, Size *destsz)
 
bool brin_tuples_equal (const BrinTuple *a, Size alen, const BrinTuple *b, Size blen)
 
BrinMemTuplebrin_new_memtuple (BrinDesc *brdesc)
 
BrinMemTuplebrin_memtuple_initialize (BrinMemTuple *dtuple, BrinDesc *brdesc)
 
BrinMemTuplebrin_deform_tuple (BrinDesc *brdesc, BrinTuple *tuple, BrinMemTuple *dMemtuple)
 

Macro Definition Documentation

#define BRIN_NULLS_MASK   0x80

Definition at line 79 of file brin_tuple.h.

Referenced by brin_form_placeholder_tuple(), and brin_form_tuple().

#define BRIN_OFFSET_MASK   0x1F

Definition at line 76 of file brin_tuple.h.

Referenced by brin_form_tuple().

#define BRIN_PLACEHOLDER_MASK   0x40

Definition at line 78 of file brin_tuple.h.

Referenced by brin_form_placeholder_tuple(), and brin_form_tuple().

#define BrinTupleDataOffset (   tup)    ((Size) (((BrinTuple *) (tup))->bt_info & BRIN_OFFSET_MASK))

Definition at line 81 of file brin_tuple.h.

Referenced by brin_deform_tuple().

#define BrinTupleHasNulls (   tup)    (((((BrinTuple *) (tup))->bt_info & BRIN_NULLS_MASK)) != 0)

Definition at line 82 of file brin_tuple.h.

Referenced by brin_deform_tuple().

#define BrinTupleIsPlaceholder (   tup)    (((((BrinTuple *) (tup))->bt_info & BRIN_PLACEHOLDER_MASK)) != 0)

Definition at line 83 of file brin_tuple.h.

Referenced by brin_deform_tuple(), and brinRevmapDesummarizeRange().

#define SizeOfBrinTuple   (offsetof(BrinTuple, bt_info) + sizeof(uint8))

Definition at line 71 of file brin_tuple.h.

Referenced by brin_deform_tuple(), brin_form_placeholder_tuple(), and brin_form_tuple().

Typedef Documentation

Function Documentation

BrinTuple* brin_copy_tuple ( BrinTuple tuple,
Size  len,
BrinTuple dest,
Size destsz 
)

Definition at line 321 of file brin_tuple.c.

References palloc(), and repalloc().

Referenced by brin_evacuate_page(), bringetbitmap(), brininsert(), and summarize_range().

322 {
323  if (!destsz || *destsz == 0)
324  dest = palloc(len);
325  else if (len > *destsz)
326  {
327  dest = repalloc(dest, len);
328  *destsz = len;
329  }
330 
331  memcpy(dest, tuple, len);
332 
333  return dest;
334 }
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:962
void * palloc(Size size)
Definition: mcxt.c:848
BrinMemTuple* brin_deform_tuple ( BrinDesc brdesc,
BrinTuple tuple,
BrinMemTuple dMemtuple 
)

Definition at line 422 of file brin_tuple.c.

References BrinDesc::bd_info, BrinDesc::bd_tupdesc, brin_deconstruct_tuple(), brin_memtuple_initialize(), brin_new_memtuple(), BrinTupleDataOffset, BrinTupleHasNulls, BrinTupleIsPlaceholder, BrinMemTuple::bt_allnulls, BrinMemTuple::bt_blkno, BrinTuple::bt_blkno, BrinMemTuple::bt_columns, BrinMemTuple::bt_context, BrinMemTuple::bt_hasnulls, BrinMemTuple::bt_placeholder, BrinMemTuple::bt_values, BrinValues::bv_allnulls, BrinValues::bv_hasnulls, BrinValues::bv_values, datumCopy(), i, MemoryContextSwitchTo(), tupleDesc::natts, BrinOpcInfo::oi_nstored, BrinOpcInfo::oi_typcache, SizeOfBrinTuple, TypeCacheEntry::typbyval, TypeCacheEntry::typlen, and values.

Referenced by brin_page_items(), bringetbitmap(), brininsert(), and union_tuples().

423 {
424  BrinMemTuple *dtup;
425  Datum *values;
426  bool *allnulls;
427  bool *hasnulls;
428  char *tp;
429  bits8 *nullbits;
430  int keyno;
431  int valueno;
432  MemoryContext oldcxt;
433 
434  dtup = dMemtuple ? brin_memtuple_initialize(dMemtuple, brdesc) :
435  brin_new_memtuple(brdesc);
436 
437  if (BrinTupleIsPlaceholder(tuple))
438  dtup->bt_placeholder = true;
439  dtup->bt_blkno = tuple->bt_blkno;
440 
441  values = dtup->bt_values;
442  allnulls = dtup->bt_allnulls;
443  hasnulls = dtup->bt_hasnulls;
444 
445  tp = (char *) tuple + BrinTupleDataOffset(tuple);
446 
447  if (BrinTupleHasNulls(tuple))
448  nullbits = (bits8 *) ((char *) tuple + SizeOfBrinTuple);
449  else
450  nullbits = NULL;
451  brin_deconstruct_tuple(brdesc,
452  tp, nullbits, BrinTupleHasNulls(tuple),
453  values, allnulls, hasnulls);
454 
455  /*
456  * Iterate to assign each of the values to the corresponding item in the
457  * values array of each column. The copies occur in the tuple's context.
458  */
459  oldcxt = MemoryContextSwitchTo(dtup->bt_context);
460  for (valueno = 0, keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
461  {
462  int i;
463 
464  if (allnulls[keyno])
465  {
466  valueno += brdesc->bd_info[keyno]->oi_nstored;
467  continue;
468  }
469 
470  /*
471  * We would like to skip datumCopy'ing the values datum in some cases,
472  * caller permitting ...
473  */
474  for (i = 0; i < brdesc->bd_info[keyno]->oi_nstored; i++)
475  dtup->bt_columns[keyno].bv_values[i] =
476  datumCopy(values[valueno++],
477  brdesc->bd_info[keyno]->oi_typcache[i]->typbyval,
478  brdesc->bd_info[keyno]->oi_typcache[i]->typlen);
479 
480  dtup->bt_columns[keyno].bv_hasnulls = hasnulls[keyno];
481  dtup->bt_columns[keyno].bv_allnulls = false;
482  }
483 
484  MemoryContextSwitchTo(oldcxt);
485 
486  return dtup;
487 }
#define BrinTupleIsPlaceholder(tup)
Definition: brin_tuple.h:83
#define SizeOfBrinTuple
Definition: brin_tuple.h:71
#define BrinTupleHasNulls(tup)
Definition: brin_tuple.h:82
BlockNumber bt_blkno
Definition: brin_tuple.h:39
bool bv_allnulls
Definition: brin_tuple.h:28
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
BrinMemTuple * brin_new_memtuple(BrinDesc *brdesc)
Definition: brin_tuple.c:357
int16 typlen
Definition: typcache.h:37
bool typbyval
Definition: typcache.h:38
int natts
Definition: tupdesc.h:73
Datum * bt_values
Definition: brin_tuple.h:42
bool bt_placeholder
Definition: brin_tuple.h:38
bool bv_hasnulls
Definition: brin_tuple.h:27
TypeCacheEntry * oi_typcache[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:34
uint16 oi_nstored
Definition: brin_internal.h:28
static void brin_deconstruct_tuple(BrinDesc *brdesc, char *tp, bits8 *nullbits, bool nulls, Datum *values, bool *allnulls, bool *hasnulls)
Definition: brin_tuple.c:505
BrinValues bt_columns[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_tuple.h:46
TupleDesc bd_tupdesc
Definition: brin_internal.h:50
bool * bt_hasnulls
Definition: brin_tuple.h:44
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:128
uint8 bits8
Definition: c.h:265
uintptr_t Datum
Definition: postgres.h:372
BrinOpcInfo * bd_info[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:59
BlockNumber bt_blkno
Definition: brin_tuple.h:57
bool * bt_allnulls
Definition: brin_tuple.h:43
static Datum values[MAXATTR]
Definition: bootstrap.c:164
#define BrinTupleDataOffset(tup)
Definition: brin_tuple.h:81
int i
Datum * bv_values
Definition: brin_tuple.h:29
BrinMemTuple * brin_memtuple_initialize(BrinMemTuple *dtuple, BrinDesc *brdesc)
Definition: brin_tuple.c:384
MemoryContext bt_context
Definition: brin_tuple.h:40
BrinTuple* brin_form_placeholder_tuple ( BrinDesc brdesc,
BlockNumber  blkno,
Size size 
)

Definition at line 263 of file brin_tuple.c.

References BrinDesc::bd_tupdesc, BITMAPLEN, BRIN_NULLS_MASK, BRIN_PLACEHOLDER_MASK, BrinTuple::bt_blkno, BrinTuple::bt_info, HIGHBIT, MAXALIGN, tupleDesc::natts, palloc0(), and SizeOfBrinTuple.

Referenced by summarize_range().

264 {
265  Size len;
266  Size hoff;
267  BrinTuple *rettuple;
268  int keyno;
269  bits8 *bitP;
270  int bitmask;
271 
272  /* compute total space needed: always add nulls */
273  len = SizeOfBrinTuple;
274  len += BITMAPLEN(brdesc->bd_tupdesc->natts * 2);
275  len = hoff = MAXALIGN(len);
276 
277  rettuple = palloc0(len);
278  rettuple->bt_blkno = blkno;
279  rettuple->bt_info = hoff;
281 
282  bitP = ((bits8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
283  bitmask = HIGHBIT;
284  /* set allnulls true for all attributes */
285  for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
286  {
287  if (bitmask != HIGHBIT)
288  bitmask <<= 1;
289  else
290  {
291  bitP += 1;
292  *bitP = 0x0;
293  bitmask = 1;
294  }
295 
296  *bitP |= bitmask;
297  }
298  /* no need to set hasnulls */
299 
300  *size = len;
301  return rettuple;
302 }
#define SizeOfBrinTuple
Definition: brin_tuple.h:71
#define BITMAPLEN(NATTS)
Definition: htup_details.h:548
int natts
Definition: tupdesc.h:73
#define BRIN_NULLS_MASK
Definition: brin_tuple.h:79
TupleDesc bd_tupdesc
Definition: brin_internal.h:50
#define HIGHBIT
Definition: c.h:961
#define BRIN_PLACEHOLDER_MASK
Definition: brin_tuple.h:78
uint8 bits8
Definition: c.h:265
void * palloc0(Size size)
Definition: mcxt.c:877
BlockNumber bt_blkno
Definition: brin_tuple.h:57
size_t Size
Definition: c.h:350
#define MAXALIGN(LEN)
Definition: c.h:576
uint8 bt_info
Definition: brin_tuple.h:68
BrinTuple* brin_form_tuple ( BrinDesc brdesc,
BlockNumber  blkno,
BrinMemTuple tuple,
Size size 
)

Definition at line 89 of file brin_tuple.c.

References Assert, BrinDesc::bd_info, BrinDesc::bd_totalstored, BrinDesc::bd_tupdesc, BITMAPLEN, BRIN_NULLS_MASK, BRIN_OFFSET_MASK, BRIN_PLACEHOLDER_MASK, brtuple_disk_tupdesc(), BrinTuple::bt_blkno, BrinMemTuple::bt_columns, BrinTuple::bt_info, BrinMemTuple::bt_placeholder, BrinValues::bv_allnulls, BrinValues::bv_hasnulls, BrinValues::bv_values, heap_compute_data_size(), heap_fill_tuple(), HIGHBIT, MAXALIGN, tupleDesc::natts, BrinOpcInfo::oi_nstored, palloc(), palloc0(), pfree(), SizeOfBrinTuple, and values.

Referenced by brininsert(), form_and_insert_tuple(), and summarize_range().

91 {
92  Datum *values;
93  bool *nulls;
94  bool anynulls = false;
95  BrinTuple *rettuple;
96  int keyno;
97  int idxattno;
98  uint16 phony_infomask = 0;
99  bits8 *phony_nullbitmap;
100  Size len,
101  hoff,
102  data_len;
103 
104  Assert(brdesc->bd_totalstored > 0);
105 
106  values = (Datum *) palloc(sizeof(Datum) * brdesc->bd_totalstored);
107  nulls = (bool *) palloc0(sizeof(bool) * brdesc->bd_totalstored);
108  phony_nullbitmap = (bits8 *)
109  palloc(sizeof(bits8) * BITMAPLEN(brdesc->bd_totalstored));
110 
111  /*
112  * Set up the values/nulls arrays for heap_fill_tuple
113  */
114  idxattno = 0;
115  for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
116  {
117  int datumno;
118 
119  /*
120  * "allnulls" is set when there's no nonnull value in any row in the
121  * column; when this happens, there is no data to store. Thus set the
122  * nullable bits for all data elements of this column and we're done.
123  */
124  if (tuple->bt_columns[keyno].bv_allnulls)
125  {
126  for (datumno = 0;
127  datumno < brdesc->bd_info[keyno]->oi_nstored;
128  datumno++)
129  nulls[idxattno++] = true;
130  anynulls = true;
131  continue;
132  }
133 
134  /*
135  * The "hasnulls" bit is set when there are some null values in the
136  * data. We still need to store a real value, but the presence of
137  * this means we need a null bitmap.
138  */
139  if (tuple->bt_columns[keyno].bv_hasnulls)
140  anynulls = true;
141 
142  for (datumno = 0;
143  datumno < brdesc->bd_info[keyno]->oi_nstored;
144  datumno++)
145  values[idxattno++] = tuple->bt_columns[keyno].bv_values[datumno];
146  }
147 
148  /* Assert we did not overrun temp arrays */
149  Assert(idxattno <= brdesc->bd_totalstored);
150 
151  /* compute total space needed */
152  len = SizeOfBrinTuple;
153  if (anynulls)
154  {
155  /*
156  * We need a double-length bitmap on an on-disk BRIN index tuple; the
157  * first half stores the "allnulls" bits, the second stores
158  * "hasnulls".
159  */
160  len += BITMAPLEN(brdesc->bd_tupdesc->natts * 2);
161  }
162 
163  len = hoff = MAXALIGN(len);
164 
165  data_len = heap_compute_data_size(brtuple_disk_tupdesc(brdesc),
166  values, nulls);
167  len += data_len;
168 
169  len = MAXALIGN(len);
170 
171  rettuple = palloc0(len);
172  rettuple->bt_blkno = blkno;
173  rettuple->bt_info = hoff;
174 
175  /* Assert that hoff fits in the space available */
176  Assert((rettuple->bt_info & BRIN_OFFSET_MASK) == hoff);
177 
178  /*
179  * The infomask and null bitmap as computed by heap_fill_tuple are useless
180  * to us. However, that function will not accept a null infomask; and we
181  * need to pass a valid null bitmap so that it will correctly skip
182  * outputting null attributes in the data area.
183  */
185  values,
186  nulls,
187  (char *) rettuple + hoff,
188  data_len,
189  &phony_infomask,
190  phony_nullbitmap);
191 
192  /* done with these */
193  pfree(values);
194  pfree(nulls);
195  pfree(phony_nullbitmap);
196 
197  /*
198  * Now fill in the real null bitmasks. allnulls first.
199  */
200  if (anynulls)
201  {
202  bits8 *bitP;
203  int bitmask;
204 
205  rettuple->bt_info |= BRIN_NULLS_MASK;
206 
207  /*
208  * Note that we reverse the sense of null bits in this module: we
209  * store a 1 for a null attribute rather than a 0. So we must reverse
210  * the sense of the att_isnull test in br_deconstruct_tuple as well.
211  */
212  bitP = ((bits8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
213  bitmask = HIGHBIT;
214  for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
215  {
216  if (bitmask != HIGHBIT)
217  bitmask <<= 1;
218  else
219  {
220  bitP += 1;
221  *bitP = 0x0;
222  bitmask = 1;
223  }
224 
225  if (!tuple->bt_columns[keyno].bv_allnulls)
226  continue;
227 
228  *bitP |= bitmask;
229  }
230  /* hasnulls bits follow */
231  for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
232  {
233  if (bitmask != HIGHBIT)
234  bitmask <<= 1;
235  else
236  {
237  bitP += 1;
238  *bitP = 0x0;
239  bitmask = 1;
240  }
241 
242  if (!tuple->bt_columns[keyno].bv_hasnulls)
243  continue;
244 
245  *bitP |= bitmask;
246  }
247  bitP = ((bits8 *) (rettuple + SizeOfBrinTuple)) - 1;
248  }
249 
250  if (tuple->bt_placeholder)
251  rettuple->bt_info |= BRIN_PLACEHOLDER_MASK;
252 
253  *size = len;
254  return rettuple;
255 }
#define BRIN_OFFSET_MASK
Definition: brin_tuple.h:76
void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
Definition: heaptuple.c:145
#define SizeOfBrinTuple
Definition: brin_tuple.h:71
bool bv_allnulls
Definition: brin_tuple.h:28
#define BITMAPLEN(NATTS)
Definition: htup_details.h:548
int natts
Definition: tupdesc.h:73
unsigned short uint16
Definition: c.h:257
void pfree(void *pointer)
Definition: mcxt.c:949
static TupleDesc brtuple_disk_tupdesc(BrinDesc *brdesc)
Definition: brin_tuple.c:51
bool bt_placeholder
Definition: brin_tuple.h:38
bool bv_hasnulls
Definition: brin_tuple.h:27
uint16 oi_nstored
Definition: brin_internal.h:28
int bd_totalstored
Definition: brin_internal.h:56
BrinValues bt_columns[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_tuple.h:46
#define BRIN_NULLS_MASK
Definition: brin_tuple.h:79
TupleDesc bd_tupdesc
Definition: brin_internal.h:50
#define HIGHBIT
Definition: c.h:961
#define BRIN_PLACEHOLDER_MASK
Definition: brin_tuple.h:78
uint8 bits8
Definition: c.h:265
void * palloc0(Size size)
Definition: mcxt.c:877
uintptr_t Datum
Definition: postgres.h:372
BrinOpcInfo * bd_info[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:59
BlockNumber bt_blkno
Definition: brin_tuple.h:57
#define Assert(condition)
Definition: c.h:664
size_t Size
Definition: c.h:350
#define MAXALIGN(LEN)
Definition: c.h:576
Size heap_compute_data_size(TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition: heaptuple.c:85
static Datum values[MAXATTR]
Definition: bootstrap.c:164
uint8 bt_info
Definition: brin_tuple.h:68
void * palloc(Size size)
Definition: mcxt.c:848
Datum * bv_values
Definition: brin_tuple.h:29
void brin_free_tuple ( BrinTuple tuple)

Definition at line 308 of file brin_tuple.c.

References pfree().

Referenced by summarize_range().

309 {
310  pfree(tuple);
311 }
void pfree(void *pointer)
Definition: mcxt.c:949
BrinMemTuple* brin_memtuple_initialize ( BrinMemTuple dtuple,
BrinDesc brdesc 
)

Definition at line 384 of file brin_tuple.c.

References BrinDesc::bd_info, BrinDesc::bd_tupdesc, BrinMemTuple::bt_columns, BrinMemTuple::bt_context, BrinValues::bv_allnulls, BrinValues::bv_attno, BrinValues::bv_hasnulls, BrinValues::bv_values, i, MAXALIGN, MemoryContextReset(), tupleDesc::natts, and BrinOpcInfo::oi_nstored.

Referenced by brin_deform_tuple(), brin_new_memtuple(), brinbuildCallback(), brinsummarize(), and initialize_brin_buildstate().

385 {
386  int i;
387  char *currdatum;
388 
390 
391  currdatum = (char *) dtuple +
392  MAXALIGN(sizeof(BrinMemTuple) +
393  sizeof(BrinValues) * brdesc->bd_tupdesc->natts);
394  for (i = 0; i < brdesc->bd_tupdesc->natts; i++)
395  {
396  dtuple->bt_columns[i].bv_allnulls = true;
397  dtuple->bt_columns[i].bv_hasnulls = false;
398 
399  dtuple->bt_columns[i].bv_attno = i + 1;
400  dtuple->bt_columns[i].bv_allnulls = true;
401  dtuple->bt_columns[i].bv_hasnulls = false;
402  dtuple->bt_columns[i].bv_values = (Datum *) currdatum;
403  currdatum += sizeof(Datum) * brdesc->bd_info[i]->oi_nstored;
404  }
405 
406  return dtuple;
407 }
struct BrinValues BrinValues
bool bv_allnulls
Definition: brin_tuple.h:28
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:135
int natts
Definition: tupdesc.h:73
bool bv_hasnulls
Definition: brin_tuple.h:27
AttrNumber bv_attno
Definition: brin_tuple.h:26
uint16 oi_nstored
Definition: brin_internal.h:28
BrinValues bt_columns[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_tuple.h:46
TupleDesc bd_tupdesc
Definition: brin_internal.h:50
uintptr_t Datum
Definition: postgres.h:372
BrinOpcInfo * bd_info[FLEXIBLE_ARRAY_MEMBER]
Definition: brin_internal.h:59
#define MAXALIGN(LEN)
Definition: c.h:576
int i
Datum * bv_values
Definition: brin_tuple.h:29
MemoryContext bt_context
Definition: brin_tuple.h:40
BrinMemTuple* brin_new_memtuple ( BrinDesc brdesc)

Definition at line 357 of file brin_tuple.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate(), BrinDesc::bd_totalstored, BrinDesc::bd_tupdesc, brin_memtuple_initialize(), BrinMemTuple::bt_allnulls, BrinMemTuple::bt_context, BrinMemTuple::bt_hasnulls, BrinMemTuple::bt_values, CurrentMemoryContext, MAXALIGN, tupleDesc::natts, palloc(), and palloc0().

Referenced by brin_deform_tuple(), bringetbitmap(), and initialize_brin_buildstate().

358 {
359  BrinMemTuple *dtup;
360  long basesize;
361 
362  basesize = MAXALIGN(sizeof(BrinMemTuple) +
363  sizeof(BrinValues) * brdesc->bd_tupdesc->natts);
364  dtup = palloc0(basesize + sizeof(Datum) * brdesc->bd_totalstored);
365 
366  dtup->bt_values = palloc(sizeof(Datum) * brdesc->bd_totalstored);
367  dtup->bt_allnulls = palloc(sizeof(bool) * brdesc->bd_tupdesc->natts);
368  dtup->bt_hasnulls = palloc(sizeof(bool) * brdesc->bd_tupdesc->natts);
369 
371  "brin dtuple",
373 
374  brin_memtuple_initialize(dtup, brdesc);
375 
376  return dtup;
377 }
int natts
Definition: tupdesc.h:73
Datum * bt_values
Definition: brin_tuple.h:42
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:165
int bd_totalstored
Definition: brin_internal.h:56
TupleDesc bd_tupdesc
Definition: brin_internal.h:50
bool * bt_hasnulls
Definition: brin_tuple.h:44
MemoryContext CurrentMemoryContext
Definition: mcxt.c:37
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: aset.c:322
void * palloc0(Size size)
Definition: mcxt.c:877
uintptr_t Datum
Definition: postgres.h:372
bool * bt_allnulls
Definition: brin_tuple.h:43
#define MAXALIGN(LEN)
Definition: c.h:576
void * palloc(Size size)
Definition: mcxt.c:848
BrinMemTuple * brin_memtuple_initialize(BrinMemTuple *dtuple, BrinDesc *brdesc)
Definition: brin_tuple.c:384
MemoryContext bt_context
Definition: brin_tuple.h:40
bool brin_tuples_equal ( const BrinTuple a,
Size  alen,
const BrinTuple b,
Size  blen 
)

Definition at line 340 of file brin_tuple.c.

Referenced by brin_doupdate().

341 {
342  if (alen != blen)
343  return false;
344  if (memcmp(a, b, alen) != 0)
345  return false;
346  return true;
347 }