Skip to content

Commit 4e614f1

Browse files
committed
get_cloudsync_context must be allocated in a global context
1 parent 13367c1 commit 4e614f1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/postgresql/cloudsync_postgresql.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ static cloudsync_context *pg_cloudsync_context = NULL;
4848
static cloudsync_context *get_cloudsync_context(void) {
4949
if (pg_cloudsync_context == NULL) {
5050
// Create context - db_t is not used in PostgreSQL mode
51+
MemoryContext old = MemoryContextSwitchTo(TopMemoryContext);
5152
pg_cloudsync_context = cloudsync_context_create(NULL);
53+
MemoryContextSwitchTo(old);
5254
if (!pg_cloudsync_context) {
5355
ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("Not enough memory to create a database context")));
5456
}

0 commit comments

Comments
 (0)