aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-02-27 15:18:17 +0900
committerMichael Paquier <michael@paquier.xyz>2024-02-27 15:18:17 +0900
commitef5e2e90859a39efdd3a78e528c544b585295a78 (patch)
treed8862c9ff15c9823a788f77263a97bbd82f5e8d4 /src
parent743112a2e9938b98d716384fa9374c41afe74e41 (diff)
downloadpostgresql-ef5e2e90859a39efdd3a78e528c544b585295a78.tar.gz
postgresql-ef5e2e90859a39efdd3a78e528c544b585295a78.zip
Remove unnecessary array object_classes[] in dependency.c
object_classes[] provided unnecessary indirection between catalog OIDs and the enum ObjectClass when calling add_object_address(). This array has been originally introduced in 30ec31604d5 and was useful because not all relation OIDs were compile-time constants back then, which has not been the case for a long time now for all the elements of ObjectClass. This commit removes object_classes[], switching to the catalog OIDs when calling add_object_address(). This shaves some code while saving in maintenance because it was necessary to maintain the enum ObjectClass and the array in sync when adding new object types. Reported-by: Jeff Davis Author: Jelte Fennema-Nio Reviewed-by: Jian He, Michael Paquier Discussion: https://postgr.es/m/CAGECzQT3caUbcCcszNewCCmMbCuyP7XNAm60J3ybd6PN5kH2Dw@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/dependency.c181
-rw-r--r--src/include/catalog/dependency.h4
2 files changed, 63 insertions, 122 deletions
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index df9886efc95..2eb41d537bb 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -144,60 +144,6 @@ typedef struct
List *rtables; /* list of rangetables to resolve Vars */
} find_expr_references_context;
-/*
- * This constant table maps ObjectClasses to the corresponding catalog OIDs.
- * See also getObjectClass().
- */
-static const Oid object_classes[] = {
- RelationRelationId, /* OCLASS_CLASS */
- ProcedureRelationId, /* OCLASS_PROC */
- TypeRelationId, /* OCLASS_TYPE */
- CastRelationId, /* OCLASS_CAST */
- CollationRelationId, /* OCLASS_COLLATION */
- ConstraintRelationId, /* OCLASS_CONSTRAINT */
- ConversionRelationId, /* OCLASS_CONVERSION */
- AttrDefaultRelationId, /* OCLASS_DEFAULT */
- LanguageRelationId, /* OCLASS_LANGUAGE */
- LargeObjectRelationId, /* OCLASS_LARGEOBJECT */
- OperatorRelationId, /* OCLASS_OPERATOR */
- OperatorClassRelationId, /* OCLASS_OPCLASS */
- OperatorFamilyRelationId, /* OCLASS_OPFAMILY */
- AccessMethodRelationId, /* OCLASS_AM */
- AccessMethodOperatorRelationId, /* OCLASS_AMOP */
- AccessMethodProcedureRelationId, /* OCLASS_AMPROC */
- RewriteRelationId, /* OCLASS_REWRITE */
- TriggerRelationId, /* OCLASS_TRIGGER */
- NamespaceRelationId, /* OCLASS_SCHEMA */
- StatisticExtRelationId, /* OCLASS_STATISTIC_EXT */
- TSParserRelationId, /* OCLASS_TSPARSER */
- TSDictionaryRelationId, /* OCLASS_TSDICT */
- TSTemplateRelationId, /* OCLASS_TSTEMPLATE */
- TSConfigRelationId, /* OCLASS_TSCONFIG */
- AuthIdRelationId, /* OCLASS_ROLE */
- AuthMemRelationId, /* OCLASS_ROLE_MEMBERSHIP */
- DatabaseRelationId, /* OCLASS_DATABASE */
- TableSpaceRelationId, /* OCLASS_TBLSPACE */
- ForeignDataWrapperRelationId, /* OCLASS_FDW */
- ForeignServerRelationId, /* OCLASS_FOREIGN_SERVER */
- UserMappingRelationId, /* OCLASS_USER_MAPPING */
- DefaultAclRelationId, /* OCLASS_DEFACL */
- ExtensionRelationId, /* OCLASS_EXTENSION */
- EventTriggerRelationId, /* OCLASS_EVENT_TRIGGER */
- ParameterAclRelationId, /* OCLASS_PARAMETER_ACL */
- PolicyRelationId, /* OCLASS_POLICY */
- PublicationNamespaceRelationId, /* OCLASS_PUBLICATION_NAMESPACE */
- PublicationRelationId, /* OCLASS_PUBLICATION */
- PublicationRelRelationId, /* OCLASS_PUBLICATION_REL */
- SubscriptionRelationId, /* OCLASS_SUBSCRIPTION */
- TransformRelationId /* OCLASS_TRANSFORM */
-};
-
-/*
- * Make sure object_classes is kept up to date with the ObjectClass enum.
- */
-StaticAssertDecl(lengthof(object_classes) == LAST_OCLASS + 1,
- "object_classes[] must cover all ObjectClasses");
-
static void findDependentObjects(const ObjectAddress *object,
int objflags,
@@ -219,7 +165,7 @@ static void process_function_rte_ref(RangeTblEntry *rte, AttrNumber attnum,
find_expr_references_context *context);
static void eliminate_duplicate_dependencies(ObjectAddresses *addrs);
static int object_address_comparator(const void *a, const void *b);
-static void add_object_address(ObjectClass oclass, Oid objectId, int32 subId,
+static void add_object_address(Oid classId, Oid objectId, int32 subId,
ObjectAddresses *addrs);
static void add_exact_object_address_extra(const ObjectAddress *object,
const ObjectAddressExtra *extra,
@@ -1786,7 +1732,7 @@ find_expr_references_walker(Node *node,
if (rte->rtekind == RTE_RELATION)
{
/* If it's a plain relation, reference this column */
- add_object_address(OCLASS_CLASS, rte->relid, var->varattno,
+ add_object_address(RelationRelationId, rte->relid, var->varattno,
context->addrs);
}
else if (rte->rtekind == RTE_FUNCTION)
@@ -1812,7 +1758,7 @@ find_expr_references_walker(Node *node,
Oid objoid;
/* A constant must depend on the constant's datatype */
- add_object_address(OCLASS_TYPE, con->consttype, 0,
+ add_object_address(TypeRelationId, con->consttype, 0,
context->addrs);
/*
@@ -1823,7 +1769,7 @@ find_expr_references_walker(Node *node,
*/
if (OidIsValid(con->constcollid) &&
con->constcollid != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, con->constcollid, 0,
+ add_object_address(CollationRelationId, con->constcollid, 0,
context->addrs);
/*
@@ -1841,7 +1787,7 @@ find_expr_references_walker(Node *node,
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists1(PROCOID,
ObjectIdGetDatum(objoid)))
- add_object_address(OCLASS_PROC, objoid, 0,
+ add_object_address(ProcedureRelationId, objoid, 0,
context->addrs);
break;
case REGOPEROID:
@@ -1849,42 +1795,42 @@ find_expr_references_walker(Node *node,
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists1(OPEROID,
ObjectIdGetDatum(objoid)))
- add_object_address(OCLASS_OPERATOR, objoid, 0,
+ add_object_address(OperatorRelationId, objoid, 0,
context->addrs);
break;
case REGCLASSOID:
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists1(RELOID,
ObjectIdGetDatum(objoid)))
- add_object_address(OCLASS_CLASS, objoid, 0,
+ add_object_address(RelationRelationId, objoid, 0,
context->addrs);
break;
case REGTYPEOID:
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists1(TYPEOID,
ObjectIdGetDatum(objoid)))
- add_object_address(OCLASS_TYPE, objoid, 0,
+ add_object_address(TypeRelationId, objoid, 0,
context->addrs);
break;
case REGCOLLATIONOID:
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists1(COLLOID,
ObjectIdGetDatum(objoid)))
- add_object_address(OCLASS_COLLATION, objoid, 0,
+ add_object_address(CollationRelationId, objoid, 0,
context->addrs);
break;
case REGCONFIGOID:
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists1(TSCONFIGOID,
ObjectIdGetDatum(objoid)))
- add_object_address(OCLASS_TSCONFIG, objoid, 0,
+ add_object_address(TSConfigRelationId, objoid, 0,
context->addrs);
break;
case REGDICTIONARYOID:
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists1(TSDICTOID,
ObjectIdGetDatum(objoid)))
- add_object_address(OCLASS_TSDICT, objoid, 0,
+ add_object_address(TSDictionaryRelationId, objoid, 0,
context->addrs);
break;
@@ -1892,7 +1838,7 @@ find_expr_references_walker(Node *node,
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists1(NAMESPACEOID,
ObjectIdGetDatum(objoid)))
- add_object_address(OCLASS_SCHEMA, objoid, 0,
+ add_object_address(NamespaceRelationId, objoid, 0,
context->addrs);
break;
@@ -1915,19 +1861,19 @@ find_expr_references_walker(Node *node,
Param *param = (Param *) node;
/* A parameter must depend on the parameter's datatype */
- add_object_address(OCLASS_TYPE, param->paramtype, 0,
+ add_object_address(TypeRelationId, param->paramtype, 0,
context->addrs);
/* and its collation, just as for Consts */
if (OidIsValid(param->paramcollid) &&
param->paramcollid != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, param->paramcollid, 0,
+ add_object_address(CollationRelationId, param->paramcollid, 0,
context->addrs);
}
else if (IsA(node, FuncExpr))
{
FuncExpr *funcexpr = (FuncExpr *) node;
- add_object_address(OCLASS_PROC, funcexpr->funcid, 0,
+ add_object_address(ProcedureRelationId, funcexpr->funcid, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -1935,7 +1881,7 @@ find_expr_references_walker(Node *node,
{
OpExpr *opexpr = (OpExpr *) node;
- add_object_address(OCLASS_OPERATOR, opexpr->opno, 0,
+ add_object_address(OperatorRelationId, opexpr->opno, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -1943,7 +1889,7 @@ find_expr_references_walker(Node *node,
{
DistinctExpr *distinctexpr = (DistinctExpr *) node;
- add_object_address(OCLASS_OPERATOR, distinctexpr->opno, 0,
+ add_object_address(OperatorRelationId, distinctexpr->opno, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -1951,7 +1897,7 @@ find_expr_references_walker(Node *node,
{
NullIfExpr *nullifexpr = (NullIfExpr *) node;
- add_object_address(OCLASS_OPERATOR, nullifexpr->opno, 0,
+ add_object_address(OperatorRelationId, nullifexpr->opno, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -1959,7 +1905,7 @@ find_expr_references_walker(Node *node,
{
ScalarArrayOpExpr *opexpr = (ScalarArrayOpExpr *) node;
- add_object_address(OCLASS_OPERATOR, opexpr->opno, 0,
+ add_object_address(OperatorRelationId, opexpr->opno, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -1967,7 +1913,7 @@ find_expr_references_walker(Node *node,
{
Aggref *aggref = (Aggref *) node;
- add_object_address(OCLASS_PROC, aggref->aggfnoid, 0,
+ add_object_address(ProcedureRelationId, aggref->aggfnoid, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -1975,7 +1921,7 @@ find_expr_references_walker(Node *node,
{
WindowFunc *wfunc = (WindowFunc *) node;
- add_object_address(OCLASS_PROC, wfunc->winfnoid, 0,
+ add_object_address(ProcedureRelationId, wfunc->winfnoid, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -1991,7 +1937,7 @@ find_expr_references_walker(Node *node,
*/
if (sbsref->refrestype != sbsref->refcontainertype &&
sbsref->refrestype != sbsref->refelemtype)
- add_object_address(OCLASS_TYPE, sbsref->refrestype, 0,
+ add_object_address(TypeRelationId, sbsref->refrestype, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -2016,15 +1962,15 @@ find_expr_references_walker(Node *node,
* anywhere else in the expression.
*/
if (OidIsValid(reltype))
- add_object_address(OCLASS_CLASS, reltype, fselect->fieldnum,
+ add_object_address(RelationRelationId, reltype, fselect->fieldnum,
context->addrs);
else
- add_object_address(OCLASS_TYPE, fselect->resulttype, 0,
+ add_object_address(TypeRelationId, fselect->resulttype, 0,
context->addrs);
/* the collation might not be referenced anywhere else, either */
if (OidIsValid(fselect->resultcollid) &&
fselect->resultcollid != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, fselect->resultcollid, 0,
+ add_object_address(CollationRelationId, fselect->resultcollid, 0,
context->addrs);
}
else if (IsA(node, FieldStore))
@@ -2038,11 +1984,11 @@ find_expr_references_walker(Node *node,
ListCell *l;
foreach(l, fstore->fieldnums)
- add_object_address(OCLASS_CLASS, reltype, lfirst_int(l),
+ add_object_address(RelationRelationId, reltype, lfirst_int(l),
context->addrs);
}
else
- add_object_address(OCLASS_TYPE, fstore->resulttype, 0,
+ add_object_address(TypeRelationId, fstore->resulttype, 0,
context->addrs);
}
else if (IsA(node, RelabelType))
@@ -2050,12 +1996,12 @@ find_expr_references_walker(Node *node,
RelabelType *relab = (RelabelType *) node;
/* since there is no function dependency, need to depend on type */
- add_object_address(OCLASS_TYPE, relab->resulttype, 0,
+ add_object_address(TypeRelationId, relab->resulttype, 0,
context->addrs);
/* the collation might not be referenced anywhere else, either */
if (OidIsValid(relab->resultcollid) &&
relab->resultcollid != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, relab->resultcollid, 0,
+ add_object_address(CollationRelationId, relab->resultcollid, 0,
context->addrs);
}
else if (IsA(node, CoerceViaIO))
@@ -2063,12 +2009,12 @@ find_expr_references_walker(Node *node,
CoerceViaIO *iocoerce = (CoerceViaIO *) node;
/* since there is no exposed function, need to depend on type */
- add_object_address(OCLASS_TYPE, iocoerce->resulttype, 0,
+ add_object_address(TypeRelationId, iocoerce->resulttype, 0,
context->addrs);
/* the collation might not be referenced anywhere else, either */
if (OidIsValid(iocoerce->resultcollid) &&
iocoerce->resultcollid != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, iocoerce->resultcollid, 0,
+ add_object_address(CollationRelationId, iocoerce->resultcollid, 0,
context->addrs);
}
else if (IsA(node, ArrayCoerceExpr))
@@ -2076,12 +2022,12 @@ find_expr_references_walker(Node *node,
ArrayCoerceExpr *acoerce = (ArrayCoerceExpr *) node;
/* as above, depend on type */
- add_object_address(OCLASS_TYPE, acoerce->resulttype, 0,
+ add_object_address(TypeRelationId, acoerce->resulttype, 0,
context->addrs);
/* the collation might not be referenced anywhere else, either */
if (OidIsValid(acoerce->resultcollid) &&
acoerce->resultcollid != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, acoerce->resultcollid, 0,
+ add_object_address(CollationRelationId, acoerce->resultcollid, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -2090,21 +2036,21 @@ find_expr_references_walker(Node *node,
ConvertRowtypeExpr *cvt = (ConvertRowtypeExpr *) node;
/* since there is no function dependency, need to depend on type */
- add_object_address(OCLASS_TYPE, cvt->resulttype, 0,
+ add_object_address(TypeRelationId, cvt->resulttype, 0,
context->addrs);
}
else if (IsA(node, CollateExpr))
{
CollateExpr *coll = (CollateExpr *) node;
- add_object_address(OCLASS_COLLATION, coll->collOid, 0,
+ add_object_address(CollationRelationId, coll->collOid, 0,
context->addrs);
}
else if (IsA(node, RowExpr))
{
RowExpr *rowexpr = (RowExpr *) node;
- add_object_address(OCLASS_TYPE, rowexpr->row_typeid, 0,
+ add_object_address(TypeRelationId, rowexpr->row_typeid, 0,
context->addrs);
}
else if (IsA(node, RowCompareExpr))
@@ -2114,12 +2060,12 @@ find_expr_references_walker(Node *node,
foreach(l, rcexpr->opnos)
{
- add_object_address(OCLASS_OPERATOR, lfirst_oid(l), 0,
+ add_object_address(OperatorRelationId, lfirst_oid(l), 0,
context->addrs);
}
foreach(l, rcexpr->opfamilies)
{
- add_object_address(OCLASS_OPFAMILY, lfirst_oid(l), 0,
+ add_object_address(OperatorFamilyRelationId, lfirst_oid(l), 0,
context->addrs);
}
/* fall through to examine arguments */
@@ -2128,14 +2074,14 @@ find_expr_references_walker(Node *node,
{
CoerceToDomain *cd = (CoerceToDomain *) node;
- add_object_address(OCLASS_TYPE, cd->resulttype, 0,
+ add_object_address(TypeRelationId, cd->resulttype, 0,
context->addrs);
}
else if (IsA(node, NextValueExpr))
{
NextValueExpr *nve = (NextValueExpr *) node;
- add_object_address(OCLASS_CLASS, nve->seqid, 0,
+ add_object_address(RelationRelationId, nve->seqid, 0,
context->addrs);
}
else if (IsA(node, OnConflictExpr))
@@ -2143,7 +2089,7 @@ find_expr_references_walker(Node *node,
OnConflictExpr *onconflict = (OnConflictExpr *) node;
if (OidIsValid(onconflict->constraint))
- add_object_address(OCLASS_CONSTRAINT, onconflict->constraint, 0,
+ add_object_address(ConstraintRelationId, onconflict->constraint, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -2151,10 +2097,10 @@ find_expr_references_walker(Node *node,
{
SortGroupClause *sgc = (SortGroupClause *) node;
- add_object_address(OCLASS_OPERATOR, sgc->eqop, 0,
+ add_object_address(OperatorRelationId, sgc->eqop, 0,
context->addrs);
if (OidIsValid(sgc->sortop))
- add_object_address(OCLASS_OPERATOR, sgc->sortop, 0,
+ add_object_address(OperatorRelationId, sgc->sortop, 0,
context->addrs);
return false;
}
@@ -2163,14 +2109,14 @@ find_expr_references_walker(Node *node,
WindowClause *wc = (WindowClause *) node;
if (OidIsValid(wc->startInRangeFunc))
- add_object_address(OCLASS_PROC, wc->startInRangeFunc, 0,
+ add_object_address(ProcedureRelationId, wc->startInRangeFunc, 0,
context->addrs);
if (OidIsValid(wc->endInRangeFunc))
- add_object_address(OCLASS_PROC, wc->endInRangeFunc, 0,
+ add_object_address(ProcedureRelationId, wc->endInRangeFunc, 0,
context->addrs);
if (OidIsValid(wc->inRangeColl) &&
wc->inRangeColl != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, wc->inRangeColl, 0,
+ add_object_address(CollationRelationId, wc->inRangeColl, 0,
context->addrs);
/* fall through to examine substructure */
}
@@ -2179,13 +2125,13 @@ find_expr_references_walker(Node *node,
CTECycleClause *cc = (CTECycleClause *) node;
if (OidIsValid(cc->cycle_mark_type))
- add_object_address(OCLASS_TYPE, cc->cycle_mark_type, 0,
+ add_object_address(TypeRelationId, cc->cycle_mark_type, 0,
context->addrs);
if (OidIsValid(cc->cycle_mark_collation))
- add_object_address(OCLASS_COLLATION, cc->cycle_mark_collation, 0,
+ add_object_address(CollationRelationId, cc->cycle_mark_collation, 0,
context->addrs);
if (OidIsValid(cc->cycle_mark_neop))
- add_object_address(OCLASS_OPERATOR, cc->cycle_mark_neop, 0,
+ add_object_address(OperatorRelationId, cc->cycle_mark_neop, 0,
context->addrs);
/* fall through to examine substructure */
}
@@ -2219,7 +2165,7 @@ find_expr_references_walker(Node *node,
switch (rte->rtekind)
{
case RTE_RELATION:
- add_object_address(OCLASS_CLASS, rte->relid, 0,
+ add_object_address(RelationRelationId, rte->relid, 0,
context->addrs);
break;
case RTE_JOIN:
@@ -2277,7 +2223,7 @@ find_expr_references_walker(Node *node,
if (tle->resjunk)
continue; /* ignore junk tlist items */
- add_object_address(OCLASS_CLASS, rte->relid, tle->resno,
+ add_object_address(RelationRelationId, rte->relid, tle->resno,
context->addrs);
}
}
@@ -2288,7 +2234,7 @@ find_expr_references_walker(Node *node,
*/
foreach(lc, query->constraintDeps)
{
- add_object_address(OCLASS_CONSTRAINT, lfirst_oid(lc), 0,
+ add_object_address(ConstraintRelationId, lfirst_oid(lc), 0,
context->addrs);
}
@@ -2322,7 +2268,7 @@ find_expr_references_walker(Node *node,
*/
foreach(ct, rtfunc->funccoltypes)
{
- add_object_address(OCLASS_TYPE, lfirst_oid(ct), 0,
+ add_object_address(TypeRelationId, lfirst_oid(ct), 0,
context->addrs);
}
foreach(ct, rtfunc->funccolcollations)
@@ -2330,7 +2276,7 @@ find_expr_references_walker(Node *node,
Oid collid = lfirst_oid(ct);
if (OidIsValid(collid) && collid != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, collid, 0,
+ add_object_address(CollationRelationId, collid, 0,
context->addrs);
}
}
@@ -2344,7 +2290,7 @@ find_expr_references_walker(Node *node,
*/
foreach(ct, tf->coltypes)
{
- add_object_address(OCLASS_TYPE, lfirst_oid(ct), 0,
+ add_object_address(TypeRelationId, lfirst_oid(ct), 0,
context->addrs);
}
foreach(ct, tf->colcollations)
@@ -2352,7 +2298,7 @@ find_expr_references_walker(Node *node,
Oid collid = lfirst_oid(ct);
if (OidIsValid(collid) && collid != DEFAULT_COLLATION_OID)
- add_object_address(OCLASS_COLLATION, collid, 0,
+ add_object_address(CollationRelationId, collid, 0,
context->addrs);
}
}
@@ -2360,7 +2306,7 @@ find_expr_references_walker(Node *node,
{
TableSampleClause *tsc = (TableSampleClause *) node;
- add_object_address(OCLASS_PROC, tsc->tsmhandler, 0,
+ add_object_address(ProcedureRelationId, tsc->tsmhandler, 0,
context->addrs);
/* fall through to examine arguments */
}
@@ -2406,7 +2352,7 @@ process_function_rte_ref(RangeTblEntry *rte, AttrNumber attnum,
Assert(attnum - atts_done <= tupdesc->natts);
if (OidIsValid(reltype)) /* can this fail? */
- add_object_address(OCLASS_CLASS, reltype,
+ add_object_address(RelationRelationId, reltype,
attnum - atts_done,
context->addrs);
return;
@@ -2553,12 +2499,9 @@ new_object_addresses(void)
/*
* Add an entry to an ObjectAddresses array.
- *
- * It is convenient to specify the class by ObjectClass rather than directly
- * by catalog OID.
*/
static void
-add_object_address(ObjectClass oclass, Oid objectId, int32 subId,
+add_object_address(Oid classId, Oid objectId, int32 subId,
ObjectAddresses *addrs)
{
ObjectAddress *item;
@@ -2573,7 +2516,7 @@ add_object_address(ObjectClass oclass, Oid objectId, int32 subId,
}
/* record this item */
item = addrs->refs + addrs->numrefs;
- item->classId = object_classes[oclass];
+ item->classId = classId;
item->objectId = objectId;
item->objectSubId = subId;
addrs->numrefs++;
@@ -2836,8 +2779,8 @@ free_object_addresses(ObjectAddresses *addrs)
/*
* Determine the class of a given object identified by objectAddress.
*
- * This function is essentially the reverse mapping for the object_classes[]
- * table. We implement it as a function because the OIDs aren't consecutive.
+ * We implement it as a function instead of an array because the OIDs aren't
+ * consecutive.
*/
ObjectClass
getObjectClass(const ObjectAddress *object)
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
index fd588659014..436b081738b 100644
--- a/src/include/catalog/dependency.h
+++ b/src/include/catalog/dependency.h
@@ -83,7 +83,7 @@ typedef struct ObjectAddresses ObjectAddresses;
/*
* This enum covers all system catalogs whose OIDs can appear in
- * pg_depend.classId or pg_shdepend.classId. Keep object_classes[] in sync.
+ * pg_depend.classId or pg_shdepend.classId.
*/
typedef enum ObjectClass
{
@@ -130,8 +130,6 @@ typedef enum ObjectClass
OCLASS_TRANSFORM, /* pg_transform */
} ObjectClass;
-#define LAST_OCLASS OCLASS_TRANSFORM
-
/* flag bits for performDeletion/performMultipleDeletions: */
#define PERFORM_DELETION_INTERNAL 0x0001 /* internal action */
#define PERFORM_DELETION_CONCURRENTLY 0x0002 /* concurrent drop */