On Thu, Oct 23, 2014 at 1:57 PM, Tom Lane <[email protected]> wrote:
> Robert Haas <[email protected]> writes:
>> Perform less setup work for AFTER triggers at transaction start.
>
> Perhaps I'm confused, but doesn't AfterTriggerEnlargeQueryState()
> need to ensure there are at least query_depth + 1 entries in the
> arrays?  Not just query_depth?

Hmm, I think you're right.  Like this?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 1db0666..31a5411 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -4332,7 +4332,7 @@ AfterTriggerEnlargeQueryState(void)
 
 	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 *)
 			MemoryContextAlloc(TopTransactionContext,
@@ -4346,7 +4346,8 @@ AfterTriggerEnlargeQueryState(void)
 	{
 		/* repalloc will keep the stack in the same context */
 		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 *)
 			repalloc(afterTriggers.query_stack,
-- 
Sent via pgsql-committers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

Reply via email to