mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
Revert "Introduce CompactAttribute array in TupleDesc"
This reverts commit d28dff3f6c.
Quite a large number of buildfarm members didn't like this commit and
it's not yet clear why. Reverting this before too many animals turn
red.
Discussion: https://postgr.es/m/CAApHDvr9i6T5=iAwQCxFDgMsthr_obVxgwBaEJkC8KUH6yM3Hw@mail.gmail.com
This commit is contained in:
@@ -83,10 +83,6 @@
|
||||
#define VARLENA_ATT_IS_PACKABLE(att) \
|
||||
((att)->attstorage != TYPSTORAGE_PLAIN)
|
||||
|
||||
/* FormData_pg_attribute.attstorage != TYPSTORAGE_PLAIN and an attlen of -1 */
|
||||
#define COMPACT_ATTR_IS_PACKABLE(att) \
|
||||
((att)->attlen == -1 && (att)->attispackable)
|
||||
|
||||
/*
|
||||
* Setup for caching pass-by-ref missing attributes in a way that survives
|
||||
* tupleDesc destruction.
|
||||
@@ -151,12 +147,12 @@ Datum
|
||||
getmissingattr(TupleDesc tupleDesc,
|
||||
int attnum, bool *isnull)
|
||||
{
|
||||
CompactAttribute *att;
|
||||
Form_pg_attribute att;
|
||||
|
||||
Assert(attnum <= tupleDesc->natts);
|
||||
Assert(attnum > 0);
|
||||
|
||||
att = TupleDescCompactAttr(tupleDesc, attnum - 1);
|
||||
att = TupleDescAttr(tupleDesc, attnum - 1);
|
||||
|
||||
if (att->atthasmissing)
|
||||
{
|
||||
@@ -227,15 +223,15 @@ heap_compute_data_size(TupleDesc tupleDesc,
|
||||
for (i = 0; i < numberOfAttributes; i++)
|
||||
{
|
||||
Datum val;
|
||||
CompactAttribute *atti;
|
||||
Form_pg_attribute atti;
|
||||
|
||||
if (isnull[i])
|
||||
continue;
|
||||
|
||||
val = values[i];
|
||||
atti = TupleDescCompactAttr(tupleDesc, i);
|
||||
atti = TupleDescAttr(tupleDesc, i);
|
||||
|
||||
if (COMPACT_ATTR_IS_PACKABLE(atti) &&
|
||||
if (ATT_IS_PACKABLE(atti) &&
|
||||
VARATT_CAN_MAKE_SHORT(DatumGetPointer(val)))
|
||||
{
|
||||
/*
|
||||
@@ -272,7 +268,7 @@ heap_compute_data_size(TupleDesc tupleDesc,
|
||||
* Fill in either a data value or a bit in the null bitmask
|
||||
*/
|
||||
static inline void
|
||||
fill_val(CompactAttribute *att,
|
||||
fill_val(Form_pg_attribute att,
|
||||
bits8 **bit,
|
||||
int *bitmask,
|
||||
char **dataP,
|
||||
@@ -353,7 +349,8 @@ fill_val(CompactAttribute *att,
|
||||
data_length = VARSIZE_SHORT(val);
|
||||
memcpy(data, val, data_length);
|
||||
}
|
||||
else if (att->attispackable && VARATT_CAN_MAKE_SHORT(val))
|
||||
else if (VARLENA_ATT_IS_PACKABLE(att) &&
|
||||
VARATT_CAN_MAKE_SHORT(val))
|
||||
{
|
||||
/* convert to short varlena -- no alignment */
|
||||
data_length = VARATT_CONVERTED_SHORT_SIZE(val);
|
||||
@@ -430,7 +427,7 @@ heap_fill_tuple(TupleDesc tupleDesc,
|
||||
|
||||
for (i = 0; i < numberOfAttributes; i++)
|
||||
{
|
||||
CompactAttribute *attr = TupleDescCompactAttr(tupleDesc, i);
|
||||
Form_pg_attribute attr = TupleDescAttr(tupleDesc, i);
|
||||
|
||||
fill_val(attr,
|
||||
bitP ? &bitP : NULL,
|
||||
@@ -464,8 +461,7 @@ heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
|
||||
Assert(!tupleDesc || attnum <= tupleDesc->natts);
|
||||
if (attnum > (int) HeapTupleHeaderGetNatts(tup->t_data))
|
||||
{
|
||||
if (tupleDesc &&
|
||||
TupleDescCompactAttr(tupleDesc, attnum - 1)->atthasmissing)
|
||||
if (tupleDesc && TupleDescAttr(tupleDesc, attnum - 1)->atthasmissing)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@@ -574,13 +570,13 @@ nocachegetattr(HeapTuple tup,
|
||||
|
||||
if (!slow)
|
||||
{
|
||||
CompactAttribute *att;
|
||||
Form_pg_attribute att;
|
||||
|
||||
/*
|
||||
* If we get here, there are no nulls up to and including the target
|
||||
* attribute. If we have a cached offset, we can use it.
|
||||
*/
|
||||
att = TupleDescCompactAttr(tupleDesc, attnum);
|
||||
att = TupleDescAttr(tupleDesc, attnum);
|
||||
if (att->attcacheoff >= 0)
|
||||
return fetchatt(att, tp + att->attcacheoff);
|
||||
|
||||
@@ -595,7 +591,7 @@ nocachegetattr(HeapTuple tup,
|
||||
|
||||
for (j = 0; j <= attnum; j++)
|
||||
{
|
||||
if (TupleDescCompactAttr(tupleDesc, j)->attlen <= 0)
|
||||
if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
|
||||
{
|
||||
slow = true;
|
||||
break;
|
||||
@@ -618,18 +614,18 @@ nocachegetattr(HeapTuple tup,
|
||||
* fixed-width columns, in hope of avoiding future visits to this
|
||||
* routine.
|
||||
*/
|
||||
TupleDescCompactAttr(tupleDesc, 0)->attcacheoff = 0;
|
||||
TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
|
||||
|
||||
/* we might have set some offsets in the slow path previously */
|
||||
while (j < natts && TupleDescCompactAttr(tupleDesc, j)->attcacheoff > 0)
|
||||
while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
|
||||
j++;
|
||||
|
||||
off = TupleDescCompactAttr(tupleDesc, j - 1)->attcacheoff +
|
||||
TupleDescCompactAttr(tupleDesc, j - 1)->attlen;
|
||||
off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
|
||||
TupleDescAttr(tupleDesc, j - 1)->attlen;
|
||||
|
||||
for (; j < natts; j++)
|
||||
{
|
||||
CompactAttribute *att = TupleDescCompactAttr(tupleDesc, j);
|
||||
Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
|
||||
|
||||
if (att->attlen <= 0)
|
||||
break;
|
||||
@@ -643,7 +639,7 @@ nocachegetattr(HeapTuple tup,
|
||||
|
||||
Assert(j > attnum);
|
||||
|
||||
off = TupleDescCompactAttr(tupleDesc, attnum)->attcacheoff;
|
||||
off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -663,7 +659,7 @@ nocachegetattr(HeapTuple tup,
|
||||
off = 0;
|
||||
for (i = 0;; i++) /* loop exit is at "break" */
|
||||
{
|
||||
CompactAttribute *att = TupleDescCompactAttr(tupleDesc, i);
|
||||
Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
|
||||
|
||||
if (HeapTupleHasNulls(tup) && att_isnull(i, bp))
|
||||
{
|
||||
@@ -711,7 +707,7 @@ nocachegetattr(HeapTuple tup,
|
||||
}
|
||||
}
|
||||
|
||||
return fetchatt(TupleDescCompactAttr(tupleDesc, attnum), tp + off);
|
||||
return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@@ -896,7 +892,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
|
||||
{
|
||||
if (attrmiss[attnum].am_present)
|
||||
{
|
||||
CompactAttribute *att = TupleDescCompactAttr(tupleDesc, attnum);
|
||||
Form_pg_attribute att = TupleDescAttr(tupleDesc, attnum);
|
||||
|
||||
targetDataLen = att_align_datum(targetDataLen,
|
||||
att->attalign,
|
||||
@@ -1024,7 +1020,8 @@ expand_tuple(HeapTuple *targetHeapTuple,
|
||||
/* Now fill in the missing values */
|
||||
for (attnum = sourceNatts; attnum < natts; attnum++)
|
||||
{
|
||||
CompactAttribute *attr = TupleDescCompactAttr(tupleDesc, attnum);
|
||||
|
||||
Form_pg_attribute attr = TupleDescAttr(tupleDesc, attnum);
|
||||
|
||||
if (attrmiss && attrmiss[attnum].am_present)
|
||||
{
|
||||
@@ -1373,7 +1370,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
|
||||
|
||||
for (attnum = 0; attnum < natts; attnum++)
|
||||
{
|
||||
CompactAttribute *thisatt = TupleDescCompactAttr(tupleDesc, attnum);
|
||||
Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
|
||||
|
||||
if (hasnulls && att_isnull(attnum, bp))
|
||||
{
|
||||
|
||||
@@ -303,13 +303,13 @@ nocache_index_getattr(IndexTuple tup,
|
||||
|
||||
if (!slow)
|
||||
{
|
||||
CompactAttribute *att;
|
||||
Form_pg_attribute att;
|
||||
|
||||
/*
|
||||
* If we get here, there are no nulls up to and including the target
|
||||
* attribute. If we have a cached offset, we can use it.
|
||||
*/
|
||||
att = TupleDescCompactAttr(tupleDesc, attnum);
|
||||
att = TupleDescAttr(tupleDesc, attnum);
|
||||
if (att->attcacheoff >= 0)
|
||||
return fetchatt(att, tp + att->attcacheoff);
|
||||
|
||||
@@ -324,7 +324,7 @@ nocache_index_getattr(IndexTuple tup,
|
||||
|
||||
for (j = 0; j <= attnum; j++)
|
||||
{
|
||||
if (TupleDescCompactAttr(tupleDesc, j)->attlen <= 0)
|
||||
if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
|
||||
{
|
||||
slow = true;
|
||||
break;
|
||||
@@ -347,18 +347,18 @@ nocache_index_getattr(IndexTuple tup,
|
||||
* fixed-width columns, in hope of avoiding future visits to this
|
||||
* routine.
|
||||
*/
|
||||
TupleDescCompactAttr(tupleDesc, 0)->attcacheoff = 0;
|
||||
TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
|
||||
|
||||
/* we might have set some offsets in the slow path previously */
|
||||
while (j < natts && TupleDescCompactAttr(tupleDesc, j)->attcacheoff > 0)
|
||||
while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
|
||||
j++;
|
||||
|
||||
off = TupleDescCompactAttr(tupleDesc, j - 1)->attcacheoff +
|
||||
TupleDescCompactAttr(tupleDesc, j - 1)->attlen;
|
||||
off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
|
||||
TupleDescAttr(tupleDesc, j - 1)->attlen;
|
||||
|
||||
for (; j < natts; j++)
|
||||
{
|
||||
CompactAttribute *att = TupleDescCompactAttr(tupleDesc, j);
|
||||
Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
|
||||
|
||||
if (att->attlen <= 0)
|
||||
break;
|
||||
@@ -372,7 +372,7 @@ nocache_index_getattr(IndexTuple tup,
|
||||
|
||||
Assert(j > attnum);
|
||||
|
||||
off = TupleDescCompactAttr(tupleDesc, attnum)->attcacheoff;
|
||||
off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -392,7 +392,7 @@ nocache_index_getattr(IndexTuple tup,
|
||||
off = 0;
|
||||
for (i = 0;; i++) /* loop exit is at "break" */
|
||||
{
|
||||
CompactAttribute *att = TupleDescCompactAttr(tupleDesc, i);
|
||||
Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
|
||||
|
||||
if (IndexTupleHasNulls(tup) && att_isnull(i, bp))
|
||||
{
|
||||
@@ -440,7 +440,7 @@ nocache_index_getattr(IndexTuple tup,
|
||||
}
|
||||
}
|
||||
|
||||
return fetchatt(TupleDescCompactAttr(tupleDesc, attnum), tp + off);
|
||||
return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -490,7 +490,7 @@ index_deform_tuple_internal(TupleDesc tupleDescriptor,
|
||||
|
||||
for (attnum = 0; attnum < natts; attnum++)
|
||||
{
|
||||
CompactAttribute *thisatt = TupleDescCompactAttr(tupleDescriptor, attnum);
|
||||
Form_pg_attribute thisatt = TupleDescAttr(tupleDescriptor, attnum);
|
||||
|
||||
if (hasnulls && att_isnull(attnum, bp))
|
||||
{
|
||||
@@ -588,7 +588,7 @@ index_truncate_tuple(TupleDesc sourceDescriptor, IndexTuple source,
|
||||
return CopyIndexTuple(source);
|
||||
|
||||
/* Create temporary descriptor to scribble on */
|
||||
truncdesc = CreateTemplateTupleDesc(sourceDescriptor->natts);
|
||||
truncdesc = palloc(TupleDescSize(sourceDescriptor));
|
||||
TupleDescCopy(truncdesc, sourceDescriptor);
|
||||
truncdesc->natts = leavenatts;
|
||||
|
||||
|
||||
@@ -56,33 +56,6 @@ ResourceOwnerForgetTupleDesc(ResourceOwner owner, TupleDesc tupdesc)
|
||||
ResourceOwnerForget(owner, PointerGetDatum(tupdesc), &tupdesc_resowner_desc);
|
||||
}
|
||||
|
||||
/*
|
||||
* populate_compact_attribute
|
||||
* Fills in the corresponding CompactAttribute element from the
|
||||
* Form_pg_attribute for the given attribute number. This must be called
|
||||
* whenever a change is made to a Form_pg_attribute in the TupleDesc.
|
||||
*/
|
||||
void
|
||||
populate_compact_attribute(TupleDesc tupdesc, int attnum)
|
||||
{
|
||||
Form_pg_attribute src = TupleDescAttr(tupdesc, attnum);
|
||||
CompactAttribute *dst = &tupdesc->compact_attrs[attnum];
|
||||
|
||||
memset(dst, 0, sizeof(CompactAttribute));
|
||||
|
||||
dst->attcacheoff = -1;
|
||||
dst->attlen = src->attlen;
|
||||
|
||||
dst->attbyval = src->attbyval;
|
||||
dst->attispackable = (src->attstorage != TYPSTORAGE_PLAIN);
|
||||
dst->atthasmissing = src->atthasmissing;
|
||||
dst->attisdropped = src->attisdropped;
|
||||
dst->attgenerated = (src->attgenerated != '\0');
|
||||
dst->attnotnull = src->attnotnull;
|
||||
|
||||
dst->attalign = src->attalign;
|
||||
}
|
||||
|
||||
/*
|
||||
* CreateTemplateTupleDesc
|
||||
* This function allocates an empty tuple descriptor structure.
|
||||
@@ -101,19 +74,18 @@ CreateTemplateTupleDesc(int natts)
|
||||
Assert(natts >= 0);
|
||||
|
||||
/*
|
||||
* Allocate enough memory for the tuple descriptor, the CompactAttribute
|
||||
* array and also an array of the full FormData_pg_attribute data.
|
||||
* Allocate enough memory for the tuple descriptor, including the
|
||||
* attribute rows.
|
||||
*
|
||||
* Note: the 'attrs' array stride is sizeof(FormData_pg_attribute), since
|
||||
* we declare the array elements as FormData_pg_attribute for notational
|
||||
* convenience. However, we only guarantee that the first
|
||||
* Note: the attribute array stride is sizeof(FormData_pg_attribute),
|
||||
* since we declare the array elements as FormData_pg_attribute for
|
||||
* notational convenience. However, we only guarantee that the first
|
||||
* ATTRIBUTE_FIXED_PART_SIZE bytes of each entry are valid; most code that
|
||||
* copies tupdesc entries around copies just that much. In principle that
|
||||
* could be less due to trailing padding, although with the current
|
||||
* definition of pg_attribute there probably isn't any padding.
|
||||
*/
|
||||
desc = (TupleDesc) palloc(offsetof(struct TupleDescData, compact_attrs) +
|
||||
natts * sizeof(CompactAttribute) +
|
||||
desc = (TupleDesc) palloc(offsetof(struct TupleDescData, attrs) +
|
||||
natts * sizeof(FormData_pg_attribute));
|
||||
|
||||
/*
|
||||
@@ -124,7 +96,6 @@ CreateTemplateTupleDesc(int natts)
|
||||
desc->tdtypeid = RECORDOID;
|
||||
desc->tdtypmod = -1;
|
||||
desc->tdrefcount = -1; /* assume not reference-counted */
|
||||
desc->attrs = TupleDescAttrAddress(desc);
|
||||
|
||||
return desc;
|
||||
}
|
||||
@@ -146,10 +117,8 @@ CreateTupleDesc(int natts, Form_pg_attribute *attrs)
|
||||
desc = CreateTemplateTupleDesc(natts);
|
||||
|
||||
for (i = 0; i < natts; ++i)
|
||||
{
|
||||
memcpy(TupleDescAttr(desc, i), attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
|
||||
populate_compact_attribute(desc, i);
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
@@ -186,8 +155,6 @@ CreateTupleDescCopy(TupleDesc tupdesc)
|
||||
att->atthasmissing = false;
|
||||
att->attidentity = '\0';
|
||||
att->attgenerated = '\0';
|
||||
|
||||
populate_compact_attribute(desc, i);
|
||||
}
|
||||
|
||||
/* We can copy the tuple type identification, too */
|
||||
@@ -216,9 +183,6 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
|
||||
TupleDescAttr(tupdesc, 0),
|
||||
desc->natts * sizeof(FormData_pg_attribute));
|
||||
|
||||
for (i = 0; i < desc->natts; i++)
|
||||
populate_compact_attribute(desc, i);
|
||||
|
||||
/* Copy the TupleConstr data structure, if any */
|
||||
if (constr)
|
||||
{
|
||||
@@ -243,7 +207,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
|
||||
{
|
||||
if (constr->missing[i].am_present)
|
||||
{
|
||||
CompactAttribute *attr = TupleDescCompactAttr(tupdesc, i);
|
||||
Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
|
||||
|
||||
cpy->missing[i].am_value = datumCopy(constr->missing[i].am_value,
|
||||
attr->attbyval,
|
||||
@@ -288,15 +252,9 @@ TupleDescCopy(TupleDesc dst, TupleDesc src)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Flat-copy the header and attribute arrays */
|
||||
/* Flat-copy the header and attribute array */
|
||||
memcpy(dst, src, TupleDescSize(src));
|
||||
|
||||
/*
|
||||
* Adjust 'attrs' to point to the dst FormData_pg_attribute array rather
|
||||
* than the src's.
|
||||
*/
|
||||
dst->attrs = TupleDescAttrAddress(dst);
|
||||
|
||||
/*
|
||||
* Since we're not copying constraints and defaults, clear fields
|
||||
* associated with them.
|
||||
@@ -310,8 +268,6 @@ TupleDescCopy(TupleDesc dst, TupleDesc src)
|
||||
att->atthasmissing = false;
|
||||
att->attidentity = '\0';
|
||||
att->attgenerated = '\0';
|
||||
|
||||
populate_compact_attribute(dst, i);
|
||||
}
|
||||
dst->constr = NULL;
|
||||
|
||||
@@ -366,8 +322,6 @@ TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno,
|
||||
dstAtt->atthasmissing = false;
|
||||
dstAtt->attidentity = '\0';
|
||||
dstAtt->attgenerated = '\0';
|
||||
|
||||
populate_compact_attribute(dst, dstAttno - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -567,7 +521,7 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
|
||||
return false;
|
||||
if (missval1->am_present)
|
||||
{
|
||||
CompactAttribute *missatt1 = TupleDescCompactAttr(tupdesc1, i);
|
||||
Form_pg_attribute missatt1 = TupleDescAttr(tupdesc1, i);
|
||||
|
||||
if (!datumIsEqual(missval1->am_value, missval2->am_value,
|
||||
missatt1->attbyval, missatt1->attlen))
|
||||
@@ -760,8 +714,6 @@ TupleDescInitEntry(TupleDesc desc,
|
||||
att->attcompression = InvalidCompressionMethod;
|
||||
att->attcollation = typeForm->typcollation;
|
||||
|
||||
populate_compact_attribute(desc, attributeNumber - 1);
|
||||
|
||||
ReleaseSysCache(tuple);
|
||||
}
|
||||
|
||||
@@ -869,8 +821,6 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
|
||||
default:
|
||||
elog(ERROR, "unsupported type %u", oidtypeid);
|
||||
}
|
||||
|
||||
populate_compact_attribute(desc, attributeNumber - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -331,9 +331,7 @@ getSpGistTupleDesc(Relation index, SpGistTypeDesc *keyType)
|
||||
att->attcollation = InvalidOid;
|
||||
/* In case we changed typlen, we'd better reset following offsets */
|
||||
for (int i = spgFirstIncludeColumn; i < outTupDesc->natts; i++)
|
||||
TupleDescCompactAttr(outTupDesc, i)->attcacheoff = -1;
|
||||
|
||||
populate_compact_attribute(outTupDesc, spgKeyColumn);
|
||||
TupleDescAttr(outTupDesc, i)->attcacheoff = -1;
|
||||
}
|
||||
return outTupDesc;
|
||||
}
|
||||
|
||||
@@ -477,8 +477,6 @@ ConstructTupleDescriptor(Relation heapRelation,
|
||||
|
||||
ReleaseSysCache(tuple);
|
||||
}
|
||||
|
||||
populate_compact_attribute(indexTupDesc, i);
|
||||
}
|
||||
|
||||
pfree(amroutine);
|
||||
|
||||
@@ -980,8 +980,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
|
||||
cookedDefaults = lappend(cookedDefaults, cooked);
|
||||
attr->atthasdef = true;
|
||||
}
|
||||
|
||||
populate_compact_attribute(descriptor, attnum - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1398,8 +1396,6 @@ BuildDescForRelation(const List *columns)
|
||||
att->attstorage = entry->storage;
|
||||
else if (entry->storage_name)
|
||||
att->attstorage = GetAttributeStorage(att->atttypid, entry->storage_name);
|
||||
|
||||
populate_compact_attribute(desc, attnum - 1);
|
||||
}
|
||||
|
||||
return desc;
|
||||
|
||||
@@ -1044,7 +1044,7 @@ slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
|
||||
|
||||
for (; attnum < natts; attnum++)
|
||||
{
|
||||
CompactAttribute *thisatt = TupleDescCompactAttr(tupleDesc, attnum);
|
||||
Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
|
||||
|
||||
if (hasnulls && att_isnull(attnum, bp))
|
||||
{
|
||||
@@ -2237,7 +2237,7 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
|
||||
*/
|
||||
for (i = 0; i < natts; i++)
|
||||
{
|
||||
if (!TupleDescCompactAttr(tupdesc, i)->attisdropped)
|
||||
if (!TupleDescAttr(tupdesc, i)->attisdropped)
|
||||
{
|
||||
/* Non-dropped attributes */
|
||||
dvalues[i] = InputFunctionCall(&attinmeta->attinfuncs[i],
|
||||
|
||||
21
src/backend/utils/cache/relcache.c
vendored
21
src/backend/utils/cache/relcache.c
vendored
@@ -585,8 +585,6 @@ RelationBuildTupleDesc(Relation relation)
|
||||
attp,
|
||||
ATTRIBUTE_FIXED_PART_SIZE);
|
||||
|
||||
populate_compact_attribute(relation->rd_att, attnum - 1);
|
||||
|
||||
/* Update constraint/default info */
|
||||
if (attp->attnotnull)
|
||||
constr->has_not_null = true;
|
||||
@@ -676,12 +674,12 @@ RelationBuildTupleDesc(Relation relation)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We can easily set the attcacheoff value for the first attribute: it
|
||||
* must be zero. This eliminates the need for special cases for attnum=1
|
||||
* that used to exist in fastgetattr() and index_getattr().
|
||||
* However, we can easily set the attcacheoff value for the first
|
||||
* attribute: it must be zero. This eliminates the need for special cases
|
||||
* for attnum=1 that used to exist in fastgetattr() and index_getattr().
|
||||
*/
|
||||
if (RelationGetNumberOfAttributes(relation) > 0)
|
||||
TupleDescCompactAttr(relation->rd_att, 0)->attcacheoff = 0;
|
||||
TupleDescAttr(relation->rd_att, 0)->attcacheoff = 0;
|
||||
|
||||
/*
|
||||
* Set up constraint/default info
|
||||
@@ -1967,12 +1965,10 @@ formrdesc(const char *relationName, Oid relationReltype,
|
||||
has_not_null |= attrs[i].attnotnull;
|
||||
/* make sure attcacheoff is valid */
|
||||
TupleDescAttr(relation->rd_att, i)->attcacheoff = -1;
|
||||
|
||||
populate_compact_attribute(relation->rd_att, i);
|
||||
}
|
||||
|
||||
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
|
||||
TupleDescCompactAttr(relation->rd_att, 0)->attcacheoff = 0;
|
||||
TupleDescAttr(relation->rd_att, 0)->attcacheoff = 0;
|
||||
|
||||
/* mark not-null status */
|
||||
if (has_not_null)
|
||||
@@ -3583,7 +3579,6 @@ RelationBuildLocalRelation(const char *relname,
|
||||
datt->attgenerated = satt->attgenerated;
|
||||
datt->attnotnull = satt->attnotnull;
|
||||
has_not_null |= satt->attnotnull;
|
||||
populate_compact_attribute(rel->rd_att, i);
|
||||
}
|
||||
|
||||
if (has_not_null)
|
||||
@@ -4404,12 +4399,10 @@ BuildHardcodedDescriptor(int natts, const FormData_pg_attribute *attrs)
|
||||
memcpy(TupleDescAttr(result, i), &attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
|
||||
/* make sure attcacheoff is valid */
|
||||
TupleDescAttr(result, i)->attcacheoff = -1;
|
||||
|
||||
populate_compact_attribute(result, i);
|
||||
}
|
||||
|
||||
/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */
|
||||
TupleDescCompactAttr(result, 0)->attcacheoff = 0;
|
||||
TupleDescAttr(result, 0)->attcacheoff = 0;
|
||||
|
||||
/* Note: we don't bother to set up a TupleConstr entry */
|
||||
|
||||
@@ -6173,8 +6166,6 @@ load_relcache_init_file(bool shared)
|
||||
goto read_failed;
|
||||
|
||||
has_not_null |= attr->attnotnull;
|
||||
|
||||
populate_compact_attribute(rel->rd_att, i);
|
||||
}
|
||||
|
||||
/* next read the access method specific field */
|
||||
|
||||
13
src/backend/utils/cache/typcache.c
vendored
13
src/backend/utils/cache/typcache.c
vendored
@@ -241,18 +241,12 @@ shared_record_table_compare(const void *a, const void *b, size_t size,
|
||||
TupleDesc t2;
|
||||
|
||||
if (k1->shared)
|
||||
{
|
||||
t1 = (TupleDesc) dsa_get_address(area, k1->u.shared_tupdesc);
|
||||
t1->attrs = TupleDescAttrAddress(t1);
|
||||
}
|
||||
else
|
||||
t1 = k1->u.local_tupdesc;
|
||||
|
||||
if (k2->shared)
|
||||
{
|
||||
t2 = (TupleDesc) dsa_get_address(area, k2->u.shared_tupdesc);
|
||||
t2->attrs = TupleDescAttrAddress(t2);
|
||||
}
|
||||
else
|
||||
t2 = k2->u.local_tupdesc;
|
||||
|
||||
@@ -270,10 +264,7 @@ shared_record_table_hash(const void *a, size_t size, void *arg)
|
||||
TupleDesc t;
|
||||
|
||||
if (k->shared)
|
||||
{
|
||||
t = (TupleDesc) dsa_get_address(area, k->u.shared_tupdesc);
|
||||
t->attrs = TupleDescAttrAddress(t);
|
||||
}
|
||||
else
|
||||
t = k->u.local_tupdesc;
|
||||
|
||||
@@ -1876,7 +1867,6 @@ lookup_rowtype_tupdesc_internal(Oid type_id, int32 typmod, bool noError)
|
||||
tupdesc = (TupleDesc)
|
||||
dsa_get_address(CurrentSession->area,
|
||||
entry->shared_tupdesc);
|
||||
tupdesc->attrs = TupleDescAttrAddress(tupdesc);
|
||||
Assert(typmod == tupdesc->tdtypmod);
|
||||
|
||||
/* We may need to extend the local RecordCacheArray. */
|
||||
@@ -2963,7 +2953,6 @@ find_or_make_matching_shared_tupledesc(TupleDesc tupdesc)
|
||||
result = (TupleDesc)
|
||||
dsa_get_address(CurrentSession->area,
|
||||
record_table_entry->key.u.shared_tupdesc);
|
||||
result->attrs = TupleDescAttrAddress(result);
|
||||
Assert(result->tdrefcount == -1);
|
||||
|
||||
return result;
|
||||
@@ -3027,7 +3016,6 @@ find_or_make_matching_shared_tupledesc(TupleDesc tupdesc)
|
||||
result = (TupleDesc)
|
||||
dsa_get_address(CurrentSession->area,
|
||||
record_table_entry->key.u.shared_tupdesc);
|
||||
result->attrs = TupleDescAttrAddress(result);
|
||||
Assert(result->tdrefcount == -1);
|
||||
|
||||
return result;
|
||||
@@ -3040,7 +3028,6 @@ find_or_make_matching_shared_tupledesc(TupleDesc tupdesc)
|
||||
record_table_entry);
|
||||
result = (TupleDesc)
|
||||
dsa_get_address(CurrentSession->area, shared_dp);
|
||||
result->attrs = TupleDescAttrAddress(result);
|
||||
Assert(result->tdrefcount == -1);
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user