Skip to content

Commit 6458daa

Browse files
committed
Running lo_read/lo_write under different memory context
cause troubles. See Message-Id: <199905090312.MAA00466@ext16.sra.co.jp> for more details.
1 parent 202e523 commit 6458daa

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/backend/libpq/be-fsstubs.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.30 1999/05/09 00:54:30 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.31 1999/05/09 15:00:18 ishii Exp $
1111
*
1212
* NOTES
1313
* This should be moved to a more appropriate place. It is here
@@ -131,6 +131,9 @@ lo_close(int fd)
131131
int
132132
lo_read(int fd, char *buf, int len)
133133
{
134+
MemoryContext currentContext;
135+
int status;
136+
134137
if (fd < 0 || fd >= MAX_LOBJ_FDS)
135138
{
136139
elog(ERROR, "lo_read: large obj descriptor (%d) out of range", fd);
@@ -141,13 +144,20 @@ lo_read(int fd, char *buf, int len)
141144
elog(ERROR, "lo_read: invalid large obj descriptor (%d)", fd);
142145
return -3;
143146
}
147+
currentContext = MemoryContextSwitchTo((MemoryContext) fscxt);
148+
149+
status = inv_read(cookies[fd], buf, len);
144150

145-
return inv_read(cookies[fd], buf, len);
151+
MemoryContextSwitchTo(currentContext);
152+
return(status);
146153
}
147154

148155
int
149156
lo_write(int fd, char *buf, int len)
150157
{
158+
MemoryContext currentContext;
159+
int status;
160+
151161
if (fd < 0 || fd >= MAX_LOBJ_FDS)
152162
{
153163
elog(ERROR, "lo_write: large obj descriptor (%d) out of range", fd);
@@ -158,8 +168,12 @@ lo_write(int fd, char *buf, int len)
158168
elog(ERROR, "lo_write: invalid large obj descriptor (%d)", fd);
159169
return -3;
160170
}
171+
currentContext = MemoryContextSwitchTo((MemoryContext) fscxt);
172+
173+
status = inv_write(cookies[fd], buf, len);
161174

162-
return inv_write(cookies[fd], buf, len);
175+
MemoryContextSwitchTo(currentContext);
176+
return(status);
163177
}
164178

165179

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy