teiid SVN: r1489 - in trunk/engine/src: main/java/com/metamatrix/query/optimizer/relational and 8 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-29 09:52:23 -0400 (Tue, 29 Sep 2009)
New Revision: 1489
Modified:
trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentAccessNode.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestAccessNode.java
Log:
TEIID-858 fix for dependentsetcriteria not being replaced
Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -317,7 +317,13 @@
valueIter = new CollectionValueIterator(((SetCriteria)criteria).getValues());
} else if (criteria instanceof DependentSetCriteria){
ContextReference ref = (ContextReference)criteria;
- HashSet<Object> values = getValues(getContext(criteria), ref);
+ ValueIteratorSource vis = (ValueIteratorSource)getContext(criteria).getVariableContext().getGlobalValue(ref.getContextSymbol());
+ HashSet<Object> values;
+ try {
+ values = vis.getCachedSet(ref.getValueExpression());
+ } catch (MetaMatrixProcessingException e) {
+ throw new CriteriaEvaluationException(e, e.getMessage());
+ }
if (values != null) {
return values.contains(leftValue);
}
@@ -362,19 +368,6 @@
return Boolean.valueOf(criteria.isNegated());
}
- public static HashSet<Object> getValues(CommandContext context,
- ContextReference ref) throws MetaMatrixComponentException,
- CriteriaEvaluationException {
- ValueIteratorSource vis = (ValueIteratorSource)context.getVariableContext().getGlobalValue(ref.getContextSymbol());
- HashSet<Object> values;
- try {
- values = vis.getCachedSet(ref.getValueExpression());
- } catch (MetaMatrixProcessingException e) {
- throw new CriteriaEvaluationException(e, e.getMessage());
- }
- return values;
- }
-
public boolean evaluate(IsNullCriteria criteria, List tuple)
throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -82,7 +82,6 @@
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
public class PlanToProcessConverter {
@@ -90,14 +89,12 @@
private IDGenerator idGenerator;
private AnalysisRecord analysisRecord;
private CapabilitiesFinder capFinder;
- private CommandContext context;
- public PlanToProcessConverter(QueryMetadataInterface metadata, IDGenerator idGenerator, AnalysisRecord analysisRecord, CapabilitiesFinder capFinder, CommandContext context) {
+ public PlanToProcessConverter(QueryMetadataInterface metadata, IDGenerator idGenerator, AnalysisRecord analysisRecord, CapabilitiesFinder capFinder) {
this.metadata = metadata;
this.idGenerator = idGenerator;
this.analysisRecord = analysisRecord;
this.capFinder = capFinder;
- this.context = context;
}
public RelationalPlan convert(PlanNode planNode)
@@ -275,16 +272,9 @@
//create dependent access node
DependentAccessNode depAccessNode = new DependentAccessNode(getID());
- int maxSetSize = -1;
if(modelID != null){
- try {
- // set the max set size for the access node
- maxSetSize = CapabilitiesUtil.getMaxInCriteriaSize(modelID, metadata, capFinder);
- }catch(QueryMetadataException e) {
- throw new QueryPlannerException(e, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0006, modelID));
- }
+ depAccessNode.setMaxSetSize(CapabilitiesUtil.getMaxInCriteriaSize(modelID, metadata, capFinder));
}
- depAccessNode.setMaxSetSize(maxSetSize);
processNode = depAccessNode;
aNode = depAccessNode;
}
@@ -298,8 +288,7 @@
//-- special handling for temp tables. currently they cannot perform projection
try {
if (command instanceof Query) {
- processNode = correctProjectionForTempTable(node,
- aNode);
+ processNode = correctProjectionForTempTable(node, aNode);
}
} catch (QueryMetadataException err) {
throw new MetaMatrixComponentException(err);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -53,7 +53,6 @@
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.CorrelatedReferenceCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ErrorMessageKeys;
@@ -146,7 +145,7 @@
planToProcessConverter = context.getPlanToProcessConverter();
}
if (planToProcessConverter == null) {
- planToProcessConverter = new PlanToProcessConverter(metadata, idGenerator, analysisRecord, capFinder, context);
+ planToProcessConverter = new PlanToProcessConverter(metadata, idGenerator, analysisRecord, capFinder);
}
RelationalPlan result = planToProcessConverter.convert(plan);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -282,8 +282,9 @@
}
satisfyAccessPatterns(critNode, currentNode);
-
- if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)) {
+
+ if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)
+ && CapabilitiesUtil.getMaxInCriteriaSize(RuleRaiseAccess.getModelIDFromAccess(currentNode, metadata), metadata, capFinder) > 0) {
//once a dependent crit node is pushed, don't bother pushing it further into the command
//dependent access node will use this as an assumption for where dependent sets can appear in the command
critNode.setProperty(NodeConstants.Info.IS_PUSHED, Boolean.TRUE);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentAccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentAccessNode.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentAccessNode.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -114,10 +114,6 @@
Query query = (Query)atomicCommand;
- if (query.getCriteria() == null || maxSetSize < 1) {
- return super.prepareNextCommand(atomicCommand);
- }
-
if (this.criteriaProcessor == null) {
this.criteriaProcessor = new DependentCriteriaProcessor(this.maxSetSize, this, query.getCriteria());
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -69,6 +69,7 @@
import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.relational.DependentValueSource;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
@@ -144,6 +145,7 @@
import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
+import com.metamatrix.query.sql.util.ValueIterator;
import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
import com.metamatrix.query.sql.visitor.CriteriaTranslatorVisitor;
import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
@@ -1085,11 +1087,36 @@
}
rewriteSubqueryContainer((SubqueryContainer)criteria, true);
} else if (criteria instanceof DependentSetCriteria) {
- criteria = rewriteCriteria((AbstractSetCriteria)criteria);
+ criteria = rewriteDependentSetCriteria((DependentSetCriteria)criteria);
}
return evaluateCriteria(criteria);
}
+
+ private Criteria rewriteDependentSetCriteria(DependentSetCriteria dsc)
+ throws QueryValidatorException {
+ if (dataMgr == null) {
+ return rewriteCriteria(dsc);
+ }
+ SetCriteria setCrit = new SetCriteria();
+ setCrit.setExpression(dsc.getExpression());
+ HashSet<Object> values = new HashSet<Object>();
+ try {
+ DependentValueSource dvs = (DependentValueSource)this.context.getVariableContext().getGlobalValue(dsc.getContextSymbol());
+ ValueIterator iter = dvs.getValueIterator(dsc.getValueExpression());
+ while (iter.hasNext()) {
+ values.add(iter.next());
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ List<Constant> constants = new ArrayList<Constant>(values.size());
+ for (Object value : values) {
+ constants.add(new Constant(value, setCrit.getExpression().getType()));
+ }
+ setCrit.setValues(constants);
+ return rewriteCriteria(setCrit);
+ }
/**
* Performs simple expression flattening
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -34,7 +34,6 @@
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.symbol.SelectSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -133,7 +133,7 @@
}
public void visit(DependentSetCriteria obj) {
- evaluationNotPossible(EvaluationLevel.PUSH_DOWN);
+ evaluationNotPossible(EvaluationLevel.PROCESSING);
}
public void visit(ExistsCriteria obj) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -59,7 +59,7 @@
IDGenerator idGenerator, AnalysisRecord analysisRecord,
CapabilitiesFinder capFinder, Set<String> multiSourceModels,
String vdbName, VDBService vdbService, String vdbVersion, CommandContext context) {
- super(metadata, idGenerator, analysisRecord, capFinder, context);
+ super(metadata, idGenerator, analysisRecord, capFinder);
this.multiSourceModels = multiSourceModels;
this.vdbName = vdbName;
this.vdbService = vdbService;
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -25,6 +25,10 @@
import java.util.Arrays;
import java.util.List;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
@@ -498,9 +502,24 @@
}
public void testCase5130a() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ HardcodedDataManager dataManager = helpTestDependentJoin(false);
+
+ assertFalse(dataManager.getCommandHistory().contains("SELECT a.stringkey, a.intkey FROM bqt2.smalla AS a WHERE (concat(a.stringkey, 't') IN ('1t', '2')) AND (a.intkey IN (1))")); //$NON-NLS-1$
+ }
+
+ public void testUnlimitedIn() throws Exception {
+ helpTestDependentJoin(true);
+ }
+
+ private HardcodedDataManager helpTestDependentJoin(boolean unlimitIn)
+ throws QueryParserException, QueryResolverException,
+ QueryValidatorException, MetaMatrixComponentException {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ if (unlimitIn) {
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, -1);
+ }
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
@@ -511,8 +530,8 @@
new String[] {"SELECT g_0.stringkey, g_0.intkey FROM bqt1.smalla AS g_0 WHERE g_0.intkey IN (<dependent values>)", "SELECT g_0.stringkey, g_0.intkey FROM bqt2.smallb AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
+ unlimitIn?2:1, // Access
+ unlimitIn?0:1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
@@ -540,9 +559,8 @@
};
TestProcessor.helpProcess(plan, dataManager, expected);
-
- assertFalse(dataManager.getCommandHistory().contains("SELECT a.stringkey, a.intkey FROM bqt2.smalla AS a WHERE (concat(a.stringkey, 't') IN ('1t', '2')) AND (a.intkey IN (1))")); //$NON-NLS-1$
- }
+ return dataManager;
+ }
static void sampleData4(FakeDataManager dataMgr) throws Exception {
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestAccessNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestAccessNode.java 2009-09-28 21:11:23 UTC (rev 1488)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestAccessNode.java 2009-09-29 13:52:23 UTC (rev 1489)
@@ -22,15 +22,15 @@
package com.metamatrix.query.processor.relational;
+import java.util.Arrays;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.FakeDataManager;
+import com.metamatrix.query.processor.TestProcessor;
import com.metamatrix.query.resolver.TestResolver;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.CompoundCriteria;
@@ -57,14 +57,18 @@
CommandContext context = new CommandContext();
context.setProcessorID("processorID"); //$NON-NLS-1$
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
- FakePDM dataManager = new FakePDM(expectedCommand);
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
node.initialize(context, bm, dataManager);
node.setShouldEvaluateExpressions(true);
// Call open()
node.open();
-
- assertEquals(shouldRegisterRequest, dataManager.registerRequestCalled);
+ if (shouldRegisterRequest) {
+ assertEquals(Arrays.asList(expectedCommand), dataManager.getQueries());
+ } else {
+ assertEquals(0, dataManager.getQueries().size());
+ }
}
public void testOpen_Defect16059() throws Exception {
@@ -91,31 +95,14 @@
CommandContext context = new CommandContext();
context.setProcessorID("processorID"); //$NON-NLS-1$
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
- FakePDM dataManager = new FakePDM("SELECT e1, e2 FROM pm1.g1 WHERE e2 = 5"); //$NON-NLS-1$
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
node.initialize(context, bm, dataManager);
// Call open()
node.open();
- assertTrue(dataManager.registerRequestCalled);
+ assertEquals(Arrays.asList("SELECT e1, e2 FROM pm1.g1 WHERE e2 = 5"), dataManager.getQueries()); //$NON-NLS-1$
}
- private final static class FakePDM implements ProcessorDataManager {
- private String expectedCommand;
- private boolean registerRequestCalled = false;
- private FakePDM(String command) {
- this.expectedCommand = command;
- }
- public Object lookupCodeValue(CommandContext context,String codeTableName,String returnElementName,String keyElementName,Object keyValue) throws BlockedException,MetaMatrixComponentException {return null;}
- public TupleSource registerRequest(Object processorID,Command command,String modelName,String connectorBindingId, int nodeID) throws MetaMatrixComponentException {
- registerRequestCalled = true;
- assertEquals(expectedCommand, command.toString());
- return null;
- }
- @Override
- public void clearCodeTables() {
-
- }
- }
-
public void testShouldExecuteUpdate() throws Exception {
Update update = new Update();
16 years, 6 months
teiid SVN: r1488 - trunk/engine/src/main/java/com/metamatrix/query/processor/proc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-28 17:11:23 -0400 (Mon, 28 Sep 2009)
New Revision: 1488
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
Log:
TEIID-849 fix for resolving subqueries in stored procedure parameters and for using the appropriate context information.
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-28 21:07:51 UTC (rev 1487)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-28 21:11:23 UTC (rev 1488)
@@ -83,6 +83,7 @@
// State initialized by processor
private ProcessorDataManager dataMgr;
+ private ProcessorDataManager parentDataMrg;
private BufferManager bufferMgr;
private int batchSize;
@@ -139,6 +140,7 @@
this.batchSize = bufferMgr.getProcessorBatchSize();
setContext(context);
this.dataMgr = dataMgr;
+ this.parentDataMrg = dataMgr;
if (evaluator == null) {
this.evaluator = new SubqueryAwareEvaluator(Collections.emptyMap(), getDataManager(), getContext(), this.bufferMgr);
}
@@ -318,6 +320,7 @@
this.evaluator.close();
}
this.tempTableStore = null;
+ this.dataMgr = parentDataMrg;
}
public String toString() {
16 years, 6 months
teiid SVN: r1487 - in trunk: connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal and 10 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-28 17:07:51 -0400 (Mon, 28 Sep 2009)
New Revision: 1487
Removed:
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeProcessorDataManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java
Log:
TEIID-849 fix for resolving subqueries in stored procedure parameters and for using the appropriate context information.
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -42,7 +42,7 @@
return new Character(' ');
}
- return new Character( s.charAt(0) );
+ return Character.valueOf(s.charAt(0));
}
/**
Deleted: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeProcessorDataManager.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeProcessorDataManager.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeProcessorDataManager.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.metadata.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.processor.FakeTupleSource;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- */
-public class FakeProcessorDataManager implements ProcessorDataManager {
- private Command command;
-
- public Command getCommand(){
- return command;
- }
- /**
- *
- */
- public FakeProcessorDataManager() {
- super();
- }
-
- /*
- * @see com.metamatrix.query.processor.ProcessorDataManager#registerRequest(java.lang.Object, com.metamatrix.query.sql.lang.Command, java.lang.String, int)
- */
- public TupleSource registerRequest(Object processorID, Command command, String modelName, String connectorBindingId, int nodeID)
- throws MetaMatrixComponentException {
- this.command = command;
- return new FakeTupleSource(new ArrayList(), new List[0]);
- }
-
- /*
- * @see com.metamatrix.query.processor.ProcessorDataManager#lookupCodeValue(com.metamatrix.query.util.CommandContext, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
- */
- public Object lookupCodeValue(
- CommandContext context,
- String codeTableName,
- String returnElementName,
- String keyElementName,
- Object keyValue)
- throws BlockedException, MetaMatrixComponentException {
- return null;
- }
-
- @Override
- public void clearCodeTables() {
-
- }
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -103,8 +103,9 @@
this.elements = elements;
}
- public void setContext(CommandContext context) {
+ public void initialize(CommandContext context, ProcessorDataManager dataMgr) {
this.context = context;
+ this.dataMgr = dataMgr;
}
public boolean evaluate(Criteria criteria, List tuple)
@@ -316,13 +317,7 @@
valueIter = new CollectionValueIterator(((SetCriteria)criteria).getValues());
} else if (criteria instanceof DependentSetCriteria){
ContextReference ref = (ContextReference)criteria;
- ValueIteratorSource vis = (ValueIteratorSource)getContext(criteria).getVariableContext().getGlobalValue(ref.getContextSymbol());
- HashSet<Object> values;
- try {
- values = vis.getCachedSet(ref.getValueExpression());
- } catch (MetaMatrixProcessingException e) {
- throw new CriteriaEvaluationException(e, e.getMessage());
- }
+ HashSet<Object> values = getValues(getContext(criteria), ref);
if (values != null) {
return values.contains(leftValue);
}
@@ -367,6 +362,19 @@
return Boolean.valueOf(criteria.isNegated());
}
+ public static HashSet<Object> getValues(CommandContext context,
+ ContextReference ref) throws MetaMatrixComponentException,
+ CriteriaEvaluationException {
+ ValueIteratorSource vis = (ValueIteratorSource)context.getVariableContext().getGlobalValue(ref.getContextSymbol());
+ HashSet<Object> values;
+ try {
+ values = vis.getCachedSet(ref.getValueExpression());
+ } catch (MetaMatrixProcessingException e) {
+ throw new CriteriaEvaluationException(e, e.getMessage());
+ }
+ return values;
+ }
+
public boolean evaluate(IsNullCriteria criteria, List tuple)
throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
Modified: trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -43,13 +43,13 @@
public class TempMetadataStore implements Serializable {
// UPPER CASE TEMP GROUP NAME --> TempMetadataID for group
- private Map tempGroups;
+ private Map<String, TempMetadataID> tempGroups;
/**
* Constructor for TempMetadataStore.
*/
public TempMetadataStore() {
- this(new HashMap());
+ this(new HashMap<String, TempMetadataID>());
}
/**
@@ -57,9 +57,9 @@
* the parameter is null, a new empty Map will beused instead.
* @param data Map of upper case group name to group TempMetadataID object
*/
- public TempMetadataStore(Map data) {
+ public TempMetadataStore(Map<String, TempMetadataID> data) {
if (data == null) {
- tempGroups = new HashMap();
+ tempGroups = new HashMap<String, TempMetadataID>();
} else {
tempGroups = data;
}
@@ -164,7 +164,7 @@
public TempMetadataID addElementSymbolToTempGroup(String tempGroup, SingleElementSymbol symbol) {
String tempName = tempGroup.toUpperCase();
- TempMetadataID groupID = (TempMetadataID)this.tempGroups.get(tempName);
+ TempMetadataID groupID = this.tempGroups.get(tempName);
if (groupID != null) {
TempMetadataID elementID = createElementSymbol(tempName, symbol, false);
@@ -198,7 +198,7 @@
* @return Metadata ID or null if not found
*/
public TempMetadataID getTempGroupID(String tempGroup) {
- return (TempMetadataID) tempGroups.get(tempGroup.toUpperCase());
+ return tempGroups.get(tempGroup.toUpperCase());
}
/**
@@ -213,7 +213,7 @@
}
String groupName = tempElement.substring(0, index);
- TempMetadataID groupID = (TempMetadataID) tempGroups.get(groupName.toUpperCase());
+ TempMetadataID groupID = tempGroups.get(groupName.toUpperCase());
if(groupID != null) {
Iterator elementIter = groupID.getElements().iterator();
while(elementIter.hasNext()) {
@@ -234,7 +234,7 @@
* @return Metadata ID or null if not found
*/
public List getTempElementElementIDs(String tempGroup) {
- TempMetadataID groupID = (TempMetadataID) tempGroups.get(tempGroup.toUpperCase());
+ TempMetadataID groupID = tempGroups.get(tempGroup.toUpperCase());
if(groupID != null) {
return groupID.getElements();
}
@@ -243,14 +243,14 @@
}
public void addElementToTempGroup(String tempGroup, ElementSymbol symbol) {
- TempMetadataID groupID = (TempMetadataID) tempGroups.get(tempGroup.toUpperCase());
+ TempMetadataID groupID = tempGroups.get(tempGroup.toUpperCase());
if(groupID != null) {
groupID.addElement((TempMetadataID)symbol.getMetadataID());
}
}
- public void removeTempGroup(String tempGroup) {
- tempGroups.remove(tempGroup.toUpperCase());
+ public TempMetadataID removeTempGroup(String tempGroup) {
+ return tempGroups.remove(tempGroup.toUpperCase());
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -137,9 +137,8 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
this.bufferMgr = bufferMgr;
this.batchSize = bufferMgr.getProcessorBatchSize();
- tempTableStore = new TempTableStoreImpl(bufferMgr, context.getConnectionID(), (TempTableStore)context.getTempTableStore());
- this.dataMgr = new TempTableDataManager(dataMgr, tempTableStore);
setContext(context);
+ this.dataMgr = dataMgr;
if (evaluator == null) {
this.evaluator = new SubqueryAwareEvaluator(Collections.emptyMap(), getDataManager(), getContext(), this.bufferMgr);
}
@@ -199,6 +198,8 @@
context.setValue(entry.getKey(), value);
}
}
+ tempTableStore = new TempTableStoreImpl(bufferMgr, getContext().getConnectionID(), null);
+ this.dataMgr = new TempTableDataManager(dataMgr, tempTableStore);
}
this.evaluatedParams = true;
}
@@ -316,6 +317,7 @@
if (this.evaluator != null) {
this.evaluator.close();
}
+ this.tempTableStore = null;
}
public String toString() {
@@ -632,14 +634,14 @@
}
boolean evaluateCriteria(Criteria condition) throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
- evaluator.setContext(getContext());
+ evaluator.initialize(getContext(), getDataManager());
boolean result = evaluator.evaluate(condition, Collections.emptyList());
this.evaluator.close();
return result;
}
Object evaluateExpression(Expression expression) throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
- evaluator.setContext(getContext());
+ evaluator.initialize(getContext(), getDataManager());
Object result = evaluator.evaluate(expression, Collections.emptyList());
this.evaluator.close();
return result;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -17,7 +17,7 @@
if (this.evaluator == null) {
this.evaluator = new SubqueryAwareEvaluator(elementMap, getDataManager(), getContext(), getBufferManager());
} else {
- this.evaluator.setContext(getContext());
+ this.evaluator.initialize(getContext(), getDataManager());
}
return this.evaluator;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -23,6 +23,7 @@
package com.metamatrix.query.resolver.command;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -44,6 +45,7 @@
import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.ProcedureContainerResolver;
+import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.resolver.VariableResolver;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
@@ -52,10 +54,13 @@
import com.metamatrix.query.sql.lang.ProcedureContainer;
import com.metamatrix.query.sql.lang.SPParameter;
import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.visitor.CommandCollectorVisitor;
+import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import com.metamatrix.query.util.ErrorMessageKeys;
/**
@@ -284,6 +289,11 @@
SPParameter param = (SPParameter) paramIter.next();
Expression expr = param.getExpression();
if(expr != null) {
+ for (SubqueryContainer container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(expr)) {
+ QueryResolver.setChildMetadata(container.getCommand(), command);
+
+ QueryResolver.resolveCommand(container.getCommand(), Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis);
+ }
ResolverVisitor.resolveLanguageObject(expr, null, externalGroups, metadata);
Class paramType = param.getClassType();
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -91,6 +91,7 @@
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.tempdata.TempTableStoreImpl;
import com.metamatrix.server.serverapi.RequestInfo;
import com.metamatrix.vdb.runtime.VDBKey;
@@ -119,6 +120,36 @@
}
}
+ static class ClientState {
+ List<RequestID> requests;
+ TempTableStoreImpl tempTableStoreImpl;
+
+ public ClientState(TempTableStoreImpl tableStoreImpl) {
+ this.tempTableStoreImpl = tableStoreImpl;
+ }
+
+ public synchronized void addRequest(RequestID requestID) {
+ if (requests == null) {
+ requests = new LinkedList<RequestID>();
+ }
+ requests.add(requestID);
+ }
+
+ public synchronized List<RequestID> getRequests() {
+ if (requests == null) {
+ return Collections.emptyList();
+ }
+ return new ArrayList<RequestID>(requests);
+ }
+
+ public synchronized void removeRequest(RequestID requestID) {
+ if (requests != null) {
+ requests.remove(requestID);
+ }
+ }
+
+ }
+
//Constants
private static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
private static final int DEFAULT_MAX_CODE_TABLES = 200;
@@ -151,11 +182,10 @@
private int processorTimeslice = DEFAULT_PROCESSOR_TIMESLICE;
private boolean processorDebugAllowed;
- private TempTableStoresHolder tempTableStoresHolder;
private int chunkSize = 0;
- private Map<RequestID, RequestWorkItem> requests = Collections.synchronizedMap(new HashMap<RequestID, RequestWorkItem>());
- private Map<String, List<RequestID>> requestsByClients = Collections.synchronizedMap(new HashMap<String, List<RequestID>>());
+ private Map<RequestID, RequestWorkItem> requests = new ConcurrentHashMap<RequestID, RequestWorkItem>();
+ private Map<String, ClientState> clientState = Collections.synchronizedMap(new HashMap<String, ClientState>());
private DQPContextCache contextCache;
private ServiceLoader loader = new ServiceLoader();
@@ -179,27 +209,32 @@
* Return a list of {@link RequestInfo} for the given session
*/
public List<RequestInfo> getRequestsByClient(String clientConnection) {
- List<RequestID> ids = this.requestsByClients.get(clientConnection);
-
- return buildRequestInfos(ids);
+ ClientState state = getClientState(clientConnection, false);
+ if (state == null) {
+ return Collections.emptyList();
+ }
+ return buildRequestInfos(state.getRequests());
}
+
+ public ClientState getClientState(String key, boolean create) {
+ synchronized (clientState) {
+ ClientState state = clientState.get(key);
+ if (state == null && create) {
+ state = new ClientState(new TempTableStoreImpl(bufferManager, key, null));
+ clientState.put(key, state);
+ }
+ return state;
+ }
+ }
/**
* Return a list of all {@link RequestInfo}
*/
public List<RequestInfo> getRequests() {
- List<RequestID> copies = null;
- synchronized(requests) {
- copies = new ArrayList<RequestID>(requests.keySet());
- }
-
- return buildRequestInfos(copies);
+ return buildRequestInfos(requests.keySet());
}
- private List<RequestInfo> buildRequestInfos(List<RequestID> ids) {
- if(ids == null) {
- return Collections.emptyList();
- }
+ private List<RequestInfo> buildRequestInfos(Collection<RequestID> ids) {
List<RequestInfo> results = new ArrayList<RequestInfo>();
for (RequestID requestID : ids) {
RequestWorkItem holder = requests.get(requestID);
@@ -246,10 +281,10 @@
} else {
request = new Request();
}
+ ClientState state = this.getClientState(workContext.getConnectionID(), true);
request.initialize(requestMsg, getEnvironment(), bufferManager,
dataTierMgr, vdbCapabilties, transactionService,
- processorDebugAllowed, this.tempTableStoresHolder
- .getTempTableStore(workContext.getConnectionID()),
+ processorDebugAllowed, state.tempTableStoreImpl,
workContext, chunkSize);
RequestWorkItem workItem = null;
@@ -266,7 +301,7 @@
}
logMMCommand(workItem, true, false, 0); //TODO: there is no transaction at this point
- addRequest(requestID, workItem);
+ addRequest(requestID, workItem, state);
this.addWork(workItem);
return resultsFuture;
@@ -284,26 +319,17 @@
return resultsFuture;
}
- void addRequest(RequestID requestID, RequestWorkItem workItem) {
+ void addRequest(RequestID requestID, RequestWorkItem workItem, ClientState state) {
this.requests.put(requestID, workItem);
- synchronized (requestsByClients) {
- List<RequestID> clientRequests = this.requestsByClients.get(workItem.getDqpWorkContext().getConnectionID());
- if (clientRequests == null) {
- clientRequests = new LinkedList<RequestID>();
- this.requestsByClients.put(workItem.getDqpWorkContext().getConnectionID(), clientRequests);
- }
- clientRequests.add(requestID);
- }
+ state.addRequest(requestID);
}
void removeRequest(final RequestWorkItem workItem) {
this.requests.remove(workItem.requestID);
- synchronized (requestsByClients) {
- List<RequestID> clientRequests = this.requestsByClients.get(workItem.getDqpWorkContext().getConnectionID());
- if (clientRequests != null) {
- clientRequests.remove(workItem.requestID);
- }
- }
+ ClientState state = getClientState(workItem.getDqpWorkContext().getConnectionID(), false);
+ if (state != null) {
+ state.removeRequest(workItem.requestID);
+ }
contextCache.removeRequestScopedCache(workItem.requestID.toString());
}
@@ -414,12 +440,9 @@
// sometimes there will not be any atomic requests pending, in that
// situation we still need to clear the master request from our map
- List<RequestID> requestIds = requestsByClients.get(sessionId);
- if (requestIds != null) {
- synchronized (requestsByClients) {
- requestIds = new ArrayList<RequestID>(requestIds);
- }
- for (RequestID reqId : requestIds) {
+ ClientState state = getClientState(sessionId, false);
+ if (state != null) {
+ for (RequestID reqId : state.getRequests()) {
try {
cancelRequest(reqId);
} catch (MetaMatrixComponentException err) {
@@ -667,8 +690,6 @@
// Create the worker pools to tie the queues together
processWorkerPool = WorkerPoolFactory.newWorkerPool(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS));
- tempTableStoresHolder = new TempTableStoresHolder(bufferManager);
-
dataTierMgr = new DataTierManagerImpl(this,
(DataService) env.findService(DQPServiceNames.DATA_SERVICE),
(VDBService) env.findService(DQPServiceNames.VDB_SERVICE),
@@ -761,7 +782,7 @@
public MetadataResult getMetadata(long requestID)
throws MetaMatrixComponentException, MetaMatrixProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
+ MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment());
return processor.processMessage(workContext.getRequestID(requestID), workContext, null, true);
}
@@ -769,7 +790,7 @@
boolean allowDoubleQuotedVariable)
throws MetaMatrixComponentException, MetaMatrixProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
+ MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment());
return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
}
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -29,6 +29,7 @@
import java.util.List;
import java.util.Map;
+import org.teiid.dqp.internal.process.DQPCore.ClientState;
import org.teiid.dqp.internal.process.PreparedPlanCache.CacheID;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
@@ -80,17 +81,15 @@
private PreparedPlanCache planCache;
private ApplicationEnvironment env;
- private TempTableStoresHolder tempTableStoresHolder;
private String vdbName;
private String vdbVersion;
private RequestID requestID;
- public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, PreparedPlanCache planCache, ApplicationEnvironment env, TempTableStoresHolder tempTableStoresHolder) {
+ public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, PreparedPlanCache planCache, ApplicationEnvironment env) {
this.metadataService = metadataService;
this.requestManager = requestManager;
this.planCache = planCache;
this.env = env;
- this.tempTableStoresHolder = tempTableStoresHolder;
}
/**
@@ -128,9 +127,12 @@
}
TempTableStore tempTableStore = null;
- if(tempTableStoresHolder != null) {
+ if(requestManager != null) {
if (workItem != null) {
- tempTableStore = tempTableStoresHolder.getTempTableStore(workContext.getConnectionID());
+ ClientState state = requestManager.getClientState(workContext.getConnectionID(), false);
+ if (state != null) {
+ tempTableStore = state.tempTableStoreImpl;
+ }
}
}
if(tempTableStore != null) {
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.query.tempdata.TempTableStore;
-import com.metamatrix.query.tempdata.TempTableStoreImpl;
-
-
-/**
- * @since 5.5
- */
-public class TempTableStoresHolder {
- private BufferManager buffer;
- private Map tempTableStores = new HashMap();
-
- public TempTableStoresHolder(BufferManager buffer) {
- this.buffer = buffer;
- }
-
- public synchronized TempTableStore getTempTableStore(String sessionID) {
- TempTableStore tempTableStore = (TempTableStore)tempTableStores.get(sessionID);
- if(tempTableStore == null) {
- tempTableStore = new TempTableStoreImpl(buffer, sessionID, null);
- tempTableStores.put(sessionID, tempTableStore);
- }
- return tempTableStore;
- }
-}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -2690,7 +2690,7 @@
helpTestProcess(plan, expected, dataMgr);
}
- @Test public void testTempSubqueryInput() throws Exception {
+ @Test public void testUpdateDeleteTemp() throws Exception {
String proc = "CREATE VIRTUAL PROCEDURE " + //$NON-NLS-1$
"BEGIN " + //$NON-NLS-1$
" select e1, e2, e3, e4 into #t1 from pm1.g1;\n" + //$NON-NLS-1$
@@ -2710,5 +2710,24 @@
helpTestProcess(plan, expected, dataMgr);
}
+ @Test public void testTempSubqueryInput() throws Exception {
+ String proc = "CREATE VIRTUAL PROCEDURE " + //$NON-NLS-1$
+ "BEGIN " + //$NON-NLS-1$
+ " create local temporary table t1 (e1 string);\n" + //$NON-NLS-1$
+ " select e1 into t1 from pm1.g1;\n" + //$NON-NLS-1$
+ " select e2 from (exec pm1.sq2((select max(e1) from t1))) x;\n" + //$NON-NLS-1$
+ "END"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = createProcedureMetadata(proc);
+ String userQuery = "SELECT * FROM (EXEC pm1.sq1()) as proc"; //$NON-NLS-1$
+ FakeDataManager dataMgr = exampleDataManager2(metadata);
+ ProcessorPlan plan = getProcedurePlan(userQuery, metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList( 51 ),
+ };
+ helpTestProcess(plan, expected, dataMgr);
+ }
+
private static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -26,15 +26,10 @@
import java.util.HashSet;
import java.util.Set;
-import org.mockito.Mockito;
-import org.teiid.connector.xa.api.TransactionContext;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.process.DataTierTupleSource;
-import org.teiid.dqp.internal.process.RequestWorkItem;
-
import junit.framework.TestCase;
+import org.teiid.dqp.internal.process.DQPCore.ClientState;
+
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.dqp.exception.SourceWarning;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
@@ -91,7 +86,7 @@
private RequestID addRequest(DQPCore rm, String sessionId, int executionId) {
RequestMessage r0 = new RequestMessage("test command"); //$NON-NLS-1$
RequestID id = new RequestID(sessionId, executionId);
- addRequest(rm, r0, id, null, null); //$NON-NLS-1$
+ addRequest(rm, r0, id, null, null);
return id;
}
@@ -118,7 +113,7 @@
DQPCore rm = new DQPCore();
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null); //$NON-NLS-1$
+ RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
assertTrue(workItem.resultsCursor.resultsRequested);
}
@@ -127,7 +122,7 @@
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null); //$NON-NLS-1$
+ RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
workItem.addSourceFailureDetails(getSourceFailures("Model1", "Binding1", "Warning1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
workItem.addSourceFailureDetails(getSourceFailures("Model2", "Binding2", "Warning2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -148,7 +143,8 @@
}
RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id, workContext);
workItem.setOriginalCommand(originalCommand);
- rm.addRequest(id, workItem);
+ ClientState state = rm.getClientState(id.getConnectionID(), true);
+ rm.addRequest(id, workItem, state);
return workItem;
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -82,7 +82,7 @@
ApplicationEnvironment env = new ApplicationEnvironment();
FakeVDBService vdbService = new FakeVDBService();
env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env, null);
+ MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env);
return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();
}
@@ -151,7 +151,7 @@
// Initialize components
ApplicationEnvironment env = new ApplicationEnvironment();
env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env, null);
+ MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env);
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
@@ -195,7 +195,7 @@
while(iter.hasNext()) {
String type = (String) iter.next();
Class typeClass = DataTypeManager.getDataTypeClass(type);
- MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null);
Map columnMetadata = processor.getDefaultColumn("vdb", "1", "t", "c", typeClass); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
verifyColumn(columnMetadata, type);
}
Modified: trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -39,7 +39,6 @@
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.MetaMatrixAuthenticationException;
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.api.MMURL;
Modified: trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java
===================================================================
--- trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -42,7 +42,7 @@
}
public StaticMetadataProvider exampleProvider() throws Exception {
- MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null);
Map col1 = processor.getDefaultColumn("vdb", "1", "table", "col1", String.class); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Map col2 = processor.getDefaultColumn("vdb", "1", "table", "col2", Integer.class); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Modified: trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java
===================================================================
--- trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -44,7 +44,7 @@
}
private StaticMetadataProvider example1() throws Exception {
- MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null);
Map[] columnMetadata = new Map[] {
processor.getDefaultColumn("vdb", "1", "table", "c1", String.class), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
processor.getDefaultColumn("vdb", "1", "table", "c2", Integer.class) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
16 years, 6 months
teiid SVN: r1486 - trunk/test-integration/db/src/main/java/org/teiid/test/framework.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-28 13:09:14 -0400 (Mon, 28 Sep 2009)
New Revision: 1486
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
Log:
Teiid 773 - cleanup
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-28 17:06:00 UTC (rev 1485)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-28 17:09:14 UTC (rev 1486)
@@ -16,8 +16,8 @@
private boolean debug = false;
- protected Properties props;
- protected ConnectionStrategy connStrategy;
+ protected Properties props;
+ protected ConnectionStrategy connStrategy;
protected TransactionContainer(){
@@ -58,13 +58,13 @@
}
- private void runIt(TransactionQueryTest test) {
-
+ private void runIt(TransactionQueryTest test) {
detail("Start transaction test: " + test.getTestName());
-
+
try {
- setUp(test);
+ setUp(test);
+
debug(" setConnection");
test.setConnection(this.connStrategy.getConnection());
test.setExecutionProperties(this.props);
16 years, 6 months
teiid SVN: r1485 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: connection and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-28 13:06:00 -0400 (Mon, 28 Sep 2009)
New Revision: 1485
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
Log:
Teiid 773 - cleanup
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -1,14 +1,13 @@
package org.teiid.test.framework;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.Properties;
-import org.teiid.test.framework.connection.ConnectionStrategyFactory;
import org.teiid.test.util.PropUtils;
-public class ConfigPropertyLoader {
-
+
+public class ConfigPropertyLoader {
+
+
/**
* The default config file to use when #CONFIG_FILE system property isn't set
*/
@@ -29,6 +28,9 @@
}
public synchronized static Properties getProperties() {
+ if (props == null) {
+ loadConfigurationProperties();
+ }
return props;
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -4,9 +4,7 @@
*/
package org.teiid.test.framework;
-import java.sql.Connection;
import java.util.Properties;
-import java.util.Set;
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
@@ -14,8 +12,6 @@
import org.teiid.test.framework.exception.TransactionRuntimeException;
-
-
public abstract class TransactionContainer {
private boolean debug = false;
@@ -23,18 +19,18 @@
protected Properties props;
protected ConnectionStrategy connStrategy;
- protected TransactionContainer(ConnectionStrategy strategy){
- this.connStrategy = strategy;
- this.props = new Properties();
- this.props.putAll(this.connStrategy.getEnvironment());
-
+ protected TransactionContainer(){
}
- protected void setupData(TransactionQueryTest test) {
- test.setDataSources(connStrategy.getDataSources());
+ protected void setUp(TransactionQueryTest test) throws QueryTestFailedException {
+ this.connStrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
+ this.props = new Properties();
+ this.props.putAll(this.connStrategy.getEnvironment());
+
+ test.setDataSources(connStrategy.getDataSources());
test.setupDataSources();
-
+
}
protected void before(TransactionQueryTest test){}
@@ -43,22 +39,23 @@
public void runTransaction(TransactionQueryTest test) {
- try {
- try {
-
- runIt(test);
-
- } finally {
- debug(" test.cleanup");
+ try {
+
+ runIt(test);
+
+ } finally {
+ debug(" test.cleanup");
+
+ try {
+ test.cleanup();
+ } finally {
+ // cleanup all connections created for this test.
+ ConnectionStrategyFactory.destroyInstance();
+
+ }
+ }
- test.cleanup();
- }
-
- } finally {
- // cleanup all connections created for this test.
- ConnectionStrategyFactory.destroyInstance();
- }
}
private void runIt(TransactionQueryTest test) {
@@ -66,7 +63,7 @@
detail("Start transaction test: " + test.getTestName());
try {
- setupData(test);
+ setUp(test);
debug(" setConnection");
test.setConnection(this.connStrategy.getConnection());
@@ -98,8 +95,6 @@
e.printStackTrace();
}
throw new TransactionRuntimeException(e.getMessage());
- }finally {
-
}
if (test.exceptionExpected() && !test.exceptionOccurred()) {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -192,9 +192,9 @@
}
- public static void main(String[] args) {
- ConnectionStrategyFactory cf = ConnectionStrategyFactory.getInstance();
-
- }
+// public static void main(String[] args) {
+// ConnectionStrategyFactory cf = ConnectionStrategyFactory.getInstance();
+//
+// }
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -50,68 +50,5 @@
identifier, ds.getProperties()).getXAConnection();
}
-
-// public static final Connection getSource(String identifier)
-// throws QueryTestFailedException {
-// if (identifier != null) {
-// String mappedName = ConfigPropertyLoader.getProperty(identifier);
-//
-// if (mappedName == null) {
-// throw new TransactionRuntimeException("Identifier mapping "
-// + identifier
-// + " is not defined in the config properties file");
-// }
-//
-// Properties sourceProps;
-// try {
-// sourceProps = DataSourceMgr.getInstance()
-// .getDatasourceProperties(mappedName, identifier);
-// } catch (QueryTestFailedException e) {
-// throw new TransactionRuntimeException(e);
-// }
-//
-// if (sourceProps == null) {
-// throw new TransactionRuntimeException("Identifier "
-// + identifier + " mapped to " + mappedName
-// + " has no datasource properties");
-// }
-//
-// return ConnectionStrategyFactory.getInstance().createDriverStrategy(identifier,
-// sourceProps).getConnection();
-//
-// }
-// throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
-// }
-//
-// public static final XAConnection getXASource(String identifier)
-// throws QueryTestFailedException {
-// if (identifier != null) {
-// String mappedName = ConfigPropertyLoader.getProperty(identifier);
-//
-// if (mappedName == null) {
-// throw new TransactionRuntimeException("Identifier mapping "
-// + identifier
-// + " is not defined in the config properties file");
-// }
-//
-// Properties sourceProps;
-// try {
-// sourceProps = DataSourceMgr.getInstance()
-// .getDatasourceProperties(mappedName, identifier);
-// } catch (QueryTestFailedException e) {
-// throw new TransactionRuntimeException(e);
-// }
-//
-// if (sourceProps == null) {
-// throw new TransactionRuntimeException("Identifier "
-// + identifier + " mapped to " + mappedName
-// + " has no datasource properties");
-// }
-//
-// return ConnectionStrategyFactory.getInstance().createDataSourceStrategy(
-// identifier, sourceProps).getXAConnection();
-// }
-// throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
-// }
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -9,8 +9,8 @@
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -18,8 +18,8 @@
public class JNDITransaction extends TransactionContainer {
UserTransaction userTxn = null;
- public JNDITransaction(ConnectionStrategy strategy) {
- super(strategy);
+ public JNDITransaction() {
+ super();
}
protected void before(TransactionQueryTest test) {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -4,14 +4,11 @@
*/
package org.teiid.test.framework.transaction;
-import java.sql.Connection;
import java.sql.SQLException;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
-import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -20,8 +17,8 @@
*/
public class LocalTransaction extends TransactionContainer {
- public LocalTransaction(ConnectionStrategy strategy) {
- super(strategy);
+ public LocalTransaction() {
+ super();
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -28,24 +28,28 @@
ConfigPropertyLoader.loadConfigurationProperties();
- ConnectionStrategy connstrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
+ // ConnectionStrategy connstrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
+
+// Properties props = ConfigPropertyLoader.getProperties();
- String type = connstrategy.getEnvironment().getProperty(ConfigPropertyNames.TRANSACTION_TYPE, ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION);
+ String type = ConfigPropertyLoader.getProperty(ConfigPropertyNames.TRANSACTION_TYPE);
+ //connstrategy.getEnvironment().getProperty(ConfigPropertyNames.TRANSACTION_TYPE, ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION);
if (type == null) {
- throw new RuntimeException("Property " + ConfigPropertyNames.TRANSACTION_TYPE + " was specified");
+ type = ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION;
+// throw new RuntimeException("Property " + ConfigPropertyNames.TRANSACTION_TYPE + " was specified");
}
System.out.println("Create TransactionContainer: " + type);
if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
- transacton = new LocalTransaction(connstrategy);
+ transacton = new LocalTransaction();
}
else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.XATRANSACTION)) {
- transacton = new XATransaction(connstrategy);
+ transacton = new XATransaction();
}
else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.JNDI_TRANSACTION)) {
- transacton = new JNDITransaction(connstrategy);
+ transacton = new JNDITransaction();
} else {
throw new TransactionRuntimeException("Invalid property value of " + type + " for " + ConfigPropertyNames.TRANSACTION_TYPE );
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -11,7 +11,6 @@
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
-import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -21,8 +20,8 @@
private static Random RANDOM = new Random();
private MMXid xid;
- public XATransaction(ConnectionStrategy strategy) {
- super(strategy);
+ public XATransaction() {
+ super();
}
protected void before(TransactionQueryTest test) {
16 years, 6 months
teiid SVN: r1484 - trunk/test-integration/db/src/test/java/org/teiid/test/framework.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-28 13:03:37 -0400 (Mon, 28 Sep 2009)
New Revision: 1484
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
Log:
Teiid 773 - cleanup
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-28 17:01:51 UTC (rev 1483)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-28 17:03:37 UTC (rev 1484)
@@ -17,7 +17,6 @@
import javax.sql.XAConnection;
import org.teiid.test.framework.connection.ConnectionStrategy;
-import org.teiid.test.framework.connection.ConnectionStrategyFactory;
import org.teiid.test.framework.connection.ConnectionUtil;
import org.teiid.test.framework.datasource.DataSource;
import org.teiid.test.framework.datasource.DataSourceSetupFactory;
16 years, 6 months
teiid SVN: r1483 - trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-28 13:01:51 -0400 (Mon, 28 Sep 2009)
New Revision: 1483
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
Log:
Teiid 773 - cleanup
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-25 20:29:56 UTC (rev 1482)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-28 17:01:51 UTC (rev 1483)
@@ -32,16 +32,12 @@
// The connections will be closed at teardown
System.out.println("Run TwoSource Setup...");
-
- System.out.println("perform source pm1 set");
AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", ds));//$NON-NLS-1$
test1.execute("delete from g2"); //$NON-NLS-1$
test1.execute("delete from g1"); //$NON-NLS-1$
-
- System.out.println("removed old data");
-
+
test1.execute("select * from g1 ");
test1.assertRowCount(0);
test1.execute("select * from g2 ");
@@ -59,22 +55,18 @@
for (int i = 0; i < 100; i++) {
sql1[i] = "insert into g2 (e1, e2) values("+i+",'"+i+"')" ;
}
- System.out.println("add new data");
-
-
+
test1.executeBatch(sql1);
test1.execute("select * from g1 ");
test1.assertRowCount(100);
test1.execute("select * from g2 ");
test1.assertRowCount(100);
- System.out.println("perform source pm2 set...");
-
+
AbstractQueryTest test2 = new QueryExecution(ConnectionUtil.getConnection("pm2", ds));//$NON-NLS-1$
test2.execute("delete from g2"); //$NON-NLS-1$
test2.execute("delete from g1"); //$NON-NLS-1$
- System.out.println("removed old data");
test2.execute("select * from g1 ");
test2.assertRowCount(0);
@@ -93,10 +85,8 @@
for (int i = 0; i < 100; i++) {
sql2[i] = "insert into g2 (e1, e2) values("+i+",'"+i+"')" ;
}
+
- System.out.println("add new data");
-
-
test2.executeBatch(sql2);
test2.execute("select * from g1 ");
test2.assertRowCount(100);
16 years, 6 months
teiid SVN: r1482 - trunk/documentation/reference/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-25 16:29:56 -0400 (Fri, 25 Sep 2009)
New Revision: 1482
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
Log:
updating programlisting of getting the query plan
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2009-09-24 19:06:34 UTC (rev 1481)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2009-09-25 20:29:56 UTC (rev 1482)
@@ -405,8 +405,17 @@
</para>
<example>
<title>Retrieving a Query Plan</title>
- <programlisting>ResultSet rs = statement.executeQuery("select ...");
-com.metamatrix.jdbc.api.Statement mmstatement = (com.metamatrix.jdbc.api.Statement)statement;
+ <programlisting>com.metamatrix.jdbc.api.Statement mmstatement = (com.metamatrix.jdbc.api.Statement)statement;
+String sql = "select ...";
+
+mmstatement.setExecutionProperty(ExecutionProperties.PROP_SQL_OPTIONS, ExecutionProperties.SQL_OPTION_SHOWPLAN);
+//or
+//sql += " OPTION SHOWPLAN";
+//or
+//sql += " OPTION PLANONLY";
+
+ResultSet rs = statement.executeQuery(sql);
+
PlanNode queryPlan = mmstatement.getPlanDescription();
System.out.println(XMLOutputVisitor.convertToXML(queryPlan);</programlisting>
</example>
16 years, 6 months
teiid SVN: r1481 - in trunk/engine/src: test/java/com/metamatrix/query/rewriter and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-24 15:06:34 -0400 (Thu, 24 Sep 2009)
New Revision: 1481
Removed:
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionSymbolCollector.java
Modified:
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
Log:
removing expressionsymbolcollectorvisitor
Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionSymbolCollector.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionSymbolCollector.java 2009-09-24 15:21:27 UTC (rev 1480)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionSymbolCollector.java 2009-09-24 19:06:34 UTC (rev 1481)
@@ -1,100 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.sql.visitor;
-
-import java.util.Collection;
-
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-/**
- * <p>This visitor class will traverse a language object tree and collect all expression
- * element symbol references it finds. It uses a collection to collect the symbols in so
- * different collections will give you different collection properties - for instance,
- * using a Set will remove duplicates.</p>
- *
- * <p>The easiest way to use this visitor is to call the static methods which create
- * the visitor (and possibly the collection), run the visitor, and return the collection.
- * The public visit() methods should NOT be called directly.</p>
- */
-public class ExpressionSymbolCollector extends LanguageVisitor {
- private Collection symbols;
-
- /**
- * Construct a new visitor with the specified collection, which should
- * be non-null.
- * @param elements Collection to use for elements
- * @throws IllegalArgumentException If elements is null
- */
- public ExpressionSymbolCollector(Collection elements) {
- if(elements == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0021));
- }
- this.symbols = elements;
- }
-
- /**
- * Get the elements collected by the visitor. This should best be called
- * after the visitor has been run on the language object tree.
- * @return Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
- */
- public Collection getSymbols() {
- return this.symbols;
- }
-
- /**
- * Visit a language object and collect symbols. This method should <b>NOT</b> be
- * called directly.
- * @param obj Language object
- */
- public void visit(ExpressionSymbol obj) {
- this.symbols.add(obj);
- }
-
- /**
- * Visit a language object and collect symbols. This method should <b>NOT</b> be
- * called directly.
- * @param obj Language object
- */
- public void visit(AggregateSymbol obj) {
- this.symbols.add(obj);
- }
-
- /**
- * Helper to quickly get the elements from obj in the elements collection
- * @param obj Language object
- * @param elements Collection to collect elements in
- */
- public static final void getSymbols(LanguageObject obj, Collection elements) {
- if(obj == null) {
- return;
- }
- ExpressionSymbolCollector visitor = new ExpressionSymbolCollector(elements);
- PreOrderNavigator.doVisit(obj, visitor);
- }
-}
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2009-09-24 15:21:27 UTC (rev 1480)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2009-09-24 19:06:34 UTC (rev 1481)
@@ -38,10 +38,11 @@
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.ExpressionSymbol;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ExpressionSymbolCollector;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.unittest.FakeMetadataObject;
@@ -80,16 +81,17 @@
private void helpCheckExpressionsSymbols(OrderBy langObj,
String[] functionsNames) {
- List symbols = new ArrayList();
+ int expCount = 0;
for (Iterator i = langObj.getVariables().iterator(); i.hasNext();) {
- ExpressionSymbolCollector.getSymbols((LanguageObject)i.next(), symbols);
+ SingleElementSymbol ses = (SingleElementSymbol)i.next();
+ if (ses instanceof AliasSymbol) {
+ AliasSymbol aSymbol = (AliasSymbol)ses;
+ if (aSymbol.getSymbol() instanceof ExpressionSymbol) {
+ assertEquals("Expression Symbols does not match: ", functionsNames[expCount++], aSymbol.getSymbol().toString()); //$NON-NLS-1$
+ }
+ }
}
- assertEquals("Wrong number of Symbols: ", functionsNames.length, symbols.size()); //$NON-NLS-1$
-
- for (int i = 0; i < symbols.size(); i++) {
- ExpressionSymbol symbol = (ExpressionSymbol)symbols.get(i);
- assertEquals("Expression Symbols does not match: ", functionsNames[i], symbol.toString()); //$NON-NLS-1$
- }
+ assertEquals("Wrong number of Symbols: ", functionsNames.length, expCount); //$NON-NLS-1$
}
public void testNumberedOrderBy1() throws Exception {
16 years, 6 months
teiid SVN: r1480 - in trunk/test-integration/db/src/test/java/org/teiid/test: framework/datasource and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-24 11:21:27 -0400 (Thu, 24 Sep 2009)
New Revision: 1480
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
Log:
Teiid 773 - working on a hudson timeout issue, not seeing it locally
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-24 14:45:26 UTC (rev 1479)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-24 15:21:27 UTC (rev 1480)
@@ -174,13 +174,12 @@
/**
- * At end of each test, clean up the connection factory so that it can be
- * established at the start of the next test.
+ * At end of each test, perfrom any cleanup that your test requires.
+ * Note: Do not cleanup any connections. That is performed by
+ * the {@link TransactionContainer#runTransaction(TransactionQueryTest)} at the end of the test.
*/
public void cleanup() {
- ConnectionStrategyFactory.destroyInstance();
-
- // this.closeConnection();
+
}
@Override
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-24 14:45:26 UTC (rev 1479)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-24 15:21:27 UTC (rev 1480)
@@ -33,12 +33,9 @@
System.out.println("Run TwoSource Setup...");
- System.out.println("perform source pm1 set...");
+ System.out.println("perform source pm1 set");
AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", ds));//$NON-NLS-1$
-
-
- System.out.println("perform source pm1 set...");
test1.execute("delete from g2"); //$NON-NLS-1$
test1.execute("delete from g1"); //$NON-NLS-1$
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-09-24 14:45:26 UTC (rev 1479)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-09-24 15:21:27 UTC (rev 1480)
@@ -6,14 +6,9 @@
-import java.sql.Connection;
-
-import javax.sql.XAConnection;
-
import junit.framework.TestCase;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.connection.ConnectionUtil;
import org.teiid.test.framework.datasource.DataSourceMgr;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.transaction.TransactionFactory;
16 years, 6 months