From a1e05115834a413b024d2330287ba3be2eb561c8 Mon Sep 17 00:00:00 2001 From: Onur Tirtir Date: Fri, 8 Oct 2021 16:16:57 +0300 Subject: [PATCH 1/2] Remove get_relation_constraint_oid_compat --- .../distributed/commands/foreign_constraint.c | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/backend/distributed/commands/foreign_constraint.c b/src/backend/distributed/commands/foreign_constraint.c index a7e0ce6f8..67a3e4335 100644 --- a/src/backend/distributed/commands/foreign_constraint.c +++ b/src/backend/distributed/commands/foreign_constraint.c @@ -76,7 +76,6 @@ static void ForeignConstraintFindDistKeys(HeapTuple pgConstraintTuple, int *referencedAttrIndex); static List * GetForeignKeyIdsForColumn(char *columnName, Oid relationId, int searchForeignKeyColumnFlags); -static Oid get_relation_constraint_oid_compat(HeapTuple heapTuple); static List * GetForeignKeysWithLocalTables(Oid relationId); static bool IsTableTypeIncluded(Oid relationId, int flags); static void UpdateConstraintIsValid(Oid constraintId, bool isValid); @@ -600,9 +599,8 @@ GetForeignKeyIdsForColumn(char *columnName, Oid relationId, if (HeapTupleOfForeignConstraintIncludesColumn(heapTuple, relationId, pgConstraintKey, columnName)) { - Oid foreignKeyOid = get_relation_constraint_oid_compat(heapTuple); foreignKeyIdsColumnAppeared = lappend_oid(foreignKeyIdsColumnAppeared, - foreignKeyOid); + constraintForm->oid); } heapTuple = systable_getnext(scanDescriptor); @@ -701,26 +699,6 @@ GetForeignConstraintCommandsInternal(Oid relationId, int flags) } -/* - * get_relation_constraint_oid_compat returns OID of the constraint represented - * by the constraintForm, which is passed as an heapTuple. OID of the contraint - * is already stored in the constraintForm struct if major PostgreSQL version is - * 12. However, in the older versions, we should utilize HeapTupleGetOid to deduce - * that OID with no cost. - */ -static Oid -get_relation_constraint_oid_compat(HeapTuple heapTuple) -{ - Assert(heapTuple != NULL); - - - Form_pg_constraint constraintForm = (Form_pg_constraint) GETSTRUCT(heapTuple); - Oid constraintOid = constraintForm->oid; - - return constraintOid; -} - - /* * HasForeignKeyWithLocalTable returns true if relation has foreign key * relationship with a local table. @@ -1050,7 +1028,7 @@ GetForeignKeyOids(Oid relationId, int flags) continue; } - Oid constraintId = get_relation_constraint_oid_compat(heapTuple); + Oid constraintId = constraintForm->oid; bool isSelfReference = (constraintForm->conrelid == constraintForm->confrelid); if (excludeSelfReference && isSelfReference) From f7f4a930733d179bb9e7ce9e5fafb53254ccf9cd Mon Sep 17 00:00:00 2001 From: Onur Tirtir Date: Fri, 8 Oct 2021 16:17:56 +0300 Subject: [PATCH 2/2] Remove get_relation_trigger_oid_compat --- src/backend/distributed/commands/trigger.c | 23 +--------------------- src/include/distributed/commands.h | 1 - 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/backend/distributed/commands/trigger.c b/src/backend/distributed/commands/trigger.c index d4d08e753..8a1a9a6cc 100644 --- a/src/backend/distributed/commands/trigger.c +++ b/src/backend/distributed/commands/trigger.c @@ -162,8 +162,7 @@ GetExplicitTriggerIdList(Oid relationId) */ if (!triggerForm->tgisinternal) { - Oid triggerId = get_relation_trigger_oid_compat(heapTuple); - triggerIdList = lappend_oid(triggerIdList, triggerId); + triggerIdList = lappend_oid(triggerIdList, triggerForm->oid); } heapTuple = systable_getnext(scanDescriptor); @@ -176,26 +175,6 @@ GetExplicitTriggerIdList(Oid relationId) } -/* - * get_relation_trigger_oid_compat returns OID of the trigger represented - * by the constraintForm, which is passed as an heapTuple. OID of the - * trigger is already stored in the triggerForm struct if major PostgreSQL - * version is 12. However, in the older versions, we should utilize - * HeapTupleGetOid to deduce that OID with no cost. - */ -Oid -get_relation_trigger_oid_compat(HeapTuple heapTuple) -{ - Assert(HeapTupleIsValid(heapTuple)); - - - Form_pg_trigger triggerForm = (Form_pg_trigger) GETSTRUCT(heapTuple); - Oid triggerOid = triggerForm->oid; - - return triggerOid; -} - - /* * PostprocessCreateTriggerStmt is called after a CREATE TRIGGER command has * been executed by standard process utility. This function errors out for diff --git a/src/include/distributed/commands.h b/src/include/distributed/commands.h index 448eeeaf6..ba8ee6d31 100644 --- a/src/include/distributed/commands.h +++ b/src/include/distributed/commands.h @@ -478,7 +478,6 @@ extern void PostprocessVacuumStmt(VacuumStmt *vacuumStmt, const char *vacuumComm extern List * GetExplicitTriggerCommandList(Oid relationId); extern HeapTuple GetTriggerTupleById(Oid triggerId, bool missingOk); extern List * GetExplicitTriggerIdList(Oid relationId); -extern Oid get_relation_trigger_oid_compat(HeapTuple heapTuple); extern List * PostprocessCreateTriggerStmt(Node *node, const char *queryString); extern ObjectAddress CreateTriggerStmtObjectAddress(Node *node, bool missingOk); extern void CreateTriggerEventExtendNames(CreateTrigStmt *createTriggerStmt,