diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index c1212e9..7adc216 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -2037,6 +2037,15 @@ add_object_address(ObjectClass oclass, Oid objectId, int32 subId, { ObjectAddress *item; + /* + * Ensure object_classes is properly sized. Can't use OidIsValid here + * because it's not marked as static (nor should it be). + */ + StaticAssertStmt(object_classes[MAX_OCLASS - 1] != 0, + "last OID in object_classes[] is invalid (did you forget to add a new entry to it?)"); + + Assert(OidIsValid(object_classes[oclass])); + /* enlarge array if needed */ if (addrs->numrefs >= addrs->maxrefs) { diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h index 5da18c2..515417d 100644 --- a/src/include/catalog/dependency.h +++ b/src/include/catalog/dependency.h @@ -149,6 +149,8 @@ typedef enum ObjectClass OCLASS_EVENT_TRIGGER, /* pg_event_trigger */ OCLASS_POLICY, /* pg_policy */ OCLASS_TRANSFORM, /* pg_transform */ + + /* New classes need to be added to object_classes[] too. */ MAX_OCLASS /* MUST BE LAST */ } ObjectClass;