68 #define ATT_IS_PACKABLE(att) \
69 ((att)->attlen == -1 && (att)->attstorage != TYPSTORAGE_PLAIN)
71 #define VARLENA_ATT_IS_PACKABLE(att) \
72 ((att)->attstorage != TYPSTORAGE_PLAIN)
89 Assert(attnum <= tupleDesc->natts);
94 if (att->atthasmissing)
123 Size data_length = 0;
125 int numberOfAttributes = tupleDesc->
natts;
127 for (
i = 0;
i < numberOfAttributes;
i++)
147 else if (atti->attlen == -1 &&
219 data_length = att->attlen;
221 else if (att->attlen == -1)
247 memcpy(
data,
val, data_length);
254 memcpy(
data,
val, data_length);
270 memcpy(
data,
val, data_length);
273 else if (att->attlen == -2)
277 Assert(att->attalign == TYPALIGN_CHAR);
286 data_length = att->attlen;
312 int numberOfAttributes = tupleDesc->
natts;
314 #ifdef USE_ASSERT_CHECKING
332 for (
i = 0;
i < numberOfAttributes;
i++)
342 isnull ? isnull[
i] :
true);
365 Assert(!tupleDesc || attnum <= tupleDesc->natts);
452 int finalbit =
attnum & 0x07;
455 if ((~bp[
byte]) & ((1 << finalbit) - 1))
462 for (
i = 0;
i < byte;
i++)
473 tp = (
char *) td + td->
t_hoff;
484 if (att->attcacheoff >= 0)
485 return fetchatt(att, tp + att->attcacheoff);
509 int natts = tupleDesc->
natts;
530 for (;
j < natts;
j++)
534 if (att->attlen <= 0)
539 att->attcacheoff = off;
550 bool usecache =
true;
575 if (usecache && att->attcacheoff >= 0)
576 off = att->attcacheoff;
577 else if (att->attlen == -1)
587 att->attcacheoff = off;
601 att->attcacheoff = off;
609 if (usecache && att->attlen <= 0)
744 int natts = tupleDesc->
natts;
751 bits8 *nullBits = NULL;
756 Assert((targetHeapTuple && !targetMinimalTuple)
757 || (!targetHeapTuple && targetMinimalTuple));
759 Assert(sourceNatts < natts);
761 sourceNullLen = (hasNulls ?
BITMAPLEN(sourceNatts) : 0);
763 targetDataLen = sourceDataLen;
779 for (firstmissingnum = sourceNatts;
780 firstmissingnum < natts;
783 if (attrmiss[firstmissingnum].am_present)
793 for (
attnum = firstmissingnum;
797 if (attrmiss[
attnum].am_present)
831 len += targetNullLen;
844 len += targetDataLen;
847 (*targetHeapTuple)->t_data
850 (*targetHeapTuple)->t_len =
len;
851 (*targetHeapTuple)->t_tableOid = sourceTuple->
t_tableOid;
852 (*targetHeapTuple)->t_self = sourceTuple->
t_self;
855 targetTHeader->
t_hoff = hoff;
862 if (targetNullLen > 0)
863 nullBits = (
bits8 *) ((
char *) (*targetHeapTuple)->t_data
865 targetData = (
char *) (*targetHeapTuple)->t_data + hoff;
872 len += targetDataLen;
875 (*targetMinimalTuple)->t_len =
len;
877 (*targetMinimalTuple)->t_infomask = sourceTHeader->
t_infomask;
880 if (targetNullLen > 0)
881 nullBits = (
bits8 *) ((
char *) *targetMinimalTuple
883 targetData = (
char *) *targetMinimalTuple + hoff;
884 infoMask = &((*targetMinimalTuple)->t_infomask);
887 if (targetNullLen > 0)
889 if (sourceNullLen > 0)
893 ((
char *) sourceTHeader)
896 nullBits += sourceNullLen - 1;
902 memset(nullBits, 0xff, sourceNullLen);
904 nullBits += sourceNullLen - 1;
906 if (sourceNatts & 0x07)
909 bitMask = 0xff << (sourceNatts & 0x07);
911 *nullBits = ~bitMask;
915 bitMask = (1 << ((sourceNatts - 1) & 0x07));
922 targetData += sourceDataLen;
930 if (attrmiss && attrmiss[
attnum].am_present)
933 nullBits ? &nullBits : NULL,
937 attrmiss[
attnum].am_value,
961 expand_tuple(NULL, &minimalTuple, sourceTuple, tupleDesc);
1003 memcpy((
char *) td, (
char *) tuple->
t_data, tuple->
t_len);
1029 bool hasnull =
false;
1030 int numberOfAttributes = tupleDescriptor->
natts;
1035 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1036 errmsg(
"number of columns (%d) exceeds limit (%d)",
1042 for (
i = 0;
i < numberOfAttributes;
i++)
1096 (hasnull ? td->
t_bits : NULL));
1119 int numberOfAttributes = tupleDesc->
natts;
1137 isnull = (
bool *)
palloc(numberOfAttributes *
sizeof(
bool));
1141 for (attoff = 0; attoff < numberOfAttributes; attoff++)
1143 if (doReplace[attoff])
1145 values[attoff] = replValues[attoff];
1146 isnull[attoff] = replIsnull[attoff];
1188 int numberOfAttributes = tupleDesc->
natts;
1199 isnull = (
bool *)
palloc(numberOfAttributes *
sizeof(
bool));
1203 for (
i = 0;
i < nCols;
i++)
1207 if (attnum <= 0 || attnum > numberOfAttributes)
1210 isnull[
attnum - 1] = replIsnull[
i];
1254 int tdesc_natts = tupleDesc->
natts;
1269 natts =
Min(natts, tdesc_natts);
1271 tp = (
char *) tup + tup->
t_hoff;
1289 if (!slow && thisatt->attcacheoff >= 0)
1290 off = thisatt->attcacheoff;
1291 else if (thisatt->attlen == -1)
1301 thisatt->attcacheoff = off;
1315 thisatt->attcacheoff = off;
1322 if (thisatt->attlen <= 0)
1364 bool hasnull =
false;
1365 int numberOfAttributes = tupleDescriptor->
natts;
1370 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1371 errmsg(
"number of columns (%d) exceeds limit (%d)",
1377 for (
i = 0;
i < numberOfAttributes;
i++)
1415 (
char *) tuple + hoff,
1418 (hasnull ? tuple->
t_bits : NULL));
1444 memcpy(result, mtup, mtup->
t_len);
static Datum values[MAXATTR]
elog(ERROR, "%s: %s", p2, msg)
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)
Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup, uint32 tup_len, TupleDesc tupleDesc)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
void heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
HeapTuple heap_copytuple(HeapTuple tuple)
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)
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 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)
void * palloc0(Size size)
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)