Skip to content

Commit 31c1136

Browse files
committed
Fix parallel query crashes by adding NULL check for exec_state_call_stack in plsql_TriggerRecursiveCheck
In parallel workers, the exec_state_call_stack global variable is NULL because parallel workers don't have the PL/tsql execution context. When the plsql_TriggerRecursiveCheck hook is called from parallel workers during query execution, it would crash trying to dereference the NULL pointer. This fix adds a NULL check to plsql_TriggerRecursiveCheck() in hooks.c that returns false (not a recursive trigger) if exec_state_call_stack is NULL. This is the safe default behavior.
1 parent f580b8d commit 31c1136

File tree

1 file changed

+3
-0
lines changed
  • contrib/babelfishpg_tsql/src

1 file changed

+3
-0
lines changed

contrib/babelfishpg_tsql/src/hooks.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,9 @@ plsql_TriggerRecursiveCheck(ResultRelInfo *resultRelInfo)
16821682
return false;
16831683
if (pltsql_recursive_triggers)
16841684
return false;
1685+
/* Safety check for parallel workers where exec_state_call_stack may be NULL */
1686+
if (exec_state_call_stack == NULL)
1687+
return false;
16851688
cur = exec_state_call_stack;
16861689
while (cur != NULL)
16871690
{

0 commit comments

Comments
 (0)