mirror of https://github.com/citusdata/citus.git
Fix ObjectClass declaration for PG17 since it was removed
Relevant PG commit:pull/7922/head89e5ef7e21
89e5ef7e21812916c9cf9fcf56e45f0f74034656 We had already provided a fix for this in the following commitda2624cee8
However, this solution wasn't enough for the commits on main. Specifically, we had issues with the following commit:1d55debb98
Problem: https://github.com/citusdata/citus/actions/runs/13806825532/attempts/1#summary-38619483894 This new solution is better anyway. We define exactly what was previously defined in PG<17.
parent
1d0bdbd749
commit
52bf7a1d03
|
@ -16,46 +16,329 @@
|
|||
#if PG_VERSION_NUM >= PG_VERSION_17
|
||||
|
||||
#include "catalog/pg_am.h"
|
||||
#include "catalog/pg_amop.h"
|
||||
#include "catalog/pg_amproc.h"
|
||||
#include "catalog/pg_attrdef.h"
|
||||
#include "catalog/pg_auth_members.h"
|
||||
#include "catalog/pg_authid.h"
|
||||
#include "catalog/pg_cast.h"
|
||||
#include "catalog/pg_class.h"
|
||||
#include "catalog/pg_collation.h"
|
||||
#include "catalog/pg_constraint.h"
|
||||
#include "catalog/pg_conversion.h"
|
||||
#include "catalog/pg_database.h"
|
||||
#include "catalog/pg_default_acl.h"
|
||||
#include "catalog/pg_depend.h"
|
||||
#include "catalog/pg_event_trigger.h"
|
||||
#include "catalog/pg_extension.h"
|
||||
#include "catalog/pg_foreign_data_wrapper.h"
|
||||
#include "catalog/pg_foreign_server.h"
|
||||
#include "catalog/pg_init_privs.h"
|
||||
#include "catalog/pg_language.h"
|
||||
#include "catalog/pg_largeobject.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "catalog/pg_opfamily.h"
|
||||
#include "catalog/pg_parameter_acl.h"
|
||||
#include "catalog/pg_policy.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_publication.h"
|
||||
#include "catalog/pg_publication_namespace.h"
|
||||
#include "catalog/pg_publication_rel.h"
|
||||
#include "catalog/pg_rewrite.h"
|
||||
#include "catalog/pg_statistic_ext.h"
|
||||
#include "catalog/pg_subscription.h"
|
||||
#include "catalog/pg_tablespace.h"
|
||||
#include "catalog/pg_transform.h"
|
||||
#include "catalog/pg_trigger.h"
|
||||
#include "catalog/pg_ts_config.h"
|
||||
#include "catalog/pg_ts_dict.h"
|
||||
#include "catalog/pg_ts_parser.h"
|
||||
#include "catalog/pg_ts_template.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "catalog/pg_user_mapping.h"
|
||||
|
||||
/*
|
||||
* This enum covers all system catalogs whose OIDs can appear in
|
||||
* pg_depend.classId or pg_shdepend.classId.
|
||||
*/
|
||||
typedef enum ObjectClass
|
||||
{
|
||||
OCLASS_CLASS, /* pg_class */
|
||||
OCLASS_PROC, /* pg_proc */
|
||||
OCLASS_TYPE, /* pg_type */
|
||||
OCLASS_CAST, /* pg_cast */
|
||||
OCLASS_COLLATION, /* pg_collation */
|
||||
OCLASS_CONSTRAINT, /* pg_constraint */
|
||||
OCLASS_CONVERSION, /* pg_conversion */
|
||||
OCLASS_DEFAULT, /* pg_attrdef */
|
||||
OCLASS_LANGUAGE, /* pg_language */
|
||||
OCLASS_LARGEOBJECT, /* pg_largeobject */
|
||||
OCLASS_OPERATOR, /* pg_operator */
|
||||
OCLASS_OPCLASS, /* pg_opclass */
|
||||
OCLASS_OPFAMILY, /* pg_opfamily */
|
||||
OCLASS_AM, /* pg_am */
|
||||
OCLASS_AMOP, /* pg_amop */
|
||||
OCLASS_AMPROC, /* pg_amproc */
|
||||
OCLASS_REWRITE, /* pg_rewrite */
|
||||
OCLASS_TRIGGER, /* pg_trigger */
|
||||
OCLASS_SCHEMA, /* pg_namespace */
|
||||
OCLASS_STATISTIC_EXT, /* pg_statistic_ext */
|
||||
OCLASS_TSPARSER, /* pg_ts_parser */
|
||||
OCLASS_TSDICT, /* pg_ts_dict */
|
||||
OCLASS_TSTEMPLATE, /* pg_ts_template */
|
||||
OCLASS_TSCONFIG, /* pg_ts_config */
|
||||
OCLASS_ROLE, /* pg_authid */
|
||||
OCLASS_ROLE_MEMBERSHIP, /* pg_auth_members */
|
||||
OCLASS_DATABASE, /* pg_database */
|
||||
OCLASS_TBLSPACE, /* pg_tablespace */
|
||||
OCLASS_FDW, /* pg_foreign_data_wrapper */
|
||||
OCLASS_FOREIGN_SERVER, /* pg_foreign_server */
|
||||
OCLASS_USER_MAPPING, /* pg_user_mapping */
|
||||
OCLASS_DEFACL, /* pg_default_acl */
|
||||
OCLASS_EXTENSION, /* pg_extension */
|
||||
OCLASS_EVENT_TRIGGER, /* pg_event_trigger */
|
||||
OCLASS_PARAMETER_ACL, /* pg_parameter_acl */
|
||||
OCLASS_POLICY, /* pg_policy */
|
||||
OCLASS_PUBLICATION, /* pg_publication */
|
||||
OCLASS_PUBLICATION_NAMESPACE, /* pg_publication_namespace */
|
||||
OCLASS_PUBLICATION_REL, /* pg_publication_rel */
|
||||
OCLASS_SUBSCRIPTION, /* pg_subscription */
|
||||
OCLASS_TRANSFORM, /* pg_transform */
|
||||
} ObjectClass;
|
||||
|
||||
#define LAST_OCLASS OCLASS_TRANSFORM
|
||||
|
||||
/*
|
||||
* Determine the class of a given object identified by objectAddress.
|
||||
*
|
||||
* We implement it as a function instead of an array because the OIDs aren't
|
||||
* consecutive.
|
||||
*/
|
||||
static inline ObjectClass
|
||||
getObjectClass(const ObjectAddress *object)
|
||||
{
|
||||
/* only pg_class entries can have nonzero objectSubId */
|
||||
if (object->classId != RelationRelationId &&
|
||||
object->objectSubId != 0)
|
||||
{
|
||||
elog(ERROR, "invalid non-zero objectSubId for object class %u",
|
||||
object->classId);
|
||||
}
|
||||
|
||||
switch (object->classId)
|
||||
{
|
||||
case RelationRelationId:
|
||||
{
|
||||
/* caller must check objectSubId */
|
||||
return OCLASS_CLASS;
|
||||
}
|
||||
|
||||
case ProcedureRelationId:
|
||||
{
|
||||
return OCLASS_PROC;
|
||||
}
|
||||
|
||||
case TypeRelationId:
|
||||
{
|
||||
return OCLASS_TYPE;
|
||||
}
|
||||
|
||||
case CastRelationId:
|
||||
{
|
||||
return OCLASS_CAST;
|
||||
}
|
||||
|
||||
case CollationRelationId:
|
||||
{
|
||||
return OCLASS_COLLATION;
|
||||
}
|
||||
|
||||
case ConstraintRelationId:
|
||||
{
|
||||
return OCLASS_CONSTRAINT;
|
||||
}
|
||||
|
||||
case ConversionRelationId:
|
||||
{
|
||||
return OCLASS_CONVERSION;
|
||||
}
|
||||
|
||||
case AttrDefaultRelationId:
|
||||
{
|
||||
return OCLASS_DEFAULT;
|
||||
}
|
||||
|
||||
case LanguageRelationId:
|
||||
{
|
||||
return OCLASS_LANGUAGE;
|
||||
}
|
||||
|
||||
case LargeObjectRelationId:
|
||||
{
|
||||
return OCLASS_LARGEOBJECT;
|
||||
}
|
||||
|
||||
case OperatorRelationId:
|
||||
{
|
||||
return OCLASS_OPERATOR;
|
||||
}
|
||||
|
||||
case OperatorClassRelationId:
|
||||
{
|
||||
return OCLASS_OPCLASS;
|
||||
}
|
||||
|
||||
case OperatorFamilyRelationId:
|
||||
{
|
||||
return OCLASS_OPFAMILY;
|
||||
}
|
||||
|
||||
case AccessMethodRelationId:
|
||||
{
|
||||
return OCLASS_AM;
|
||||
}
|
||||
|
||||
case AccessMethodOperatorRelationId:
|
||||
{
|
||||
return OCLASS_AMOP;
|
||||
}
|
||||
|
||||
case AccessMethodProcedureRelationId:
|
||||
{
|
||||
return OCLASS_AMPROC;
|
||||
}
|
||||
|
||||
case RewriteRelationId:
|
||||
{
|
||||
return OCLASS_REWRITE;
|
||||
}
|
||||
|
||||
case TriggerRelationId:
|
||||
{
|
||||
return OCLASS_TRIGGER;
|
||||
}
|
||||
|
||||
case NamespaceRelationId:
|
||||
{
|
||||
return OCLASS_SCHEMA;
|
||||
}
|
||||
|
||||
case StatisticExtRelationId:
|
||||
{
|
||||
return OCLASS_STATISTIC_EXT;
|
||||
}
|
||||
|
||||
case TSParserRelationId:
|
||||
{
|
||||
return OCLASS_TSPARSER;
|
||||
}
|
||||
|
||||
case TSDictionaryRelationId:
|
||||
{
|
||||
return OCLASS_TSDICT;
|
||||
}
|
||||
|
||||
case TSTemplateRelationId:
|
||||
{
|
||||
return OCLASS_TSTEMPLATE;
|
||||
}
|
||||
|
||||
case TSConfigRelationId:
|
||||
{
|
||||
return OCLASS_TSCONFIG;
|
||||
}
|
||||
|
||||
case AuthIdRelationId:
|
||||
{
|
||||
return OCLASS_ROLE;
|
||||
}
|
||||
|
||||
case AuthMemRelationId:
|
||||
{
|
||||
return OCLASS_ROLE_MEMBERSHIP;
|
||||
}
|
||||
|
||||
case DatabaseRelationId:
|
||||
{
|
||||
return OCLASS_DATABASE;
|
||||
}
|
||||
|
||||
case TableSpaceRelationId:
|
||||
{
|
||||
return OCLASS_TBLSPACE;
|
||||
}
|
||||
|
||||
case ForeignDataWrapperRelationId:
|
||||
{
|
||||
return OCLASS_FDW;
|
||||
}
|
||||
|
||||
case ForeignServerRelationId:
|
||||
{
|
||||
return OCLASS_FOREIGN_SERVER;
|
||||
}
|
||||
|
||||
case UserMappingRelationId:
|
||||
{
|
||||
return OCLASS_USER_MAPPING;
|
||||
}
|
||||
|
||||
case DefaultAclRelationId:
|
||||
{
|
||||
return OCLASS_DEFACL;
|
||||
}
|
||||
|
||||
case ExtensionRelationId:
|
||||
{
|
||||
return OCLASS_EXTENSION;
|
||||
}
|
||||
|
||||
case EventTriggerRelationId:
|
||||
{
|
||||
return OCLASS_EVENT_TRIGGER;
|
||||
}
|
||||
|
||||
case ParameterAclRelationId:
|
||||
{
|
||||
return OCLASS_PARAMETER_ACL;
|
||||
}
|
||||
|
||||
case PolicyRelationId:
|
||||
{
|
||||
return OCLASS_POLICY;
|
||||
}
|
||||
|
||||
case PublicationNamespaceRelationId:
|
||||
{
|
||||
return OCLASS_PUBLICATION_NAMESPACE;
|
||||
}
|
||||
|
||||
case PublicationRelationId:
|
||||
{
|
||||
return OCLASS_PUBLICATION;
|
||||
}
|
||||
|
||||
case PublicationRelRelationId:
|
||||
{
|
||||
return OCLASS_PUBLICATION_REL;
|
||||
}
|
||||
|
||||
case SubscriptionRelationId:
|
||||
{
|
||||
return OCLASS_SUBSCRIPTION;
|
||||
}
|
||||
|
||||
case TransformRelationId:
|
||||
return OCLASS_TRANSFORM;
|
||||
}
|
||||
|
||||
/* shouldn't get here */
|
||||
elog(ERROR, "unrecognized object class: %u", object->classId);
|
||||
return OCLASS_CLASS; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
typedef int ObjectClass;
|
||||
#define getObjectClass(a) a->classId
|
||||
#define LAST_OCLASS TransformRelationId
|
||||
#define OCLASS_ROLE AuthIdRelationId
|
||||
#define OCLASS_DATABASE DatabaseRelationId
|
||||
#define OCLASS_TBLSPACE TableSpaceRelationId
|
||||
#define OCLASS_PARAMETER_ACL ParameterAclRelationId
|
||||
#define OCLASS_ROLE_MEMBERSHIP AuthMemRelationId
|
||||
#define OCLASS_CLASS RelationRelationId
|
||||
#define OCLASS_COLLATION CollationRelationId
|
||||
#define OCLASS_CONSTRAINT ConstraintRelationId
|
||||
#define OCLASS_PROC ProcedureRelationId
|
||||
#define OCLASS_PUBLICATION PublicationRelationId
|
||||
#define OCLASS_SCHEMA NamespaceRelationId
|
||||
#define OCLASS_TSCONFIG TSConfigRelationId
|
||||
#define OCLASS_TSDICT TSDictionaryRelationId
|
||||
#define OCLASS_TYPE TypeRelationId
|
||||
#define OCLASS_EXTENSION ExtensionRelationId
|
||||
#define OCLASS_FOREIGN_SERVER ForeignServerRelationId
|
||||
#define OCLASS_AM AccessMethodRelationId
|
||||
#define OCLASS_TSTEMPLATE TSTemplateRelationId
|
||||
|
||||
#include "commands/tablecmds.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue