80#define ATT_IS_PACKABLE(att) \
81 ((att)->attlen == -1 && (att)->attstorage != TYPSTORAGE_PLAIN)
83#define VARLENA_ATT_IS_PACKABLE(att) \
84 ((att)->attstorage != TYPSTORAGE_PLAIN)
87#define COMPACT_ATTR_IS_PACKABLE(att) \
88 ((att)->attlen == -1 && (att)->attispackable)
117 if (entry1->
len != entry2->
len)
118 return entry1->
len > entry2->
len ? 1 : -1;
156 Assert(attnum <= tupleDesc->natts);
223 Size data_length = 0;
225 int numberOfAttributes = tupleDesc->
natts;
227 for (
i = 0;
i < numberOfAttributes;
i++)
247 else if (atti->
attlen == -1 &&
319 data_length = att->
attlen;
321 else if (att->
attlen == -1)
346 memcpy(
data,
val, data_length);
353 memcpy(
data,
val, data_length);
367 memcpy(
data,
val, data_length);
370 else if (att->
attlen == -2)
383 data_length = att->
attlen;
409 int numberOfAttributes = tupleDesc->
natts;
411#ifdef USE_ASSERT_CHECKING
429 for (
i = 0;
i < numberOfAttributes;
i++)
439 isnull ? isnull[
i] :
true);
462 Assert(!tupleDesc || attnum <= tupleDesc->natts);
550 int finalbit =
attnum & 0x07;
553 if ((~bp[
byte]) & ((1 << finalbit) - 1))
560 for (
i = 0;
i < byte;
i++)
571 tp = (
char *) td + td->
t_hoff;
607 int natts = tupleDesc->
natts;
628 for (;
j < natts;
j++)
648 bool usecache =
true;
675 else if (att->
attlen == -1)
707 if (usecache && att->
attlen <= 0)
842 int natts = tupleDesc->
natts;
849 bits8 *nullBits = NULL;
854 Assert((targetHeapTuple && !targetMinimalTuple)
855 || (!targetHeapTuple && targetMinimalTuple));
857 Assert(sourceNatts < natts);
859 sourceNullLen = (hasNulls ?
BITMAPLEN(sourceNatts) : 0);
861 targetDataLen = sourceDataLen;
877 for (firstmissingnum = sourceNatts;
878 firstmissingnum < natts;
881 if (attrmiss[firstmissingnum].am_present)
891 for (
attnum = firstmissingnum;
895 if (attrmiss[
attnum].am_present)
929 len += targetNullLen;
942 len += targetDataLen;
945 (*targetHeapTuple)->t_data
948 (*targetHeapTuple)->t_len =
len;
949 (*targetHeapTuple)->t_tableOid = sourceTuple->
t_tableOid;
950 (*targetHeapTuple)->t_self = sourceTuple->
t_self;
953 targetTHeader->
t_hoff = hoff;
960 if (targetNullLen > 0)
961 nullBits = (
bits8 *) ((
char *) (*targetHeapTuple)->t_data
963 targetData = (
char *) (*targetHeapTuple)->t_data + hoff;
970 len += targetDataLen;
973 (*targetMinimalTuple)->t_len =
len;
975 (*targetMinimalTuple)->t_infomask = sourceTHeader->
t_infomask;
978 if (targetNullLen > 0)
979 nullBits = (
bits8 *) ((
char *) *targetMinimalTuple
981 targetData = (
char *) *targetMinimalTuple + hoff;
982 infoMask = &((*targetMinimalTuple)->t_infomask);
985 if (targetNullLen > 0)
987 if (sourceNullLen > 0)
991 ((
char *) sourceTHeader)
994 nullBits += sourceNullLen - 1;
1000 memset(nullBits, 0xff, sourceNullLen);
1002 nullBits += sourceNullLen - 1;
1004 if (sourceNatts & 0x07)
1007 bitMask = 0xff << (sourceNatts & 0x07);
1009 *nullBits = ~bitMask;
1013 bitMask = (1 << ((sourceNatts - 1) & 0x07));
1017 ((
char *) sourceTuple->
t_data) + sourceTHeader->
t_hoff,
1020 targetData += sourceDataLen;
1027 if (attrmiss && attrmiss[
attnum].am_present)
1030 nullBits ? &nullBits : NULL,
1034 attrmiss[
attnum].am_value,
1058 expand_tuple(NULL, &minimalTuple, sourceTuple, tupleDesc);
1059 return minimalTuple;
1070 expand_tuple(&heapTuple, NULL, sourceTuple, tupleDesc);
1126 bool hasnull =
false;
1127 int numberOfAttributes = tupleDescriptor->
natts;
1132 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1133 errmsg(
"number of columns (%d) exceeds limit (%d)",
1139 for (
i = 0;
i < numberOfAttributes;
i++)
1193 (hasnull ? td->
t_bits : NULL));
1212 const Datum *replValues,
1213 const bool *replIsnull,
1214 const bool *doReplace)
1216 int numberOfAttributes = tupleDesc->
natts;
1234 isnull = (
bool *)
palloc(numberOfAttributes *
sizeof(
bool));
1238 for (attoff = 0; attoff < numberOfAttributes; attoff++)
1240 if (doReplace[attoff])
1242 values[attoff] = replValues[attoff];
1243 isnull[attoff] = replIsnull[attoff];
1281 const int *replCols,
1282 const Datum *replValues,
1283 const bool *replIsnull)
1285 int numberOfAttributes = tupleDesc->
natts;
1296 isnull = (
bool *)
palloc(numberOfAttributes *
sizeof(
bool));
1300 for (
i = 0;
i < nCols;
i++)
1304 if (attnum <= 0 || attnum > numberOfAttributes)
1307 isnull[
attnum - 1] = replIsnull[
i];
1351 int tdesc_natts = tupleDesc->
natts;
1366 natts =
Min(natts, tdesc_natts);
1368 tp = (
char *) tup + tup->
t_hoff;
1388 else if (thisatt->
attlen == -1)
1412 thisatt->attcacheoff = off;
1419 if (thisatt->attlen <= 0)
1463 bool hasnull =
false;
1464 int numberOfAttributes = tupleDescriptor->
natts;
1471 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1472 errmsg(
"number of columns (%d) exceeds limit (%d)",
1478 for (
i = 0;
i < numberOfAttributes;
i++)
1505 memset(mem, 0, extra);
1518 (
char *) tuple + hoff,
1521 (hasnull ? tuple->
t_bits : NULL));
1549 memset(mem, 0, extra);
1551 memcpy(result, mtup, mtup->
t_len);
1597 memset(mem, 0, extra);
static Datum values[MAXATTR]
Datum datumCopy(Datum value, bool typByVal, int typLen)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
ExpandedObjectHeader * DatumGetEOHP(Datum d)
void EOH_flatten_into(ExpandedObjectHeader *eohptr, void *result, Size allocated_size)
Size EOH_get_flat_size(ExpandedObjectHeader *eohptr)
uint32 hash_bytes(const unsigned char *k, int keylen)
Assert(PointerIsAligned(start, uint64))
Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
Size heap_compute_data_size(TupleDesc tupleDesc, const Datum *values, const bool *isnull)
static uint32 missing_hash(const void *key, Size keysize)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
void heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
HeapTuple heap_copytuple(HeapTuple tuple)
static void init_missing_cache()
size_t varsize_any(void *p)
MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup, Size extra)
Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull, Size extra)
HeapTuple heap_modify_tuple_by_cols(HeapTuple tuple, TupleDesc tupleDesc, int nCols, const int *replCols, const Datum *replValues, const bool *replIsnull)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_free_minimal_tuple(MinimalTuple mtup)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
Datum nocachegetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc)
Datum getmissingattr(TupleDesc tupleDesc, int attnum, bool *isnull)
MinimalTuple minimal_tuple_from_heap_tuple(HeapTuple htup, Size extra)
HeapTuple heap_expand_tuple(HeapTuple sourceTuple, TupleDesc tupleDesc)
static void fill_val(CompactAttribute *att, bits8 **bit, int *bitmask, char **dataP, uint16 *infomask, Datum datum, bool isnull)
void heap_fill_tuple(TupleDesc tupleDesc, const Datum *values, const bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
#define COMPACT_ATTR_IS_PACKABLE(att)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
static int missing_match(const void *key1, const void *key2, Size keysize)
Datum heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc)
static HTAB * missing_cache
static void expand_tuple(HeapTuple *targetHeapTuple, MinimalTuple *targetMinimalTuple, HeapTuple sourceTuple, TupleDesc tupleDesc)
HeapTuple heap_tuple_from_minimal_tuple(MinimalTuple mtup)
MinimalTuple minimal_expand_tuple(HeapTuple sourceTuple, TupleDesc tupleDesc)
void heap_freetuple(HeapTuple htup)
HeapTupleData * HeapTuple
MinimalTupleData * MinimalTuple
HeapTupleHeaderData * HeapTupleHeader
#define HeapTupleIsValid(tuple)
#define MINIMAL_TUPLE_OFFSET
#define HeapTupleHeaderGetNatts(tup)
static void HeapTupleHeaderSetTypMod(HeapTupleHeaderData *tup, int32 typmod)
static bool HeapTupleHasNulls(const HeapTupleData *tuple)
static int BITMAPLEN(int NATTS)
static bool HeapTupleHasExternal(const HeapTupleData *tuple)
#define SizeofMinimalTupleHeader
static void HeapTupleHeaderSetTypeId(HeapTupleHeaderData *tup, Oid datum_typeid)
static CommandId HeapTupleHeaderGetRawCommandId(const HeapTupleHeaderData *tup)
static TransactionId HeapTupleHeaderGetRawXmax(const HeapTupleHeaderData *tup)
#define MaxTupleAttributeNumber
static bool HeapTupleNoNulls(const HeapTupleData *tuple)
static void HeapTupleHeaderSetDatumLength(HeapTupleHeaderData *tup, uint32 len)
static TransactionId HeapTupleHeaderGetRawXmin(const HeapTupleHeaderData *tup)
#define HeapTupleHeaderSetNatts(tup, natts)
static bool HeapTupleHasVarWidth(const HeapTupleData *tuple)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext TopMemoryContext
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static Datum PointerGetDatum(const void *X)
static Datum TransactionIdGetDatum(TransactionId X)
static Datum CommandIdGetDatum(CommandId X)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum X)
static Pointer DatumGetPointer(Datum X)
bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]
struct AttrMissing * missing
#define MinTransactionIdAttributeNumber
#define MaxCommandIdAttributeNumber
#define MaxTransactionIdAttributeNumber
#define TableOidAttributeNumber
#define SelfItemPointerAttributeNumber
#define MinCommandIdAttributeNumber
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
#define att_nominal_alignby(cur_offset, attalignby)
#define att_datum_alignby(cur_offset, attalignby, attlen, attdatum)
static bool att_isnull(int ATT, const bits8 *BITS)
#define att_addlength_pointer(cur_offset, attlen, attptr)
#define att_pointer_alignby(cur_offset, attalignby, attlen, attptr)
#define att_addlength_datum(cur_offset, attlen, attdatum)
static void store_att_byval(void *T, Datum newdatum, int attlen)
#define VARSIZE_SHORT(PTR)
#define SET_VARSIZE_SHORT(PTR, len)
#define VARATT_CAN_MAKE_SHORT(PTR)
#define VARATT_IS_EXTERNAL_EXPANDED(PTR)
#define VARATT_IS_SHORT(PTR)
#define VARSIZE_EXTERNAL(PTR)
#define VARATT_CONVERTED_SHORT_SIZE(PTR)
#define VARATT_IS_EXTERNAL(PTR)
Datum bit(PG_FUNCTION_ARGS)