Here's a better patch.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
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:44:51 -0000
*************** inv_open(Oid lobjId, int flags, MemoryCo
*** 247,254 ****
--- 247,258 ----
  	}
  	else if (flags & INV_READ)
  	{
+ 		ResourceOwner	save_resowner = CurrentResourceOwner;
+ 
+ 		CurrentResourceOwner = TopTransactionResourceOwner;
  		retval->snapshot = RegisterSnapshot(GetActiveSnapshot());
  		retval->flags = IFS_RDLOCK;
+ 		CurrentResourceOwner = save_resowner;
  	}
  	else
  		elog(ERROR, "invalid flags: %d", flags);
*************** void
*** 270,277 ****
--- 274,289 ----
  inv_close(LargeObjectDesc *obj_desc)
  {
  	Assert(PointerIsValid(obj_desc));
+ 
  	if (obj_desc->snapshot != SnapshotNow)
+ 	{
+ 		ResourceOwner	save_resowner = CurrentResourceOwner;
+ 
+ 		CurrentResourceOwner = TopTransactionResourceOwner;
  		UnregisterSnapshot(obj_desc->snapshot);
+ 		CurrentResourceOwner = save_resowner;
+ 	}
+ 
  	pfree(obj_desc);
  }
  
Index: src/test/regress/input/largeobject.source
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/test/regress/input/largeobject.source,v
retrieving revision 1.4
diff -c -p -r1.4 largeobject.source
*** src/test/regress/input/largeobject.source	3 Mar 2007 22:57:03 -0000	1.4
--- src/test/regress/input/largeobject.source	2 Dec 2008 14:27:26 -0000
*************** SELECT lo_close(fd) FROM lotest_stash_va
*** 83,88 ****
--- 83,93 ----
  
  END;
  
+ -- Test resource management
+ BEGIN;
+ SELECT lo_open(loid, x'40000'::int) from lotest_stash_values;
+ ABORT;
+ 
  -- Test truncation.
  BEGIN;
  UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
Index: src/test/regress/output/largeobject.source
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/test/regress/output/largeobject.source,v
retrieving revision 1.4
diff -c -p -r1.4 largeobject.source
*** src/test/regress/output/largeobject.source	3 Mar 2007 22:57:04 -0000	1.4
--- src/test/regress/output/largeobject.source	2 Dec 2008 14:42:34 -0000
*************** SELECT lo_close(fd) FROM lotest_stash_va
*** 116,121 ****
--- 116,130 ----
  (1 row)
  
  END;
+ -- Test resource management
+ BEGIN;
+ SELECT lo_open(loid, x'40000'::int) from lotest_stash_values;
+  lo_open 
+ ---------
+        0
+ (1 row)
+ 
+ ABORT;
  -- Test truncation.
  BEGIN;
  UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
Index: src/test/regress/output/largeobject_1.source
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/test/regress/output/largeobject_1.source,v
retrieving revision 1.1
diff -c -p -r1.1 largeobject_1.source
*** src/test/regress/output/largeobject_1.source	10 Mar 2007 03:42:19 -0000	1.1
--- src/test/regress/output/largeobject_1.source	2 Dec 2008 14:42:51 -0000
*************** SELECT lo_close(fd) FROM lotest_stash_va
*** 116,121 ****
--- 116,130 ----
  (1 row)
  
  END;
+ -- Test resource management
+ BEGIN;
+ SELECT lo_open(loid, x'40000'::int) from lotest_stash_values;
+  lo_open 
+ ---------
+        0
+ (1 row)
+ 
+ ABORT;
  -- Test truncation.
  BEGIN;
  UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
-- 
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