29 #define TOAST_INDEX_HACK
76 unsigned short infomask = 0;
79 int numberOfAttributes = tupleDescriptor->
natts;
81 #ifdef TOAST_INDEX_HACK
88 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
89 errmsg(
"number of index columns (%d) exceeds limit (%d)",
92 #ifdef TOAST_INDEX_HACK
93 for (
i = 0;
i < numberOfAttributes;
i++)
98 untoasted_free[
i] =
false;
101 if (isnull[
i] || att->attlen != -1)
110 untoasted_values[
i] =
113 untoasted_free[
i] =
true;
122 (att->attstorage == TYPSTORAGE_EXTENDED ||
123 att->attstorage == TYPSTORAGE_MAIN))
128 att->attcompression);
133 if (untoasted_free[
i])
135 untoasted_values[
i] = cvalue;
136 untoasted_free[
i] =
true;
142 for (
i = 0;
i < numberOfAttributes;
i++)
155 #ifdef TOAST_INDEX_HACK
157 untoasted_values, isnull);
162 size = hoff + data_size;
180 #ifdef TOAST_INDEX_HACK
181 for (
i = 0;
i < numberOfAttributes;
i++)
183 if (untoasted_free[
i])
198 #ifdef TOAST_INDEX_HACK
208 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
209 errmsg(
"index row requires %zu bytes, maximum size is %zu",
280 int finalbit =
attnum & 0x07;
283 if ((~bp[
byte]) & ((1 << finalbit) - 1))
290 for (
i = 0;
i < byte;
i++)
302 tp = (
char *) tup + data_off;
313 if (att->attcacheoff >= 0)
314 return fetchatt(att, tp + att->attcacheoff);
338 int natts = tupleDesc->
natts;
359 for (;
j < natts;
j++)
363 if (att->attlen <= 0)
368 att->attcacheoff = off;
379 bool usecache =
true;
404 if (usecache && att->attcacheoff >= 0)
405 off = att->attcacheoff;
406 else if (att->attlen == -1)
416 att->attcacheoff = off;
430 att->attcacheoff = off;
438 if (usecache && att->attlen <= 0)
481 char *tp,
bits8 *bp,
int hasnulls)
483 int natts = tupleDescriptor->
natts;
505 if (!slow && thisatt->attcacheoff >= 0)
506 off = thisatt->attcacheoff;
507 else if (thisatt->attlen == -1)
517 thisatt->attcacheoff = off;
531 thisatt->attcacheoff = off;
538 if (thisatt->attlen <= 0)
584 Assert(leavenatts <= sourceDescriptor->natts);
587 if (leavenatts == sourceDescriptor->
natts)
593 truncdesc->
natts = leavenatts;
static Datum values[MAXATTR]
#define Assert(condition)
struct varlena * detoast_external_attr(struct varlena *attr)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define TOAST_INDEX_TARGET
Size heap_compute_data_size(TupleDesc tupleDesc, const Datum *values, const bool *isnull)
void heap_fill_tuple(TupleDesc tupleDesc, const Datum *values, const bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor, Datum *values, bool *isnull)
IndexTuple index_truncate_tuple(TupleDesc sourceDescriptor, IndexTuple source, int leavenatts)
IndexTuple CopyIndexTuple(IndexTuple source)
void index_deform_tuple_internal(TupleDesc tupleDescriptor, Datum *values, bool *isnull, char *tp, bits8 *bp, int hasnulls)
IndexTuple index_form_tuple_context(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull, MemoryContext context)
Datum nocache_index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc)
IndexTuple index_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
#define IndexTupleHasVarwidths(itup)
#define IndexTupleHasNulls(itup)
IndexTupleData * IndexTuple
#define IndexTupleSize(itup)
struct IndexTupleData IndexTupleData
static Size IndexInfoFindDataOffset(unsigned short t_info)
void pfree(void *pointer)
void * MemoryContextAllocZero(MemoryContext context, Size size)
MemoryContext CurrentMemoryContext
FormData_pg_attribute * Form_pg_attribute
static rewind_source * source
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
static pg_noinline void Size size
Datum toast_compress_datum(Datum value, char cmethod)
void TupleDescCopy(TupleDesc dst, TupleDesc src)
#define TupleDescSize(src)
#define TupleDescAttr(tupdesc, i)
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
#define att_align_nominal(cur_offset, attalign)
static bool att_isnull(int ATT, const bits8 *BITS)
#define att_addlength_pointer(cur_offset, attlen, attptr)
#define VARATT_IS_EXTENDED(PTR)
#define VARATT_IS_EXTERNAL(PTR)