Author: shawkins
Date: 2010-08-23 20:25:18 -0400 (Mon, 23 Aug 2010)
New Revision: 2486
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
Log:
TEIID-1221 fix for reexecution of uncorrelated scalar subqueries.
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2010-08-23
19:19:45 UTC (rev 2485)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2010-08-24
00:25:18 UTC (rev 2486)
@@ -56,6 +56,7 @@
private TupleSource tupleSource;
private boolean isUpdate = false;
private boolean returnedRows = false;
+ private Command nextCommand;
public AccessNode(int nodeID) {
super(nodeID);
@@ -66,6 +67,7 @@
tupleSource = null;
isUpdate = false;
returnedRows = false;
+ nextCommand = null;
}
public void setCommand(Command command) {
@@ -95,8 +97,9 @@
Command atomicCommand = command;
boolean needProcessing = true;
if(shouldEvaluate) {
- atomicCommand = (Command) command.clone();
+ atomicCommand = nextCommand();
needProcessing = prepareNextCommand(atomicCommand);
+ nextCommand = null;
} else {
needProcessing = RelationalNodeUtil.shouldExecute(atomicCommand, true);
}
@@ -111,6 +114,15 @@
}
}
+ private Command nextCommand() {
+ //it's important to save the next command
+ //to ensure that the subquery ids remain stable
+ if (nextCommand == null) {
+ nextCommand = (Command) command.clone();
+ }
+ return nextCommand;
+ }
+
protected boolean prepareNextCommand(Command atomicCommand) throws
TeiidComponentException, TeiidProcessingException {
return prepareCommand(atomicCommand, getEvaluator(Collections.emptyMap()),
this.getContext(), this.getContext().getMetadata());
}
@@ -155,11 +167,13 @@
if (processCommandsIndividually() && hasPendingRows()) {
return pullBatch();
}
- Command atomicCommand = (Command)command.clone();
+ Command atomicCommand = nextCommand();
if (prepareNextCommand(atomicCommand)) {
+ nextCommand = null;
registerRequest(atomicCommand);
break;
}
+ nextCommand = null;
}
}
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-08-23
19:19:45 UTC (rev 2485)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-08-24
00:25:18 UTC (rev 2486)
@@ -42,6 +42,7 @@
import org.junit.Test;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.TupleBuffer;
@@ -249,9 +250,18 @@
TupleBuffer id = null;
try {
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr,
dataManager);
- processor.setNonBlocking(true);
+ //processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
- id = collector.collectTuples();
+ for (int i = 0; i < 100; i++) {
+ try {
+ id = collector.collectTuples();
+ } catch (BlockedException e) {
+
+ }
+ }
+ if (id == null) {
+ fail("did not complete processing");
+ }
if ( expectedResults != null ) {
examineResults(expectedResults, bufferMgr, id);
}
@@ -7518,7 +7528,7 @@
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT MAX(g_0.e1) FROM pm1.g1 AS g_0", new List[]
{Arrays.asList("c")});
hdm.addData("SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 <
'c'", new List[] {Arrays.asList("a")});
-
+ hdm.setBlockOnce(true);
List[] expected = new List[] {
Arrays.asList("a"),
};
Show replies by date