Thue Janus Kristensen <thu...@gmail.com> writes:
> I finally succeeded in creating a test case, after much experimentation.
> Running the attached sql crashes my postgresql server 100% of the time.

Cute problem.  The attached fix cures it for me; would you see if it
solves your original case too?

                        regards, tom lane

Index: src/backend/commands/trigger.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/commands/trigger.c,v
retrieving revision 1.248.2.2
diff -c -r1.248.2.2 trigger.c
*** src/backend/commands/trigger.c	24 Jan 2010 21:49:31 -0000	1.248.2.2
--- src/backend/commands/trigger.c	19 Aug 2010 15:14:06 -0000
***************
*** 2534,2539 ****
--- 2534,2540 ----
  		else
  			events->tail->next = chunk;
  		events->tail = chunk;
+ 		/* events->tailfree is now out of sync, but we'll fix it below */
  	}
  
  	/*
***************
*** 2935,2940 ****
--- 2936,2950 ----
  		{
  			chunk->freeptr = CHUNK_DATA_START(chunk);
  			chunk->endfree = chunk->endptr;
+ 
+ 			/*
+ 			 * If it's last chunk, must sync event list's tailfree too.  Note
+ 			 * that delete_ok must NOT be passed as true if there could be
+ 			 * stacked AfterTriggerEventList values pointing at this event
+ 			 * list, since we'd fail to fix their copies of tailfree.
+ 			 */
+ 			if (chunk == events->tail)
+ 				events->tailfree = chunk->freeptr;
  		}
  	}
  
-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to