Skip to content

Commit

Permalink
Revert "Fix crash for indirect recursion"
Browse files Browse the repository at this point in the history
This reverts commit 4e1b87c.
  • Loading branch information
deepakshi-mittal committed Nov 22, 2023
1 parent 41efcba commit ad5f18c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
23 changes: 0 additions & 23 deletions src/backend/commands/trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -5446,29 +5446,6 @@ isTsqlInsteadofTriggerExecution(EState *estate, ResultRelInfo *relinfo, TriggerE
return false;
}

void checkRecursiveTriggerDepth(ResultRelInfo *relinfo)
{
if (triggerOids && relinfo->ri_TrigDesc)
{
TriggerDesc *trigdesc;
int i;
trigdesc = relinfo->ri_TrigDesc;
for (i = 0; i < trigdesc->numtriggers; i++)
{
Trigger *trigger = &trigdesc->triggers[i];
Oid current_tgoid = trigger->tgoid;
Oid prev_tgoid = lfirst_oid(list_tail(triggerOids));
if (prev_tgoid != current_tgoid && list_member_oid(triggerOids, current_tgoid))
{
/** Indirect recursive trigger case*/
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)")));
}
}
}
}

/* ----------
* AfterTriggerBeginXact()
*
Expand Down
8 changes: 0 additions & 8 deletions src/backend/executor/nodeModifyTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,6 @@ ExecInsert(ModifyTableContext *context,
if (resultRelInfo->ri_projectReturning)
result = ExecProcessReturning(resultRelInfo, slot, planSlot);

if (sql_dialect == SQL_DIALECT_TSQL)
checkRecursiveTriggerDepth(resultRelInfo);

/* INSTEAD OF ROW INSERT Triggers */
if (resultRelInfo->ri_TrigDesc &&
resultRelInfo->ri_TrigDesc->trig_insert_instead_row)
Expand Down Expand Up @@ -1480,8 +1477,6 @@ ExecDelete(ModifyTableContext *context,

ExecClearTuple(slot);
}
if (sql_dialect == SQL_DIALECT_TSQL)
checkRecursiveTriggerDepth(resultRelInfo);

if (resultRelInfo->ri_TrigDesc &&
resultRelInfo->ri_TrigDesc->trig_delete_instead_statement &&
Expand Down Expand Up @@ -2338,9 +2333,6 @@ ExecUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
if (resultRelInfo->ri_projectReturning && sql_dialect == SQL_DIALECT_TSQL)
rslot = ExecProcessReturning(resultRelInfo, slot, context->planSlot);

if (sql_dialect == SQL_DIALECT_TSQL)
checkRecursiveTriggerDepth(resultRelInfo);

if (resultRelInfo->ri_TrigDesc &&
resultRelInfo->ri_TrigDesc->trig_update_instead_statement &&
sql_dialect == SQL_DIALECT_TSQL &&
Expand Down
1 change: 0 additions & 1 deletion src/include/commands/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ extern void ExecASTruncateTriggers(EState *estate,
ResultRelInfo *relinfo);

extern bool isTsqlInsteadofTriggerExecution(EState *estate, ResultRelInfo *relinfo, TriggerEvent event);
extern void checkRecursiveTriggerDepth(ResultRelInfo *relinfo);

extern void AfterTriggerBeginXact(void);
extern void AfterTriggerBeginQuery(void);
Expand Down

0 comments on commit ad5f18c

Please sign in to comment.