Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc655935

Browse files
committed
Hello,
here is the patch attached which do check in each BLOB operation, if we arein transaction, and raise an error otherwise. This will prevent such mistakes.--Sincerely Yours,Denis Perchine
1 parent023a48b commitc655935

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎src/backend/storage/large_object/inv_api.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.80 2000/11/02 23:52:06 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.81 2001/01/21 03:49:14 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -64,6 +64,9 @@ inv_create(int flags)
6464
Oidfile_oid;
6565
LargeObjectDesc*retval;
6666

67+
if (!IsTransactionBlock())
68+
elog(ERROR,"inv_create: Not in transaction. BLOBs should be used inside transaction.");
69+
6770
/*
6871
* Allocate an OID to be the LO's identifier.
6972
*/
@@ -117,6 +120,9 @@ inv_open(Oid lobjId, int flags)
117120
{
118121
LargeObjectDesc*retval;
119122

123+
if (!IsTransactionBlock())
124+
elog(ERROR,"inv_open: Not in transaction. BLOBs should be used inside transaction.");
125+
120126
if (!LargeObjectExists(lobjId))
121127
elog(ERROR,"inv_open: large object %u not found",lobjId);
122128

@@ -145,6 +151,9 @@ inv_open(Oid lobjId, int flags)
145151
void
146152
inv_close(LargeObjectDesc*obj_desc)
147153
{
154+
if (!IsTransactionBlock())
155+
elog(ERROR,"inv_close: Not in transaction. BLOBs should be used inside transaction.");
156+
148157
Assert(PointerIsValid(obj_desc));
149158

150159
if (obj_desc->flags&IFS_WRLOCK)
@@ -164,6 +173,9 @@ inv_close(LargeObjectDesc *obj_desc)
164173
int
165174
inv_drop(OidlobjId)
166175
{
176+
if (!IsTransactionBlock())
177+
elog(ERROR,"inv_drop: Not in transaction. BLOBs should be used inside transaction.");
178+
167179
LargeObjectDrop(lobjId);
168180

169181
/*
@@ -248,6 +260,9 @@ inv_getsize(LargeObjectDesc *obj_desc)
248260
int
249261
inv_seek(LargeObjectDesc*obj_desc,intoffset,intwhence)
250262
{
263+
if (!IsTransactionBlock())
264+
elog(ERROR,"inv_seek: Not in transaction. BLOBs should be used inside transaction.");
265+
251266
Assert(PointerIsValid(obj_desc));
252267

253268
switch (whence)
@@ -280,6 +295,9 @@ inv_seek(LargeObjectDesc *obj_desc, int offset, int whence)
280295
int
281296
inv_tell(LargeObjectDesc*obj_desc)
282297
{
298+
if (!IsTransactionBlock())
299+
elog(ERROR,"inv_tell: Not in transaction. BLOBs should be used inside transaction.");
300+
283301
Assert(PointerIsValid(obj_desc));
284302

285303
returnobj_desc->offset;
@@ -303,6 +321,9 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
303321
bytea*datafield;
304322
boolpfreeit;
305323

324+
if (!IsTransactionBlock())
325+
elog(ERROR,"inv_read: Not in transaction. BLOBs should be used inside transaction.");
326+
306327
Assert(PointerIsValid(obj_desc));
307328
Assert(buf!=NULL);
308329

@@ -415,6 +436,9 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
415436
boolwrite_indices;
416437
Relationidescs[Num_pg_largeobject_indices];
417438

439+
if (!IsTransactionBlock())
440+
elog(ERROR,"inv_write: Not in transaction. BLOBs should be used inside transaction.");
441+
418442
Assert(PointerIsValid(obj_desc));
419443
Assert(buf!=NULL);
420444

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp