*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.74 2004/08/29 05:06:43 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.75 2004/09/11 15:56:46 tgl Exp $
*
* NOTES
* This should be moved to a more appropriate place. It is here
static MemoryContext fscxt = NULL;
+#define CreateFSContext() \
+ do { \
+ if (fscxt == NULL) \
+ fscxt = AllocSetContextCreate(TopMemoryContext, \
+ "Filesystem", \
+ ALLOCSET_DEFAULT_MINSIZE, \
+ ALLOCSET_DEFAULT_INITSIZE, \
+ ALLOCSET_DEFAULT_MAXSIZE); \
+ } while (0)
+
static int newLOfd(LargeObjectDesc *lobjCookie);
static void deleteLOfd(int fd);
elog(DEBUG4, "lo_open(%u,%d)", lobjId, mode);
#endif
- if (fscxt == NULL)
- fscxt = AllocSetContextCreate(TopMemoryContext,
- "Filesystem",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ CreateFSContext();
currentContext = MemoryContextSwitchTo(fscxt);
MemoryContext currentContext;
Oid lobjId;
- if (fscxt == NULL)
- fscxt = AllocSetContextCreate(TopMemoryContext,
- "Filesystem",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ CreateFSContext();
currentContext = MemoryContextSwitchTo(fscxt);
errhint("Anyone can use the client-side lo_import() provided by libpq.")));
#endif
+ /*
+ * We don't actually need to switch into fscxt, but create it anyway
+ * to ensure that AtEOXact_LargeObject knows there is state to clean up
+ */
+ CreateFSContext();
+
/*
* open the file to be read in
*/
errhint("Anyone can use the client-side lo_export() provided by libpq.")));
#endif
+ /*
+ * We don't actually need to switch into fscxt, but create it anyway
+ * to ensure that AtEOXact_LargeObject knows there is state to clean up
+ */
+ CreateFSContext();
+
/*
* open the inversion object (no need to test for failure)
*/