]> granicus.if.org Git - postgresql/commitdiff
InsertPgAttributeTuple() to set attcacheoff
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 17 Jul 2018 07:48:29 +0000 (09:48 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 17 Aug 2018 20:08:21 +0000 (22:08 +0200)
InsertPgAttributeTuple() is the interface between in-memory tuple
descriptors and on-disk pg_attribute, so it makes sense to give it the
job of resetting attcacheoff.  This avoids having all the callers having
to do so.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/commands/tablecmds.c

index 4cfc0c89116438b71f78453ff3c5ffd6d161be33..ac5a677c5f76c9e362696909de11f3b29f448164 100644 (file)
@@ -592,8 +592,8 @@ CheckAttributeType(const char *attname,
  *             Construct and insert a new tuple in pg_attribute.
  *
  * Caller has already opened and locked pg_attribute.  new_attribute is the
- * attribute to insert (but we ignore attacl and attoptions, which are always
- * initialized to NULL).
+ * attribute to insert.  attcacheoff is always initialized to -1, attacl and
+ * attoptions are always initialized to NULL.
  *
  * indstate is the index state for CatalogTupleInsertWithInfo.  It can be
  * passed as NULL, in which case we'll fetch the necessary info.  (Don't do
@@ -620,7 +620,7 @@ InsertPgAttributeTuple(Relation pg_attribute_rel,
        values[Anum_pg_attribute_attlen - 1] = Int16GetDatum(new_attribute->attlen);
        values[Anum_pg_attribute_attnum - 1] = Int16GetDatum(new_attribute->attnum);
        values[Anum_pg_attribute_attndims - 1] = Int32GetDatum(new_attribute->attndims);
-       values[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(new_attribute->attcacheoff);
+       values[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1);
        values[Anum_pg_attribute_atttypmod - 1] = Int32GetDatum(new_attribute->atttypmod);
        values[Anum_pg_attribute_attbyval - 1] = BoolGetDatum(new_attribute->attbyval);
        values[Anum_pg_attribute_attstorage - 1] = CharGetDatum(new_attribute->attstorage);
@@ -689,9 +689,8 @@ AddNewAttributeTuples(Oid new_rel_oid,
                attr = TupleDescAttr(tupdesc, i);
                /* Fill in the correct relation OID */
                attr->attrelid = new_rel_oid;
-               /* Make sure these are OK, too */
+               /* Make sure this is OK, too */
                attr->attstattarget = -1;
-               attr->attcacheoff = -1;
 
                InsertPgAttributeTuple(rel, attr, indstate);
 
index 2dad7b059e9fec1ec1a1fb2fa0218ae3a9d41d95..b2560549083cea9ff81be8879b706b349a2eb00d 100644 (file)
@@ -557,12 +557,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
        {
                Form_pg_attribute attr = TupleDescAttr(indexTupDesc, i);
 
-               /*
-                * There used to be very grotty code here to set these fields, but I
-                * think it's unnecessary.  They should be set already.
-                */
                Assert(attr->attnum == i + 1);
-               Assert(attr->attcacheoff == -1);
 
                InsertPgAttributeTuple(pg_attribute, attr, indstate);
        }
index f6210226e981aa7010eb5548f59822b9565bc5f3..7cedc28c6b5e72187ddd5a377acbff0f814da0ed 100644 (file)
@@ -5522,7 +5522,6 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
        attribute.atttypid = typeOid;
        attribute.attstattarget = (newattnum > 0) ? -1 : 0;
        attribute.attlen = tform->typlen;
-       attribute.attcacheoff = -1;
        attribute.atttypmod = typmod;
        attribute.attnum = newattnum;
        attribute.attbyval = tform->typbyval;