Skip to content

Instantly share code, notes, and snippets.

@danielgustafsson
Created May 6, 2016 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielgustafsson/955c64ed84f5ab6fb5698664097c6b0c to your computer and use it in GitHub Desktop.
Save danielgustafsson/955c64ed84f5ab6fb5698664097c6b0c to your computer and use it in GitHub Desktop.
diff --git a/src/backend/access/appendonly/aosegfiles.c b/src/backend/access/appendonly/aosegfiles.c
index b03661b..d67b069 100644
--- a/src/backend/access/appendonly/aosegfiles.c
+++ b/src/backend/access/appendonly/aosegfiles.c
@@ -1985,7 +1985,7 @@ aorow_compression_ratio_internal(Relation parentrel)
int ret;
float8 compress_ratio = -1; /* the default, meaning "not available" */
- MemoryContext oldcontext = CurrentMemoryContext;
+ MemoryContext oldcontext;
Oid segrelid = InvalidOid;
GetAppendOnlyEntryAuxOids(RelationGetRelid(parentrel), SnapshotNow,
@@ -2046,7 +2046,7 @@ aorow_compression_ratio_internal(Relation parentrel)
val_eof_uncomp = SPI_getvalue(tuple, tupdesc, 2);
/* use our own context so that SPI won't free our stuff later */
- cxt_save = MemoryContextSwitchTo(oldcontext);
+ oldcontext = MemoryContextSwitchTo(cxt_save);
/*
* Calculate the compression ratio. but do it only if the uncomp
@@ -2079,8 +2079,7 @@ aorow_compression_ratio_internal(Relation parentrel)
}
}
- MemoryContextSwitchTo(cxt_save);
-
+ MemoryContextSwitchTo(oldcontext);
}
connected = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment