From a29a6d2068d71e8a2c7938097028d6283a84951d Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Wed, 28 Oct 2009 12:57:23 +0000 Subject: [PATCH] geterrcode(): Switch memory context to work around Assert() in CopyErrorData() --- src/execute.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/execute.c b/src/execute.c index c62c285..f28114a 100644 --- a/src/execute.c +++ b/src/execute.c @@ -34,9 +34,12 @@ #if PG_VERSION_NUM < 80400 static int geterrcode(void) { + /* switch context to work around Assert() in CopyErrorData() */ + MemoryContext ctx = MemoryContextSwitchTo(TopMemoryContext); ErrorData *edata = CopyErrorData(); int code = edata->sqlerrcode; - FreeErrorData(edata); /* unnecessary? */ + FreeErrorData(edata); + MemoryContextSwitchTo(ctx); return code; } #endif -- 2.39.5