Author: shawkins
Date: 2010-09-08 17:22:26 -0400 (Wed, 08 Sep 2010)
New Revision: 2553
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-1254 adding detection of session scoped temp tables for determinism
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-09-08
20:07:17 UTC (rev 2552)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-09-08
21:22:26 UTC (rev 2553)
@@ -135,13 +135,8 @@
//if prepared plan does not exist, create one
prepPlan = new PreparedPlan();
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query does not
exist in cache: ", sqlQuery}); //$NON-NLS-1$
- }
-
- ProcessorPlan cachedPlan = prepPlan.getPlan();
-
- if (cachedPlan == null) {
- super.generatePlan();
- if (!this.addedLimit) { //TODO: this is a little problematic
+ super.generatePlan();
+ if (!this.addedLimit) { //TODO: this is a little problematic
prepPlan.setCommand(this.userCommand);
// Defect 13751: Clone the plan in its current state (i.e. before processing)
so that it can be used for later queries
prepPlan.setPlan(processPlan.clone());
@@ -149,15 +144,17 @@
this.prepPlanCache.put(id, this.context.getDeterminismLevel(), prepPlan,
userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
}
} else {
+ ProcessorPlan cachedPlan = prepPlan.getPlan();
+ this.userCommand = prepPlan.getCommand();
+ validateAccess(userCommand);
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in
cache: ", sqlQuery }); //$NON-NLS-1$
processPlan = cachedPlan.clone();
//already in cache. obtain the values from cache
analysisRecord = prepPlan.getAnalysisRecord();
- this.userCommand = prepPlan.getCommand();
createCommandContext();
}
-
+
if (requestMsg.isBatchedUpdate()) {
handlePreparedBatchUpdate();
} else {
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-09-08
20:07:17 UTC (rev 2552)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-09-08
21:22:26 UTC (rev 2553)
@@ -24,6 +24,7 @@
import java.sql.Connection;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.Properties;
import java.util.Set;
@@ -59,6 +60,7 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.eval.SecurityFunctionEvaluator;
+import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempCapabilitiesFinder;
import org.teiid.query.metadata.TempMetadataAdapter;
@@ -81,7 +83,9 @@
import org.teiid.query.sql.lang.SetQuery;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
import org.teiid.query.tempdata.TempTableStore;
import org.teiid.query.util.CommandContext;
@@ -380,15 +384,24 @@
List<Reference> references =
ReferenceCollectorVisitor.getReferences(command);
- //there should be no reference (?) for query/update executed as statement
checkReferences(references);
this.analysisRecord = new AnalysisRecord(requestMsg.getShowPlan() !=
ShowPlan.OFF, requestMsg.getShowPlan() == ShowPlan.DEBUG);
resolveCommand(command);
+ validateAccess(userCommand);
+
createCommandContext();
-
+
+ Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command,
true);
+ for (GroupSymbol groupSymbol : groups) {
+ if (groupSymbol.isTempTable()) {
+ this.context.setDeterminismLevel(FunctionMethod.SESSION_DETERMINISTIC);
+ break;
+ }
+ }
+
validateQuery(command);
command = QueryRewriter.rewrite(command, metadata, context);
@@ -448,8 +461,6 @@
postProcessXML();
- validateAccess(userCommand);
-
createProcessor();
}
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-09-08
20:07:17 UTC (rev 2552)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-09-08
21:22:26 UTC (rev 2553)
@@ -409,7 +409,6 @@
try {
String fullName = metadata.getFullName(group.getMetadataID());
//TODO: order by primary key nulls first - then have an insert ordered optimization
- //TODO: use the getCommand logic in RelationalPlanner to reuse commands for this.
String transformation = metadata.getVirtualPlan(group.getMetadataID()).getQuery();
QueryProcessor qp =
context.getQueryProcessorFactory().createQueryProcessor(transformation, fullName,
context);
qp.setNonBlocking(true);
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-09-08
20:07:17 UTC (rev 2552)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-09-08
21:22:26 UTC (rev 2553)
@@ -36,6 +36,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
@@ -57,6 +58,7 @@
CommandContext cc = TestProcessor.createCommandContext();
cc.setTempTableStore(tempStore);
TestProcessor.doProcess(processorPlan, dataManager, expectedResults, cc);
+ assertTrue(cc.getDeterminismLevel() <= FunctionMethod.SESSION_DETERMINISTIC);
}
@Before public void setUp() {
Show replies by date