From 1aa495b8d2fd93a3a94b6b8a9eb0c1139cf2056c Mon Sep 17 00:00:00 2001 From: Deepakshi Mittal Date: Tue, 2 Jan 2024 16:14:05 +0000 Subject: [PATCH] Merged if condition into one Task: BABEL-2170 Signed-off-by: Deepakshi Mittal --- contrib/babelfishpg_tsql/src/hooks.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/contrib/babelfishpg_tsql/src/hooks.c b/contrib/babelfishpg_tsql/src/hooks.c index ed8674f3ad7..0506a5f6e95 100644 --- a/contrib/babelfishpg_tsql/src/hooks.c +++ b/contrib/babelfishpg_tsql/src/hooks.c @@ -745,21 +745,15 @@ pltsql_bbfViewHasInsteadofTrigger(Relation view, CmdType event) Oid current_tgoid = trigger->tgoid; Oid prev_tgoid = InvalidOid; prev_tgoid = lfirst_oid(list_tail(triggerInvocationSequence)); - if (list_length(triggerInvocationSequence) > 32) + if (prev_tgoid == current_tgoid) { - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)"))); - } - else if (prev_tgoid == current_tgoid) - { - return false; /** A trigger called recursively by itself*/ + return false; /** Loop trigger call by itself*/ } - else if (list_member_oid(triggerInvocationSequence, current_tgoid)) + else if (list_length(triggerInvocationSequence) > 32 || list_member_oid(triggerInvocationSequence, current_tgoid)) { - /** A trigger called recursively by another trigger */ + /** Loop trigger call by another trigger */ ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)"))); } }