Skip to content

Commit e4597ee

Browse files
committed
InsertPgAttributeTuple() to set attcacheoff
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>
1 parent 520acab commit e4597ee

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

src/backend/catalog/heap.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,8 @@ CheckAttributeType(const char *attname,
592592
* Construct and insert a new tuple in pg_attribute.
593593
*
594594
* Caller has already opened and locked pg_attribute. new_attribute is the
595-
* attribute to insert (but we ignore attacl and attoptions, which are always
596-
* initialized to NULL).
595+
* attribute to insert. attcacheoff is always initialized to -1, attacl and
596+
* attoptions are always initialized to NULL.
597597
*
598598
* indstate is the index state for CatalogTupleInsertWithInfo. It can be
599599
* passed as NULL, in which case we'll fetch the necessary info. (Don't do
@@ -620,7 +620,7 @@ InsertPgAttributeTuple(Relation pg_attribute_rel,
620620
values[Anum_pg_attribute_attlen - 1] = Int16GetDatum(new_attribute->attlen);
621621
values[Anum_pg_attribute_attnum - 1] = Int16GetDatum(new_attribute->attnum);
622622
values[Anum_pg_attribute_attndims - 1] = Int32GetDatum(new_attribute->attndims);
623-
values[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(new_attribute->attcacheoff);
623+
values[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1);
624624
values[Anum_pg_attribute_atttypmod - 1] = Int32GetDatum(new_attribute->atttypmod);
625625
values[Anum_pg_attribute_attbyval - 1] = BoolGetDatum(new_attribute->attbyval);
626626
values[Anum_pg_attribute_attstorage - 1] = CharGetDatum(new_attribute->attstorage);
@@ -689,9 +689,8 @@ AddNewAttributeTuples(Oid new_rel_oid,
689689
attr = TupleDescAttr(tupdesc, i);
690690
/* Fill in the correct relation OID */
691691
attr->attrelid = new_rel_oid;
692-
/* Make sure these are OK, too */
692+
/* Make sure this is OK, too */
693693
attr->attstattarget = -1;
694-
attr->attcacheoff = -1;
695694

696695
InsertPgAttributeTuple(rel, attr, indstate);
697696

src/backend/catalog/index.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
557557
{
558558
Form_pg_attribute attr = TupleDescAttr(indexTupDesc, i);
559559

560-
/*
561-
* There used to be very grotty code here to set these fields, but I
562-
* think it's unnecessary. They should be set already.
563-
*/
564560
Assert(attr->attnum == i + 1);
565-
Assert(attr->attcacheoff == -1);
566561

567562
InsertPgAttributeTuple(pg_attribute, attr, indstate);
568563
}

src/backend/commands/tablecmds.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5522,7 +5522,6 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
55225522
attribute.atttypid = typeOid;
55235523
attribute.attstattarget = (newattnum > 0) ? -1 : 0;
55245524
attribute.attlen = tform->typlen;
5525-
attribute.attcacheoff = -1;
55265525
attribute.atttypmod = typmod;
55275526
attribute.attnum = newattnum;
55285527
attribute.attbyval = tform->typbyval;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy