Skip to content

Commit

Permalink
TEIID-3127 changing the scope of closing the evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 12, 2014
1 parent e9316f2 commit 9657d4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Expand Up @@ -209,12 +209,16 @@ public void open() throws TeiidProcessingException, TeiidComponentException {
Expression expr = entry.getValue();

VariableContext context = getCurrentVariableContext();
if (context.getVariableMap().containsKey(param)) {
continue;
}
Object value = this.evaluateExpression(expr);

//check constraint
checkNotNull(param, value);
setParameterValue(param, context, value);
}
this.evaluator.close();
} else if (runInContext) {
//if there are no params, this needs to run in the current variable context
this.currentVarContext.setParentContext(parentContext);
Expand Down Expand Up @@ -373,6 +377,7 @@ private TupleSource processProcedure()
} else {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "Executing instruction", inst); //$NON-NLS-1$
inst.process(this);
this.evaluator.close();
}
} catch (RuntimeException e) {
throw e;
Expand Down Expand Up @@ -649,6 +654,7 @@ public void executePlan(ProcessorPlan command, String rsName, Map<ElementSymbol,
* @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;
Expand Down Expand Up @@ -691,6 +697,7 @@ private void removeAllCursors(VariableContext cs) {
}

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();
Expand Down Expand Up @@ -813,16 +820,12 @@ public TempTableStore getTempTableStore() {

boolean evaluateCriteria(Criteria condition) throws BlockedException, TeiidProcessingException, TeiidComponentException {
evaluator.initialize(getContext(), getDataManager());
boolean result = evaluator.evaluate(condition, Collections.emptyList());
this.evaluator.close();
return result;
return evaluator.evaluate(condition, Collections.emptyList());
}

Object evaluateExpression(Expression expression) throws BlockedException, TeiidProcessingException, TeiidComponentException {
evaluator.initialize(getContext(), getDataManager());
Object result = evaluator.evaluate(expression, Collections.emptyList());
this.evaluator.close();
return result;
return evaluator.evaluate(expression, Collections.emptyList());
}

public Program peek() {
Expand Down
Expand Up @@ -23,6 +23,7 @@
package org.teiid.query.processor.proc;

import static org.junit.Assert.*;
import static org.teiid.query.processor.TestProcessor.*;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -2268,6 +2269,16 @@ private QueryMetadataInterface createProcedureMetadata(String procedure) {
helpTestProcess(plan, new List[] {Arrays.asList(2)}, dataManager, tm);
}

@Test public void testSubqueryArguments() {
String sql = "select * from (EXEC pm1.sq3b((select min(e1) from pm1.g1), (select max(e2) from pm1.g1))) as x"; //$NON-NLS-1$

ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
FakeDataManager fdm = new FakeDataManager();
fdm.setBlockOnce();
sampleData1(fdm);
helpProcess(plan, fdm, new List[] {Arrays.asList("a", 0), Arrays.asList("a", 3), Arrays.asList("a", 0), Arrays.asList("a", 3)});
}

private static final boolean DEBUG = false;

}

0 comments on commit 9657d4f

Please sign in to comment.