Alvaro Herrera wrote:

> I think the solution is to have each large object have its own
> ResourceOwner, and store the snapshot in it.  Otherwise the snapshot is
> left in the calling query's resowner, which is not good.

Turns out to be overkill.  This patch solves the problem, by using the
transaction's resowner.  I'm now going to check if we need something
similar elsewhere.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Index: src/backend/storage/large_object/inv_api.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/storage/large_object/inv_api.c,v
retrieving revision 1.135
diff -c -p -r1.135 inv_api.c
*** src/backend/storage/large_object/inv_api.c	2 Nov 2008 01:45:28 -0000	1.135
--- src/backend/storage/large_object/inv_api.c	2 Dec 2008 14:09:34 -0000
*************** LargeObjectDesc *
*** 232,237 ****
--- 232,238 ----
  inv_open(Oid lobjId, int flags, MemoryContext mcxt)
  {
  	LargeObjectDesc *retval;
+ 	ResourceOwner	save_resowner;
  
  	retval = (LargeObjectDesc *) MemoryContextAlloc(mcxt,
  													sizeof(LargeObjectDesc));
*************** inv_open(Oid lobjId, int flags, MemoryCo
*** 240,245 ****
--- 241,249 ----
  	retval->subid = GetCurrentSubTransactionId();
  	retval->offset = 0;
  
+ 	save_resowner = CurrentResourceOwner;
+ 	CurrentResourceOwner = TopTransactionResourceOwner;
+ 
  	if (flags & INV_WRITE)
  	{
  		retval->snapshot = SnapshotNow;
*************** inv_open(Oid lobjId, int flags, MemoryCo
*** 259,264 ****
--- 263,270 ----
  				(errcode(ERRCODE_UNDEFINED_OBJECT),
  				 errmsg("large object %u does not exist", lobjId)));
  
+ 	CurrentResourceOwner = save_resowner;
+ 
  	return retval;
  }
  
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to