72 #define ATT_IS_PACKABLE(att) \
73 ((att)->attlen == -1 && (att)->attstorage != TYPSTORAGE_PLAIN)
75 #define VARLENA_ATT_IS_PACKABLE(att) \
76 ((att)->attstorage != TYPSTORAGE_PLAIN)
105 if (entry1->
len != entry2->
len)
106 return entry1->
len > entry2->
len ? 1 : -1;
144 Assert(attnum <= tupleDesc->natts);
149 if (att->atthasmissing)
176 Assert(att->attlen > 0 || att->attlen == -1);
178 key.len = att->attlen;
211 Size data_length = 0;
213 int numberOfAttributes = tupleDesc->
natts;
215 for (
i = 0;
i < numberOfAttributes;
i++)
235 else if (atti->attlen == -1 &&
307 data_length = att->attlen;
309 else if (att->attlen == -1)
335 memcpy(
data,
val, data_length);
342 memcpy(
data,
val, data_length);
358 memcpy(
data,
val, data_length);
361 else if (att->attlen == -2)
365 Assert(att->attalign == TYPALIGN_CHAR);
374 data_length = att->attlen;
400 int numberOfAttributes = tupleDesc->
natts;
402 #ifdef USE_ASSERT_CHECKING
420 for (
i = 0;
i < numberOfAttributes;
i++)
430 isnull ? isnull[
i] :
true);
453 Assert(!tupleDesc || attnum <= tupleDesc->natts);
540 int finalbit =
attnum & 0x07;
543 if ((~bp[
byte]) & ((1 << finalbit) - 1))
550 for (
i = 0;
i < byte;
i++)
561 tp = (
char *) td + td->
t_hoff;
572 if (att->attcacheoff >= 0)
573 return fetchatt(att, tp + att->attcacheoff);
597 int natts = tupleDesc->
natts;
618 for (;
j < natts;
j++)
622 if (att->attlen <= 0)
627 att->attcacheoff = off;
638 bool usecache =
true;
663 if (usecache && att->attcacheoff >= 0)
664 off = att->attcacheoff;
665 else if (att->attlen == -1)
675 att->attcacheoff = off;
689 att->attcacheoff = off;
697 if (usecache && att->attlen <= 0)
832 int natts = tupleDesc->
natts;
839 bits8 *nullBits = NULL;
844 Assert((targetHeapTuple && !targetMinimalTuple)
845 || (!targetHeapTuple && targetMinimalTuple));
847 Assert(sourceNatts < natts);
849 sourceNullLen = (hasNulls ?
BITMAPLEN(sourceNatts) : 0);
851 targetDataLen = sourceDataLen;
867 for (firstmissingnum = sourceNatts;
868 firstmissingnum < natts;
871 if (attrmiss[firstmissingnum].am_present)
881 for (
attnum = firstmissingnum;
885 if (attrmiss[
attnum].am_present)
919 len += targetNullLen;
932 len += targetDataLen;
935 (*targetHeapTuple)->t_data
938 (*targetHeapTuple)->t_len =
len;
939 (*targetHeapTuple)->t_tableOid = sourceTuple->
t_tableOid;
940 (*targetHeapTuple)->t_self = sourceTuple->
t_self;
943 targetTHeader->
t_hoff = hoff;
950 if (targetNullLen > 0)
951 nullBits = (
bits8 *) ((
char *) (*targetHeapTuple)->t_data
953 targetData = (
char *) (*targetHeapTuple)->t_data + hoff;
960 len += targetDataLen;
963 (*targetMinimalTuple)->t_len =
len;
965 (*targetMinimalTuple)->t_infomask = sourceTHeader->
t_infomask;
968 if (targetNullLen > 0)
969 nullBits = (
bits8 *) ((
char *) *targetMinimalTuple
971 targetData = (
char *) *targetMinimalTuple + hoff;
972 infoMask = &((*targetMinimalTuple)->t_infomask);
975 if (targetNullLen > 0)
977 if (sourceNullLen > 0)
981 ((
char *) sourceTHeader)
984 nullBits += sourceNullLen - 1;
990 memset(nullBits, 0xff, sourceNullLen);
992 nullBits += sourceNullLen - 1;
994 if (sourceNatts & 0x07)
997 bitMask = 0xff << (sourceNatts & 0x07);
999 *nullBits = ~bitMask;
1003 bitMask = (1 << ((sourceNatts - 1) & 0x07));
1007 ((
char *) sourceTuple->
t_data) + sourceTHeader->
t_hoff,
1010 targetData += sourceDataLen;
1018 if (attrmiss && attrmiss[
attnum].am_present)
1021 nullBits ? &nullBits : NULL,
1025 attrmiss[
attnum].am_value,
1049 expand_tuple(NULL, &minimalTuple, sourceTuple, tupleDesc);
1050 return minimalTuple;
1061 expand_tuple(&heapTuple, NULL, sourceTuple, tupleDesc);
1091 memcpy((
char *) td, (
char *) tuple->
t_data, tuple->
t_len);
1117 bool hasnull =
false;
1118 int numberOfAttributes = tupleDescriptor->
natts;
1123 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1124 errmsg(
"number of columns (%d) exceeds limit (%d)",
1130 for (
i = 0;
i < numberOfAttributes;
i++)
1184 (hasnull ? td->
t_bits : NULL));
1207 int numberOfAttributes = tupleDesc->
natts;
1225 isnull = (
bool *)
palloc(numberOfAttributes *
sizeof(
bool));
1229 for (attoff = 0; attoff < numberOfAttributes; attoff++)
1231 if (doReplace[attoff])
1233 values[attoff] = replValues[attoff];
1234 isnull[attoff] = replIsnull[attoff];
1276 int numberOfAttributes = tupleDesc->
natts;
1287 isnull = (
bool *)
palloc(numberOfAttributes *
sizeof(
bool));
1291 for (
i = 0;
i < nCols;
i++)
1295 if (attnum <= 0 || attnum > numberOfAttributes)
1298 isnull[
attnum - 1] = replIsnull[
i];
1342 int tdesc_natts = tupleDesc->
natts;
1357 natts =
Min(natts, tdesc_natts);
1359 tp = (
char *) tup + tup->
t_hoff;
1377 if (!slow && thisatt->attcacheoff >= 0)
1378 off = thisatt->attcacheoff;
1379 else if (thisatt->attlen == -1)
1389 thisatt->attcacheoff = off;
1403 thisatt->attcacheoff = off;
1410 if (thisatt->attlen <= 0)
1452 bool hasnull =
false;
1453 int numberOfAttributes = tupleDescriptor->
natts;
1458 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1459 errmsg(
"number of columns (%d) exceeds limit (%d)",
1465 for (
i = 0;
i < numberOfAttributes;
i++)
1503 (
char *) tuple + hoff,
1506 (hasnull ? tuple->
t_bits : NULL));
1532 memcpy(result, mtup, mtup->
t_len);
static Datum values[MAXATTR]
Datum datumCopy(Datum value, bool typByVal, int typLen)
elog(ERROR, "%s: %s", p2, msg)
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)
Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
static uint32 missing_hash(const void *key, Size keysize)
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 minimal_tuple_from_heap_tuple(HeapTuple htup)
Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
#define VARLENA_ATT_IS_PACKABLE(att)
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)
HeapTuple heap_expand_tuple(HeapTuple sourceTuple, TupleDesc tupleDesc)
#define ATT_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)
MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup)
Size heap_compute_data_size(TupleDesc tupleDesc, Datum *values, bool *isnull)
Datum heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc)
void heap_fill_tuple(TupleDesc tupleDesc, Datum *values, bool *isnull, char *data, Size data_size, uint16 *infomask, bits8 *bit)
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)
static void fill_val(Form_pg_attribute att, bits8 **bit, int *bitmask, char **dataP, uint16 *infomask, Datum datum, bool isnull)
HeapTuple heap_modify_tuple_by_cols(HeapTuple tuple, TupleDesc tupleDesc, int nCols, int *replCols, Datum *replValues, bool *replIsnull)
void heap_freetuple(HeapTuple htup)
HeapTupleData * HeapTuple
MinimalTupleData * MinimalTuple
HeapTupleHeaderData * HeapTupleHeader
#define HeapTupleIsValid(tuple)
#define MINIMAL_TUPLE_OFFSET
#define HeapTupleHeaderSetTypMod(tup, typmod)
#define HeapTupleHeaderGetNatts(tup)
#define SizeofMinimalTupleHeader
#define HeapTupleHasVarWidth(tuple)
#define HeapTupleHasExternal(tuple)
#define MaxTupleAttributeNumber
#define HeapTupleNoNulls(tuple)
#define HeapTupleHeaderGetRawXmin(tup)
#define HeapTupleHeaderSetNatts(tup, natts)
#define HeapTupleHeaderSetDatumLength(tup, len)
#define HeapTupleHeaderGetRawXmax(tup)
#define HeapTupleHeaderGetRawCommandId(tup)
#define HeapTupleHasNulls(tuple)
#define HeapTupleHeaderSetTypeId(tup, typeid)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Assert(fmt[strlen(fmt) - 1] !='\n')
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * palloc0(Size size)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
FormData_pg_attribute * Form_pg_attribute
static Datum PointerGetDatum(const void *X)
static char * DatumGetCString(Datum X)
static Datum TransactionIdGetDatum(TransactionId X)
static Datum CommandIdGetDatum(CommandId X)
static Datum ObjectIdGetDatum(Oid 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
#define TupleDescAttr(tupdesc, i)
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
#define att_align_nominal(cur_offset, attalign)
#define att_align_datum(cur_offset, attalign, attlen, attdatum)
static bool att_isnull(int ATT, const bits8 *BITS)
#define att_addlength_pointer(cur_offset, 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)