Patch to check whether we are in TX when to lo_*
Hello,
here is the patch attached which do check in each BLOB operation, if we are
in transaction, and raise an error otherwise. This will prevent such mistakes.
--
Sincerely Yours,
Denis Perchine
----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------
Index: inv_api.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v
retrieving revision 1.80
diff -u -r1.80 inv_api.c
--- inv_api.c 2000/11/02 23:52:06 1.80
+++ inv_api.c 2000/11/03 16:57:57
@@ -64,6 +64,9 @@
Oid file_oid;
LargeObjectDesc *retval;
+ if (!IsTransactionBlock())
+ elog(ERROR, "inv_create: Not in transaction. BLOBs should be used inside transaction.");
+
/*
* Allocate an OID to be the LO's identifier.
*/
@@ -117,6 +120,9 @@
{
LargeObjectDesc *retval;
+ if (!IsTransactionBlock())
+ elog(ERROR, "inv_open: Not in transaction. BLOBs should be used inside transaction.");
+
if (! LargeObjectExists(lobjId))
elog(ERROR, "inv_open: large object %u not found", lobjId);
@@ -145,6 +151,9 @@
void
inv_close(LargeObjectDesc *obj_desc)
{
+ if (!IsTransactionBlock())
+ elog(ERROR, "inv_close: Not in transaction. BLOBs should be used inside transaction.");
+
Assert(PointerIsValid(obj_desc));
if (obj_desc->flags & IFS_WRLOCK)
@@ -164,6 +173,9 @@
int
inv_drop(Oid lobjId)
{
+ if (!IsTransactionBlock())
+ elog(ERROR, "inv_drop: Not in transaction. BLOBs should be used inside transaction.");
+
LargeObjectDrop(lobjId);
/*
@@ -248,6 +260,9 @@
int
inv_seek(LargeObjectDesc *obj_desc, int offset, int whence)
{
+ if (!IsTransactionBlock())
+ elog(ERROR, "inv_seek: Not in transaction. BLOBs should be used inside transaction.");
+
Assert(PointerIsValid(obj_desc));
switch (whence)
@@ -280,6 +295,9 @@
int
inv_tell(LargeObjectDesc *obj_desc)
{
+ if (!IsTransactionBlock())
+ elog(ERROR, "inv_tell: Not in transaction. BLOBs should be used inside transaction.");
+
Assert(PointerIsValid(obj_desc));
return obj_desc->offset;
@@ -303,6 +321,9 @@
bytea *datafield;
bool pfreeit;
+ if (!IsTransactionBlock())
+ elog(ERROR, "inv_read: Not in transaction. BLOBs should be used inside transaction.");
+
Assert(PointerIsValid(obj_desc));
Assert(buf != NULL);
@@ -414,6 +435,9 @@
char replace[Natts_pg_largeobject];
bool write_indices;
Relation idescs[Num_pg_largeobject_indices];
+
+ if (!IsTransactionBlock())
+ elog(ERROR, "inv_write: Not in transaction. BLOBs should be used inside transaction.");
Assert(PointerIsValid(obj_desc));
Assert(buf != NULL);
Home |
Main Index |
Thread Index