mirror of https://github.com/citusdata/citus.git
Attempt to fix windows crash on intermediate_results
parent
71209054dc
commit
c271c2350e
|
@ -148,6 +148,7 @@ ReadFileIntoTupleStore(char *fileName, char *copyFormat, TupleDesc tupleDescript
|
|||
EState *executorState = CreateExecutorState();
|
||||
MemoryContext executorTupleContext = GetPerTupleMemoryContext(executorState);
|
||||
ExprContext *executorExpressionContext = GetPerTupleExprContext(executorState);
|
||||
MemoryContext oldContext = NULL;
|
||||
|
||||
int columnCount = tupleDescriptor->natts;
|
||||
Datum *columnValues = palloc0(columnCount * sizeof(Datum));
|
||||
|
@ -172,9 +173,10 @@ ReadFileIntoTupleStore(char *fileName, char *copyFormat, TupleDesc tupleDescript
|
|||
copyOptions);
|
||||
#endif
|
||||
|
||||
PG_TRY();
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
MemoryContext oldContext = NULL;
|
||||
bool nextRowFound = false;
|
||||
|
||||
ResetPerTupleExprContext(executorState);
|
||||
|
@ -191,6 +193,23 @@ ReadFileIntoTupleStore(char *fileName, char *copyFormat, TupleDesc tupleDescript
|
|||
tuplestore_putvalues(tupstore, tupleDescriptor, columnValues, columnNulls);
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
}
|
||||
}
|
||||
PG_CATCH();
|
||||
{
|
||||
/*
|
||||
* This is only necessary on windows, in the abort handler we might try to remove
|
||||
* the file being COPY'd (if it was an intermediate result), but on Windows that's
|
||||
* not possible unless we first close our handle to the file.
|
||||
*/
|
||||
if (oldContext != NULL)
|
||||
{
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
}
|
||||
|
||||
EndCopyFrom(copyState);
|
||||
PG_RE_THROW();
|
||||
}
|
||||
PG_END_TRY();
|
||||
|
||||
EndCopyFrom(copyState);
|
||||
pfree(columnValues);
|
||||
|
|
Loading…
Reference in New Issue