1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

Remove ancient special case code for dropping oid columns

The special handling of negative attribute numbers in
RemoveAttributeById() was introduced to support SET WITHOUT OIDS
(commit 24614a9880).  But that feature doesn't exist anymore, so we
can revert to the previous, simpler version.

Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/52a125e4-ff9a-95f5-9f61-b87cf447e4da@eisentraut.org
This commit is contained in:
Peter Eisentraut
2023-07-12 16:12:34 +02:00
parent 5eaa0e92ee
commit 7ef2912519

View File

@ -1666,27 +1666,16 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
attnum, relid); attnum, relid);
attStruct = (Form_pg_attribute) GETSTRUCT(tuple); attStruct = (Form_pg_attribute) GETSTRUCT(tuple);
if (attnum < 0)
{
/* System attribute (probably OID) ... just delete the row */
CatalogTupleDelete(attr_rel, &tuple->t_self);
}
else
{
/* Dropping user attributes is lots harder */
/* Mark the attribute as dropped */ /* Mark the attribute as dropped */
attStruct->attisdropped = true; attStruct->attisdropped = true;
/* /*
* Set the type OID to invalid. A dropped attribute's type link * Set the type OID to invalid. A dropped attribute's type link cannot be
* cannot be relied on (once the attribute is dropped, the type might * relied on (once the attribute is dropped, the type might be too).
* be too). Fortunately we do not need the type row --- the only * Fortunately we do not need the type row --- the only really essential
* really essential information is the type's typlen and typalign, * information is the type's typlen and typalign, which are preserved in
* which are preserved in the attribute's attlen and attalign. We set * the attribute's attlen and attalign. We set atttypid to zero here as a
* atttypid to zero here as a means of catching code that incorrectly * means of catching code that incorrectly expects it to be valid.
* expects it to be valid.
*/ */
attStruct->atttypid = InvalidOid; attStruct->atttypid = InvalidOid;
@ -1726,7 +1715,6 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
} }
CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple); CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple);
}
/* /*
* Because updating the pg_attribute row will trigger a relcache flush for * Because updating the pg_attribute row will trigger a relcache flush for
@ -1736,7 +1724,6 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
table_close(attr_rel, RowExclusiveLock); table_close(attr_rel, RowExclusiveLock);
if (attnum > 0)
RemoveStatistics(relid, attnum); RemoveStatistics(relid, attnum);
relation_close(rel, NoLock); relation_close(rel, NoLock);