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/0915: 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)
131131int
132132lo_read (int fd ,char * buf ,int len )
133133{
134+ MemoryContext currentContext ;
135+ int status ;
136+
134137if (fd < 0 || fd >=MAX_LOBJ_FDS )
135138{
136139elog (ERROR ,"lo_read: large obj descriptor (%d) out of range" ,fd );
@@ -141,13 +144,20 @@ lo_read(int fd, char *buf, int len)
141144elog (ERROR ,"lo_read: invalid large obj descriptor (%d)" ,fd );
142145return -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
148155int
149156lo_write (int fd ,char * buf ,int len )
150157{
158+ MemoryContext currentContext ;
159+ int status ;
160+
151161if (fd < 0 || fd >=MAX_LOBJ_FDS )
152162{
153163elog (ERROR ,"lo_write: large obj descriptor (%d) out of range" ,fd );
@@ -158,8 +168,12 @@ lo_write(int fd, char *buf, int len)
158168elog (ERROR ,"lo_write: invalid large obj descriptor (%d)" ,fd );
159169return -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