public void push(Program program) throws XATransactionException { this.evaluator.close(); program.reset(this.getContext().getConnectionId()); program.setTrappingExceptions( program.getExceptionGroup() != null || (!this.programs.isEmpty() && this.programs.peek().isTrappingExceptions())); TempTableStore tts = getTempTableStore(); getContext().setTempTableStore(program.getTempTableStore()); program.getTempTableStore().setParentTempTableStore(tts); this.programs.push(program); VariableContext context = new VariableContext(true); context.setParentContext(this.currentVarContext); this.currentVarContext = context; VariableContext cc = new VariableContext(true); cc.setParentContext(this.cursorStates); this.cursorStates = cc; if (program.isAtomic() && this.blockContext == null) { TransactionContext tc = this.getContext().getTransactionContext(); if (tc != null && tc.getTransactionType() == Scope.NONE) { // start a transaction this.getContext().getTransactionServer().begin(tc); this.blockContext = tc; program.setStartedTxn(true); } } }
/** * @param success * @throws TeiidComponentException * @throws XATransactionException */ public void pop(boolean success) throws TeiidComponentException { this.evaluator.close(); Program program = this.programs.pop(); VariableContext vc = this.currentVarContext; VariableContext cs = this.cursorStates; try { this.currentVarContext = this.currentVarContext.getParentContext(); this.cursorStates = this.cursorStates.getParentContext(); TempTableStore tempTableStore = program.getTempTableStore(); this.getContext().setTempTableStore(tempTableStore.getParentTempTableStore()); tempTableStore.removeTempTables(); if (program.startedTxn()) { TransactionService ts = this.getContext().getTransactionServer(); TransactionContext tc = this.blockContext; this.blockContext = null; try { ts.resume(tc); for (WeakReference<DataTierTupleSource> ref : txnTupleSources) { DataTierTupleSource dtts = ref.get(); if (dtts != null) { dtts.fullyCloseSource(); } } this.txnTupleSources.clear(); if (success) { ts.commit(tc); } else { ts.rollback(tc); } } catch (XATransactionException e) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30165, e); } } } finally { removeAllCursors(cs); } }