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

Commit9835944

Browse files
committed
Ensure that pg_largeobject references opened by lo_import() or lo_export()
will be cleaned up at end of transaction, even when there is no other LOoperation in the transaction. Per bug report from Daniel Schuchardt.
1 parentb85faa8 commit9835944

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

‎src/backend/libpq/be-fsstubs.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.74 2004/08/29 05:06:43 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.75 2004/09/11 15:56:46 tgl Exp $
1212
*
1313
* NOTES
1414
* This should be moved to a more appropriate place. It is here
@@ -65,6 +65,16 @@ static intcookies_size = 0;
6565

6666
staticMemoryContextfscxt=NULL;
6767

68+
#defineCreateFSContext() \
69+
do { \
70+
if (fscxt == NULL) \
71+
fscxt = AllocSetContextCreate(TopMemoryContext, \
72+
"Filesystem", \
73+
ALLOCSET_DEFAULT_MINSIZE, \
74+
ALLOCSET_DEFAULT_INITSIZE, \
75+
ALLOCSET_DEFAULT_MAXSIZE); \
76+
} while (0)
77+
6878

6979
staticintnewLOfd(LargeObjectDesc*lobjCookie);
7080
staticvoiddeleteLOfd(intfd);
@@ -87,12 +97,7 @@ lo_open(PG_FUNCTION_ARGS)
8797
elog(DEBUG4,"lo_open(%u,%d)",lobjId,mode);
8898
#endif
8999

90-
if (fscxt==NULL)
91-
fscxt=AllocSetContextCreate(TopMemoryContext,
92-
"Filesystem",
93-
ALLOCSET_DEFAULT_MINSIZE,
94-
ALLOCSET_DEFAULT_INITSIZE,
95-
ALLOCSET_DEFAULT_MAXSIZE);
100+
CreateFSContext();
96101

97102
currentContext=MemoryContextSwitchTo(fscxt);
98103

@@ -236,12 +241,7 @@ lo_creat(PG_FUNCTION_ARGS)
236241
MemoryContextcurrentContext;
237242
OidlobjId;
238243

239-
if (fscxt==NULL)
240-
fscxt=AllocSetContextCreate(TopMemoryContext,
241-
"Filesystem",
242-
ALLOCSET_DEFAULT_MINSIZE,
243-
ALLOCSET_DEFAULT_INITSIZE,
244-
ALLOCSET_DEFAULT_MAXSIZE);
244+
CreateFSContext();
245245

246246
currentContext=MemoryContextSwitchTo(fscxt);
247247

@@ -379,6 +379,12 @@ lo_import(PG_FUNCTION_ARGS)
379379
errhint("Anyone can use the client-side lo_import() provided by libpq.")));
380380
#endif
381381

382+
/*
383+
* We don't actually need to switch into fscxt, but create it anyway
384+
* to ensure that AtEOXact_LargeObject knows there is state to clean up
385+
*/
386+
CreateFSContext();
387+
382388
/*
383389
* open the file to be read in
384390
*/
@@ -446,6 +452,12 @@ lo_export(PG_FUNCTION_ARGS)
446452
errhint("Anyone can use the client-side lo_export() provided by libpq.")));
447453
#endif
448454

455+
/*
456+
* We don't actually need to switch into fscxt, but create it anyway
457+
* to ensure that AtEOXact_LargeObject knows there is state to clean up
458+
*/
459+
CreateFSContext();
460+
449461
/*
450462
* open the inversion object (no need to test for failure)
451463
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp