postgres.git / summary / log / commit / refs
commit 526d9ca619cc466fd637a7545c0d3ad3ea7bc6cf
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Thu Apr 23 18:05:27 2026 +0000
First released in: 14.23, 15.18, 16.14, 17.10, 18.4
Don't call CheckAttributeType() with InvalidOid on dropped cols
If CheckAttributeType() is called with InvalidOid, it performs a bunch
of pointless, futile syscache lookups with InvalidOid, but ultimately
tolerates it and has no effect. We were calling it with InvalidOid on
dropped columns, but it seems accidental that it works, so let's stop
doing it.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/93ce56cd-02a6-4db1-8224-c8999372facc@iki.fi
Backpatch-through: 14
src/backend/catalog/heap.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 5811bcd074c..194a692aeb4 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -508,9 +508,13 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
*/
for (i = 0; i < natts; i++)
{
- CheckAttributeType(NameStr(TupleDescAttr(tupdesc, i)->attname),
- TupleDescAttr(tupdesc, i)->atttypid,
- TupleDescAttr(tupdesc, i)->attcollation,
+ Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
+
+ if (attr->attisdropped)
+ continue;
+ CheckAttributeType(NameStr(attr->attname),
+ attr->atttypid,
+ attr->attcollation,
NIL, /* assume we're creating a new rowtype */
flags);
}
[parent: 06e304524d5c]