PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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_EMPTY_RANGE_MASK   0x20
 
#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)
 
#define BrinTupleIsEmptyRange(tup)   (((((BrinTuple *) (tup))->bt_info & BRIN_EMPTY_RANGE_MASK)) != 0)
 

Typedefs

typedef void(* brin_serialize_callback_type) (BrinDesc *bdesc, Datum src, Datum *dst)
 
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

◆ BRIN_EMPTY_RANGE_MASK

#define BRIN_EMPTY_RANGE_MASK   0x20

Definition at line 86 of file brin_tuple.h.

◆ BRIN_NULLS_MASK

#define BRIN_NULLS_MASK   0x80

Definition at line 88 of file brin_tuple.h.

◆ BRIN_OFFSET_MASK

#define BRIN_OFFSET_MASK   0x1F

Definition at line 85 of file brin_tuple.h.

◆ BRIN_PLACEHOLDER_MASK

#define BRIN_PLACEHOLDER_MASK   0x40

Definition at line 87 of file brin_tuple.h.

◆ BrinTupleDataOffset

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

Definition at line 90 of file brin_tuple.h.

◆ BrinTupleHasNulls

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

Definition at line 91 of file brin_tuple.h.

◆ BrinTupleIsEmptyRange

#define BrinTupleIsEmptyRange (   tup)    (((((BrinTuple *) (tup))->bt_info & BRIN_EMPTY_RANGE_MASK)) != 0)

Definition at line 93 of file brin_tuple.h.

◆ BrinTupleIsPlaceholder

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

Definition at line 92 of file brin_tuple.h.

◆ SizeOfBrinTuple

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

Definition at line 80 of file brin_tuple.h.

Typedef Documentation

◆ brin_serialize_callback_type

typedef void(* brin_serialize_callback_type) (BrinDesc *bdesc, Datum src, Datum *dst)

Definition at line 21 of file brin_tuple.h.

◆ BrinMemTuple

◆ BrinTuple

◆ BrinValues

Function Documentation

◆ brin_copy_tuple()

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

Definition at line 446 of file brin_tuple.c.

447{
448 if (!destsz || *destsz == 0)
449 dest = palloc(len);
450 else if (len > *destsz)
451 {
452 dest = repalloc(dest, len);
453 *destsz = len;
454 }
455
456 memcpy(dest, tuple, len);
457
458 return dest;
459}
void * repalloc(void *pointer, Size size)
Definition mcxt.c:1632
void * palloc(Size size)
Definition mcxt.c:1387
const void size_t len
static int fb(int x)

References fb(), len, palloc(), and repalloc().

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

◆ brin_deform_tuple()

BrinMemTuple * brin_deform_tuple ( BrinDesc brdesc,
BrinTuple tuple,
BrinMemTuple dMemtuple 
)
extern

Definition at line 553 of file brin_tuple.c.

554{
556 Datum *values;
557 bool *allnulls;
558 bool *hasnulls;
559 char *tp;
561 int keyno;
562 int valueno;
564
567
568 if (BrinTupleIsPlaceholder(tuple))
569 dtup->bt_placeholder = true;
570
571 /* ranges start as empty, depends on the BrinTuple */
572 if (!BrinTupleIsEmptyRange(tuple))
573 dtup->bt_empty_range = false;
574
575 dtup->bt_blkno = tuple->bt_blkno;
576
577 values = dtup->bt_values;
578 allnulls = dtup->bt_allnulls;
579 hasnulls = dtup->bt_hasnulls;
580
581 tp = (char *) tuple + BrinTupleDataOffset(tuple);
582
583 if (BrinTupleHasNulls(tuple))
584 nullbits = (bits8 *) ((char *) tuple + SizeOfBrinTuple);
585 else
586 nullbits = NULL;
588 tp, nullbits, BrinTupleHasNulls(tuple),
590
591 /*
592 * Iterate to assign each of the values to the corresponding item in the
593 * values array of each column. The copies occur in the tuple's context.
594 */
595 oldcxt = MemoryContextSwitchTo(dtup->bt_context);
596 for (valueno = 0, keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
597 {
598 int i;
599
600 if (allnulls[keyno])
601 {
602 valueno += brdesc->bd_info[keyno]->oi_nstored;
603 continue;
604 }
605
606 /*
607 * We would like to skip datumCopy'ing the values datum in some cases,
608 * caller permitting ...
609 */
610 for (i = 0; i < brdesc->bd_info[keyno]->oi_nstored; i++)
611 dtup->bt_columns[keyno].bv_values[i] =
613 brdesc->bd_info[keyno]->oi_typcache[i]->typbyval,
614 brdesc->bd_info[keyno]->oi_typcache[i]->typlen);
615
616 dtup->bt_columns[keyno].bv_hasnulls = hasnulls[keyno];
617 dtup->bt_columns[keyno].bv_allnulls = false;
618
619 dtup->bt_columns[keyno].bv_mem_value = PointerGetDatum(NULL);
620 dtup->bt_columns[keyno].bv_serialize = NULL;
621 dtup->bt_columns[keyno].bv_context = dtup->bt_context;
622 }
623
625
626 return dtup;
627}
static Datum values[MAXATTR]
Definition bootstrap.c:188
static void brin_deconstruct_tuple(BrinDesc *brdesc, char *tp, bits8 *nullbits, bool nulls, Datum *values, bool *allnulls, bool *hasnulls)
Definition brin_tuple.c:645
BrinMemTuple * brin_new_memtuple(BrinDesc *brdesc)
Definition brin_tuple.c:482
BrinMemTuple * brin_memtuple_initialize(BrinMemTuple *dtuple, BrinDesc *brdesc)
Definition brin_tuple.c:511
#define BrinTupleIsEmptyRange(tup)
Definition brin_tuple.h:93
#define BrinTupleDataOffset(tup)
Definition brin_tuple.h:90
#define BrinTupleIsPlaceholder(tup)
Definition brin_tuple.h:92
#define SizeOfBrinTuple
Definition brin_tuple.h:80
#define BrinTupleHasNulls(tup)
Definition brin_tuple.h:91
uint8 bits8
Definition c.h:625
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition datum.c:132
int i
Definition isn.c:77
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
static Datum PointerGetDatum(const void *X)
Definition postgres.h:342
uint64_t Datum
Definition postgres.h:70
bool bt_placeholder
Definition brin_tuple.h:46
BlockNumber bt_blkno
Definition brin_tuple.h:66

References brin_deconstruct_tuple(), brin_memtuple_initialize(), brin_new_memtuple(), BrinTupleDataOffset, BrinTupleHasNulls, BrinTupleIsEmptyRange, BrinTupleIsPlaceholder, BrinTuple::bt_blkno, datumCopy(), fb(), i, MemoryContextSwitchTo(), PointerGetDatum(), SizeOfBrinTuple, and values.

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

◆ brin_form_placeholder_tuple()

BrinTuple * brin_form_placeholder_tuple ( BrinDesc brdesc,
BlockNumber  blkno,
Size size 
)
extern

Definition at line 388 of file brin_tuple.c.

389{
390 Size len;
391 Size hoff;
393 int keyno;
394 bits8 *bitP;
395 int bitmask;
396
397 /* compute total space needed: always add nulls */
399 len += BITMAPLEN(brdesc->bd_tupdesc->natts * 2);
400 len = hoff = MAXALIGN(len);
401
403 rettuple->bt_blkno = blkno;
404 rettuple->bt_info = hoff;
406
407 bitP = ((bits8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
408 bitmask = HIGHBIT;
409 /* set allnulls true for all attributes */
410 for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
411 {
412 if (bitmask != HIGHBIT)
413 bitmask <<= 1;
414 else
415 {
416 bitP += 1;
417 *bitP = 0x0;
418 bitmask = 1;
419 }
420
421 *bitP |= bitmask;
422 }
423 /* no need to set hasnulls */
424
425 *size = len;
426 return rettuple;
427}
#define BRIN_EMPTY_RANGE_MASK
Definition brin_tuple.h:86
#define BRIN_PLACEHOLDER_MASK
Definition brin_tuple.h:87
#define BRIN_NULLS_MASK
Definition brin_tuple.h:88
#define MAXALIGN(LEN)
Definition c.h:898
#define HIGHBIT
Definition c.h:1245
size_t Size
Definition c.h:691
static int BITMAPLEN(int NATTS)
void * palloc0(Size size)
Definition mcxt.c:1417

References BITMAPLEN(), BRIN_EMPTY_RANGE_MASK, BRIN_NULLS_MASK, BRIN_PLACEHOLDER_MASK, fb(), HIGHBIT, len, MAXALIGN, palloc0(), and SizeOfBrinTuple.

Referenced by summarize_range().

◆ brin_form_tuple()

BrinTuple * brin_form_tuple ( BrinDesc brdesc,
BlockNumber  blkno,
BrinMemTuple tuple,
Size size 
)
extern

Definition at line 100 of file brin_tuple.c.

102{
103 Datum *values;
104 bool *nulls;
105 bool anynulls = false;
107 int keyno;
108 int idxattno;
111 Size len,
112 hoff,
113 data_len;
114 int i;
115
116#ifdef TOAST_INDEX_HACK
118 int nuntoasted = 0;
119#endif
120
121 Assert(brdesc->bd_totalstored > 0);
122
123 values = palloc_array(Datum, brdesc->bd_totalstored);
124 nulls = palloc0_array(bool, brdesc->bd_totalstored);
126
127#ifdef TOAST_INDEX_HACK
128 untoasted_values = palloc_array(Datum, brdesc->bd_totalstored);
129#endif
130
131 /*
132 * Set up the values/nulls arrays for heap_fill_tuple
133 */
134 idxattno = 0;
135 for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
136 {
137 int datumno;
138
139 /*
140 * "allnulls" is set when there's no nonnull value in any row in the
141 * column; when this happens, there is no data to store. Thus set the
142 * nullable bits for all data elements of this column and we're done.
143 */
144 if (tuple->bt_columns[keyno].bv_allnulls)
145 {
146 for (datumno = 0;
147 datumno < brdesc->bd_info[keyno]->oi_nstored;
148 datumno++)
149 nulls[idxattno++] = true;
150 anynulls = true;
151 continue;
152 }
153
154 /*
155 * The "hasnulls" bit is set when there are some null values in the
156 * data. We still need to store a real value, but the presence of
157 * this means we need a null bitmap.
158 */
159 if (tuple->bt_columns[keyno].bv_hasnulls)
160 anynulls = true;
161
162 /* If needed, serialize the values before forming the on-disk tuple. */
163 if (tuple->bt_columns[keyno].bv_serialize)
164 {
165 tuple->bt_columns[keyno].bv_serialize(brdesc,
166 tuple->bt_columns[keyno].bv_mem_value,
167 tuple->bt_columns[keyno].bv_values);
168 }
169
170 /*
171 * Now obtain the values of each stored datum. Note that some values
172 * might be toasted, and we cannot rely on the original heap values
173 * sticking around forever, so we must detoast them. Also try to
174 * compress them.
175 */
176 for (datumno = 0;
177 datumno < brdesc->bd_info[keyno]->oi_nstored;
178 datumno++)
179 {
180 Datum value = tuple->bt_columns[keyno].bv_values[datumno];
181
182#ifdef TOAST_INDEX_HACK
183
184 /* We must look at the stored type, not at the index descriptor. */
185 TypeCacheEntry *atttype = brdesc->bd_info[keyno]->oi_typcache[datumno];
186
187 /* Do we need to free the value at the end? */
188 bool free_value = false;
189
190 /* For non-varlena types we don't need to do anything special */
191 if (atttype->typlen != -1)
192 {
193 values[idxattno++] = value;
194 continue;
195 }
196
197 /*
198 * Do nothing if value is not of varlena type. We don't need to
199 * care about NULL values here, thanks to bv_allnulls above.
200 *
201 * If value is stored EXTERNAL, must fetch it so we are not
202 * depending on outside storage.
203 *
204 * XXX Is this actually true? Could it be that the summary is NULL
205 * even for range with non-NULL data? E.g. degenerate bloom filter
206 * may be thrown away, etc.
207 */
209 {
212 free_value = true;
213 }
214
215 /*
216 * If value is above size target, and is of a compressible
217 * datatype, try to compress it in-line.
218 */
221 (atttype->typstorage == TYPSTORAGE_EXTENDED ||
222 atttype->typstorage == TYPSTORAGE_MAIN))
223 {
225 char compression;
227 keyno);
228
229 /*
230 * If the BRIN summary and indexed attribute use the same data
231 * type and it has a valid compression method, we can use the
232 * same compression method. Otherwise we have to use the
233 * default method.
234 */
235 if (att->atttypid == atttype->type_id)
236 compression = att->attcompression;
237 else
238 compression = InvalidCompressionMethod;
239
240 cvalue = toast_compress_datum(value, compression);
241
243 {
244 /* successful compression */
245 if (free_value)
247
248 value = cvalue;
249 free_value = true;
250 }
251 }
252
253 /*
254 * If we untoasted / compressed the value, we need to free it
255 * after forming the index tuple.
256 */
257 if (free_value)
259
260#endif
261
262 values[idxattno++] = value;
263 }
264 }
265
266 /* Assert we did not overrun temp arrays */
267 Assert(idxattno <= brdesc->bd_totalstored);
268
269 /* compute total space needed */
271 if (anynulls)
272 {
273 /*
274 * We need a double-length bitmap on an on-disk BRIN index tuple; the
275 * first half stores the "allnulls" bits, the second stores
276 * "hasnulls".
277 */
278 len += BITMAPLEN(brdesc->bd_tupdesc->natts * 2);
279 }
280
281 len = hoff = MAXALIGN(len);
282
284 values, nulls);
285 len += data_len;
286
287 len = MAXALIGN(len);
288
290 rettuple->bt_blkno = blkno;
291 rettuple->bt_info = hoff;
292
293 /* Assert that hoff fits in the space available */
294 Assert((rettuple->bt_info & BRIN_OFFSET_MASK) == hoff);
295
296 /*
297 * The infomask and null bitmap as computed by heap_fill_tuple are useless
298 * to us. However, that function will not accept a null infomask; and we
299 * need to pass a valid null bitmap so that it will correctly skip
300 * outputting null attributes in the data area.
301 */
303 values,
304 nulls,
305 (char *) rettuple + hoff,
306 data_len,
309
310 /* done with these */
311 pfree(values);
312 pfree(nulls);
314
315#ifdef TOAST_INDEX_HACK
316 for (i = 0; i < nuntoasted; i++)
318#endif
319
320 /*
321 * Now fill in the real null bitmasks. allnulls first.
322 */
323 if (anynulls)
324 {
325 bits8 *bitP;
326 int bitmask;
327
328 rettuple->bt_info |= BRIN_NULLS_MASK;
329
330 /*
331 * Note that we reverse the sense of null bits in this module: we
332 * store a 1 for a null attribute rather than a 0. So we must reverse
333 * the sense of the att_isnull test in brin_deconstruct_tuple as well.
334 */
335 bitP = ((bits8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
336 bitmask = HIGHBIT;
337 for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
338 {
339 if (bitmask != HIGHBIT)
340 bitmask <<= 1;
341 else
342 {
343 bitP += 1;
344 *bitP = 0x0;
345 bitmask = 1;
346 }
347
348 if (!tuple->bt_columns[keyno].bv_allnulls)
349 continue;
350
351 *bitP |= bitmask;
352 }
353 /* hasnulls bits follow */
354 for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
355 {
356 if (bitmask != HIGHBIT)
357 bitmask <<= 1;
358 else
359 {
360 bitP += 1;
361 *bitP = 0x0;
362 bitmask = 1;
363 }
364
365 if (!tuple->bt_columns[keyno].bv_hasnulls)
366 continue;
367
368 *bitP |= bitmask;
369 }
370 }
371
372 if (tuple->bt_placeholder)
374
375 if (tuple->bt_empty_range)
377
378 *size = len;
379 return rettuple;
380}
static TupleDesc brtuple_disk_tupdesc(BrinDesc *brdesc)
Definition brin_tuple.c:61
#define BRIN_OFFSET_MASK
Definition brin_tuple.h:85
#define Assert(condition)
Definition c.h:945
uint16_t uint16
Definition c.h:617
varlena * detoast_external_attr(varlena *attr)
Definition detoast.c:45
#define palloc_array(type, count)
Definition fe_memutils.h:76
#define palloc0_array(type, count)
Definition fe_memutils.h:77
#define TOAST_INDEX_TARGET
Definition heaptoast.h:68
Size heap_compute_data_size(TupleDesc tupleDesc, const Datum *values, const bool *isnull)
Definition heaptuple.c:219
void heap_fill_tuple(TupleDesc tupleDesc, const Datum *values, const bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
Definition heaptuple.c:401
static struct @175 value
void pfree(void *pointer)
Definition mcxt.c:1616
FormData_pg_attribute * Form_pg_attribute
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:332
BrinValues bt_columns[FLEXIBLE_ARRAY_MEMBER]
Definition brin_tuple.h:55
bool bt_empty_range
Definition brin_tuple.h:47
bool bv_hasnulls
Definition brin_tuple.h:32
Datum bv_mem_value
Definition brin_tuple.h:35
brin_serialize_callback_type bv_serialize
Definition brin_tuple.h:37
Datum * bv_values
Definition brin_tuple.h:34
bool bv_allnulls
Definition brin_tuple.h:33
char typstorage
Definition typcache.h:42
Definition c.h:778
#define InvalidCompressionMethod
Datum toast_compress_datum(Datum value, char cmethod)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:178
static bool VARATT_IS_EXTENDED(const void *PTR)
Definition varatt.h:410
static bool VARATT_IS_EXTERNAL(const void *PTR)
Definition varatt.h:354
static Size VARSIZE(const void *PTR)
Definition varatt.h:298

References Assert, BITMAPLEN(), BRIN_EMPTY_RANGE_MASK, BRIN_NULLS_MASK, BRIN_OFFSET_MASK, BRIN_PLACEHOLDER_MASK, brtuple_disk_tupdesc(), BrinMemTuple::bt_columns, BrinMemTuple::bt_empty_range, BrinMemTuple::bt_placeholder, BrinValues::bv_allnulls, BrinValues::bv_hasnulls, BrinValues::bv_mem_value, BrinValues::bv_serialize, BrinValues::bv_values, DatumGetPointer(), detoast_external_attr(), fb(), heap_compute_data_size(), heap_fill_tuple(), HIGHBIT, i, InvalidCompressionMethod, len, MAXALIGN, palloc0(), palloc0_array, palloc_array, pfree(), PointerGetDatum(), SizeOfBrinTuple, toast_compress_datum(), TOAST_INDEX_TARGET, TupleDescAttr(), TypeCacheEntry::type_id, TypeCacheEntry::typlen, TypeCacheEntry::typstorage, value, values, VARATT_IS_EXTENDED(), VARATT_IS_EXTERNAL(), and VARSIZE().

Referenced by _brin_parallel_merge(), brin_build_empty_tuple(), brininsert(), form_and_insert_tuple(), form_and_spill_tuple(), and summarize_range().

◆ brin_free_tuple()

void brin_free_tuple ( BrinTuple tuple)
extern

Definition at line 433 of file brin_tuple.c.

434{
435 pfree(tuple);
436}

References pfree().

Referenced by summarize_range().

◆ brin_memtuple_initialize()

BrinMemTuple * brin_memtuple_initialize ( BrinMemTuple dtuple,
BrinDesc brdesc 
)
extern

Definition at line 511 of file brin_tuple.c.

512{
513 int i;
514 char *currdatum;
515
516 MemoryContextReset(dtuple->bt_context);
517
518 currdatum = (char *) dtuple +
519 MAXALIGN(sizeof(BrinMemTuple) +
520 sizeof(BrinValues) * brdesc->bd_tupdesc->natts);
521 for (i = 0; i < brdesc->bd_tupdesc->natts; i++)
522 {
523 dtuple->bt_columns[i].bv_attno = i + 1;
524 dtuple->bt_columns[i].bv_allnulls = true;
525 dtuple->bt_columns[i].bv_hasnulls = false;
526 dtuple->bt_columns[i].bv_values = (Datum *) currdatum;
527
528 dtuple->bt_columns[i].bv_mem_value = PointerGetDatum(NULL);
529 dtuple->bt_columns[i].bv_serialize = NULL;
530 dtuple->bt_columns[i].bv_context = dtuple->bt_context;
531
532 currdatum += sizeof(Datum) * brdesc->bd_info[i]->oi_nstored;
533 }
534
535 dtuple->bt_empty_range = true;
536
537 return dtuple;
538}
void MemoryContextReset(MemoryContext context)
Definition mcxt.c:403

References fb(), i, MAXALIGN, MemoryContextReset(), and PointerGetDatum().

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

◆ brin_new_memtuple()

BrinMemTuple * brin_new_memtuple ( BrinDesc brdesc)
extern

Definition at line 482 of file brin_tuple.c.

483{
485 long basesize;
486
487 basesize = MAXALIGN(sizeof(BrinMemTuple) +
488 sizeof(BrinValues) * brdesc->bd_tupdesc->natts);
489 dtup = palloc0(basesize + sizeof(Datum) * brdesc->bd_totalstored);
490
491 dtup->bt_values = palloc_array(Datum, brdesc->bd_totalstored);
492 dtup->bt_allnulls = palloc_array(bool, brdesc->bd_tupdesc->natts);
493 dtup->bt_hasnulls = palloc_array(bool, brdesc->bd_tupdesc->natts);
494
495 dtup->bt_empty_range = true;
496
498 "brin dtuple",
500
502
503 return dtup;
504}
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition memutils.h:160

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, brin_memtuple_initialize(), CurrentMemoryContext, fb(), MAXALIGN, palloc0(), and palloc_array.

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

◆ brin_tuples_equal()

bool brin_tuples_equal ( const BrinTuple a,
Size  alen,
const BrinTuple b,
Size  blen 
)
extern

Definition at line 465 of file brin_tuple.c.

466{
467 if (alen != blen)
468 return false;
469 if (memcmp(a, b, alen) != 0)
470 return false;
471 return true;
472}
int b
Definition isn.c:74
int a
Definition isn.c:73

References a, b, and fb().

Referenced by brin_doupdate().