summaryrefslogtreecommitdiff
path: root/src/backend/access/common/tupdesc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/common/tupdesc.c')
-rw-r--r--src/backend/access/common/tupdesc.c70
1 files changed, 10 insertions, 60 deletions
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index b49584768e5..47379fef220 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -57,33 +57,6 @@ ResourceOwnerForgetTupleDesc(ResourceOwner owner, TupleDesc tupdesc)
}
/*
- * 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,16 +252,10 @@ 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);
}
/*