/* * Construct a leaf tuple containing the given heap TID and datum value */ SpGistLeafTuple spgFormLeafTuple(SpGistState *state, ItemPointer heapPtr, Datum datum, bool isnull) { SpGistLeafTuple tup; unsigned int size; /* compute space needed (note result is already maxaligned) */ size = SGLTHDRSZ; if (!isnull) size += SpGistGetTypeSize(&state->attType, datum); /* * Ensure that we can replace the tuple with a dead tuple later. This * test is unnecessary when !isnull, but let's be safe. */ if (size < SGDTSIZE) size = SGDTSIZE; /* OK, form the tuple */ tup = (SpGistLeafTuple) palloc0(size); tup->size = size; tup->nextOffset = InvalidOffsetNumber; tup->heapPtr = *heapPtr; if (!isnull) memcpyDatum(SGLTDATAPTR(tup), &state->attType, datum); return tup; }
SpGistLeafTuple spgFormLeafTuple(SpGistState *state, ItemPointer heapPtr, Datum datum) { SpGistLeafTuple tup; unsigned int size = SGLTHDRSZ + getTypeLength(&state->attType, datum); Assert(size < 0xffff); tup = palloc0(size); tup->heapPtr = *heapPtr; tup->nextOffset = InvalidOffsetNumber; tup->size = size; memcpyDatum(SGLTDATAPTR(tup), &state->attType, datum); return tup; }