Commit 85bb81de authored by Robert Haas's avatar Robert Haas

Fix off-by-one error in 2781b4be.

Spotted by Tom Lane.
parent 3c2aa0c6
...@@ -4332,7 +4332,7 @@ AfterTriggerEnlargeQueryState(void) ...@@ -4332,7 +4332,7 @@ AfterTriggerEnlargeQueryState(void)
if (afterTriggers.maxquerydepth == 0) if (afterTriggers.maxquerydepth == 0)
{ {
int new_alloc = Max(afterTriggers.query_depth, 8); int new_alloc = Max(afterTriggers.query_depth + 1, 8);
afterTriggers.query_stack = (AfterTriggerEventList *) afterTriggers.query_stack = (AfterTriggerEventList *)
MemoryContextAlloc(TopTransactionContext, MemoryContextAlloc(TopTransactionContext,
...@@ -4346,7 +4346,8 @@ AfterTriggerEnlargeQueryState(void) ...@@ -4346,7 +4346,8 @@ AfterTriggerEnlargeQueryState(void)
{ {
/* repalloc will keep the stack in the same context */ /* repalloc will keep the stack in the same context */
int old_alloc = afterTriggers.maxquerydepth; int old_alloc = afterTriggers.maxquerydepth;
int new_alloc = Max(afterTriggers.query_depth, old_alloc * 2); int new_alloc = Max(afterTriggers.query_depth + 1,
old_alloc * 2);
afterTriggers.query_stack = (AfterTriggerEventList *) afterTriggers.query_stack = (AfterTriggerEventList *)
repalloc(afterTriggers.query_stack, repalloc(afterTriggers.query_stack,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment