diff --git a/cstore_tableam.c b/cstore_tableam.c index 312e10981..0e630d653 100644 --- a/cstore_tableam.c +++ b/cstore_tableam.c @@ -58,7 +58,7 @@ CStoreTableAMGetOptions(void) static MemoryContext -GetCStoreMemoryContext(void) +GetCStoreMemoryContext() { if (CStoreContext == NULL) { @@ -69,6 +69,16 @@ GetCStoreMemoryContext(void) } +static void +ResetCStoreMemoryContext() +{ + if (CStoreContext != NULL) + { + MemoryContextReset(CStoreContext); + } +} + + static void cstore_init_write_state(Relation relation) { @@ -591,6 +601,7 @@ CStoreExecutorEnd(QueryDesc *queryDesc) { standard_ExecutorEnd(queryDesc); } + ResetCStoreMemoryContext(); }