PostgreSQL Source Code git master
Loading...
Searching...
No Matches
heaptoast.c File Reference
#include "postgres.h"
#include "access/detoast.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "access/heaptoast.h"
#include "access/toast_helper.h"
#include "access/toast_internals.h"
#include "utils/fmgroids.h"
Include dependency graph for heaptoast.c:

Go to the source code of this file.

Functions

void heap_toast_delete (Relation rel, HeapTuple oldtup, bool is_speculative)
 
HeapTuple heap_toast_insert_or_update (Relation rel, HeapTuple newtup, HeapTuple oldtup, int options)
 
HeapTuple toast_flatten_tuple (HeapTuple tup, TupleDesc tupleDesc)
 
Datum toast_flatten_tuple_to_datum (HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
 
HeapTuple toast_build_flattened_tuple (TupleDesc tupleDesc, const Datum *values, const bool *isnull)
 
void heap_fetch_toast_slice (Relation toastrel, Oid valueid, int32 attrsize, int32 sliceoffset, int32 slicelength, struct varlena *result)
 

Function Documentation

◆ heap_fetch_toast_slice()

void heap_fetch_toast_slice ( Relation  toastrel,
Oid  valueid,
int32  attrsize,
int32  sliceoffset,
int32  slicelength,
struct varlena result 
)

Definition at line 626 of file heaptoast.c.

629{
633 int nscankeys;
638 int startchunk;
639 int endchunk;
640 int num_indexes;
641 int validIndex;
642
643 /* Look for the valid index of toast relation */
646 &toastidxs,
647 &num_indexes);
648
652
653 /* Set up a scan key to fetch from the index. */
655 (AttrNumber) 1,
658
659 /*
660 * No additional condition if fetching all chunks. Otherwise, use an
661 * equality condition for one chunk, and a range condition otherwise.
662 */
663 if (startchunk == 0 && endchunk == totalchunks - 1)
664 nscankeys = 1;
665 else if (startchunk == endchunk)
666 {
668 (AttrNumber) 2,
671 nscankeys = 2;
672 }
673 else
674 {
676 (AttrNumber) 2,
680 (AttrNumber) 2,
683 nscankeys = 3;
684 }
685
686 /* Prepare for scan */
689
690 /*
691 * Read the chunks by index
692 *
693 * The index is on (valueid, chunkidx) so they will come in order
694 */
697 {
700 bool isnull;
701 char *chunkdata;
706
707 /*
708 * Have a chunk, extract the sequence number and the data
709 */
711 Assert(!isnull);
713 Assert(!isnull);
715 {
718 }
719 else if (VARATT_IS_SHORT(chunk))
720 {
721 /* could happen due to heap_form_tuple doing its thing */
724 }
725 else
726 {
727 /* should never happen */
728 elog(ERROR, "found toasted toast chunk for toast value %u in %s",
730 chunksize = 0; /* keep compiler quiet */
731 chunkdata = NULL;
732 }
733
734 /*
735 * Some checks on the data we've found
736 */
737 if (curchunk != expectedchunk)
740 errmsg_internal("unexpected chunk number %d (expected %d) for toast value %u in %s",
743 if (curchunk > endchunk)
746 errmsg_internal("unexpected chunk number %d (out of range %d..%d) for toast value %u in %s",
747 curchunk,
755 errmsg_internal("unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %u in %s",
759
760 /*
761 * Copy the data into proper place in our result
762 */
763 chcpystrt = 0;
764 chcpyend = chunksize - 1;
765 if (curchunk == startchunk)
767 if (curchunk == endchunk)
769
770 memcpy(VARDATA(result) +
773 (chcpyend - chcpystrt) + 1);
774
776 }
777
778 /*
779 * Final checks that we successfully fetched the datum
780 */
781 if (expectedchunk != (endchunk + 1))
784 errmsg_internal("missing chunk number %d for toast value %u in %s",
787
788 /* End scan and close indexes. */
791}
int16 AttrNumber
Definition attnum.h:21
#define VARHDRSZ
Definition c.h:711
#define Assert(condition)
Definition c.h:873
int32_t int32
Definition c.h:542
void * Pointer
Definition c.h:537
int errmsg_internal(const char *fmt,...)
Definition elog.c:1170
int errcode(int sqlerrcode)
Definition elog.c:863
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
#define ereport(elevel,...)
Definition elog.h:150
SysScanDesc systable_beginscan_ordered(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, ScanKey key)
Definition genam.c:650
void systable_endscan_ordered(SysScanDesc sysscan)
Definition genam.c:757
HeapTuple systable_getnext_ordered(SysScanDesc sysscan, ScanDirection direction)
Definition genam.c:732
#define TOAST_MAX_CHUNK_SIZE
Definition heaptoast.h:84
static Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
#define AccessShareLock
Definition lockdefs.h:36
#define ERRCODE_DATA_CORRUPTED
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:342
static Datum Int32GetDatum(int32 X)
Definition postgres.h:222
static int32 DatumGetInt32(Datum X)
Definition postgres.h:212
static int fb(int x)
#define RelationGetRelationName(relation)
Definition rel.h:548
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition scankey.c:76
@ ForwardScanDirection
Definition sdir.h:28
#define BTEqualStrategyNumber
Definition stratnum.h:31
#define BTLessEqualStrategyNumber
Definition stratnum.h:30
#define BTGreaterEqualStrategyNumber
Definition stratnum.h:32
void toast_close_indexes(Relation *toastidxs, int num_indexes, LOCKMODE lock)
int toast_open_indexes(Relation toastrel, LOCKMODE lock, Relation **toastidxs, int *num_indexes)
Snapshot get_toast_snapshot(void)
#define VARHDRSZ_SHORT
Definition varatt.h:278
static bool VARATT_IS_SHORT(const void *PTR)
Definition varatt.h:403
static bool VARATT_IS_EXTENDED(const void *PTR)
Definition varatt.h:410
static Size VARSIZE(const void *PTR)
Definition varatt.h:298
static char * VARDATA(const void *PTR)
Definition varatt.h:305
static char * VARDATA_SHORT(const void *PTR)
Definition varatt.h:319
static Size VARSIZE_SHORT(const void *PTR)
Definition varatt.h:312

References AccessShareLock, Assert, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTLessEqualStrategyNumber, DatumGetInt32(), DatumGetPointer(), elog, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errmsg_internal(), ERROR, fastgetattr(), fb(), ForwardScanDirection, get_toast_snapshot(), Int32GetDatum(), ObjectIdGetDatum(), RelationGetRelationName, ScanKeyInit(), systable_beginscan_ordered(), systable_endscan_ordered(), systable_getnext_ordered(), toast_close_indexes(), TOAST_MAX_CHUNK_SIZE, toast_open_indexes(), VARATT_IS_EXTENDED(), VARATT_IS_SHORT(), VARDATA(), VARDATA_SHORT(), VARHDRSZ, VARHDRSZ_SHORT, VARSIZE(), and VARSIZE_SHORT().

◆ heap_toast_delete()

void heap_toast_delete ( Relation  rel,
HeapTuple  oldtup,
bool  is_speculative 
)

Definition at line 43 of file heaptoast.c.

44{
48
49 /*
50 * We should only ever be called for tuples of plain relations or
51 * materialized views --- recursing on a toast rel is bad news.
52 */
53 Assert(rel->rd_rel->relkind == RELKIND_RELATION ||
54 rel->rd_rel->relkind == RELKIND_MATVIEW);
55
56 /*
57 * Get the tuple descriptor and break down the tuple into fields.
58 *
59 * NOTE: it's debatable whether to use heap_deform_tuple() here or just
60 * heap_getattr() only the varlena columns. The latter could win if there
61 * are few varlena columns and many non-varlena ones. However,
62 * heap_deform_tuple costs only O(N) while the heap_getattr way would cost
63 * O(N^2) if there are many varlena columns, so it seems better to err on
64 * the side of linear cost. (We won't even be here unless there's at
65 * least one varlena column, by the way.)
66 */
67 tupleDesc = rel->rd_att;
68
71
72 /* Do the real work. */
74}
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
Definition heaptuple.c:1346
#define MaxHeapAttributeNumber
uint64_t Datum
Definition postgres.h:70
TupleDesc rd_att
Definition rel.h:112
Form_pg_class rd_rel
Definition rel.h:111
void toast_delete_external(Relation rel, const Datum *values, const bool *isnull, bool is_speculative)

References Assert, fb(), heap_deform_tuple(), MaxHeapAttributeNumber, RelationData::rd_att, RelationData::rd_rel, and toast_delete_external().

Referenced by heap_abort_speculative(), and heap_delete().

◆ heap_toast_insert_or_update()

HeapTuple heap_toast_insert_or_update ( Relation  rel,
HeapTuple  newtup,
HeapTuple  oldtup,
int  options 
)

Definition at line 96 of file heaptoast.c.

98{
101 int numAttrs;
102
104 Size hoff;
105
112
113 /*
114 * Ignore the INSERT_SPECULATIVE option. Speculative insertions/super
115 * deletions just normally insert/delete the toast values. It seems
116 * easiest to deal with that here, instead on, potentially, multiple
117 * callers.
118 */
120
121 /*
122 * We should only ever be called for tuples of plain relations or
123 * materialized views --- recursing on a toast rel is bad news.
124 */
125 Assert(rel->rd_rel->relkind == RELKIND_RELATION ||
126 rel->rd_rel->relkind == RELKIND_MATVIEW);
127
128 /*
129 * Get the tuple descriptor and break down the tuple(s) into fields.
130 */
131 tupleDesc = rel->rd_att;
133
136 if (oldtup != NULL)
138
139 /* ----------
140 * Prepare for toasting
141 * ----------
142 */
143 ttc.ttc_rel = rel;
144 ttc.ttc_values = toast_values;
145 ttc.ttc_isnull = toast_isnull;
146 if (oldtup == NULL)
147 {
148 ttc.ttc_oldvalues = NULL;
149 ttc.ttc_oldisnull = NULL;
150 }
151 else
152 {
153 ttc.ttc_oldvalues = toast_oldvalues;
154 ttc.ttc_oldisnull = toast_oldisnull;
155 }
156 ttc.ttc_attr = toast_attr;
158
159 /* ----------
160 * Compress and/or save external until data fits into target length
161 *
162 * 1: Inline compress attributes with attstorage EXTENDED, and store very
163 * large attributes with attstorage EXTENDED or EXTERNAL external
164 * immediately
165 * 2: Store attributes with attstorage EXTENDED or EXTERNAL external
166 * 3: Inline compress attributes with attstorage MAIN
167 * 4: Store attributes with attstorage MAIN external
168 * ----------
169 */
170
171 /* compute header overhead --- this should match heap_form_tuple() */
173 if ((ttc.ttc_flags & TOAST_HAS_NULLS) != 0)
174 hoff += BITMAPLEN(numAttrs);
175 hoff = MAXALIGN(hoff);
176 /* now convert to a limit on the tuple data size */
178
179 /*
180 * Look for attributes with attstorage EXTENDED to compress. Also find
181 * large attributes with attstorage EXTENDED or EXTERNAL, and store them
182 * external.
183 */
186 {
187 int biggest_attno;
188
190 if (biggest_attno < 0)
191 break;
192
193 /*
194 * Attempt to compress it inline, if it has attstorage EXTENDED
195 */
198 else
199 {
200 /*
201 * has attstorage EXTERNAL, ignore on subsequent compression
202 * passes
203 */
205 }
206
207 /*
208 * If this value is by itself more than maxDataLen (after compression
209 * if any), push it out to the toast table immediately, if possible.
210 * This avoids uselessly compressing other fields in the common case
211 * where we have one long field and several short ones.
212 *
213 * XXX maybe the threshold should be less than maxDataLen?
214 */
215 if (toast_attr[biggest_attno].tai_size > maxDataLen &&
216 rel->rd_rel->reltoastrelid != InvalidOid)
218 }
219
220 /*
221 * Second we look for attributes of attstorage EXTENDED or EXTERNAL that
222 * are still inline, and make them external. But skip this if there's no
223 * toast table to push them to.
224 */
227 rel->rd_rel->reltoastrelid != InvalidOid)
228 {
229 int biggest_attno;
230
232 if (biggest_attno < 0)
233 break;
235 }
236
237 /*
238 * Round 3 - this time we take attributes with storage MAIN into
239 * compression
240 */
243 {
244 int biggest_attno;
245
247 if (biggest_attno < 0)
248 break;
249
251 }
252
253 /*
254 * Finally we store attributes of type MAIN externally. At this point we
255 * increase the target tuple size, so that MAIN attributes aren't stored
256 * externally unless really necessary.
257 */
259
262 rel->rd_rel->reltoastrelid != InvalidOid)
263 {
264 int biggest_attno;
265
267 if (biggest_attno < 0)
268 break;
269
271 }
272
273 /*
274 * In the case we toasted any values, we need to build a new heap tuple
275 * with the changed values.
276 */
277 if ((ttc.ttc_flags & TOAST_NEEDS_CHANGE) != 0)
278 {
284
285 /*
286 * Calculate the new size of the tuple.
287 *
288 * Note: we used to assume here that the old tuple's t_hoff must equal
289 * the new_header_len value, but that was incorrect. The old tuple
290 * might have a smaller-than-current natts, if there's been an ALTER
291 * TABLE ADD COLUMN since it was stored; and that would lead to a
292 * different conclusion about the size of the null bitmap, or even
293 * whether there needs to be one at all.
294 */
296 if ((ttc.ttc_flags & TOAST_HAS_NULLS) != 0)
302
303 /*
304 * Allocate and zero the space needed, and fill HeapTupleData fields.
305 */
308 result_tuple->t_self = newtup->t_self;
309 result_tuple->t_tableOid = newtup->t_tableOid;
311 result_tuple->t_data = new_data;
312
313 /*
314 * Copy the existing tuple header, but adjust natts and t_hoff.
315 */
318 new_data->t_hoff = new_header_len;
319
320 /* Copy over the data, and fill the null bitmap if needed */
324 (char *) new_data + new_header_len,
326 &(new_data->t_infomask),
327 ((ttc.ttc_flags & TOAST_HAS_NULLS) != 0) ?
328 new_data->t_bits : NULL);
329 }
330 else
332
334
335 return result_tuple;
336}
#define MAXALIGN(LEN)
Definition c.h:826
size_t Size
Definition c.h:619
#define TOAST_TUPLE_TARGET
Definition heaptoast.h:50
#define TOAST_TUPLE_TARGET_MAIN
Definition heaptoast.h:61
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
#define HEAPTUPLESIZE
Definition htup.h:73
HeapTupleData * HeapTuple
Definition htup.h:71
HeapTupleHeaderData * HeapTupleHeader
Definition htup.h:23
#define SizeofHeapTupleHeader
static int BITMAPLEN(int NATTS)
#define HeapTupleHeaderSetNatts(tup, natts)
void * palloc0(Size size)
Definition mcxt.c:1417
char attstorage
#define InvalidOid
#define RelationGetToastTupleTarget(relation, defaulttarg)
Definition rel.h:366
void toast_tuple_init(ToastTupleContext *ttc)
void toast_tuple_try_compression(ToastTupleContext *ttc, int attribute)
void toast_tuple_externalize(ToastTupleContext *ttc, int attribute, int options)
void toast_tuple_cleanup(ToastTupleContext *ttc)
int toast_tuple_find_biggest_attribute(ToastTupleContext *ttc, bool for_compression, bool check_main)
#define TOAST_NEEDS_CHANGE
#define TOAST_HAS_NULLS
#define TOASTCOL_INCOMPRESSIBLE
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:160

References Assert, attstorage, BITMAPLEN(), fb(), heap_compute_data_size(), heap_deform_tuple(), heap_fill_tuple(), HeapTupleHeaderSetNatts, HEAPTUPLESIZE, InvalidOid, MAXALIGN, MaxHeapAttributeNumber, TupleDescData::natts, palloc0(), RelationData::rd_att, RelationData::rd_rel, RelationGetToastTupleTarget, SizeofHeapTupleHeader, TOAST_HAS_NULLS, TOAST_NEEDS_CHANGE, toast_tuple_cleanup(), toast_tuple_externalize(), toast_tuple_find_biggest_attribute(), toast_tuple_init(), TOAST_TUPLE_TARGET, TOAST_TUPLE_TARGET_MAIN, toast_tuple_try_compression(), TOASTCOL_INCOMPRESSIBLE, and TupleDescAttr().

Referenced by heap_prepare_insert(), heap_update(), and raw_heap_insert().

◆ toast_build_flattened_tuple()

HeapTuple toast_build_flattened_tuple ( TupleDesc  tupleDesc,
const Datum values,
const bool isnull 
)

Definition at line 563 of file heaptoast.c.

566{
568 int numAttrs = tupleDesc->natts;
569 int num_to_free;
570 int i;
573
574 /*
575 * We can pass the caller's isnull array directly to heap_form_tuple, but
576 * we potentially need to modify the values array.
577 */
580
581 num_to_free = 0;
582 for (i = 0; i < numAttrs; i++)
583 {
584 /*
585 * Look at non-null varlena attributes
586 */
587 if (!isnull[i] && TupleDescCompactAttr(tupleDesc, i)->attlen == -1)
588 {
589 struct varlena *new_value;
590
593 {
597 }
598 }
599 }
600
601 /*
602 * Form the reconfigured tuple.
603 */
605
606 /*
607 * Free allocated temp values
608 */
609 for (i = 0; i < num_to_free; i++)
611
612 return new_tuple;
613}
static Datum values[MAXATTR]
Definition bootstrap.c:155
struct varlena * detoast_external_attr(struct varlena *attr)
Definition detoast.c:45
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1117
#define MaxTupleAttributeNumber
int i
Definition isn.c:77
void pfree(void *pointer)
Definition mcxt.c:1616
int16 attlen
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
Definition c.h:706
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:175
static bool VARATT_IS_EXTERNAL(const void *PTR)
Definition varatt.h:354

References Assert, attlen, DatumGetPointer(), detoast_external_attr(), fb(), heap_form_tuple(), i, MaxTupleAttributeNumber, pfree(), PointerGetDatum(), TupleDescCompactAttr(), values, and VARATT_IS_EXTERNAL().

Referenced by ExecEvalWholeRowVar().

◆ toast_flatten_tuple()

HeapTuple toast_flatten_tuple ( HeapTuple  tup,
TupleDesc  tupleDesc 
)

Definition at line 350 of file heaptoast.c.

351{
353 int numAttrs = tupleDesc->natts;
354 int i;
358
359 /*
360 * Break down the tuple into fields.
361 */
364
365 memset(toast_free, 0, numAttrs * sizeof(bool));
366
367 for (i = 0; i < numAttrs; i++)
368 {
369 /*
370 * Look at non-null varlena attributes
371 */
373 {
374 struct varlena *new_value;
375
378 {
381 toast_free[i] = true;
382 }
383 }
384 }
385
386 /*
387 * Form the reconfigured tuple.
388 */
390
391 /*
392 * Be sure to copy the tuple's identity fields. We also make a point of
393 * copying visibility info, just in case anybody looks at those fields in
394 * a syscache entry.
395 */
396 new_tuple->t_self = tup->t_self;
397 new_tuple->t_tableOid = tup->t_tableOid;
398
399 new_tuple->t_data->t_choice = tup->t_data->t_choice;
400 new_tuple->t_data->t_ctid = tup->t_data->t_ctid;
401 new_tuple->t_data->t_infomask &= ~HEAP_XACT_MASK;
402 new_tuple->t_data->t_infomask |=
403 tup->t_data->t_infomask & HEAP_XACT_MASK;
404 new_tuple->t_data->t_infomask2 &= ~HEAP2_XACT_MASK;
405 new_tuple->t_data->t_infomask2 |=
406 tup->t_data->t_infomask2 & HEAP2_XACT_MASK;
407
408 /*
409 * Free allocated temp values
410 */
411 for (i = 0; i < numAttrs; i++)
412 if (toast_free[i])
414
415 return new_tuple;
416}
#define HEAP2_XACT_MASK
#define HEAP_XACT_MASK

References Assert, attlen, DatumGetPointer(), detoast_external_attr(), fb(), HEAP2_XACT_MASK, heap_deform_tuple(), heap_form_tuple(), HEAP_XACT_MASK, i, MaxTupleAttributeNumber, pfree(), PointerGetDatum(), TupleDescCompactAttr(), and VARATT_IS_EXTERNAL().

Referenced by CatalogCacheCreateEntry(), expanded_record_set_tuple(), and ExtractReplicaIdentity().

◆ toast_flatten_tuple_to_datum()

Datum toast_flatten_tuple_to_datum ( HeapTupleHeader  tup,
uint32  tup_len,
TupleDesc  tupleDesc 
)

Definition at line 449 of file heaptoast.c.

452{
458 int numAttrs = tupleDesc->natts;
459 int i;
460 bool has_nulls = false;
464
465 /* Build a temporary HeapTuple control structure */
467 ItemPointerSetInvalid(&(tmptup.t_self));
468 tmptup.t_tableOid = InvalidOid;
469 tmptup.t_data = tup;
470
471 /*
472 * Break down the tuple into fields.
473 */
476
477 memset(toast_free, 0, numAttrs * sizeof(bool));
478
479 for (i = 0; i < numAttrs; i++)
480 {
481 /*
482 * Look at non-null varlena attributes
483 */
484 if (toast_isnull[i])
485 has_nulls = true;
486 else if (TupleDescCompactAttr(tupleDesc, i)->attlen == -1)
487 {
488 struct varlena *new_value;
489
493 {
496 toast_free[i] = true;
497 }
498 }
499 }
500
501 /*
502 * Calculate the new size of the tuple.
503 *
504 * This should match the reconstruction code in
505 * heap_toast_insert_or_update.
506 */
508 if (has_nulls)
514
516
517 /*
518 * Copy the existing tuple header, but adjust natts and t_hoff.
519 */
522 new_data->t_hoff = new_header_len;
523
524 /* Set the composite-Datum header fields correctly */
528
529 /* Copy over the data, and fill the null bitmap if needed */
533 (char *) new_data + new_header_len,
535 &(new_data->t_infomask),
536 has_nulls ? new_data->t_bits : NULL);
537
538 /*
539 * Free allocated temp values
540 */
541 for (i = 0; i < numAttrs; i++)
542 if (toast_free[i])
544
546}
struct varlena * detoast_attr(struct varlena *attr)
Definition detoast.c:116
static void HeapTupleHeaderSetTypMod(HeapTupleHeaderData *tup, int32 typmod)
static void HeapTupleHeaderSetTypeId(HeapTupleHeaderData *tup, Oid datum_typeid)
static void HeapTupleHeaderSetDatumLength(HeapTupleHeaderData *tup, uint32 len)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Definition itemptr.h:184
uint32 t_len
Definition htup.h:64
static bool VARATT_IS_COMPRESSED(const void *PTR)
Definition varatt.h:347

References Assert, attlen, BITMAPLEN(), DatumGetPointer(), detoast_attr(), fb(), heap_compute_data_size(), heap_deform_tuple(), heap_fill_tuple(), HeapTupleHeaderSetDatumLength(), HeapTupleHeaderSetNatts, HeapTupleHeaderSetTypeId(), HeapTupleHeaderSetTypMod(), i, InvalidOid, ItemPointerSetInvalid(), MAXALIGN, MaxTupleAttributeNumber, palloc0(), pfree(), PointerGetDatum(), SizeofHeapTupleHeader, HeapTupleData::t_len, TupleDescCompactAttr(), VARATT_IS_COMPRESSED(), and VARATT_IS_EXTERNAL().

Referenced by heap_copy_tuple_as_datum(), and HeapTupleHeaderGetDatum().