[teiid-commits] teiid SVN: r1630 - in trunk: client/src/main/java/com/metamatrix/dqp/embedded and 59 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Dec 9 16:41:45 EST 2009


Author: shawkins
Date: 2009-12-09 16:41:41 -0500 (Wed, 09 Dec 2009)
New Revision: 1630

Added:
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
Removed:
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeNode.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeProcessor.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/OptimizerContext.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/GenerateCanonical.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/MergeTreeNodeProcessor.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SQLSource.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/XMLSource.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/CommandContainer.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCacheUtil.java
Modified:
   trunk/build/kit-runtime/deploy.properties
   trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
   trunk/connector-sdk/src/main/java/com/metamatrix/cdk/CommandBuilder.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/SizeUtility.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java
   trunk/engine/src/main/java/com/metamatrix/common/buffer/storage/file/FileStorageManager.java
   trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java
   trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/ResultSetInfo.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlaceAccess.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushNonJoinCriteria.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlannerEnvironment.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLStagaingQueryPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xquery/XQueryPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java
   trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/BatchedUpdateResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XMLQueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XQueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/GroupContext.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/MultipleElementSymbol.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/util/ElementSymbolOptimizer.java
   trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CommandCollectorVisitor.java
   trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
   trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
   trunk/engine/src/main/java/com/metamatrix/query/validator/Validator.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheID.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheResults.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCache.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
   trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
   trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
   trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
   trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestBufferManagerImpl.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java
   trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
   trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
   trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestCreateUpdateProcedureCommand.java
   trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestElementSymbolOptimizer.java
   trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestResultSetCache.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
   trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBufferService.java
   trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.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-897 TEIID-900 TEIID-902 TEIID-168 beginning to modify pessimistic/optimistic, refining no cache, removing connector resultset caching, and restructuring the planner

Modified: trunk/build/kit-runtime/deploy.properties
===================================================================
--- trunk/build/kit-runtime/deploy.properties	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/build/kit-runtime/deploy.properties	2009-12-09 21:41:41 UTC (rev 1630)
@@ -78,12 +78,15 @@
 #Denotes whether or not result set caching is enabled. (default false)
 ResultSetCache.enabled=false
 
-#The maximum size in MB the result set cache will be allowed to grow to before objects are removed. 0 indicates no limit. (default 50)
-#ResultSetCache.maxSizeInMB=50
+#The maximum size of an result set cache entry in bytes. 0 indicates no limit. (default 1001024)
+#ResultSetCache.maxEntrySize=1001024
 
-#The maximum time a result set will be kept in cache before being automatically cleared. 0 indicates no limit. (default 3600000)
-#ResultSetCache.maxAgeInSeconds=3600000
+#The maximum number of result set cache entries. 0 indicates no limit. (default 1024)
+#ResultSetCache.maxEntries=1024
 
+#The maximum time in seconds a result set will be kept in cache before being automatically cleared. 0 indicates no limit. (default 3600)
+#ResultSetCache.maxAge=3600
+
 #Defines whether caching is restricted to a specific session ('session') or a specific VDB version ('vdb'). (default vdb)	
 #ResultSetCache.scope=vdb
 

Modified: trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -42,9 +42,6 @@
 
     // cache properties
     public static final String USE_RESULTSET_CACHE = "ResultSetCache.enabled"; //$NON-NLS-1$
-    public static final String MAX_RESULTSET_CACHE_SIZE = "ResultSetCache.maxSizeInMB"; //$NON-NLS-1$
-	public static final String MAX_RESULTSET_CACHE_AGE = "ResultSetCache.maxAgeInSeconds"; //$NON-NLS-1$
-	public static final String RESULTSET_CACHE_SCOPE = "ResultSetCache.scope"; //$NON-NLS-1$
 	public static final String MAX_CODE_TABLE_RECORDS_PER_TABLE = "CodeTables.maxRowsPerTable"; //$NON-NLS-1$
 	public static final String MAX_CODE_TABLE_RECORDS = "CodeTables.maxRows"; //$NON-NLS-1$
 	public static final String MAX_CODE_TABLES = "CodeTables.maxCount"; //$NON-NLS-1$

Modified: trunk/connector-sdk/src/main/java/com/metamatrix/cdk/CommandBuilder.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/cdk/CommandBuilder.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/cdk/CommandBuilder.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -73,7 +73,7 @@
         try {
             command = QueryParser.getQueryParser().parseCommand(queryString);
             QueryResolver.resolveCommand(command, metadata);
-            command = QueryRewriter.rewrite(command, null, metadata, null);
+            command = QueryRewriter.rewrite(command, metadata, null);
             expandAllSymbol(command);            
             if (generateAliases) {
                 command.acceptVisitor(new AliasGenerator(supportsGroupAlias));

Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -23,7 +23,6 @@
 package com.metamatrix.common.buffer;
 
 import java.util.List;
-import java.util.Properties;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.common.lob.LobChunk;
@@ -69,16 +68,6 @@
 	}
 
     /**
-	 * Prompts this implementation to initialize itself with the supplied
-	 * Properties.  The implementation Class should document what properties
-	 * are necessary, if any.
-     * @param lookup Class used to determine identity and lookup other managers
-     * @param properties Properties required to initialize the Buffer Manager
-     * @throws BufferException if there was a problem initializing
-	 */
-	void initialize(String location, Properties properties) throws MetaMatrixComponentException;
-	
-    /**
      * Get the batch size to use during query processing.  
      * @return Batch size (# of rows)
      */
@@ -91,12 +80,6 @@
     int getConnectorBatchSize();
     
 	/**
-	 * Adds a {@link StorageManager} to this BufferManager instance.
-     * @param storageManager Storage manager to add
-	 */
-	void setStorageManager(StorageManager storageManager);
-
-	/**
 	 * Creates a tuple source based on a schema and properties describing
 	 * hints about the source
      * @param elements Elements of the tuple source
@@ -259,8 +242,6 @@
     LobChunk getStreamablePart(TupleSourceID tupleSourceID, int beginRow)
     throws TupleSourceNotFoundException, MetaMatrixComponentException;
         
-    void stop();
-    
     /**
      * Release batches that have been pinned by this thread.
      * This method should be called when processing is terminated

Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -273,6 +273,9 @@
      * @since 4.2
      */
     public static String[] getTypeNames(List expressions) {
+    	if (expressions == null) {
+    		return null;
+    	}
         String[] types = new String[expressions.size()];
         for (ListIterator i = expressions.listIterator(); i.hasNext();) {
             Expression expr = (Expression)i.next();
@@ -391,7 +394,7 @@
 
 		TupleSourceInfo info = getTupleSourceInfo(tupleSourceID, true);
         int batchSize = this.config.getProcessorBatchSize();
-        return new TupleSourceImpl(this, tupleSourceID, info.getTupleSchema(), batchSize);
+        return new TupleSourceImpl(this, tupleSourceID, info.getTupleSchema());
     }
 
     /**
@@ -745,7 +748,6 @@
         }
     }
 
-    //TODO: run asynch
 	private void cleanLobTupleSource() {
 		String tupleSourceId = TupleSourceInfo.getStaleLobTupleSource();
 		if (tupleSourceId != null) {

Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/SizeUtility.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/SizeUtility.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/SizeUtility.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -48,6 +48,8 @@
 	public static final boolean IS_64BIT = System.getProperty("sun.arch.data.model", "32").indexOf("64") != -1; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 //	public static final boolean IS_64BIT = true;
 	public static final int REFERENCE_SIZE = IS_64BIT?8:4;
+	
+	private static final int SAMPLE_RATE = 10;
     
     
     /**
@@ -95,14 +97,14 @@
                     || type == DataTypeManager.DefaultDataClasses.TIME
                     || type == DataTypeManager.DefaultDataClasses.TIMESTAMP) { 
                 	// Even though Timestamp contains an extra int, these are 
-                	// the same size because of rounding                                                                               // though
+                	// the same size because of rounding 
                 size += (32*rowLength);            
             } else if (type == DataTypeManager.DefaultDataClasses.NULL) {
             	//do nothing
             }
             else {
-                for (int row = 0; row < rowLength; row++) {
-                    size += getSize(data[row].get(col));
+                for (int row = 0; row < rowLength; row+=SAMPLE_RATE) {
+                    size += getSize(data[row].get(col)) * Math.min(rowLength - row, SAMPLE_RATE);
                 }
             }
         }

Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/TupleSourceImpl.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -45,7 +45,7 @@
     private int mark = 1;
 	private List<?> currentTuple;
 
-    TupleSourceImpl(BufferManagerImpl bufferManagerImpl, TupleSourceID tupleSourceID, List schema, int batchSize){
+    TupleSourceImpl(BufferManagerImpl bufferManagerImpl, TupleSourceID tupleSourceID, List schema){
         this.bufferManagerImpl = bufferManagerImpl;
 		this.tupleSourceID = tupleSourceID;
         this.schema = schema;

Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/storage/file/FileStorageManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/storage/file/FileStorageManager.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/storage/file/FileStorageManager.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -178,7 +178,7 @@
                 return;
             }
             Integer batchKey = new Integer(batch.getBeginRow());
-            if (tsInfo.tupleBatchPointers != null && tsInfo.tupleBatchPointers.containsKey(batchKey)) {
+            if (tsInfo.tupleBatchPointers.containsKey(batchKey)) {
                 return;
             }
             byte[] bytes = convertToBytes(batch, types);
@@ -316,11 +316,6 @@
         }
 
         synchronized(info) {
-            if(info.isRemoved) {
-                // Someone else got here first!
-                return;
-            }
-
             // If open, close the file and decrement the open file counter
             for (int i = 0; i < info.storageFiles.size(); i++) {
                 FileInfo fileInfo = info.storageFiles.get(i);
@@ -359,7 +354,6 @@
         return this.fileCache.size();
     }
 
-
     private class FileInfo {
     	private File file;
         private RandomAccessFile fileData;       // may be null if not open

Modified: trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -35,7 +35,7 @@
  * <li>Debug trace information, if requested</LI>
  * </ul>
  */
-public class AnalysisRecord {
+public class AnalysisRecord implements Serializable {
 
     // Flags regarding what should be recorded
     private boolean recordQueryPlan = false;

Modified: trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/ResultSetInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/ResultSetInfo.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/ResultSetInfo.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -100,18 +100,6 @@
         this.rsPlan = plan;
     }
     
-    public List getReferences() {
-        return boundReferences;
-    }
-    
-    public void setReferences(List references) {
-        this.boundReferences = references;
-    }
-    
-    public boolean hasReferences() {
-        return boundReferences != null;
-    }
-    
     public int getUserRowLimit() {
         return userRowLimit;
     }

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -30,6 +30,7 @@
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.util.CommandContext;
 
 /**
@@ -37,38 +38,14 @@
  * object and produce a 
  * {@link com.metamatrix.query.processor.ProcessorPlan ProcessorPlan} 
  * object, which is a plan for executing the query.</p>
- * 
- * <p>Implementations need to be stateless; state can be stored in the
- * {@link CommandTreeNode CommandTreeNode} objects during planning.  
- * The main client of this interface, {@link QueryOptimizer}, will assume
- * the planners to be stateless and therefore thread safe.</p>
  */
 public interface CommandPlanner {
 	
 	/**
-	 * <p>Requests that the planner generate the canonical plan(s) for the 
-	 * Command object(s) represented by the CommandTreeNode tree parameter.
-	 * The canonical plan(s) should be added to the node(s) of the tree rooted
-	 * at rootNode.</p>
-	 * 
-	 * <p>It may or may not make sense for a specific implementation of this
-	 * Class to create a canonical plan.  It may be that all planning can be done
-	 * during the call to {@link #optimize}</p>
-	 * @param rootNode tree of CommandTreeNode object(s) rooted at rootNode
-	 * @param context 
-	 * @param debug whether or not to generate verbose debug output during planning
-	 * @throws QueryPlannerException indicating a problem in planning
-     * @throws MetaMatrixComponentException indicating an unexpected exception
-	 */
-	void generateCanonical(CommandTreeNode rootNode, QueryMetadataInterface metadata, AnalysisRecord analysisRecord, CommandContext context)
-	throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException;
-	
-	/**
 	 * Allows the planner a chance to optimize the canonical plan(s) stored in
 	 * the CommandTreeNode tree.  This method should be called in a bottom-up
 	 * manner; from leaf nodes up to the root node.
-	 * @param node root of a tree (or subtree) of CommandTreeNode objects, each of 
-	 * which should have its canonical plan
+	 * @param command TODO
 	 * @param metadata source of metadata
 	 * @param capFinder Class usable to find the connector capabilities for a particular model
 	 * @param context 
@@ -78,7 +55,7 @@
      * @throws QueryMetadataException indicating an exception in accessing the metadata
      * @throws MetaMatrixComponentException indicating an unexpected exception
 	 */
-	ProcessorPlan optimize(CommandTreeNode node, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
+	ProcessorPlan optimize(Command command, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
 	throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException;
 
 }

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeNode.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeNode.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,316 +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.optimizer;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.lang.Command;
-
-/**
- * A tree node object used to hold state during command planning and optimizing.
- */
-public class CommandTreeNode {
-	
-	/** The command type is a relational command */
-	public static final int TYPE_RELATIONAL_COMMAND = 2;
-	
-	/** The command type is an XML query */
-	public static final int TYPE_XML_COMMAND = 3;
-	
-	/** The command type is a procedural command */
-	public static final int TYPE_PROCEDURAL_COMMAND = 4;
-
-    /** The command type is an XQuery command */
-    public static final int TYPE_XQUERY_COMMAND = 5;
-    
-    /** The command type is a batched update command. */
-    public static final int TYPE_BATCHED_UPDATE_COMMAND = 6;
-
-    /** The command type is a dynamic command. */
-    public static final int TYPE_DYNAMIC_COMMAND = 7;
-    
-    /** The command type is a prepared batched update command. */
-    public static final int TYPE_PREPARED_BATCH_UPDATE_COMMAND = 8;
-    
-	/** The command, or subcommand, stored at this node */
-	private Command command;
-
-	/** The type of node, as defined by class constants */
-	private int commandType;
-	
-	/** The Planner-specific canonical plan object */
-	private Object canonicalPlan;
-	
-	/** Planner-specific node properties, as defined by each CommandPlanner implementation */
-	private Map<Integer, Object> properties = new HashMap<Integer, Object>();
-	
-	/** The parent of this node, null if root. */
-	private CommandTreeNode parent;
-
-	/** Child nodes */
-	private LinkedList<CommandTreeNode> children = new LinkedList<CommandTreeNode>();	
-
-	// ====================================================
-	// API
-	// ====================================================
-	
-	/**
-	 * Get the type of this command
-	 * @return int one of three type constants defined in this class
-	 * @see #TYPE_RELATIONAL_COMMAND
-	 * @see #TYPE_XML_COMMAND
-	 * @see #TYPE_PROCEDURAL_COMMAND
-	 */
-	public int getCommandType() {
-		return commandType;
-	}	
-
-	/**
-	 * Set the type of this command
-	 * @param commandType one of three type constants defined in this class
-	 * @see #TYPE_RELATIONAL_COMMAND
-	 * @see #TYPE_XML_COMMAND
-	 * @see #TYPE_PROCEDURAL_COMMAND
-	 */
-	public void setCommandType(int commandType) {
-		this.commandType = commandType;
-	}	
-	
-	/**
-	 * Returns the Command object.
-	 * @return Command
-	 */
-	public Command getCommand() {
-		return command;
-	}
-
-	/**
-	 * Sets the Command object.
-	 * @param command The command to set
-	 */
-	public void setCommand(Command command) {
-		this.command = command;
-	}
-	
-	/**
-	 * Retrieve the planner-specific canonical plan
-	 * @return Object planner-specific canonical plan
-	 */
-	public Object getCanonicalPlan(){
-		return this.canonicalPlan;
-	}
-	
-	/**
-	 * Set the planner-specific canonical plan
-	 * @param canonicalPlan Object
-	 */
-	public void setCanonicalPlan(Object canonicalPlan){
-		this.canonicalPlan = canonicalPlan;
-	}
-	
-	/**
-	 * Returns the planner-specific ProcessorPlan implementation.
-	 * This ProcessorPlan may be needed by the planner of this
-	 * node's parent node - in other words a planner may need 
-	 * access to the ProcessorPlans of subcommands or other nested
-	 * commands.
-	 * @return ProcessorPlan at this node, or null if none
-	 */
-	public ProcessorPlan getProcessorPlan() {
-		return this.command.getProcessorPlan();
-	}
-
-	/**
-	 * Sets the planner-specific ProcessorPlan implementation for the
-	 * Command represented by this node.
-	 * @param processorPlan The processorPlan to set
-	 */
-	public void setProcessorPlan(ProcessorPlan processorPlan) {
-		this.command.setProcessorPlan(processorPlan);
-	}	
-
-	// ====================================================
-	// Tree Stuff
-	// ====================================================
-
-	public CommandTreeNode getParent() {
-		return parent;
-	}
-
-	public void setParent(CommandTreeNode parent) {
-		this.parent = parent;
-	}
-
-	public List<CommandTreeNode> getChildren() {
-		return this.children;
-	}
-	
-	public int getChildCount() {
-		return this.children.size();
-	}
-		
-	public CommandTreeNode getFirstChild() {
-		return this.children.getFirst();
-	}
-	
-	public CommandTreeNode getLastChild() {
-		return this.children.getLast();
-	}
-		
-	public void addFirstChild(CommandTreeNode child) {
-		this.children.addFirst(child);
-	}
-	
-	public void addLastChild(CommandTreeNode child) {
-		this.children.addLast(child);
-	}
-	
-	public void addChildren(List<CommandTreeNode> otherChildren) {
-		this.children.addAll(otherChildren);
-	}
-	
-	public boolean hasChild(CommandTreeNode child) {
-		return this.children.contains(child);
-	}
-		
-	public boolean removeChild(CommandTreeNode child) {
-		return this.children.remove(child);
-	}		
-
-	// ====================================================
-	// Properties
-	// ====================================================
-
-	/**
-	 * Retrieve one of the {@link CommandPlanner}-specific properties 
-	 * stored at this node, or null if no property of the given key
-	 * exists.
-	 * @param propertyID key of the property
-	 * @return Object property value
-	 */
-	public Object getProperty(Integer propertyID) {
-		return properties.get(propertyID);
-	}
-	
-	/**
-	 * Set a {@link CommandPlanner}-specific property.  Each planner may have
-	 * conflicting property keys, so an object of this Class should only be
-	 * used for one CommandPlanner at a time.
-	 * @param propertyID planner-specific property key
-	 * @param value property value
-	 */
-	public void setProperty(Integer propertyID, Object value) {
-		properties.put(propertyID, value);
-	}
-
-	// ====================================================
-	// Overriden Object Methods
-	// ====================================================
-
-	/**
-	 * Print CommandTreeNode structure starting at this node
-	 * @return String representing this node and all children under this node
-	 */
-	public String toString() {
-		StringBuffer str = new StringBuffer();
-		getRecursiveString(str, 0);
-		return str.toString();
-	}
-
-	// ====================================================
-	// Utility
-	// ====================================================
-
-	/**
-	 * Just print single node to string instead of node+recursive plan.
-	 * @return String representing just this node
-	 */
-	public String nodeToString() {
-		StringBuffer str = new StringBuffer();
-		getNodeString(str);
-		return str.toString();
-	}
-	
-	// Define a single tab
-	private static final String TAB = "  "; //$NON-NLS-1$
-
-	
-	private void setTab(StringBuffer str, int tabStop) {
-		for(int i=0; i<tabStop; i++) {
-			str.append(TAB);
-		}			
-	}
-	
-	private void getRecursiveString(StringBuffer str, int tabLevel) {
-		setTab(str, tabLevel);
-		getNodeString(str);
-		str.append("\n");  //$NON-NLS-1$
-		getCanonicalPlanString(str);
-		
-		// Recursively add children at one greater tab level
-		for (CommandTreeNode child : this.children) {
-			child.getRecursiveString(str, tabLevel+1);
-		}		
-	}
-
-	private void getNodeString(StringBuffer str) {
-		str.append("(type="); //$NON-NLS-1$
-		str.append(CommandTreeNode.getNodeTypeString(this.commandType));
-		str.append(", command="); //$NON-NLS-1$
-		str.append(this.command);
-		if(this.properties != null) {
-			str.append(", props="); //$NON-NLS-1$
-			str.append(this.properties);
-		}
-		str.append(")");  //$NON-NLS-1$
-	}	
-
-	private void getCanonicalPlanString(StringBuffer str) {
-		if(this.canonicalPlan != null) {
-			str.append("canonical plan:\n"); //$NON-NLS-1$
-			str.append(this.canonicalPlan);
-			str.append("\n");  //$NON-NLS-1$
-		}		
-	}
-	
-	/** 
-	 * Convert a type code into a type string. 
-	 * @param type Type code, as defined in class constants
-	 * @return String representation for code
-	 */
-	private static final String getNodeTypeString(int type) {
-		switch(type) {
-			case TYPE_PROCEDURAL_COMMAND:		return "Procedural"; //$NON-NLS-1$
-			case TYPE_RELATIONAL_COMMAND:		return "Relational"; //$NON-NLS-1$
-			case TYPE_XML_COMMAND:				return "XML"; //$NON-NLS-1$
-            case TYPE_XQUERY_COMMAND:           return "XQuery"; //$NON-NLS-1$
-            case TYPE_BATCHED_UPDATE_COMMAND:   return "BatchedUpdate"; //$NON-NLS-1$
-			default:							return "Unknown: " + type; //$NON-NLS-1$
-		}
-	}	
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeProcessor.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandTreeProcessor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,48 +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.optimizer;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-
-/**
- * An object that performs some processing on a tree of 
- * {@link CommandTreeNode CommandTreeNodes} during command
- * planning.
- */
-public interface CommandTreeProcessor {
-	
-	/**
-	 * Do any necessary processing on the given tree of
-	 * command tree nodes; return the root of the modified
-	 * tree.
-	 * @param root root of the tree of nodes
-	 * @return root of the modified tree, or just the root
-	 * param if no modification occurred.
-	 * @param metadata source of metadata 
-	 */
-	CommandTreeNode process(CommandTreeNode root, QueryMetadataInterface metadata)
-	throws QueryMetadataException, MetaMatrixComponentException; 
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/OptimizerContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/OptimizerContext.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/OptimizerContext.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,62 +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.optimizer;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.metamatrix.query.util.CommandContext;
-
-public class OptimizerContext {
-
-    private static ThreadLocal<OptimizerContext> CONTEXT = new ThreadLocal<OptimizerContext>() {
-        protected OptimizerContext initialValue() {
-            return new OptimizerContext();
-        }
-    };
-    
-    private Set<String> groups = new HashSet<String>();
-    private CommandContext commandContext;
-    
-    public static OptimizerContext getOptimizerContext() {
-        return CONTEXT.get();
-    }
-    
-    void reset(CommandContext context) {
-        this.commandContext = context;
-        this.groups.clear();
-    }
-
-    public Set<String> getGroups() {
-        return this.groups;
-    }
-
-    public CommandContext getCommandContext() {
-        return this.commandContext;
-    }
-
-    public void setCommandContext(CommandContext commandContext) {
-        this.commandContext = commandContext;
-    }
-    
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,13 +22,13 @@
 
 package com.metamatrix.query.optimizer;
 
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.Map;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.core.id.IDGenerator;
 import com.metamatrix.core.id.IntegerIDFactory;
 import com.metamatrix.query.analysis.AnalysisRecord;
@@ -38,15 +38,13 @@
 import com.metamatrix.query.optimizer.batch.BatchedUpdatePlanner;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.optimizer.proc.ProcedurePlanner;
-import com.metamatrix.query.optimizer.relational.MergeTreeNodeProcessor;
-import com.metamatrix.query.optimizer.relational.PlanHints;
 import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.optimizer.xml.XMLPlanner;
 import com.metamatrix.query.optimizer.xquery.XQueryPlanner;
 import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.resolver.QueryResolver;
 import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
+import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.util.CommandContext;
 
 /**
@@ -59,247 +57,70 @@
  * tree.</p>
  */
 public class QueryOptimizer {
-
-	private static final CommandPlanner RELATIONAL_PLANNER = new RelationalPlanner();
+	
 	private static final CommandPlanner XML_PLANNER = new XMLPlanner();
 	private static final CommandPlanner PROCEDURE_PLANNER = new ProcedurePlanner();
     private static final CommandPlanner XQUERY_PLANNER = new XQueryPlanner();
     private static final CommandPlanner BATCHED_UPDATE_PLANNER = new BatchedUpdatePlanner();
-	private static final CommandTreeProcessor MERGE_TREE_NODE_PROCESSOR = new MergeTreeNodeProcessor();
 
 	// Can't construct	
 	private QueryOptimizer() {}
 
-	/**
-	 * <p>This method is intended only for clients with a need to have access to the 
-	 * planning state of QueryOptimizer, which it can get to through the 
-	 * {@link CommandTreeNode CommandTreeNode} reference passed in.</p>
-	 * 
-	 * <p>If there's no need to access the planning state, use one of the other
-	 * overloaded methods, either
-	 * {@link #optimizePlan(Command, boolean, QueryMetadataInterface) optimizePlan}
-	 * or
-	 * {@link #optimizePlan(Command, boolean, QueryMetadataInterface, boolean) optimizePlan}
-	 * </p>
-	 * 
-	 * @param command fully-resolved user's command object
-	 * @param metadata source of metadata
-	 * @param idGenerator IDGenerator to be used for data nodes - if null, one will be created
-	 * @param context 
-	 * @param annotations Collection to add annotations to, null if annotations should be co  
-	 * @param debug True if OPTION DEBUG output should be sent to analysisRecord 
-	 * @return ProcessorPlan plan for query execution.
-	 * @throws QueryPlannerException if there is a problem planning the query plan
-	 * @throws QueryMetadataException if there is a problem accessing the metadata source
-	 * @throws MetaMatrixComponentException if there is an unexpected exception
-	 */
-	public static ProcessorPlan optimizePlan(Command command, QueryMetadataInterface metadata, IDGenerator idGenerator, CapabilitiesFinder capabilitiesFinder, AnalysisRecord analysisRecord, CommandContext context)
+	public static ProcessorPlan optimizePlan(Command command, QueryMetadataInterface metadata, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
 		throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
 
+		if (analysisRecord == null) {
+			analysisRecord = new AnalysisRecord(false, false, false);
+		}
+		
+		if (context == null) {
+			context = new CommandContext();
+		}
+		
         boolean debug = analysisRecord.recordDebug();
-		if(debug) {
-			analysisRecord.println("\n============================================================================"); //$NON-NLS-1$
-            analysisRecord.println("USER COMMAND:\n" + command);		 //$NON-NLS-1$
-            analysisRecord.println("\nINITIAL COMMAND STRUCTURE:\n" + command.printCommandTree());             //$NON-NLS-1$
-        }
-
-		// Generate canonical plans for each command
-        CommandTreeNode root = new CommandTreeNode();
-		recursiveGenerateCanonical(root, command, metadata, analysisRecord, context);
+        
+        Map tempMetadata = command.getTemporaryMetadata();
+        metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(tempMetadata));
                 
-		// Run preprocessors
-        root = MERGE_TREE_NODE_PROCESSOR.process(root, metadata);
-		if(debug) {
-            analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
-			analysisRecord.println("COMMAND TREE after merging relational nodes: \n" + root); //$NON-NLS-1$
-		}   
-
         // Create an ID generator that can be used for all plans to generate unique data node IDs
         if(idGenerator == null) {
             idGenerator = new IDGenerator();
             idGenerator.setDefaultFactory(new IntegerIDFactory());
         }
         
-        OptimizerContext.getOptimizerContext().reset(context);
-        
-		// Optimize command tree recursively, bottom-up
-		ProcessorPlan plan = recursiveOptimize(root, idGenerator, metadata, capabilitiesFinder, analysisRecord, context);
-		
-        OptimizerContext.getOptimizerContext().reset(context);
-
 		if(debug) {
-            analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
-            analysisRecord.println("OPTIMIZATION COMPLETE:"); //$NON-NLS-1$
-            analysisRecord.println("PLAN TREE:\n" + root); //$NON-NLS-1$
-            analysisRecord.println("PROCESSOR PLAN:\n" + plan); //$NON-NLS-1$
-			analysisRecord.println("============================================================================");		 //$NON-NLS-1$
-		}			
-
-		return plan;
-	}
-	
-	/**
-	 * Method recursiveGenerateCanonical.
-	 * @param CommandTreeNode
-	 * @param command
-	 * @param minimizeToSource
-	 * @param metadata
-	 * @param planNodeIDOffset
-	 * @param boundReferencesMap
-	 * @param debug
-	 */
-	private static void recursiveGenerateCanonical(
-		CommandTreeNode node,
-		Command command,
-		QueryMetadataInterface metadata,
-		AnalysisRecord analysisRecord,
-        CommandContext context) 
-	throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-		
-        boolean debug = analysisRecord.recordDebug();
-		if(debug) {
-            analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
-            analysisRecord.println("GENERATE CANONICAL: \n" + command); //$NON-NLS-1$
-		}   
-		makeCanonical(node, command, metadata, analysisRecord, context);
-
-		if(debug) {
-            analysisRecord.println("\nCANONICAL PLAN: \n" + node.getCanonicalPlan()); //$NON-NLS-1$
-		}   
-				
-		for (Command subcommand : command.getSubCommands()) {
-			CommandTreeNode child = new CommandTreeNode();
-			node.addLastChild(child);
-            child.setParent(node);
-			recursiveGenerateCanonical(child, subcommand, metadata, analysisRecord, context);
-		}
-	}
-
-	/**
-	 * Method recursiveOptimize.
-	 * @param node
-	 * @param minimizeToSource
-	 * @param metadata
-	 * @param boundReferencesMap
-	 * @param debug
-	 */
-	private static ProcessorPlan recursiveOptimize(
-		CommandTreeNode node,
-        IDGenerator idGenerator,
-		QueryMetadataInterface metadata,
-        CapabilitiesFinder capFinder,
-		AnalysisRecord analysisRecord,
-        CommandContext context) 
-	throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-		for (CommandTreeNode child : node.getChildren()) {
-			recursiveOptimize(child, idGenerator, metadata, capFinder, analysisRecord, context);
-		}
-        
-        // Create metadata adapter if necessary
-        QueryMetadataInterface optMetadata = metadata;
-        Map commandMetadata = node.getCommand().getTemporaryMetadata();
-        if(commandMetadata != null && commandMetadata.size() > 0) {
-            optMetadata = new TempMetadataAdapter(metadata, new TempMetadataStore(commandMetadata));
-        }
-
-        boolean debug = analysisRecord.recordDebug();
-		if(debug) {
 			analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
-            analysisRecord.println("OPTIMIZE: \n" + node.getCommand()); //$NON-NLS-1$
+            analysisRecord.println("OPTIMIZE: \n" + command); //$NON-NLS-1$
 		}   
                                    
-		//optimize step
-		ProcessorPlan plan = optimize(node, idGenerator, optMetadata, capFinder, analysisRecord, context);
-		node.setProcessorPlan(plan);
-
-		return plan;
-	}
-	
-	/**
-	 * Method optimize.
-	 * @param node
-	 * @param minimizeToSource
-	 * @param metadata
-	 * @param boundReferencesMap
-	 * @return ProcessorPlan
-	 */
-	private static ProcessorPlan optimize(
-		CommandTreeNode node,
-        IDGenerator idGenerator,
-		QueryMetadataInterface metadata,
-        CapabilitiesFinder capFinder,
-		AnalysisRecord analysisRecord,
-        CommandContext context) 
-	throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-
 		ProcessorPlan result = null;
 
-		if (node.getCommandType() == CommandTreeNode.TYPE_RELATIONAL_COMMAND){
-			result = RELATIONAL_PLANNER.optimize(node, idGenerator, metadata, capFinder, analysisRecord, context);
-		} else if (node.getCommandType() == CommandTreeNode.TYPE_XML_COMMAND){
-			result = XML_PLANNER.optimize(node, idGenerator, metadata, capFinder, analysisRecord, context);
-		} else if (node.getCommandType() == CommandTreeNode.TYPE_PROCEDURAL_COMMAND){
-			result = PROCEDURE_PLANNER.optimize(node, idGenerator, metadata, capFinder, analysisRecord, context);
-        } else if (node.getCommandType() == CommandTreeNode.TYPE_XQUERY_COMMAND){
-            result = XQUERY_PLANNER.optimize(node, idGenerator, metadata, capFinder, analysisRecord, context);
-        } else if (node.getCommandType() == CommandTreeNode.TYPE_BATCHED_UPDATE_COMMAND){
-            result = BATCHED_UPDATE_PLANNER.optimize(node, idGenerator, metadata, capFinder, analysisRecord, context);
+		if (command.getType() == Command.TYPE_UPDATE_PROCEDURE){
+			result = PROCEDURE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+        } else if (command.getType() == Command.TYPE_XQUERY){
+            result = XQUERY_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+        } else if (command.getType() == Command.TYPE_BATCHED_UPDATE){
+            result = BATCHED_UPDATE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+        } else {
+			try {
+				if (command.getType() == Command.TYPE_QUERY && command instanceof Query && QueryResolver.isXMLQuery((Query)command, metadata)) {
+					result = XML_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+				} else {
+					result = new RelationalPlanner().optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+				}
+			} catch (QueryResolverException e) {
+				throw new MetaMatrixRuntimeException(e);
+			}
         }
+		
+		if(debug) {
+            analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
+            analysisRecord.println("OPTIMIZATION COMPLETE:"); //$NON-NLS-1$
+            analysisRecord.println("PROCESSOR PLAN:\n" + result); //$NON-NLS-1$
+			analysisRecord.println("============================================================================");		 //$NON-NLS-1$
+		}			
+
 		return result;
 	}
 	
-	private static void makeCanonical(CommandTreeNode node, Command command, QueryMetadataInterface metadata, AnalysisRecord analysisRecord, CommandContext context)
-	throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-
-        node.setCommand(command);
-
-        // Use command metadata while checking type                
-        QueryMetadataInterface optMetadata = metadata;
-        Map tempMetadata = command.getTemporaryMetadata();
-        if(tempMetadata != null && !tempMetadata.isEmpty()) {
-            optMetadata = new TempMetadataAdapter(metadata, new TempMetadataStore(tempMetadata));
-        }
-        
-        // Easy to detect batched update planner, procedural planner, or XQueryPlanner
-        int commandType = command.getType();
-        if (commandType == Command.TYPE_BATCHED_UPDATE) {
-            node.setCommandType(CommandTreeNode.TYPE_BATCHED_UPDATE_COMMAND);
-            BATCHED_UPDATE_PLANNER.generateCanonical(node, optMetadata, analysisRecord, context);
-            return;
-        } else if (commandType == Command.TYPE_UPDATE_PROCEDURE){
-            //it's a procedure command
-            node.setCommandType(CommandTreeNode.TYPE_PROCEDURAL_COMMAND);
-            PROCEDURE_PLANNER.generateCanonical(node, optMetadata, analysisRecord, context);   
-			return;
-        } else if (commandType == Command.TYPE_XQUERY){
-            node.setCommandType(CommandTreeNode.TYPE_XQUERY_COMMAND);
-            XQUERY_PLANNER.generateCanonical(node, optMetadata, analysisRecord, context);   
-            return;
-        } else if (commandType == Command.TYPE_DYNAMIC){
-            node.setCommandType(CommandTreeNode.TYPE_DYNAMIC_COMMAND);
-            return;
-        }
-        
-        // Set type
-        node.setCommandType(CommandTreeNode.TYPE_RELATIONAL_COMMAND);
-        if(commandType == Command.TYPE_QUERY) {
-            Collection groups = GroupCollectorVisitor.getGroups(command, true);
-            if(groups.size() == 1) {
-                GroupSymbol group = (GroupSymbol) groups.iterator().next();
-                                     
-                if(optMetadata.isXMLGroup(group.getMetadataID())) {
-                    node.setCommandType(CommandTreeNode.TYPE_XML_COMMAND);    
-                }                    
-            }
-        }
-        
-        if(node.getCommandType() == CommandTreeNode.TYPE_RELATIONAL_COMMAND) {    
-            PlanHints hints = new PlanHints();
-            node.setProperty(RelationalPlanner.HINTS, hints);
-            RELATIONAL_PLANNER.generateCanonical(node, optMetadata, analysisRecord, context);
-        } else {
-            XML_PLANNER.generateCanonical(node, optMetadata, analysisRecord, context);            
-        }
-        
-	}
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -35,11 +35,10 @@
 import com.metamatrix.query.execution.QueryExecPlugin;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.CommandTreeNode;
+import com.metamatrix.query.optimizer.QueryOptimizer;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.optimizer.relational.rules.CapabilitiesUtil;
 import com.metamatrix.query.processor.ProcessorPlan;
 import com.metamatrix.query.processor.batch.BatchedUpdatePlan;
@@ -65,17 +64,6 @@
 public class BatchedUpdatePlanner implements CommandPlanner {
 
     /** 
-     * @see com.metamatrix.query.optimizer.CommandPlanner#generateCanonical(com.metamatrix.query.optimizer.CommandTreeNode, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.analysis.AnalysisRecord, CommandContext)
-     * @since 4.2
-     */
-    public void generateCanonical(CommandTreeNode rootNode,
-                                  QueryMetadataInterface metadata,
-                                  AnalysisRecord analysisRecord, CommandContext context)
-    throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-        // do nothing. the planner framework takes care of generating the canonical plan for each of the child commands
-    }
-
-    /** 
      * Optimizes batched updates by batching all contiguous commands that relate to the same physical model.
      * For example, for the following batch of commands:
      * <br/>
@@ -95,21 +83,20 @@
      * </ol>
      * <br/> this implementation will batch as follows: (1,2), (5, 6, 7), (8 thru 12).
      * The remaining commands/plans will be executed individually.
-     * @see com.metamatrix.query.optimizer.CommandPlanner#optimize(com.metamatrix.query.optimizer.CommandTreeNode, com.metamatrix.core.id.IDGenerator, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.analysis.AnalysisRecord, CommandContext)
+     * @see com.metamatrix.query.optimizer.CommandPlanner#optimize(Command, com.metamatrix.core.id.IDGenerator, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.analysis.AnalysisRecord, CommandContext)
      * @since 4.2
      */
-    public ProcessorPlan optimize(CommandTreeNode node,
+    public ProcessorPlan optimize(Command command,
                                   IDGenerator idGenerator,
                                   QueryMetadataInterface metadata,
                                   CapabilitiesFinder capFinder,
                                   AnalysisRecord analysisRecord, CommandContext context)
     throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-        List children = node.getChildren();
-        List childPlans = new ArrayList(children.size());
-        BatchedUpdateCommand batchedUpdateCommand = (BatchedUpdateCommand)node.getCommand();
+        BatchedUpdateCommand batchedUpdateCommand = (BatchedUpdateCommand)command;
+        List childPlans = new ArrayList(batchedUpdateCommand.getUpdateCommands().size());
         List updateCommands = batchedUpdateCommand.getUpdateCommands();
         int numCommands = updateCommands.size();
-        List<VariableContext> allContexts = (List<VariableContext>)node.getProperty(RelationalPlanner.VARIABLE_CONTEXTS);
+        List<VariableContext> allContexts = batchedUpdateCommand.getVariableContexts();
         for (int commandIndex = 0; commandIndex < numCommands; commandIndex++) {
             // Potentially the first command of a batch
             Command updateCommand = (Command)updateCommands.get(commandIndex);
@@ -174,10 +161,15 @@
                 }
             }
             if (!commandWasBatched) { // If the command wasn't batched, just add the plan for this command to the list of plans
-                childPlans.add(((CommandTreeNode)children.get(commandIndex)).getProcessorPlan()); // Assumes the command index is the same as the plan node index
+            	Command cmd = (Command)batchedUpdateCommand.getUpdateCommands().get(commandIndex);
+            	ProcessorPlan plan = cmd.getProcessorPlan();
+            	if (plan == null) {
+            		plan = QueryOptimizer.optimizePlan(cmd, metadata, idGenerator, capFinder, analysisRecord, context);
+            	}
+                childPlans.add(plan);
             }
         }
-        return new BatchedUpdatePlan(childPlans, children.size());
+        return new BatchedUpdatePlan(childPlans, batchedUpdateCommand.getUpdateCommands().size());
     }
     
     /**

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -23,18 +23,18 @@
 package com.metamatrix.query.optimizer.proc;
 
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryPlannerException;
 import com.metamatrix.core.id.IDGenerator;
+import com.metamatrix.core.util.Assertion;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.execution.QueryExecPlugin;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.CommandTreeNode;
+import com.metamatrix.query.optimizer.QueryOptimizer;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.processor.ProcessorPlan;
 import com.metamatrix.query.processor.proc.AbstractAssignmentInstruction;
@@ -66,6 +66,7 @@
 import com.metamatrix.query.sql.proc.WhileStatement;
 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.util.CommandContext;
 
 /**
@@ -76,25 +77,9 @@
 public final class ProcedurePlanner implements CommandPlanner {
 	
 	/**
-	 * <p>This method does nothing as the method call to {@link #optimize} directly produces
-	 * the ProcessorPlan for the given procedure.</p>
-	 *
-	 * @param rootNode tree of CommandTreeNode object(s) rooted at rootNode
-	 * @param debug whether or not to generate verbose debug output during planning
-	 * @throws QueryPlannerException indicating a problem in planning
-     * @throws MetaMatrixComponentException indicating an unexpected exception
-	 */
-	public void generateCanonical(CommandTreeNode rootNode, QueryMetadataInterface metadata, AnalysisRecord analysisRecord, CommandContext context)
-	throws QueryPlannerException, MetaMatrixComponentException {
-		// does nothing
-	}
-
-	/**
 	 * <p>Produce a ProcessorPlan for the CreateUpdateProcedureCommand on the current node
 	 * of the CommandTreeNode, the procedure plan construction involves using the child
 	 * processor plans.</p>
-	 * @param node root of a tree (or subtree) of CommandTreeNode objects, each of
-	 * which should have its canonical plan
 	 * @param metadata source of metadata
 	 * @param debug whether or not to generate verbose debug output during planning
 	 * @return ProcessorPlan This processorPlan is a <code>ProcedurePlan</code>
@@ -102,29 +87,30 @@
      * @throws QueryMetadataException indicating an exception in accessing the metadata
      * @throws MetaMatrixComponentException indicating an unexpected exception
 	 */
-	public ProcessorPlan optimize(CommandTreeNode node, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
+	public ProcessorPlan optimize(Command procCommand, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
 	throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
 
-		// get the current command on the current node of the tree
-		Command procCommand = node.getCommand();
-        
-		// set state of the planner with child nodes
-		// to be used while planning
-		List<CommandTreeNode> childNodes = node.getChildren();
-
         boolean debug = analysisRecord.recordDebug();
         if(debug) {
             analysisRecord.println("\n####################################################"); //$NON-NLS-1$
-            analysisRecord.println("PROCEDURE COMMAND: " + node.getCommand()); //$NON-NLS-1$
+            analysisRecord.println("PROCEDURE COMMAND: " + procCommand); //$NON-NLS-1$
         }
 
-        if(!(procCommand instanceof CreateUpdateProcedureCommand)) {
-        	throw new QueryPlannerException(QueryExecPlugin.Util.getString("ProcedurePlanner.wrong_type", procCommand.getType())); //$NON-NLS-1$
+        Assertion.isInstanceOf(procCommand, CreateUpdateProcedureCommand.class, "Wrong command type"); //$NON-NLS-1$
+
+        if(debug) {
+            analysisRecord.println("OPTIMIZING SUB-COMMANDS: "); //$NON-NLS-1$
         }
+        
+        for (Command command : CommandCollectorVisitor.getCommands(procCommand)) {
+        	if (!(command instanceof DynamicCommand)) {
+        		command.setProcessorPlan(QueryOptimizer.optimizePlan(command, metadata, idGenerator, capFinder, analysisRecord, context));
+        	}
+        }
 
         Block block = ((CreateUpdateProcedureCommand) procCommand).getBlock();
 
-		Program programBlock = planBlock(((CreateUpdateProcedureCommand)procCommand), block, metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
+		Program programBlock = planBlock(((CreateUpdateProcedureCommand)procCommand), block, metadata, debug, idGenerator, capFinder, analysisRecord, context);
 
         if(debug) {
             analysisRecord.println("\n####################################################"); //$NON-NLS-1$
@@ -170,7 +156,7 @@
 	 * @throws QueryMetadataException if there is an error accessing metadata
 	 * @throws MetaMatrixComponentException if unexpected error occurs
 	 */
-    private Program planBlock(CreateUpdateProcedureCommand parentProcCommand, Block block, QueryMetadataInterface metadata, List<CommandTreeNode> childNodes, boolean debug, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord)
+    private Program planBlock(CreateUpdateProcedureCommand parentProcCommand, Block block, QueryMetadataInterface metadata, boolean debug, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
         throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
 
         Iterator stmtIter = block.getStatements().iterator();
@@ -183,7 +169,7 @@
 		// plan each statement in the block
         while(stmtIter.hasNext()) {
 			Statement statement = (Statement) stmtIter.next();
-			Object instruction = planStatement(parentProcCommand, statement, metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
+			Object instruction = planStatement(parentProcCommand, statement, metadata, debug, idGenerator, capFinder, analysisRecord, context);
 			//childIndex = ((Integer) array[0]).intValue();
             if(instruction instanceof ProgramInstruction){
                 programBlock.addInstruction((ProgramInstruction)instruction);
@@ -215,7 +201,7 @@
 	 * @throws QueryMetadataException if there is an error accessing metadata
 	 * @throws MetaMatrixComponentException if unexpected error occurs
 	 */
-    private Object planStatement(CreateUpdateProcedureCommand parentProcCommand, Statement statement, QueryMetadataInterface metadata, List<CommandTreeNode> childNodes, boolean debug, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord)
+    private Object planStatement(CreateUpdateProcedureCommand parentProcCommand, Statement statement, QueryMetadataInterface metadata, boolean debug, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
         throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
 
 		int stmtType = statement.getType();
@@ -284,10 +270,10 @@
 			case Statement.TYPE_IF:
             {
 				IfStatement ifStmt = (IfStatement)statement;
-				Program ifProgram = planBlock(parentProcCommand, ifStmt.getIfBlock(), metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
+				Program ifProgram = planBlock(parentProcCommand, ifStmt.getIfBlock(), metadata, debug, idGenerator, capFinder, analysisRecord, context);
 				Program elseProgram = null;
 				if(ifStmt.hasElseBlock()) {
-					elseProgram = planBlock(parentProcCommand, ifStmt.getElseBlock(), metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
+					elseProgram = planBlock(parentProcCommand, ifStmt.getElseBlock(), metadata, debug, idGenerator, capFinder, analysisRecord, context);
 				}
 				instruction = new IfInstruction(ifStmt.getCondition(), ifProgram, elseProgram);
 				if(debug) {
@@ -318,16 +304,17 @@
                 	analysisRecord.println("\tLOOP STATEMENT:\n" + statement); //$NON-NLS-1$
                 }
                 String rsName = loopStmt.getCursorName();
+
                 ProcessorPlan commandPlan = loopStmt.getCommand().getProcessorPlan();
 
-                Program loopProgram = planBlock(parentProcCommand, loopStmt.getBlock(), metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
+                Program loopProgram = planBlock(parentProcCommand, loopStmt.getBlock(), metadata, debug, idGenerator, capFinder, analysisRecord, context);
                 instruction = new LoopInstruction(loopProgram, rsName, commandPlan);
                 break;
             }
             case Statement.TYPE_WHILE:
             {
                 WhileStatement whileStmt = (WhileStatement)statement;
-                Program whileProgram = planBlock(parentProcCommand, whileStmt.getBlock(), metadata, childNodes, debug, idGenerator, capFinder, analysisRecord);
+                Program whileProgram = planBlock(parentProcCommand, whileStmt.getBlock(), metadata, debug, idGenerator, capFinder, analysisRecord, context);
                 if(debug) {
                 	analysisRecord.println("\tWHILE STATEMENT:\n" + statement); //$NON-NLS-1$
                 }

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/GenerateCanonical.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/GenerateCanonical.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/GenerateCanonical.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,502 +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.optimizer.relational;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-public final class GenerateCanonical {
-
-	/**
-	 * Generate an initial plan given a command.  This plan will contain all necessary
-	 * information from the command but will not be optimized or even executable.
-	 * @param command Command to plan
-	 * @param metadata Metadata access
-	 * @param debug True if debugging information should be dumped to STDOUT
-	 * @return Initial query plan tree
-	 */
-	public static PlanNode generatePlan(Command command, PlanHints hints, QueryMetadataInterface metadata)
-	    throws QueryPlannerException, MetaMatrixComponentException {
-		if( command.getType() == Command.TYPE_QUERY ) {
-
-			return GenerateCanonical.createQueryPlan(command, hints, metadata);
-
-		} else if( command.getType() == Command.TYPE_INSERT ||
-					command.getType() == Command.TYPE_UPDATE ||
-					command.getType() == Command.TYPE_DELETE ||
-                    command.getType() == Command.TYPE_CREATE ||
-                    command.getType() == Command.TYPE_DROP            
-        ) {
-
-			// update PlanHints to note that it is an update
-			hints.isUpdate = true;
-
-			return GenerateCanonical.createUpdatePlan(command, hints, metadata);
-
-		} else if( command.getType() == Command.TYPE_STORED_PROCEDURE) {
-
-			return GenerateCanonical.createStoredProcedurePlan(command, hints);
-
-		} else {
-            throw new QueryPlannerException(QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0005, command.getClass().getName()));
-		}
-	}
-
-	private GenerateCanonical() { }
-
-	static PlanNode createUpdatePlan(Command command, PlanHints hints, QueryMetadataInterface metadata) throws QueryPlannerException, MetaMatrixComponentException {
-
-        // Create top project node - define output columns for stored query / procedure
-        PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
-
-        Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, false);
-        projectNode.addGroups(groups);
-
-        // Set output columns
-        List<SingleElementSymbol> cols = command.getProjectedSymbols();
-        projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, cols);
-
-        // Define source of data for stored query / procedure
-        PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
-        sourceNode.setProperty(NodeConstants.Info.ATOMIC_REQUEST, command);
-        sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, command);
-        if (command instanceof ProcedureContainer) {
-        	ProcedureContainer container = (ProcedureContainer)command;
-	        if (container.getSubCommand() != null) {
-	            sourceNode.setProperty(NodeConstants.Info.NESTED_COMMAND, container.getSubCommand());
-	        }
-        }
-        sourceNode.addGroups(groups);
-
-        GenerateCanonical.attachLast(projectNode, sourceNode);
-
-        //for INTO query, attach source and project nodes
-        if(command instanceof Insert){
-        	Insert insert = (Insert)command;
-        	if (insert.getQueryExpression() != null) {
-	            PlanNode plan = createQueryPlan(insert.getQueryExpression(), hints, metadata);
-	            GenerateCanonical.attachLast(sourceNode, plan);
-	            MergeTreeNodeProcessor.mergeTempMetadata(insert.getQueryExpression(), insert);
-	            projectNode.setProperty(NodeConstants.Info.INTO_GROUP, insert.getGroup());
-        	}
-        }
-        
-        return projectNode;
-	}
-
-    static PlanNode createStoredProcedurePlan(Command command, PlanHints hints) {
-
-        StoredProcedure storedProc = (StoredProcedure) command;
-
-        // Create top project node - define output columns for stored query / procedure
-        PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
-
-        // Set output columns
-        List cols = storedProc.getProjectedSymbols();
-        projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, cols);
-
-        // Define source of data for stored query / procedure
-        PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
-        sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, storedProc);
-        if (storedProc.getSubCommand() != null) {
-            sourceNode.setProperty(NodeConstants.Info.NESTED_COMMAND, storedProc.getSubCommand());
-        }
-        
-        hints.hasRelationalProc |= storedProc.isProcedureRelational();
-
-        // Set group on source node
-        sourceNode.addGroup(storedProc.getGroup());
-
-        GenerateCanonical.attachLast(projectNode, sourceNode);
-
-        return projectNode;
-    }
-
-	static PlanNode createQueryPlan(Command command, PlanHints hints, QueryMetadataInterface metadata)
-		throws QueryPlannerException, MetaMatrixComponentException {
-
-        // Add make dependent hints from OPTION clause
-        QueryCommand qcommand = (QueryCommand) command;
-        Option option = qcommand.getOption();
-        if(option != null) {
-            hints.addMakeDepGroups(option.getDependentGroups());
-            hints.addMakeNotDepGroups(option.getNotDependentGroups());
-        }
-
-        // Build canonical plan
-    	PlanNode node = null;
-        if(command instanceof Query) {
-            node = createQueryPlan((Query) command, hints, metadata);
-        } else {
-            node = createQueryPlan((SetQuery) command, hints, metadata);
-        }
-
-        return node;
-    }
-
-    private static PlanNode createQueryPlan(SetQuery query, PlanHints hints, QueryMetadataInterface metadata)
-		throws QueryPlannerException, MetaMatrixComponentException {
-
-        hints.hasSetQuery = true;
-        
-        PlanNode leftPlan = createQueryPlan( query.getLeftQuery(), hints, metadata);
-        PlanNode rightPlan = createQueryPlan( query.getRightQuery(), hints, metadata);
-
-        PlanNode plan = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
-        plan.setProperty(NodeConstants.Info.SET_OPERATION, query.getOperation());
-        plan.setProperty(NodeConstants.Info.USE_ALL, query.isAll());
-        
-        GenerateCanonical.attachLast(plan, leftPlan);
-        GenerateCanonical.attachLast(plan, rightPlan);
-
-		// Attach sorting on top of union
-		if(query.getOrderBy() != null) {
-			plan = attachSorting(plan, query.getOrderBy());
-            hints.hasSort = true;
-		}
-
-        if (query.getLimit() != null) {
-            plan = attachTupleLimit(plan, query.getLimit(), hints);
-        }
-        
-        return plan;
-    }
-
-    private static PlanNode createQueryPlan(Query query, PlanHints hints, QueryMetadataInterface metadata)
-		throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-
-        PlanNode plan = null;
-
-        if(query.getFrom() != null){
-            FromClause fromClause = mergeClauseTrees(query.getFrom());
-            
-            PlanNode dummyRoot = new PlanNode();
-            
-    		hints.hasOptionalJoin |= buildTree(fromClause, dummyRoot, metadata, hints);
-            
-            plan = dummyRoot.getFirstChild();
-            
-            hints.hasJoin |= plan.getType() == NodeConstants.Types.JOIN;
-
-    		// Attach criteria on top
-    		if(query.getCriteria() != null) {
-    			plan = attachCriteria(plan, query.getCriteria(), false);
-                hints.hasCriteria = true;
-    		}
-
-    		// Attach grouping node on top
-    		if(query.getGroupBy() != null || query.getHaving() != null || !AggregateSymbolCollectorVisitor.getAggregates(query.getSelect(), false).isEmpty()) {
-    			plan = attachGrouping(plan, query, hints);
-    		}
-
-    		// Attach having criteria node on top
-    		if(query.getHaving() != null) {
-    			plan = attachCriteria(plan, query.getHaving(), true);
-                hints.hasCriteria = true;
-    		}
-            
-        }
-
-		// Attach project on top
-		plan = attachProject(plan, query.getSelect());
-
-		// Attach dup removal on top
-		if(query.getSelect().isDistinct()) {
-			plan = attachDupRemoval(plan);
-		}
-
-		// Attach sorting on top
-		if(query.getOrderBy() != null) {
-			plan = attachSorting(plan, query.getOrderBy());
-            hints.hasSort = true;
-		}
-        
-        if (query.getLimit() != null) {
-            plan = attachTupleLimit(plan, query.getLimit(), hints);
-        }
-
-		return plan;
-	}
-
-    /**
-     * Merges the from clause into a single join predicate if there are more than 1 from clauses
-     */
-    private static FromClause mergeClauseTrees(From from) {
-        List clauses = from.getClauses();
-        
-        while (clauses.size() > 1) {
-            FromClause first = (FromClause)from.getClauses().remove(0);
-            FromClause second = (FromClause)from.getClauses().remove(0);
-            JoinPredicate jp = new JoinPredicate(first, second, JoinType.JOIN_CROSS);
-            clauses.add(0, jp);
-        }
-        
-        return (FromClause)clauses.get(0);
-    }
-    
-    /**
-     * Build a join plan based on the structure in a clause.  These structures should be
-     * essentially the same tree, but with different objects and details.
-     * @param clause Clause to build tree from
-     * @param parent Parent node to attach join node structure to
-     * @param sourceMap Map of group to source node, used for connecting children to join plan
-     * @param markJoinsInternal Flag saying whether joins built in this method should be marked
-     * as internal
-     * @return true if there are optional join nodes
-     * @throws MetaMatrixComponentException 
-     * @throws QueryMetadataException 
-     */
-    static boolean buildTree(FromClause clause, PlanNode parent, QueryMetadataInterface metadata, PlanHints hints)
-        throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-        
-        boolean result = false;
-        
-        PlanNode node = null;
-        
-        if(clause instanceof UnaryFromClause) {
-            // No join required
-            UnaryFromClause ufc = (UnaryFromClause)clause;
-            GroupSymbol group = ufc.getGroup();
-            if (metadata.isVirtualGroup(group.getMetadataID())) {
-            	hints.hasVirtualGroups = true;
-            }
-            Command nestedCommand = ufc.getExpandedCommand();
-            node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
-            node.addGroup(group);
-            node.setProperty(NodeConstants.Info.NESTED_COMMAND, nestedCommand);
-
-            parent.addLastChild(node);
-        } else if(clause instanceof JoinPredicate) {
-            JoinPredicate jp = (JoinPredicate) clause;
-
-            // Set up new join node corresponding to this join predicate
-            node = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
-            node.setProperty(NodeConstants.Info.JOIN_TYPE, jp.getJoinType());
-            node.setProperty(NodeConstants.Info.JOIN_STRATEGY, JoinStrategyType.NESTED_LOOP);
-            node.setProperty(NodeConstants.Info.JOIN_CRITERIA, jp.getJoinCriteria());
-            
-            if (jp.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
-            	result = true;
-            }
-         
-            // Attach join node to parent
-            parent.addLastChild(node);
-
-            // Handle each child
-            FromClause[] clauses = new FromClause[] {jp.getLeftClause(), jp.getRightClause()};
-            for(int i=0; i<2; i++) {
-                result |= buildTree(clauses[i], node, metadata, hints);
-
-                // Add groups to joinNode
-                for (PlanNode child : node.getChildren()) {
-                    node.addGroups(child.getGroups());
-                }
-            }
-        } else if (clause instanceof SubqueryFromClause) {
-            SubqueryFromClause sfc = (SubqueryFromClause)clause;
-            GroupSymbol group = sfc.getGroupSymbol();
-            Command nestedCommand = sfc.getCommand();
-            node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
-            node.addGroup(group);
-            node.setProperty(NodeConstants.Info.NESTED_COMMAND, nestedCommand);
-            hints.hasVirtualGroups = true;
-            parent.addLastChild(node);
-        }
-        
-        if (clause.isOptional()) {
-            node.setProperty(NodeConstants.Info.IS_OPTIONAL, Boolean.TRUE);
-            result = true;
-        }
-        
-        if (clause.isMakeDep()) {
-            node.setProperty(NodeConstants.Info.MAKE_DEP, Boolean.TRUE);
-        } else if (clause.isMakeNotDep()) {
-            node.setProperty(NodeConstants.Info.MAKE_NOT_DEP, Boolean.TRUE);
-        }
-
-        return result;
-    }
-
-	/**
-	 * Attach all criteria above the join nodes.  The optimizer will push these
-	 * criteria down to the appropriate source.
-	 * @param plan Existing plan, which joins all source groups
-	 * @param criteria Criteria from query
-	 * @return Updated tree
-	 */
-	private static PlanNode attachCriteria(PlanNode plan, Criteria criteria, boolean isHaving) {
-	    List crits = Criteria.separateCriteriaByAnd(criteria);
-	    
-	    for (final Iterator iterator = crits.iterator(); iterator.hasNext();) {
-            final Criteria crit = (Criteria)iterator.next();
-            PlanNode critNode = createSelectNode(crit, isHaving);
-            GenerateCanonical.attachLast(critNode, plan);
-            plan = critNode;
-        } 
-	    
-		return plan;
-	}
-
-    public static PlanNode createSelectNode(final Criteria crit, boolean isHaving) {
-        PlanNode critNode = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
-        critNode.setProperty(NodeConstants.Info.SELECT_CRITERIA, crit);
-        if (isHaving && !AggregateSymbolCollectorVisitor.getAggregates(crit, false).isEmpty()) {
-            critNode.setProperty(NodeConstants.Info.IS_HAVING, Boolean.TRUE);
-        }
-        // Add groups to crit node
-        critNode.addGroups(GroupsUsedByElementsVisitor.getGroups(crit));
-        critNode.addGroups(GroupsUsedByElementsVisitor.getGroups(critNode.getCorrelatedReferenceElements()));
-        return critNode;
-    }
-
-	/**
-	 * Attach a grouping node at top of tree.
-	 * @param plan Existing plan
-	 * @param groupBy Group by clause, which may be null
-	 * @return Updated plan
-	 */
-	private static PlanNode attachGrouping(PlanNode plan, Query query, PlanHints hints) {
-		PlanNode groupNode = NodeFactory.getNewNode(NodeConstants.Types.GROUP);
-
-		GroupBy groupBy = query.getGroupBy();
-		if(groupBy != null) {
-			groupNode.setProperty(NodeConstants.Info.GROUP_COLS, groupBy.getSymbols());
-            groupNode.addGroups(GroupsUsedByElementsVisitor.getGroups(groupBy));
-		}
-
-		GenerateCanonical.attachLast(groupNode, plan);
-        
-        // Mark in hints
-        hints.hasAggregates = true;
-        
-		return groupNode;
-	}
-
-    /**
-	 * Attach SORT node at top of tree.  The SORT may be pushed down to a source (or sources)
-	 * if possible by the optimizer.
-	 * @param plan Existing plan
-	 * @param orderBy Sort description from the query
-	 * @return Updated plan
-	 */
-	private static PlanNode attachSorting(PlanNode plan, OrderBy orderBy) {
-		PlanNode sortNode = NodeFactory.getNewNode(NodeConstants.Types.SORT);
-		
-		sortNode.setProperty(NodeConstants.Info.SORT_ORDER, orderBy.getVariables());
-		sortNode.setProperty(NodeConstants.Info.ORDER_TYPES, orderBy.getTypes());
-		if (orderBy.hasUnrelated()) {
-			sortNode.setProperty(Info.UNRELATED_SORT, true);
-		}
-		sortNode.addGroups(GroupsUsedByElementsVisitor.getGroups(orderBy));
-
-		GenerateCanonical.attachLast(sortNode, plan);
-		return sortNode;
-	}
-    
-    private static PlanNode attachTupleLimit(PlanNode plan, Limit limit, PlanHints hints) {
-        hints.hasLimit = true;
-        PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
-        
-        boolean attach = false;
-        if (limit.getOffset() != null) {
-            limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, limit.getOffset());
-            attach = true;
-        }
-        if (limit.getRowLimit() != null) {
-            limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, limit.getRowLimit());
-            attach = true;
-        }
-        if (attach) {
-            GenerateCanonical.attachLast(limitNode, plan);
-            plan = limitNode;
-        }
-        return plan;
-    }
-
-	/**
-	 * Attach DUP_REMOVE node at top of tree.  The DUP_REMOVE may be pushed down
-	 * to a source (or sources) if possible by the optimizer.
-	 * @param plan Existing plan
-	 * @return Updated plan
-	 */
-	private static PlanNode attachDupRemoval(PlanNode plan) {
-		PlanNode dupNode = NodeFactory.getNewNode(NodeConstants.Types.DUP_REMOVE);
-		GenerateCanonical.attachLast(dupNode, plan);
-		return dupNode;
-	}
-
-	private static PlanNode attachProject(PlanNode plan, Select select) {
-		PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
-		projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, select.getProjectedSymbols());
-
-		// Set groups
-		projectNode.addGroups(GroupsUsedByElementsVisitor.getGroups(select));
-
-		GenerateCanonical.attachLast(projectNode, plan);
-		return projectNode;
-	}
-
-	static final void attachLast(PlanNode parent, PlanNode child) {
-		if(child != null) {
-			parent.addLastChild(child);
-		}
-	}
-
-}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/MergeTreeNodeProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/MergeTreeNodeProcessor.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/MergeTreeNodeProcessor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,297 +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.optimizer.relational;
-
-import java.util.*;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.metadata.*;
-import com.metamatrix.query.optimizer.CommandTreeNode;
-import com.metamatrix.query.optimizer.CommandTreeProcessor;
-import com.metamatrix.query.optimizer.relational.plantree.*;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.*;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-
-/**
- * Merge neighboring relational nodes by combining canonical plans 
- */
-public class MergeTreeNodeProcessor implements CommandTreeProcessor {
-
-	/**
-	 * @see com.metamatrix.query.optimizer.CommandTreeProcessor#process(com.metamatrix.query.optimizer.CommandTreeNode)
-	 */
-	public CommandTreeNode process(CommandTreeNode node, QueryMetadataInterface metadata) 
-	throws QueryMetadataException, MetaMatrixComponentException {
-		MergeTreeNodeProcessor.processRecursive(node, metadata);
-		return node;
-	}
-
-	/**
-	 * Recursively, in depth-first order, examines the tree of CommandTreeNode
-	 * objects.  
-	 * @param node
-	 * @param metadata
-	 * @throws QueryMetadataException
-	 * @throws MetaMatrixComponentException
-	 */
-	private static void processRecursive(CommandTreeNode node, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException{
-
-        // process children
-		Iterator children = node.getChildren().iterator();
-		while (children.hasNext()) {
-			CommandTreeNode child = (CommandTreeNode) children.next();
-			processRecursive(child, metadata);
-		}
-        
-        // Use command-level metadata if necessary
-        QueryMetadataInterface fullMetadata = metadata;
-        Map commandMetadata = node.getCommand().getTemporaryMetadata();
-        if(commandMetadata != null && commandMetadata.size() > 0) {
-            fullMetadata = new TempMetadataAdapter(metadata, new TempMetadataStore(commandMetadata));    
-        }
-        
-		// process node	
-		List oldChildren = new ArrayList(node.getChildren());
-		int childCount = oldChildren.size();
-		for (int childIndex=0; childIndex < childCount; childIndex++){
-			CommandTreeNode child = (CommandTreeNode)oldChildren.get(childIndex);                        
-			checkNode(node, child, childIndex, fullMetadata);
-		}
-	}
-	
-	/**
-	 * Checks if parent and child both contain relational commands.  If so, 
-	 * they will be merged - unless the child node is a subquery of a
-	 * criteria or scalar subquery of parent command; these have to remain unmerged.
-	 * @param parent 
-	 * @param child
-	 * @param childIndex index of child in the parent's List of children
-	 * @param metadata source of metadata
-	 * @throws QueryMetadataException
-	 * @throws MetaMatrixComponentException
-	 */
-	private static void checkNode(CommandTreeNode parent, CommandTreeNode child, int childIndex, QueryMetadataInterface metadata) 
-	throws QueryMetadataException, MetaMatrixComponentException{
-		if (parent.getCommandType() == CommandTreeNode.TYPE_RELATIONAL_COMMAND &&
-		    child.getCommandType() == CommandTreeNode.TYPE_RELATIONAL_COMMAND){
-		    	
-			Command childCommand = child.getCommand();
-			Command parentCommand = parent.getCommand();
-			
-			for (SubqueryContainer crit : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(parentCommand)) {
-				if (crit.getCommand() == childCommand){
-					//Don't merge these two nodes
-					return;
-				}
-			}
-
-			removeChildNode(parent, child);
-			mergeRelationalPlans(parent, child, metadata);
-            mergeTempMetadata(childCommand, parentCommand);
-		}
-	}
-
-    /**
-     * Adds temp metadata (if any) of child command to temp metadata
-     * (if any) of parent command.
-     * @param childCommand 
-     * @param parentCommand
-     */
-    static void mergeTempMetadata(
-        Command childCommand,
-        Command parentCommand) {
-        Map childTempMetadata = childCommand.getTemporaryMetadata();
-        if (childTempMetadata != null && !childTempMetadata.isEmpty()){
-            // Add to parent temp metadata
-            Map parentTempMetadata = parentCommand.getTemporaryMetadata();
-            if (parentTempMetadata == null){
-                parentCommand.setTemporaryMetadata(new HashMap(childTempMetadata));
-            } else {
-                parentTempMetadata.putAll(childTempMetadata);
-            }
-        }
-    }
-	
-	/**
-	 * The canonical plan stored in child must be grafted onto the appropriate
-	 * source node in the canonical plan of parent - since the other previous
-     * children have already been merged, this must occur on the first eligible
-     * node.
-	 * @param parent a node containing a relational plan
-	 * @param child a node containing a relational plan
-	 * @param metadata source of metadata
-	 */
-	private static void mergeRelationalPlans(
-		CommandTreeNode parent,
-		CommandTreeNode child, 
-		QueryMetadataInterface metadata) 
-	throws QueryMetadataException, MetaMatrixComponentException {
-			
-		PlanNode parentPlan = (PlanNode)parent.getCanonicalPlan();
-		for (PlanNode sourceNode : NodeEditor.findAllNodes(parentPlan, NodeConstants.Types.SOURCE)) {
-            if(sourceNode.getChildCount()>0) {
-                continue;
-            }
-            
-            Command command = (Command)sourceNode.getProperty(NodeConstants.Info.NESTED_COMMAND);
-            /* Defect 13296 - Check for UPDATE PROCEDURE Source nodes, since an update procedure
-             * is also considered a virtual group, 
-             */
-            if(command == null || command.getType() == Command.TYPE_UPDATE_PROCEDURE) {
-                continue;
-            }
-
-			GroupSymbol sourceGroup = sourceNode.getGroups().iterator().next();
-			// Only source nodes representing virtual groups are eligible to
-			// be merged with.
-			if (metadata.isVirtualGroup(sourceGroup.getMetadataID())){
-                // Attach nodes
-                PlanNode childPlan = (PlanNode) child.getCanonicalPlan();
-				sourceNode.addFirstChild(childPlan);
-                
-                // Create symbol map from virtual group to child plan
-                List projectCols = child.getCommand().getProjectedSymbols();
-                sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(), projectCols));
-                
-                // Combine hints
-                combineHints(parent, child);
-                
-                // done        
-				break;
-			}
-		}
-	}
-    
-    /**
-     * Method combineHints.
-     * @param parent
-     * @param child
-     */
-    private static void combineHints(CommandTreeNode parent, CommandTreeNode child) {
-        PlanHints parentHints = (PlanHints) parent.getProperty(RelationalPlanner.HINTS);
-        PlanHints childHints = (PlanHints) child.getProperty(RelationalPlanner.HINTS);
-
-        if(childHints.hasCriteria) {
-            parentHints.hasCriteria = true;
-        }        
-        if(childHints.hasJoin) {
-            parentHints.hasJoin = true;
-        }        
-        if(childHints.hasSort) {
-            parentHints.hasSort = true;
-        }        
-        if(childHints.hasVirtualGroups) {
-            parentHints.hasVirtualGroups = true;
-        }        
-        if(childHints.isUpdate) {
-            parentHints.isUpdate = true;
-        }        
-        if(childHints.isUpdate) {
-            parentHints.isUpdate = true;
-        }      
-        if(childHints.hasSetQuery) {
-            parentHints.hasSetQuery = true;
-        }
-        if(childHints.hasAggregates) {
-            parentHints.hasAggregates = true;
-        }
-        if(childHints.makeDepGroups != null && childHints.makeDepGroups.size() > 0) {
-            if(parentHints.makeDepGroups == null) {
-                parentHints.makeDepGroups = childHints.makeDepGroups;
-            } else {
-                parentHints.makeDepGroups.addAll(childHints.makeDepGroups);
-            }    
-        }  
-        if(childHints.makeNotDepGroups != null && childHints.makeNotDepGroups.size() > 0) {
-            if(parentHints.makeNotDepGroups == null) {
-                parentHints.makeNotDepGroups = childHints.makeNotDepGroups;
-            } else {
-                parentHints.makeNotDepGroups.addAll(childHints.makeNotDepGroups);
-            }    
-        }  
-        if(childHints.hasLimit) {
-            parentHints.hasLimit = true;
-        }
-        if(childHints.hasOptionalJoin) {
-            parentHints.hasOptionalJoin = true;
-        }
-        if(childHints.hasRelationalProc) {
-            parentHints.hasRelationalProc = true;
-        }
-    }
-	        
-	/**
-	 * All of child's children become children of parent
-	 */
-	private static final void removeChildNode(CommandTreeNode parent, CommandTreeNode child) {
-		Assertion.isNotNull(parent);
-		Assertion.isNotNull(child);
-
-		// Get all existing children from parent
-		List newChildren = new LinkedList(parent.getChildren());
-
-		// get child's children
-		List orphans = child.getChildren();
-        
-		// Find the child being removed and replace with the child's children
-		ListIterator childIter = newChildren.listIterator();
-		while(childIter.hasNext()) {
-			CommandTreeNode possibleChild = (CommandTreeNode) childIter.next();        
-			if(possibleChild == child) {
-				childIter.remove();
-				child.setParent(null);
-				Iterator orphanIter = orphans.iterator();
-				while(orphanIter.hasNext()) {
-					CommandTreeNode orphan = (CommandTreeNode) orphanIter.next();
-					childIter.add(orphan);
-				}                
-			}
-		}
-        		
-		// Remove all children from parent and re-add from newChildren
-		Iterator removeIter = new LinkedList(parent.getChildren()).iterator();
-		while(removeIter.hasNext()) {
-			CommandTreeNode removeNode = (CommandTreeNode) removeIter.next();
-			parent.removeChild(removeNode);
-		}
-		parent.addChildren(newChildren);
-        		
-		// set new children's parent to new parent
-		Iterator iter = newChildren.iterator();
-		while(iter.hasNext()) {
-			CommandTreeNode newChild = (CommandTreeNode) iter.next();
-			newChild.setParent(parent);
-		}
-        
-		// Remove old children from child
-		removeIter = new LinkedList(child.getChildren()).iterator();
-		while(removeIter.hasNext()) {
-			child.removeChild((CommandTreeNode)removeIter.next());
-		}
-	}
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,8 +22,6 @@
 
 package com.metamatrix.query.optimizer.relational;
 
-import java.util.ArrayList;
-import java.util.List;
 
 public final class PlanHints { 
 
@@ -39,21 +37,12 @@
     // This flag indicates that the plan has a sort somewhere
     public boolean hasSort = false;
     
-    // flag added to indentify that the plan generated if for an updated
-    public boolean isUpdate = false;
-    
-    // List of groups to make dependent
-    public List makeDepGroups = null;
-    
     // flag indicates that the plan has a union somewhere
     public boolean hasSetQuery = false;
     
     // flag indicating that the plan has a grouping node somewhere
     public boolean hasAggregates = false;
         
-    // List of groups that should not be dependent
-    public List makeNotDepGroups = null;
-    
     public boolean hasLimit = false;
     
     public boolean hasOptionalJoin = false;
@@ -62,26 +51,6 @@
     
     public PlanHints() { }    
     
-    public void addMakeDepGroups(List groups) {
-        if(groups == null) {
-            return;
-        }
-        if(this.makeDepGroups == null) {
-            this.makeDepGroups = new ArrayList();
-        } 
-        this.makeDepGroups.addAll(groups);
-    }
-    
-    public void addMakeNotDepGroups(List groups) {
-        if(groups == null) {
-            return;
-        }
-        if(this.makeNotDepGroups == null) {
-            this.makeNotDepGroups = new ArrayList();
-        } 
-        this.makeNotDepGroups.addAll(groups);
-    }
-    
     public String toString(){
     	return "PlanHints"; //$NON-NLS-1$
     }

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -24,39 +24,81 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
+import org.teiid.dqp.internal.process.Request;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.QueryValidatorException;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.core.id.IDGenerator;
+import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.analysis.QueryAnnotation;
 import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataID;
 import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.CommandTreeNode;
+import com.metamatrix.query.optimizer.QueryOptimizer;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
 import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
+import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
 import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
+import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
 import com.metamatrix.query.optimizer.relational.rules.RuleConstants;
+import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.processor.ProcessorPlan;
 import com.metamatrix.query.processor.relational.RelationalPlan;
+import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
+import com.metamatrix.query.resolver.QueryResolver;
+import com.metamatrix.query.resolver.util.BindVariableVisitor;
+import com.metamatrix.query.rewriter.QueryRewriter;
 import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.lang.From;
+import com.metamatrix.query.sql.lang.FromClause;
+import com.metamatrix.query.sql.lang.GroupBy;
+import com.metamatrix.query.sql.lang.Insert;
+import com.metamatrix.query.sql.lang.JoinPredicate;
+import com.metamatrix.query.sql.lang.JoinType;
+import com.metamatrix.query.sql.lang.Limit;
+import com.metamatrix.query.sql.lang.Option;
+import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
+import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.QueryCommand;
+import com.metamatrix.query.sql.lang.Select;
+import com.metamatrix.query.sql.lang.SetQuery;
+import com.metamatrix.query.sql.lang.StoredProcedure;
 import com.metamatrix.query.sql.lang.SubqueryContainer;
+import com.metamatrix.query.sql.lang.SubqueryFromClause;
+import com.metamatrix.query.sql.lang.UnaryFromClause;
+import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 import com.metamatrix.query.sql.symbol.Reference;
 import com.metamatrix.query.sql.symbol.SingleElementSymbol;
 import com.metamatrix.query.sql.util.SymbolMap;
+import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
 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.sql.visitor.ValueIteratorProviderCollectorVisitor;
 import com.metamatrix.query.util.CommandContext;
 import com.metamatrix.query.util.ErrorMessageKeys;
 import com.metamatrix.query.util.LogConstants;
+import com.metamatrix.query.validator.ValidationVisitor;
 
 /**
  * This class generates a relational plan for query execution.  The output of
@@ -64,35 +106,24 @@
  * object - this object then becomes the input to
  * {@link PlanToProcessConverter PlanToProcessConverter}
  * to  produce a
- * {@link com. metamatrix.query.processor.relational.RelationalPlan RelationalPlan}.
+ * {@link com.metamatrix.query.processor.relational.RelationalPlan RelationalPlan}.
  */
 public class RelationalPlanner implements CommandPlanner {
+	
+	private AnalysisRecord analysisRecord;
+	private Command parentCommand;
+	private IDGenerator idGenerator;
+	private CommandContext context;
+	private CapabilitiesFinder capFinder;
+	private QueryMetadataInterface metadata;
+	private PlanHints hints = new PlanHints();
+	private Option option;
 
     /**
-	 * Key for a {@link PlanHints PlanHints} object 
-	 */
-	public static final Integer HINTS = Integer.valueOf(0);
-	public static final Integer VARIABLE_CONTEXTS = Integer.valueOf(1);
-
-	/**
-     * @see com.metamatrix.query.optimizer.CommandPlanner#generateCanonical(com.metamatrix.query.optimizer.CommandTreeNode, boolean)
-     */
-    public void generateCanonical(CommandTreeNode node, QueryMetadataInterface metadata, AnalysisRecord analysisRecord, CommandContext context)
-        throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-
-        // Create canonical plan for this command
-        Command command = node.getCommand();
-
-        PlanHints hints = (PlanHints)node.getProperty(RelationalPlanner.HINTS);
-        PlanNode canonicalPlan = GenerateCanonical.generatePlan(command, hints, metadata);
-        node.setCanonicalPlan(canonicalPlan);
-    }
-
-    /**
      * @see com.metamatrix.query.optimizer.CommandPlanner#optimize(com.metamatrix.query.optimizer.CommandTreeNode, java.util.Map, com.metamatrix.query.metadata.QueryMetadataInterface, boolean)
      */
     public ProcessorPlan optimize(
-        CommandTreeNode node,
+        Command command,
         IDGenerator idGenerator,
         QueryMetadataInterface metadata,
         CapabilitiesFinder capFinder,
@@ -101,44 +132,37 @@
             QueryPlannerException,
             QueryMetadataException,
             MetaMatrixComponentException {
+    	initialize(command, idGenerator, metadata, capFinder, analysisRecord, context);
 
+        boolean debug = analysisRecord.recordDebug();
+		if(debug) {
+            analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
+            analysisRecord.println("GENERATE CANONICAL: \n" + command); //$NON-NLS-1$
+		}   
+        PlanNode plan;
+		try {
+			plan = generatePlan(command);
+		} catch (QueryResolverException e) {
+			throw new QueryPlannerException(e, e.getMessage());
+		} catch (QueryValidatorException e) {
+			throw new QueryPlannerException(e, e.getMessage());
+		}
 
-        // Distribute childPlans into relational plan
-        PlanNode plan = (PlanNode)node.getCanonicalPlan();
-        connectChildPlans(plan);
+		if(debug) {
+            analysisRecord.println("\nCANONICAL PLAN: \n" + plan); //$NON-NLS-1$
+		} 
 
-        // Check whether command has virtual groups
-        Command command = node.getCommand();
-        PlanHints hints = (PlanHints)node.getProperty(RelationalPlanner.HINTS);
-
-        // Distribute make dependent hints as necessary
-        if(hints.makeDepGroups != null) {
-            RelationalPlanner.distributeDependentHints(hints.makeDepGroups, plan, metadata, NodeConstants.Info.MAKE_DEP);
-        }
-        if (hints.makeNotDepGroups != null) {
-            RelationalPlanner.distributeDependentHints(hints.makeNotDepGroups, plan, metadata, NodeConstants.Info.MAKE_NOT_DEP);
-        }
-
         // Connect ProcessorPlan to SubqueryContainer (if any) of SELECT or PROJECT nodes
-    	if (node.getChildCount() > 0) {
-    		connectSubqueryContainers(plan);
-    	}
+		connectSubqueryContainers(plan); //TODO: merge with node creation
         
         // Set top column information on top node
-        List projectCols = command.getProjectedSymbols();
-        List<SingleElementSymbol> topCols = new ArrayList<SingleElementSymbol>(projectCols.size());
-        Iterator projectIter = projectCols.iterator();
-        while(projectIter.hasNext()) {
-            SingleElementSymbol symbol = (SingleElementSymbol) projectIter.next();
-            topCols.add( (SingleElementSymbol)symbol.clone() );
-        }
+        List<SingleElementSymbol> topCols = QueryRewriter.deepClone(command.getProjectedSymbols(), SingleElementSymbol.class);
 
         // Build rule set based on hints
         RuleStack rules = RelationalPlanner.buildRules(hints);
 
         // Run rule-based optimizer
-        plan = RelationalPlanner.executeRules(rules, plan, metadata, capFinder, analysisRecord, context);
-        node.setCanonicalPlan(plan);
+        plan = executeRules(rules, plan);
 
         PlanToProcessConverter planToProcessConverter = null;
         if (context != null) {
@@ -155,7 +179,18 @@
         return result;
     }
 
-    private static void connectSubqueryContainers(PlanNode plan) {
+	public void initialize(Command command, IDGenerator idGenerator,
+			QueryMetadataInterface metadata, CapabilitiesFinder capFinder,
+			AnalysisRecord analysisRecord, CommandContext context) {
+		this.parentCommand = command;
+    	this.idGenerator = idGenerator;
+    	this.metadata = metadata;
+    	this.capFinder = capFinder;
+    	this.analysisRecord = analysisRecord;
+    	this.context = context;
+	}
+
+    private void connectSubqueryContainers(PlanNode plan) throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
         Set<GroupSymbol> groupSymbols = getGroupSymbols(plan);
 
         for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.PROJECT | NodeConstants.Types.SELECT | NodeConstants.Types.JOIN)) {
@@ -170,6 +205,8 @@
             for (SubqueryContainer container : subqueryContainers) {
                 ArrayList<Reference> correlatedReferences = new ArrayList<Reference>(); 
                 Command subCommand = container.getCommand();
+                ProcessorPlan procPlan = QueryOptimizer.optimizePlan(subCommand, metadata, idGenerator, capFinder, analysisRecord, context);
+                subCommand.setProcessorPlan(procPlan);
                 CorrelatedReferenceCollectorVisitor.collectReferences(subCommand, localGroupSymbols, correlatedReferences);
                 if (!correlatedReferences.isEmpty()) {
 	                SymbolMap map = new SymbolMap();
@@ -192,23 +229,6 @@
 	}
 
     /**
-     * Method connectChildPlans.
-     * @param plan
-     * @param childPlans
-     * @param metadata
-     * @return Map <Command - child ProcessorPlan>
-     */
-    private static void connectChildPlans(PlanNode plan) {
-        // Find all nodes that need subcommands attached
-        for (PlanNode source : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) {
-            Command nodeCommand = (Command)source.getProperty(NodeConstants.Info.NESTED_COMMAND);
-            if(nodeCommand != null && nodeCommand.getProcessorPlan() != null) {
-                source.setProperty(NodeConstants.Info.PROCESSOR_PLAN, nodeCommand.getProcessorPlan());
-            }
-        }
-    }
-
-    /**
      * Distribute and "make (not) dependent" hints specified in the query into the
      * fully resolved query plan.  This is done after virtual group resolution so
      * that all groups in the plan are known.  The hint is attached to all SOURCE
@@ -216,43 +236,39 @@
      * @param groups List of groups (Strings) to be made dependent
      * @param plan The canonical plan
      */
-    private static void distributeDependentHints(Collection groups, PlanNode plan, QueryMetadataInterface metadata, NodeConstants.Info hintProperty)
+    private static void distributeDependentHints(Collection<String> groups, PlanNode plan, QueryMetadataInterface metadata, NodeConstants.Info hintProperty)
         throws QueryMetadataException, MetaMatrixComponentException {
     
-        if(groups != null && groups.size() > 0) {
-            // Get all source nodes
-            List nodes = NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE);
-    
-            // Walk through each dependent group hint and
-            // attach to the correct source node
-            Iterator groupIter = groups.iterator();
-            while(groupIter.hasNext()) {
-                String groupName = (String) groupIter.next();
-    
-                // Walk through nodes and apply hint to all that match group name
-                boolean appliedHint = applyHint(nodes, groupName, hintProperty);
-    
+        if(groups == null || groups.isEmpty()) {
+        	return;
+        }
+        // Get all source nodes
+        List<PlanNode> nodes = NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE);
+
+        // Walk through each dependent group hint and
+        // attach to the correct source node
+        for (String groupName : groups) {
+            // Walk through nodes and apply hint to all that match group name
+            boolean appliedHint = applyHint(nodes, groupName, hintProperty);
+
+            if(! appliedHint) {
+                //check if it is partial group name
+                Collection groupNames = metadata.getGroupsForPartialName(groupName);
+                if(groupNames.size() == 1) {
+                    groupName = (String)groupNames.iterator().next();
+                    appliedHint = applyHint(nodes, groupName, hintProperty);
+                }
+                
                 if(! appliedHint) {
-                    //check if it is partial group name
-                    Collection groupNames = metadata.getGroupsForPartialName(groupName);
-                    if(groupNames.size() == 1) {
-                        groupName = (String)groupNames.iterator().next();
-                        appliedHint = applyHint(nodes, groupName, hintProperty);
-                    }
-                    
-                    if(! appliedHint) {
-                        LogManager.logWarning(LogConstants.CTX_QUERY_PLANNER, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0010, groupName));
-                    }
+                    LogManager.logWarning(LogConstants.CTX_QUERY_PLANNER, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0010, groupName));
                 }
             }
         }
     }
     
-    private static boolean applyHint(List nodes, String groupName, NodeConstants.Info hintProperty) {
+    private static boolean applyHint(List<PlanNode> nodes, String groupName, NodeConstants.Info hintProperty) {
         boolean appliedHint = false;
-        Iterator nodeIter = nodes.iterator();
-        while(nodeIter.hasNext()) {
-            PlanNode node = (PlanNode) nodeIter.next();
+        for (PlanNode node : nodes) {
             GroupSymbol nodeGroup = node.getGroups().iterator().next();
             
             String sDefinition = nodeGroup.getDefinition();
@@ -328,7 +344,7 @@
         return rules;
     }
 
-    private static PlanNode executeRules(RuleStack rules, PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
+    private PlanNode executeRules(RuleStack rules, PlanNode plan)
         throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
 
         boolean debug = analysisRecord.recordDebug();
@@ -349,4 +365,609 @@
         }
         return plan;
     }
-}
+	
+	public PlanNode generatePlan(Command cmd) throws QueryPlannerException, QueryResolverException, QueryValidatorException, MetaMatrixComponentException {
+		//cascade the option clause nocache
+		Option savedOption = option;
+		option = cmd.getOption();
+        if (option == null) {
+        	if (savedOption != null) {
+        		option = savedOption;
+        	} 
+        } else if (savedOption != null && savedOption.isNoCache()) { //merge no cache settings
+    		if (savedOption.getNoCacheGroups() == null || savedOption.getNoCacheGroups().isEmpty()) {
+    			if (option.getNoCacheGroups() != null) {
+    				option.getNoCacheGroups().clear(); // full no cache
+    			}
+    		} else if (option.getNoCacheGroups() != null && !option.getNoCacheGroups().isEmpty()) {
+    			for (String noCache : savedOption.getNoCacheGroups()) {
+					option.addNoCacheGroup(noCache); // only groups
+				}
+    		}
+    		option.setNoCache(true);
+        }
+		
+		PlanNode result = null;
+		switch (cmd.getType()) {
+		case Command.TYPE_QUERY:
+			result = createQueryPlan((QueryCommand)cmd);
+			break;
+		case Command.TYPE_INSERT:
+		case Command.TYPE_UPDATE:
+		case Command.TYPE_DELETE:
+		case Command.TYPE_CREATE:
+		case Command.TYPE_DROP:
+			result = createUpdatePlan(cmd);
+			break;
+		case Command.TYPE_STORED_PROCEDURE:
+			result = createStoredProcedurePlan((StoredProcedure)cmd);
+			break;
+		default:
+			throw new AssertionError("Invalid command type"); //$NON-NLS-1$
+		}
+        // Distribute make dependent hints as necessary
+        if (cmd.getOption() != null) {
+	        if(cmd.getOption().getDependentGroups() != null) {
+	            distributeDependentHints(cmd.getOption().getDependentGroups(), result, metadata, NodeConstants.Info.MAKE_DEP);
+	        }
+	        if (cmd.getOption().getNotDependentGroups() != null) {
+	            distributeDependentHints(cmd.getOption().getNotDependentGroups(), result, metadata, NodeConstants.Info.MAKE_NOT_DEP);
+	        }
+        }
+        this.option = savedOption;
+        return result;
+	}
+
+	PlanNode createUpdatePlan(Command command) throws QueryPlannerException, MetaMatrixComponentException, QueryResolverException, QueryValidatorException {
+        // Create top project node - define output columns for stored query / procedure
+        PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
+
+        Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, false);
+        projectNode.addGroups(groups);
+
+        // Set output columns
+        List<SingleElementSymbol> cols = command.getProjectedSymbols();
+        projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, cols);
+
+        // Define source of data for stored query / procedure
+        PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+        sourceNode.setProperty(NodeConstants.Info.ATOMIC_REQUEST, command);
+        sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, command);
+        if (command instanceof ProcedureContainer) {
+        	ProcedureContainer container = (ProcedureContainer)command;
+        	addNestedProcedure(sourceNode, container);
+        }
+        sourceNode.addGroups(groups);
+
+        attachLast(projectNode, sourceNode);
+
+        //for INTO query, attach source and project nodes
+        if(command instanceof Insert){
+        	Insert insert = (Insert)command;
+        	if (insert.getQueryExpression() != null) {
+	            PlanNode plan = createQueryPlan(insert.getQueryExpression());
+	            attachLast(sourceNode, plan);
+	            mergeTempMetadata(insert.getQueryExpression(), insert);
+	            projectNode.setProperty(NodeConstants.Info.INTO_GROUP, insert.getGroup());
+        	}
+        }
+        
+        return projectNode;
+	}
+
+	private void addNestedProcedure(PlanNode sourceNode,
+			ProcedureContainer container) throws MetaMatrixComponentException,
+			QueryMetadataException, QueryResolverException,
+			QueryValidatorException, QueryPlannerException {
+		//plan any subqueries in criteria/parameters/values
+		for (SubqueryContainer subqueryContainer : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(container)) {
+    		ProcessorPlan plan = QueryOptimizer.optimizePlan(subqueryContainer.getCommand(), metadata, null, capFinder, analysisRecord, context);
+    		subqueryContainer.getCommand().setProcessorPlan(plan);
+		}
+		
+		String cacheString = "transformation/" + container.getClass().getSimpleName(); //$NON-NLS-1$
+		Command c = (Command)metadata.getFromMetadataCache(container.getGroup().getMetadataID(), cacheString);
+		if (c == null) {
+			c = QueryResolver.expandCommand(container, metadata, analysisRecord);
+			if (c != null) {
+		        Request.validateWithVisitor(new ValidationVisitor(), metadata, c, true);
+		        metadata.addToMetadataCache(container.getGroup().getMetadataID(), cacheString, c.clone());
+			}
+		} else {
+			c = (Command)c.clone();
+			if (c instanceof CreateUpdateProcedureCommand) {
+				((CreateUpdateProcedureCommand)c).setUserCommand(container);
+			}
+		}
+		if (c != null) {
+		    c = QueryRewriter.rewrite(c, metadata, context);
+		    addNestedCommand(sourceNode, container.getGroup(), container, c, false);
+		}
+	}
+
+    PlanNode createStoredProcedurePlan(StoredProcedure storedProc) throws QueryPlannerException, QueryResolverException, QueryValidatorException, QueryMetadataException, MetaMatrixComponentException {
+        // Create top project node - define output columns for stored query / procedure
+        PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
+
+        // Set output columns
+        List cols = storedProc.getProjectedSymbols();
+        projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, cols);
+
+        // Define source of data for stored query / procedure
+        PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+        sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, storedProc);
+    	addNestedProcedure(sourceNode, storedProc);
+        
+        hints.hasRelationalProc |= storedProc.isProcedureRelational();
+
+        // Set group on source node
+        sourceNode.addGroup(storedProc.getGroup());
+
+        attachLast(projectNode, sourceNode);
+
+        return projectNode;
+    }
+
+	PlanNode createQueryPlan(QueryCommand command)
+		throws QueryPlannerException, MetaMatrixComponentException, QueryResolverException, QueryValidatorException {
+        // Build canonical plan
+    	PlanNode node = null;
+        if(command instanceof Query) {
+            node = createQueryPlan((Query) command);
+        } else {
+            hints.hasSetQuery = true;
+            SetQuery query = (SetQuery)command;
+            PlanNode leftPlan = createQueryPlan( query.getLeftQuery());
+            PlanNode rightPlan = createQueryPlan( query.getRightQuery());
+
+            node = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
+            node.setProperty(NodeConstants.Info.SET_OPERATION, query.getOperation());
+            node.setProperty(NodeConstants.Info.USE_ALL, query.isAll());
+            
+            attachLast(node, leftPlan);
+            attachLast(node, rightPlan);
+        }
+        
+		if(command.getOrderBy() != null) {
+			node = attachSorting(node, command.getOrderBy());
+            hints.hasSort = true;
+		}
+
+        if (command.getLimit() != null) {
+            node = attachTupleLimit(node, command.getLimit(), hints);
+        }
+        
+        return node;
+    }
+
+    private PlanNode createQueryPlan(Query query)
+		throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException, QueryResolverException, QueryValidatorException {
+
+        PlanNode plan = null;
+
+        if(query.getFrom() != null){
+            FromClause fromClause = mergeClauseTrees(query.getFrom());
+            
+            PlanNode dummyRoot = new PlanNode();
+            
+    		buildTree(fromClause, dummyRoot);
+            
+            plan = dummyRoot.getFirstChild();
+            
+            hints.hasJoin |= plan.getType() == NodeConstants.Types.JOIN;
+
+    		// Attach criteria on top
+    		if(query.getCriteria() != null) {
+    			plan = attachCriteria(plan, query.getCriteria(), false);
+                hints.hasCriteria = true;
+    		}
+
+    		// Attach grouping node on top
+    		if(query.getGroupBy() != null || query.getHaving() != null || !AggregateSymbolCollectorVisitor.getAggregates(query.getSelect(), false).isEmpty()) {
+    			plan = attachGrouping(plan, query, hints);
+    		}
+
+    		// Attach having criteria node on top
+    		if(query.getHaving() != null) {
+    			plan = attachCriteria(plan, query.getHaving(), true);
+                hints.hasCriteria = true;
+    		}
+            
+        }
+
+		// Attach project on top
+		plan = attachProject(plan, query.getSelect());
+
+		// Attach dup removal on top
+		if(query.getSelect().isDistinct()) {
+			plan = attachDupRemoval(plan);
+		}
+
+		return plan;
+	}
+
+    /**
+     * Merges the from clause into a single join predicate if there are more than 1 from clauses
+     */
+    private static FromClause mergeClauseTrees(From from) {
+        List clauses = from.getClauses();
+        
+        while (clauses.size() > 1) {
+            FromClause first = (FromClause)from.getClauses().remove(0);
+            FromClause second = (FromClause)from.getClauses().remove(0);
+            JoinPredicate jp = new JoinPredicate(first, second, JoinType.JOIN_CROSS);
+            clauses.add(0, jp);
+        }
+        
+        return (FromClause)clauses.get(0);
+    }
+    
+    /**
+     * Build a join plan based on the structure in a clause.  These structures should be
+     * essentially the same tree, but with different objects and details.
+     * @param clause Clause to build tree from
+     * @param parent Parent node to attach join node structure to
+     * @param sourceMap Map of group to source node, used for connecting children to join plan
+     * @param markJoinsInternal Flag saying whether joins built in this method should be marked
+     * as internal
+     * @throws MetaMatrixComponentException 
+     * @throws QueryMetadataException 
+     * @throws QueryValidatorException 
+     * @throws QueryResolverException 
+     */
+    void buildTree(FromClause clause, PlanNode parent)
+        throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException, QueryResolverException, QueryValidatorException {
+        
+        PlanNode node = null;
+        
+        if(clause instanceof UnaryFromClause) {
+            // No join required
+            UnaryFromClause ufc = (UnaryFromClause)clause;
+            GroupSymbol group = ufc.getGroup();
+            if (metadata.isVirtualGroup(group.getMetadataID())) {
+            	hints.hasVirtualGroups = true;
+            }
+            Command nestedCommand = ufc.getExpandedCommand();
+            if (nestedCommand == null && !group.isTempGroupSymbol() && !group.isProcedure() 
+            		&& (!(group.getMetadataID() instanceof TempMetadataID) || metadata.getVirtualPlan(group.getMetadataID()) != null)
+        	        && (metadata.isVirtualGroup(group.getMetadataID()))) { 
+            	//must be a view layer
+            	nestedCommand = resolveVirtualGroup(group);
+            }
+            node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+            node.addGroup(group);
+            if (nestedCommand != null) {
+            	addNestedCommand(node, group, nestedCommand, nestedCommand, true);
+            }
+            parent.addLastChild(node);
+        } else if(clause instanceof JoinPredicate) {
+            JoinPredicate jp = (JoinPredicate) clause;
+
+            // Set up new join node corresponding to this join predicate
+            node = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
+            node.setProperty(NodeConstants.Info.JOIN_TYPE, jp.getJoinType());
+            node.setProperty(NodeConstants.Info.JOIN_STRATEGY, JoinStrategyType.NESTED_LOOP);
+            node.setProperty(NodeConstants.Info.JOIN_CRITERIA, jp.getJoinCriteria());
+            
+            if (jp.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
+            	hints.hasOptionalJoin = true;
+            }
+         
+            // Attach join node to parent
+            parent.addLastChild(node);
+
+            // Handle each child
+            FromClause[] clauses = new FromClause[] {jp.getLeftClause(), jp.getRightClause()};
+            for(int i=0; i<2; i++) {
+                buildTree(clauses[i], node);
+
+                // Add groups to joinNode
+                for (PlanNode child : node.getChildren()) {
+                    node.addGroups(child.getGroups());
+                }
+            }
+        } else if (clause instanceof SubqueryFromClause) {
+            SubqueryFromClause sfc = (SubqueryFromClause)clause;
+            GroupSymbol group = sfc.getGroupSymbol();
+            Command nestedCommand = sfc.getCommand();
+            node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+            node.addGroup(group);
+            addNestedCommand(node, group, nestedCommand, nestedCommand, true);
+            hints.hasVirtualGroups = true;
+            parent.addLastChild(node);
+        }
+        
+        if (clause.isOptional()) {
+            node.setProperty(NodeConstants.Info.IS_OPTIONAL, Boolean.TRUE);
+            hints.hasOptionalJoin = true;
+        }
+        
+        if (clause.isMakeDep()) {
+            node.setProperty(NodeConstants.Info.MAKE_DEP, Boolean.TRUE);
+        } else if (clause.isMakeNotDep()) {
+            node.setProperty(NodeConstants.Info.MAKE_NOT_DEP, Boolean.TRUE);
+        }
+    }
+
+	private void addNestedCommand(PlanNode node,
+			GroupSymbol group, Command nestedCommand, Command toPlan, boolean merge) throws QueryPlannerException,
+			MetaMatrixComponentException, QueryResolverException,
+			QueryValidatorException, QueryMetadataException {
+		if (nestedCommand instanceof QueryCommand) {
+        	QueryCommand queryCommand = (QueryCommand)nestedCommand;
+        	if (queryCommand.getLimit() == null) {
+        		queryCommand.setOrderBy(null);
+        	}
+        }
+		node.setProperty(NodeConstants.Info.NESTED_COMMAND, nestedCommand);
+		// Create symbol map from virtual group to child plan
+		List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
+		node.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(group, projectCols));
+		
+		if (merge && nestedCommand instanceof Query && QueryResolver.isXMLQuery((Query)nestedCommand, metadata)) {
+			merge = false;
+		}
+
+		if (merge) {
+			mergeTempMetadata(nestedCommand, parentCommand);
+		    PlanNode childRoot = generatePlan(nestedCommand);
+		    node.addFirstChild(childRoot);
+		} else {
+			QueryMetadataInterface actualMetadata = metadata;
+			if (actualMetadata instanceof TempMetadataAdapter) {
+				actualMetadata = ((TempMetadataAdapter)metadata).getMetadata();
+			}
+			ProcessorPlan plan = QueryOptimizer.optimizePlan(toPlan, actualMetadata, null, capFinder, analysisRecord, context);
+		    node.setProperty(NodeConstants.Info.PROCESSOR_PLAN, plan);
+		}
+	}
+
+	/**
+	 * Attach all criteria above the join nodes.  The optimizer will push these
+	 * criteria down to the appropriate source.
+	 * @param plan Existing plan, which joins all source groups
+	 * @param criteria Criteria from query
+	 * @return Updated tree
+	 */
+	private static PlanNode attachCriteria(PlanNode plan, Criteria criteria, boolean isHaving) {
+	    List<Criteria> crits = Criteria.separateCriteriaByAnd(criteria);
+	    
+	    for (Criteria crit : crits) {
+            PlanNode critNode = createSelectNode(crit, isHaving);
+            attachLast(critNode, plan);
+            plan = critNode;
+        } 
+	    
+		return plan;
+	}
+
+    public static PlanNode createSelectNode(final Criteria crit, boolean isHaving) {
+        PlanNode critNode = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
+        critNode.setProperty(NodeConstants.Info.SELECT_CRITERIA, crit);
+        if (isHaving && !AggregateSymbolCollectorVisitor.getAggregates(crit, false).isEmpty()) {
+            critNode.setProperty(NodeConstants.Info.IS_HAVING, Boolean.TRUE);
+        }
+        // Add groups to crit node
+        critNode.addGroups(GroupsUsedByElementsVisitor.getGroups(crit));
+        critNode.addGroups(GroupsUsedByElementsVisitor.getGroups(critNode.getCorrelatedReferenceElements()));
+        return critNode;
+    }
+
+	/**
+	 * Attach a grouping node at top of tree.
+	 * @param plan Existing plan
+	 * @param groupBy Group by clause, which may be null
+	 * @return Updated plan
+	 */
+	private static PlanNode attachGrouping(PlanNode plan, Query query, PlanHints hints) {
+		PlanNode groupNode = NodeFactory.getNewNode(NodeConstants.Types.GROUP);
+
+		GroupBy groupBy = query.getGroupBy();
+		if(groupBy != null) {
+			groupNode.setProperty(NodeConstants.Info.GROUP_COLS, groupBy.getSymbols());
+            groupNode.addGroups(GroupsUsedByElementsVisitor.getGroups(groupBy));
+		}
+
+		attachLast(groupNode, plan);
+        
+        // Mark in hints
+        hints.hasAggregates = true;
+        
+		return groupNode;
+	}
+
+    /**
+	 * Attach SORT node at top of tree.  The SORT may be pushed down to a source (or sources)
+	 * if possible by the optimizer.
+	 * @param plan Existing plan
+	 * @param orderBy Sort description from the query
+	 * @return Updated plan
+	 */
+	private static PlanNode attachSorting(PlanNode plan, OrderBy orderBy) {
+		PlanNode sortNode = NodeFactory.getNewNode(NodeConstants.Types.SORT);
+		
+		sortNode.setProperty(NodeConstants.Info.SORT_ORDER, orderBy.getVariables());
+		sortNode.setProperty(NodeConstants.Info.ORDER_TYPES, orderBy.getTypes());
+		if (orderBy.hasUnrelated()) {
+			sortNode.setProperty(Info.UNRELATED_SORT, true);
+		}
+		sortNode.addGroups(GroupsUsedByElementsVisitor.getGroups(orderBy));
+
+		attachLast(sortNode, plan);
+		return sortNode;
+	}
+    
+    private static PlanNode attachTupleLimit(PlanNode plan, Limit limit, PlanHints hints) {
+        hints.hasLimit = true;
+        PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
+        
+        boolean attach = false;
+        if (limit.getOffset() != null) {
+            limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, limit.getOffset());
+            attach = true;
+        }
+        if (limit.getRowLimit() != null) {
+            limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, limit.getRowLimit());
+            attach = true;
+        }
+        if (attach) {
+            attachLast(limitNode, plan);
+            plan = limitNode;
+        }
+        return plan;
+    }
+
+	/**
+	 * Attach DUP_REMOVE node at top of tree.  The DUP_REMOVE may be pushed down
+	 * to a source (or sources) if possible by the optimizer.
+	 * @param plan Existing plan
+	 * @return Updated plan
+	 */
+	private static PlanNode attachDupRemoval(PlanNode plan) {
+		PlanNode dupNode = NodeFactory.getNewNode(NodeConstants.Types.DUP_REMOVE);
+		attachLast(dupNode, plan);
+		return dupNode;
+	}
+
+	private static PlanNode attachProject(PlanNode plan, Select select) {
+		PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
+		projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, select.getProjectedSymbols());
+
+		// Set groups
+		projectNode.addGroups(GroupsUsedByElementsVisitor.getGroups(select));
+
+		attachLast(projectNode, plan);
+		return projectNode;
+	}
+
+	static final void attachLast(PlanNode parent, PlanNode child) {
+		if(child != null) {
+			parent.addLastChild(child);
+		}
+	}
+
+    /**
+     * Adds temp metadata (if any) of child command to temp metadata
+     * (if any) of parent command.
+     * @param childCommand 
+     * @param parentCommand
+     */
+    static void mergeTempMetadata(
+        Command childCommand,
+        Command parentCommand) {
+        Map childTempMetadata = childCommand.getTemporaryMetadata();
+        if (childTempMetadata != null && !childTempMetadata.isEmpty()){
+            // Add to parent temp metadata
+            Map parentTempMetadata = parentCommand.getTemporaryMetadata();
+            if (parentTempMetadata == null){
+                parentCommand.setTemporaryMetadata(new HashMap(childTempMetadata));
+            } else {
+                parentTempMetadata.putAll(childTempMetadata);
+            }
+        }
+    }
+	
+    private Command resolveVirtualGroup(GroupSymbol virtualGroup)
+    throws QueryMetadataException, MetaMatrixComponentException, QueryResolverException, QueryValidatorException {
+    	
+        QueryNode qnode = null;
+        
+        Object metadataID = virtualGroup.getMetadataID();
+        boolean noCache = false;
+        boolean isMaterializedGroup = metadata.hasMaterialization(metadataID);
+        String cacheString = "select"; //$NON-NLS-1$
+        if( isMaterializedGroup) {
+            noCache = isNoCacheGroup(metadata, metadataID, option);
+        	if(noCache){
+        		//not use cache
+        		qnode = metadata.getVirtualPlan(metadataID);
+        		String matTableName = metadata.getFullName(metadata.getMaterialization(metadataID));
+        		recordMaterializationTableAnnotation(virtualGroup, analysisRecord, matTableName, "SimpleQueryResolver.materialized_table_not_used"); //$NON-NLS-1$
+        	}else{
+                // Default query for a materialized group - go to cached table
+                String groupName = metadata.getFullName(metadataID);
+                String matTableName = metadata.getFullName(metadata.getMaterialization(metadataID));
+                qnode = new QueryNode(groupName, "SELECT * FROM " + matTableName); //$NON-NLS-1$
+                cacheString = "matview"; //$NON-NLS-1$
+                recordMaterializationTableAnnotation(virtualGroup, analysisRecord, matTableName, "SimpleQueryResolver.Query_was_redirected_to_Mat_table"); //$NON-NLS-1$                
+        	}
+        } else {
+            // Not a materialized view - query the primary transformation
+            qnode = metadata.getVirtualPlan(metadataID);            
+        }
+
+        Command result = (Command)metadata.getFromMetadataCache(virtualGroup.getMetadataID(), "transformation/" + cacheString); //$NON-NLS-1$
+        if (result != null) {
+        	result = (Command)result.clone();
+        } else {
+        	//parse, resolve, validate
+        	result = convertToSubquery(qnode, metadata);
+	        QueryResolver.resolveCommand(result, Collections.EMPTY_MAP, metadata, analysisRecord);
+	        Request.validateWithVisitor(new ValidationVisitor(), metadata, result, true);
+	        metadata.addToMetadataCache(virtualGroup.getMetadataID(), "transformation/" + cacheString, result.clone()); //$NON-NLS-1$
+        }        
+        return QueryRewriter.rewrite(result, metadata, context);
+    }
+
+    public static boolean isNoCacheGroup(QueryMetadataInterface metadata,
+                                          Object metadataID,
+                                          Option option) throws QueryMetadataException,
+                                                        MetaMatrixComponentException {
+        if(option == null || !option.isNoCache()){
+            return false;
+        }
+    	if(option.getNoCacheGroups() == null || option.getNoCacheGroups().isEmpty()){
+    		//only OPTION NOCACHE, no group specified
+    		return true;
+    	}       
+    	for (String groupName : option.getNoCacheGroups()) {
+            try {
+                Object noCacheGroupID = metadata.getGroupID(groupName);
+                if(metadataID.equals(noCacheGroupID)){
+                    return true;
+                }
+            } catch (QueryMetadataException e) {
+                //log that an unknown groups was used in the no cache
+                LogManager.logWarning(LogConstants.CTX_QUERY_RESOLVER, e, QueryPlugin.Util.getString("SimpleQueryResolver.unknown_group_in_nocache", groupName)); //$NON-NLS-1$
+            }
+        }
+        return false;
+    }
+    
+    private static void recordMaterializationTableAnnotation(GroupSymbol virtualGroup,
+                                                      AnalysisRecord analysis,
+                                                      String matTableName, String msg) {
+        if ( analysis.recordAnnotations() ) {
+            Object[] params = new Object[] {virtualGroup, matTableName};
+            QueryAnnotation annotation = new QueryAnnotation(QueryAnnotation.MATERIALIZED_VIEW, 
+                                                         QueryPlugin.Util.getString(msg, params), 
+                                                         null, 
+                                                         QueryAnnotation.LOW);
+            analysis.addAnnotation(annotation);
+        }
+    }
+
+    private static Command convertToSubquery(QueryNode qnode, QueryMetadataInterface metadata)
+    throws QueryResolverException, MetaMatrixComponentException {
+
+        // Parse this node's command
+        Command command = qnode.getCommand();
+        
+        if (command == null) {
+            try {
+                command = QueryParser.getQueryParser().parseCommand(qnode.getQuery());
+            } catch(QueryParserException e) {
+                throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0011, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0011, qnode.getGroupName()));
+            }
+            
+            //Handle bindings and references
+            List bindings = qnode.getBindings();
+            if (bindings != null){
+                BindVariableVisitor.bindReferences(command, bindings, metadata);
+            }
+        }
+
+        return command;
+    }
+
+}
\ No newline at end of file

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -343,7 +343,7 @@
 				break;
 			}
 		}
-		return (List<SubqueryContainer>) ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(toSearch);
+		return ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(toSearch);
 	}
         
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -68,7 +68,7 @@
 
 public class FrameUtil {
 
-    static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata) 
+    public static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata) 
         throws QueryPlannerException {
 
         PlanNode current = startNode;

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -37,7 +37,7 @@
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.query.function.metadata.FunctionMethod;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.relational.GenerateCanonical;
+import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
 import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
 import com.metamatrix.query.resolver.util.AccessPattern;
@@ -152,7 +152,7 @@
         }
         for (Iterator i = joinCriteria.iterator(); i.hasNext();) {
             Criteria crit = (Criteria)i.next();
-            criteriaNodes.add(GenerateCanonical.createSelectNode(crit, false));
+            criteriaNodes.add(RelationalPlanner.createSelectNode(crit, false));
         }
     }
     

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -35,8 +35,8 @@
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.GenerateCanonical;
 import com.metamatrix.query.optimizer.relational.OptimizerRule;
+import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.optimizer.relational.RuleStack;
 import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
 import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
@@ -307,7 +307,7 @@
             DependentSetCriteria crit = new DependentSetCriteria(SymbolMap.getExpression(depExpr), id);
             crit.setValueExpression(indepExpr);
             
-            PlanNode selectNode = GenerateCanonical.createSelectNode(crit, false);
+            PlanNode selectNode = RelationalPlanner.createSelectNode(crit, false);
             
             selectNode.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);
             result.add(selectNode);

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlaceAccess.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlaceAccess.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlaceAccess.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -35,7 +35,6 @@
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.OptimizerContext;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.optimizer.relational.OptimizerRule;
 import com.metamatrix.query.optimizer.relational.RuleStack;
@@ -68,7 +67,11 @@
                                                    MetaMatrixComponentException,
                                                    QueryPlannerException {
 
-        Set<String> groups = OptimizerContext.getOptimizerContext().getGroups();
+        Set<String> groups = context.getGroups();
+        if (groups == null) {
+        	groups = new HashSet<String>();
+        	context.setGroups(groups);
+        }
 
         boolean[] addtionalRules = new boolean[2];
 

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushNonJoinCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushNonJoinCriteria.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushNonJoinCriteria.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -32,8 +32,8 @@
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.GenerateCanonical;
 import com.metamatrix.query.optimizer.relational.OptimizerRule;
+import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.optimizer.relational.RuleStack;
 import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
 import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
@@ -144,7 +144,7 @@
      */
     private boolean pushCriteria(PlanNode joinNode,
                                   Criteria tgtCrit) {
-        PlanNode newCritNode = GenerateCanonical.createSelectNode(tgtCrit, false);
+        PlanNode newCritNode = RelationalPlanner.createSelectNode(tgtCrit, false);
         
         Set<GroupSymbol> groups = newCritNode.getGroups();
         
@@ -156,7 +156,7 @@
             if (FrameUtil.findOriginatingNode(innerJoinNodes[i], groups) != null) {
                 if (pushed) {
                     //create a new copy since the old one has been used
-                    newCritNode = GenerateCanonical.createSelectNode(tgtCrit, false);
+                    newCritNode = RelationalPlanner.createSelectNode(tgtCrit, false);
                 }
                 innerJoinNodes[i].addAsParent(newCritNode);
                 pushed = true;

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -27,7 +27,6 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -57,7 +56,6 @@
 import com.metamatrix.query.sql.symbol.Expression;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.visitor.CommandCollectorVisitor;
 import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
 import com.metamatrix.query.util.CommandContext;
 import com.metamatrix.query.util.ErrorMessageKeys;
@@ -91,16 +89,6 @@
         return query;
     }
 
-    static Command parseQuery(String queryStr) throws QueryPlannerException {
-        Command query = null;
-        try {
-            query = QueryParser.getQueryParser().parseCommand(queryStr);            
-        } catch (QueryParserException e) {
-            throw new QueryPlannerException(e, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0054, new Object[]{queryStr}));
-        }
-        return query;
-    }
-    
     /** 
      * Resolve a command using the metadata in the planner environment.
      * @param query The query to resolve
@@ -113,7 +101,7 @@
         throws MetaMatrixComponentException, QueryPlannerException {
         // Run resolver
         try {
-            QueryResolver.resolveCommand(query, Collections.EMPTY_MAP, true, metadata, AnalysisRecord.createNonRecordingRecord());
+            QueryResolver.resolveCommand(query, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
         } catch(QueryResolverException e) {
             throw new QueryPlannerException(e, e.getMessage());
         }
@@ -129,7 +117,7 @@
     static Command rewriteQuery(Command query, QueryMetadataInterface metadata, CommandContext context) 
         throws QueryPlannerException {
         try {
-            return QueryRewriter.rewrite(query, null, metadata, context);
+            return QueryRewriter.rewrite(query, metadata, context);
         } catch(QueryValidatorException e) {
             throw new QueryPlannerException(e, e.getMessage());
         }
@@ -236,33 +224,21 @@
     }
 
     
-    static List getReferences(Command query, boolean embeddedOnly) {
+    static List getReferences(Command command) {
         List boundList = new ArrayList();
         
-        Collection commands = null;
-        
-        if (embeddedOnly) {
-            commands = new LinkedList();
-        } else {
-            commands = new LinkedList(CommandCollectorVisitor.getNonEmbeddedCommands(query));
-        }
-        commands.add(query);
-        
-        for (Iterator cmds = commands.iterator(); cmds.hasNext();) {
-            Command command = (Command)cmds.next();
-            for (Iterator refs = ReferenceCollectorVisitor.getReferences(command).iterator(); refs.hasNext();) {
-                Reference ref = (Reference) refs.next();
-                Expression expr = ref.getExpression();
-                if (!(expr instanceof ElementSymbol)){
-                    continue;
-                }
-                ElementSymbol elem = (ElementSymbol)expr;
-                
-                if (!query.getExternalGroupContexts().getGroups().contains(elem.getGroupSymbol())) {
-                    continue;
-                }                
-                boundList.add(ref);
+        for (Iterator refs = ReferenceCollectorVisitor.getReferences(command).iterator(); refs.hasNext();) {
+            Reference ref = (Reference) refs.next();
+            Expression expr = ref.getExpression();
+            if (!(expr instanceof ElementSymbol)){
+                continue;
             }
+            ElementSymbol elem = (ElementSymbol)expr;
+            
+            if (!command.getExternalGroupContexts().getGroups().contains(elem.getGroupSymbol())) {
+                continue;
+            }                
+            boundList.add(ref);
         }
         return boundList;
     }     

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -46,7 +46,6 @@
 import com.metamatrix.query.mapping.xml.ResultSetInfo;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.CommandTreeNode;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.processor.ProcessorPlan;
 import com.metamatrix.query.processor.xml.Program;
@@ -79,31 +78,15 @@
 	 */
 	public XMLPlanner() {}
 
-    /**
-	 * @see com.metamatrix.query.optimizer.CommandPlanner#generateCanonical
-	 */
-	public void generateCanonical(CommandTreeNode rootNode, QueryMetadataInterface metadata, AnalysisRecord analysisRecord, CommandContext context)
-	throws QueryPlannerException, MetaMatrixComponentException {
-		//Nothing to do here
-	}
-
 	/**
 	 * @see com.metamatrix.query.optimizer.CommandPlanner#optimize
 	 */
-	public ProcessorPlan optimize(CommandTreeNode node,IDGenerator idGenerator,QueryMetadataInterface metadata,CapabilitiesFinder capFinder,AnalysisRecord analysisRecord,CommandContext context)
+	public ProcessorPlan optimize(Command command,IDGenerator idGenerator,QueryMetadataInterface metadata,CapabilitiesFinder capFinder,AnalysisRecord analysisRecord,CommandContext context)
 		throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
 
         XMLPlannerEnvironment env = new XMLPlannerEnvironment(metadata);
 
-        // Check for XML results form property in parent CommandTreeNode (if any)
-        if (node.getParent() != null && node.getParent().getCommandType() == CommandTreeNode.TYPE_XQUERY_COMMAND){
-            String xmlFormResults = (String)node.getParent().getProperty(XMLPlannerEnvironment.XML_FORM_RESULTS_PROPERTY);
-            if (xmlFormResults != null){
-                env.xmlFormResults = xmlFormResults;
-            }
-        }
-
-		return XMLPlanner.preparePlan(node.getCommand(), metadata, analysisRecord, env, idGenerator, capFinder, context);
+		return XMLPlanner.preparePlan(command, metadata, analysisRecord, env, idGenerator, capFinder, context);
 	}
 
     /**

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlannerEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlannerEnvironment.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlannerEnvironment.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -89,13 +89,6 @@
     // Context this command is running in
     CommandContext context;
     
-    /*
-     * The form the result documents should be in, either
-     * String or JDOM Document, see
-     * {@link XML_FORM_RESULTS_PROPERTY} 
-     */
-    String xmlFormResults;
-    
     // ################## Planning state ################## 
     private HashMap stagingResultsInfo = new HashMap();
     
@@ -119,9 +112,6 @@
     XMLProcessorEnvironment createProcessorEnvironment(Program mainProgram) {
         XMLProcessorEnvironment processorEnv = new XMLProcessorEnvironment(mainProgram);
         
-        if (this.xmlFormResults != null){
-            processorEnv.setXMLResultsForm(xmlFormResults);
-        }  
         processorEnv.setDocumentGroup(documentGroup);
         return processorEnv;
     }

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -72,7 +72,6 @@
 import com.metamatrix.query.sql.symbol.Constant;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
 import com.metamatrix.query.sql.visitor.StaticSymbolMappingVisitor;
 
 public class XMLQueryPlanner {
@@ -125,9 +124,6 @@
                     
                     QueryUtil.rewriteQuery(command, planEnv.getGlobalMetadata(), planEnv.context);
                     
-                    List references = QueryUtil.getReferences(command, false);
-                    rsInfo.setReferences(references);    
-                    
                     // Plan the result set.
                     ProcessorPlan queryPlan = optimizePlan(command, planEnv);
                     rsInfo.setPlan(queryPlan);                    
@@ -362,7 +358,7 @@
             QueryUtil.rewriteQuery(contextQuery, planEnv.getGlobalMetadata(), planEnv.context);
 
             //selectively replace correlated references with their actual element symbols
-            List bindings = QueryUtil.getReferences(contextQuery, true);
+            List bindings = QueryUtil.getReferences(contextQuery);
             
             QueryNode modifiedNode = new QueryNode(rsInfo.getResultSetName(), null);
             modifiedNode.setCommand(contextQuery);
@@ -426,13 +422,6 @@
         
         QueryUtil.resolveQuery(query, planEnv.getGlobalMetadata());
         
-        if (!implicit) {
-	        UnaryFromClause ufc = (UnaryFromClause)query.getFrom().getClauses().get(0);
-	        if (!ReferenceCollectorVisitor.getReferences(ufc.getExpandedCommand()).isEmpty()) {
-	        	throw new QueryPlannerException(QueryExecPlugin.Util.getString("XMLQueryPlanner.staging_table_has_input_set", stageGroupName)); //$NON-NLS-1$
-	        }
-        }
-        
         Command cmd = QueryUtil.rewriteQuery(query, planEnv.getGlobalMetadata(), planEnv.context);
                 
         ProcessorPlan plan = null;

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLStagaingQueryPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLStagaingQueryPlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLStagaingQueryPlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -34,7 +34,7 @@
 import com.metamatrix.query.mapping.xml.MappingVisitor;
 import com.metamatrix.query.mapping.xml.Navigator;
 import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.resolver.command.SimpleQueryResolver;
+import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.sql.lang.Option;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
@@ -114,24 +114,24 @@
         
         //id as mapping class
         Object metadataID = planEnv.getGlobalMetadata().getGroupID(sourceNode.getResultName());
-        if (SimpleQueryResolver.isNoCacheGroup(planEnv.getGlobalMetadata(), metadataID, option)) {
+        if (RelationalPlanner.isNoCacheGroup(planEnv.getGlobalMetadata(), metadataID, option)) {
             return false;
         }
 
         //id as generated mapping class name
         metadataID = planEnv.getGlobalMetadata().getGroupID(sourceNode.getActualResultSetName());
-        if (SimpleQueryResolver.isNoCacheGroup(planEnv.getGlobalMetadata(), metadataID, option)) {
+        if (RelationalPlanner.isNoCacheGroup(planEnv.getGlobalMetadata(), metadataID, option)) {
             return false;
         }
         
         // get the original transformation of the mapping class before planning. 
         Query stagableQuery = (Query)QueryUtil.getQueryFromQueryNode(groupName, planEnv);
         
-        Collection groups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(stagableQuery, false);
+        Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(stagableQuery, false);
         
         //check for already staged queries
         if (groups.size() == 1) {
-            GroupSymbol group = (GroupSymbol)groups.iterator().next();
+            GroupSymbol group = groups.iterator().next();
             group = QueryUtil.createResolvedGroup((GroupSymbol)group.clone(), planEnv.getGlobalMetadata());
             if (planEnv.isStagingTable(group.getMetadataID()) && stagableQuery.getCriteria() == null) {
                 return false;

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xquery/XQueryPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xquery/XQueryPlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xquery/XQueryPlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -29,13 +29,10 @@
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.CommandTreeNode;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.xml.XMLPlannerEnvironment;
 import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.xml.XMLProcessorEnvironment;
 import com.metamatrix.query.processor.xquery.XQueryPlan;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
+import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.XQuery;
 import com.metamatrix.query.util.CommandContext;
 
@@ -45,27 +42,12 @@
 public class XQueryPlanner implements CommandPlanner {
 
     /**
-     * @see com.metamatrix.query.optimizer.CommandPlanner#generateCanonical(com.metamatrix.query.optimizer.CommandTreeNode, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.analysis.AnalysisRecord, CommandContext)
+     * @see com.metamatrix.query.optimizer.CommandPlanner#optimize(Command, com.metamatrix.core.id.IDGenerator, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.analysis.AnalysisRecord, CommandContext)
      */
-    public void generateCanonical(CommandTreeNode node, QueryMetadataInterface metadata, AnalysisRecord analysisRecord, CommandContext context)
+    public ProcessorPlan optimize(Command command, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
         throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
 
-        //indicate child XML results should be as JDOM Documents
-        node.setProperty(XMLPlannerEnvironment.XML_FORM_RESULTS_PROPERTY, XMLProcessorEnvironment.JDOM_DOCUMENT_RESULT);
+    	return new XQueryPlan((XQuery)command);        
     }
 
-    /**
-     * @see com.metamatrix.query.optimizer.CommandPlanner#optimize(com.metamatrix.query.optimizer.CommandTreeNode, com.metamatrix.core.id.IDGenerator, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.analysis.AnalysisRecord, CommandContext)
-     */
-    public ProcessorPlan optimize(CommandTreeNode node, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
-        throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-
-    	String parentGroup = null;
-    	if (node.getParent() != null && node.getParent().getCommand() instanceof ProcedureContainer) {
-    		parentGroup = ((ProcedureContainer)node.getParent().getCommand()).getGroup().getCanonicalName();
-    	}
-    	
-    	return new XQueryPlan((XQuery)node.getCommand(), parentGroup);        
-    }
-
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -106,7 +106,7 @@
      * Check if this is a valid string literal
      * @param id Possible string literal
      */
-    boolean isStringLiteral(String str, ParseInfo info) throws ParseException {
+    boolean isStringLiteral(String str, ParseInfo info) {
     	if (info.useAnsiQuotedIdentifiers() || str.charAt(0) != '"' || str.charAt(str.length() - 1) != '"') {
     		return false;
     	}

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SQLSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SQLSource.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SQLSource.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,62 +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.processor.dynamic;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.sax.SAXSource;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.TupleSource;
-
-
-/** 
- * This is merely a wrapper class which brings together the TupleInputSource and
- * TupleXMLReader classes together to build SAXSource object.
- */
-public class SQLSource extends SAXSource {
-    
-    public static SAXSource createSource(String[] columns, Class[] types, TupleSource source) throws  MetaMatrixProcessingException, MetaMatrixComponentException {
-
-        try {
-            // get the sax parser and the its XML reader and replace with 
-            // our own. and then supply the customized input source.            
-            SAXParserFactory spf = SAXParserFactory.newInstance();
-            spf.setNamespaceAware(true);            
-            SAXParser sp = spf.newSAXParser();            
-            XMLReader reader = sp.getXMLReader();
-            
-            return new SAXSource(new TupleXMLReader(reader), new TupleInputSource(columns, types, source));
-            
-        } catch (ParserConfigurationException e) {
-            throw new MetaMatrixComponentException(e);
-        } catch (SAXException e) {
-            throw new MetaMatrixProcessingException(e);
-        }        
-    }
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/SqlEval.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,14 +22,23 @@
 
 package com.metamatrix.query.processor.dynamic;
 
+import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
 
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.query.ExpressionEvaluationException;
@@ -40,6 +49,7 @@
 import com.metamatrix.common.buffer.TupleSourceID;
 import com.metamatrix.common.buffer.TupleSourceNotFoundException;
 import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.XMLType;
 import com.metamatrix.query.eval.Evaluator;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.processor.QueryProcessor;
@@ -57,13 +67,59 @@
  */
 public class SqlEval implements XQuerySQLEvaluator {
 
+    private static final String NO_RESULTS_DOCUMENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><results/>"; //$NON-NLS-1$
+	
     private BufferManager bufferMgr;
     private CommandContext context;
     private ArrayList<TupleSourceID> openTupleList;
     private String parentGroup;
     private Map<String, Expression> params;
     private ProcessorDataManager dataManager;
+        
+    public static Source createSource(TupleSource source) 
+        throws  MetaMatrixProcessingException {
+
+        try {
+            // we only want to return the very first document from the result set
+            // as XML we expect in doc function to have single XML document
+            List tuple = source.nextTuple();
+            if (tuple != null) {                        
+                Object value = tuple.get(0);
+                if (value != null) {
+                    // below we will catch any invalid LOB refereces and return them
+                    // as processing excceptions.
+                    if (value instanceof XMLType) {
+                        XMLType xml = (XMLType)value;
+                        return xml.getSource(null);
+                    }
+                    return new StreamSource(new StringReader((String)value));
+                }
+            }
+        } catch (Exception e) { 
+            throw new MetaMatrixProcessingException(e);
+        }
+        return new StreamSource(new StringReader(NO_RESULTS_DOCUMENT));
+    }
     
+    public static SAXSource createSource(String[] columns, Class[] types, TupleSource source) throws  MetaMatrixProcessingException, MetaMatrixComponentException {
+
+        try {
+            // get the sax parser and the its XML reader and replace with 
+            // our own. and then supply the customized input source.            
+            SAXParserFactory spf = SAXParserFactory.newInstance();
+            spf.setNamespaceAware(true);            
+            SAXParser sp = spf.newSAXParser();            
+            XMLReader reader = sp.getXMLReader();
+            
+            return new SAXSource(new TupleXMLReader(reader), new TupleInputSource(columns, types, source));
+            
+        } catch (ParserConfigurationException e) {
+            throw new MetaMatrixComponentException(e);
+        } catch (SAXException e) {
+            throw new MetaMatrixProcessingException(e);
+        }        
+    }
+    
     public SqlEval(BufferManager bufferMgr, ProcessorDataManager dataManager, CommandContext context, String parentGroup, Map<String, Expression> params) {
         this.bufferMgr = bufferMgr;
         this.dataManager = dataManager;
@@ -101,9 +157,9 @@
         }            
         
         if (xml) {
-            return XMLSource.createSource(columns, types, src, this.bufferMgr);
+            return createSource(src);
         }
-        return SQLSource.createSource(columns, types, src);
+        return createSource(columns, types, src);
     }
     
     @Override

Deleted: trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/XMLSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/XMLSource.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/dynamic/XMLSource.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,68 +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.processor.dynamic;
-
-import java.io.StringReader;
-import java.util.List;
-
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.types.XMLType;
-
-
-/** 
- * This class will be a reader class for reading data from the XML Source realated
- * connectors. 
- */
-public class XMLSource {
-    private static final String NO_RESULTS_DOCUMENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><results/>"; //$NON-NLS-1$
-    
-    public static Source createSource(String[] columns, Class[] types, TupleSource source, BufferManager bufferMgr) 
-        throws  MetaMatrixProcessingException {
-
-        try {
-            // we only want to return the very first document from the result set
-            // as XML we expect in doc function to have single XML document
-            List tuple = source.nextTuple();
-            if (tuple != null) {                        
-                Object value = tuple.get(0);
-                if (value != null) {
-                    // below we will catch any invalid LOB refereces and return them
-                    // as processing excceptions.
-                    if (value instanceof XMLType) {
-                        XMLType xml = (XMLType)value;
-                        return xml.getSource(null);
-                    }
-                    return new StreamSource(new StringReader((String)value));
-                }
-            }
-        } catch (Exception e) { 
-            throw new MetaMatrixProcessingException(e);
-        }
-        return new StreamSource(new StringReader(NO_RESULTS_DOCUMENT));
-    }    
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,7 +22,6 @@
 
 package com.metamatrix.query.processor.xml;
 
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -33,17 +32,14 @@
 import com.metamatrix.common.buffer.TupleSource;
 import com.metamatrix.common.buffer.TupleSourceNotFoundException;
 import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.MetaMatrixCoreException;
 import com.metamatrix.query.execution.QueryExecPlugin;
 import com.metamatrix.query.mapping.xml.ResultSetInfo;
 import com.metamatrix.query.processor.ProcessorDataManager;
 import com.metamatrix.query.processor.ProcessorPlan;
 import com.metamatrix.query.processor.QueryProcessor;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
 import com.metamatrix.query.sql.util.VariableContext;
 import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
 import com.metamatrix.query.util.LogConstants;
 
 
@@ -104,22 +100,16 @@
             throw e;
         } catch (MetaMatrixProcessingException e) {
         	throw e;
-        } catch (MetaMatrixCoreException e) {
-            throw new MetaMatrixComponentException(e, ErrorMessageKeys.PROCESSOR_0047,QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0047,e.getMessage()));
         }
     }    
     
-    void setReferenceValues(Map referencesValues) throws MetaMatrixComponentException {
-        if (this.resultInfo.hasReferences() && (referencesValues != null && !referencesValues.isEmpty()) ) {
-            for (final Iterator i = this.resultInfo.getReferences().iterator(); i.hasNext();) {
-                Reference ref = (Reference)i.next();
-                ElementSymbol expr = ref.getExpression();
-                if(!referencesValues.containsKey(expr)) {
-                    throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("unmapped_reference", expr.getName())); //$NON-NLS-1$
-                }
-                this.internalProcessor.getContext().getVariableContext().setValue(expr, referencesValues.get(expr));
-            }
+    void setReferenceValues(Map<ElementSymbol, Object> referencesValues) throws MetaMatrixComponentException {
+        if (referencesValues == null || referencesValues.isEmpty()) {
+        	return;
         }
+        for (Map.Entry<ElementSymbol, Object> entry : referencesValues.entrySet()) {
+            this.internalProcessor.getContext().getVariableContext().setValue(entry.getKey(), entry.getValue());
+		}
     }    
     
     /**

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -262,17 +262,6 @@
     }
 
     /**
-     * @see com.metamatrix.query.processor.xml.ProcessorEnvironment#getXMLResultsForm
-     */
-    public String getXMLResultsForm(){
-        return this.xmlResultsForm;
-    }
-
-    public void setXMLResultsForm(String xmlResultsForm){
-        this.xmlResultsForm = xmlResultsForm;
-    }
-   
-    /**
      * @see com.metamatrix.query.processor.xml.ProcessorEnvironment#getDataManager()
      */
     public ProcessorDataManager getDataManager() {
@@ -319,7 +308,6 @@
                
         // XML results form and format
         clone.setXMLFormat(this.getXMLFormat());
-        clone.setXMLResultsForm(this.getXMLResultsForm());
     }
 
     public GroupSymbol getDocumentGroup() {

Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -59,7 +59,6 @@
     private XQuery xQuery;
     private BufferManager bufferMgr;
     private String xmlFormat;
-    private String parentGroup;
     private ProcessorDataManager dataManager;
 
     private int chunkSize = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
@@ -70,10 +69,9 @@
      * @param xmlPlans Map of XQuery doc() args to XMLPlan for
      * that virtual doc
      */
-    public XQueryPlan(XQuery xQuery, String parentGroup) {
+    public XQueryPlan(XQuery xQuery) {
         super();
         this.xQuery = xQuery;
-        this.parentGroup = parentGroup;
     }
 
     /**
@@ -81,7 +79,7 @@
      */
     public Object clone() {
         XQuery clonedQuery = (XQuery)this.xQuery.clone();
-        return new XQueryPlan(clonedQuery, parentGroup);
+        return new XQueryPlan(clonedQuery);
     }
 
     /**
@@ -122,7 +120,7 @@
     	XQueryExpression expr = this.xQuery.getCompiledXQuery();    
         expr.setXMLFormat(xmlFormat);
         
-        SqlEval sqlEval = new SqlEval(bufferMgr, this.dataManager, getContext(), this.parentGroup, this.xQuery.getVariables());
+        SqlEval sqlEval = new SqlEval(bufferMgr, this.dataManager, getContext(), this.xQuery.getProcedureGroup(), this.xQuery.getVariables());
         try {
         	SQLXML xml = expr.evaluateXQuery(sqlEval);
             TupleBatch batch = packResultsIntoBatch(xml);        

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -38,7 +38,6 @@
     /**
      * Resolve the command using the metadata.  
      * @param command The command to resolve
-     * @param useMetadataCommands true if the resolver should use metadata commands to completely resolve
      * @param metadata Metadata
      * @param analysis
      * @param resolveNullLiterals true if the resolver should consider replacing null literals with more appropriate types 
@@ -47,7 +46,7 @@
      * @throws QueryResolverException If the query cannot be resolved
      * @throws MetaMatrixComponentException If there is an internal error     
      */        
-    void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
+    void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
     throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException;
     
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -51,7 +51,6 @@
 public abstract class ProcedureContainerResolver implements CommandResolver {
 
     public abstract void resolveProceduralCommand(Command command,
-                                                  boolean useMetadataCommands,
                                                   TempMetadataAdapter metadata,
                                                   AnalysisRecord analysis) throws QueryMetadataException,
                                                                           QueryResolverException,
@@ -70,29 +69,50 @@
      * @throws QueryResolverException If the query cannot be resolved
      * @throws MetaMatrixComponentException If there is an internal error
      */
-    public void expandCommand(Command command, QueryMetadataInterface metadata, AnalysisRecord analysis)
+    public Command expandCommand(ProcedureContainer procCommand, QueryMetadataInterface metadata, AnalysisRecord analysis)
     throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-        // Cast to known type
-        ProcedureContainer procCommand = (ProcedureContainer) command;
-
+    	
         // Resolve group so we can tell whether it is an update procedure
         GroupSymbol group = procCommand.getGroup();
 
-        if(!group.isTempGroupSymbol() && metadata.isVirtualGroup(group.getMetadataID())) {
-            String plan = getPlan(metadata, group);
-            
-            if(plan == null) {
-                String name = command.getClass().getName();
-                name = name.substring(name.lastIndexOf('.') + 1);
-                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0009, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0009, group, name));
-            }
-            QueryParser parser = QueryParser.getQueryParser();
-            try {
-                procCommand.setSubCommand(parser.parseCommand(plan));
-            } catch(QueryParserException e) {
-                throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0045, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0045, group));
-            }
+        Command subCommand = null;
+        
+        String plan = getPlan(metadata, procCommand);
+        
+        if (plan == null) {
+            return null;
         }
+        
+        QueryParser parser = QueryParser.getQueryParser();
+        try {
+            subCommand = parser.parseCommand(plan);
+        } catch(QueryParserException e) {
+            throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0045, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0045, group));
+        }
+        
+        if(subCommand instanceof CreateUpdateProcedureCommand){
+            CreateUpdateProcedureCommand cupCommand = (CreateUpdateProcedureCommand)subCommand;
+            //if the subcommand is virtual stored procedure, it must have the same
+            //projected symbol as its parent.
+            if(!cupCommand.isUpdateProcedure()){
+                cupCommand.setProjectedSymbols(procCommand.getProjectedSymbols());
+            } 
+            
+            cupCommand.setVirtualGroup(procCommand.getGroup());
+            cupCommand.setUserCommand(procCommand);
+        } 
+        
+        //find the childMetadata using a clean metadata store
+        TempMetadataStore childMetadata = new TempMetadataStore();
+        QueryMetadataInterface resolveMetadata = new TempMetadataAdapter(metadata, childMetadata);
+
+        GroupContext externalGroups = findChildCommandMetadata(procCommand, subCommand, childMetadata, resolveMetadata);
+        
+        QueryResolver.setChildMetadata(subCommand, childMetadata.getData(), externalGroups);
+        
+        QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, metadata, analysis);
+        
+        return subCommand;
     }
 
     /** 
@@ -113,99 +133,75 @@
      * in the childMetadata object.  Typical uses of this are for stored queries that define parameter
      * variables valid in subcommands. only used for inserts, updates, and deletes
      * @param command The command to find metadata on
-     * @param childMetadata The store to collect child metadata in 
-     * @param useMetadataCommands True if resolver should use metadata commands to completely resolve
      * @param metadata Metadata access
+     * @param childMetadata The store to collect child metadata in 
      * @throws QueryMetadataException If there is a metadata problem
      * @throws QueryResolverException If the query cannot be resolved
      * @throws MetaMatrixComponentException If there is an internal error    
      */ 
-    public GroupContext findChildCommandMetadata(Command command, TempMetadataStore discoveredMetadata, boolean useMetadataCommands, QueryMetadataInterface metadata)
+    public GroupContext findChildCommandMetadata(ProcedureContainer container, Command subCommand, TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata)
     throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-        // Cast to known type
-        ProcedureContainer container = (ProcedureContainer) command;
-
         // get the group on the delete statement
         GroupSymbol group = container.getGroup();
         // proceed further if it is a virtual group
-        if(metadata.isVirtualGroup(group.getMetadataID())) {
-            CreateUpdateProcedureCommand procCmd = (CreateUpdateProcedureCommand) container.getSubCommand();
-            if (procCmd == null) {
-                return null;
-            }
             
-            GroupContext externalGroups = new GroupContext();
-            
-            // set the user's command on the procedure
-            procCmd.setUserCommand(container);
-            
-            //Look up elements for the virtual group
-            List elements = ResolverUtil.resolveElementsInGroup(group, metadata);
+        GroupContext externalGroups = new GroupContext();
+        
+        //Look up elements for the virtual group
+        List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(group, metadata);
 
-            // Create the INPUT variables
-            List inputElments = new ArrayList(elements.size());
-            for(int i=0; i<elements.size(); i++) {
-                ElementSymbol virtualElmnt = (ElementSymbol)elements.get(i);
-                ElementSymbol inputElement = (ElementSymbol)virtualElmnt.clone();
-                inputElments.add(inputElement);
-            }
+        // Create the INPUT variables
+        List<ElementSymbol> inputElments = new ArrayList<ElementSymbol>(elements.size());
+        for(int i=0; i<elements.size(); i++) {
+            ElementSymbol virtualElmnt = elements.get(i);
+            ElementSymbol inputElement = (ElementSymbol)virtualElmnt.clone();
+            inputElments.add(inputElement);
+        }
 
-            addScalarGroup(ProcedureReservedWords.INPUT, discoveredMetadata, externalGroups, inputElments);
+        addScalarGroup(ProcedureReservedWords.INPUT, discoveredMetadata, externalGroups, inputElments);
 
-            // Switch type to be boolean for all CHANGING variables
-            List changingElements = new ArrayList(elements.size());
-            for(int i=0; i<elements.size(); i++) {
-                ElementSymbol virtualElmnt = (ElementSymbol)elements.get(i);
-                ElementSymbol changeElement = (ElementSymbol)virtualElmnt.clone();
-                changeElement.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
-                changingElements.add(changeElement);
-            }
-
-            addScalarGroup(ProcedureReservedWords.CHANGING, discoveredMetadata, externalGroups, changingElements);
-            
-            // set the virtual group on the procedure
-            procCmd.setVirtualGroup(group);
-            
-            return externalGroups;
+        // Switch type to be boolean for all CHANGING variables
+        List<ElementSymbol> changingElements = new ArrayList<ElementSymbol>(elements.size());
+        for(int i=0; i<elements.size(); i++) {
+            ElementSymbol virtualElmnt = elements.get(i);
+            ElementSymbol changeElement = (ElementSymbol)virtualElmnt.clone();
+            changeElement.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
+            changingElements.add(changeElement);
         }
+
+        addScalarGroup(ProcedureReservedWords.CHANGING, discoveredMetadata, externalGroups, changingElements);
         
-        return null;
+        return externalGroups;
     }
         
     /** 
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
+     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
      */
-    public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
+    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
         
         ProcedureContainer procCommand = (ProcedureContainer)command;
         
         resolveGroup(metadata, procCommand);
         
-        resolveProceduralCommand(procCommand, useMetadataCommands, metadata, analysis);
+        resolveProceduralCommand(procCommand, metadata, analysis);
         
-        if (!useMetadataCommands) {
-            return;
-        }
-        
-        expandCommand(procCommand, metadata, analysis);
+        getPlan(metadata, procCommand);
+    }
 
-        Command subCommand = procCommand.getSubCommand();
-        
-        if (subCommand == null) {
-            return;
+	private String getPlan(QueryMetadataInterface metadata, ProcedureContainer procCommand)
+			throws MetaMatrixComponentException, QueryMetadataException,
+			QueryResolverException {
+		if(!procCommand.getGroup().isTempGroupSymbol() && metadata.isVirtualGroup(procCommand.getGroup().getMetadataID())) {
+            String plan = getPlan(metadata, procCommand.getGroup());
+            
+            if(plan == null) {
+                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0009, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0009, procCommand.getGroup(), procCommand.getClass().getSimpleName()));
+            }
+            return plan;
         }
-        
-        //find the childMetadata using a clean metadata store
-        TempMetadataStore childMetadata = new TempMetadataStore();
-        QueryMetadataInterface resolveMetadata = new TempMetadataAdapter(metadata.getMetadata(), childMetadata);
-
-        GroupContext externalGroups = findChildCommandMetadata(procCommand, childMetadata, useMetadataCommands, resolveMetadata);
-        
-        QueryResolver.setChildMetadata(subCommand, childMetadata.getData(), externalGroups);
-        
-        QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis);
-    }
+		return null;
+	}
     
     /** 
      * @param metadata

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -33,7 +33,6 @@
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.common.log.LogManager;
-import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.TempMetadataAdapter;
@@ -58,10 +57,10 @@
 import com.metamatrix.query.sql.lang.From;
 import com.metamatrix.query.sql.lang.FromClause;
 import com.metamatrix.query.sql.lang.GroupContext;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.UnaryFromClause;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
 import com.metamatrix.query.util.LogConstants;
 
 /**
@@ -85,6 +84,11 @@
     private static final CommandResolver BATCHED_UPDATE_RESOLVER = new BatchedUpdateResolver();
     private static final CommandResolver DYNAMIC_COMMAND_RESOLVER = new DynamicCommandResolver();
     private static final CommandResolver TEMP_TABLE_RESOLVER = new TempTableResolver();
+    
+    public static Command expandCommand(ProcedureContainer proc, QueryMetadataInterface metadata, AnalysisRecord analysisRecord) throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
+    	ProcedureContainerResolver cr = (ProcedureContainerResolver)chooseResolver(proc, metadata);
+    	return cr.expandCommand(proc, metadata, analysisRecord);
+    }
 
     /**
      * This implements an algorithm to resolve all the symbols created by the parser into real metadata IDs
@@ -95,7 +99,7 @@
      public static void resolveCommand(Command command, QueryMetadataInterface metadata, AnalysisRecord analysis)
          throws QueryResolverException, MetaMatrixComponentException {
 
-         resolveCommand(command, Collections.EMPTY_MAP, true, metadata, analysis);
+         resolveCommand(command, Collections.EMPTY_MAP, metadata, analysis);
      }
 
      /**
@@ -106,28 +110,26 @@
       public static void resolveCommand(Command command, QueryMetadataInterface metadata)
           throws QueryResolverException, MetaMatrixComponentException {
 
-          resolveCommand(command, Collections.EMPTY_MAP, true, metadata, AnalysisRecord.createNonRecordingRecord());
+          resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
       }
 
    /**
     * This implements an algorithm to resolve all the symbols created by the parser into real metadata IDs
-    * @param command Command the SQL command we are running (Select, Update, Insert, Delete)
-    * @param externalMetadata Map of GroupSymbol to a List of ElementSymbol that identifies
+ * @param externalMetadata Map of GroupSymbol to a List of ElementSymbol that identifies
     * valid external groups that can be resolved against. Any elements resolved against external
     * groups will be treated as variables
-    * @param useMetadataCommands True if resolver should use metadata commands to completely resolve
-    * the command tree all the way to physical.  False if resolver should resolve only the visible command
-    * @param metadata QueryMetadataInterface the metadata
-    * @param analysis The analysis record which can be used to add anotations and debug information.
+ * @param metadata QueryMetadataInterface the metadata
+ * @param analysis The analysis record which can be used to add anotations and debug information.
+ * @param command Command the SQL command we are running (Select, Update, Insert, Delete)
     */
-    public static TempMetadataStore resolveCommand(Command currentCommand, Map externalMetadata, boolean useMetadataCommands, 
-                                                     QueryMetadataInterface metadata, AnalysisRecord analysis)
+    public static TempMetadataStore resolveCommand(Command currentCommand, Map externalMetadata, QueryMetadataInterface metadata, 
+                                                     AnalysisRecord analysis)
                        throws QueryResolverException, MetaMatrixComponentException {
-        return resolveCommand(currentCommand, externalMetadata, useMetadataCommands, metadata, analysis, true);
+        return resolveCommand(currentCommand, externalMetadata, metadata, analysis, true);
     }
       
-    public static TempMetadataStore resolveCommand(Command currentCommand, Map externalMetadata, boolean useMetadataCommands, 
-                                      QueryMetadataInterface metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
+    public static TempMetadataStore resolveCommand(Command currentCommand, Map externalMetadata, QueryMetadataInterface metadata, 
+                                      AnalysisRecord analysis, boolean resolveNullLiterals)
         throws QueryResolverException, MetaMatrixComponentException {
 
 		LogManager.logTrace(LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving command", currentCommand}); //$NON-NLS-1$
@@ -171,7 +173,7 @@
             CommandResolver resolver = chooseResolver(currentCommand, resolverMetadata);
 
             // Resolve this command
-            resolver.resolveCommand(currentCommand, useMetadataCommands, resolverMetadata, analysis, resolveNullLiterals);            
+            resolver.resolveCommand(currentCommand, resolverMetadata, analysis, resolveNullLiterals);            
         } catch(QueryMetadataException e) {
             throw new QueryResolverException(e, e.getMessage());
         }
@@ -211,7 +213,7 @@
             case Command.TYPE_CREATE:               return TEMP_TABLE_RESOLVER;
             case Command.TYPE_DROP:                 return TEMP_TABLE_RESOLVER;
             default:
-                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0002, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0002, command.getType()));
+                throw new AssertionError("Unknown command type"); //$NON-NLS-1$
         }
     }
 
@@ -220,7 +222,7 @@
      * @param query the query to check
      * @param metadata QueryMetadataInterface the metadata
      */
-    static boolean isXMLQuery(Query query, QueryMetadataInterface metadata)
+    public static boolean isXMLQuery(Query query, QueryMetadataInterface metadata)
      throws MetaMatrixComponentException, QueryMetadataException, QueryResolverException {
 
         // Check first group

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/BatchedUpdateResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/BatchedUpdateResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/BatchedUpdateResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -42,9 +42,9 @@
 public class BatchedUpdateResolver implements CommandResolver {
     
     /** 
-     * @see com.metamatrix.query.resolver.command.AbstractCommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
+     * @see com.metamatrix.query.resolver.command.AbstractCommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.analysis.AnalysisRecord, boolean)
      */
-    public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
+    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
         BatchedUpdateCommand batchedUpdateCommand = (BatchedUpdateCommand) command;
@@ -52,7 +52,7 @@
         for (Iterator i = batchedUpdateCommand.getSubCommands().iterator(); i.hasNext();) {
             Command subCommand = (Command)i.next();
             QueryResolver.setChildMetadata(subCommand, command);
-            QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis);
+            QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, metadata.getMetadata(), analysis);
         }
     }
 

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -37,6 +37,7 @@
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Delete;
 import com.metamatrix.query.sql.lang.GroupContext;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 
 /**
@@ -45,15 +46,15 @@
 public class DeleteResolver extends ProcedureContainerResolver {
 
     /** 
-     * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
+     * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
      */
-    public void resolveProceduralCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis) 
+    public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
         //Cast to known type
         Delete delete = (Delete) command;
 
-        Set groups = new HashSet();
+        Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
         groups.add(delete.getGroup());
         ResolverVisitor.resolveLanguageObject(delete, groups, delete.getExternalGroupContexts(), metadata);
 
@@ -73,12 +74,10 @@
     }
     
     @Override
-    public GroupContext findChildCommandMetadata(Command command,
-    		TempMetadataStore discoveredMetadata, boolean useMetadataCommands,
+    public GroupContext findChildCommandMetadata(ProcedureContainer container,
+    		Command subCommand, TempMetadataStore discoveredMetadata,
     		QueryMetadataInterface metadata) throws QueryMetadataException,
     		QueryResolverException, MetaMatrixComponentException {
-    	super.findChildCommandMetadata(command, discoveredMetadata,
-    			useMetadataCommands, metadata);
     	//defect 16451: don't expose input and changing variables to delete procedures
     	return null;
     }

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -49,9 +49,9 @@
 public class DynamicCommandResolver implements CommandResolver {
 
     /** 
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, boolean, TempMetadataAdapter, AnalysisRecord, boolean)
+     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
      */
-    public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
+    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
         DynamicCommand dynamicCmd = (DynamicCommand)command;

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -31,7 +31,6 @@
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.dqp.message.ParameterInfo;
@@ -43,7 +42,6 @@
 import com.metamatrix.query.metadata.TempMetadataAdapter;
 import com.metamatrix.query.metadata.TempMetadataID;
 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;
@@ -55,7 +53,7 @@
 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.lang.XQuery;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.symbol.Expression;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
@@ -65,50 +63,22 @@
 /**
  */
 public class ExecResolver extends ProcedureContainerResolver implements VariableResolver {
+	
+	@Override
+	public Command expandCommand(ProcedureContainer procCommand,
+			QueryMetadataInterface metadata, AnalysisRecord analysis)
+			throws QueryMetadataException, QueryResolverException,
+			MetaMatrixComponentException {
+		Command command = super.expandCommand(procCommand, metadata, analysis);
+		if (command instanceof XQuery) {
+			XQuery query = (XQuery)command;
+			query.setProcedureGroup(procCommand.getGroup().getCanonicalName());
+			query.setVariables(getVariableValues(procCommand, metadata));
+		}
+		return command;
+	}
 
     /**
-     * @see com.metamatrix.query.resolver.CommandResolver#expandCommand(com.metamatrix.query.sql.lang.Command, java.util.Map, com.metamatrix.query.metadata.QueryMetadataInterface, AnalysisRecord)
-     * 
-     * In this method - retrieve the parameter metadata information for the stored procedure, validate
-     * that it matches up with the actual parameters entered by the user, and replace the parsed
-     * expressions with the ones retrieved from metadata (except retain the user's parameter values).
-     * 
-     * The user may have used the more common indexed parameters syntax, or may have used named parameters syntax.
-     * Named parameters are a little more tricky, because the user is free to enter the parameters in
-     * any order and even to leave off optional parameters and/or parameters with default values.
-     */
-    public void expandCommand(Command command, QueryMetadataInterface metadata, AnalysisRecord analysis)
-        throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-
-        StoredProcedure storedProcedureCommand = (StoredProcedure) command;
-
-        StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(storedProcedureCommand.getProcedureName());
-        
-        //if there is a query plan associated with the procedure, get it.
-        QueryNode plan = storedProcedureInfo.getQueryPlan();
-
-        //if there is a query plan, parse and resolve it
-        if(plan != null ){
-            try {
-                Command subCommand = QueryParser.getQueryParser().parseCommand(plan.getQuery());
-                if(subCommand instanceof CreateUpdateProcedureCommand){
-                    CreateUpdateProcedureCommand cupCommand = (CreateUpdateProcedureCommand)subCommand;
-                    //if the subcommand is virtual stored procedure, it must have the same
-                    //projected symbol as its parent.
-                    if(!cupCommand.isUpdateProcedure()){
-                        cupCommand.setProjectedSymbols(storedProcedureCommand.getProjectedSymbols());
-                    }
-                    
-                    cupCommand.setVirtualGroup(storedProcedureCommand.getGroup());
-                }
-                storedProcedureCommand.setSubCommand(subCommand);
-            } catch(QueryParserException e) {
-                throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0008, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0008, storedProcedureCommand.getProcedureName()));
-            }
-        }
-    }
-
-    /**
      * @see com.metamatrix.query.resolver.CommandResolver#findCommandMetadata(com.metamatrix.query.sql.lang.Command,
      * com.metamatrix.query.metadata.QueryMetadataInterface)
      */
@@ -232,16 +202,15 @@
         procGroup.setMetadataID(tid);
         storedProcedureCommand.setGroup(procGroup);
     }
+    
+    @Override
+    public GroupContext findChildCommandMetadata(ProcedureContainer container,
+    		Command subCommand, TempMetadataStore discoveredMetadata,
+    		QueryMetadataInterface metadata) throws QueryMetadataException,
+    		QueryResolverException, MetaMatrixComponentException {
 
-    /**
-     * @see com.metamatrix.query.resolver.CommandResolver#findChildCommandMetadata(com.metamatrix.query.sql.lang.
-     * Command, com.metamatrix.query.metadata.QueryMetadataInterface)
-     */
-    public GroupContext findChildCommandMetadata(Command command, TempMetadataStore childMetadata, boolean useMetadataCommands, QueryMetadataInterface metadata)
-    throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+        StoredProcedure storedProcedureCommand = (StoredProcedure) container;
 
-        StoredProcedure storedProcedureCommand = (StoredProcedure) command;
-
         // Create temporary metadata that defines a group based on either the stored proc
         // name or the stored query name - this will be used later during planning
         String procName = storedProcedureCommand.getProcedureName();
@@ -249,7 +218,7 @@
         GroupContext context = new GroupContext();
 
         // Look through parameters to find input elements - these become child metadata
-        List tempElements = new ArrayList();
+        List<ElementSymbol> tempElements = new ArrayList<ElementSymbol>();
         Iterator iter = storedProcedureCommand.getParameters().iterator();
         while(iter.hasNext()) {
             SPParameter param = (SPParameter) iter.next();
@@ -259,21 +228,15 @@
             }
         }
 
-        ProcedureContainerResolver.addScalarGroup(procName, childMetadata, context, tempElements);
+        ProcedureContainerResolver.addScalarGroup(procName, discoveredMetadata, context, tempElements);
         
-        if (storedProcedureCommand.getSubCommand() instanceof CreateUpdateProcedureCommand) {
-            CreateUpdateProcedureCommand cup = (CreateUpdateProcedureCommand)storedProcedureCommand.getSubCommand();
-            
-            cup.setUserCommand(storedProcedureCommand);
-        }
-        
         return context;
     }
 
     /** 
-     * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
+     * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
      */
-    public void resolveProceduralCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis) 
+    public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
         findCommandMetadata(command, metadata.getMetadataStore(), metadata);
@@ -291,7 +254,7 @@
                     for (SubqueryContainer container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(expr)) {
                         QueryResolver.setChildMetadata(container.getCommand(), command);
                         
-                        QueryResolver.resolveCommand(container.getCommand(), Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis);
+                        QueryResolver.resolveCommand(container.getCommand(), Collections.EMPTY_MAP, metadata.getMetadata(), analysis);
                     }
                     ResolverVisitor.resolveLanguageObject(expr, null, externalGroups, metadata);
                     Class paramType = param.getClassType();
@@ -353,6 +316,11 @@
     protected String getPlan(QueryMetadataInterface metadata,
                              GroupSymbol group) throws MetaMatrixComponentException,
                                                QueryMetadataException {
-        return null;
+        StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(group.getCanonicalName());
+        
+        //if there is a query plan associated with the procedure, get it.
+        QueryNode plan = storedProcedureInfo.getQueryPlan();
+        
+        return plan.getQuery();
     }
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -65,9 +65,9 @@
 
     /**
      * Resolve an INSERT.  Need to resolve elements, constants, types, etc.
-     * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
+     * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
      */
-    public void resolveProceduralCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis) 
+    public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
 
@@ -81,7 +81,7 @@
         if(insert.getQueryExpression() != null) {
         	QueryResolver.setChildMetadata(insert.getQueryExpression(), command);
             
-            QueryResolver.resolveCommand(insert.getQueryExpression(), Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis, false);
+            QueryResolver.resolveCommand(insert.getQueryExpression(), Collections.EMPTY_MAP, metadata.getMetadata(), analysis, false);
         }
 
         Set<GroupSymbol> groups = new HashSet<GroupSymbol>();

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -50,9 +50,9 @@
 public class SetQueryResolver implements CommandResolver {
 
     /**
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, java.util.Collection, TempMetadataAdapter, AnalysisRecord, boolean)
+     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
      */
-    public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
+    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
         SetQuery setQuery = (SetQuery) command;
@@ -60,7 +60,7 @@
         QueryCommand firstCommand = setQuery.getLeftQuery();
         
         QueryResolver.setChildMetadata(firstCommand, setQuery);
-        QueryResolver.resolveCommand(firstCommand, Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis, false);
+        QueryResolver.resolveCommand(firstCommand, Collections.EMPTY_MAP, metadata.getMetadata(), analysis, false);
 
         List firstProject = firstCommand.getProjectedSymbols();
         List<Class<?>> firstProjectTypes = new ArrayList<Class<?>>();
@@ -72,7 +72,7 @@
         QueryCommand rightCommand = setQuery.getRightQuery();
         
         QueryResolver.setChildMetadata(rightCommand, setQuery);
-        QueryResolver.resolveCommand(rightCommand, Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis, false);
+        QueryResolver.resolveCommand(rightCommand, Collections.EMPTY_MAP, metadata.getMetadata(), analysis, false);
 
         if (firstProject.size() != rightCommand.getProjectedSymbols().size()) {
             throw new QueryResolverException(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0035, setQuery.getOperation()));

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -35,25 +35,19 @@
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
-import com.metamatrix.common.log.LogManager;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.dqp.message.ParameterInfo;
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.analysis.QueryAnnotation;
-import com.metamatrix.query.mapping.relational.QueryNode;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.StoredProcedureInfo;
 import com.metamatrix.query.metadata.SupportConstants;
 import com.metamatrix.query.metadata.TempMetadataAdapter;
 import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.CommandResolver;
 import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.BindVariableVisitor;
 import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.resolver.util.ResolverVisitor;
 import com.metamatrix.query.sql.LanguageObject;
@@ -62,8 +56,6 @@
 import com.metamatrix.query.sql.lang.From;
 import com.metamatrix.query.sql.lang.Into;
 import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.OrderBy;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.SPParameter;
 import com.metamatrix.query.sql.lang.Select;
@@ -84,218 +76,21 @@
 import com.metamatrix.query.sql.symbol.ScalarSubquery;
 import com.metamatrix.query.sql.symbol.SingleElementSymbol;
 import com.metamatrix.query.util.ErrorMessageKeys;
-import com.metamatrix.query.util.LogConstants;
 
 public class SimpleQueryResolver implements CommandResolver {
 
     private static final String ALL_IN_GROUP_SUFFIX = ".*"; //$NON-NLS-1$
 
-    private static Command resolveVirtualGroup(GroupSymbol virtualGroup, Command parentCommand, QueryMetadataInterface metadata, AnalysisRecord analysis)
-    throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-        QueryNode qnode = null;
-        
-        Object metadataID = virtualGroup.getMetadataID();
-        boolean isSelectInto = ((Query)parentCommand).getInto() != null;
-        boolean isMaterializedViewLoad = false;
-        boolean noCache = false;
-        boolean cacheCommand = false;
-        boolean isMaterializedGroup = metadata.hasMaterialization(metadataID);
-        if( isMaterializedGroup) {
-            if(isSelectInto) {
-                //Case 2945: Only bypass Mat View logic if this is an explicit load into 
-                //the Matierialzed View.
-                final Object intoGrpID = ((Query)parentCommand).getInto().getGroup().getMetadataID();
-                final Object matID = metadata.getMaterialization(metadataID);
-                final Object matSTID =  metadata.getMaterializationStage(metadataID);
-                if(matID != null) {
-                    isMaterializedViewLoad = matID.equals(intoGrpID);
-                }
-                
-                if(matSTID != null && !isMaterializedViewLoad) {
-                    isMaterializedViewLoad = matSTID.equals(intoGrpID);
-                }
-            }
-
-            Option option  = parentCommand.getOption();
-            noCache = isNoCacheGroup(metadata, metadataID, option);
-        	if(noCache){
-        		//not use cache
-        		qnode = metadata.getVirtualPlan(metadataID);
-        		String matTableName = metadata.getFullName(metadata.getMaterialization(metadataID));
-        		recordMaterializedTableNotUsedAnnotation(virtualGroup, analysis, matTableName);
-        	}else{
-	            if(!isMaterializedViewLoad) {           	
-	                // Default query for a materialized group - go to cached table
-	                String groupName = metadata.getFullName(metadataID);
-	                String matTableName = metadata.getFullName(metadata.getMaterialization(metadataID));
-	                qnode = new QueryNode(groupName, "SELECT * FROM " + matTableName); //$NON-NLS-1$
-	                
-	                recordMaterializationTableAnnotation(virtualGroup, analysis, matTableName);                
-	            } else {
-	                // Loading due to SELECT INTO - query the primary transformation
-	                qnode = metadata.getVirtualPlan(metadataID);
-	
-	                recordLoadingMaterializationTableAnnotation(virtualGroup, analysis);                
-	            }
-        	}
-        } else {
-            if (metadata.isXMLGroup(virtualGroup.getMetadataID())) {
-                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0003, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0003));
-            }
-            cacheCommand = true;
-            Command command = (Command)metadata.getFromMetadataCache(virtualGroup.getMetadataID(), "transformation/select"); //$NON-NLS-1$
-            if (command != null) {
-            	command = (Command)command.clone();
-            	command.setVirtualGroup(virtualGroup);
-            	return command;
-            }
-            // Not a materialized view - query the primary transformation
-            qnode = metadata.getVirtualPlan(metadataID);            
-        }
-        
-        Command subCommand = convertToSubquery(qnode, noCache, metadata);
-        subCommand.setVirtualGroup(virtualGroup);
-        QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, true, metadata, analysis);
-        if (cacheCommand) {
-        	metadata.addToMetadataCache(virtualGroup.getMetadataID(), "transformation/select", subCommand.clone()); //$NON-NLS-1$
-        }        
-        return subCommand;
-    }
-
     /** 
-     * @param metadata
-     * @param metadataID
-     * @param noCache
-     * @param option
-     * @return
-     * @throws QueryMetadataException
-     * @throws MetaMatrixComponentException
+     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
      */
-    public static boolean isNoCacheGroup(QueryMetadataInterface metadata,
-                                          Object metadataID,
-                                          Option option) throws QueryMetadataException,
-                                                        MetaMatrixComponentException {
-        if(option == null){
-            return false;
-        }
-    	if(option.isNoCache() && (option.getNoCacheGroups() == null || option.getNoCacheGroups().isEmpty())){
-    		//only OPTION NOCACHE, no group specified
-    		return true;
-    	}       
-        if(option.getNoCacheGroups() != null){
-            for(int i=0; i< option.getNoCacheGroups().size(); i++){
-                String groupName = (String)option.getNoCacheGroups().get(i);
-                try {
-                    Object noCacheGroupID = metadata.getGroupID(groupName);
-                    if(metadataID.equals(noCacheGroupID)){
-                        return true;
-                    }
-                } catch (QueryMetadataException e) {
-                    //log that an unknown groups was used in the no cache
-                    LogManager.logWarning(LogConstants.CTX_QUERY_RESOLVER, e, QueryPlugin.Util.getString("SimpleQueryResolver.unknown_group_in_nocache", groupName)); //$NON-NLS-1$
-                }
-            }
-    	}
-        return false;
-    }
-    
-    /**
-	 * @param virtualGroup
-	 * @param analysis
-	 */
-	private static void recordMaterializedTableNotUsedAnnotation(GroupSymbol virtualGroup, AnalysisRecord analysis, String matTableName) {
-        if ( analysis.recordAnnotations() ) {
-            Object[] params = new Object[] {virtualGroup, matTableName};
-            QueryAnnotation annotation = new QueryAnnotation(QueryAnnotation.MATERIALIZED_VIEW, 
-                                                         QueryPlugin.Util.getString("SimpleQueryResolver.materialized_table_not_used", params),  //$NON-NLS-1$
-                                                         null, 
-                                                         QueryAnnotation.LOW);
-            analysis.addAnnotation(annotation);
-        }
-	}
-
-	/** 
-     * @param virtualGroup
-     * @param analysis
-     * @param matTableName
-     * @since 4.2
-     */
-    private static void recordMaterializationTableAnnotation(GroupSymbol virtualGroup,
-                                                      AnalysisRecord analysis,
-                                                      String matTableName) {
-        if ( analysis.recordAnnotations() ) {
-            Object[] params = new Object[] {virtualGroup, matTableName};
-            QueryAnnotation annotation = new QueryAnnotation(QueryAnnotation.MATERIALIZED_VIEW, 
-                                                         QueryPlugin.Util.getString("SimpleQueryResolver.Query_was_redirected_to_Mat_table", params),  //$NON-NLS-1$
-                                                         null, 
-                                                         QueryAnnotation.LOW);
-            analysis.addAnnotation(annotation);
-        }
-    }
-
-    /** 
-     * @param virtualGroup
-     * @param analysis
-     * @param matTableName
-     * @since 4.2
-     */
-    private static void recordLoadingMaterializationTableAnnotation(GroupSymbol virtualGroup,
-                                                      AnalysisRecord analysis) {
-        if ( analysis.recordAnnotations() ) {
-            Object[] params = new Object[] {virtualGroup};
-            QueryAnnotation annotation = new QueryAnnotation(QueryAnnotation.MATERIALIZED_VIEW, 
-                                                         QueryPlugin.Util.getString("SimpleQueryResolver.Loading_materialized_table", params),  //$NON-NLS-1$
-                                                         null, 
-                                                         QueryAnnotation.LOW);
-            analysis.addAnnotation(annotation);
-        }
-    }
-
-    private static Command convertToSubquery(QueryNode qnode, boolean nocache, QueryMetadataInterface metadata)
-    throws QueryResolverException, MetaMatrixComponentException {
-
-        // Parse this node's command
-        Command command = qnode.getCommand();
-        
-        if (command == null) {
-            try {
-                command = QueryParser.getQueryParser().parseCommand(qnode.getQuery());
-            } catch(QueryParserException e) {
-                throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0011, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0011, qnode.getGroupName()));
-            }
-            
-            //Handle bindings and references
-            List bindings = qnode.getBindings();
-            if (bindings != null){
-                BindVariableVisitor.bindReferences(command, bindings, metadata);
-            }
-        }
-        
-        if (nocache) {
-            Option option = command.getOption();
-            if (option == null) {
-                option = new Option();
-                command.setOption(option);
-            }
-            option.setNoCache(true);
-            if (option.getNoCacheGroups() != null) {
-                option.getNoCacheGroups().clear();
-            }
-        }
-
-        return command;
-    }
-
-    /** 
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
-     */
-    public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
+    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
         Query query = (Query) command;
         
         try {
-            QueryResolverVisitor qrv = new QueryResolverVisitor(query, metadata, useMetadataCommands, analysis);
+            QueryResolverVisitor qrv = new QueryResolverVisitor(query, metadata, analysis);
             qrv.visit(query);
             ResolverVisitor visitor = (ResolverVisitor)qrv.getVisitor();
 			visitor.throwException(true);
@@ -316,6 +111,10 @@
             ResolverUtil.resolveLimit(query.getLimit());
         }
         
+        if (query.getOrderBy() != null) {
+        	ResolverUtil.resolveOrderBy(query.getOrderBy(), query, metadata);
+        }
+        
         List symbols = query.getSelect().getProjectedSymbols();
         
         if (query.getInto() != null) {
@@ -326,11 +125,11 @@
         }
     }
 
-    private static GroupSymbol resolveAllInGroup(AllInGroupSymbol allInGroupSymbol, Set groups, QueryMetadataInterface metadata) throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {       
+    private static GroupSymbol resolveAllInGroup(AllInGroupSymbol allInGroupSymbol, Set<GroupSymbol> groups, QueryMetadataInterface metadata) throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {       
         String name = allInGroupSymbol.getName();
         int index = name.lastIndexOf(ALL_IN_GROUP_SUFFIX);
         String groupAlias = name.substring(0, index);
-        List groupSymbols = ResolverUtil.findMatchingGroups(groupAlias.toUpperCase(), groups, metadata);
+        List<GroupSymbol> groupSymbols = ResolverUtil.findMatchingGroups(groupAlias.toUpperCase(), groups, metadata);
         if(groupSymbols.isEmpty() || groupSymbols.size() > 1) {
             String msg = QueryPlugin.Util.getString(groupSymbols.isEmpty()?ErrorMessageKeys.RESOLVER_0047:"SimpleQueryResolver.ambiguous_all_in_group", allInGroupSymbol);  //$NON-NLS-1$
             QueryResolverException qre = new QueryResolverException(msg);
@@ -338,7 +137,7 @@
             throw qre;
         }
 
-        return (GroupSymbol)groupSymbols.get(0);
+        return groupSymbols.get(0);
     }
     
     public static class QueryResolverVisitor extends PostOrderNavigator {
@@ -346,17 +145,15 @@
         private LinkedHashSet<GroupSymbol> currentGroups = new LinkedHashSet<GroupSymbol>();
         private List<GroupSymbol> discoveredGroups = new LinkedList<GroupSymbol>();
         private TempMetadataAdapter metadata;
-        private boolean expandCommand;
         private Query query;
         private AnalysisRecord analysis;
         
-        public QueryResolverVisitor(Query query, TempMetadataAdapter metadata, boolean expandCommand, AnalysisRecord record) {
+        public QueryResolverVisitor(Query query, TempMetadataAdapter metadata, AnalysisRecord record) {
             super(new ResolverVisitor(metadata, null, query.getExternalGroupContexts()));
             ResolverVisitor visitor = (ResolverVisitor)getVisitor();
             visitor.setGroups(currentGroups);
             this.query = query;
             this.metadata = metadata;
-            this.expandCommand = expandCommand;
             this.analysis = record;
         }
         
@@ -374,8 +171,6 @@
                 
         /**
          * Resolving a Query requires a special ordering
-         * 
-         * Note that into is actually first to handle mat view logic
          */
         public void visit(Query obj) {
             visitNode(obj.getInto());
@@ -384,7 +179,6 @@
             visitNode(obj.getGroupBy());
             visitNode(obj.getHaving());
             visitNode(obj.getSelect());        
-            visitNode(obj.getOrderBy());
         }
         
         public void visit(GroupSymbol obj) {
@@ -404,7 +198,7 @@
             command.pushNewResolvingContext(this.currentGroups);
             
             try {
-                QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, expandCommand, metadata.getMetadata(), analysis, false);
+                QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata.getMetadata(), analysis, false);
             } catch (QueryResolverException err) {
                 throw new MetaMatrixRuntimeException(err);
             } catch (MetaMatrixComponentException err) {
@@ -414,14 +208,9 @@
         
         public void visit(AllSymbol obj) {
             try {
-                List elementSymbols = new ArrayList();
-                Iterator groupIter = currentGroups.iterator();
-                while(groupIter.hasNext()){
-                    GroupSymbol group = (GroupSymbol)groupIter.next();
-    
-                    List elements = resolveSelectableElements(group);
-    
-                    elementSymbols.addAll(elements);
+                List<ElementSymbol> elementSymbols = new ArrayList<ElementSymbol>();
+                for (GroupSymbol group : currentGroups) {
+                    elementSymbols.addAll(resolveSelectableElements(group));
                 }
                 obj.setElementSymbols(elementSymbols);
             } catch (MetaMatrixComponentException err) {
@@ -429,16 +218,14 @@
             } 
         }
 
-        private List resolveSelectableElements(GroupSymbol group) throws QueryMetadataException,
+        private List<ElementSymbol> resolveSelectableElements(GroupSymbol group) throws QueryMetadataException,
                                                                  MetaMatrixComponentException {
-            List elements = ResolverUtil.resolveElementsInGroup(group, metadata);
+            List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(group, metadata);
             
-            List result = new ArrayList(elements.size());
+            List<ElementSymbol> result = new ArrayList<ElementSymbol>(elements.size());
    
             // Look for elements that are not selectable and remove them
-            Iterator elementIter = elements.iterator();
-            while(elementIter.hasNext()) {
-                ElementSymbol element = (ElementSymbol) elementIter.next();
+            for (ElementSymbol element : elements) {
                 if(metadata.elementSupports(element.getMetadataID(), SupportConstants.Element.SELECT)) {
                     element = (ElementSymbol)element.clone();
                     element.setGroupSymbol(group);
@@ -453,7 +240,7 @@
             try {
                 GroupSymbol group = resolveAllInGroup(obj, currentGroups, metadata);
                 
-                List elements = resolveSelectableElements(group);
+                List<ElementSymbol> elements = resolveSelectableElements(group);
                 
                 obj.setElementSymbols(elements);
             } catch (QueryResolverException err) {
@@ -466,7 +253,7 @@
         public void visit(ScalarSubquery obj) {
             resolveSubQuery(obj);
             
-            Collection projSymbols = obj.getCommand().getProjectedSymbols();
+            Collection<SingleElementSymbol> projSymbols = obj.getCommand().getProjectedSymbols();
 
             //Scalar subquery should have one projected symbol (query with one expression
             //in SELECT or stored procedure execution that returns a single value).
@@ -506,120 +293,106 @@
         public void visit(UnaryFromClause obj) {
             GroupSymbol group = obj.getGroup();
             visitNode(group);
-            this.discoveredGroups.add(group);
-            
             try {
-                if (expandCommand
-                    && !group.isTempGroupSymbol()
-                    && !group.isProcedure()
-                    && (!(group.getMetadataID() instanceof TempMetadataID) || metadata.getVirtualPlan(group.getMetadataID()) != null)
-                    && (metadata.isVirtualGroup(group.getMetadataID()))) {
-                    
-                    Command command = resolveVirtualGroup(group, query, metadata.getMetadata(), analysis);                    
-                    obj.setExpandedCommand(command);
-                } else if (group.isProcedure()) {
-                    //"relational" select of a virtual procedure
-                    String fullName = metadata.getFullName(group.getMetadataID());
-                    String queryName = group.getName();
-                    
-                    StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(fullName);
-
-                    StoredProcedure storedProcedureCommand = new StoredProcedure();
-                    storedProcedureCommand.setProcedureRelational(true);
-                    storedProcedureCommand.setProcedureName(fullName);
-                    
-                    List metadataParams = storedProcedureInfo.getParameters();
-                    
-                    Query procQuery = new Query();
-                    From from = new From();
-                    from.addClause(new SubqueryFromClause("X", storedProcedureCommand)); //$NON-NLS-1$
-                    procQuery.setFrom(from);
-                    Select select = new Select();
-                    select.addSymbol(new AllInGroupSymbol("X.*")); //$NON-NLS-1$
-                    procQuery.setSelect(select);
-                    
-                    List accessPatternElementNames = new LinkedList();
-                    
-                    int paramIndex = 1;
-                    
-                    for(Iterator paramIter = metadataParams.iterator(); paramIter.hasNext();){
-                        SPParameter metadataParameter  = (SPParameter)paramIter.next();
-                        SPParameter clonedParam = (SPParameter)metadataParameter.clone();
-                        if (clonedParam.getParameterType()==ParameterInfo.IN || metadataParameter.getParameterType()==ParameterInfo.INOUT) {
-                            ElementSymbol paramSymbol = clonedParam.getParameterSymbol();
-                            Reference ref = new Reference(paramSymbol);
-                            clonedParam.setExpression(ref);
-                            clonedParam.setIndex(paramIndex++);
-                            storedProcedureCommand.setParameter(clonedParam);
-                            
-                            String aliasName = paramSymbol.getShortName();
-                            
-                            if (metadataParameter.getParameterType()==ParameterInfo.INOUT) {
-                                aliasName += "_IN"; //$NON-NLS-1$
-                            }
-                            
-                            SingleElementSymbol newSymbol = new AliasSymbol(aliasName, new ExpressionSymbol(paramSymbol.getShortName(), ref));
-                            
-                            select.addSymbol(newSymbol);
-                            accessPatternElementNames.add(queryName + ElementSymbol.SEPARATOR + aliasName);
-                        }
-                    }
-                    
-                    QueryResolver.resolveCommand(procQuery, Collections.EMPTY_MAP, expandCommand, metadata.getMetadata(), analysis);
-                    
-                    List projectedSymbols = procQuery.getProjectedSymbols();
-                    
-                    HashSet foundNames = new HashSet();
-                    
-                    for (Iterator i = projectedSymbols.iterator(); i.hasNext();) {
-                        SingleElementSymbol ses = (SingleElementSymbol)i.next();
-                        if (!foundNames.add(ses.getShortCanonicalName())) {
-                            throw new QueryResolverException(QueryPlugin.Util.getString("SimpleQueryResolver.Proc_Relational_Name_conflict", fullName)); //$NON-NLS-1$                            
-                        }
-                    }
-                    
-                    TempMetadataID id = metadata.getMetadataStore().getTempGroupID(queryName);
-
-                    if (id == null) {
-                        metadata.getMetadataStore().addTempGroup(queryName, projectedSymbols, true);
-                        
-                        id = metadata.getMetadataStore().getTempGroupID(queryName);
-                        id.setOriginalMetadataID(storedProcedureCommand.getProcedureID());
-                        List accessPatternIds = new LinkedList();
-                        
-                        for (Iterator i = accessPatternElementNames.iterator(); i.hasNext();) {
-                            String name = (String)i.next();
-                            accessPatternIds.add(metadata.getMetadataStore().getTempElementID(name));
-                        }
-                        
-                        id.setAccessPatterns(Arrays.asList(new TempMetadataID("procedure access pattern", accessPatternIds))); //$NON-NLS-1$
-                    }
-                    
-                    group.setMetadataID(id);
-                    group.setProcedure(true);
-                    procQuery.setVirtualGroup(group);
-                    
-                    if (expandCommand) {
-                        obj.setExpandedCommand(procQuery);
-                    }
-                }
+	            if (metadata.isXMLGroup(group.getMetadataID())) {
+	                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0003, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0003));
+	            }
+	            this.discoveredGroups.add(group);
+	            if (group.isProcedure()) {
+	                createProcRelational(obj);
+	            }
             } catch(QueryResolverException e) {
                 throw new MetaMatrixRuntimeException(e);
             } catch(MetaMatrixComponentException e) {
                 throw new MetaMatrixRuntimeException(e);                        
 			}
         }
+
+		private void createProcRelational(UnaryFromClause obj)
+				throws MetaMatrixComponentException, QueryMetadataException,
+				QueryResolverException {
+			GroupSymbol group = obj.getGroup();
+			String fullName = metadata.getFullName(group.getMetadataID());
+			String queryName = group.getName();
+			
+			StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(fullName);
+
+			StoredProcedure storedProcedureCommand = new StoredProcedure();
+			storedProcedureCommand.setProcedureRelational(true);
+			storedProcedureCommand.setProcedureName(fullName);
+			
+			List metadataParams = storedProcedureInfo.getParameters();
+			
+			Query procQuery = new Query();
+			From from = new From();
+			from.addClause(new SubqueryFromClause("X", storedProcedureCommand)); //$NON-NLS-1$
+			procQuery.setFrom(from);
+			Select select = new Select();
+			select.addSymbol(new AllInGroupSymbol("X.*")); //$NON-NLS-1$
+			procQuery.setSelect(select);
+			
+			List<String> accessPatternElementNames = new LinkedList<String>();
+			
+			int paramIndex = 1;
+			
+			for(Iterator paramIter = metadataParams.iterator(); paramIter.hasNext();){
+			    SPParameter metadataParameter  = (SPParameter)paramIter.next();
+			    SPParameter clonedParam = (SPParameter)metadataParameter.clone();
+			    if (clonedParam.getParameterType()==ParameterInfo.IN || metadataParameter.getParameterType()==ParameterInfo.INOUT) {
+			        ElementSymbol paramSymbol = clonedParam.getParameterSymbol();
+			        Reference ref = new Reference(paramSymbol);
+			        clonedParam.setExpression(ref);
+			        clonedParam.setIndex(paramIndex++);
+			        storedProcedureCommand.setParameter(clonedParam);
+			        
+			        String aliasName = paramSymbol.getShortName();
+			        
+			        if (metadataParameter.getParameterType()==ParameterInfo.INOUT) {
+			            aliasName += "_IN"; //$NON-NLS-1$
+			        }
+			        
+			        SingleElementSymbol newSymbol = new AliasSymbol(aliasName, new ExpressionSymbol(paramSymbol.getShortName(), ref));
+			        
+			        select.addSymbol(newSymbol);
+			        accessPatternElementNames.add(queryName + ElementSymbol.SEPARATOR + aliasName);
+			    }
+			}
+			
+			QueryResolver.resolveCommand(procQuery, Collections.EMPTY_MAP, metadata.getMetadata(), analysis);
+			
+			List projectedSymbols = procQuery.getProjectedSymbols();
+			
+			HashSet<String> foundNames = new HashSet<String>();
+			
+			for (Iterator i = projectedSymbols.iterator(); i.hasNext();) {
+			    SingleElementSymbol ses = (SingleElementSymbol)i.next();
+			    if (!foundNames.add(ses.getShortCanonicalName())) {
+			        throw new QueryResolverException(QueryPlugin.Util.getString("SimpleQueryResolver.Proc_Relational_Name_conflict", fullName)); //$NON-NLS-1$                            
+			    }
+			}
+			
+			TempMetadataID id = metadata.getMetadataStore().getTempGroupID(queryName);
+
+			if (id == null) {
+			    metadata.getMetadataStore().addTempGroup(queryName, projectedSymbols, true);
+			    
+			    id = metadata.getMetadataStore().getTempGroupID(queryName);
+			    id.setOriginalMetadataID(storedProcedureCommand.getProcedureID());
+			    List accessPatternIds = new LinkedList();
+			    
+			    for (Iterator i = accessPatternElementNames.iterator(); i.hasNext();) {
+			        String name = (String)i.next();
+			        accessPatternIds.add(metadata.getMetadataStore().getTempElementID(name));
+			    }
+			    
+			    id.setAccessPatterns(Arrays.asList(new TempMetadataID("procedure access pattern", accessPatternIds))); //$NON-NLS-1$
+			}
+			
+			group.setMetadataID(id);
+			
+		    obj.setExpandedCommand(procQuery);
+		}
         
-        public void visit(OrderBy obj) {
-            try {
-                ResolverUtil.resolveOrderBy(obj, query, metadata);
-            } catch(QueryResolverException e) {
-                throw new MetaMatrixRuntimeException(e);
-            } catch(MetaMatrixComponentException e) {
-                throw new MetaMatrixRuntimeException(e);                        
-            }
-        }
-        
         /** 
          * @see com.metamatrix.query.sql.navigator.PreOrPostOrderNavigator#visit(com.metamatrix.query.sql.lang.Into)
          */
@@ -658,5 +431,4 @@
             addDiscoveredGroups();
         }
     }
-
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -49,9 +49,9 @@
 public class TempTableResolver implements CommandResolver {
 
     /** 
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
+     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
      */
-    public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
+    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
         
         if(command.getType() == Command.TYPE_CREATE) {

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -79,7 +79,7 @@
  */
 public class UpdateProcedureResolver implements CommandResolver {
 
-    public void resolveVirtualGroupElements(CreateUpdateProcedureCommand procCommand, boolean useMetadataCommands, QueryMetadataInterface metadata)
+    public void resolveVirtualGroupElements(CreateUpdateProcedureCommand procCommand, QueryMetadataInterface metadata)
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
 		// virtual group on procedure
@@ -109,26 +109,23 @@
 
 		ResolveVirtualGroupCriteriaVisitor.resolveCriteria(procCommand, virtualGroup, metadata);
 
-		// symbol map need not be checked as we are not validating
-		// in the modeler
-		if(useMetadataCommands) {
-	    	// get a symbol map between virtual elements and the elements that define
-	    	// then in the query transformation, this info is used in evaluating/validating
-	    	// has criteria/trnaslate criteria clauses
-			Command transformCmd = getQueryTransformCmd(virtualGroup, metadata);
-			Map symbolMap = SymbolMap.createSymbolMap(virtualGroup, (List<SingleElementSymbol>)transformCmd.getProjectedSymbols()).asMap();
-	        // set the symbolMap on the procedure
-			procCommand.setSymbolMap(symbolMap);
-		}
+    	// get a symbol map between virtual elements and the elements that define
+    	// then in the query transformation, this info is used in evaluating/validating
+    	// has criteria/translate criteria clauses
+        Command transformCmd = getQueryTransformCmd(virtualGroup, metadata);
+		Map symbolMap = SymbolMap.createSymbolMap(virtualGroup, (List<SingleElementSymbol>)transformCmd.getProjectedSymbols()).asMap();
+		procCommand.setSymbolMap(symbolMap);
     }
-
-	/**
+    
+    /**
 	 * Get the command for the transformation query that defines this virtual group.
 	 */
     private Command getQueryTransformCmd(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
     throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
-
-        Command transformCmd = null;
+    	Command transformCmd = (Command)metadata.getFromMetadataCache(virtualGroup.getMetadataID(), "transformation/select"); //$NON-NLS-1$
+    	if (transformCmd != null) {
+    		return transformCmd;
+    	}
     	QueryNode queryNode = metadata.getVirtualPlan(virtualGroup.getMetadataID());
     	String transformQuery = queryNode.getQuery();
         try {
@@ -143,9 +140,9 @@
     }
 
     /**
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, java.util.Collection, TempMetadataAdapter, AnalysisRecord, boolean)
+     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
      */
-    public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
+    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
         CreateUpdateProcedureCommand procCommand = (CreateUpdateProcedureCommand) command;
@@ -157,7 +154,7 @@
         
         // virtual group elements in HAS and TRANSLATE criteria have to be resolved
         if(procCommand.isUpdateProcedure()){
-            resolveVirtualGroupElements(procCommand, useMetadataCommands, metadata);
+            resolveVirtualGroupElements(procCommand, metadata);
 
             //add the default variables
             String countVar = ProcedureReservedWords.VARIABLES + ElementSymbol.SEPARATOR + ProcedureReservedWords.ROWS_UPDATED;
@@ -167,11 +164,11 @@
             ProcedureContainerResolver.addScalarGroup(ProcedureReservedWords.VARIABLES, metadata.getMetadataStore(), externalGroups, symbols);         
         }
         
-        resolveBlock(procCommand, procCommand.getBlock(), externalGroups, metadata, useMetadataCommands, procCommand.isUpdateProcedure(), analysis);
+        resolveBlock(procCommand, procCommand.getBlock(), externalGroups, metadata, procCommand.isUpdateProcedure(), analysis);
     }
 
 	private void resolveBlock(CreateUpdateProcedureCommand command, Block block, GroupContext externalGroups, 
-                              TempMetadataAdapter metadata, boolean useMetadataCommands, boolean isUpdateProcedure, AnalysisRecord analysis)
+                              TempMetadataAdapter metadata, boolean isUpdateProcedure, AnalysisRecord analysis)
         throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
         LogManager.logTrace(LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving block", block}); //$NON-NLS-1$
         
@@ -185,11 +182,11 @@
         
         Iterator stmtIter = block.getStatements().iterator();
         while(stmtIter.hasNext()) {
-            resolveStatement(command, (Statement)stmtIter.next(), externalGroups, variables, metadata, useMetadataCommands, isUpdateProcedure, analysis);
+            resolveStatement(command, (Statement)stmtIter.next(), externalGroups, variables, metadata, isUpdateProcedure, analysis);
         }
     }
 
-	private void resolveStatement(CreateUpdateProcedureCommand command, Statement statement, GroupContext externalGroups, GroupSymbol variables, TempMetadataAdapter metadata, boolean expandCommand, boolean isUpdateProcedure, AnalysisRecord analysis)
+	private void resolveStatement(CreateUpdateProcedureCommand command, Statement statement, GroupContext externalGroups, GroupSymbol variables, TempMetadataAdapter metadata, boolean isUpdateProcedure, AnalysisRecord analysis)
         throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
         LogManager.logTrace(LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving statement", statement}); //$NON-NLS-1$
 
@@ -198,19 +195,19 @@
                 IfStatement ifStmt = (IfStatement) statement;
                 Criteria ifCrit = ifStmt.getCondition();
                 for (SubqueryContainer container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(ifCrit)) {
-                	resolveEmbeddedCommand(metadata, externalGroups, container.getCommand(), expandCommand, analysis);
+                	resolveEmbeddedCommand(metadata, externalGroups, container.getCommand(), analysis);
                 }
                 ResolverVisitor.resolveLanguageObject(ifCrit, null, externalGroups, metadata);
-            	resolveBlock(command, ifStmt.getIfBlock(), externalGroups, metadata, expandCommand, isUpdateProcedure, analysis);
+            	resolveBlock(command, ifStmt.getIfBlock(), externalGroups, metadata, isUpdateProcedure, analysis);
                 if(ifStmt.hasElseBlock()) {
-                    resolveBlock(command, ifStmt.getElseBlock(), externalGroups, metadata, expandCommand, isUpdateProcedure, analysis);
+                    resolveBlock(command, ifStmt.getElseBlock(), externalGroups, metadata, isUpdateProcedure, analysis);
                 }
                 break;
             case Statement.TYPE_COMMAND:
                 CommandStatement cmdStmt = (CommandStatement) statement;
                 Command subCommand = cmdStmt.getCommand();
                 
-                TempMetadataStore discoveredMetadata = resolveEmbeddedCommand(metadata, externalGroups, subCommand, expandCommand, analysis);
+                TempMetadataStore discoveredMetadata = resolveEmbeddedCommand(metadata, externalGroups, subCommand, analysis);
                 
                 if (discoveredMetadata != null) {
                     metadata.getMetadataStore().getData().putAll(discoveredMetadata.getData());
@@ -220,12 +217,9 @@
                 if (subCommand instanceof DynamicCommand) {
                     DynamicCommand dynCommand = (DynamicCommand)subCommand;
                     
-                    if(dynCommand.getIntoGroup() == null && !command.isUpdateProcedure() && !dynCommand.isAsClauseSet()) {
-                        if (command.getProjectedSymbols().size() > 0) {
-                            dynCommand.setAsColumns(command.getProjectedSymbols());
-                        } else if (command.getParentProjectSymbols() != null) {
-                            dynCommand.setAsColumns(command.getParentProjectSymbols());
-                        }
+                    if(dynCommand.getIntoGroup() == null && !command.isUpdateProcedure() 
+                    		&& !dynCommand.isAsClauseSet() && !command.getProjectedSymbols().isEmpty()) {
+                        dynCommand.setAsColumns(command.getProjectedSymbols());
                     }
                 }
                 
@@ -251,11 +245,11 @@
             	if (assStmt.getValue() != null) {
 					if (assStmt.hasCommand()) {
 						Command cmd = assStmt.getCommand();
-						resolveEmbeddedCommand(metadata, externalGroups, cmd, expandCommand, analysis);
+						resolveEmbeddedCommand(metadata, externalGroups, cmd, analysis);
 					} else if (assStmt.hasExpression()) {
                         Expression expr = assStmt.getExpression();
                         for (SubqueryContainer container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(expr)) {
-                        	resolveEmbeddedCommand(metadata, externalGroups, container.getCommand(), expandCommand, analysis);
+                        	resolveEmbeddedCommand(metadata, externalGroups, container.getCommand(), analysis);
                         }
                         ResolverVisitor.resolveLanguageObject(expr, null, externalGroups, metadata);
                     }
@@ -291,10 +285,10 @@
                 WhileStatement whileStmt = (WhileStatement) statement;
                 Criteria whileCrit = whileStmt.getCondition();
                 for (SubqueryContainer container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(whileCrit)) {
-                	resolveEmbeddedCommand(metadata, externalGroups, container.getCommand(), expandCommand, analysis);
+                	resolveEmbeddedCommand(metadata, externalGroups, container.getCommand(), analysis);
                 }
                 ResolverVisitor.resolveLanguageObject(whileCrit, null, externalGroups, metadata);
-                resolveBlock(command, whileStmt.getBlock(), externalGroups, metadata, expandCommand, isUpdateProcedure, analysis);
+                resolveBlock(command, whileStmt.getBlock(), externalGroups, metadata, isUpdateProcedure, analysis);
                 break;
             case Statement.TYPE_LOOP:
                 LoopStatement loopStmt = (LoopStatement) statement;
@@ -310,7 +304,7 @@
 	        		throw new QueryResolverException(errorMsg);
 	        	}
                 Command cmd = loopStmt.getCommand();
-                resolveEmbeddedCommand(metadata, externalGroups, cmd, expandCommand, analysis);
+                resolveEmbeddedCommand(metadata, externalGroups, cmd, analysis);
                 List symbols = cmd.getProjectedSymbols();
                 
                 //add the loop cursor group into its own context
@@ -320,7 +314,7 @@
                 
                 ProcedureContainerResolver.addScalarGroup(groupName, store, externalGroups, symbols);
                 
-                resolveBlock(command, loopStmt.getBlock(), externalGroups, metadata, expandCommand, isUpdateProcedure, analysis);
+                resolveBlock(command, loopStmt.getBlock(), externalGroups, metadata, isUpdateProcedure, analysis);
                 break;
             case Statement.TYPE_BREAK:
             case Statement.TYPE_CONTINUE:
@@ -331,11 +325,11 @@
     }
 
     private TempMetadataStore resolveEmbeddedCommand(TempMetadataAdapter metadata, GroupContext groupContext,
-                                Command cmd, boolean expandCommand, AnalysisRecord analysis) throws MetaMatrixComponentException,
+                                Command cmd, AnalysisRecord analysis) throws MetaMatrixComponentException,
                                             QueryResolverException {
         QueryResolver.setChildMetadata(cmd, metadata.getMetadataStore().getData(), groupContext);
         
-        return QueryResolver.resolveCommand(cmd, Collections.EMPTY_MAP, expandCommand, metadata.getMetadata(), analysis);
+        return QueryResolver.resolveCommand(cmd, Collections.EMPTY_MAP, metadata.getMetadata(), analysis);
     }
         
     private void collectDeclareVariable(DeclareStatement obj, GroupSymbol variables, TempMetadataAdapter metadata, GroupContext externalGroups) throws QueryResolverException, MetaMatrixComponentException {

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -56,9 +56,9 @@
 public class UpdateResolver extends ProcedureContainerResolver implements VariableResolver {
 
     /** 
-     * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
+     * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
      */
-    public void resolveProceduralCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis) 
+    public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
         //Cast to known type

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XMLQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XMLQueryResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XMLQueryResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -63,9 +63,9 @@
 public class XMLQueryResolver implements CommandResolver {
 
     /**
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, java.util.Collection, TempMetadataAdapter, AnalysisRecord, boolean)
+     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
      */
-	public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
+	public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
 		throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
 
 		Query query = (Query) command;
@@ -96,7 +96,7 @@
             
             QueryResolver.setChildMetadata(subCommand, command);
             
-            QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis);
+            QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, metadata.getMetadata(), analysis);
         }
         
 		if(crit != null) {

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XQueryResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XQueryResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -44,9 +44,9 @@
 public class XQueryResolver implements CommandResolver {
 
     /** 
-     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
+     * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
      */
-    public void resolveCommand(Command command, boolean useMetadataCommands, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
+    public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals) 
         throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
     }
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -708,8 +708,8 @@
      * @throws MetaMatrixComponentException
      * @throws QueryMetadataException
      */
-    public static List findMatchingGroups(String groupContext,
-                            Collection groups,
+    public static List<GroupSymbol> findMatchingGroups(String groupContext,
+                            Collection<GroupSymbol> groups,
                             QueryMetadataInterface metadata) throws MetaMatrixComponentException,
                                                             QueryMetadataException {
 
@@ -717,14 +717,12 @@
             return null;
         }
 
-        LinkedList matchedGroups = new LinkedList();
+        LinkedList<GroupSymbol> matchedGroups = new LinkedList<GroupSymbol>();
 
         if (groupContext == null) {
             matchedGroups.addAll(groups);
         } else {
-            Iterator iter = groups.iterator();
-            while (iter.hasNext()) {
-                GroupSymbol group = (GroupSymbol)iter.next();
+        	for (GroupSymbol group : groups) {
                 String fullName = group.getCanonicalName();
                 if (nameMatchesGroup(groupContext, matchedGroups, group, fullName)) {
                     if (groupContext.length() == fullName.length()) {
@@ -767,7 +765,7 @@
     }
     
     private static boolean nameMatchesGroup(String groupContext,
-                                            LinkedList matchedGroups,
+                                            LinkedList<GroupSymbol> matchedGroups,
                                             GroupSymbol group,
                                             String fullName) {
         if (nameMatchesGroup(groupContext, fullName)) {

Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -52,7 +52,6 @@
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BlockedException;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.common.util.TimestampWithTimezone;
 import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -64,7 +63,6 @@
 import com.metamatrix.query.function.FunctionLibraryManager;
 import com.metamatrix.query.function.FunctionMethods;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
 import com.metamatrix.query.metadata.TempMetadataAdapter;
 import com.metamatrix.query.metadata.TempMetadataStore;
 import com.metamatrix.query.processor.ProcessorDataManager;
@@ -76,9 +74,9 @@
 import com.metamatrix.query.sql.ProcedureReservedWords;
 import com.metamatrix.query.sql.ReservedWords;
 import com.metamatrix.query.sql.lang.AbstractSetCriteria;
+import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
 import com.metamatrix.query.sql.lang.BetweenCriteria;
 import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CommandContainer;
 import com.metamatrix.query.sql.lang.CompareCriteria;
 import com.metamatrix.query.sql.lang.CompoundCriteria;
 import com.metamatrix.query.sql.lang.Criteria;
@@ -96,9 +94,7 @@
 import com.metamatrix.query.sql.lang.Limit;
 import com.metamatrix.query.sql.lang.MatchCriteria;
 import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.Option;
 import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.QueryCommand;
 import com.metamatrix.query.sql.lang.SPParameter;
@@ -115,7 +111,6 @@
 import com.metamatrix.query.sql.lang.TranslatableProcedureContainer;
 import com.metamatrix.query.sql.lang.UnaryFromClause;
 import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.lang.XQuery;
 import com.metamatrix.query.sql.lang.PredicateCriteria.Negatable;
 import com.metamatrix.query.sql.navigator.PostOrderNavigator;
 import com.metamatrix.query.sql.navigator.PreOrderNavigator;
@@ -224,8 +219,8 @@
 		return rewriter.rewriteCommand(command, false);
 	}
     
-	public static Command rewrite(Command command, CreateUpdateProcedureCommand procCommand, QueryMetadataInterface metadata, CommandContext context) throws QueryValidatorException {
-		return rewrite(command, procCommand, metadata, context, null, Command.TYPE_UNKNOWN);
+	public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context) throws QueryValidatorException {
+		return rewrite(command, null, metadata, context, null, Command.TYPE_UNKNOWN);
     }
 
     /**
@@ -275,125 +270,42 @@
                 procCommand = (CreateUpdateProcedureCommand) command;
                 command = rewriteUpdateProcedure((CreateUpdateProcedureCommand) command);
                 break;
-            case Command.TYPE_XQUERY:
-            	((XQuery)command).setVariables(this.variables);
-            	break;
+            case Command.TYPE_BATCHED_UPDATE:
+            	List subCommands = ((BatchedUpdateCommand)command).getUpdateCommands();
+                for (int i = 0; i < subCommands.size(); i++) {
+                    Command subCommand = (Command)subCommands.get(i);
+                    subCommand = rewriteCommand(subCommand, false);
+                    subCommands.set(i, subCommand);
+                }
+                break;
+            	
 		}
         
-        //recursively rewrite simple containers - after the container itself was rewritten
-        if (command instanceof CommandContainer) {
-            Map oldVariables = variables;
-        	List subCommands = ((CommandContainer)command).getContainedCommands();
-            for (int i = 0; i < subCommands.size(); i++) {
-                Command subCommand = (Command)subCommands.get(i);
-                
-                if (command instanceof ProcedureContainer) {
-                       
-                    try {
-    	                variables = QueryResolver.getVariableValues(command, metadata);                        
-    	                commandType = command.getType();
-                    } catch (QueryMetadataException err) {
-                        throw new QueryValidatorException(err, err.getMessage());
-                    } catch (QueryResolverException err) {
-                        throw new QueryValidatorException(err, err.getMessage());
-                    } catch (MetaMatrixComponentException err) {
-                        throw new QueryValidatorException(err, err.getMessage());
-                    }
-                }
-                
-                subCommand = rewriteCommand(subCommand, false);
-                subCommands.set(i, subCommand);
-            }
-            variables = oldVariables;
-        }
-
-        Command result = removeProceduralWrapper(command);
         this.metadata = oldMetadata;
         this.procCommand = oldProcCommand;
-        return result;
+        return command;
 	}
     
-    private void mergeOptions( Option sourceOption, Option targetOption ) {
-        if ( sourceOption.getPlanOnly()) {
-            targetOption.setPlanOnly( true );
-        }
-        if ( sourceOption.getDebug()) {
-            targetOption.setDebug( true );
-        }
-        if ( sourceOption.getShowPlan()) {
-            targetOption.setShowPlan( true );
-        }
-    }
-	
-    private Command removeProceduralWrapper(Command command) throws QueryValidatorException {
-        
-        if (!(command instanceof StoredProcedure)) {
-            return command;
-        }
-        
-        StoredProcedure container = (StoredProcedure)command;
-        if (container.isProcedureRelational()) {
-            return command;
-        }
-        
-        if (!(container.getSubCommand() instanceof CreateUpdateProcedureCommand)) {
-            return command;
-        }
-        
-        CreateUpdateProcedureCommand subCommand = (CreateUpdateProcedureCommand)container.getSubCommand();
-        
-        if (subCommand == null) {
-            return command;
-        }
-        
-        //if all parameters can be evaluated, we need to validate their values before removing the procedure wrapper
-        for (Iterator iter = container.getInputParameters().iterator(); iter.hasNext();) {
-            SPParameter param = (SPParameter)iter.next();
-            Expression expr = param.getExpression();
-            if (!EvaluatableVisitor.isFullyEvaluatable(expr, true)) {
-                return command;
-            }
-            try {
-                Object value = new Evaluator(Collections.emptyMap(), this.dataMgr, context).evaluate(expr, Collections.emptyList());
-
-                //check contraint
-                if (value == null && !metadata.elementSupports(param.getMetadataID(), SupportConstants.Element.NULL)) {
-                    throw new QueryValidatorException(QueryExecPlugin.Util.getString("ProcedurePlan.nonNullableParam", expr)); //$NON-NLS-1$
-                }
-            } catch (ExpressionEvaluationException err) {
-            } catch (BlockedException err) {
-            } catch (MetaMatrixComponentException err) {            
-            }
-        } 
-        
-        Block block = subCommand.getBlock();
-        
-        if (block.getStatements().size() != 1) {
-            return command;
-        }
-        Statement statement = (Statement)block.getStatements().get(0);
-        if (statement.getType() != Statement.TYPE_COMMAND) {
-            return command;
-        }
-        
-        Command child = (((CommandStatement)statement).getCommand());
-        
-        if (child != null && child.getType() != Command.TYPE_DYNAMIC) {
-            if ( child.getOption() == null ) {
-                child.setOption( command.getOption() );                
-            } else if (command.getOption() != null) {
-                mergeOptions( command.getOption(), child.getOption() );
-            }
-            return child;        
-        }
-        return command;
-    }
-
 	private Command rewriteUpdateProcedure(CreateUpdateProcedureCommand command)
 								 throws QueryValidatorException {
-		
+        Map oldVariables = variables;
+        try {
+        	if (command.getUserCommand() != null) {
+	            variables = QueryResolver.getVariableValues(command.getUserCommand(), metadata);                        
+	            commandType = command.getUserCommand().getType();
+        	}
+        } catch (QueryMetadataException err) {
+            throw new QueryValidatorException(err, err.getMessage());
+        } catch (QueryResolverException err) {
+            throw new QueryValidatorException(err, err.getMessage());
+        } catch (MetaMatrixComponentException err) {
+            throw new QueryValidatorException(err, err.getMessage());
+        }
+
 		Block block = rewriteBlock(command.getBlock());
         command.setBlock(block);
+
+        variables = oldVariables;
         
         return command;
 	}
@@ -1054,24 +966,12 @@
 			 throws QueryValidatorException {
 		if(clause instanceof JoinPredicate) {
 			return rewriteJoinPredicate(parent, (JoinPredicate) clause);
-        } else if (clause instanceof UnaryFromClause) {
-            rewriteUnaryFromClause((UnaryFromClause)clause);
         } else if (clause instanceof SubqueryFromClause) {
             rewriteSubqueryContainer((SubqueryFromClause)clause, true);
         }
         return clause;
 	}
 
-    private void rewriteUnaryFromClause(UnaryFromClause ufc) throws QueryValidatorException {
-        Command nestedCommand = ufc.getExpandedCommand();
-        
-        if (nestedCommand == null) {
-            return;
-        }
-            
-        ufc.setExpandedCommand(rewriteCommand(nestedCommand, true));
-    }
-
 	private JoinPredicate rewriteJoinPredicate(Query parent, JoinPredicate predicate)
 			 throws QueryValidatorException {
 		List joinCrits = predicate.getJoinCriteria();

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -33,15 +33,17 @@
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.sql.LanguageVisitor;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.util.VariableContext;
 
 
 /** 
  * Represents a batch of INSERT, UPDATE, DELETE, and SELECT INTO commands
  * @since 4.2
  */
-public class BatchedUpdateCommand extends Command implements CommandContainer {
+public class BatchedUpdateCommand extends Command {
     
     protected List commands;
+    private List<VariableContext> variableContexts; //processing state
     
     /**
      * Add sub command
@@ -216,11 +218,12 @@
         return '?';
     }
 
-    /** 
-     * @see com.metamatrix.query.sql.lang.CommandContainer#getContainedCommands()
-     */
-    public List getContainedCommands() {
-        return getSubCommands();
-    }
+	public void setVariableContexts(List<VariableContext> variableContexts) {
+		this.variableContexts = variableContexts;
+	}
 
+	public List<VariableContext> getVariableContexts() {
+		return variableContexts;
+	}
+
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -120,8 +120,6 @@
 
     private boolean isResolved;
     
-    private GroupSymbol virtualGroup;
-    
 	/** The option clause */
 	private Option option;
 	
@@ -228,7 +226,6 @@
         if(this.tempGroupIDs != null) {
             copy.setTemporaryMetadata(new HashMap(this.tempGroupIDs));
         }
-        copy.setVirtualGroup(getVirtualGroup());
         
         copy.setIsResolved(this.isResolved());
         copy.plan = this.plan;
@@ -340,14 +337,6 @@
         }
         return 0;
     }
-
-    public GroupSymbol getVirtualGroup() {
-        return this.virtualGroup;
-    }
-
-    public void setVirtualGroup(GroupSymbol virtualGroup) {
-        this.virtualGroup = virtualGroup;
-    }
     
     public ProcessorPlan getProcessorPlan() {
     	return this.plan;

Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/CommandContainer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/CommandContainer.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/CommandContainer.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,34 +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.lang;
-
-import java.util.List;
-
-/**
- * Returns a list of subCommands that is safe to manipulate 
- */
-public interface CommandContainer {
-
-    List getContainedCommands();
-    
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/GroupContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/GroupContext.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/GroupContext.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -35,24 +35,24 @@
  */
 public class GroupContext implements Cloneable {
     
-    private Collection groups;
+    private Collection<GroupSymbol> groups;
     
-    private GroupContext parent = null;
+    private GroupContext parent;
     
     public GroupContext() {
         this(null, null);
     }
     
-    public GroupContext(GroupContext parent, Collection groups) {
+    public GroupContext(GroupContext parent, Collection<GroupSymbol> groups) {
         this.parent = parent;
         if (groups == null) {
-            this.groups = new LinkedList();
+            this.groups = new LinkedList<GroupSymbol>();
         } else {
             this.groups = groups;    
         }
     }
 
-    public Collection getGroups() {
+    public Collection<GroupSymbol> getGroups() {
         return this.groups;
     }
     
@@ -69,8 +69,8 @@
      *  
      * @return
      */
-    public List getAllGroups() {
-        LinkedList result = new LinkedList();
+    public List<GroupSymbol> getAllGroups() {
+        LinkedList<GroupSymbol> result = new LinkedList<GroupSymbol>();
         
         GroupContext root = this;
         while (root != null) {

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -42,10 +42,10 @@
 
 	private boolean showPlan = false;
 	private boolean debug = false;
-    private List makeDependentGroups = null;        // of String
-    private List makeNotDependentGroups = null;        // of String
+    private List<String> makeDependentGroups;
+    private List<String> makeNotDependentGroups;
     private boolean planOnly = false;
-	private List noCacheGroups;	// List of String
+	private List<String> noCacheGroups;
     private boolean noCache;
 
 	/**
@@ -108,7 +108,7 @@
      */
     public void addDependentGroup(String group) {
         if(this.makeDependentGroups == null) {
-            this.makeDependentGroups = new ArrayList();
+            this.makeDependentGroups = new ArrayList<String>();
         }
         this.makeDependentGroups.add(group);    
     }
@@ -117,7 +117,7 @@
      * Get all groups to make dependent
      * @return List of String defining groups to be made dependent, may be null if no groups
      */
-    public List getDependentGroups() {
+    public List<String> getDependentGroups() {
         return this.makeDependentGroups;
     }
     
@@ -127,7 +127,7 @@
      */
     public void addNotDependentGroup(String group) {
         if(this.makeNotDependentGroups == null) {
-            this.makeNotDependentGroups = new ArrayList();
+            this.makeNotDependentGroups = new ArrayList<String>();
         }
         this.makeNotDependentGroups.add(group);    
     }
@@ -136,7 +136,7 @@
      * Get all groups to make dependent
      * @return List of String defining groups to be made dependent, may be null if no groups
      */
-    public List getNotDependentGroups() {
+    public List<String> getNotDependentGroups() {
         return this.makeNotDependentGroups;
     }
     
@@ -148,7 +148,7 @@
      */
     public void addNoCacheGroup(String group) {
         if(this.noCacheGroups == null) {
-            this.noCacheGroups = new ArrayList();
+            this.noCacheGroups = new ArrayList<String>();
         }
         this.noCacheGroups.add(group);    
     }
@@ -160,7 +160,7 @@
      * @return List of String defining groups that overrides the default behavior of 
      * Materialized View, may be null if there are no groups
      */
-    public List getNoCacheGroups() {
+    public List<String> getNoCacheGroups() {
         return this.noCacheGroups;
     }
 	
@@ -242,24 +242,15 @@
         newOption.setNoCache(noCache);
         
         if(getDependentGroups() != null) {
-            Iterator iter = getDependentGroups().iterator();
-            while(iter.hasNext()) {
-                newOption.addDependentGroup( (String) iter.next() );
-            }
+        	newOption.makeDependentGroups = new ArrayList<String>(getDependentGroups());
         }
             
         if(getNotDependentGroups() != null) {
-            Iterator iter = getNotDependentGroups().iterator();
-            while(iter.hasNext()) {
-                newOption.addNotDependentGroup( (String) iter.next() );
-            }
+        	newOption.makeNotDependentGroups = new ArrayList<String>(getNotDependentGroups());
         }
             
         if(getNoCacheGroups() != null) {
-            Iterator iter = getNoCacheGroups().iterator();
-            while(iter.hasNext()) {
-                newOption.addNoCacheGroup( (String) iter.next() );
-            }
+        	newOption.noCacheGroups = new ArrayList<String>(getNoCacheGroups());
         }
         
 		return newOption;

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,71 +22,23 @@
 
 package com.metamatrix.query.sql.lang;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Map;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 
-public abstract class ProcedureContainer extends Command implements CommandContainer {
+public abstract class ProcedureContainer extends Command {
 
-    /**
-     * This is a little hack to maintain a list of at most 1
-     */
-    private List subCommands = new ArrayList(1);
-    
     private int updateCount = -1;
     
     public abstract GroupSymbol getGroup();
     
-    /** 
-     * @return Returns the subCommand.
-     */
-    public Command getSubCommand() {
-        if (subCommands.isEmpty()) {
-            return null;
-        }
-        return (Command)subCommands.get(0);
-    }
-
-    /** 
-     * @param subCommand The subCommand to set.
-     */
-    public void setSubCommand(Command subCommand) {
-        if (subCommands.isEmpty()) {
-            subCommands.add(null);
-        }
-        if (subCommand == null) {
-            subCommands.remove(0);
-        } else {
-            this.subCommands.set(0, subCommand);
-        }
-    }
-    
     protected void copyMetadataState(Command copy) {
         super.copyMetadataState(copy);
-        
-        Command subCommand = getSubCommand();
-        if (subCommand != null) {
-        	subCommand = (Command)subCommand.clone();
-	        ((ProcedureContainer)copy).subCommands.add(subCommand);
-	        if (subCommand instanceof CreateUpdateProcedureCommand) {
-	            ((CreateUpdateProcedureCommand)subCommand).setUserCommand(copy);
-	        } 
-        }
     }
     
-    /** 
-     * @see com.metamatrix.query.sql.lang.CommandContainer#getContainedCommands()
-     */
-    public List getContainedCommands() {
-        return subCommands;
-    }
-    
     public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException{
         if (updateCount != -1) {
             return updateCount;
@@ -105,7 +57,7 @@
             throw new MetaMatrixComponentException(e);
         }
         
-        return this.getSubCommand().updatingModelCount(metadata);
+        return 2;
     }
 
     

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,14 +22,15 @@
 
 package com.metamatrix.query.sql.lang;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.*;
+import com.metamatrix.query.sql.LanguageVisitor;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.visitor.SQLStringVisitor;
 import com.metamatrix.query.xquery.XQueryExpression;
@@ -42,6 +43,7 @@
     private String xQuery;
     private XQueryExpression compiledXQuery;
     private Map variables;
+    private String procedureGroup;
     
     public XQuery(){
     }
@@ -51,6 +53,10 @@
         this.compiledXQuery = compiledXQuery;
     }
     
+    public void setProcedureGroup(String procedureGroup) {
+		this.procedureGroup = procedureGroup;
+	}
+    
     public void setVariables(Map variables) {
 		this.variables = variables;
 	}
@@ -110,7 +116,7 @@
      * @return Hash code
      */
     public int hashCode() {
-        return HashCodeUtil.hashCode(0, getXQuery());
+        return xQuery.hashCode();
     }
 
     /**
@@ -120,6 +126,7 @@
     public Object clone() {
         XQuery copy = new XQuery(getXQuery(), this.compiledXQuery);
         copy.variables = variables;
+        copy.procedureGroup = procedureGroup;
         copyMetadataState(copy);
         return copy;
     }
@@ -146,4 +153,8 @@
     public int updatingModelCount(QueryMetadataInterface metadata) throws MetaMatrixComponentException {
         return 2; //since there may be dynamic sql, just assume a transaction is required
     }
+
+	public String getProcedureGroup() {
+		return procedureGroup;
+	}
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -35,6 +35,7 @@
 import com.metamatrix.query.sql.LanguageVisitor;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Option;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
 import com.metamatrix.query.sql.visitor.SQLStringVisitor;
 
 /**
@@ -59,7 +60,7 @@
     
     private List projectedSymbols;
     
-    private List parentProjectSymbols;
+    private GroupSymbol virtualGroup;
 
     //command that returns resultset. For virtual procedure only.
     private Command resultsCommand;
@@ -167,11 +168,8 @@
         if (this.projectedSymbols != null) {
             copy.setProjectedSymbols(new ArrayList(this.projectedSymbols));
         }
-        if (getResultsCommand() != null) {
-            copy.setResultsCommand((Command)this.getResultsCommand().clone());
-        } 
-        if (parentProjectSymbols != null) {
-            copy.parentProjectSymbols = new ArrayList(this.parentProjectSymbols);
+        if (this.virtualGroup != null) {
+        	copy.virtualGroup = (GroupSymbol)this.virtualGroup.clone();
         }
         this.copyMetadataState(copy);
 		return copy;
@@ -313,20 +311,12 @@
         return 0;
     }
 
-    
-    /** 
-     * @return Returns the parentProjectSymbols.
-     */
-    public List getParentProjectSymbols() {
-        return this.parentProjectSymbols;
+    public GroupSymbol getVirtualGroup() {
+        return this.virtualGroup;
     }
 
-    
-    /** 
-     * @param parentProjectSymbols The parentProjectSymbols to set.
-     */
-    public void setParentProjectSymbols(List parentProjectSymbols) {
-        this.parentProjectSymbols = parentProjectSymbols;
+    public void setVirtualGroup(GroupSymbol virtualGroup) {
+        this.virtualGroup = virtualGroup;
     }
 
 } // END CLASS

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/MultipleElementSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/MultipleElementSymbol.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/MultipleElementSymbol.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -28,7 +28,7 @@
  * <p>This is a subclass of Symbol representing multiple output columns.</p>
  */
 public abstract class MultipleElementSymbol extends SelectSymbol {
-    private List elementSymbols;
+    private List<ElementSymbol> elementSymbols;
 
     /**
      * Passthrough constructor used for cloning 
@@ -52,7 +52,7 @@
      * Set the {@link ElementSymbol}s that this symbol refers to
      * @param elementSymbols List of {@link ElementSymbol}
      */
-    public void setElementSymbols(List elementSymbols){
+    public void setElementSymbols(List<ElementSymbol> elementSymbols){
         this.elementSymbols = elementSymbols;
     }
 
@@ -60,7 +60,7 @@
      * Get the element symbols referred to by this multiple element symbol
      * @return List of {@link ElementSymbol}s, may be null
      */
-    public List getElementSymbols(){
+    public List<ElementSymbol> getElementSymbols(){
         return this.elementSymbols;
     }
 
@@ -70,7 +70,7 @@
      */
     public void addElementSymbol(ElementSymbol symbol) {
 		if(getElementSymbols() == null) { 
-			setElementSymbols(new LinkedList());
+			setElementSymbols(new LinkedList<ElementSymbol>());
 		}
 		getElementSymbols().add(symbol);
     }

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/ElementSymbolOptimizer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/ElementSymbolOptimizer.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/ElementSymbolOptimizer.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -67,7 +67,7 @@
         } else {
             commandList.add(command);
 
-            List subCommands = CommandCollectorVisitor.getCommands(command, true);
+            List subCommands = CommandCollectorVisitor.getCommands(command);
             if(subCommands != null && subCommands.size() > 0) {
                 for(int i=0; i<subCommands.size(); i++) {
                     Command subCommand = (Command) subCommands.get(i);

Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CommandCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CommandCollectorVisitor.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CommandCollectorVisitor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -23,9 +23,7 @@
 package com.metamatrix.query.sql.visitor;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.LanguageVisitor;
@@ -33,12 +31,10 @@
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.ExistsCriteria;
 import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
 import com.metamatrix.query.sql.lang.SetQuery;
 import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
 import com.metamatrix.query.sql.lang.SubqueryFromClause;
 import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
 import com.metamatrix.query.sql.navigator.PreOrderNavigator;
 import com.metamatrix.query.sql.proc.AssignmentStatement;
 import com.metamatrix.query.sql.proc.CommandStatement;
@@ -55,23 +51,9 @@
  */
 public class CommandCollectorVisitor extends LanguageVisitor {
 
-	private enum Mode {
-		EMBEDDED,
-		NON_EMBEDDED
-	}
-	
     private List<Command> commands = new ArrayList<Command>();
-    private Set<Mode> modes;
 
     /**
-     * Construct a new visitor with the default collection type, which is a 
-     * {@link java.util.HashSet}.  
-     */
-    public CommandCollectorVisitor(Set<Mode> modes) { 
-        this.modes = modes;
-    }   
-
-    /**
      * Get the commands collected by the visitor.  This should best be called 
      * after the visitor has been run on the language object tree.
      * @return List of {@link com.metamatrix.query.sql.lang.Command}
@@ -84,27 +66,21 @@
      * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.ExistsCriteria)
      */
     public void visit(ExistsCriteria obj) {
-        if (modes.contains(Mode.EMBEDDED)) {
-            this.commands.add(obj.getCommand());
-        }
+        this.commands.add(obj.getCommand());
     }
 
     /**
      * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.ScalarSubquery)
      */
     public void visit(ScalarSubquery obj) {
-    	if (modes.contains(Mode.EMBEDDED)) {
-            this.commands.add(obj.getCommand());
-    	}
+        this.commands.add(obj.getCommand());
     }
 
     /**
      * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.SubqueryCompareCriteria)
      */
     public void visit(SubqueryCompareCriteria obj) {
-    	if (modes.contains(Mode.EMBEDDED)) {
-            this.commands.add(obj.getCommand());
-        }
+        this.commands.add(obj.getCommand());
     }
 
     /**
@@ -113,9 +89,7 @@
      * @param obj Language object
      */
     public void visit(SubqueryFromClause obj) {
-    	if (modes.contains(Mode.EMBEDDED)) {
-            this.commands.add(obj.getCommand());
-        }
+        this.commands.add(obj.getCommand());
     }
 
     /**
@@ -124,9 +98,7 @@
      * @param obj Language object
      */
     public void visit(SubquerySetCriteria obj) {
-    	if (modes.contains(Mode.EMBEDDED)) {
-            this.commands.add(obj.getCommand());
-        }
+        this.commands.add(obj.getCommand());
     }
 
     /**
@@ -135,9 +107,7 @@
      * @param obj Language object
      */
     public void visit(CommandStatement obj) {
-    	if (modes.contains(Mode.EMBEDDED)) {
-            this.commands.add(obj.getCommand());
-        }
+        this.commands.add(obj.getCommand());
     }    
 
     /**
@@ -146,7 +116,7 @@
      * @param obj Language object
      */
     public void visit(AssignmentStatement obj) {
-    	if(modes.contains(Mode.EMBEDDED) && obj.hasCommand()) {
+    	if(obj.hasCommand()) {
 	        this.commands.add(obj.getCommand());
     	}
     }
@@ -157,51 +127,20 @@
      * @param obj Language object
      */
     public void visit(LoopStatement obj) {
-        if (modes.contains(Mode.EMBEDDED)) {
-            this.commands.add(obj.getCommand());
-        }
+        this.commands.add(obj.getCommand());
     }
     
-    public void visit(UnaryFromClause obj) {
-        if (modes.contains(Mode.NON_EMBEDDED) && obj.getExpandedCommand() != null) {
-            this.commands.add(obj.getExpandedCommand());
-        }
-    }
-    
     public void visit(BatchedUpdateCommand obj) {
-        if (modes.contains(Mode.NON_EMBEDDED)) {
-            this.commands.addAll(obj.getUpdateCommands());
-        }
+        this.commands.addAll(obj.getUpdateCommands());
     }
     
-    public void visit(ProcedureContainer obj) {
-        if (modes.contains(Mode.NON_EMBEDDED) && obj.getSubCommand() != null) {
-            this.commands.add(obj.getSubCommand());
-        }
-    }
-    
     /**
      * Helper to quickly get the commands from obj
      * @param obj Language object
      * @param elements Collection to collect commands in
      */
-    public static final List<Command> getCommands(Command obj) {
-        return getCommands(obj, true, true);
-    }
-
-    public static final List<Command> getCommands(Command obj, boolean embeddedOnly) {
-        return getCommands(obj, true, !embeddedOnly);
-    }
-    
-    private static final List<Command> getCommands(Command command, boolean embedded, boolean nonEmbedded) {
-    	HashSet<Mode> modes = new HashSet<Mode>();
-    	if (embedded) {
-    		modes.add(Mode.EMBEDDED);
-    	}
-    	if (nonEmbedded) {
-    		modes.add(Mode.NON_EMBEDDED);
-    	}
-        CommandCollectorVisitor visitor = new CommandCollectorVisitor(modes);
+    public static final List<Command> getCommands(Command command) {
+        CommandCollectorVisitor visitor = new CommandCollectorVisitor();
         final boolean visitCommands = command instanceof SetQuery || command instanceof Insert;
         PreOrderNavigator navigator = new PreOrderNavigator(visitor) {
 
@@ -218,8 +157,4 @@
         return visitor.getCommands();
     }
     
-    public static final List<Command> getNonEmbeddedCommands(Command obj) {
-        return getCommands(obj, false, true);
-    }
-
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -25,6 +25,7 @@
 import java.io.Serializable;
 import java.util.Properties;
 import java.util.Random;
+import java.util.Set;
 import java.util.Stack;
 import java.util.TimeZone;
 
@@ -99,6 +100,8 @@
     
     private boolean sessionFunctionEvaluated;
     
+    private Set<String> groups;
+    
     /**
      * Construct a new context.
      * @param collectNodeStatistics TODO
@@ -449,4 +452,12 @@
 		return value;
 	}
 	
+	public Set<String> getGroups() {
+		return groups;
+	}
+	
+	public void setGroups(Set<String> groups) {
+		this.groups = groups;
+	}
+	
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -103,6 +103,7 @@
 import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
 import com.metamatrix.query.sql.visitor.PredicateCollectorVisitor;
 import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
 import com.metamatrix.query.util.ErrorMessageKeys;
 
 public class ValidationVisitor extends AbstractValidationVisitor {
@@ -221,7 +222,7 @@
 
             //if it is select with no from, should not have ScalarSubQuery
             if(obj.getSelect() != null && obj.getFrom() == null){
-                if(!CommandCollectorVisitor.getCommands(obj).isEmpty()){
+                if(!ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(obj.getSelect()).isEmpty()){
                     handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0067),obj);
                 }
             }

Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/Validator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/Validator.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/Validator.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -37,11 +37,11 @@
 public class Validator {
 
     public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata) throws MetaMatrixComponentException {
-        ValidatorReport report1 = Validator.validate(object, metadata, new ValidationVisitor(), false);
+        ValidatorReport report1 = Validator.validate(object, metadata, new ValidationVisitor());
         return report1;
     }
 
-    public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata, AbstractValidationVisitor visitor, boolean validateOnlyEmbedded)
+    public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata, AbstractValidationVisitor visitor)
         throws MetaMatrixComponentException {
 
         // Construct combined runtime / query metadata if necessary
@@ -56,10 +56,10 @@
             }
             
             // Recursively validate subcommands
-            Iterator iter = CommandCollectorVisitor.getCommands((Command)object, validateOnlyEmbedded).iterator();
+            Iterator iter = CommandCollectorVisitor.getCommands((Command)object).iterator();
             while(iter.hasNext()) {
                 Command subCommand = (Command) iter.next();
-                validate(subCommand, metadata, visitor, validateOnlyEmbedded);
+                validate(subCommand, metadata, visitor);
             }
         }
 

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheID.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheID.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheID.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,16 +22,16 @@
 
 package org.teiid.dqp.internal.cache;
 
+import java.io.Serializable;
 import java.util.List;
 
 import com.metamatrix.core.util.HashCodeUtil;
 
-public class CacheID {
+public class CacheID implements Serializable {
 	private String scopeID;
 	private String command;
 	private int hashCode;
 	private List preparedStatementValues;
-	private long size=0L;
 	
 	public CacheID(String scopeID, String command){
 		this(scopeID, command, null);
@@ -51,7 +51,7 @@
 	public boolean equals(Object obj){
         if(obj == this) {
             return true;
-        } else if(obj == null || ! (obj instanceof CacheID)) {
+        } else if(! (obj instanceof CacheID)) {
             return false;
         } else {
         	CacheID that = (CacheID)obj;
@@ -65,31 +65,14 @@
 		if(thisPreparedStatementValues == null && thatPreparedStatementValues == null){
 			return true;
 		}
-		if((thisPreparedStatementValues == null && thatPreparedStatementValues != null)
-				|| thisPreparedStatementValues != null && thatPreparedStatementValues == null){
+		if(thisPreparedStatementValues == null || thatPreparedStatementValues == null){
 			return false;
 		}
-		int size = thisPreparedStatementValues.size();
-		if(size != thatPreparedStatementValues.size()){
-			return false;
-		}
-		for(int i=0; i< size; i++){
-			if(!thisPreparedStatementValues.get(i).equals(thatPreparedStatementValues.get(i))){
-				return false;
-			}
-		}
-		return true;
+		return thisPreparedStatementValues.equals(thatPreparedStatementValues);
 	}
 
 	public int hashCode() {
         return hashCode;
     }
 	
-	public long getMemorySize() {
-		return size;
-	}
-	
-	public void setMemorySize(long size) {
-		this.size = size;
-	}
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheResults.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheResults.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheResults.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,44 +22,32 @@
 
 package org.teiid.dqp.internal.cache;
 
+import java.io.Serializable;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
 
-public class CacheResults {
+public class CacheResults implements Serializable {
 	private List[] results;
-	private List elements;
 	private AnalysisRecord analysisRecord;
 	private Command command;
-	private Map paramValues;
 	
 	private boolean isFinal;
 	private int firstRow = 1;
     //size of this results in memory
 	private long size= -1;
-	private int finalRow = -1;
 		
 	public CacheResults(List[] results, int firstRow, boolean isFinal){
-		this(results, null, firstRow, isFinal);
-	}
-	
-	public CacheResults(List[] results, List elements, int firstRow, boolean isFinal){
 		this.results = results;
 		this.firstRow = firstRow;
 		this.isFinal = isFinal;
-		this.elements = elements;
 	}
 
-	public CacheResults(Map paramValues, boolean isFinal){
-		this.paramValues = paramValues;
-		this.isFinal = isFinal;
-	}
-	
 	public int getFirstRow() {
 		return firstRow;
 	}
@@ -68,12 +56,15 @@
 		return isFinal;
 	}
 
-	public List[] getResults() {
+	public List<?>[] getResults() {
 		return results;
 	}
 
-	public List getElements() {
-		return elements;
+	public List<SingleElementSymbol> getElements() {
+		if (command == null) {
+			return null;
+		}
+		return command.getProjectedSymbols();
 	}
 
 	public Command getCommand() {
@@ -101,25 +92,12 @@
 	}
 
 	public int getFinalRow() {
-		return finalRow;
-	}
-
-	public void setFinalRow(int finalRow) {
-		this.finalRow = finalRow;
-	}
-
-	public Map getParamValues() {
-		return paramValues;
-	}
-
-	public void setParamValues(Map paramValues) {
-		if(this.paramValues == null){
-			this.paramValues = paramValues;
-		}else if(paramValues != null){
-			this.paramValues.putAll(paramValues);
+		if (this.isFinal) {
+			return results.length;
 		}
+		return -1;
 	}
-		
+
     //add the results to the existing one, this is used
     //when building the batched results
 	boolean addResults(CacheResults cacheResults){
@@ -140,7 +118,6 @@
 			this.analysisRecord = cacheResults.getAnalysisRecord();
 			this.firstRow = 1;
 			this.isFinal = true;
-			this.finalRow = this.results.length;
 		}
 		return true;
 	}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCache.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCache.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -25,14 +25,17 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
 import com.metamatrix.cache.Cache;
 import com.metamatrix.cache.CacheConfiguration;
 import com.metamatrix.cache.CacheFactory;
 import com.metamatrix.cache.Cache.Type;
 import com.metamatrix.cache.CacheConfiguration.Policy;
-import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.impl.BufferManagerImpl;
+import com.metamatrix.common.buffer.impl.SizeUtility;
 import com.metamatrix.core.util.HashCodeUtil;
 
 /**
@@ -67,36 +70,35 @@
 	}
 	
 	//configurable parameters
-	public static final String RS_CACHE_MAX_SIZE = "maxSize"; //$NON-NLS-1$
+	public static final String RS_CACHE_MAX_ENTRIES = "maxEntries"; //$NON-NLS-1$
+	public static final String RS_CACHE_MAX_SIZE = "maxEntrySize"; //$NON-NLS-1$
 	public static final String RS_CACHE_MAX_AGE = "maxAge"; //$NON-NLS-1$
 	public static final String RS_CACHE_SCOPE = "scope"; //$NON-NLS-1$
 		
 	//constants
 	public static final String RS_CACHE_SCOPE_VDB = "vdb"; //$NON-NLS-1$
 	public static final String RS_CACHE_SCOPE_CONN = "connection"; //$NON-NLS-1$
-
+	private static final char DELIMITOR = '.';
+	
 	private Cache<CacheID, CacheResults> cache; 
-	private String scope;
+	private String scope = RS_CACHE_SCOPE_VDB;
 	private Map<TempKey, CacheResults> tempBatchResults = new HashMap<TempKey, CacheResults>();
-	private int maxSize = 50 * 1024 * 1024; //bytes
+	private int maxEntrySize = 100 * 1024; //bytes
 	private int maxAge = 60 * 60; // seconds
-	private int maxEntries = 20 * 1024; 
+	private int maxEntries = 1024;
 	
-	public ResultSetCache(Properties props, CacheFactory cacheFactory) {
-		PropertiesUtils.setBeanProperties(this, props, null);
+	public void start(CacheFactory cacheFactory) {
 		this.cache = cacheFactory.get(Type.RESULTSET, new CacheConfiguration(Policy.MRU, maxAge, maxEntries));
 	}
 	
-	public void setMaxSize(int maxSize) {
-		if (maxSize <= 0 ) {
-			this.maxSize = 0;
-			this.maxEntries = Integer.MAX_VALUE;
-		} else {
-			this.maxSize = maxSize * 1024 * 1024;
-			this.maxEntries = this.maxSize * 1024;
-		}
+	public void setMaxEntries(int maxEntries) {
+		this.maxEntries = maxEntries;
 	}
 	
+	public void setMaxEntrySize(int maxEntrySize) {
+		this.maxEntrySize = maxEntrySize;
+	}
+	
 	public void setMaxAge(int maxAge) {
 		if (maxAge <= 0) {
 			this.maxAge = Integer.MAX_VALUE;
@@ -115,6 +117,9 @@
 		if(cacheResults == null){
 			return null;
 		}
+		if (interval == null) {
+			return cacheResults;
+		}
 		int firstRow = interval[0] - 1;
 		int resultSize = cacheResults.getResults().length;
 		int finalRow = resultSize - 1;
@@ -126,15 +131,9 @@
 		int batchSize = lastRow - firstRow + 1;
 		List<?>[] resultsPart = new List[batchSize];
 		System.arraycopy(cacheResults.getResults(), firstRow, resultsPart, 0, batchSize);
-		boolean isFinal = lastRow == finalRow;
-		CacheResults newCacheResults = new CacheResults(resultsPart, cacheResults.getElements(), firstRow + 1, lastRow == finalRow);
+		CacheResults newCacheResults = new CacheResults(resultsPart, firstRow + 1, lastRow == finalRow);
 		newCacheResults.setCommand(cacheResults.getCommand());
 		newCacheResults.setAnalysisRecord(cacheResults.getAnalysisRecord());
-		newCacheResults.setParamValues(cacheResults.getParamValues());
-        
-		if(isFinal){
-			newCacheResults.setFinalRow(resultSize);
-		}
 		return newCacheResults;
 	}
 	
@@ -149,15 +148,13 @@
      */
 	public boolean setResults(CacheID cacheID, CacheResults cacheResults, Object requestID){	
 		List<?>[] results = cacheResults.getResults();
-		if(cacheResults.getSize() == -1){
-			cacheResults.setSize(ResultSetCacheUtil.getResultsSize(results, true));
+		if(cacheResults.getSize() == TupleBatch.UNKNOWN_SIZE){
+			cacheResults.setSize(SizeUtility.getBatchSize(BufferManagerImpl.getTypeNames(cacheResults.getElements()), results));
 		}
 		
-		long currentCacheSize = getCacheSize();
-		
 		TempKey key = new TempKey(cacheID, requestID);
 		//do not cache if it is over cache limit
-		if(isOverCacheLimit(currentCacheSize, cacheResults.getSize())){
+		if(isOverCacheLimit(cacheResults.getSize())){
 			removeTempResults(key);
 			return false;
 		}
@@ -165,6 +162,9 @@
 		synchronized(tempBatchResults){
 			CacheResults savedResults = tempBatchResults.get(key);
 			if(savedResults == null){
+				if (tempBatchResults.size() >= maxEntries) {
+					return false;
+				}
 				savedResults = cacheResults; 
 				tempBatchResults.put(key, cacheResults);
 			} else if(!savedResults.addResults(cacheResults)){
@@ -173,14 +173,13 @@
 			}
 			
 			//do not cache if it is over cache limit
-			if(isOverCacheLimit(currentCacheSize, savedResults.getSize())){
+			if(isOverCacheLimit(savedResults.getSize())){
 				removeTempResults(key);
 				return false;
 			}
 		
 			if(savedResults.isFinal()){
 				tempBatchResults.remove(cacheID);
-				cacheID.setMemorySize(savedResults.getSize());
 				cache.put(cacheID, savedResults);
 			}
 		}
@@ -188,14 +187,11 @@
 		return true;
 	}
 
-	private boolean isOverCacheLimit(long recentCacheSize, long sizeToAdd) {
-		if(maxSize == 0 || sizeToAdd == 0){
+	private boolean isOverCacheLimit(long sizeToAdd) {
+		if(maxEntrySize == 0 || sizeToAdd == 0){
 			return false;
 		}
-		if(sizeToAdd + recentCacheSize > maxSize){
-			return true;
-		}
-		return false;
+		return sizeToAdd > maxEntrySize;
 	}
 	
 	public void removeTempResults(CacheID cacheID, Object requestID){
@@ -215,14 +211,6 @@
 		}
 	}
 
-	private long getCacheSize(){
-		long size = 0L;
-		for(CacheID key:cache.keySet()) {
-			size += key.getMemorySize();
-		}
-		return size;
-	}
-	
 	public void shutDown(){
 		clear();
 	}
@@ -230,4 +218,15 @@
 	public String getCacheScope(){
 		return scope;
 	}
+
+	public CacheID createCacheID(DQPWorkContext workContext, String command, List<?> parameterValues){
+		String scopeID = null;
+		if(RS_CACHE_SCOPE_VDB.equalsIgnoreCase(getCacheScope())){
+			scopeID = workContext.getVdbName() + DELIMITOR + workContext.getVdbVersion();
+		}else{
+			scopeID = workContext.getConnectionID();
+		}
+		return new CacheID(scopeID, command, parameterValues);
+	}
+
 }

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCacheUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCacheUtil.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCacheUtil.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -1,62 +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.cache;
-
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.common.buffer.impl.SizeUtility;
-import com.metamatrix.dqp.message.RequestMessage;
-
-public class ResultSetCacheUtil {
-	private static final char DELIMITOR = '.'; 
-	
-	public static CacheID createCacheID(RequestMessage request, ResultSetCache rsCache){
-		String scopeID = null;
-		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		if(ResultSetCache.RS_CACHE_SCOPE_VDB.equalsIgnoreCase(rsCache.getCacheScope())){
-			scopeID = workContext.getVdbName() + DELIMITOR + workContext.getVdbVersion();
-		}else{
-			scopeID = workContext.getConnectionID();
-		}
-		return new CacheID(scopeID, request.getCommandString(), request.getParameterValues());
-	}
-	
-//	public static boolean isQuery(String sql){
-//		return !SqlUtil.isUpdateSql(sql);
-//	}
-
-	public static long getResultsSize(Object[] results, boolean useEstimate){
-		if(results == null || results.length == 0){
-			return 0;
-		}
-		if(useEstimate){
-			//calculate the first row. Estimate the total
-			//by multiply the row count
-			Object row = results[0];
-			long rowSize = SizeUtility.getSize(row);
-			return rowSize * results.length;
-		}
-		return SizeUtility.getSize(results);
-	}
-
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -46,11 +46,10 @@
 import org.teiid.connector.api.ExecutionContext;
 import org.teiid.connector.api.ConnectorAnnotations.ConnectionPooling;
 import org.teiid.connector.api.ConnectorAnnotations.SynchronousWorkers;
-import org.teiid.connector.metadata.runtime.MetadataStore;
 import org.teiid.connector.metadata.runtime.MetadataFactory;
+import org.teiid.connector.metadata.runtime.MetadataStore;
 import org.teiid.connector.xa.api.XAConnector;
 import org.teiid.dqp.internal.cache.DQPContextCache;
-import org.teiid.dqp.internal.cache.ResultSetCache;
 import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
 import org.teiid.dqp.internal.pooling.connector.PooledConnector;
 import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -97,14 +96,11 @@
 public class ConnectorManager implements ApplicationService {
 
 	public static final int DEFAULT_MAX_THREADS = 20;
-    private static final String DEFAULT_MAX_RESULTSET_CACHE_SIZE = "20"; //$NON-NLS-1$
-    private static final String DEFAULT_MAX_RESULTSET_CACHE_AGE = "3600000"; //$NON-NLS-1$
 
     //state constructed in start
     private ConnectorWrapper connector;
     private ConnectorID connectorID;
     private WorkerPool connectorWorkerPool;
-    private ResultSetCache rsCache;
     private ConnectorWorkItemFactory workItemFactory;
 	private String connectorName;
     private int maxResultRows;
@@ -209,12 +205,6 @@
         }
     }
     
-    public void clearCache() {
-        if (rsCache != null) {
-        	rsCache.clear();
-        }
-    }
-     
     public void executeRequest(ResultsReceiver<AtomicResultsMessage> receiver, AtomicRequestMessage message) {
         // Set the connector ID to be used; if not already set. 
     	AtomicRequestID atomicRequestId = message.getAtomicRequestID();
@@ -359,15 +349,7 @@
      	this.bufferService = (BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE);
         // Initialize and start the connector
         initStartConnector(connectorEnv);
-        //check result set cache
-        if(PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.USE_RESULTSET_CACHE, false)) {
-            Properties rsCacheProps = new Properties();
-        	rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, props.getProperty(ConnectorPropertyNames.MAX_RESULTSET_CACHE_SIZE, DEFAULT_MAX_RESULTSET_CACHE_SIZE)); 
-        	rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, props.getProperty(ConnectorPropertyNames.MAX_RESULTSET_CACHE_AGE, DEFAULT_MAX_RESULTSET_CACHE_AGE)); 
-        	rsCacheProps.setProperty(ResultSetCache.RS_CACHE_SCOPE, props.getProperty(ConnectorPropertyNames.RESULTSET_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB)); 
-    		this.rsCache = new ResultSetCache(rsCacheProps, env.getCacheFactory());
-        }
-		this.workItemFactory = new ConnectorWorkItemFactory(this, this.rsCache, synchWorkers);
+		this.workItemFactory = new ConnectorWorkItemFactory(this, synchWorkers);
     	this.state = ConnectorStatus.OPEN;
     }
     
@@ -530,11 +512,6 @@
             }
             
         }
-        
-        if (this.rsCache != null) {
-        	this.rsCache.shutDown();
-        	this.rsCache = null;
-        }
     }
 
     /**

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,152 +22,26 @@
 
 package org.teiid.dqp.internal.datamgr.impl;
 
-import java.util.Arrays;
 
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.dqp.internal.cache.CacheID;
-import org.teiid.dqp.internal.cache.CacheResults;
-import org.teiid.dqp.internal.cache.ResultSetCache;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.query.sql.lang.Command;
 
 public class ConnectorWorkItemFactory {
 	
-    private final static char DELIMITER = '.';
-
-	private ResultSetCache rsCache;
 	private ConnectorManager manager;
 	private boolean synchWorkers;
 
-	/**
-	 * A work item that can get results from cache.
-	 */
-	private final class CachedResultsConnectorWorkItem extends
-			AsynchConnectorWorkItem {
-		private final CacheID cacheID;
-
-		private CachedResultsConnectorWorkItem(AtomicRequestMessage message,
-				ConnectorManager manager,
-				ResultsReceiver<AtomicResultsMessage> resultsReceiver,
-				CacheID cacheID) {
-			super(message, manager, resultsReceiver);
-			this.cacheID = cacheID;
-		}
-
-		@Override
-		protected void createExecution()
-				throws MetaMatrixComponentException,
-				ConnectorException {
-		}
-		
-		@Override
-		protected void processNewRequest() throws ConnectorException {
-			handleBatch();
-		}
-
-		@Override
-		protected void handleBatch() throws ConnectorException {
-			int firstRow = rowCount + 1;
-			//already in cache
-			CacheResults results = rsCache.getResults(cacheID, new int[]{firstRow, firstRow + requestMsg.getFetchSize() -1});
-			this.rowCount = rowCount + results.getResults().length;
-			if(results.isFinal()){
-				this.lastBatch = true;
-			}
-
-		    LogManager.logTrace(LogConstants.CTX_DQP, 
-		                        new Object[] { "CacheSynchQueryExecution - returnning batch from cache, startRow =",  //$NON-NLS-1$
-		                                       new Integer(firstRow),
-		                                       ", endRow =", //$NON-NLS-1$
-		                                       new Integer(rowCount)});
-		    sendResults(Arrays.asList(results.getResults()));
-		}
-	}
-
-	/**
-	 * Intercepts results for cachable commands
-	 */
-	public class CachedResultsReceiver implements ResultsReceiver<AtomicResultsMessage> {
-		
-		private ResultsReceiver<AtomicResultsMessage> actual;
-		private AtomicRequestID requestId;
-		private CacheID cacheID;
-		private int firstRow = 1;
-		
-		public CachedResultsReceiver(ResultsReceiver<AtomicResultsMessage> actual,
-				CacheID cacheID, AtomicRequestID requestId) {
-			this.actual = actual;
-			this.cacheID = cacheID;
-			this.requestId = requestId;
-		}
-
-		@Override
-		public void receiveResults(AtomicResultsMessage results) {
-			boolean isFinal = results.getFinalRow() >= 0;
-			if (results.isRequestClosed()) {
-				rsCache.removeTempResults(cacheID, requestId);
-			} else {
-				CacheResults cr = new CacheResults(results.getResults(), firstRow, isFinal);
-				firstRow += results.getResults().length;
-				rsCache.setResults(cacheID, cr, requestId);
-			}
-			actual.receiveResults(results);
-		}
-
-		@Override
-		public void exceptionOccurred(Throwable e) {
-			rsCache.removeTempResults(cacheID, requestId);
-			actual.exceptionOccurred(e);
-		}
-
-	}
-	
-	public ConnectorWorkItemFactory(ConnectorManager manager,
-			ResultSetCache rsCache, boolean synchWorkers) {
+	public ConnectorWorkItemFactory(ConnectorManager manager, boolean synchWorkers) {
 		this.manager = manager;
-		this.rsCache = rsCache;
 		this.synchWorkers = synchWorkers;
 	}
 	
 	public ConnectorWorkItem createWorkItem(AtomicRequestMessage message, ResultsReceiver<AtomicResultsMessage> receiver) {
-    	if (this.rsCache != null && message.useResultSetCache()) {
-        	final CacheID cacheID = createCacheID(message);
-
-        	if (cacheID != null) {
-	        	if (rsCache.hasResults(cacheID)) {
-	        		return new CachedResultsConnectorWorkItem(message, manager,
-							receiver, cacheID);
-	        	}
-        		receiver = new CachedResultsReceiver(receiver, cacheID, message.getAtomicRequestID());
-        	}
-    	}
-    	
     	if (synchWorkers) {
     		return new SynchConnectorWorkItem(message, manager, receiver);
     	} 
     	return new AsynchConnectorWorkItem(message, manager, receiver);
 	}
 	
-	private CacheID createCacheID(AtomicRequestMessage message) {
-		Command command = message.getCommand();
-		if (!command.areResultsCachable()) {
-			return null;
-		}
-		String scope = rsCache.getCacheScope();
-		String scopeId = null;
-		if(ResultSetCache.RS_CACHE_SCOPE_VDB.equalsIgnoreCase(scope)){
-			scopeId = message.getWorkContext().getVdbName() + DELIMITER + message.getWorkContext().getVdbVersion();
-		}else{
-			scopeId = message.getWorkContext().getConnectionID();
-		}
-		return new CacheID(scopeId, command.toString());
-	}
-
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -36,6 +36,7 @@
 import com.metamatrix.common.buffer.TupleSourceNotFoundException;
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
@@ -72,6 +73,9 @@
 			}
 		}
 		CacheResults cResult = rsCache.getResults(cid, new int[] {this.resultsCursor.begin, this.resultsCursor.end});
+		if (cResult == null) {
+			throw new MetaMatrixComponentException(DQPPlugin.Util.getString("CachedRequestWorkItem.not_available")); //$NON-NLS-1$
+		}
 		List results[] = cResult.getResults();
 		int firstRow = cResult.getFirstRow();
 

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -40,9 +40,9 @@
 
 import org.teiid.connector.xa.api.TransactionContext;
 import org.teiid.dqp.internal.cache.CacheID;
+import org.teiid.dqp.internal.cache.CacheResults;
 import org.teiid.dqp.internal.cache.DQPContextCache;
 import org.teiid.dqp.internal.cache.ResultSetCache;
-import org.teiid.dqp.internal.cache.ResultSetCacheUtil;
 
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -88,7 +88,6 @@
 import com.metamatrix.dqp.util.LogConstants;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 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;
 
@@ -136,8 +135,6 @@
     private static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
     private static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
     private static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
-    private static final String DEFAULT_MAX_RESULTSET_CACHE_SIZE = "50"; //$NON-NLS-1$
-    private static final String DEFAULT_MAX_RESULTSET_CACHE_AGE = "3600000"; //$NON-NLS-1$
 
     // System properties for Code Table
     private int maxCodeTableRecords = DEFAULT_MAX_CODE_TABLE_RECORDS;
@@ -273,12 +270,14 @@
         
         ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
         
-        if (areResultsInCache(requestMsg)) {
-            CacheID cID = ResultSetCacheUtil.createCacheID(requestMsg, this.rsCache);
-            Command command = this.rsCache.getResults(cID, new int[]{1, 1}).getCommand();
-        	workItem = new CachedRequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext, command);
+        if(this.rsCache != null && requestMsg.useResultSetCache()) {
+        	CacheID cID = this.rsCache.createCacheID(workContext, requestMsg.getCommandString(), requestMsg.getParameterValues());
+            CacheResults cr = this.rsCache.getResults(cID, new int[]{1, 1});
+            if (cr != null) {
+            	workItem = new CachedRequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext, cr.getCommand());
+            }
         }
-        else {            
+        if (workItem == null) {
             workItem = new RequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext);
         }
         
@@ -315,17 +314,6 @@
     	contextCache.removeRequestScopedCache(workItem.requestID.toString());
     }
            
-    boolean areResultsInCache(final RequestMessage requestMsg) {
-        if(this.rsCache == null){
-            return false;
-        }
-        if(!requestMsg.useResultSetCache()){
-            return false;
-        }
-        CacheID cID = ResultSetCacheUtil.createCacheID(requestMsg, this.rsCache);
-        return rsCache.hasResults(cID);        
-    }
-           
     void addWork(Runnable r) {
     	this.processWorkerPool.execute(r);
     }
@@ -645,11 +633,9 @@
         
         //result set cache
         if(PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.USE_RESULTSET_CACHE, false)){ 
-        	Properties rsCacheProps = new Properties();
-        	rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, props.getProperty(DQPEmbeddedProperties.MAX_RESULTSET_CACHE_SIZE, DEFAULT_MAX_RESULTSET_CACHE_SIZE));
-        	rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, props.getProperty(DQPEmbeddedProperties.MAX_RESULTSET_CACHE_AGE, DEFAULT_MAX_RESULTSET_CACHE_AGE));
-        	rsCacheProps.setProperty(ResultSetCache.RS_CACHE_SCOPE, props.getProperty(DQPEmbeddedProperties.RESULTSET_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB)); 
-			this.rsCache = new ResultSetCache(rsCacheProps, cacheFactory);
+			this.rsCache = new ResultSetCache();
+			PropertiesUtils.setBeanProperties(this.rsCache, props, "ResultSetCache"); //$NON-NLS-1$
+			this.rsCache.start(cacheFactory);
         }
 
         //prepared plan cache
@@ -763,7 +749,7 @@
 	public MetadataResult getMetadata(long requestID)
 			throws MetaMatrixComponentException, MetaMatrixProcessingException {
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, this.environment);
+		MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, this.environment, workContext.getVdbName(), workContext.getVdbVersion());
 		return processor.processMessage(workContext.getRequestID(requestID), workContext, null, true);
 	}
 
@@ -771,7 +757,7 @@
 			boolean allowDoubleQuotedVariable)
 			throws MetaMatrixComponentException, MetaMatrixProcessingException {
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, this.environment);
+		MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, this.environment, workContext.getVdbName(), workContext.getVdbVersion());
 		return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
 	}
 	

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -75,7 +75,7 @@
             chunk = stream.getNextChunk();
             shouldClose = chunk.isLast();
     	} catch (BlockedOnMemoryException e) {
-			LogManager.logDetail(LogConstants.CTX_DQP, new Object[] {"Reenqueueing LOB chunk request due to lack of available memory ###########", requestID}); //$NON-NLS-1$ //$NON-NLS-2$
+			LogManager.logDetail(LogConstants.CTX_DQP, new Object[] {"Reenqueueing LOB chunk request due to lack of available memory ###########", requestID}); //$NON-NLS-1$ 
 			this.dqpCore.addWork(this);
 			return;
     	} catch (TupleSourceNotFoundException e) {

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -85,11 +85,14 @@
     private String vdbVersion;
     private RequestID requestID;
     
-    public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, PreparedPlanCache planCache, ApplicationEnvironment env) {
+    
+    public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, PreparedPlanCache planCache, ApplicationEnvironment env, String vdbName, String vdbVersion) {
         this.metadataService = metadataService;    
         this.requestManager = requestManager;
         this.planCache = planCache;
         this.env = env;
+        this.vdbName = vdbName;
+        this.vdbVersion = vdbVersion;
     }
         
     /**
@@ -104,8 +107,6 @@
     MetadataResult processMessage(RequestID requestId, DQPWorkContext workContext, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException {
         final VDBService vdbService = (VDBService)env.findService(DQPServiceNames.VDB_SERVICE);
         this.requestID = requestId;
-        this.vdbName = workContext.getVdbName();
-        this.vdbVersion = workContext.getVdbVersion();
         
         this.metadata = metadataService.lookupMetadata(vdbName, vdbVersion);
         
@@ -220,14 +221,14 @@
             command = plan.getCommand();
         } else {
         	command = QueryParser.getQueryParser().parseCommand(sql, info);
-            QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, false, this.metadata, AnalysisRecord.createNonRecordingRecord());                        
+            QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, this.metadata, AnalysisRecord.createNonRecordingRecord());                        
         }
         return getMetadataForCommand(command);            
     }
 
     private Map createXMLColumnMetadata(Query xmlCommand) {
         GroupSymbol doc = (GroupSymbol) xmlCommand.getFrom().getGroups().get(0);
-        Map xmlMetadata = getDefaultColumn(vdbName, vdbVersion, doc.getName(), ResultsMetadataDefaults.XML_COLUMN_NAME, XMLType.class);
+        Map xmlMetadata = getDefaultColumn(doc.getName(), ResultsMetadataDefaults.XML_COLUMN_NAME, XMLType.class);
 
         // Override size as XML may be big        
         xmlMetadata.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.XML_COLUMN_LENGTH);
@@ -236,7 +237,7 @@
     }
 
     private Map createXQueryColumnMetadata(XQuery xqueryCommand) {
-        Map xqueryMetadata = getDefaultColumn(vdbName, vdbVersion, null, ResultsMetadataDefaults.XML_COLUMN_NAME, XMLType.class);
+        Map xqueryMetadata = getDefaultColumn(null, ResultsMetadataDefaults.XML_COLUMN_NAME, XMLType.class);
 
         // Override size as XML may be big        
         xqueryMetadata.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.XML_COLUMN_LENGTH);
@@ -333,7 +334,7 @@
     }
 
     private Map createTypedMetadata(String shortColumnName, SingleElementSymbol symbol) {
-        return getDefaultColumn(vdbName, vdbVersion, null, shortColumnName, symbol.getType());
+        return getDefaultColumn(null, shortColumnName, symbol.getType());
     }
     
     private int getColumnPrecision(Class dataType, Object elementID) throws QueryMetadataException, MetaMatrixComponentException {
@@ -403,10 +404,10 @@
        return ResultsMetadataDefaults.getMaxDisplaySize(dataType);
     }
 
-    public Map getDefaultColumn(String vdbName, String vdbVersion, 
-        String tableName, String columnName, Class javaType) {
+    public Map<Integer, Object> getDefaultColumn(String tableName, String columnName, 
+        Class javaType) {
             
-        Map column = new HashMap();
+        Map<Integer, Object> column = new HashMap<Integer, Object>();
         
         // set defaults
         column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, vdbName);

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -41,10 +41,8 @@
 import com.metamatrix.dqp.util.LogConstants;
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.optimizer.CommandTreeNode;
 import com.metamatrix.query.optimizer.batch.BatchedUpdatePlanner;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.processor.ProcessorPlan;
 import com.metamatrix.query.processor.relational.AccessNode;
 import com.metamatrix.query.processor.relational.RelationalPlan;
@@ -202,7 +200,6 @@
 		        supportPreparedBatchUpdate = caps.supportsCapability(SourceCapabilities.Capability.BULK_UPDATE);
 			}
 		}
-		CommandTreeNode ctn = new CommandTreeNode();
 		List<Command> commands = new LinkedList<Command>();
 		List<VariableContext> contexts = new LinkedList<VariableContext>();
 		List<List<Object>> multiValues = new ArrayList<List<Object>>(this.prepPlan.getReferences().size());
@@ -223,10 +220,7 @@
 			}
 			Command c = (Command)this.prepPlan.getRewritenCommand().clone();
 			commands.add(c);
-			CommandTreeNode child = new CommandTreeNode();
-			child.setCommand(c);
-			child.setProcessorPlan((ProcessorPlan)this.processPlan.clone());
-			ctn.addLastChild(child);
+			c.setProcessorPlan((ProcessorPlan)this.processPlan.clone());
 		}
 		
 		if (paramValues.size() > 1) {
@@ -247,10 +241,9 @@
 		}
 		
 		BatchedUpdateCommand buc = new BatchedUpdateCommand(commands);
-		ctn.setCommand(buc);
-		ctn.setProperty(RelationalPlanner.VARIABLE_CONTEXTS, contexts);
+		buc.setVariableContexts(contexts);
 		BatchedUpdatePlanner planner = new BatchedUpdatePlanner();
-		this.processPlan = planner.optimize(ctn, idGenerator, metadata, capabilitiesFinder, analysisRecord, context);
+		this.processPlan = planner.optimize(buc, idGenerator, metadata, capabilitiesFinder, analysisRecord, context);
 	}
 
 	/** 

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -335,7 +335,7 @@
         throws QueryValidatorException, MetaMatrixComponentException {
 
         // Validate with visitor
-        ValidatorReport report = Validator.validate(command, metadata, visitor, validateOnlyEmbedded);
+        ValidatorReport report = Validator.validate(command, metadata, visitor);
         if (report.hasItems()) {
             ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
             throw new QueryValidatorException(firstFailure.getMessage());
@@ -444,7 +444,7 @@
         
         validateQuery(command);
         
-        command = QueryRewriter.rewrite(command, null, metadata, context);
+        command = QueryRewriter.rewrite(command, metadata, context);
         
         /*
          * Adds a row limit to a query if Statement.setMaxRows has been called and the command
@@ -467,6 +467,11 @@
                 finder = new MultiSourceCapabilitiesFinder(finder, this.multiSourceModels);
             }
             
+            boolean debug = analysisRecord.recordDebug();
+    		if(debug) {
+    			analysisRecord.println("\n============================================================================"); //$NON-NLS-1$
+                analysisRecord.println("USER COMMAND:\n" + command);		 //$NON-NLS-1$
+            }
             // Run the optimizer
             try {
                 processPlan = QueryOptimizer.optimizePlan(command, metadata, idGenerator, finder, analysisRecord, context);
@@ -595,7 +600,7 @@
         	copy.pushCall(recursionGroup);
         }
         
-        newCommand = QueryRewriter.rewrite(newCommand, null, metadata, copy);
+        newCommand = QueryRewriter.rewrite(newCommand, metadata, copy);
         ProcessorPlan plan = QueryOptimizer.optimizePlan(newCommand, metadata, idGenerator, capabilitiesFinder, analysisRecord, copy);
         return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
 	}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -39,7 +39,6 @@
 import org.teiid.dqp.internal.cache.CacheID;
 import org.teiid.dqp.internal.cache.CacheResults;
 import org.teiid.dqp.internal.cache.ResultSetCache;
-import org.teiid.dqp.internal.cache.ResultSetCacheUtil;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixException;
@@ -169,7 +168,7 @@
         this.processorTimeslice = dqpCore.getProcessorTimeSlice();
         this.rsCache = dqpCore.getRsCache();
         if (this.rsCache != null) {
-        	this.cid = ResultSetCacheUtil.createCacheID(requestMsg, rsCache);
+        	this.cid = this.rsCache.createCacheID(workContext, requestMsg.getCommandString(), requestMsg.getParameterValues());
         }
         this.transactionService = dqpCore.getTransactionServiceDirect();
         this.dqpCore = dqpCore;
@@ -369,12 +368,9 @@
 			public void batchProduced(TupleBatch batch) throws BlockedOnMemoryException, TupleSourceNotFoundException, MetaMatrixComponentException {
 	            //if there is a cache, and it is a query, save it
 	            if(rsCache != null && requestMsg.useResultSetCache() && originalCommand.areResultsCachable() && transactionState == TransactionState.NONE && !rsCache.hasResults(cid)){
-            		CacheResults cr = new CacheResults(batch.getAllTuples(), processor.getProcessorPlan().getOutputElements(), batch.getBeginRow(), !doneProducingBatches);
+            		CacheResults cr = new CacheResults(batch.getAllTuples(), batch.getBeginRow(), !doneProducingBatches);
                     cr.setCommand(originalCommand);
                     cr.setSize(batch.getSize());
-                    if(batch.getSize() != TupleBatch.UNKNOWN_SIZE){
-                    	cr.setSize(batch.getSize());
-                    }
                     cr.setAnalysisRecord(analysisRecord);
             		if (!rsCache.setResults(cid, cr, requestID)) {
             			rsCache = null; //disable caching if we are over size

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -107,7 +107,7 @@
 
             // Rewrite the command now that criteria may have been simplified
             try {
-                command = QueryRewriter.rewrite(command, null, metadata, null);                    
+                command = QueryRewriter.rewrite(command, metadata, null);                    
                 instanceNode.setCommand(command);
             } catch(QueryValidatorException e) {
                 // ignore and use original command

Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -65,6 +65,7 @@
 import com.metamatrix.query.mapping.xml.MappingLoader;
 import com.metamatrix.query.mapping.xml.MappingNode;
 import com.metamatrix.query.metadata.BasicQueryMetadata;
+import com.metamatrix.query.metadata.GroupInfo;
 import com.metamatrix.query.metadata.StoredProcedureInfo;
 import com.metamatrix.query.metadata.SupportConstants;
 import com.metamatrix.query.sql.lang.SPParameter;
@@ -91,7 +92,8 @@
     /*
      * TODO: move caching to jboss cache structure
      */
-    private final Map<String, Object> metadataCache = Collections.synchronizedMap(new LRUCache<String, Object>(500));
+    private final Map<String, Object> metadataCache = Collections.synchronizedMap(new LRUCache<String, Object>(250));
+    private final Map<String, Object> groupInfoCache = Collections.synchronizedMap(new LRUCache<String, Object>(250));
     private final Map<String, Collection<Table>> partialNameToFullNameCache = Collections.synchronizedMap(new LRUCache<String, Collection<Table>>(1000));
     private final Map<String, Collection<StoredProcedureInfo>> procedureCache = Collections.synchronizedMap(new LRUCache<String, Collection<StoredProcedureInfo>>(200));
     /**
@@ -1027,7 +1029,11 @@
 	public Object addToMetadataCache(Object metadataID, String key, Object value)
 			throws MetaMatrixComponentException, QueryMetadataException {
         ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
+        boolean groupInfo = key.startsWith(GroupInfo.CACHE_PREFIX);
         key = getCacheKey(key, (AbstractMetadataRecord)metadataID);
+        if (groupInfo) {
+        	return this.groupInfoCache.put(key, value); 
+        }
     	return this.metadataCache.put(key, value); 
 	}
 
@@ -1035,7 +1041,11 @@
 	public Object getFromMetadataCache(Object metadataID, String key)
 			throws MetaMatrixComponentException, QueryMetadataException {
         ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
+        boolean groupInfo = key.startsWith(GroupInfo.CACHE_PREFIX);
         key = getCacheKey(key, (AbstractMetadataRecord)metadataID);
+        if (groupInfo) {
+        	return this.groupInfoCache.get(key); 
+        }
     	return this.metadataCache.get(key);
 	}
 

Modified: trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties	2009-12-09 21:41:41 UTC (rev 1630)
@@ -495,7 +495,7 @@
 TransformationMetadata.Multiple_transformation_records_found_for_the_group___1=Multiple transformation records found for the group: 
 TransformationMetadata.Multiple_annotation_records_found_for_the_entity_{0}_1=Multiple annotation records found for the entity {0}
 TransformationMetadata.No_metadata_info_available_for_the_index_with_UUID_{0}._1=No metadata info available for the index with UUID {0}.
-TransformationMetadata.Ambigous_index_with_UUID_{0},_found_multiple_indexes_with_the_given_UUID._2=Ambigous index with UUID {0}, found multiple indexes with the given UUID.
+TransformationMetadata.Ambiguous_index_with_UUID_{0},_found_multiple_indexes_with_the_given_UUID._2=Ambiguous index with UUID {0}, found multiple indexes with the given UUID.
 TransformationMetadata.Invalid_type=Invalid type: {0}.
 TransformationMetadata.Unable_to_determine_fullname_for_element__1=Unable to determine fullname for element
 TransformationMetadata.does_not_exist._1=does not exist.
@@ -526,6 +526,8 @@
 TransformationMetadata.Multiple_transformation_records_found_for_the_group___1=Multiple transformation records found for the group: 
 TransformationMetadata.Multiple_annotation_records_found_for_the_entity_{0}_1=Multiple annotation records found for the entity {0}
 TransformationMetadata.No_metadata_info_available_for_the_index_with_UUID_{0}._1=No metadata info available for the index with UUID {0}.
-TransformationMetadata.Ambigous_index_with_UUID_{0},_found_multiple_indexes_with_the_given_UUID._2=Ambigous index with UUID {0}, found multiple indexes with the given UUID.
+TransformationMetadata.Ambiguous_index_with_UUID_{0},_found_multiple_indexes_with_the_given_UUID._2=Ambiguous index with UUID {0}, found multiple indexes with the given UUID.
 TransformationMetadata.Invalid_type=Invalid type: {0}.
-TransformationMetadata.Unable_to_determine_fullname_for_element__1=Unable to determine fullname for element
\ No newline at end of file
+TransformationMetadata.Unable_to_determine_fullname_for_element__1=Unable to determine fullname for element
+
+CachedRequestWorkItem.not_available=Cache result is no longer available.
\ No newline at end of file

Modified: trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -122,7 +122,7 @@
      */
     public static BufferManager getStandaloneBufferManager() throws MetaMatrixComponentException {
     	if (INSTANCE == null) {
-	        BufferManager bufferMgr = new BufferManagerImpl();
+	        BufferManagerImpl bufferMgr = new BufferManagerImpl();
 	        Properties props = new Properties();
 	        props.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, String.valueOf(Long.MAX_VALUE));
 	        props.setProperty(BufferManagerPropertyNames.SESSION_USE_PERCENTAGE, "100"); //$NON-NLS-1$

Modified: trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestBufferManagerImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestBufferManagerImpl.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestBufferManagerImpl.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -70,7 +70,7 @@
         Properties bmProps = new Properties();                        
         bmProps.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, String.valueOf(bytesAvailable));
         bmProps.setProperty(BufferManagerPropertyNames.MANAGEMENT_INTERVAL, "0"); //$NON-NLS-1$
-        BufferManager bufferManager = new BufferManagerImpl();
+        BufferManagerImpl bufferManager = new BufferManagerImpl();
         bufferManager.initialize("local", bmProps); //$NON-NLS-1$
 
         if(sm2 != null) { 

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,6 +22,8 @@
 
 package com.metamatrix.query.optimizer;
 
+import static org.junit.Assert.*;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -30,8 +32,7 @@
 import java.util.List;
 import java.util.Set;
 
-import junit.framework.TestCase;
-
+import org.junit.Test;
 import org.teiid.connector.api.SourceSystemFunctions;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -88,7 +89,7 @@
 import com.metamatrix.query.validator.Validator;
 import com.metamatrix.query.validator.ValidatorReport;
 
-public class TestOptimizer extends TestCase {
+public class TestOptimizer {
 
     public interface DependentJoin {}
     public interface DependentSelectNode {}
@@ -118,12 +119,6 @@
     public static final boolean SHOULD_SUCCEED = true;
     public static final boolean SHOULD_FAIL = false;
 
-	// ################################## FRAMEWORK ################################
-	
-	public TestOptimizer(String name) { 
-		super(name);
-	}	
-
 	// ################################## TEST HELPERS ################################
 
     public static BasicSourceCapabilities getTypicalCapabilities() {        
@@ -218,7 +213,7 @@
         }                       	
 
 		// rewrite
-		command = QueryRewriter.rewrite(command, null, md, new CommandContext());
+		command = QueryRewriter.rewrite(command, md, new CommandContext());
 
         return command;
     }
@@ -758,12 +753,12 @@
 	/**
 	 * Test defect 8096 - query a virtual group with subquery of another virtual group 
 	 */
-	public void testVirtualSubqueryINClause_8096() { 
+	@Test public void testVirtualSubqueryINClause_8096() { 
 		helpPlan("SELECT * FROM vm1.sub1", example1(), //$NON-NLS-1$
 			new String[] {"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
 	}
 
-	public void testQueryPhysical() { 
+	@Test public void testQueryPhysical() { 
 		ProcessorPlan plan = helpPlan("SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] {"SELECT pm1.g1.e1, e2, pm1.g1.e3, e4 FROM pm1.g1"} ); //$NON-NLS-1$
 
@@ -772,58 +767,58 @@
         checkSubPlanCount(plan, 0);
 	}
     
-	public void testSelectStarPhysical() { 
+	@Test public void testSelectStarPhysical() { 
 		ProcessorPlan plan = helpPlan("SELECT * FROM pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
 	}
 
-	public void testQuerySingleSourceVirtual() { 
+	@Test public void testQuerySingleSourceVirtual() { 
 		ProcessorPlan plan = helpPlan("SELECT * FROM vm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
 	}
 	
-	public void testQueryMultiSourceVirtual() { 
+	@Test public void testQueryMultiSourceVirtual() { 
 		ProcessorPlan plan = helpPlan("SELECT * FROM vm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "SELECT g_0.e1, g_0.e2, g_1.e3, g_1.e4 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1"} ); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
 	}
 
-	public void testPhysicalVirtualJoinWithCriteria() throws Exception { 
+	@Test public void testPhysicalVirtualJoinWithCriteria() throws Exception { 
 		ProcessorPlan plan = helpPlan("SELECT vm1.g2.e1 from vm1.g2, pm1.g3 where vm1.g2.e1=pm1.g3.e1 and vm1.g2.e2 > 0", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g3 AS g_2 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = g_2.e1) AND (g_0.e2 > 0)" }, ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
 	}
     
-    public void testQueryWithExpression() { 
+    @Test public void testQueryWithExpression() { 
         helpPlan("SELECT e4 FROM pm3.g1 WHERE e4 < convert('2001-11-01 10:30:40.42', timestamp)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "SELECT e4 FROM pm3.g1 WHERE e4 < {ts'2001-11-01 10:30:40.42'}"} ); //$NON-NLS-1$
     }
     
-    public void testInsert() { 
+    @Test public void testInsert() { 
         helpPlan("Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values ('MyString', 1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES ('MyString', 1)"} ); //$NON-NLS-1$
     }
     
-    public void testUpdate1() { 
+    @Test public void testUpdate1() { 
       	helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM('MyString'), pm1.g1.e2= 1 where pm1.g1.e3= 'true'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "UPDATE pm1.g1 SET pm1.g1.e1 = 'MyString', pm1.g1.e2 = 1 WHERE pm1.g1.e3 = TRUE"} ); //$NON-NLS-1$
   	}
   	
-    public void testUpdate2() { 
+    @Test public void testUpdate2() { 
         helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM('MyString'), pm1.g1.e2= 1 where pm1.g1.e2= convert(pm1.g1.e4, integer)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "UPDATE pm1.g1 SET pm1.g1.e1 = 'MyString', pm1.g1.e2 = 1 WHERE pm1.g1.e2 = convert(pm1.g1.e4, integer)"} ); //$NON-NLS-1$
     }
     
-    public void testDelete() { 
+    @Test public void testDelete() { 
     	helpPlan("Delete from pm1.g1 where pm1.g1.e1 = cast(pm1.g1.e2 AS string)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
 			new String[] { "DELETE FROM pm1.g1 WHERE pm1.g1.e1 = cast(pm1.g1.e2 AS string)"} ); //$NON-NLS-1$
   	}
 
 	// ############################# TESTS ON EXAMPLE 1 ############################
 	
-    public void testCopyInAcrossJoin() throws Exception {
+    @Test public void testCopyInAcrossJoin() throws Exception {
         ProcessorPlan plan = helpPlan("select pm1.g1.e1, pm2.g2.e1 from pm1.g1, pm2.g2 where pm1.g1.e1=pm2.g2.e1 and pm1.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
             new String[] { "SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 WHERE g_0.e1 IN ('a', 'b') ORDER BY c_0", //$NON-NLS-1$
         				   "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN ('a', 'b') ORDER BY c_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
@@ -846,75 +841,75 @@
         }); 
     }
 
-    public void testCopyMatchAcrossJoin() throws Exception {
+    @Test public void testCopyMatchAcrossJoin() throws Exception {
         helpPlan("select pm1.g1.e1, pm2.g2.e1 from pm1.g1, pm2.g2 where pm1.g1.e1=pm2.g2.e1 and pm1.g1.e1 LIKE '%1'", example1(), //$NON-NLS-1$
             new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 LIKE '%1' ORDER BY c_0", //$NON-NLS-1$
         					"SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 WHERE g_0.e1 LIKE '%1' ORDER BY c_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
     }
  
-    public void testCopyOrAcrossJoin() throws Exception {
+    @Test public void testCopyOrAcrossJoin() throws Exception {
         helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and (pm1.g1.e1 = 'abc' OR pm1.g1.e1 = 'def')", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e1 = 'def')", //$NON-NLS-1$
                             "SELECT pm1.g2.e1 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') OR (pm1.g2.e1 = 'def')" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
     }
  
-    public void testCopyMultiElementCritAcrossJoin() throws Exception {
+    @Test public void testCopyMultiElementCritAcrossJoin() throws Exception {
         helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and pm1.g1.e2=pm1.g2.e2 and (pm1.g1.e1 = 'abc' OR pm1.g1.e2 = 5)", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g2.e1, pm1.g2.e2 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') OR (pm1.g2.e2 = 5)", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testCantCopyAcrossJoin1() throws Exception {
+    @Test public void testCantCopyAcrossJoin1() throws Exception {
         helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and concat(pm1.g1.e1, pm1.g1.e2) = 'abc'", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", //$NON-NLS-1$
                             "SELECT pm1.g2.e1 FROM pm1.g2" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
     }
 
-    public void testCantCopyAcrossJoin2() throws Exception {
+    @Test public void testCantCopyAcrossJoin2() throws Exception {
         helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and (pm1.g1.e1 = 'abc' OR pm1.g1.e2 = 5)", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)", //$NON-NLS-1$
                             "SELECT pm1.g2.e1 FROM pm1.g2" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
     }
 
-    public void testPushingCriteriaThroughFrame1() { 
+    @Test public void testPushingCriteriaThroughFrame1() { 
     	helpPlan("select * from vm1.g1, vm1.g2 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g2.e1", example1(), //$NON-NLS-1$
 			new String[] { "SELECT g1__1.e1, g1__1.e2, g1__1.e3, g1__1.e4 FROM pm1.g1 AS g1__1 WHERE g1__1.e1 = 'abc'", //$NON-NLS-1$
 							"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
   	}
 
-    public void testPushingCriteriaThroughFrame2() throws Exception { 
+    @Test public void testPushingCriteriaThroughFrame2() throws Exception { 
     	helpPlan("select * from vm1.g1, vm1.g3 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g3.e1", example1(), //$NON-NLS-1$
 			new String[] { "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'",  //$NON-NLS-1$
 							"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING ); //$NON-NLS-1$
   	}
 
-    public void testPushingCriteriaThroughFrame3() { 
+    @Test public void testPushingCriteriaThroughFrame3() { 
     	helpPlan("select * from vm1.g1, vm1.g2, vm1.g1 as a where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g2.e1 and vm1.g1.e1=a.e1", example1(), //$NON-NLS-1$
 			new String[] { "SELECT g1__1.e1, g1__1.e2, g1__1.e3, g1__1.e4 FROM pm1.g1 AS g1__1 WHERE g1__1.e1 = 'abc'", //$NON-NLS-1$
 							"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
 							"SELECT g1__2.e1, g1__2.e2, g1__2.e3, g1__2.e4 FROM pm1.g1 AS g1__2 WHERE g1__2.e1 = 'abc'" } ); //$NON-NLS-1$
   	}
 
-    public void testPushingCriteriaThroughUnion1() { 
+    @Test public void testPushingCriteriaThroughUnion1() { 
     	helpPlan("select e1 from vm1.u1 where e1='abc'", example1(), //$NON-NLS-1$
 			new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE pm1.g3.e1 = 'abc'", //$NON-NLS-1$
 							"SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
 							"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
   	}
 
-    public void testPushingCriteriaThroughUnion2() { 
+    @Test public void testPushingCriteriaThroughUnion2() { 
     	helpPlan("select e1 from vm1.u2 where e1='abc'", example1(), //$NON-NLS-1$
 			new String[] { "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
 							"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
   	}
 
-    public void testPushingCriteriaThroughUnion3() { 
+    @Test public void testPushingCriteriaThroughUnion3() { 
     	helpPlan("select e1 from vm1.u1 where e1='abc' and e2=5", example1(), //$NON-NLS-1$
 			new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE (pm1.g3.e1 = 'abc') AND (pm1.g3.e2 = 5)", //$NON-NLS-1$
 							"SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') AND (pm1.g2.e2 = 5)", //$NON-NLS-1$
 							"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') AND (pm1.g1.e2 = 5)" } ); //$NON-NLS-1$
   	}
 
-    public void testPushingCriteriaThroughUnion4() { 
+    @Test public void testPushingCriteriaThroughUnion4() { 
     	helpPlan("select e1 from vm1.u1 where e1='abc' or e2=5", example1(), //$NON-NLS-1$
 			new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE (pm1.g3.e1 = 'abc') OR (pm1.g3.e2 = 5)", //$NON-NLS-1$
 							"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)", //$NON-NLS-1$
@@ -922,38 +917,38 @@
   	}
 
 	// expression in a subquery of the union
-    public void testPushingCriteriaThroughUnion5() { 
+    @Test public void testPushingCriteriaThroughUnion5() { 
     	helpPlan("select e1 from vm1.u3 where e1='abc'", example1(), //$NON-NLS-1$
 			new String[] { "SELECT DISTINCT e1 FROM pm1.g1 WHERE e1 = 'abc'" } ); //$NON-NLS-1$
   	}
 
     /** defect #4956 */
-    public void testPushCriteriaThroughUnion6() { 
+    @Test public void testPushCriteriaThroughUnion6() { 
         helpPlan("select v1 from vm1.u4 where vm1.u4.v1='x'", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
                             "SELECT e1 FROM pm1.g2 WHERE e1 = 'x'" } ); //$NON-NLS-1$
     }
 
-    public void testPushCriteriaThroughUnion7() { 
+    @Test public void testPushCriteriaThroughUnion7() { 
         helpPlan("select v1 from vm1.u5 where vm1.u5.v1='x'", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
                             "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
     }
 
-    public void testPushCriteriaThroughUnion8() { 
+    @Test public void testPushCriteriaThroughUnion8() { 
         helpPlan("select v1 from vm1.u5 where length(v1) > 0", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
                             "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
     }
     
-    public void testPushCriteriaThroughUnion11() {
+    @Test public void testPushCriteriaThroughUnion11() {
         helpPlan("select * from vm1.u8 where const = 's3' or e1 is null", example1(), //$NON-NLS-1$
             new String[] { "SELECT 's3', e1 FROM pm1.g3", //$NON-NLS-1$
                             "SELECT 's2', e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
                             "SELECT 's1', e1 FROM pm1.g1 WHERE e1 IS NULL" } );     //$NON-NLS-1$
     }
 
-    public void testPushCriteriaThroughUnion12() {
+    @Test public void testPushCriteriaThroughUnion12() {
         helpPlan("select * from vm1.u8 where const = 's1' or e1 is null", example1(), //$NON-NLS-1$
             new String[] { "SELECT 's3', e1 FROM pm1.g3 WHERE e1 IS NULL", //$NON-NLS-1$
                             "SELECT 's2', e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
@@ -961,7 +956,7 @@
     }
 
     /** defect #4997 */
-    public void testCountStarNoRows() { 
+    @Test public void testCountStarNoRows() { 
         ProcessorPlan plan = helpPlan("select count(*) from vm1.u4", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g2",  //$NON-NLS-1$
                             "SELECT e1 FROM pm1.g1" } ); //$NON-NLS-1$
@@ -983,7 +978,7 @@
         }); 
     }
 
-    public void testPushingCriteriaWithCopy() { 
+    @Test public void testPushingCriteriaWithCopy() { 
     	ProcessorPlan plan = helpPlan("select vm1.u1.e1 from vm1.u1, pm1.g1 where vm1.u1.e1='abc' and vm1.u1.e1=pm1.g1.e1", example1(), //$NON-NLS-1$
 			new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
                             "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE pm1.g3.e1 = 'abc'", //$NON-NLS-1$
@@ -1007,84 +1002,84 @@
         }); 
   	}
 
-    public void testVirtualGroupWithAliasedElement() {
+    @Test public void testVirtualGroupWithAliasedElement() {
         helpPlan("select elem FROM vm1.u6 where elem='abc' and const='xyz'", example1(), //$NON-NLS-1$
             new String[] { "SELECT x1.e1 FROM pm1.g1 AS x1 WHERE x1.e1 = 'abc'" } );     //$NON-NLS-1$
     }
 
-    public void testPushThroughGroup1() {
+    @Test public void testPushThroughGroup1() {
         helpPlan("select * FROM vm1.a1 WHERE e1 = 'x'", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = 'x'" } );     //$NON-NLS-1$
     }
  
-    public void testPushThroughGroup2() {
+    @Test public void testPushThroughGroup2() {
         helpPlan("select * FROM vm1.a2 WHERE e1 = 'x'", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = 'x'" } );     //$NON-NLS-1$
     }
 
-    public void testPushThroughGroup3() {
+    @Test public void testPushThroughGroup3() {
         helpPlan("select * FROM vm1.a3 WHERE sum_e2 > 0", example1(), //$NON-NLS-1$
             new String[] { "SELECT e2 FROM pm1.g1" } );     //$NON-NLS-1$
     }
 
-    public void testPushMultiGroupCriteria() { 
+    @Test public void testPushMultiGroupCriteria() { 
         ProcessorPlan plan = helpPlan("select pm2.g1.e1 from pm2.g1, pm2.g2 where pm2.g1.e1 = pm2.g2.e1 and (pm2.g1.e2 = 1 OR pm2.g2.e2 = 2)", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2 WHERE (pm2.g1.e1 = pm2.g2.e1) AND ((pm2.g1.e2 = 1) OR (pm2.g2.e2 = 2))" } ); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }   
 
-    public void testSimpleCrossJoin1() throws Exception {
+    @Test public void testSimpleCrossJoin1() throws Exception {
         helpPlan("select pm1.g1.e1 FROM pm1.g1, pm1.g2", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
                 "SELECT pm1.g2.e1 FROM pm1.g2" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING );     //$NON-NLS-1$
     }
 
-    public void testSimpleCrossJoin2() {
+    @Test public void testSimpleCrossJoin2() {
         helpPlan("select pm2.g1.e1 FROM pm2.g1, pm2.g2", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2"} ); //$NON-NLS-1$
                
     }
 
-    public void testSimpleCrossJoin3() {
+    @Test public void testSimpleCrossJoin3() {
         helpPlan("select pm2.g1.e1 FROM pm2.g1 CROSS JOIN pm2.g2", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2"} ); //$NON-NLS-1$
                
     }
 
-    public void testMultiSourceCrossJoin() throws Exception {
+    @Test public void testMultiSourceCrossJoin() throws Exception {
         helpPlan("select pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
                 "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
                 "SELECT pm1.g3.e1 FROM pm1.g3" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING );     //$NON-NLS-1$
     }
 
-    public void testSingleSourceCrossJoin() {
+    @Test public void testSingleSourceCrossJoin() {
         helpPlan("select pm2.g1.e1 FROM pm2.g1, pm2.g2, pm2.g3", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2, pm2.g3"} ); //$NON-NLS-1$
     }
 
-    public void testSelfJoins() {
+    @Test public void testSelfJoins() {
         helpPlan("select pm2.g1.e1 FROM pm2.g1 JOIN pm2.g1 AS x ON pm2.g1.e1=x.e1", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1 FROM pm2.g1 order by e1", //$NON-NLS-1$
                 "SELECT x.e1 FROM pm2.g1 AS x order by e1" } );     //$NON-NLS-1$
     }
 
-    public void testDefect5282_1() {
+    @Test public void testDefect5282_1() {
         helpPlan("select * FROM vm1.a4 WHERE vm1.a4.count > 0", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } );     //$NON-NLS-1$
     }
 
-    public void testDefect5282_2() {
+    @Test public void testDefect5282_2() {
         helpPlan("select count(*) FROM vm1.a4", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } );     //$NON-NLS-1$
     }
 
-    public void testDefect5282_3() {
+    @Test public void testDefect5282_3() {
         helpPlan("select * FROM vm1.a5 WHERE vm1.a5.count > 0", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } );     //$NON-NLS-1$
     }
     
-    public void testDepJoinHintBaseline() throws Exception {
+    @Test public void testDepJoinHintBaseline() throws Exception {
         ProcessorPlan plan = helpPlan("select * FROM vm1.g4", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
                             "SELECT pm1.g2.e1 FROM pm1.g2" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
@@ -1106,37 +1101,37 @@
         }); 
     }
     
-    public void testDefect6425_1() {
+    @Test public void testDefect6425_1() {
         helpPlan("select * from vm1.u9", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1, e1 FROM pm1.g1", //$NON-NLS-1$
                             "SELECT e1, e1 FROM pm1.g2" } );     //$NON-NLS-1$
     }
 
-    public void testDefect6425_2() {
+    @Test public void testDefect6425_2() {
         helpPlan("select count(*) from vm1.u9", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
                             "SELECT e1 FROM pm1.g2" } );     //$NON-NLS-1$
     }
     
-    public void testPushMatchCritWithReference() {
+    @Test public void testPushMatchCritWithReference() {
         List bindings = new ArrayList();
         bindings.add("pm1.g2.e1"); //$NON-NLS-1$
         helpPlan("select e1 FROM pm1.g1 WHERE e1 LIKE ?", example1(), bindings, null,  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 LIKE ?" }, true ); //$NON-NLS-1$
     }
     
-    public void testDefect6517() {
+    @Test public void testDefect6517() {
         helpPlan("select count(*) from vm1.g5", example1(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm1.g1.e1 FROM pm1.g1" });     //$NON-NLS-1$
     }
     
-    public void testDefect5283() {        
+    @Test public void testDefect5283() {        
         helpPlan("select * from vm1.a6", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
                             "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2" } ); //$NON-NLS-1$
     }
     
-    public void testManyJoinsOverThreshold() throws Exception {
+    @Test public void testManyJoinsOverThreshold() throws Exception {
         long begin = System.currentTimeMillis();
         helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3, pm1.g4, pm1.g5, pm1.g6, pm1.g7, pm1.g8, pm1.g1 AS x, pm1.g2 AS y WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1 AND pm1.g3.e1 = pm1.g4.e1 AND pm1.g4.e1 = pm1.g5.e1 AND pm1.g5.e1=pm1.g6.e1 AND pm1.g6.e1=pm1.g7.e1 AND pm1.g7.e1=pm1.g8.e1", //$NON-NLS-1$
             example1(), 
@@ -1155,7 +1150,7 @@
         assertTrue("Did not plan many join query in reasonable time frame: " + elapsed + " ms", elapsed < 4000); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testAggregateWithoutGroupBy() {
+    @Test public void testAggregateWithoutGroupBy() {
         ProcessorPlan plan = helpPlan("select count(e2) from pm1.g1", example1(), //$NON-NLS-1$
             new String[] { "SELECT e2 FROM pm1.g1" } );         //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1176,7 +1171,7 @@
         }); 
     }
     
-    public void testHavingWithoutGroupBy() {
+    @Test public void testHavingWithoutGroupBy() {
         ProcessorPlan plan = helpPlan("select count(e2) from pm1.g1 HAVING count(e2) > 0", example1(), //$NON-NLS-1$
             new String[] { "SELECT e2 FROM pm1.g1" } );         //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1197,7 +1192,7 @@
         }); 
     }
 
-    public void testHavingAndGroupBy() {
+    @Test public void testHavingAndGroupBy() {
         ProcessorPlan plan = helpPlan("select e1, count(e2) from pm1.g1 group by e1 having count(e2) > 0 and sum(e2) > 0", example1(), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm1.g1" } );         //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1218,7 +1213,7 @@
         }); 
     }
     
-    public void testAllJoinsInSingleClause() throws Exception {
+    @Test public void testAllJoinsInSingleClause() throws Exception {
         ProcessorPlan plan = helpPlan("select pm1.g1.e1 FROM pm1.g1 join (pm1.g2 right outer join pm1.g3 on pm1.g2.e1=pm1.g3.e1) on pm1.g1.e1=pm1.g3.e1", example1(),  //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1",  //$NON-NLS-1$
                             "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
@@ -1241,7 +1236,7 @@
         }); 
     }
 
-    public void testSelectCountStarFalseCriteria() {
+    @Test public void testSelectCountStarFalseCriteria() {
         ProcessorPlan plan = helpPlan("Select count(*) from pm1.g1 where 1=0", example1(),  //$NON-NLS-1$
             new String[] { });
         checkNodeTypes(plan, new int[] {
@@ -1262,31 +1257,31 @@
         }); 
     }
 
-    public void testSubquery1() {
+    @Test public void testSubquery1() {
         ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1) AS x", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testSubquery2() {
+    @Test public void testSubquery2() {
         ProcessorPlan plan = helpPlan("Select e1, a from (select e1 FROM pm1.g1) AS x, (select e1 as a FROM pm1.g2) AS y WHERE x.e1=y.a", example1(),  //$NON-NLS-1$
             new String[] { "SELECT g_0.e1, g_1.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-	public void testSubquery3() {
+	@Test public void testSubquery3() {
 		ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1) AS x WHERE x.e1 = 'a'", example1(), //$NON-NLS-1$
 			new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = 'a'" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-	public void testSubquery4() {
+	@Test public void testSubquery4() {
 		ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1 WHERE e1 = 'a') AS x", example1(), //$NON-NLS-1$
 			new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = 'a'" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testSubqueryInClause1() {
+    @Test public void testSubqueryInClause1() {
         ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm2.g1)", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1307,7 +1302,7 @@
         }); 
     }
 
-    public void testCompareSubquery1() {
+    @Test public void testCompareSubquery1() {
         ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 < any (select e1 FROM pm2.g1)", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1328,7 +1323,7 @@
         }); 
     }
 
-    public void testCompareSubquery2() {
+    @Test public void testCompareSubquery2() {
         ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 <= some (select e1 FROM pm2.g1)", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1349,7 +1344,7 @@
         }); 
     }
 
-    public void testCompareSubquery3() {
+    @Test public void testCompareSubquery3() {
         ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 >= all (select e1 FROM pm2.g1)", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1370,7 +1365,7 @@
         }); 
     }
 
-    public void testCompareSubquery4() {
+    @Test public void testCompareSubquery4() {
         ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 > (select e1 FROM pm2.g1 where e2 = 13)", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1391,7 +1386,7 @@
         }); 
     }
 
-    public void testExistsSubquery1() {
+    @Test public void testExistsSubquery1() {
         ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where exists (select e1 FROM pm2.g1)", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1412,7 +1407,7 @@
         }); 
     }
     
-    public void testScalarSubquery1() {
+    @Test public void testScalarSubquery1() {
         ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 where e1 = 'x') from pm1.g1", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1433,7 +1428,7 @@
         }); 
     }    
 
-    public void testScalarSubquery2() {
+    @Test public void testScalarSubquery2() {
         ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 where e1 = 'x') as X from pm1.g1", example1(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1454,7 +1449,7 @@
         }); 
     } 
     
-    public void testTempGroup() {
+    @Test public void testTempGroup() {
         ProcessorPlan plan = helpPlan("select e1 from tm1.g1 where e1 = 'x'", FakeMetadataFactory.example1Cached(),  //$NON-NLS-1$
             new String[] { "SELECT e1 FROM tm1.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1475,7 +1470,7 @@
         }); 
     }
     
-    public void testNotPushDistinct() throws Exception {
+    @Test public void testNotPushDistinct() throws Exception {
         ProcessorPlan plan = helpPlan("select distinct e1 from pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1496,73 +1491,73 @@
         }); 
     }
 
-    public void testPushDistinct() {
+    @Test public void testPushDistinct() {
         ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT e1 FROM pm3.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctSort() {
+    @Test public void testPushDistinctSort() {
         ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1 order by e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT e1 FROM pm3.g1 ORDER BY e1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctWithCriteria() {
+    @Test public void testPushDistinctWithCriteria() {
         ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1 where e1 = 'x'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT e1 FROM pm3.g1 WHERE e1 = 'x'" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual1() {
+    @Test public void testPushDistinctVirtual1() {
         ProcessorPlan plan = helpPlan("select * from vm1.g12", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual2() {
+    @Test public void testPushDistinctVirtual2() {
         ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g12", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual3() {
+    @Test public void testPushDistinctVirtual3() {
         ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g12 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual4() {
+    @Test public void testPushDistinctVirtual4() {
         ProcessorPlan plan = helpPlan("select * from vm1.g13", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual5() {
+    @Test public void testPushDistinctVirtual5() {
         ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g13", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual6() {
+    @Test public void testPushDistinctVirtual6() {
         ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g13 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual7() {
+    @Test public void testPushDistinctVirtual7() {
         ProcessorPlan plan = helpPlan("select * from vm1.g14", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual8() {
+    @Test public void testPushDistinctVirtual8() {
         ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g14", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushDistinctVirtual9() {
+    @Test public void testPushDistinctVirtual9() {
         ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g14 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN); 
@@ -1571,7 +1566,7 @@
     /**
      * Defect #7819
      */
-    public void testPushDistinctWithExpressions() {
+    @Test public void testPushDistinctWithExpressions() {
         ProcessorPlan plan = helpPlan("SELECT DISTINCT * FROM vm1.g15", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm3.g1" }); //$NON-NLS-1$
         checkNodeTypes(plan, new int[] {
@@ -1592,7 +1587,7 @@
         }); 
     }
 
-    public void testNestedSubquery() {
+    @Test public void testNestedSubquery() {
         ProcessorPlan plan = helpPlan("SELECT IntKey, LongNum FROM (SELECT IntKey, LongNum FROM (SELECT IntKey, LongNum, DoubleNum FROM BQT2.SmallA ) AS x ) AS y ORDER BY IntKey", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
             new String[] { "SELECT IntKey, LongNum FROM BQT2.SmallA order by intkey" }); //$NON-NLS-1$
 
@@ -1600,7 +1595,7 @@
     }
 
     /** Tests a user's order by is pushed to the source */
-    public void testPushOrderBy() {
+    @Test public void testPushOrderBy() {
         ProcessorPlan plan = helpPlan("SELECT pm3.g1.e1 FROM pm3.g1 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT pm3.g1.e1 FROM pm3.g1 ORDER BY pm3.g1.e1"}); //$NON-NLS-1$
 
@@ -1608,7 +1603,7 @@
     }
     
     /** Tests an order by is not pushed to source due to join */
-    public void testDontPushOrderByWithJoin() {
+    @Test public void testDontPushOrderByWithJoin() {
         ProcessorPlan plan = helpPlan("SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 INNER JOIN pm2.g2 ON pm3.g1.e1 = pm2.g2.e1 ORDER BY pm3.g1.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 ORDER BY pm3.g1.e1", //$NON-NLS-1$
                            "SELECT pm2.g2.e1 FROM pm2.g2 ORDER BY pm2.g2.e1"}); //$NON-NLS-1$
@@ -1635,7 +1630,7 @@
      * Tests that user's order by gets pushed to the source, but query
      * transformation order by is discarded 
      */
-    public void testPushOrderByThroughFrame() {
+    @Test public void testPushOrderByThroughFrame() {
         ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g14 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 ORDER BY pm3.g1.e2"}); //$NON-NLS-1$
 
@@ -1645,7 +1640,7 @@
     /** 
      * Tests that query transformation order by is discarded by
      */
-    public void testPushOrderByThroughFrame2() {
+    @Test public void testPushOrderByThroughFrame2() {
         ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g1 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 order by e2"}); //$NON-NLS-1$
 
@@ -1657,7 +1652,7 @@
      * user order by, and that user order by is discarded because
      * of the function in the query transformation 
      */
-    public void testPushOrderByThroughFrame3() {
+    @Test public void testPushOrderByThroughFrame3() {
         ProcessorPlan plan = helpPlan("SELECT e, e2 FROM vm1.g16 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm3.g1"}); //$NON-NLS-1$
 
@@ -1683,7 +1678,7 @@
      * Tests that a user's order by does not get pushed to the source
      * if there is a UNION in the query transformation 
      */
-    public void testPushOrderByThroughFrame4_Union() {
+    @Test public void testPushOrderByThroughFrame4_Union() {
         ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g17 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1", //$NON-NLS-1$
                            "SELECT pm3.g2.e1, pm3.g2.e2 FROM pm3.g2"}); //$NON-NLS-1$
@@ -1707,7 +1702,7 @@
     }
 
     /** Tests outer join defect #7945 - see also defect #10050*/
-    public void testOuterJoinDefect7945() {
+    @Test public void testOuterJoinDefect7945() {
         ProcessorPlan plan = helpPlan(
             "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey, BQT3.MediumB.IntKey AS MediumC_IntKey " +  //$NON-NLS-1$
             "FROM (BQT1.SmallA RIGHT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey) " +  //$NON-NLS-1$
@@ -1738,7 +1733,7 @@
     }    
 
     /** Tests outer join defect #7945 */
-    public void testFunctionSimplification1() {
+    @Test public void testFunctionSimplification1() {
         ProcessorPlan plan = helpPlan(
             "SELECT x FROM vm1.g18 WHERE x = 92.0",   //$NON-NLS-1$
             FakeMetadataFactory.example1Cached(),
@@ -1763,7 +1758,7 @@
         });                                    
     }    
             
-    public void testCantPushJoin1() {
+    @Test public void testCantPushJoin1() {
         ProcessorPlan plan = helpPlan(
             "SELECT a.e1, b.e2 FROM pm1.g1 a, pm1.g2 b WHERE a.e1 = b.e1",  //$NON-NLS-1$
             FakeMetadataFactory.example1Cached(),
@@ -1789,7 +1784,7 @@
         });                                    
     }
 
-    public void testCantPushJoin2() {
+    @Test public void testCantPushJoin2() {
         ProcessorPlan plan = helpPlan(
             "SELECT a.e1, b.e2 FROM pm1.g1 a, pm1.g2 b, pm2.g1 c WHERE a.e1 = b.e1 AND b.e1 = c.e1",  //$NON-NLS-1$
             FakeMetadataFactory.example1Cached(),
@@ -1817,7 +1812,7 @@
         });                                    
     }
     
-    public void testPushSelfJoin1() {
+    @Test public void testPushSelfJoin1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
@@ -1838,7 +1833,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }
 
-    public void testPushSelfJoin2() {
+    @Test public void testPushSelfJoin2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
@@ -1874,7 +1869,7 @@
         });                                    
     }
         
-    public void testPushOuterJoin1() {
+    @Test public void testPushOuterJoin1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
@@ -1894,7 +1889,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }
 
-    public void testPushOuterJoin2() {
+    @Test public void testPushOuterJoin2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
@@ -1929,7 +1924,7 @@
     }
 
     // With join expression that can't be pushed
-    public void testPushOuterJoin3() {
+    @Test public void testPushOuterJoin3() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
@@ -1966,7 +1961,7 @@
                                
     }
 
-    public void testPushGroupBy1() {
+    @Test public void testPushGroupBy1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -1983,7 +1978,7 @@
                                
     }
 
-    public void testPushGroupBy2() {
+    @Test public void testPushGroupBy2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -2001,7 +1996,7 @@
                                
     }
 
-    public void testPushGroupBy3() {
+    @Test public void testPushGroupBy3() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
@@ -2033,7 +2028,7 @@
                                
     }
 
-    public void testPushGroupBy4() {
+    @Test public void testPushGroupBy4() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -2066,7 +2061,7 @@
                                
     }
     
-    public void testPushHaving1() {
+    @Test public void testPushHaving1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -2084,7 +2079,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                                  
     }
 
-    public void testPushHaving2() {
+    @Test public void testPushHaving2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
@@ -2115,7 +2110,7 @@
         });                                                                  
     }
 
-    public void testPushHaving3() {
+    @Test public void testPushHaving3() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -2147,7 +2142,7 @@
         });                                                                  
     }
 
-    public void testPushAggregate1() {
+    @Test public void testPushAggregate1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -2164,7 +2159,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                                  
     }
     
-    public void testPushAggregate2() {
+    @Test public void testPushAggregate2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -2181,7 +2176,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                                  
     }
 
-    public void testPushAggregate3() {
+    @Test public void testPushAggregate3() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -2198,7 +2193,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                                  
     }
 
-    public void testPushAggregate4() {
+    @Test public void testPushAggregate4() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
@@ -2220,7 +2215,7 @@
     /**
      * Can't push aggs due to not being able to push COUNT in the HAVING clause.
      */
-    public void testPushAggregate5() {
+    @Test public void testPushAggregate5() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
@@ -2257,7 +2252,7 @@
     /**
      * Can't push aggs due to not being able to push function inside the aggregate
      */
-    public void testPushAggregate6() {
+    @Test public void testPushAggregate6() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -2292,7 +2287,7 @@
     /**
      * Can't push aggs due to not being able to push function inside having
      */
-    public void testPushAggregate7() {
+    @Test public void testPushAggregate7() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -2327,7 +2322,7 @@
     /**
      * BQT query that is failing
      */
-    public void testPushAggregate8() {
+    @Test public void testPushAggregate8() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2357,7 +2352,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                                  
     }
     
-    public void testQueryManyJoin() throws Exception { 
+    @Test public void testQueryManyJoin() throws Exception { 
         FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
         ProcessorPlan plan = helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 JOIN ((pm1.g2 JOIN pm1.g3 ON pm1.g2.e1=pm1.g3.e1) JOIN pm1.g4 ON pm1.g3.e1=pm1.g4.e1) ON pm1.g1.e1=pm1.g4.e1",  //$NON-NLS-1$
             metadata,
@@ -2365,7 +2360,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
     
-    public void testPushSelectDistinct() { 
+    @Test public void testPushSelectDistinct() { 
         FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
         ProcessorPlan plan = helpPlan("SELECT DISTINCT e1 FROM pm3.g1",  //$NON-NLS-1$
             metadata,
@@ -2373,7 +2368,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);         
     }
 
-    public void testPushFunctionInCriteria1() {
+    @Test public void testPushFunctionInCriteria1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -2393,7 +2388,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }
 
-    public void testPushFunctionInSelect1() {
+    @Test public void testPushFunctionInSelect1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2415,7 +2410,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }
 
-    public void testPushFunctionInSelect2() {
+    @Test public void testPushFunctionInSelect2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2437,7 +2432,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }
     
-    public void testPushFunctionInSelect3() {
+    @Test public void testPushFunctionInSelect3() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -2473,7 +2468,7 @@
         });                                    
     }    
 
-    public void testPushFunctionInSelect4() {
+    @Test public void testPushFunctionInSelect4() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2495,7 +2490,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }    
 
-    public void testPushFunctionInSelect5() {
+    @Test public void testPushFunctionInSelect5() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2517,7 +2512,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }    
 
-    public void testPushFunctionInSelect6_defect_10081() {
+    @Test public void testPushFunctionInSelect6_defect_10081() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setFunctionSupport("upper", true); //$NON-NLS-1$
@@ -2552,7 +2547,7 @@
         });                                    
     }
             
-    public void testPushFunctionInSelectWithOrderBy1() {
+    @Test public void testPushFunctionInSelectWithOrderBy1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2576,7 +2571,7 @@
     }
 
     /** defect 13336 */
-    public void testPushFunctionInSelectWithOrderBy1a() {
+    @Test public void testPushFunctionInSelectWithOrderBy1a() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2600,7 +2595,7 @@
     }    
     
     /** defect 13336 */
-    public void testPushFunctionInSelectWithOrderBy2() {
+    @Test public void testPushFunctionInSelectWithOrderBy2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2623,7 +2618,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }
     
-    public void testPushFunctionInJoin1() {
+    @Test public void testPushFunctionInJoin1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -2645,7 +2640,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }    
 
-    public void testPushFunctionInJoin2() {
+    @Test public void testPushFunctionInJoin2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -2683,7 +2678,7 @@
         });                                    
     }    
 
-    public void testPushFunctionInJoin3() {
+    @Test public void testPushFunctionInJoin3() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -2721,7 +2716,7 @@
         });                                    
     }    
 
-    public void testUnionOverFunctions() {
+    @Test public void testUnionOverFunctions() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2760,7 +2755,7 @@
         });                                    
     }    
 
-    public void testDefect9827() { 
+    @Test public void testDefect9827() { 
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
         
         ProcessorPlan plan = helpPlan("SELECT intkey, c FROM (SELECT DISTINCT b.intkey, b.intnum, a.stringkey AS c FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY) AS x ORDER BY x.intkey", metadata, //$NON-NLS-1$
@@ -2789,7 +2784,7 @@
      * but instead is cleaned up properly later
      * See defect 9865
      */
-    public void testCrossJoinNoElementCriteriaOptimization2() {
+    @Test public void testCrossJoinNoElementCriteriaOptimization2() {
         ProcessorPlan plan = helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} = {b'true'}", example1(),  //$NON-NLS-1$
             new String[]{"SELECT g1__1.e1 FROM pm1.g1 AS g1__1", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}); //$NON-NLS-1$ //$NON-NLS-2$
         checkNodeTypes(plan, new int[] {
@@ -2813,7 +2808,7 @@
     /**
      * <p>This tests that a SELECT node with no groups is not pushed down without the capability to have a subquery in the where clause.
      */
-    public void testCrossJoinNoElementCriteriaOptimization3() {
+    @Test public void testCrossJoinNoElementCriteriaOptimization3() {
         ProcessorPlan plan = helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} in (select e3 FROM vm1.g1)", example1(),  //$NON-NLS-1$
             new String[]{"SELECT g1__1.e1 FROM pm1.g1 AS g1__1", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}); //$NON-NLS-1$ //$NON-NLS-2$
         checkNodeTypes(plan, new int[] {
@@ -2837,7 +2832,7 @@
     /**
      * <p>This tests that a SELECT node with no groups is pushed down.
      */
-    public void testCrossJoinNoElementCriteriaOptimization4() {
+    @Test public void testCrossJoinNoElementCriteriaOptimization4() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
@@ -2867,7 +2862,7 @@
     /**
      * Criteria should be copied across this join
      */
-    public void testCopyCriteriaWithOuterJoin_defect10050(){
+    @Test public void testCopyCriteriaWithOuterJoin_defect10050(){
         
         ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1 where pm2.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1 LEFT OUTER JOIN pm2.g2 ON pm2.g1.e1 = pm2.g2.e1 AND pm2.g2.e1 IN ('a', 'b') WHERE pm2.g1.e1 IN ('a', 'b')" }); //$NON-NLS-1$
@@ -2877,7 +2872,7 @@
     /**
      * Criteria should be copied across this join
      */
-    public void testCopyCriteriaWithOuterJoin2_defect10050(){
+    @Test public void testCopyCriteriaWithOuterJoin2_defect10050(){
         
         ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1 and pm2.g1.e2=pm2.g2.e2 where pm2.g1.e1 = 'a' and pm2.g1.e2 = 1", example1(), //$NON-NLS-1$
             new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0 LEFT OUTER JOIN pm2.g2 AS g_1 ON g_0.e1 = g_1.e1 AND g_0.e2 = g_1.e2 AND g_1.e2 = 1 AND g_1.e1 = 'a' WHERE (g_0.e1 = 'a') AND (g_0.e2 = 1)" }); //$NON-NLS-1$
@@ -2887,7 +2882,7 @@
     /**
      * See also case 2912.
      */
-    public void testCopyCriteriaWithOuterJoin5_defect10050(){
+    @Test public void testCopyCriteriaWithOuterJoin5_defect10050(){
         
         ProcessorPlan plan = helpPlan(
             "select pm2.g1.e1, pm2.g2.e1, pm2.g3.e1 from ( (pm2.g1 right outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1) right outer join pm2.g3 on pm2.g2.e1=pm2.g3.e1) where pm2.g3.e1 = 'a'", example1(), //$NON-NLS-1$
@@ -2898,7 +2893,7 @@
     /**
      * 
      */
-    public void testCopyCriteriaWithOuterJoin6_defect10050(){
+    @Test public void testCopyCriteriaWithOuterJoin6_defect10050(){
         
         ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g2.e1=pm2.g1.e1 where pm2.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1 LEFT OUTER JOIN pm2.g2 ON pm2.g2.e1 = pm2.g1.e1 AND pm2.g2.e1 IN ('a', 'b') WHERE pm2.g1.e1 IN ('a', 'b')" }); //$NON-NLS-1$
@@ -2908,28 +2903,28 @@
     /**
      * Same as previous test, only right outer join
      */
-    public void testCopyCriteriaWithOuterJoin7_defect10050(){
+    @Test public void testCopyCriteriaWithOuterJoin7_defect10050(){
         
         ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 right outer join pm2.g2 on pm2.g2.e1=pm2.g1.e1 where pm2.g2.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g2 LEFT OUTER JOIN pm2.g1 ON pm2.g2.e1 = pm2.g1.e1 AND pm2.g1.e1 IN ('a', 'b') WHERE pm2.g2.e1 IN ('a', 'b')" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN);         
     }         
     
-    public void testCleanCriteria(){
+    @Test public void testCleanCriteria(){
         
         ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1, pm2.g2 where pm2.g1.e1=pm2.g2.e1 and pm2.g1.e2 IN (1, 2)", example1(), //$NON-NLS-1$
             new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1, pm2.g2 WHERE (pm2.g1.e1 = pm2.g2.e1) AND (pm2.g1.e2 IN (1, 2))" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN);         
     }
 
-    public void testCleanCriteria2(){
+    @Test public void testCleanCriteria2(){
         
         ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1, pm2.g2 where pm2.g1.e1=pm2.g2.e1 and pm2.g1.e1 = 'a'", example1(), //$NON-NLS-1$
             new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0, pm2.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'a') AND (g_1.e1 = 'a')" }); //$NON-NLS-1$
         checkNodeTypes(plan, FULL_PUSHDOWN);         
     }
 
-    public void testCleanCriteria3(){
+    @Test public void testCleanCriteria3(){
         
         ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 inner join pm2.g2 on pm2.g1.e1=pm2.g2.e1 where pm2.g1.e1 = 'a'", example1(), //$NON-NLS-1$
             new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0, pm2.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'a') AND (g_1.e1 = 'a')" }); //$NON-NLS-1$
@@ -2937,7 +2932,7 @@
     }
     
     
-    public void testPushSubqueryInWhereClause1() {
+    @Test public void testPushSubqueryInWhereClause1() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
@@ -2949,7 +2944,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
 
-    public void testPushSubqueryInWhereClause2() {
+    @Test public void testPushSubqueryInWhereClause2() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
@@ -2966,7 +2961,7 @@
     /**
      * Check that subquery is pushed if the subquery selects a function that is pushed
      */
-    public void testPushSubqueryInWhereClause3() {
+    @Test public void testPushSubqueryInWhereClause3() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -2985,7 +2980,7 @@
     /**
      * Check that subquery is pushed if the subquery selects an aliased function that is pushed
      */
-    public void testPushSubqueryInWhereClause4() {
+    @Test public void testPushSubqueryInWhereClause4() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -3003,7 +2998,7 @@
     }   
 
     /** Case 1456, defect 10492*/
-    public void testAliasingDefect1(){
+    @Test public void testAliasingDefect1(){
         // Create query
         String sql = "SELECT e1 FROM vm1.g1 X WHERE e2 = (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1)";//$NON-NLS-1$
 
@@ -3026,7 +3021,7 @@
     }   
 
     /** Case 1456, defect 10492*/
-    public void testAliasingDefect2(){
+    @Test public void testAliasingDefect2(){
         // Create query
         String sql = "SELECT X.e1 FROM vm1.g1 X, vm1.g1 Z WHERE X.e2 = (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1 AND Y.e2 = Z.e2) AND X.e1 = Z.e1";//$NON-NLS-1$
 
@@ -3051,7 +3046,7 @@
     }   
 
     /** Case 1456, defect 10492*/
-    public void testAliasingDefect3(){
+    @Test public void testAliasingDefect3(){
         // Create query
         String sql = "SELECT X.e1 FROM pm1.g2, vm1.g1 X WHERE X.e2 = ANY (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1) AND X.e1 = pm1.g2.e1";//$NON-NLS-1$
 
@@ -3077,7 +3072,7 @@
     }
         
     /** Should use merge join since neither access node is "strong" - order by's pushed to source */
-    public void testUseMergeJoin3(){
+    @Test public void testUseMergeJoin3(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
 
@@ -3114,7 +3109,7 @@
     }    
 
     /** Model supports order by, should be pushed to the source */
-    public void testUseMergeJoin4(){
+    @Test public void testUseMergeJoin4(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
 
@@ -3153,7 +3148,7 @@
     } 
 
     /** Should use merge join, since costs are not known, neither access node is "strong" */
-    public void testUseMergeJoin5_CostsNotKnown(){
+    @Test public void testUseMergeJoin5_CostsNotKnown(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
 
@@ -3187,7 +3182,7 @@
     }
     
     /** one side of join supports order by, the other doesn't*/
-    public void testUseMergeJoin7(){
+    @Test public void testUseMergeJoin7(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE pm1.g1.e1 = pm2.g2.e1";//$NON-NLS-1$
 
@@ -3228,7 +3223,7 @@
     }     
 
     /** reverse of testUseMergeJoin7 */
-    public void testUseMergeJoin7a(){
+    @Test public void testUseMergeJoin7a(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE pm1.g1.e1 = pm2.g2.e1";//$NON-NLS-1$
 
@@ -3269,7 +3264,7 @@
     }   
 
     /** function on one side of join should prevent order by from being pushed down*/
-    public void testUseMergeJoin8(){
+    @Test public void testUseMergeJoin8(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE concat(pm1.g1.e1, 'x') = pm2.g2.e1";//$NON-NLS-1$
 
@@ -3311,7 +3306,7 @@
     }
 
     /** Model supports order by, functions in join criteria */
-    public void testUseMergeJoin9(){
+    @Test public void testUseMergeJoin9(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE concat(pm1.g1.e1, 'x') = concat(pm1.g2.e1, 'x')";//$NON-NLS-1$
 
@@ -3352,7 +3347,7 @@
     } 
 
     /** should be one dependent join */
-    public void testMultiMergeJoin1(){
+    @Test public void testMultiMergeJoin1(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1";//$NON-NLS-1$
 
@@ -3393,7 +3388,7 @@
         });         
     } 
 
-    public void testLargeSetCriteria() {
+    @Test public void testLargeSetCriteria() {
         //      Create query
         String sql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA INNER JOIN BQT2.SmallB ON BQT1.SmallA.IntKey = BQT2.SmallB.IntKey WHERE BQT1.SmallA.IntKey IN (1,2,3,4,5)";     //$NON-NLS-1$
 
@@ -3427,7 +3422,7 @@
         });            
     }
     
-    public void testMergeJoin_defect11236(){
+    @Test public void testMergeJoin_defect11236(){
         // Create query
         String sql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE BQT1.SmallA.IntKey = (BQT1.SmallB.IntKey + 1)";     //$NON-NLS-1$
 
@@ -3464,7 +3459,7 @@
         });         
     }
         
-    public void testNoFrom() { 
+    @Test public void testNoFrom() { 
         ProcessorPlan plan = helpPlan("SELECT 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] {} ); 
 
@@ -3486,7 +3481,7 @@
         });                                    
     }
 
-    public void testINCriteria_defect10718(){
+    @Test public void testINCriteria_defect10718(){
         // Create query
         String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
 
@@ -3528,7 +3523,7 @@
         });         
     }
     
-    public void testDefect10711(){
+    @Test public void testDefect10711(){
         ProcessorPlan plan = helpPlan("SELECT * from vm1.g1a as X", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] {"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
 
@@ -3537,7 +3532,7 @@
     }
     
     // SELECT 5, SUM(IntKey) FROM BQT1.SmallA
-    public void testAggregateNoGroupByWithExpression() {
+    @Test public void testAggregateNoGroupByWithExpression() {
         ProcessorPlan plan = helpPlan("SELECT 5, SUM(IntKey) FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
             new String[] { "SELECT IntKey FROM BQT1.SmallA"  }); //$NON-NLS-1$
 
@@ -3560,7 +3555,7 @@
     }
     
     /** defect 11630 - note that the lookup function is not pushed down, it will actually be evaluated before being sent to the connector */
-    public void testLookupFunction() {
+    @Test public void testLookupFunction() {
 
         ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1', 'e1', 'e2', 1) IS NULL"  }); //$NON-NLS-1$
@@ -3570,7 +3565,7 @@
     }
     
     /** case 5213 - note here that the lookup cannot be pushed down since it is dependent upon an element symbol*/
-    public void testLookupFunction2() throws Exception {
+    @Test public void testLookupFunction2() throws Exception {
 
         ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', e2) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT g_0.e2, g_0.e1 FROM pm1.g2 AS g_0"  }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
@@ -3595,7 +3590,7 @@
     }
     
     /** defect 21965 */
-    public void testLookupFunctionInSelect() {
+    @Test public void testLookupFunctionInSelect() {
         ProcessorPlan plan = helpPlan("SELECT e1, LOOKUP('pm1.g1','e1', 'e2', 1) FROM pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT e1, LOOKUP('pm1.g1','e1', 'e2', 1) FROM pm1.g2"  }); //$NON-NLS-1$
 
@@ -3603,7 +3598,7 @@
     }
     
     // SELECT * FROM (SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT DISTINCT IntNum FROM BQT1.SmallA) AS x WHERE IntKey = 0
-    public void testCase1649() {
+    @Test public void testCase1649() {
         ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA) AS x WHERE IntKey = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
             new String[] { "SELECT DISTINCT IntKey FROM BQT1.SmallA WHERE IntKey = 0", "SELECT IntNum FROM BQT1.SmallA WHERE IntNum = 0"  }); //$NON-NLS-1$ //$NON-NLS-2$
 
@@ -3625,7 +3620,7 @@
         });                                    
     }   
 
-    public void testDefect12298() throws Exception {      
+    @Test public void testDefect12298() throws Exception {      
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -3666,7 +3661,7 @@
     }
     
     // SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0
-    public void testCase1727_1() {
+    @Test public void testCase1727_1() {
         ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
             new String[] { 
                 "SELECT IntKey, IntNum FROM BQT1.SmallA WHERE IntNum = 0", //$NON-NLS-1$
@@ -3691,7 +3686,7 @@
     }
 
     // SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0
-    public void testCase1727_2() {
+    @Test public void testCase1727_2() {
         ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntKey b FROM BQT1.SmallA UNION ALL SELECT IntKey, IntNum FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
             new String[] { 
                 "SELECT IntKey, IntNum FROM BQT1.SmallA WHERE IntNum = 0", //$NON-NLS-1$
@@ -3715,7 +3710,7 @@
         });                                    
     }
     
-    public void testCountStarOverSelectDistinct() {
+    @Test public void testCountStarOverSelectDistinct() {
         ProcessorPlan plan = helpPlan("SELECT COUNT(*) FROM (SELECT DISTINCT IntNum, Intkey FROM bqt1.smalla) AS x", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
                                       new String[] { 
                                           "SELECT DISTINCT IntNum, Intkey FROM bqt1.smalla" }); //$NON-NLS-1$ 
@@ -3739,14 +3734,14 @@
     }
 
     //virtual group with two elements. One selectable, one not
-    public void testVirtualGroup1() {
+    @Test public void testVirtualGroup1() {
         ProcessorPlan plan = helpPlan("select e2 from vm1.g35", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
             new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
 
         checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);     
     }
     
-    public void testBQT9500_126() {
+    @Test public void testBQT9500_126() {
         String sql = "SELECT IntKey, LongNum, expr FROM (SELECT IntKey, LongNum, concat(LongNum, 'abc') FROM BQT2.SmallA ) AS x ORDER BY IntKey"; //$NON-NLS-1$
         ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), 
                                       new String[] { 
@@ -3837,39 +3832,39 @@
     /**
      * Query has union but no order by and no capabilities.
      */
-    public void testUnionPushdown1() {
+    @Test public void testUnionPushdown1() {
         helpTestUnionPushdown(false, false, false);
     }
 
     /**
      * Query has union but no order by and only union capability.
      */
-    public void testUnionPushdown2() {
+    @Test public void testUnionPushdown2() {
         helpTestUnionPushdown(false, true, false);
     }
 
     /**
      * Query has union with order by and no capabilities.
      */
-    public void testUnionPushdown3() {
+    @Test public void testUnionPushdown3() {
         helpTestUnionPushdown(true, false, false);
     }
 
     /**
      * Query has union with order by and just union capability.
      */
-    public void testUnionPushdown4() {
+    @Test public void testUnionPushdown4() {
         helpTestUnionPushdown(true, true, false);
     }
 
     /**
      * Query has union with order by and both capabilities.
      */
-    public void testUnionPushdown5() {
+    @Test public void testUnionPushdown5() {
         helpTestUnionPushdown(true, true, true);
     }
 
-    public void testUnionPushdownWithSelectNoFrom() {        
+    @Test public void testUnionPushdownWithSelectNoFrom() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -3899,7 +3894,7 @@
         });                                                   
     }
 
-    public void testUnionPushdownWithSelectNoFromFirstBranch() {        
+    @Test public void testUnionPushdownWithSelectNoFromFirstBranch() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -3929,7 +3924,7 @@
         });                                                   
     }
 
-    public void testUnionPushdownWithSelectNoFromSecondBranch() {        
+    @Test public void testUnionPushdownWithSelectNoFromSecondBranch() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -3959,7 +3954,7 @@
         });                                                   
     }
     
-    public void testUnionPushdownMultipleBranches() {        
+    @Test public void testUnionPushdownMultipleBranches() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -3976,7 +3971,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     }
     
-    public void testUnionPushdownMultipleBranchesMixedModels1() {        
+    @Test public void testUnionPushdownMultipleBranchesMixedModels1() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4009,7 +4004,7 @@
         });                                                   
     }
     
-    public void testUnionPushdownMultipleBranchesNoDupRemoval() {        
+    @Test public void testUnionPushdownMultipleBranchesNoDupRemoval() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4026,7 +4021,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     }
     
-    public void testAggregateOverUnionPushdown() {        
+    @Test public void testAggregateOverUnionPushdown() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4058,7 +4053,7 @@
         });                                                   
     }
 
-    public void testUnionPushdownWithFunctionsAndAliases() {        
+    @Test public void testUnionPushdownWithFunctionsAndAliases() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -4077,7 +4072,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     }
     
-    public void testUnionPushdownWithInternalOrderBy() {        
+    @Test public void testUnionPushdownWithInternalOrderBy() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4096,7 +4091,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     }    
 
-    public void testUnionPushdownWithInternalDistinct() {        
+    @Test public void testUnionPushdownWithInternalDistinct() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4117,7 +4112,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     } 
     
-    public void testUnionNoAllPushdownInInlineView() {        
+    @Test public void testUnionNoAllPushdownInInlineView() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -4151,7 +4146,7 @@
         });                                                   
     }
 
-    public void testUnionAllPushdownInInlineView() {        
+    @Test public void testUnionAllPushdownInInlineView() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4169,7 +4164,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     }
 
-    public void testUnionAllPushdownVirtualGroup() {        
+    @Test public void testUnionAllPushdownVirtualGroup() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -4188,7 +4183,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     }
 
-    public void testUnionAllPushdownVirtualGroup2() {        
+    @Test public void testUnionAllPushdownVirtualGroup2() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4205,7 +4200,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     }
 
-    public void testUnionAllPushdownVirtualGroup3() {        
+    @Test public void testUnionAllPushdownVirtualGroup3() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4239,7 +4234,7 @@
     }
 
     // Allow pushing literals
-    public void testUnionAllPushdownVirtualGroup4() {        
+    @Test public void testUnionAllPushdownVirtualGroup4() {        
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
@@ -4258,7 +4253,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                                   
     }
 
-    public void testPushCaseInSelect() {
+    @Test public void testPushCaseInSelect() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -4280,7 +4275,7 @@
         checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);                                    
     }
     
-    public void testCantPushCaseInSelectWithFunction() {
+    @Test public void testCantPushCaseInSelectWithFunction() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -4315,7 +4310,7 @@
         });                                    
     }
 
-    public void testPushSearchedCaseInSelect() {
+    @Test public void testPushSearchedCaseInSelect() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -4336,7 +4331,7 @@
         checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);                                    
     }
 
-    public void testCantPushSearchedCaseInSelectWithFunction() {
+    @Test public void testCantPushSearchedCaseInSelectWithFunction() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -4371,7 +4366,7 @@
         });                                    
     }
 
-    public void testPushdownFunctionNotEvaluated() {
+    @Test public void testPushdownFunctionNotEvaluated() {
         FakeFunctionMetadataSource.setupFunctionLibrary();
         
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -4394,7 +4389,7 @@
         checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);                                    
     }
 
-    public void testNoSourceQuery() {
+    @Test public void testNoSourceQuery() {
         ProcessorPlan plan = helpPlan("SELECT * FROM (select parsetimestamp(x,'yyyy-MM-dd') as c1 from (select '2004-10-20' as x) as y) as z " +//$NON-NLS-1$ 
                                       "WHERE c1= '2004-10-20 00:00:00.0'", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
             new String[] {  }); 
@@ -4418,7 +4413,7 @@
     }
     
     /** defect 14510 */
-    public void testDefect14510LookupFunction() {
+    @Test public void testDefect14510LookupFunction() {
 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4461,7 +4456,7 @@
     }    
 
     /** defect 14510 */
-    public void testDefect14510LookupFunction2() {
+    @Test public void testDefect14510LookupFunction2() {
 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4505,7 +4500,7 @@
     }
 
     /** defect 14510 */
-    public void testDefect14510LookupFunction3() {
+    @Test public void testDefect14510LookupFunction3() {
 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
@@ -4548,7 +4543,7 @@
         });
     }    
     
-    public void testCase2125() throws Exception {
+    @Test public void testCase2125() throws Exception {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -4596,7 +4591,7 @@
                                     });
     }
     
-    public void testPushdownLiteralInSelectUnderAggregate() {  
+    @Test public void testPushdownLiteralInSelectUnderAggregate() {  
         String sql = "SELECT COUNT(*) FROM (SELECT '' AS y, a.IntKey FROM BQT1.SmallA a union all select '', b.intkey from bqt1.smallb b) AS x"; //$NON-NLS-1$
 
         // Plan query
@@ -4635,7 +4630,7 @@
                                     });
     }
 
-    public void testPushdownLiteralInSelectUnderAggregate2() {  
+    @Test public void testPushdownLiteralInSelectUnderAggregate2() {  
         String sql = "SELECT SUM(z) FROM (SELECT '' AS y, a.IntKey as z FROM BQT1.SmallA a union all select b.stringkey, 0 from bqt1.smallb b) AS x group by z"; //$NON-NLS-1$
 
         // Plan query
@@ -4674,7 +4669,7 @@
                                     });
     }
 
-    public void testPushdownLiteralInSelectUnderAggregate3() {  
+    @Test public void testPushdownLiteralInSelectUnderAggregate3() {  
         String sql = "SELECT code, SUM(ID) FROM (SELECT IntKey AS ID, '' AS Code FROM BQT1.SmallA union all select intkey, stringkey from bqt1.smallb b) AS x group by code"; //$NON-NLS-1$
 
         // Plan query
@@ -4713,7 +4708,7 @@
                                     });
     }
 
-    public void testPushdownLiteralInSelectWithOrderBy() {  
+    @Test public void testPushdownLiteralInSelectWithOrderBy() {  
         String sql = "SELECT 1, concat('a', 'b' ) AS X FROM BQT1.SmallA where intkey = 0 " +  //$NON-NLS-1$
             "UNION ALL " +  //$NON-NLS-1$
             "select 2, 'Hello2' from BQT1.SmallA where intkey = 1 order by X desc"; //$NON-NLS-1$
@@ -4736,7 +4731,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);
     }
     
-    public void testUpdateWithElement() {
+    @Test public void testUpdateWithElement() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -4754,7 +4749,7 @@
         checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
     }            
     
-    public void testCase2187() {
+    @Test public void testCase2187() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -4781,7 +4776,7 @@
         checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
     }        
     
-    public void testMultiUnionMergeVirtual() throws Exception {
+    @Test public void testMultiUnionMergeVirtual() throws Exception {
         String sql = "SELECT * FROM " +  //$NON-NLS-1$
             "(SELECT IntKey, 'a' AS s FROM (SELECT intkey, stringkey from BQT1.SmallA) as a union all " +  //$NON-NLS-1$
             "select IntKey, 'b' FROM (SELECT intkey, stringkey from BQT1.SmallA) as b union all " +  //$NON-NLS-1$
@@ -4806,7 +4801,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);        
     }
     
-    public void testDefect16848_groupAliasNotSupported_1() {
+    @Test public void testDefect16848_groupAliasNotSupported_1() {
         String sql = "SELECT sa.intkey, sa.objectvalue FROM bqt1.smalla AS sa WHERE (sa.intkey = 46) AND (sa.stringkey IN (46)) AND (sa.datevalue = (SELECT MAX(sb.datevalue) FROM bqt1.smalla AS sb WHERE (sb.intkey = sa.intkey) AND (sa.stringkey = sb.stringkey) ))"; //$NON-NLS-1$
 
         // Plan query
@@ -4870,7 +4865,7 @@
 
     }
 
-    public void testFunctionOfAggregate1() {
+    @Test public void testFunctionOfAggregate1() {
         String sql = "SELECT SUM(IntKey) + 1 AS x FROM BQT1.SmallA GROUP BY IntKey"; //$NON-NLS-1$
 
         // Plan query
@@ -4891,7 +4886,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);        
     }
 
-    public void testFunctionOfAggregateCantPush1() {
+    @Test public void testFunctionOfAggregateCantPush1() {
         String sql = "SELECT SUM(IntKey) + 1 AS x FROM BQT1.SmallA GROUP BY IntKey"; //$NON-NLS-1$
 
         // Plan query
@@ -4923,7 +4918,7 @@
                                     });        
     }
 
-    public void testFunctionOfAggregateCantPush3() {
+    @Test public void testFunctionOfAggregateCantPush3() {
         String sql = "SELECT avg(intkey) * 2 FROM BQT1.SmallA "; //$NON-NLS-1$
 
         // Plan query
@@ -5023,7 +5018,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);          
     }
     
-    public void testCase2589() throws Exception {  
+    @Test public void testCase2589() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
         
@@ -5032,7 +5027,7 @@
         helpTestCase2589(sql, expected);
     }     
 
-    public void testCase2589a() throws Exception {  
+    @Test public void testCase2589a() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589a ON MediumA.IntKey = SmallA_2589a.IntKey"; //$NON-NLS-1$
         
@@ -5040,7 +5035,7 @@
         helpTestCase2589(sql, expected);
     }    
 
-    public void testCase2589b() throws Exception {  
+    @Test public void testCase2589b() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
         
@@ -5048,7 +5043,7 @@
         helpTestCase2589(sql, expected);
     }     
     
-    public void testCase2589c() throws Exception {  
+    @Test public void testCase2589c() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB, BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey " + //$NON-NLS-1$
                      "WHERE BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
@@ -5057,7 +5052,7 @@
         helpTestCase2589(sql, expected);
     }    
 
-    public void testCase2589d() throws Exception {  
+    @Test public void testCase2589d() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB INNER JOIN " + //$NON-NLS-1$
                      "(BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " + //$NON-NLS-1$
                      "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
@@ -5066,7 +5061,7 @@
         helpTestCase2589(sql, expected);
     }     
     
-    public void testCase2589e() throws Exception {  
+    @Test public void testCase2589e() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " +  //$NON-NLS-1$
                      "(BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " +  //$NON-NLS-1$
                      "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
@@ -5075,7 +5070,7 @@
         helpTestCase2589(sql, expected);
     }     
     
-    public void testCase2589f() throws Exception {  
+    @Test public void testCase2589f() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
                      "(BQT1.MediumA INNER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " + //$NON-NLS-1$
                      "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
@@ -5084,7 +5079,7 @@
         helpTestCase2589(sql, expected);
     }    
 
-    public void testCase2589g() throws Exception {  
+    @Test public void testCase2589g() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$ 
                      "(BQT1.MediumA INNER JOIN VQT.SmallA_2589c ON MediumA.IntKey = SmallA_2589c.IntKey) " + //$NON-NLS-1$ 
                      "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
@@ -5097,7 +5092,7 @@
         helpTestCase2589(sql, expected);
     }    
     
-    public void testCase2589h() throws Exception {  
+    @Test public void testCase2589h() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589c " + //$NON-NLS-1$ 
                      "ON MediumA.IntKey = SmallA_2589c.IntKey"; //$NON-NLS-1$
         
@@ -5105,7 +5100,7 @@
         helpTestCase2589(sql, expected);
     }
     
-    public void testCase2589i() throws Exception {  
+    @Test public void testCase2589i() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589d " + //$NON-NLS-1$ 
                      "ON MediumA.IntKey = SmallA_2589d.IntKey"; //$NON-NLS-1$
         
@@ -5116,7 +5111,7 @@
     /**
      * Test optimization doesn't happen if an outer join isn't involved 
      */
-    public void testCase2589j() throws Exception {  
+    @Test public void testCase2589j() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA INNER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
         
@@ -5128,7 +5123,7 @@
     /**
      * Test optimization doesn't happen if an outer join isn't involved 
      */
-    public void testCase2589k() throws Exception {  
+    @Test public void testCase2589k() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA INNER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
 
@@ -5141,7 +5136,7 @@
     /**
      * Same as testCase2589 except right outer join
      */
-    public void testCase2589l() throws Exception {  
+    @Test public void testCase2589l() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM VQT.SmallA_2589 RIGHT OUTER JOIN " + //$NON-NLS-1$
                      "BQT1.MediumA ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
         
@@ -5154,7 +5149,7 @@
      * Same as testCase2589 except full outer join - criteria "below" full outer join cannot be
      * raised into the join criteria, so basically the virtual groups cannot be merged in this test.
      */
-    public void testCase2589m() {  
+    @Test public void testCase2589m() {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM VQT.SmallA_2589 FULL OUTER JOIN " + //$NON-NLS-1$
                      "BQT1.MediumA ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
         
@@ -5169,7 +5164,7 @@
     /**
      * Same as testCase2589b except full outer join
      */
-    public void testCase2589n() {  
+    @Test public void testCase2589n() {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA FULL OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
         
@@ -5184,7 +5179,7 @@
     /**
      * Same as testCase2589 except with two virtual layers instead of one 
      */
-    public void testCase2589o() throws Exception {  
+    @Test public void testCase2589o() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589f ON MediumA.IntKey = SmallA_2589f.IntKey"; //$NON-NLS-1$
         
@@ -5196,7 +5191,7 @@
     /**
      * Same as testCase2589b except with two virtual layers instead of one 
      */
-    public void testCase2589p() throws Exception {  
+    @Test public void testCase2589p() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589g ON MediumA.IntKey = SmallA_2589g.IntKey"; //$NON-NLS-1$
         
@@ -5208,7 +5203,7 @@
      * Test 3 frames, where top frame has outer join, middle frame has inner join, and
      * bottom frame has criteria that must be made into join criteria.  
      */
-    public void testCase2589q() throws Exception {  
+    @Test public void testCase2589q() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589h ON MediumA.IntKey = SmallA_2589h.IntKey"; //$NON-NLS-1$
         
@@ -5220,7 +5215,7 @@
      * Similar to testCase2589b, except virtual transformation has criteria on an 
      * element from each physical table
      */
-    public void testCase2589r() throws Exception {  
+    @Test public void testCase2589r() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589i ON MediumA.IntKey = SmallA_2589i.IntKey"; //$NON-NLS-1$
         
@@ -5231,7 +5226,7 @@
     /**
      * Test user criteria that should NOT be moved into join clause 
      */
-    public void testCase2589s() throws Exception {  
+    @Test public void testCase2589s() throws Exception {  
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey " + //$NON-NLS-1$
                      "WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
@@ -5243,7 +5238,7 @@
     /**
      * Test user criteria that should NOT be moved into join clause 
      */
-    public void testCase2589t() throws Exception {  
+    @Test public void testCase2589t() throws Exception {  
         String sql = "SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE BQT1.MediumA.IntNum = 10) as z " + //$NON-NLS-1$
                      "LEFT OUTER JOIN " + //$NON-NLS-1$
                      "VQT.SmallA_2589 ON z.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
@@ -5258,7 +5253,7 @@
      * that the same results are produced?  More specifically, where should the criteria
      * go - WHERE clause or FROM clause? 
      */
-    public void testCase2589u() throws Exception {  
+    @Test public void testCase2589u() throws Exception {  
         String sql = "SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE IntNum = 10) as z " + //$NON-NLS-1$
                      "LEFT OUTER JOIN " + //$NON-NLS-1$
                      "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
@@ -5272,7 +5267,7 @@
      * Same sql as testCase2589, but the model doesn't support outer joins, so 
      * case 2589 optimization shouldn't happen. 
      */
-    public void testCase2589v() {  
+    @Test public void testCase2589v() {  
 
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
         "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
@@ -5324,7 +5319,7 @@
     /**
      * Same as previous testCase2589v, but with full outer join. 
      */
-    public void testCase2589w() {  
+    @Test public void testCase2589w() {  
 
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA FULL OUTER JOIN " + //$NON-NLS-1$
         "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
@@ -5379,7 +5374,7 @@
      * to be put in the join criteria, not the where clause, of the second atomic
      * query, because in the user query it is on the inner side of an outer join.
      */
-    public void testCase2589x() throws Exception {  
+    @Test public void testCase2589x() throws Exception {  
 
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT2.SmallA INNER JOIN " + //$NON-NLS-1$
         "(BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
@@ -5469,7 +5464,7 @@
      *  MedB   MedA           
      * </pre>
      */
-    public void testCase2589y() throws Exception {  
+    @Test public void testCase2589y() throws Exception {  
         String sql = "SELECT L.IntKey, y.IntKey, z.IntKey " + //$NON-NLS-1$
                      "FROM (BQT1.MediumB as L LEFT OUTER JOIN " + //$NON-NLS-1$
                      "(SELECT IntKey FROM BQT1.MediumA as M WHERE M.IntNum = 4) as y ON y.IntKey = L.IntKey) " + //$NON-NLS-1$
@@ -5491,7 +5486,7 @@
      * to be put in the join criteria, not the where clause, of the second atomic
      * query, because in the user query it is on the inner side of an outer join.
      */
-    public void testCase2589z() {  
+    @Test public void testCase2589z() {  
 
         String sql = "SELECT BQT1.MediumA.IntKey FROM BQT2.SmallA INNER JOIN " + //$NON-NLS-1$
         "(BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
@@ -5548,7 +5543,7 @@
     /**
      * Union with multiple joins underneath 
      */
-    public void testCase2589aa() throws Exception {  
+    @Test public void testCase2589aa() throws Exception {  
         String sql = "SELECT * FROM (SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE IntNum = 10) as z " + //$NON-NLS-1$
                      "LEFT OUTER JOIN " + //$NON-NLS-1$
                      "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
@@ -5565,7 +5560,7 @@
     /**
      * Since can now guarantee unique select column names, it's ok to have repeated entries in the order by clause.
      */
-    public void testOrderByDuplicates() throws Exception {
+    @Test public void testOrderByDuplicates() throws Exception {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -5593,7 +5588,7 @@
     }
 
     //Test use of OrderBy with expression
-    public void testCase2507() {
+    @Test public void testCase2507() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -5623,7 +5618,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);
     }
     
-    public void testCase2507A() {
+    @Test public void testCase2507A() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -5652,7 +5647,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);
     }  
     
-    public void testCase2507B() {
+    @Test public void testCase2507B() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -5685,7 +5680,7 @@
      * RulePlanJoins does not initially allow the cross join push.
      * The subsequent RuleRaiseAccess does since we believe it was the intent of the user
      */
-    public void testPushCrossJoins() throws Exception {
+    @Test public void testPushCrossJoins() throws Exception {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -5712,7 +5707,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);        
     }
     
-    public void testCase3023() {
+    @Test public void testCase3023() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -5739,7 +5734,7 @@
                                       SHOULD_SUCCEED );
     }
     
-    public void testCase3367() {
+    @Test public void testCase3367() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         FakeMetadataFacade metadata = example1();
 
@@ -5763,7 +5758,7 @@
      * of a virtual table containing a join in it's transformation.  All virtual 
      * models use the same physical model pm1.
      */
-    public void testCase3778() throws Exception {
+    @Test public void testCase3778() throws Exception {
     	
     	FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
         
@@ -5785,7 +5780,7 @@
     /** 
      * Ensures that order by expressions are not repeated when multiple criteria span a merge join 
      */ 
-    public void testCase3832() throws Exception { 
+    @Test public void testCase3832() throws Exception { 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); 
         BasicSourceCapabilities caps = new BasicSourceCapabilities(); 
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true); 
@@ -5815,7 +5810,7 @@
     /*
      * Functions containing exec statements should not be evaluated
      */
-    public void testDefect21972() { 
+    @Test public void testDefect21972() { 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); 
         BasicSourceCapabilities caps = new BasicSourceCapabilities(); 
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -5835,7 +5830,7 @@
              
     }
     
-    public void testExpressionSymbolPreservation() throws Exception { 
+    @Test public void testExpressionSymbolPreservation() throws Exception { 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); 
         BasicSourceCapabilities caps = new BasicSourceCapabilities(); 
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true); 
@@ -5882,7 +5877,7 @@
     /**
      * Order by's will be added to the atomic queries
      */
-    public void testCrossSourceInlineView() throws Exception {
+    @Test public void testCrossSourceInlineView() throws Exception {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
         
@@ -5910,7 +5905,7 @@
         checkSubPlanCount(plan, 0);
     }
     
-    public void testAliasPreservationWithInlineView() {
+    @Test public void testAliasPreservationWithInlineView() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
         
@@ -5923,7 +5918,7 @@
     }
     
     //since this does not support convert, it should not be collapsed
-    public void testBadCollapseUnion() {
+    @Test public void testBadCollapseUnion() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_UNION, true);
@@ -5954,7 +5949,7 @@
         
     }
     
-    public void testCase3966() {
+    @Test public void testCase3966() {
         ProcessorPlan plan = helpPlan("insert into vm1.g37 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )", FakeMetadataFactory.example1(), //$NON-NLS-1$
                                       new String[] {} ); 
 
@@ -5981,7 +5976,7 @@
     /*
      * Select literals created by runtime evaluation should not be pushed down.
      */
-    public void testCase4017() throws Exception {
+    @Test public void testCase4017() throws Exception {
         
         String sql = "SELECT env('soap_host') AS HOST, intkey from bqt2.smalla"; //$NON-NLS-1$
         
@@ -5993,7 +5988,7 @@
      * Test of RuleCopyCriteria.  Criteria should NOT be copied across a join if the join has any other operator
      * other than an equality operator, but if the single group criteria is equality, then we can copy into a join criteria   
      */
-    public void testCase4265() throws Exception {
+    @Test public void testCase4265() throws Exception {
         String sql = "SELECT X.intkey, Y.intkey FROM BQT1.SmallA X, BQT1.SmallA Y WHERE X.IntKey <> Y.IntKey and Y.IntKey = 1"; //$NON-NLS-1$
 
         ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), 
@@ -6024,7 +6019,7 @@
      * Test of RuleCopyCriteria.  Criteria should be copied across a join only for an equality operator in
      * the join criteria.
      */
-    public void testCase4265ControlTest() throws Exception {
+    @Test public void testCase4265ControlTest() throws Exception {
         String sql = "SELECT X.intkey, Y.intkey FROM BQT1.SmallA X, BQT1.SmallA Y WHERE X.IntKey = Y.IntKey and Y.IntKey = 1"; //$NON-NLS-1$
 
         ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), 
@@ -6053,7 +6048,7 @@
     /**
      * The bug was in FrameUtil.convertCriteria() method, where ExistsCriteria was not being checked for. 
      */
-    public void testExistsCriteriaInSelect() {
+    @Test public void testExistsCriteriaInSelect() {
         String sql = "select intkey, case when exists (select stringkey from bqt1.smallb) then 'nuge' end as a from vqt.smalla"; //$NON-NLS-1$
 
         ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), 
@@ -6082,7 +6077,7 @@
     /**
      * Try substituting "is not null" for "exists" criteria 
      */
-    public void testScalarSubQueryInSelect() {
+    @Test public void testScalarSubQueryInSelect() {
         String sql = "select intkey, case when (select stringkey from bqt1.smallb) is not null then 'nuge' end as a from vqt.smalla"; //$NON-NLS-1$
 
         ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), 
@@ -6108,7 +6103,7 @@
         
     }
     
-    public void testCase4263() {
+    @Test public void testCase4263() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         FakeMetadataFacade metadata = example1();
         
@@ -6129,7 +6124,7 @@
         checkSubPlanCount(plan, 0);        
     }
     
-    public void testCase4263b() {
+    @Test public void testCase4263b() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         FakeMetadataFacade metadata = example1();
         
@@ -6165,7 +6160,7 @@
         checkSubPlanCount(plan, 1);        
     }
     
-    public void testCase4279() throws Exception {
+    @Test public void testCase4279() throws Exception {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         FakeMetadataFacade metadata = example1();
         
@@ -6187,7 +6182,7 @@
         checkSubPlanCount(plan, 0);        
     }
     
-    public void testCase4312() {
+    @Test public void testCase4312() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
@@ -6200,7 +6195,7 @@
 
     }    
     
-    public void testCase2507_2(){
+    @Test public void testCase2507_2(){
 
         String sql = "SELECT a FROM (SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) as a " +  //$NON-NLS-1$
                      "FROM BQT1.SmallA, BQT1.SmallB WHERE SmallA.IntKey = SmallB.IntKey) as X ORDER BY X.a"; //$NON-NLS-1$
@@ -6263,7 +6258,7 @@
     }
     
     //Test use of OrderBy with Alias
-    public void testCase2430D() {
+    @Test public void testCase2430D() {
         String sql = "SELECT bqt1.smalla.longnum + bqt1.smalla.longnum as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
                      "bqt1.smalla.doublenum as EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR "; //$NON-NLS-1$
 
@@ -6276,7 +6271,7 @@
      * If expressionsymbol comparison would ignore expression names then this should just select a single column,
      * but for now it will select 2.
      */
-    public void testCase2430E() {
+    @Test public void testCase2430E() {
         String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
                      "CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR "; //$NON-NLS-1$
 
@@ -6285,7 +6280,7 @@
         helpTestCase2430and2507(sql, expected);
     }     
     
-    public void testCase2430G() {
+    @Test public void testCase2430G() {
         String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
                      "CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
 
@@ -6294,7 +6289,7 @@
         helpTestCase2430and2507(sql, expected);
     }  
     
-    public void testCase2507_1(){
+    @Test public void testCase2507_1(){
 
         String sql = "SELECT a FROM (SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) as a " +  //$NON-NLS-1$
                      "FROM BQT1.SmallA) as X ORDER BY X.a"; //$NON-NLS-1$
@@ -6325,7 +6320,7 @@
      * This is taken from testPushCorrelatedSubquery1.  However this subquery is not expected to be pushed down since the correlated
      * reference expression cannot be evaluated by the source.
      */
-    public void testDefect23614() {
+    @Test public void testDefect23614() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -6366,7 +6361,7 @@
      * Normally the following queries would plan as if they were federated, but setting the connector_id source property
      * allows them to be planned as if they were the same source. 
      */
-    public void testSameConnector() {
+    @Test public void testSameConnector() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
@@ -6402,7 +6397,7 @@
     /**
      * Test changes to RuleCollapseSource for removing aliases 
      */
-    public void testCase4898() {
+    @Test public void testCase4898() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_UNION, true);
@@ -6421,7 +6416,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN);                                    
     }
     
-    public void testDefect13971() {
+    @Test public void testDefect13971() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
@@ -6455,7 +6450,7 @@
     /**
      * Ensures that aliases are not stripped from projected symbols if they might conflict with an order by element
      */
-    public void testCase5067() {
+    @Test public void testCase5067() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
@@ -6473,7 +6468,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
         
-    public void testDontPushConvertObject() {
+    @Test public void testDontPushConvertObject() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -6508,7 +6503,7 @@
         });                                    
     }
     
-    public void testDontPushConvertClobToString() {
+    @Test public void testDontPushConvertClobToString() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
@@ -6543,7 +6538,7 @@
         });                                    
     }
     
-    public void testSelectIntoWithDistinct() throws Exception {
+    @Test public void testSelectIntoWithDistinct() throws Exception {
         String sql = "select distinct e1 into #temp from pm1.g1"; //$NON-NLS-1$
         
         FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -6558,7 +6553,7 @@
     /**
      * previously the subqueries were being pushed too far and then not having the appropriate correlated references
      */
-    public void testCorrelatedSubqueryOverJoin() {
+    @Test public void testCorrelatedSubqueryOverJoin() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
@@ -6579,7 +6574,7 @@
     /**
      * see testSimpleCrossJoin3
      */
-    public void testMaxFromGroups() {
+    @Test public void testMaxFromGroups() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setSourceProperty(Capability.MAX_QUERY_FROM_GROUPS, new Integer(1));
@@ -6590,7 +6585,7 @@
                
     }
     
-    public void testCase6249() {
+    @Test public void testCase6249() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -6612,7 +6607,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
         
-    public void testCase6181() throws Exception {
+    @Test public void testCase6181() throws Exception {
         FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
         
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -6651,7 +6646,7 @@
         }); 
     }
     
-    public void testCase6325() {
+    @Test public void testCase6325() {
         String sql = "select e1 into #temp from pm4.g1 where e1='1'"; //$NON-NLS-1$
         
         FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -6661,7 +6656,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
     
-    public void testAliasCreationWithInlineView() {
+    @Test public void testAliasCreationWithInlineView() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
         
@@ -6673,7 +6668,7 @@
         checkSubPlanCount(plan, 0);
     }
     
-    public void testCase6364() {
+    @Test public void testCase6364() {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
@@ -6690,7 +6685,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }
     
-    public void testExceptPushdown() throws Exception {
+    @Test public void testExceptPushdown() throws Exception {
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_EXCEPT, true);
@@ -6704,7 +6699,7 @@
         checkNodeTypes(plan, FULL_PUSHDOWN); 
     }    
    
-    public void testCase6597() { 
+    @Test public void testCase6597() { 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
@@ -6735,7 +6730,7 @@
         }); 
     }
     
-    public void testCopyCriteriaWithIsNull() {
+    @Test public void testCopyCriteriaWithIsNull() {
     	String sql = "select * from (select a.intnum, a.intkey y, b.intkey from bqt1.smalla a, bqt2.smalla b where a.intkey = b.intkey) x where intkey is null"; //$NON-NLS-1$
     	
     	helpPlan(sql, FakeMetadataFactory.exampleBQT(), new String[] {});
@@ -6750,7 +6745,7 @@
      * <p>
      * SELECT * FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2
      */
-    public void testBetween() { 
+    @Test public void testBetween() { 
         helpPlan("select * from pm1.g1 where e2 between 1 and 2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
     			new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (e2 >= 1) AND (e2 <= 2)"} ); //$NON-NLS-1$
     }
@@ -6765,7 +6760,7 @@
      * <p>
      * SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1
      */
-    public void testBetweenInCase() { 
+    @Test public void testBetweenInCase() { 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
@@ -6787,7 +6782,7 @@
      * <p>
      * SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1
      */
-    public void testBetweenInCaseInSum() { 
+    @Test public void testBetweenInCaseInSum() { 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
@@ -6812,7 +6807,7 @@
      * SELECT e1, SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) 
      * FROM pm1.g1 GROUP BY e1
      */
-    public void testBetweenInCaseInSumWithGroupBy() { 
+    @Test public void testBetweenInCaseInSumWithGroupBy() { 
         FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
         BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,19 +22,21 @@
 
 package com.metamatrix.query.optimizer;
 
-import junit.framework.TestCase;
+import org.junit.Ignore;
+import org.junit.Test;
 
 import com.metamatrix.query.metadata.TempMetadataAdapter;
 import com.metamatrix.query.metadata.TempMetadataStore;
 import com.metamatrix.query.processor.ProcessorPlan;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
 
-public class TestStoredProcedurePlanning extends TestCase {
+public class TestStoredProcedurePlanning {
     
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 1a
      */
-    public void testStoredQuery1() {
+	@Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery1() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -44,7 +46,8 @@
     /**
      * Test planning stored queries
      */
-    public void testStoredQuery2() {
+	@Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery2() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -53,19 +56,20 @@
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 1b
      */
-    public void testStoredQuery3() {
+	@Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery3() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq2('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
     }
-    
-    public void testStoredQuery4() {
+	@Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery4() {
         ProcessorPlan plan = TestOptimizer.helpPlan("select x.e1 from (EXEC pm1.sq1()) as x", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
     }
 
-    public void testStoredQuery5() {
+    @Test public void testStoredQuery5() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -86,7 +90,7 @@
         }); 
     }
     
-    public void testStoredQuery6() {
+    @Test public void testStoredQuery6() {
         ProcessorPlan plan = TestOptimizer.helpPlan("select x.e1 from (EXEC pm1.sp1()) as x", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -107,7 +111,8 @@
         }); 
     }
     
-    public void testStoredQuery7() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery7() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sqsp1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -131,7 +136,8 @@
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 1c
      */
-    public void testStoredQuery8() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery8() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq3('1', 1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'", "SELECT e1, e2 FROM pm1.g1 WHERE e2 = 1" }); //$NON-NLS-1$ //$NON-NLS-2$
         TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -155,7 +161,8 @@
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 5a
      */
-    public void testStoredQuery9() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery9() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq4()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] {"SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -164,7 +171,8 @@
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 5b
      */
-    public void testStoredQuery10() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery10() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq5('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'"}); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -173,7 +181,8 @@
      /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 5c
      */
-    public void testStoredQuery11() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery11() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq6()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] {"SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -182,7 +191,8 @@
      /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 6a
      */
-    public void testStoredQuery12() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery12() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq7()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -191,7 +201,8 @@
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 6c
      */
-    public void testStoredQuery13() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery13() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq8('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -200,7 +211,8 @@
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 6b
      */
-    public void testStoredQuery14() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery14() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq9('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -209,7 +221,8 @@
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 6d
      */
-    public void testStoredQuery15() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery15() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq10('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT e1 FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN); 
@@ -218,7 +231,7 @@
     /**
      * Test planning stored queries. 
      */
-    public void testStoredQuery16() {
+    @Test public void testStoredQuery16() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp2(1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "EXEC pm1.sp2(1)" }); //$NON-NLS-1$
         TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -242,7 +255,8 @@
     /**
      * Test planning stored queries. GeminiStoredQueryTestPlan - 6d
      */
-    public void testStoredQuery17() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery17() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq11(1, 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "EXEC pm1.sp2(?)" }); //$NON-NLS-1$
 
@@ -265,7 +279,8 @@
     }
     
     //GeminiStoredQueryTestPlan - 2a, 2b
-    public void testStoredQuery18() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery18() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq12('1', 1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 1)" }); //$NON-NLS-1$
 
@@ -273,7 +288,8 @@
     }
     
     //GeminiStoredQueryTestPlan - 2c
-    public void testStoredQuery19() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery19() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq13('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 2)" }); //$NON-NLS-1$
 
@@ -281,7 +297,8 @@
     }
     
     //GeminiStoredQueryTestPlan - 3c
-    public void testStoredQuery20() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery20() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq14('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "UPDATE pm1.g1 SET e1 = '1' WHERE e2 = 2" }); //$NON-NLS-1$
 
@@ -289,14 +306,16 @@
     }
     
     //GeminiStoredQueryTestPlan - 4b
-    public void testStoredQuery21() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery21() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq15('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "DELETE FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
 
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);               
     }
     
-    public void testStoredQuery22() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery22() {
         ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from (EXEC pm1.sq1()) as x where e1='a' union (select e1 from vm1.g2 where e1='b')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 = 'a'", "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'b') AND (g_1.e1 = 'b')" }); //$NON-NLS-1$ //$NON-NLS-2$
 
@@ -318,36 +337,38 @@
         });               
     }
     
-    public void testStoredQuery23() {
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery23() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq16()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 2)" }); //$NON-NLS-1$
             
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);               
     }
     
-    public void testStoredQuery24() {
+    @Test public void testStoredQuery24() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp3()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "EXEC pm1.sp3()" }); //$NON-NLS-1$
 
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);               
     }
 
-    // test implicit type conversion of argument 
-    public void testStoredQuery25() {
+    // test implicit type conversion of argument
+    @Ignore("stored procedure wrapper removal logic has been removed")
+    @Test public void testStoredQuery25() {
         ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq15(1, 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "DELETE FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
 
         TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
     }
 
-    public void testStoredQueryXML1() {
+    @Test public void testStoredQueryXML1() {
         TestOptimizer.helpPlan("EXEC pm1.sq18()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), new String[] { }); //$NON-NLS-1$
     }
     
     /**
      * union of two stored procs - case #1466
      */
-    public void testStoredProc1() {
+    @Test public void testStoredProc1() {
         ProcessorPlan plan = TestOptimizer.helpPlan("SELECT * FROM (EXEC pm1.sp2(1)) AS x UNION ALL SELECT * FROM (EXEC pm1.sp2(2)) AS y", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "EXEC pm1.sp2(1)", "EXEC pm1.sp2(2)" }); //$NON-NLS-1$ //$NON-NLS-2$
         TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -371,7 +392,7 @@
     /**
      * union of stored proc and query - case #1466
      */
-    public void testStoredProc2() {
+    @Test public void testStoredProc2() {
         ProcessorPlan plan = TestOptimizer.helpPlan("SELECT * FROM (EXEC pm1.sp2(1)) AS x UNION ALL SELECT e1, e2 FROM pm1.g1", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
             new String[] { "EXEC pm1.sp2(1)", "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$ //$NON-NLS-2$
         TestOptimizer.checkNodeTypes(plan, new int[] {

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -80,7 +80,7 @@
                 fail("Exception during validation (" + repo); //$NON-NLS-1$
             }                    
             
-            command = QueryRewriter.rewrite(command, null, md, null);
+            command = QueryRewriter.rewrite(command, md, null);
             commands.add(command);
         }
         return commands;

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -80,7 +80,7 @@
             ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
             throw new QueryValidatorException(firstFailure.getMessage());
         }
-        userCommand = QueryRewriter.rewrite(userCommand, null, metadata, null);
+        userCommand = QueryRewriter.rewrite(userCommand, metadata, null);
         
         AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
         

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -45,7 +45,7 @@
                           boolean aliasGroups,
                           QueryMetadataInterface metadata) throws QueryValidatorException {
         Command command = TestResolver.helpResolve(sql, metadata, null);
-        command = QueryRewriter.rewrite(command, null, metadata, null);
+        command = QueryRewriter.rewrite(command, metadata, null);
         command.acceptVisitor(new AliasGenerator(aliasGroups));
         assertEquals(expected, command.toString());
         return command;

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -34,7 +34,7 @@
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestOptimizer;
 import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.relational.GenerateCanonical;
+import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
 import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
 import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
@@ -82,7 +82,7 @@
     
     void helpTestEstimateCost(String critString, float childCost, float expectedResult, QueryMetadataInterface metadata) throws Exception {
         Criteria crit = helpGetCriteria(critString, metadata);
-        PlanNode select = GenerateCanonical.createSelectNode(crit, false);
+        PlanNode select = RelationalPlanner.createSelectNode(crit, false);
         
         float resultCost = NewCalculateCostUtil.recursiveEstimateCostOfCriteria(childCost, select, crit, metadata);
         assertEquals((int)expectedResult, (int)resultCost);

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -35,7 +35,6 @@
 import com.metamatrix.query.optimizer.TestOptimizer;
 import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
 import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.GenerateCanonical;
 import com.metamatrix.query.optimizer.relational.OptimizerRule;
 import com.metamatrix.query.optimizer.relational.PlanHints;
 import com.metamatrix.query.optimizer.relational.RelationalPlanner;
@@ -47,6 +46,7 @@
 import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
 import com.metamatrix.query.unittest.FakeMetadataFacade;
 import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.util.CommandContext;
 
 /**
  * Tests {@link RuleChooseAccessPattern}
@@ -58,6 +58,8 @@
     private PlanHints planHints;
     
     private static final boolean DEBUG = false;
+
+	private static CapabilitiesFinder FINDER = new DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities());;
    
     // ################################## FRAMEWORK ################################
     
@@ -106,7 +108,9 @@
 		GroupCollectorVisitor.getGroups(query, groups);
 		
 		//Generate canonical plan
-		PlanNode planNode = GenerateCanonical.generatePlan(query, planHints, METADATA);
+    	RelationalPlanner p = new RelationalPlanner();
+    	p.initialize(query, null, METADATA, FINDER, null, null);
+    	PlanNode planNode = p.generatePlan(query);
 
 		final RuleStack rules = RelationalPlanner.buildRules(planHints);
 
@@ -120,7 +124,7 @@
 	 */
 	private static PlanNode helpExecuteRules(RuleStack rules, PlanNode plan, QueryMetadataInterface metadata, boolean debug)
 		throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
-
+		CommandContext context = new CommandContext();
 		while(! rules.isEmpty()) {
 			if(debug) {
 				System.out.println("\n============================================================================"); //$NON-NLS-1$
@@ -129,9 +133,8 @@
 			if(debug) {
 				System.out.println("EXECUTING " + rule); //$NON-NLS-1$
 			}
-
-            CapabilitiesFinder finder = new DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities());             
-            plan = rule.execute(plan, metadata, finder, rules, new AnalysisRecord(false, false, debug), null);
+             
+            plan = rule.execute(plan, metadata, FINDER, rules, new AnalysisRecord(false, false, debug), context);
 			if(debug) {
 				System.out.println("\nAFTER: \n" + plan); //$NON-NLS-1$
 			}

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -34,8 +34,7 @@
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.optimizer.TestOptimizer;
 import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.GenerateCanonical;
-import com.metamatrix.query.optimizer.relational.PlanHints;
+import com.metamatrix.query.optimizer.relational.RelationalPlanner;
 import com.metamatrix.query.optimizer.relational.RuleStack;
 import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
 import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
@@ -69,8 +68,10 @@
     	FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
     	Command command = TestOptimizer.helpGetCommand("select * from (select * from pm1.g1 union select * from pm1.g2) x where e1 = 1", metadata, null); //$NON-NLS-1$
     	Command subCommand = TestOptimizer.helpGetCommand("select * from pm1.g1 union select * from pm1.g2", metadata, null); //$NON-NLS-1$
-    	PlanNode root = GenerateCanonical.generatePlan(command, new PlanHints(), metadata);
-    	PlanNode child = GenerateCanonical.generatePlan(subCommand, new PlanHints(), metadata);
+    	RelationalPlanner p = new RelationalPlanner();
+    	p.initialize(command, null, metadata, null, null, null);
+    	PlanNode root = p.generatePlan(command);
+    	PlanNode child = p.generatePlan(subCommand);
     	PlanNode sourceNode = NodeEditor.findNodePreOrder(root, NodeConstants.Types.SOURCE);
     	sourceNode.addFirstChild(child);
         sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(), (List<SingleElementSymbol>)child.getFirstChild().getProperty(Info.PROJECT_COLS)));

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -38,7 +38,6 @@
 import com.metamatrix.query.metadata.TempMetadataID;
 import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
 import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CommandContainer;
 import com.metamatrix.query.sql.lang.Delete;
 import com.metamatrix.query.sql.lang.From;
 import com.metamatrix.query.sql.lang.Insert;
@@ -103,15 +102,7 @@
         LogManager.logTrace(LOG_CONTEXT, new Object[]{"Register Request:", command, ",processorID:", processorID, ",model name:", modelName,",TupleSourceID nodeID:",new Integer(nodeID)}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 
         
-        if ( command instanceof CommandContainer ) {
-        	if ( ((CommandContainer) command).getContainedCommands() != null && ((CommandContainer) command).getContainedCommands().size() > 0 ) {
-            	for ( Iterator<Command> it = ((CommandContainer) command).getContainedCommands().iterator(); it.hasNext(); ) {
-            		this.queries.add(it.next().toString());
-            	}
-        	} else {
-        		this.queries.add(command.toString());
-        	}
-        } else {
+        if (! (command instanceof BatchedUpdateCommand) ) {
         	this.queries.add(command.toString());
         }
 
@@ -128,10 +119,11 @@
 		} else if (command instanceof ProcedureContainer) {
 			group = ((ProcedureContainer) command).getGroup();
 		} else if ( command instanceof BatchedUpdateCommand ) {
-        	if ( ((CommandContainer) command).getContainedCommands() != null && ((CommandContainer) command).getContainedCommands().size() > 0 ) {
-        		if ( command.getSubCommands().get(0) instanceof Update ) {
-        			group = ((Update)command.getSubCommands().get(0)).getGroup();
-        		}
+    		if ( command.getSubCommands().get(0) instanceof Update ) {
+    			group = ((Update)command.getSubCommands().get(0)).getGroup();
+    		}
+        	for ( Iterator<Command> it = ((BatchedUpdateCommand) command).getUpdateCommands().iterator(); it.hasNext(); ) {
+        		this.queries.add(it.next().toString());
         	}
 		}
 		
@@ -184,10 +176,8 @@
 			// add single update command to a list to be executed
 			updateCommands.add(command);
 		} else if ( command instanceof BatchedUpdateCommand ) {
-        	if ( ((CommandContainer) command).getContainedCommands() != null && ((CommandContainer) command).getContainedCommands().size() > 0 ) {
-				// add all update commands to a list to be executed
-        		updateCommands.addAll(((CommandContainer) command).getContainedCommands());
-        	}
+			// add all update commands to a list to be executed
+    		updateCommands.addAll(((BatchedUpdateCommand) command).getUpdateCommands());
 		}
 		
 		// if we had update commands added to the list, execute them now

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -152,7 +152,7 @@
 	        if (failures.size() > 0){
 	            fail("Exception during validation (" + repo); //$NON-NLS-1$
 	        }        
-			command = QueryRewriter.rewrite(command, null, metadata, createCommandContext());
+			command = QueryRewriter.rewrite(command, metadata, createCommandContext());
 	        ProcessorPlan process = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, context);
 			if(DEBUG) System.out.println("\n" + process); //$NON-NLS-1$
 	        //per defect 10022, clone this plan before processing, just to make sure

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -490,7 +490,7 @@
     }
 
     private BufferManager createCustomBufferMgr(int batchSize) throws MetaMatrixComponentException {
-        BufferManager bufferMgr = new BufferManagerImpl();
+        BufferManagerImpl bufferMgr = new BufferManagerImpl();
         Properties props = new Properties();
         props.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, String.valueOf(Long.MAX_VALUE)); 
         props.setProperty(BufferManagerPropertyNames.SESSION_USE_PERCENTAGE, "100"); //$NON-NLS-1$

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -63,7 +63,7 @@
 			throws MetaMatrixProcessingException, MetaMatrixComponentException {
 		Command command = QueryParser.getQueryParser().parseCommand(sql);
 		QueryResolver.resolveCommand(command, metadata);
-		command = QueryRewriter.rewrite(command, null, metadata, commandContext);
+		command = QueryRewriter.rewrite(command, metadata, commandContext);
 		ProcessorPlan plan = QueryOptimizer.optimizePlan(command, metadata,
 				idGenerator, finder, AnalysisRecord.createNonRecordingRecord(),
 				commandContext);

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -90,7 +90,7 @@
             ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
             throw new QueryValidatorException(firstFailure.getMessage());
         }
-        QueryRewriter.rewrite(userCommand, null, metadata, new CommandContext());
+        QueryRewriter.rewrite(userCommand, metadata, new CommandContext());
 
         AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
         try {

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -63,7 +63,7 @@
     }
     
     static BufferManager createBufferManager(Properties bmProps) {
-        BufferManager bufferManager = new TestableBufferManagerImpl();
+        BufferManagerImpl bufferManager = new TestableBufferManagerImpl();
         bmProps.setProperty(BufferManagerPropertyNames.MANAGEMENT_INTERVAL, "0"); //$NON-NLS-1$
         try {
             bufferManager.initialize("local", bmProps); //$NON-NLS-1$

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -194,7 +194,7 @@
         };
         int[] expectedResults = {1};
         FakePDM fpdm = helpTestNextBatch(commands, expectedResults);
-        assertEquals("INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES (null, 1, TRUE, 1.0)", ((BatchedUpdateCommand)fpdm.actualCommands.get(0)).getContainedCommands().get(0).toString()); //$NON-NLS-1$
+        assertEquals("INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES (null, 1, TRUE, 1.0)", ((BatchedUpdateCommand)fpdm.actualCommands.get(0)).getUpdateCommands().get(0).toString()); //$NON-NLS-1$
     }
     
     private static final class FakePDM implements ProcessorDataManager {

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -119,7 +119,7 @@
         Command command = parser.parseCommand(sql);
         
         QueryResolver.resolveCommand(command, metadata);
-        command = QueryRewriter.rewrite(command, null, metadata, null);
+        command = QueryRewriter.rewrite(command, metadata, null);
         
         return command;        
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,6 +22,8 @@
 
 package com.metamatrix.query.processor.xml;
 
+import static org.junit.Assert.*;
+
 import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
 import java.util.ArrayList;
@@ -31,7 +33,8 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import junit.framework.TestCase;
+import org.junit.Ignore;
+import org.junit.Test;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -86,13 +89,9 @@
  * metadata, and then that XMLPlan being processed with metadata, a 
  * ProcessorDataManager and a QueryProcessor.
  */
-public class TestXMLProcessor extends TestCase {
+public class TestXMLProcessor {
     private static final boolean DEBUG = false;
     
-    public TestXMLProcessor(String name) {
-        super(name);
-    }
-
     /**
      * Construct some fake metadata.  Basic conceptual tree is:
      * 
@@ -2929,7 +2928,7 @@
         QueryParser parser = new QueryParser();
         Command command = parser.parseCommand(sql);
         QueryResolver.resolveCommand(command, metadata);
-        command = QueryRewriter.rewrite(command, null, metadata, null);
+        command = QueryRewriter.rewrite(command, metadata, null);
         return command;
     }
 
@@ -3079,7 +3078,7 @@
     // T E S T S 
     // =============================================================================================
 
-    public void test1() throws Exception {
+    @Test public void test1() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -3106,7 +3105,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
     
-    public void testOrderBy1() throws Exception {
+    @Test public void testOrderBy1() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -3133,7 +3132,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 ORDER BY Catalogs.Catalog.Items.Item.Quantity ASC", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testOrderBy1a() throws Exception {
+    @Test public void testOrderBy1a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -3160,7 +3159,7 @@
         helpTestProcess("SELECT \"xml\" FROM xmltest.doc1 ORDER BY Catalogs.Catalog.Items.Item.Quantity ASC", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
     
-    public void testOrderBy1b() throws Exception {
+    @Test public void testOrderBy1b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -3187,7 +3186,7 @@
         helpTestProcess("SELECT xmltest.doc1.xml FROM xmltest.doc1 ORDER BY Catalogs.Catalog.Items.Item.Quantity ASC", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
                
-    public void testOrderBy2() throws Exception {
+    @Test public void testOrderBy2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -3214,7 +3213,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 ORDER BY Catalogs.Catalog.Items.Item.Quantity DESC", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
     
-    public void testOrderBy3() throws Exception {
+    @Test public void testOrderBy3() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -3279,7 +3278,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 ORDER BY Catalogs.Catalog.Items.Item.ItemID DESC, Catalogs.Catalog.Items.Item.Suppliers.Supplier.SupplierID ASC", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }   
     
-    public void testOrderBy3a() throws Exception {
+    @Test public void testOrderBy3a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -3344,7 +3343,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 ORDER BY Catalogs.Catalog.Items.Item.ItemID ASC, Catalogs.Catalog.Items.Item.Suppliers.Supplier.SupplierID DESC", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }      
     
-    public void testOrderBy4() throws Exception {
+    @Test public void testOrderBy4() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -3364,7 +3363,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE ItemID='001' AND Quantity < 60 ORDER BY ItemID", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }     
      
-    public void testOrderBy5() throws Exception {
+    @Test public void testOrderBy5() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
          String expectedDoc = 
@@ -3391,7 +3390,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 ORDER BY ItemID", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     } 
     
-    public void testOrderBy6() throws Exception {
+    @Test public void testOrderBy6() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -3499,14 +3498,14 @@
     }   
    
     //order by with temp group at the root    
-    public void testOrderBy7() throws Exception {
+    @Test public void testOrderBy7() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         helpTestProcess("SELECT * FROM xmltest.doc9a ORDER BY ItemID DESC", EXPECTED_ORDERED_DOC9A, metadata, dataMgr);         //$NON-NLS-1$
     }   
            
     //order by with multiple elements and criteria with long name, short name doesn't work
-    public void testOrderBy8() throws Exception {
+    @Test public void testOrderBy8() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -3577,7 +3576,7 @@
     }   
 
     /*    
-    public void testOrderBy9() throws Exception {
+    @Test public void testOrderBy9() throws Exception {
         FakeMetadataFacade metadata = exampleMetadata();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = "";
@@ -3590,7 +3589,7 @@
     }
     */
   
-    public void testOrderBy10() throws Exception {
+    @Test public void testOrderBy10() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -3614,13 +3613,13 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE Quantity < 60 ORDER BY Name DESC", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }     
     
-     public void testOrderBy11() throws Exception {
+     @Test public void testOrderBy11() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         helpTestProcess("SELECT * FROM xmltest.doc9a WHERE ItemID='001' OR ItemID='002' OR ItemID='003' ORDER BY ItemID DESC", EXPECTED_ORDERED_DOC9A, metadata, dataMgr);         //$NON-NLS-1$
     }   
 
-    public void testOrderBy13() throws Exception {
+    @Test public void testOrderBy13() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -3648,7 +3647,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 ORDER BY Name DESC, Quantity ASC ", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
         
-    public void testOrderBy14() throws Exception {
+    @Test public void testOrderBy14() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -3755,7 +3754,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 ORDER BY Catalogs.Catalog.Items.Item.Suppliers.Supplier.SupplierID ASC, OrderID DESC, Catalogs.Catalog.Items.Item.ItemID DESC", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }   
      
-    public void testOrderBy15() throws Exception {
+    @Test public void testOrderBy15() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -3784,7 +3783,7 @@
     }
 
     /** test null elements*/
-    public void testOrderBy17() throws Exception {
+    @Test public void testOrderBy17() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithNulls(metadata);
         
@@ -3813,7 +3812,7 @@
     }
     
     /**  test duplicate elements*/
-    public void testOrderBy18() throws Exception {
+    @Test public void testOrderBy18() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithDuplicates(metadata);
         
@@ -3842,7 +3841,7 @@
     }
     
     /**  test more than two parallel elements*/
-    public void testOrderBy19() throws Exception {
+    @Test public void testOrderBy19() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithDuplicates1(metadata);
         
@@ -3870,7 +3869,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 ORDER BY ItemID ASC, Name ASC, Quantity DESC ", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
     
-    public void testOrderBy20() throws Exception {
+    @Test public void testOrderBy20() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc =
@@ -3928,7 +3927,7 @@
      * Doc nodes that are not mapped to data cannot be used in the 
      * ORDER BY clause of an XML doc query
      */
-    public void testOrderBy_defect9803() throws Exception {
+    @Test public void testOrderBy_defect9803() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
                
@@ -3944,7 +3943,7 @@
     }    
         
     //defect 8130
-    public void test1CriteriaWithUnmappedElementFails() throws Exception {
+    @Test public void test1CriteriaWithUnmappedElementFails() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         
@@ -3952,14 +3951,14 @@
     }    
 
     //defect 8130
-    public void test1CriteriaWithUnmappedElementFails2() throws Exception {
+    @Test public void test1CriteriaWithUnmappedElementFails2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE Item = 'something'", null, metadata, dataMgr, false, QueryPlannerException.class, null);         //$NON-NLS-1$
     }  
     
-    public void testNested() throws Exception {
+    @Test public void testNested() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4165,7 +4164,7 @@
             "    </Catalog>\r\n" +  //$NON-NLS-1$
             "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
             
-    public void testNested2() throws Exception {
+    @Test public void testNested2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2;
@@ -4176,14 +4175,14 @@
      * Tests a couple temp groups at the root - B selects from A, and a mapping class
      * selects from B
      */
-    public void testNested2aTempGroup() throws Exception {
+    @Test public void testNested2aTempGroup() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2;
         helpTestProcess("SELECT * FROM xmltest.doc9a", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }   
 
-    public void testNested2aTempGroupCriteria() throws Exception {
+    @Test public void testNested2aTempGroupCriteria() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4263,7 +4262,7 @@
     }   
 
     /** defect 13172, CSE Case 1811 */
-    public void testNested2aTempGroupCompoundCriteria() throws Exception {
+    @Test public void testNested2aTempGroupCompoundCriteria() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4344,7 +4343,7 @@
     }
 
     /** defect 13172, CSE Case 1811 */
-    public void testNested2aTempGroupCompoundCriteria1() throws Exception {
+    @Test public void testNested2aTempGroupCompoundCriteria1() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4425,7 +4424,7 @@
     }
 
     /** defect 13172, CSE Case 1811 */
-    public void testNested2aTempGroupCompoundCriteria2() throws Exception {
+    @Test public void testNested2aTempGroupCompoundCriteria2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4511,7 +4510,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9a WHERE tempGroup.orders.orderNum = '1' OR tempGroup.orders.orderStatus = 'processing'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2cTempGroup() throws Exception {
+    @Test public void testNested2cTempGroup() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_3;
@@ -4529,7 +4528,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9b", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }   
 
-    public void testNested2WithCriteria() throws Exception {
+    @Test public void testNested2WithCriteria() throws Exception {
 
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -4587,7 +4586,7 @@
      * 
      * @see #testNested2WithCriteria2a
      */
-    public void testNested2WithCriteria2() throws Exception {
+    @Test public void testNested2WithCriteria2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4647,7 +4646,7 @@
      * 
      * @see #testNested2WithCriteria2a
      */
-    public void testNested2WithCriteria2_defect9802() throws Exception {
+    @Test public void testNested2WithCriteria2_defect9802() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4697,7 +4696,7 @@
      * shows a similar
      * @see #testNested2WithCriteria2
      */
-    public void testNested2WithCriteria2_function() throws Exception {
+    @Test public void testNested2WithCriteria2_function() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc =
@@ -4753,7 +4752,7 @@
      * at "Item" node) will be limited by default, instead of the one
      * the criteria is actually specified on.</p>
      */
-    public void testNested2WithCriteria2a() throws Exception {
+    @Test public void testNested2WithCriteria2a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4802,7 +4801,7 @@
     }
 
 
-    public void testNested2WithContextCriteria() throws Exception {
+    @Test public void testNested2WithContextCriteria() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4849,7 +4848,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(Item, SupplierID)='52'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria2() throws Exception {
+    @Test public void testNested2WithContextCriteria2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4902,7 +4901,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(Item, OrderID)='5'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria3() throws Exception {
+    @Test public void testNested2WithContextCriteria3() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -4995,7 +4994,7 @@
             "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
 
 
-    public void testNested2WithContextCriteria4() throws Exception {
+    @Test public void testNested2WithContextCriteria4() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_4;
@@ -5003,7 +5002,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(Item, OrderID)='5' OR context(Item, OrderID)='6'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria4a() throws Exception {
+    @Test public void testNested2WithContextCriteria4a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_4;
@@ -5011,7 +5010,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(Item, OrderID)='5' OR OrderID='6'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria4b() throws Exception {
+    @Test public void testNested2WithContextCriteria4b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_4;
@@ -5097,7 +5096,7 @@
             "    </Catalog>\r\n" +  //$NON-NLS-1$
             "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
 
-    public void testNested2WithContextCriteria5() throws Exception {
+    @Test public void testNested2WithContextCriteria5() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_5;
@@ -5105,7 +5104,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(Item, OrderID)='5' OR context(Item, OrderID)='2'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria5a() throws Exception {
+    @Test public void testNested2WithContextCriteria5a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_5;
@@ -5113,7 +5112,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE OrderID='5' OR context(Item, OrderID)='2'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria5b() throws Exception {
+    @Test public void testNested2WithContextCriteria5b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_5;
@@ -5134,7 +5133,7 @@
         return baos.toString();
     }
 
-    public void testNested2WithContextCriteria5Fail() throws Exception {
+    @Test public void testNested2WithContextCriteria5Fail() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = ""; //doesn't matter //$NON-NLS-1$
@@ -5146,7 +5145,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(Item, OrderID)='5' OR context(SupplierID, OrderID)='2'", expectedDoc, metadata, dataMgr, shouldSucceed, expectedException, shouldFailMsg);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria6() throws Exception {
+    @Test public void testNested2WithContextCriteria6() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5159,7 +5158,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE context(Item, OrderID)='5' AND context(Item, OrderID)='2'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria6b() throws Exception {
+    @Test public void testNested2WithContextCriteria6b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5209,14 +5208,14 @@
             "    </Catalog>\r\n" +  //$NON-NLS-1$
             "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
 
-    public void testNested2WithContextCriteria7() throws Exception {
+    @Test public void testNested2WithContextCriteria7() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_7;
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE CONTEXT(SupplierID, OrderID)='5' AND context(OrderID, OrderID)='5'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNested2WithContextCriteria7b() throws Exception {
+    @Test public void testNested2WithContextCriteria7b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_7;
@@ -5225,7 +5224,7 @@
         helpTestProcess(query, expectedDoc, metadata, dataMgr);        
     }
 
-    public void testNested2WithContextCriteria7c() throws Exception {
+    @Test public void testNested2WithContextCriteria7c() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = EXPECTED_DOC_NESTED_2_WITH_CONTEXT_CRITERIA_7;
@@ -5237,7 +5236,7 @@
     /**
      * per defect 7333
      */
-    public void testNested2WithContextCriteria_7333() throws Exception {
+    @Test public void testNested2WithContextCriteria_7333() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5276,7 +5275,7 @@
     /**
      * per defect 7333
      */
-    public void testNested2WithContextCriteria_7333b() throws Exception {
+    @Test public void testNested2WithContextCriteria_7333b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5315,7 +5314,7 @@
     /**
      * per defect 7333
      */
-    public void testNested2WithContextCriteria_7333c() throws Exception {
+    @Test public void testNested2WithContextCriteria_7333c() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5331,7 +5330,7 @@
     /**
      * per defect 7333
      */
-    public void testNested2WithContextCriteria_7333d() throws Exception {
+    @Test public void testNested2WithContextCriteria_7333d() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5347,7 +5346,7 @@
     /**
      * Select a single item, and then limit the suppliers based on an order #
      */
-    public void testNested2WithContextCriteria8() throws Exception {
+    @Test public void testNested2WithContextCriteria8() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5383,7 +5382,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc9 WHERE ItemID='002' AND Context(Supplier,OrderID)='5'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testNestedWithChoice() throws Exception {
+    @Test public void testNestedWithChoice() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5472,7 +5471,7 @@
     /**
      * Does not use 'context' operator
      */
-    public void testNestedWithChoiceAndCriteria2_6796() throws Exception {
+    @Test public void testNestedWithChoiceAndCriteria2_6796() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5516,7 +5515,7 @@
     /**
      * Uses the 'context' operator
      */
-    public void testNestedWithChoiceAndCriteria2a_6796() throws Exception {
+    @Test public void testNestedWithChoiceAndCriteria2a_6796() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5594,7 +5593,7 @@
     /**
      * Does not use 'context' operator
      */
-    public void testNestedWithLookupChoice() throws Exception {
+    @Test public void testNestedWithLookupChoice() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -5641,7 +5640,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc10L where Catalogs.Catalog.Items.Item.Suppliers.Supplier.ProcessingOrders.OtherOrder.OrderID='5'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }    
     
-    public void test1Unformatted() throws Exception {
+    @Test public void test1Unformatted() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -5671,7 +5670,7 @@
 
     // jhTODO: complete this
 
-    public void testChoice_5266a() throws Exception {
+    @Test public void testChoice_5266a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -5750,7 +5749,7 @@
     }
     
     
-    public void test1WithCriteriaShortName() throws Exception {
+    @Test public void test1WithCriteriaShortName() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -5773,7 +5772,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE quantity < 50", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void test1WithCriteriaLongName() throws Exception {
+    @Test public void test1WithCriteriaLongName() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -5796,7 +5795,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE catalogs.catalog.items.item.quantity < 50", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void test2() throws Exception {
+    @Test public void test2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -5815,7 +5814,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc2", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void test2a() throws Exception {
+    @Test public void test2a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -5842,13 +5841,13 @@
         helpTestProcess("SELECT * FROM xmltest.doc2a", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void test2b() throws Exception {
+    @Test public void test2b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         helpTestProcess("SELECT * FROM xmltest.doc2b", null, metadata, dataMgr, false, MetaMatrixComponentException.class, "Should have failed on default");         //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void test2c() throws Exception {
+    @Test public void test2c() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -5871,7 +5870,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc2c", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void test2d() throws Exception {
+    @Test public void test2d() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -5898,7 +5897,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc2d", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void test2e() throws Exception {
+    @Test public void test2e() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -5925,7 +5924,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc2e", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testWithNillableNode() throws Exception {
+    @Test public void testWithNillableNode() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithNulls(metadata);
         String expectedDoc = 
@@ -5952,7 +5951,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testWithDefault() throws Exception {
+    @Test public void testWithDefault() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithNulls(metadata);
         String expectedDoc = 
@@ -5979,7 +5978,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc3", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testWithNamespaces() throws Exception {
+    @Test public void testWithNamespaces() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithNulls(metadata);
         String expectedDoc = 
@@ -6012,7 +6011,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc4", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testWithNewIter3Properties() throws Exception {
+    @Test public void testWithNewIter3Properties() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerDuJour(metadata);
         String expectedDoc = 
@@ -6051,7 +6050,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc5", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testWithNewIter3PropertiesException() throws Exception {
+    @Test public void testWithNewIter3PropertiesException() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerDuJour(metadata);
         
@@ -6069,10 +6068,10 @@
             failOnDefaultException = e;
         }
         
-        super.assertNotNull("Query processing should have failed on default of choice node.", failOnDefaultException); //$NON-NLS-1$
+        assertNotNull("Query processing should have failed on default of choice node.", failOnDefaultException); //$NON-NLS-1$
     }
 
-    public void testAttributeBug() throws Exception {
+    @Test public void testAttributeBug() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
 
@@ -6096,7 +6095,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc7", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testMultipleDocs() throws Exception {
+    @Test public void testMultipleDocs() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
 
@@ -6165,7 +6164,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc11", expectedDocs, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testRecursive() throws Exception {
+    @Test public void testRecursive() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
 
@@ -6250,7 +6249,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc12", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
     }
 
-    public void testRecursiveA() throws Exception {
+    @Test public void testRecursiveA() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
 
@@ -6348,7 +6347,7 @@
      * See commented out section below for previous expected results. 
      * @throws Exception
      */
-    public void testRecursive2() throws Exception {
+    @Test public void testRecursive2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
 
@@ -6410,7 +6409,7 @@
 
         helpTestProcess("SELECT * FROM xmltest.doc13", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
     }
-    public void testRecursive3() throws Exception {
+    @Test public void testRecursive3() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
 
@@ -6472,7 +6471,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc14", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
     }
 
-    public void testRecursive4Exception() throws Exception {
+    @Test public void testRecursive4Exception() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         helpTestProcess("SELECT * FROM xmltest.doc15", null, metadata, dataMgr, false, MetaMatrixComponentException.class, "Query processing should have failed on recursion limit."); //$NON-NLS-1$ //$NON-NLS-2$
@@ -6481,7 +6480,7 @@
     /**
      * Seems to be failing as a result of changes for defect 12288 
      */
-    public void testRecursive5() throws Exception {
+    @Test public void testRecursive5() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
 
@@ -6532,7 +6531,7 @@
      * See commented out section below for previous expected results. 
      * @throws Exception
      */
-    public void testRecursiveWithStagingTable_defect15607() throws Exception {
+    @Test public void testRecursiveWithStagingTable_defect15607() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
 
@@ -6599,7 +6598,7 @@
      * Tests a recursive nested mapping class within a recursive mapping class, where
      * all nested "anchor" nodes are named "srcNestedRecursive".  Test of defect #5988
      */
-    public void testXQTRecursive_5988() throws Exception {
+    @Test public void testXQTRecursive_5988() throws Exception {
         FakeMetadataFacade metadata = exampleMetadata2();
         FakeDataManager dataMgr = exampleXQTDataManager(metadata);
 
@@ -6727,7 +6726,7 @@
      * Tests a non-recursive nested mapping class within a recursive mapping class, where
      * all nested "anchor" nodes are named "srcNested".  Test of defect #5988
      */
-    public void testXQTRecursive2_5988() throws Exception {
+    @Test public void testXQTRecursive2_5988() throws Exception {
         FakeMetadataFacade metadata = exampleMetadata2();
         FakeDataManager dataMgr = exampleXQTDataManager(metadata);
 
@@ -6779,7 +6778,7 @@
     /**
      * for defect 5988
      */
-    public void testXQTRecursiveSiblings_5988() throws Exception {
+    @Test public void testXQTRecursiveSiblings_5988() throws Exception {
         FakeMetadataFacade metadata = exampleMetadata2();
         FakeDataManager dataMgr = exampleXQTDataManager(metadata);
 
@@ -6915,7 +6914,7 @@
         helpTestProcess("SELECT * FROM xqttest.doc2", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
     }
 
-    public void testSelectElement1() throws Exception {
+    @Test public void testSelectElement1() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -6939,7 +6938,7 @@
         helpTestProcess("SELECT Name FROM xmltest.doc1", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
      
-    public void testSelectElement2() throws Exception {
+    @Test public void testSelectElement2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -7016,7 +7015,7 @@
     }
     
     /** select element in the reverse order of depth*/
-    public void testSelectElement3() throws Exception {
+    @Test public void testSelectElement3() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -7093,7 +7092,7 @@
     }
     
     /** two select elements at the same level*/
-    public void testSelectElement4() throws Exception {
+    @Test public void testSelectElement4() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -7123,7 +7122,7 @@
     }
     
     /** defect 9756 */
-    public void testSelectElement4_defect9756() throws Exception {
+    @Test public void testSelectElement4_defect9756() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -7143,7 +7142,7 @@
     }    
     
     /** three select elements with two of them at the same level and there are other nodes with the same name*/
-    public void testSelectElement5() throws Exception {
+    @Test public void testSelectElement5() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -7228,7 +7227,7 @@
     }
     
     /** check element.* case */
-    public void testSelectElement6() throws Exception {
+    @Test public void testSelectElement6() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -7256,7 +7255,7 @@
     }
     
     /** check element.* case without attribute in order by*/
-    public void testSelectElement6a() throws Exception {
+    @Test public void testSelectElement6a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -7284,7 +7283,7 @@
             + " FROM xmltest.doc1", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
     
-    public void testSelectElement7() throws Exception {
+    @Test public void testSelectElement7() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -7312,7 +7311,7 @@
             expectedDoc, metadata, dataMgr);        
     }
     
-    public void testSelectElement8() throws Exception {
+    @Test public void testSelectElement8() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -7341,7 +7340,7 @@
     }
     
     /** SELECT clause has element.*, but the sibling elements should not be included, only subtree should */
-    public void testSelectElement9() throws Exception {
+    @Test public void testSelectElement9() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -7377,7 +7376,7 @@
           expectedDoc, metadata, dataMgr);        
     }         
     
-    public void testSelectElement9a() throws Exception {
+    @Test public void testSelectElement9a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -7410,7 +7409,7 @@
     }    
              
     /** check element.* case with criteria and order by clause */
-    public void testSelectElement10() throws Exception {
+    @Test public void testSelectElement10() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -7438,7 +7437,7 @@
             expectedDoc, metadata, dataMgr);        
     }
     
-    public void testSelectElement12() throws Exception {
+    @Test public void testSelectElement12() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -7491,7 +7490,7 @@
             expectedDoc, metadata, dataMgr);                
     }
     
-    public void testSelectElement13() throws Exception {
+    @Test public void testSelectElement13() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -7513,7 +7512,7 @@
             expectedDoc, metadata, dataMgr);                
     }
 
-    public void testSelectElement14() throws Exception {
+    @Test public void testSelectElement14() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc =
@@ -7567,7 +7566,7 @@
                 expectedDoc, metadata, dataMgr);        
     }
     
-    public void testSelectElement15() throws Exception {
+    @Test public void testSelectElement15() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc =
@@ -7620,7 +7619,7 @@
             expectedDoc, metadata, dataMgr);        
     }
 
-    public void testSelectElement16() throws Exception {
+    @Test public void testSelectElement16() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc =
@@ -7674,7 +7673,7 @@
     }         
 
     /**  CSE query 0 */
-    public void testSelectElement17() throws Exception {
+    @Test public void testSelectElement17() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
 
@@ -7775,7 +7774,7 @@
     }   
 
     /**  CSE query 1 */
-    public void testSelectElement18() throws Exception {
+    @Test public void testSelectElement18() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -7820,7 +7819,7 @@
     }   
 
     /**  CSE query 2 */
-    public void testSelectElement19() throws Exception {
+    @Test public void testSelectElement19() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -7866,7 +7865,7 @@
             
 
     /**  CSE query 3 */
-    public void testSelectElement20() throws Exception {
+    @Test public void testSelectElement20() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -7899,7 +7898,7 @@
     }   
 
     /**  CSE query 3a */
-    public void testSelectElement20a() throws Exception {
+    @Test public void testSelectElement20a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -7929,7 +7928,7 @@
     }   
 
     /**  CSE query 4 */
-    public void testSelectElement21() throws Exception {
+    @Test public void testSelectElement21() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8016,7 +8015,7 @@
     }  
 
     /**  CSE query 4a */
-    public void testSelectElement21a() throws Exception {
+    @Test public void testSelectElement21a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8079,7 +8078,7 @@
     }  
     
     /**  CSE query 5 */
-    public void testSelectElement22() throws Exception {
+    @Test public void testSelectElement22() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
 
@@ -8138,7 +8137,7 @@
     } 
     
     /**  CSE query 5a */
-    public void testSelectElement22a() throws Exception {
+    @Test public void testSelectElement22a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
 
@@ -8194,7 +8193,7 @@
     } 
     
     /**  CSE query 6 */
-    public void testSelectElement23() throws Exception {
+    @Test public void testSelectElement23() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
 
@@ -8236,7 +8235,7 @@
     } 
     
     /**  CSE query 6a */
-    public void testSelectElement23a() throws Exception {
+    @Test public void testSelectElement23a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8275,7 +8274,7 @@
     }
                      
     /** test with order by and the element in the criteria is not in the select elements*/
-    public void testSelectElement24() throws Exception {
+    @Test public void testSelectElement24() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8315,7 +8314,7 @@
     }
 
     /** test element.* with order by and the element in the criteria is not in the select elements*/
-    public void testSelectElement24a() throws Exception {
+    @Test public void testSelectElement24a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8376,7 +8375,7 @@
     }
                          
     /** test with order by with only necessary sub-mapping classes are queried*/
-    public void testSelectElement25() throws Exception {
+    @Test public void testSelectElement25() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8417,7 +8416,7 @@
     }
     
     /** test element.* with order by with only necessary sub-mapping classes are queried*/
-    public void testSelectElement25a() throws Exception {
+    @Test public void testSelectElement25a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8484,7 +8483,7 @@
     /** Test element.* with order by with only necessary sub-mapping classes are queried 
      *  and case_insensitive nodes in the mapping tree
      */
-    public void testSelectElement25b() throws Exception {
+    @Test public void testSelectElement25b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8548,7 +8547,7 @@
             expectedDoc, metadata, dataMgr);        
     }
     
-    public void testSelectElement26() throws Exception {
+    @Test public void testSelectElement26() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8615,7 +8614,7 @@
     /** test special elements: result set name, and name with format of "document.fully.qualified.element" 
      * --> refer to Defect9497, this should fail
      */
-    public void testSelectElement27() throws Exception {
+    @Test public void testSelectElement27() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8643,7 +8642,7 @@
     }
         
     /** test special element, root element */
-    public void testSelectElement28() throws Exception {
+    @Test public void testSelectElement28() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8667,7 +8666,7 @@
     }
     
     /** test special element */
-    public void testSelectElement28a() throws Exception {
+    @Test public void testSelectElement28a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc =  
@@ -8693,7 +8692,7 @@
     }
 
     /** test model.document.* */
-    public void testSelectElement28b() throws Exception {
+    @Test public void testSelectElement28b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -8724,7 +8723,7 @@
     }
         
     /** test special element, root element */
-    public void testSelectElement29() throws Exception {
+    @Test public void testSelectElement29() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8749,7 +8748,7 @@
     }
     
     /** test simple case for two elements in a mapping class */
-    public void testSelectElement30() throws Exception {
+    @Test public void testSelectElement30() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -8770,7 +8769,7 @@
     }     
                         
     /** test NullPointerException*/
-    public void testDefect_9496_1() throws Exception {
+    @Test public void testDefect_9496_1() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8834,7 +8833,7 @@
             expectedDoc, metadata, dataMgr);        
     }
 
-    public void testDefect_9496_2() throws Exception {
+    @Test public void testDefect_9496_2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8891,7 +8890,7 @@
     }
     
     /** test StringIndexOutOfBoundsException */
-    public void testDefect_9496_3() throws Exception {
+    @Test public void testDefect_9496_3() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -8996,7 +8995,7 @@
     }
     
     /** should fail: because there are other element other than "xml" */
-    /*public void testResolver1() throws Exception {
+    /*@Test public void testResolver1() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = ""; 
@@ -9012,7 +9011,7 @@
     }*/
 
     /** should fail: partial qualified element name and "model.document.xml" */
-    /*public void testResolver2() throws Exception {
+    /*@Test public void testResolver2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = ""; 
@@ -9028,7 +9027,7 @@
     }*/
 
     /** should fail: test XMLResolver validatation for model.* */
-    /*public void testDefect_9498_1() throws Exception {
+    /*@Test public void testDefect_9498_1() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = ""; 
@@ -9041,7 +9040,7 @@
     }*/
 
     /** should fail: test XMLResolver validatation for model.document.* */
-    /*public void testDefect_9498_2() throws Exception {
+    /*@Test public void testDefect_9498_2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = ""; 
@@ -9054,7 +9053,7 @@
     }*/
 
     /** should fail: test XMLResolver validatation for xml.* */
-    /*public void testDefect_9498_3() throws Exception {
+    /*@Test public void testDefect_9498_3() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = ""; 
@@ -9069,7 +9068,7 @@
     /** Test element.* with order by with only necessary sub-mapping classes are queried 
      *  and case_insensitive nodes in the mapping tree
      */
-    public void testCommentNodeInDoc() throws Exception {
+    @Test public void testCommentNodeInDoc() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9118,7 +9117,7 @@
         "    <Catalog6/>\r\n" +  //$NON-NLS-1$
         "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
 
-    public void testDefect8917() throws Exception {
+    @Test public void testDefect8917() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager_8917(metadata);
         
@@ -9129,7 +9128,7 @@
     /*
      * jhTODO
      */
-    public void testNillableOptional() throws Exception {
+    @Test public void testNillableOptional() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -9148,7 +9147,7 @@
     /*
      * jhTODO
      */
-    public void testNillableNonOptional() throws Exception {
+    @Test public void testNillableNonOptional() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         
@@ -9170,7 +9169,7 @@
      * NON-empty whitespace string, which will NOT be treated as null
      * see also defect 15117
      */
-    public void testDefect11789() throws Exception {
+    @Test public void testDefect11789() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager_8917a(metadata);
 
@@ -9232,7 +9231,7 @@
      * Related to defect 8917 - the result should be the same as 
      * testDefect8917
      */
-    public void testDefect11789b() throws Exception {
+    @Test public void testDefect11789b() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager_8917b(metadata);
 
@@ -9240,7 +9239,7 @@
             EXPECTED_DOC_DEFECT_8917_AND_11789, metadata, dataMgr);        
     }    
     
-    public void testDefect9446() throws Exception {
+    @Test public void testDefect9446() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager_8917(metadata);
         String expectedDoc = 
@@ -9261,7 +9260,7 @@
             expectedDoc, metadata, dataMgr);        
     } 
 
-    public void testDefect9446_2() throws Exception {
+    @Test public void testDefect9446_2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager_8917(metadata);
         String expectedDoc = 
@@ -9276,7 +9275,7 @@
             expectedDoc, metadata, dataMgr);        
     } 
 
-    public void testDefect_9530() throws Exception {
+    @Test public void testDefect_9530() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9307,7 +9306,7 @@
             expectedDoc, metadata, dataMgr);        
     } 
 
-    public void testSubqueryInXMLQueryCriteria() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteria() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9334,7 +9333,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE ItemID IN (SELECT itemNum FROM stock.items WHERE itemNum = '001')", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testSubqueryInXMLQueryCriteria2() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteria2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9361,7 +9360,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE ItemID > ANY (SELECT itemNum FROM stock.items WHERE itemNum IN ('001','002') )", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testSubqueryInXMLQueryCriteria3() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteria3() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9415,7 +9414,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE EXISTS (SELECT itemNum FROM stock.items WHERE itemNum = '001')", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testSubqueryInXMLQueryCriteriaNestedSubquery() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteriaNestedSubquery() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9442,7 +9441,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1 WHERE ItemID > ANY (SELECT itemNum FROM stock.items WHERE itemNum IN (SELECT itemNum FROM stock.items WHERE itemNum IN ('001','002') ) )", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testSubqueryInXMLQueryCriteriaNestedMappingClass() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteriaNestedMappingClass() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -9507,7 +9506,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 WHERE ItemID > ANY (SELECT itemNum FROM stock.items WHERE itemNum IN ('001','002') )", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }  
 
-    public void testSubqueryInXMLQueryCriteriaNestedMappingClass2() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteriaNestedMappingClass2() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -9572,7 +9571,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 WHERE SupplierID > ANY (SELECT supplierNum FROM stock.suppliers WHERE supplierNum IN ('53','54') )", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     } 
 
-    public void testSubqueryInXMLQueryCriteriaNestedMappingClass3() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteriaNestedMappingClass3() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -9637,7 +9636,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 WHERE SupplierID < ALL (SELECT supplierNum FROM stock.suppliers WHERE supplierNum IN ('52','54') )", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testSubqueryInXMLQueryCriteriaNestedMappingClass3a() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteriaNestedMappingClass3a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -9703,7 +9702,7 @@
     }
 
 
-    public void testSubqueryInXMLQueryCriteriaNestedMappingClass4() throws Exception {
+    @Test public void testSubqueryInXMLQueryCriteriaNestedMappingClass4() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -9770,7 +9769,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 WHERE context(SupplierID, SupplierID) < SOME (SELECT supplierNum FROM stock.suppliers WHERE supplierNum IN ('52','54') )", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testCritNestedMappingClass() throws Exception {
+    @Test public void testCritNestedMappingClass() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -9835,7 +9834,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 WHERE SupplierID = '52'", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testDefect_9893() throws Exception{
+    @Test public void testDefect_9893() throws Exception{
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9850,7 +9849,7 @@
             expectedDoc, metadata, dataMgr); 
     }
 
-    public void testDefect_9893_2() throws Exception{
+    @Test public void testDefect_9893_2() throws Exception{
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9865,7 +9864,7 @@
             expectedDoc, metadata, dataMgr); 
     }
 
-    public void testDefect_9893_3() throws Exception{
+    @Test public void testDefect_9893_3() throws Exception{
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 
@@ -9880,7 +9879,7 @@
             expectedDoc, metadata, dataMgr); 
     }
 
-    public void testDefect_9893_4() throws Exception{
+    @Test public void testDefect_9893_4() throws Exception{
         FakeMetadataFacade metadata = exampleMetadataNestedWithSibling();
         FakeDataManager dataMgr = exampleDataManagerNestedWithSibling(metadata);
         String expectedDoc = 
@@ -9900,7 +9899,7 @@
             expectedDoc, metadata, dataMgr, SHOULD_SUCCEED, null, null);       
     }
 
-    public void testNestedWithStoredQueryInMappingClass() throws Exception {
+    @Test public void testNestedWithStoredQueryInMappingClass() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -9966,7 +9965,7 @@
     }
 
     /** homegenous, simple array elements */
-    public void testWithSOAPEncoding1() throws Exception {
+    @Test public void testWithSOAPEncoding1() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataSoap1();
         FakeDataManager dataMgr = exampleDataManagerForSoap1(metadata, false);
          
@@ -10000,7 +9999,7 @@
      * (e.g. ORG:ArrayOfTaxID) and the schema allows it, eliminate the 
      * whole fragment
      */        
-    public void testWithSOAPEncodingNoRows() throws Exception {
+    @Test public void testWithSOAPEncodingNoRows() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataSoap1();
         FakeDataManager dataMgr = exampleDataManagerForSoap1(metadata, true);
          
@@ -10026,7 +10025,7 @@
         helpTestProcess("SELECT * FROM xmltest.docSoap", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }  
     
-    public void testDefect12260() throws Exception{
+    @Test public void testDefect12260() throws Exception{
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
         String expectedDoc = 
@@ -10065,7 +10064,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc12260", expectedDoc, metadata, dataMgr, true, MetaMatrixComponentException.class, null, capFinder); //$NON-NLS-1$
     }
     
-    public void testDefect8373() throws Exception{
+    @Test public void testDefect8373() throws Exception{
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithNulls(metadata);
@@ -10106,7 +10105,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8373", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testDefect8373a() throws Exception{
+    @Test public void testDefect8373a() throws Exception{
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithNulls(metadata);
@@ -10147,7 +10146,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8373a", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testDefect8373b() throws Exception{
+    @Test public void testDefect8373b() throws Exception{
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerWithNulls(metadata);
@@ -10188,7 +10187,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8373b", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }    
 
-    public void testDefect13617() throws Exception {
+    @Test public void testDefect13617() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager13617(metadata);
         String expectedDoc = 
@@ -10212,7 +10211,7 @@
         helpTestProcess("SELECT Item.Name FROM xmltest.doc13617", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }       
 
-    public void testDefect13617a() throws Exception {
+    @Test public void testDefect13617a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager13617(metadata);
         String expectedDoc = 
@@ -10243,7 +10242,7 @@
      * @throws Exception
      * @since 4.2
      */
-    public void testDefect14905() throws Exception {
+    @Test public void testDefect14905() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager14905(metadata);
         String expectedDoc = 
@@ -10270,7 +10269,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }    
 
-    public void testTextUnnormalizedDefect15117() throws Exception {
+    @Test public void testTextUnnormalizedDefect15117() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager15117(metadata);
         String expectedDoc = 
@@ -10297,7 +10296,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
 
-    public void testTextUnnormalizedDefect15117a() throws Exception {
+    @Test public void testTextUnnormalizedDefect15117a() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager15117a(metadata);
         String expectedDoc = 
@@ -10324,7 +10323,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc1", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }      
     
-    public void testRecursiveGroupDoc() throws Exception {
+    @Test public void testRecursiveGroupDoc() throws Exception {
 
         FakeMetadataFacade metadata = exampleMetadata2();
         FakeDataManager dataMgr = exampleXQTDataManager(metadata);
@@ -10358,7 +10357,7 @@
         helpTestProcess("SELECT * FROM xqttest.groupDoc WHERE pseudoID = 2", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
     
-    public void testCase2951MaxRows() throws Exception {
+    @Test public void testCase2951MaxRows() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10425,7 +10424,7 @@
     }
     
     /** test rowlimitexception() doesn't throw exception is rowlimit isn't passed */
-    public void testDefect19173RowLimitException() throws Exception {
+    @Test public void testDefect19173RowLimitException() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10492,7 +10491,7 @@
     }    
 
     /** test criteria can be written backwards */
-    public void testDefect19173RowLimitExceptionBackwardsCriteria() throws Exception {
+    @Test public void testDefect19173RowLimitExceptionBackwardsCriteria() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10558,7 +10557,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 WHERE 4 = rowlimitexception(supplier)", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }    
     
-    public void testCase2951MaxRows2() throws Exception {
+    @Test public void testCase2951MaxRows2() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10613,7 +10612,7 @@
     }    
 
     /** test processing exception is thrown if row limit is passed */
-    public void testDefect19173RowLimitException2() throws Exception {
+    @Test public void testDefect19173RowLimitException2() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10622,7 +10621,7 @@
     }      
     
     /** Two row limits on the same mapping class should be harmless as long as the row limits are identical. */
-    public void testCase2951MaxRows2a() throws Exception {
+    @Test public void testCase2951MaxRows2a() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10677,7 +10676,7 @@
     }    
 
     /** test processing exception is thrown if row limit is passed */
-    public void testDefect19173RowLimitException2a() throws Exception {
+    @Test public void testDefect19173RowLimitException2a() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10686,7 +10685,7 @@
     }      
     
     /** compound criteria */
-    public void testCase2951MaxRows3() throws Exception {
+    @Test public void testCase2951MaxRows3() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10717,7 +10716,7 @@
     }    
 
     /** compound criteria */
-    public void testDefect19173RowLimitException3() throws Exception {
+    @Test public void testDefect19173RowLimitException3() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10725,7 +10724,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 WHERE ItemID='002' AND rowlimitexception(supplier) = 2", null, metadata, dataMgr, false, MetaMatrixProcessingException.class, "");         //$NON-NLS-1$ //$NON-NLS-2$
     }     
     
-    public void testCase2951MaxRows4() throws Exception {
+    @Test public void testCase2951MaxRows4() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10769,7 +10768,7 @@
         helpTestProcess("SELECT * FROM xmltest.doc8 WHERE rowlimit(supplier) = 2 AND rowlimit(item) = 2", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }     
 
-    public void testCase2951AndDefect19173MixTwoFunctions() throws Exception {
+    @Test public void testCase2951AndDefect19173MixTwoFunctions() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10824,7 +10823,7 @@
     }     
     
     /** arg to rowlimit function isn't in the scope of any mapping class */
-    public void testCase2951MaxRowsFails() throws Exception {
+    @Test public void testCase2951MaxRowsFails() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10833,7 +10832,7 @@
     }     
 
     /** two conflicting row limits on the same mapping class */
-    public void testCase2951MaxRowsFails2() throws Exception {
+    @Test public void testCase2951MaxRowsFails2() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10842,7 +10841,7 @@
     }
     
     /** arg to rowlimitexception function isn't in the scope of any mapping class */
-    public void testDefect19173RowLimitExceptionFails() throws Exception {
+    @Test public void testDefect19173RowLimitExceptionFails() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10851,7 +10850,7 @@
     }     
 
     /** two conflicting rowlimitexceptions on the same mapping class */
-    public void testDefect19173RowLimitExceptionFails2() throws Exception {
+    @Test public void testDefect19173RowLimitExceptionFails2() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10860,7 +10859,7 @@
     }    
     
     /** two conflicting rowlimit and rowlimitexceptions on the same mapping class fails planning */
-    public void testDefect19173RowLimitAndRowLimitExceptionMixFails2() throws Exception {
+    @Test public void testDefect19173RowLimitAndRowLimitExceptionMixFails2() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10869,7 +10868,7 @@
     }    
 
     /** try rowlimit criteria written the reverse way */
-    public void testCase2951MaxRows5() throws Exception {
+    @Test public void testCase2951MaxRows5() throws Exception {
         
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNested(metadata);
@@ -10924,7 +10923,7 @@
     } 
     
     
-    public void testNormalizationCollapse() throws Exception {
+    @Test public void testNormalizationCollapse() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNormalization(metadata);
         String expectedDoc = 
@@ -10963,7 +10962,7 @@
         helpTestProcess("SELECT * FROM xmltest.normDoc1", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
     
-    public void testNormalizationReplace() throws Exception {
+    @Test public void testNormalizationReplace() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNormalization(metadata);
         String expectedDoc = 
@@ -11001,7 +11000,7 @@
  
         helpTestProcess("SELECT * FROM xmltest.normDoc2", expectedDoc, metadata, dataMgr);         //$NON-NLS-1$
     }
-    public void testNormalizationPreserve() throws Exception {
+    @Test public void testNormalizationPreserve() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManagerNormalization2(metadata);
         String expectedDoc = 
@@ -11268,7 +11267,7 @@
      * Test of doc model w/o criteria, just as a baseline 
      * @throws Exception
      */
-    public void testCase3225() throws Exception {
+    @Test public void testCase3225() throws Exception {
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleCase3225();
         FakeDataManager dataMgr = exampleDataManagerCase3225(metadata);
         String expectedDoc = 
@@ -11586,7 +11585,7 @@
      * the combined criteria should limit returned items to item 001.
      * @throws Exception
      */
-    public void testCase3225WithCriteria() throws Exception {
+    @Test public void testCase3225WithCriteria() throws Exception {
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleCase3225();
         FakeDataManager dataMgr = exampleDataManagerCase3225(metadata);
         helpTestProcess("select * from xmltest.itemsdoc where employee. at supervisorID='1004' and order.orderquantity > 1", CASE_3225_WITH_CRITERIA_EXPECTED_DOC, metadata, dataMgr);         //$NON-NLS-1$
@@ -11608,7 +11607,7 @@
      * the combined criteria should limit returned items to item 001.
      * @throws Exception
      */
-    public void testCase3225WithCriteriaReversed() throws Exception {
+    @Test public void testCase3225WithCriteriaReversed() throws Exception {
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleCase3225();
         FakeDataManager dataMgr = exampleDataManagerCase3225(metadata);
         helpTestProcess("select * from xmltest.itemsdoc where order.orderquantity > 1 and employee. at supervisorID='1004'", CASE_3225_WITH_CRITERIA_EXPECTED_DOC, metadata, dataMgr);         //$NON-NLS-1$
@@ -11620,7 +11619,7 @@
      * to make sure all of the criteria is processed correctly. 
      * @throws Exception
      */
-    public void testCase3225WithEmptyDocCriteria() throws Exception {
+    @Test public void testCase3225WithEmptyDocCriteria() throws Exception {
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleCase3225();
         FakeDataManager dataMgr = exampleDataManagerCase3225(metadata);
         String expectedDoc = 
@@ -11639,7 +11638,7 @@
      * @throws Exception
      * @since 4.3
      */
-    public void testBaseballPlayersDoc() throws Exception {
+    @Test public void testBaseballPlayersDoc() throws Exception {
         
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleCase3225();
         FakeDataManager dataMgr = exampleDataManagerCase3225(metadata);
@@ -11731,7 +11730,7 @@
      * @throws Exception
      * @since 4.3
      */
-    public void testBaseballPlayersDocCriteria() throws Exception {
+    @Test public void testBaseballPlayersDocCriteria() throws Exception {
         
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleCase3225();
         FakeDataManager dataMgr = exampleDataManagerCase3225(metadata);
@@ -11786,7 +11785,7 @@
      * @throws Exception
      * @since 4.3
      */
-    public void testBaseballPlayersDocContextCriteria() throws Exception {
+    @Test public void testBaseballPlayersDocContextCriteria() throws Exception {
         
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleCase3225();
         FakeDataManager dataMgr = exampleDataManagerCase3225(metadata);
@@ -11847,7 +11846,8 @@
         
     }    
     
-    public void testProcedureAndXML() throws Exception {
+    @Ignore("stored procedure wrapper removal has been disabled")
+    @Test public void testProcedureAndXML() throws Exception {
         FakeMetadataFacade metadata = exampleMetadataCached();
         FakeDataManager dataMgr = exampleDataManager(metadata);
         String expectedDoc = 

Added: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -0,0 +1,1639 @@
+/*
+ * 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.resolver;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataID;
+import com.metamatrix.query.metadata.TempMetadataStore;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.resolver.util.ResolverUtil;
+import com.metamatrix.query.sql.ProcedureReservedWords;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.Insert;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
+import com.metamatrix.query.sql.proc.AssignmentStatement;
+import com.metamatrix.query.sql.proc.Block;
+import com.metamatrix.query.sql.proc.CommandStatement;
+import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
+import com.metamatrix.query.sql.proc.LoopStatement;
+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.ElementCollectorVisitor;
+import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.unittest.FakeMetadataObject;
+
+public class TestProcedureResolving {
+
+ 	private QueryMetadataInterface exampleStoredProcedure(String procedure) {
+		FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+        
+        FakeMetadataObject pm1 = metadata.getStore().findObject("pm1",FakeMetadataObject.MODEL); //$NON-NLS-1$
+        FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+        FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2);  //$NON-NLS-1$
+        FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null);  //$NON-NLS-1$
+        QueryNode sq2n1 = new QueryNode("pm1.sq1", procedure); //$NON-NLS-1$ 
+        FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1);  //$NON-NLS-1$
+
+        metadata.getStore().addObject(rs2);
+        metadata.getStore().addObject(sq1);
+        
+        return metadata;
+	}
+ 	
+    private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType) {
+        helpFailUpdateProcedure(procedure, userUpdateStr, procedureType, null);
+    }
+    
+	private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType, String msg) {
+        // resolve
+        try {
+    		helpResolveUpdateProcedure(procedure, userUpdateStr, procedureType);
+            fail("Expected a QueryResolverException but got none."); //$NON-NLS-1$
+        } catch(QueryResolverException ex) {
+        	if (msg != null) {
+                assertEquals(msg, ex.getMessage());
+            }
+        } catch (MetaMatrixComponentException e) {
+        	throw new RuntimeException(e);
+		} catch (QueryParserException e) {
+			throw new RuntimeException(e);
+		} 
+	}	
+	
+    public static Map getProcedureExternalMetadata(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
+    throws QueryMetadataException, MetaMatrixComponentException {
+        Map externalMetadata = new HashMap();
+
+        // Look up elements for the virtual group
+        List elements = ResolverUtil.resolveElementsInGroup(virtualGroup, metadata);
+        // virtual group metadata info
+        externalMetadata.put(virtualGroup, elements);
+
+        // INPUT group metadata info
+        GroupSymbol inputGroup = new GroupSymbol(ProcedureReservedWords.INPUT);
+        List inputElments = new ArrayList(elements.size());
+        List elementIds = new ArrayList();
+        for(int i=0; i<elements.size(); i++) {
+            ElementSymbol virtualElmnt = (ElementSymbol)elements.get(i);
+            ElementSymbol inputElement = (ElementSymbol)virtualElmnt.clone();
+            inputElments.add(inputElement);
+            elementIds.add(new TempMetadataID(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + virtualElmnt.getShortName(), virtualElmnt.getType()));
+        }
+        inputGroup.setMetadataID(new TempMetadataID(ProcedureReservedWords.INPUT, elementIds));
+        externalMetadata.put(inputGroup, inputElments);
+
+        // CHANGING group metadata info
+        // Switch type to be boolean for all CHANGING variables
+        GroupSymbol changeGroup = new GroupSymbol(ProcedureReservedWords.CHANGING);
+        List changingElments = new ArrayList(elements.size());
+        elementIds = new ArrayList();
+        for(int i=0; i<elements.size(); i++) {
+            ElementSymbol changeElement = (ElementSymbol)((ElementSymbol)elements.get(i)).clone();
+            changeElement.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
+            changingElments.add(changeElement);
+            elementIds.add(new TempMetadataID(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + changeElement.getShortName(), changeElement.getType()));
+        }
+        changeGroup.setMetadataID(new TempMetadataID(ProcedureReservedWords.CHANGING, elementIds));
+        externalMetadata.put(changeGroup, changingElments);
+
+        return externalMetadata;
+    }
+	
+    @Test public void testDefect13029_CorrectlySetUpdateProcedureTempGroupIDs() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
+            .append("\nBEGIN") //$NON-NLS-1$
+            .append("\nDECLARE string var1;") //$NON-NLS-1$
+            .append("\nvar1 = '';") //$NON-NLS-1$
+            .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+            .append("\n  BEGIN") //$NON-NLS-1$
+            .append("\n    LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor2") //$NON-NLS-1$
+            .append("\n    BEGIN") //$NON-NLS-1$
+            .append("\n      var1 = CONCAT(var1, CONCAT(' ', loopCursor2.e1));") //$NON-NLS-1$
+            .append("\n    END") //$NON-NLS-1$
+            .append("\n  END") //$NON-NLS-1$
+            .append("\nEND"); //$NON-NLS-1$
+            
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        Command command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        Map tempIDs = command.getTemporaryMetadata();
+        assertNotNull(tempIDs);
+        assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+        
+        Command subCommand = command.getSubCommands().get(0);
+        tempIDs = subCommand.getTemporaryMetadata();
+        assertNotNull(tempIDs);
+        assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+
+        subCommand = command.getSubCommands().get(1);
+        tempIDs = subCommand.getTemporaryMetadata();
+        assertNotNull(tempIDs);
+        assertNotNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
+        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
+    }
+    
+	private CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr, String procedureType) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
+		return resolveProcedure(userUpdateStr, metadata);
+	}
+
+	private CreateUpdateProcedureCommand resolveProcedure(String userUpdateStr,
+			QueryMetadataInterface metadata) throws QueryParserException,
+			QueryResolverException, MetaMatrixComponentException,
+			QueryMetadataException {
+		ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr); 
+        QueryResolver.resolveCommand(userCommand, metadata);
+        metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(userCommand.getTemporaryMetadata()));
+        return (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
+	}
+
+	private void helpResolveException(String userUpdateStr, QueryMetadataInterface metadata, String msg) throws QueryParserException, MetaMatrixComponentException {
+		try {
+			helpResolve(userUpdateStr, metadata);
+		} catch (QueryResolverException e) {
+			assertEquals(msg, e.getMessage());
+		}
+	}
+
+	private CreateUpdateProcedureCommand helpResolve(String userUpdateStr, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+		return resolveProcedure(userUpdateStr, metadata);
+	}
+    
+    /**
+     *  Constants will now auto resolve if they are consistently representable in the target type
+     */
+    @Test public void testDefect23257() throws Exception{
+    	CreateUpdateProcedureCommand command = helpResolve("EXEC pm5.vsp59()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+        
+        CommandStatement cs = (CommandStatement)command.getBlock().getStatements().get(1);
+        
+        Insert insert = (Insert)cs.getCommand();
+        
+        assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType());
+    } 
+    
+    @Test public void testProcedureScoping() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        //note that this declare takes presedense over the proc INPUT.e1 and CHANGING.e1 variables
+        .append("\n  declare integer e1 = 1;") //$NON-NLS-1$
+        .append("\n  e1 = e1;") //$NON-NLS-1$
+        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+        .append("\n  BEGIN") //$NON-NLS-1$
+        //inside the scope of the loop, an unqualified e1 should resolve to the loop variable group
+        .append("\n    variables.e1 = convert(e1, integer);") //$NON-NLS-1$
+        .append("\n  END") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        CreateUpdateProcedureCommand command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        
+        Block block = command.getBlock();
+        
+        AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1);
+        assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getCanonicalName());
+        assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getValue()).getGroupSymbol().getCanonicalName());
+        
+        Block inner = ((LoopStatement)block.getStatements().get(2)).getBlock();
+        
+        assStmt = (AssignmentStatement)inner.getStatements().get(0);
+        
+        ElementSymbol value = ElementCollectorVisitor.getElements(assStmt.getValue(), false).iterator().next();
+        
+        assertEquals("LOOPCURSOR", value.getGroupSymbol().getCanonicalName()); //$NON-NLS-1$
+    }
+    
+	// variable resolution, variable used in if statement, variable compared against
+	// different datatype element
+    @Test public void testCreateUpdateProcedure4() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1);\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// variable resolution, variable used in if statement, invalid operation on variable
+    @Test public void testCreateUpdateProcedure5() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = var1 + var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 whwre var1 = var1+var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }    
+    
+	// variable resolution, variables declared in different blocks local variables
+	// should not override
+    @Test public void testCreateUpdateProcedure6() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable var1 was previously declared."); //$NON-NLS-1$
+    }
+    
+	// variable resolution, variables declared in different blocks local variables
+	// inner block using outer block variables
+    @Test public void testCreateUpdateProcedure7() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var2;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// variable resolution, variables declared in different blocks local variables
+	// outer block cannot use inner block variables
+    @Test public void testCreateUpdateProcedure8() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var2;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+        procedure = procedure + "var2 = 1\n";                 //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }     
+    
+	// variable resolution, variables declared in different blocks local variables
+	// should override, outer block variables still valid afetr inner block is declared
+    @Test public void testCreateUpdateProcedure9() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = var1 +1;\n";                 //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }    
+    
+	// special variable ROWS_UPDATED resolution
+    @Test public void testCreateUpdateProcedure10() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable ROWS_UPDATED used with declared variable
+    @Test public void testCreateUpdateProcedure11() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable INPUT used with declared variable
+    @Test public void testCreateUpdateProcedure12() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable CHANGING used with declared variable
+    @Test public void testCreateUpdateProcedure14() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(CHANGING.e1 = 'true')\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable CHANGING and INPUT used in compound criteria
+    @Test public void testCreateUpdateProcedure15() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(CHANGING.e1='false' and INPUT.e1=1)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable CHANGING and INPUT used in compound criteria, with declared variables
+    @Test public void testCreateUpdateProcedure16() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(CHANGING.e4 ='true' and INPUT.e2=1 or var1 < 30)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// special variable CHANGING compared against integer no implicit conversion available
+    @Test public void testCreateUpdateProcedure17() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "if(CHANGING.e4 = {d'2000-01-01'})\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0027 Message:The expressions in this criteria are being compared but are of differing types (boolean and date) and no implicit conversion is available:  CHANGING.e4 = {d'2000-01-01'}"); //$NON-NLS-1$
+    }       
+    
+	// virtual group elements used in procedure(HAS CRITERIA)
+    @Test public void testCreateUpdateProcedure18() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// virtual group elements used in procedure in if statement(HAS CRITERIA)
+    @Test public void testCreateUpdateProcedure19() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1))\n";                 //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }    
+    
+	// virtual group elements used in procedure(TRANSLATE CRITERIA)
+    @Test public void testCreateUpdateProcedure20() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// virtual group elements used in procedure(TRANSLATE CRITERIA)
+    @Test public void testCreateUpdateProcedure21() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using undefined variable should fail
+    @Test public void testCreateUpdateProcedure22() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+//        procedure = procedure + "DECLARE integer var1;\n";
+        procedure = procedure + "var3 = var2+var1;\n";         //$NON-NLS-1$
+        procedure = procedure + "var2 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using undefined variable declared is of invalid datatype
+    @Test public void testCreateUpdateProcedure23() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE struct var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using declare variable that has parts
+    @Test public void testCreateUpdateProcedure24() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var2.var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using declare variable is qualified
+    @Test public void testCreateUpdateProcedure26() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer VARIABLES.var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using declare variable is qualified but has more parts
+    @Test public void testCreateUpdateProcedure27() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer VARIABLES.var1.var2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using a variable that has not been declared in an assignment stmt
+    @Test public void testCreateUpdateProcedure28() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using a variable that has not been declared in an assignment stmt
+    @Test public void testCreateUpdateProcedure29() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = 1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using invalid function in assignment expr
+    @Test public void testCreateUpdateProcedure30() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Declare integer var1;\n";         //$NON-NLS-1$
+        procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }    
+    
+	// using invalid function in assignment expr
+    @Test public void testCreateUpdateProcedure31() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Declare integer var1;\n";         //$NON-NLS-1$
+        procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// using a variable being used inside a subcomand
+    @Test public void testCreateUpdateProcedure32() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select var1 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// variable resolution, variables declared in different blocks local variables
+	// should override, outer block variables still valid afetr inner block is declared
+	// fails as variable being compared against incorrect type
+    @Test public void testCreateUpdateProcedure33() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE timestamp var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = var1 +1;\n";                 //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// physical elements used on criteria of the if statement
+    @Test public void testCreateUpdateProcedure34() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol pm1.g1.e2 is specified with an unknown group context"); //$NON-NLS-1$
+    }
+    
+	// virtual elements used on criteria of the if statement
+    @Test public void testCreateUpdateProcedure35() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1) and var1=1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// physical elements used on criteria of the if statement
+    @Test public void testCreateUpdateProcedure36() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }          
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure37() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(TRANSLATE CRITERIA ON (vm1.g1.e1) WITH (vm1.g1.e1 = 1))\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// validating Translate CRITERIA, elements on it should be virtual group elements
+	// but can use variables
+    @Test public void testCreateUpdateProcedure38() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (pm1.g1.e2 = var1);\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// physical elements used on criteria of the if statement
+    @Test public void testCreateUpdateProcedure39() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure40() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1))\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure41() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure42() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// TranslateCriteria on criteria of the if statement
+    @Test public void testCreateUpdateProcedure43() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n";         //$NON-NLS-1$
+//        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n";
+//        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n";
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);
+
+        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+		Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
+        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+    }
+    
+	// special variable CHANGING compared against integer no implicit conversion available
+    @Test public void testCreateUpdateProcedure44() throws Exception {
+        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.INSERT_PROCEDURE);
+    }
+    
+	// special variable CHANGING compared against integer no implicit conversion available
+    @Test public void testCreateUpdateProcedure45() throws Exception {
+        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.INSERT_PROCEDURE, procedure);        
+        
+		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+		
+    	Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
+        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+    }
+    
+	// special variable CHANGING compared against integer no implicit conversion available
+    @Test public void testCreateUpdateProcedure46() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
+        
+        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);        
+        
+		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
+		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
+
+		Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
+        QueryResolver.resolveCommand(procCommand, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
+    }
+
+	// TranslateCriteria on criteria of the if statement
+	@Test public void testCreateUpdateProcedure47() throws Exception {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (vm1.g1.e1 = pm1.g1.e1);\n"; //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// validating Translate CRITERIA, elements(left elements on  on it should be virtual group elements
+	@Test public void testCreateUpdateProcedure48() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, INPUT.e2 = 2);\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving Translate CRITERIA, right element should be present on the command
+	@Test public void testCreateUpdateProcedure49() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = pm1.g2.e1);\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving criteria selector(on HAS CRITERIA), elements on it should be virtual group elements
+	@Test public void testCreateUpdateProcedure50() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.E1, vm1.g1.e1, INPUT.e1))\n";                 //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving Translate CRITERIA, right side expression in the translate criteria should be elements on the command
+	@Test public void testCreateUpdateProcedure51() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "var1=1;\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e2 = var1+vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// validating Translate CRITERIA, elements on it should be virtual group elements
+	// but can use variables, gut left exprs should always be virtual elements
+	@Test public void testCreateUpdateProcedure52() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (var1 = vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving AssignmentStatement, variable type and assigned type 
+	// do not match and no implicit conversion available
+	@Test public void testCreateUpdateProcedure53() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "var1 = INPUT.e4;"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+	
+	// resolving AssignmentStatement, variable type and assigned type 
+	// do not match, but implicit conversion available
+	@Test public void testCreateUpdateProcedure54() throws Exception {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "var1 = 1+1;"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}
+    
+	// resolving AssignmentStatement, variable type and assigned type 
+	// do not match, but implicit conversion available
+	@Test public void testCreateUpdateProcedure55() throws Exception {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+		procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+		procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
+		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+		procedure = procedure + "END\n"; //$NON-NLS-1$
+
+		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+	}	
+
+    // no user command provided - should throw resolver exception
+    @Test public void testCreateUpdateProcedure56() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        TestResolver.helpResolveException(procedure, FakeMetadataFactory.example1Cached(), "Error Code:ERR.015.008.0012 Message:Unable to resolve update procedure as the virtual group context is ambiguous."); //$NON-NLS-1$
+    }
+    
+    @Test public void testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
+        // Tests that the function params are resolved before the function for assignment statements
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = badFunction(badElement);"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"badElement\" is not defined by any relevant group."); //$NON-NLS-1$
+    }
+    
+	// addresses Cases 4624.  Before change to UpdateProcedureResolver,
+    // this case failed with assertion exception.
+    @Test public void testCase4624() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "VARIABLES.ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = {b'false'};\n"; //$NON-NLS-1$
+        procedure = procedure + "IF(var1 = {b 'true'})\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "SELECT Rack_ID, RACK_MDT_TYPE INTO #racks FROM Bert_MAP.BERT3.RACK;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: Bert_MAP.BERT3.RACK"); //$NON-NLS-1$
+    }
+
+	// addresses Cases 5474.  
+    @Test public void testCase5474() throws Exception {
+        String procedure = "CREATE VIRTUAL PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer VARIABLES.NLEVELS;\n"; //$NON-NLS-1$
+        procedure = procedure + "VARIABLES.NLEVELS = SELECT COUNT(*) FROM (SELECT oi.e1 AS Col1, oi.e2 AS Col2, oi.e3 FROM pm1.g2 AS oi) AS TOBJ, pm2.g2 AS TModel WHERE TModel.e3 = TOBJ.e3;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
+    }
+    
+    @Test public void testIssue174102() throws Exception {
+        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE string crit = 'WHERE pm1.sq2.in = \"test\"';\n"; //$NON-NLS-1$
+        procedure = procedure + "CREATE LOCAL TEMPORARY TABLE #TTable (e1 string);"; //$NON-NLS-1$
+        procedure = procedure + "EXECUTE STRING ('SELECT e1 FROM pm1.sq2 ' || crit ) AS e1 string INTO #TTable;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        TestResolver.helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
+    }
+    
+    // Address Issue 174519.
+    // Expected result is resolver failure, but with different error.
+    @Test public void testIssue174519() throws Exception {
+        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE string VARIABLES.l_in = pm1.sq1.in;\n"; //$NON-NLS-1$
+        procedure = procedure + "INSERT INTO #temp \n"; //$NON-NLS-1$
+        procedure = procedure + "SELECT pm1.sq3.e1 FROM pm1.sq3 WHERE pm1.sq3.in = VARIABLES.l_in;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
+        helpResolveException("EXEC pm1.sq1(1)", metadata, "Error Code:ERR.015.008.0010 Message:INSERT statement must have the same number of elements and values specified.  This statement has 0 elements and 0 values."); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+	/*@Test public void testCommandUpdatingCountFromLastStatement() throws Exception {
+        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "declare integer x = convert(pm1.sq1.in, integer) + 5;\n"; //$NON-NLS-1$
+        procedure = procedure + "insert into pm1.g1 values (null, null, null, null);"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
+        Command command = helpResolve(helpParse("exec pm1.sq1(1)"), metadata, null); //$NON-NLS-1$
+        
+        assertEquals(1, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
+	}*/
+
+    //baseline test to ensure that a declare assignment cannot contain the declared variable
+    @Test public void testDeclareStatement() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer VARIABLES.var1 = VARIABLES.var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    @Test public void testDynamicIntoInProc() throws Exception {
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2' as e1 string, e2 string, e3 string, e4 string INTO #myTempTable;\n") //$NON-NLS-1$
+                                .append("select e1 from #myTempTable;\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    @Test public void testDynamicStatement() throws Exception {
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2';\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    @Test public void testDynamicStatementType() {
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("DECLARE object VARIABLES.X = null;\n") //$NON-NLS-1$
+                                .append("execute string VARIABLES.X;\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpFailUpdateProcedure(procedure.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+
+	// variable resolution
+    @Test public void testCreateUpdateProcedure1() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+	// variable resolution, variable used in if statement
+    @Test public void testCreateUpdateProcedure3() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpResolveUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+
+    @Test public void testSelectIntoInProc() throws Exception {
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                            .append("BEGIN\n") //$NON-NLS-1$
+                                            .append("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2;\n") //$NON-NLS-1$
+                                            .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                            .append("END\n"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        
+        procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g2;\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+
+    @Test public void testSelectIntoInProcNoFrom() throws Exception {
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                            .append("BEGIN\n") //$NON-NLS-1$
+                                            .append("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1;\n") //$NON-NLS-1$
+                                            .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                            .append("END\n"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        
+        procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+                                .append("BEGIN\n") //$NON-NLS-1$
+                                .append("SELECT 'a', 19, {b'true'}, 13.999 INTO #myTempTable;\n") //$NON-NLS-1$
+                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
+                                .append("END\n"); //$NON-NLS-1$
+        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    /*@Test public void testCommandUpdating3() throws Exception{
+        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
+        .append("BEGIN\n") //$NON-NLS-1$
+        .append("INSERT INTO pm1.g1 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
+        .append("ROWS_UPDATED = INSERT INTO pm1.g2 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
+        .append("END\n"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        Command command = helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
+                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
+        assertEquals(2, command.updatingModelCount(metadata));
+    }*/
+
+    /*@Test public void testCommandUpdatingCount6() throws Exception{
+        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
+        procedure = procedure + "INSERT INTO pm1.g1 (e2) VALUES (Input.e2);\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n";         //$NON-NLS-1$
+
+        String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
+        
+        Command command = helpResolveUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.INSERT_PROCEDURE);
+        assertEquals(2, command.updatingModelCount(metadata));
+    }*/
+    
+    // variable declared is of special type ROWS_RETURNED
+    @Test public void testDeclareRowsUpdated() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer rows_updated;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable rows_updated was previously declared."); //$NON-NLS-1$
+    }
+    
+    // validating INPUT element assigned
+    @Test public void testAssignInput() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "INPUT.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"INPUT.e1\" cannot be assigned a value.  Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
+    }
+    
+    // validating CHANGING element assigned
+    @Test public void testAssignChanging() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "CHANGING.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"CHANGING.e1\" cannot be assigned a value.  Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
+    }
+    
+    // variables cannot be used among insert elements
+    @Test public void testVariableInInsert() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, var1) values (1, 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userQuery, 
+                FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'var1': Element \"var1\" is not defined by any relevant group.]"); //$NON-NLS-1$
+    }
+    
+    // variables cannot be used among insert elements
+    @Test public void testVariableInInsert2() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, INPUT.x) values (1, 2);\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+        helpFailUpdateProcedure(procedure, userQuery, 
+                FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'INPUT.x': Symbol INPUT.x is specified with an unknown group context]"); //$NON-NLS-1$
+    }
+    
+    //should resolve first to the table's column
+    @Test public void testVariableInInsert3() throws Exception {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "DECLARE integer e2;\n"; //$NON-NLS-1$
+        procedure = procedure + "Insert into pm1.g1 (e2) values (1);\n"; //$NON-NLS-1$
+        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
+
+        helpResolveUpdateProcedure(procedure, userQuery, 
+                FakeMetadataObject.Props.UPDATE_PROCEDURE); 
+    }
+    
+    @Test public void testAmbigousInput() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
+        procedure = procedure + "select e1;\n"; //$NON-NLS-1$
+        procedure = procedure + "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(procedure, userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"e1\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
+    }
+    
+    @Test public void testLoopRedefinition() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  declare string var1;") //$NON-NLS-1$
+        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+        .append("\n  BEGIN") //$NON-NLS-1$
+        .append("\n    LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor") //$NON-NLS-1$
+        .append("\n    BEGIN") //$NON-NLS-1$
+        .append("\n      var1 = CONCAT(var1, CONCAT(' ', loopCursor.e1));") //$NON-NLS-1$
+        .append("\n    END") //$NON-NLS-1$
+        .append("\n  END") //$NON-NLS-1$
+        .append("\n  END"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$
+    }
+    
+    @Test public void testTempGroupElementShouldNotBeResolable() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  select 1 as a into #temp;") //$NON-NLS-1$
+        .append("\n  select #temp.a from pm1.g1;") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
+    }
+    
+    @Test public void testTempGroupElementShouldNotBeResolable1() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  select 1 as a into #temp;") //$NON-NLS-1$
+        .append("\n  insert into #temp (a) values (#temp.a);") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
+                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
+    }
+    
+    @Test public void testProcedureCreate() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
+        .append("\n  select e1 from t1;") //$NON-NLS-1$
+        .append("\n  create local temporary table t1 (e1 string, e2 integer);") //$NON-NLS-1$
+        .append("\n  select e2 from t1;") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
+    }
+    
+    /**
+     * it is not ok to redefine the loopCursor 
+     */
+    @Test public void testProcedureCreate1() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
+        .append("\n  BEGIN") //$NON-NLS-1$
+        .append("\n  create local temporary table loopCursor (e1 string);") //$NON-NLS-1$
+        .append("\nEND") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Cannot create temporary table \"loopCursor\". A table with the same name already exists."); //$NON-NLS-1$
+    }
+    
+    @Test public void testProcedureCreateDrop() {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n drop table t1;") //$NON-NLS-1$
+        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: t1"); //$NON-NLS-1$
+    }
+    
+    @Test public void testProcedureCreateDrop1() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
+        .append("\n  drop table t1;") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
+    }
+    
+    @Test public void testCreateAfterImplicitTempTable() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  select e1 into #temp from pm1.g1;") //$NON-NLS-1$
+        .append("\n  create local temporary table #temp (e1 string);") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
+    }
+    
+    @Test public void testInsertAfterCreate() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  create local temporary table #temp (e1 string, e2 string);") //$NON-NLS-1$
+        .append("\n  insert into #temp (e1) values ('a');") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
+    }
+    
+	/**
+	 * delete procedures should not reference input or changing vars.
+	 */
+	@Test public void testDefect16451() {
+		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure += "BEGIN\n"; //$NON-NLS-1$
+        procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = input.e1;\n"; //$NON-NLS-1$
+        procedure += "ROWS_UPDATED = 0;"; //$NON-NLS-1$
+        procedure += "END\n"; //$NON-NLS-1$
+        
+        String userUpdateStr = "delete from vm1.g1 where e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+									 FakeMetadataObject.Props.DELETE_PROCEDURE, "Symbol input.e1 is specified with an unknown group context"); //$NON-NLS-1$
+	}
+	
+    @Test public void testInvalidVirtualProcedure3() throws Exception {
+    	helpResolveException("EXEC pm1.vsp18()", FakeMetadataFactory.example1Cached(), "Group does not exist: temptable"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+    // variable resolution, variable compared against
+    // different datatype element for which there is no implicit transformation)
+    @Test public void testCreateUpdateProcedure2() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure += "BEGIN\n"; //$NON-NLS-1$
+        procedure += "DECLARE boolean var1;\n"; //$NON-NLS-1$
+        procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e4 = convert(var1, string), pm1.g1.e1 = var1;\n"; //$NON-NLS-1$
+        procedure += "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+				 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e4' with expected type double to expression 'convert(var1, string)'"); //$NON-NLS-1$
+    }
+    
+    // special variable INPUT compared against invalid type
+    @Test public void testInvalidInputInUpdate() {
+        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
+        procedure += "BEGIN\n"; //$NON-NLS-1$
+        procedure += "DECLARE integer var1;\n"; //$NON-NLS-1$
+        procedure += "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
+        procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e1;\n"; //$NON-NLS-1$
+        procedure += "END\n"; //$NON-NLS-1$
+
+        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
+        
+		helpFailUpdateProcedure(procedure, userUpdateStr,
+				 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e2' with expected type integer to expression 'INPUT.e1'"); //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedure() throws Exception {
+        helpResolve("EXEC pm1.vsp1()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedure2() throws Exception {
+        helpResolve("EXEC pm1.vsp14()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedurePartialParameterReference() throws Exception {
+        helpResolve("EXEC pm1.vsp58(5)", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+    }
+    
+    //cursor starts with "#" Defect14924
+    @Test public void testVirtualProcedureInvalid1() throws Exception {
+    	helpResolveException("EXEC pm1.vsp32()",FakeMetadataFactory.example1Cached(), "Cursor names cannot begin with \"#\" as that indicates the name of a temporary table: #mycursor.");   //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+    @Test public void testVirtualProcedureWithOrderBy() throws Exception {
+        helpResolve("EXEC pm1.vsp29()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedureWithTempTableAndOrderBy() throws Exception {
+        helpResolve("EXEC pm1.vsp33()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedureWithConstAndOrderBy() throws Exception {
+        helpResolve("EXEC pm1.vsp34()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testVirtualProcedureWithNoFromAndOrderBy() throws Exception {
+        helpResolve("EXEC pm1.vsp28()", FakeMetadataFactory.example1Cached());   //$NON-NLS-1$
+    }
+    
+    @Test public void testInvalidVirtualProcedure2() throws Exception {
+        helpResolveException("EXEC pm1.vsp12()", FakeMetadataFactory.example1Cached(), "Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+    @Test public void testLoopRedefinition2() throws Exception {
+        helpResolveException("EXEC pm1.vsp11()", FakeMetadataFactory.example1Cached(), "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+        
+    @Test public void testVariableResolutionWithIntervening() throws Exception {
+        StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
+        .append("\nBEGIN") //$NON-NLS-1$
+        .append("\n  declare string x;") //$NON-NLS-1$
+        .append("\n  x = '1';") //$NON-NLS-1$
+        .append("\n  declare string y;") //$NON-NLS-1$
+        .append("\n  y = '1';") //$NON-NLS-1$
+        .append("\nEND"); //$NON-NLS-1$
+        
+        TestResolver.helpResolve(proc.toString(), FakeMetadataFactory.example1Cached(), null); 
+    }
+    
+}


Property changes on: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,6 +22,8 @@
 
 package com.metamatrix.query.resolver;
 
+import static org.junit.Assert.*;
+
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.Date;
@@ -38,17 +40,13 @@
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
-
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
 import com.metamatrix.api.exception.query.QueryResolverException;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.dqp.message.ParameterInfo;
 import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.analysis.QueryAnnotation;
 import com.metamatrix.query.function.FunctionDescriptor;
 import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.function.FunctionLibraryManager;
@@ -59,7 +57,6 @@
 import com.metamatrix.query.metadata.TempMetadataStore;
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.util.BindVariableVisitor;
-import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.ProcedureReservedWords;
 import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
@@ -69,7 +66,6 @@
 import com.metamatrix.query.sql.lang.From;
 import com.metamatrix.query.sql.lang.Insert;
 import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.SPParameter;
 import com.metamatrix.query.sql.lang.Select;
@@ -80,11 +76,8 @@
 import com.metamatrix.query.sql.lang.SubquerySetCriteria;
 import com.metamatrix.query.sql.lang.Update;
 import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
 import com.metamatrix.query.sql.proc.CommandStatement;
 import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.LoopStatement;
 import com.metamatrix.query.sql.symbol.Constant;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.symbol.Expression;
@@ -120,46 +113,7 @@
             throw new RuntimeException(e);
         }
 	}
-    
-    public static Map getProcedureExternalMetadata(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
-    throws QueryMetadataException, MetaMatrixComponentException {
-        Map externalMetadata = new HashMap();
-
-        // Look up elements for the virtual group
-        List elements = ResolverUtil.resolveElementsInGroup(virtualGroup, metadata);
-        // virtual group metadata info
-        externalMetadata.put(virtualGroup, elements);
-
-        // INPUT group metadata info
-        GroupSymbol inputGroup = new GroupSymbol(ProcedureReservedWords.INPUT);
-        List inputElments = new ArrayList(elements.size());
-        List elementIds = new ArrayList();
-        for(int i=0; i<elements.size(); i++) {
-            ElementSymbol virtualElmnt = (ElementSymbol)elements.get(i);
-            ElementSymbol inputElement = (ElementSymbol)virtualElmnt.clone();
-            inputElments.add(inputElement);
-            elementIds.add(new TempMetadataID(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + virtualElmnt.getShortName(), virtualElmnt.getType()));
-        }
-        inputGroup.setMetadataID(new TempMetadataID(ProcedureReservedWords.INPUT, elementIds));
-        externalMetadata.put(inputGroup, inputElments);
-
-        // CHANGING group metadata info
-        // Switch type to be boolean for all CHANGING variables
-        GroupSymbol changeGroup = new GroupSymbol(ProcedureReservedWords.CHANGING);
-        List changingElments = new ArrayList(elements.size());
-        elementIds = new ArrayList();
-        for(int i=0; i<elements.size(); i++) {
-            ElementSymbol changeElement = (ElementSymbol)((ElementSymbol)elements.get(i)).clone();
-            changeElement.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
-            changingElments.add(changeElement);
-            elementIds.add(new TempMetadataID(ProcedureReservedWords.INPUT + ElementSymbol.SEPARATOR + changeElement.getShortName(), changeElement.getType()));
-        }
-        changeGroup.setMetadataID(new TempMetadataID(ProcedureReservedWords.CHANGING, elementIds));
-        externalMetadata.put(changeGroup, changingElments);
-
-        return externalMetadata;
-    }
-	
+    	
     /**
      * Helps resolve command, then check that the actual resolved Elements variables are the same as
      * the expected variable names.  The variableNames param will be empty unless the subquery
@@ -209,39 +163,6 @@
 		return helpResolve(helpParse(sql));
 	}
 	
-	private Command helpResolveUpdateProcedure(String procedure, String userUpdateStr, String procedureType) {
-        metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
-
-        return helpResolve(userUpdateStr, metadata, AnalysisRecord.createNonRecordingRecord());
-    }
-	
-    private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType) {
-        helpFailUpdateProcedure(procedure, userUpdateStr, procedureType, null);
-    }
-    
-	private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType, String msg) {
-        metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
-
-        Command userCommand;
-		try {
-			userCommand = QueryParser.getQueryParser().parseCommand(userUpdateStr);
-		} catch (QueryParserException e) {
-			throw new RuntimeException(e);
-		}
-
-        // resolve
-        try {
-            QueryResolver.resolveCommand(userCommand, metadata);
-            fail("Expected a QueryResolverException but got none."); //$NON-NLS-1$
-        } catch(QueryResolverException ex) {
-        	if (msg != null) {
-                assertEquals(msg, ex.getMessage());
-            }
-        } catch (MetaMatrixComponentException e) {
-        	throw new RuntimeException(e);
-		} 
-	}	
-
     private Command helpResolve(Command command) {    
         return helpResolve(command, this.metadata, AnalysisRecord.createNonRecordingRecord());  
     }	
@@ -1052,7 +973,7 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
         
-        QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
 
         // Verify results        
         helpCheckFrom((Query)command, new String[] { "pm1.g1" });         //$NON-NLS-1$
@@ -1072,7 +993,7 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
                     
-        QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
 
         // Verify results        
         helpCheckFrom((Query)command, new String[] { "pm1.g1" });         //$NON-NLS-1$
@@ -1092,7 +1013,7 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
 
-        QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
 
         // Verify results
         Collection vars = getVariables(command);
@@ -1113,7 +1034,7 @@
             Map externalMetadata = new HashMap();
             externalMetadata.put(sqGroup, sqParams);
 
-            QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
+            QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
             
             fail("Expected exception on invalid variable pm1.sq2.in"); //$NON-NLS-1$
         } catch(QueryResolverException e) {
@@ -1416,949 +1337,7 @@
 
         helpResolve(sql);
 	}	
-
-	// variable resolution
-    @Test public void testCreateUpdateProcedure1() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
     
-	// variable resolution, variable used in if statement
-    @Test public void testCreateUpdateProcedure3() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable resolution, variable used in if statement, variable comapred against
-	// differrent datatype element
-    @Test public void testCreateUpdateProcedure4() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1);\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable resolution, variable used in if statement, invalid operation on variable
-    @Test public void testCreateUpdateProcedure5() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = var1 + var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 whwre var1 = var1+var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }    
-    
-	// variable resolution, variables declared in different blocks local variables
-	// should not override
-    @Test public void testCreateUpdateProcedure6() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable var1 was previously declared."); //$NON-NLS-1$
-    }
-    
-	// variable resolution, variables declared in different blocks local variables
-	// inner block using outer block variables
-    @Test public void testCreateUpdateProcedure7() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var2;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable resolution, variables declared in differrent blocks local variables
-	// outer block cannot use inner block variables
-    @Test public void testCreateUpdateProcedure8() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var2;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-        procedure = procedure + "var2 = 1\n";                 //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }     
-    
-	// variable resolution, variables declared in differrent blocks local variables
-	// should override, outer block variables still valid afetr inner block is declared
-    @Test public void testCreateUpdateProcedure9() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e3;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = var1 +1;\n";                 //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }    
-    
-	// special variable ROWS_UPDATED resolution
-    @Test public void testCreateUpdateProcedure10() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED = ROWS_UPDATED + var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable ROWS_UPDATED used with declared variable
-    @Test public void testCreateUpdateProcedure11() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable INPUT used with declared variable
-    @Test public void testCreateUpdateProcedure12() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable CHANGING used with declared variable
-    @Test public void testCreateUpdateProcedure14() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(CHANGING.e1 = 'true')\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable CHANGING and INPUT used in conpound criteria
-    @Test public void testCreateUpdateProcedure15() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(CHANGING.e1='false' and INPUT.e1=1)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable CHANGING and INPUT used in conpound criteria, with declared variables
-    @Test public void testCreateUpdateProcedure16() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(CHANGING.e4 ='true' and INPUT.e2=1 or var1 < 30)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// special variable CHANGING compared against integer no implicit conversion available
-    @Test public void testCreateUpdateProcedure17() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "if(CHANGING.e4 = {d'2000-01-01'})\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0027 Message:The expressions in this criteria are being compared but are of differing types (boolean and date) and no implicit conversion is available:  CHANGING.e4 = {d'2000-01-01'}"); //$NON-NLS-1$
-    }       
-    
-	// virtual group elements used in procedure(HAS CRITERIA)
-    @Test public void testCreateUpdateProcedure18() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// virtual group elements used in procedure in if statement(HAS CRITERIA)
-    @Test public void testCreateUpdateProcedure19() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1))\n";                 //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where HAS CRITERIA ON (vm1.g1.e1, vm1.g1.e1);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }    
-    
-	// virtual group elements used in procedure(TRANSLATE CRITERIA)
-    @Test public void testCreateUpdateProcedure20() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// virtual group elements used in procedure(TRANSLATE CRITERIA)
-    @Test public void testCreateUpdateProcedure21() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using undefined variable should fail
-    @Test public void testCreateUpdateProcedure22() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-//        procedure = procedure + "DECLARE integer var1;\n";
-        procedure = procedure + "var3 = var2+var1;\n";         //$NON-NLS-1$
-        procedure = procedure + "var2 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using undefined variable declared is of invalid datatype
-    @Test public void testCreateUpdateProcedure23() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE struct var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = 'x', pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using declare variable that has parts
-    @Test public void testCreateUpdateProcedure24() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var2.var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using declare variable is qualified
-    @Test public void testCreateUpdateProcedure26() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer VARIABLES.var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using declare variable is qualified but has more parts
-    @Test public void testCreateUpdateProcedure27() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer VARIABLES.var1.var2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using a variable that has not been declared in an assignment stmt
-    @Test public void testCreateUpdateProcedure28() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using a variable that has not been declared in an assignment stmt
-    @Test public void testCreateUpdateProcedure29() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = 1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using invalid function in assignment expr
-    @Test public void testCreateUpdateProcedure30() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Declare integer var1;\n";         //$NON-NLS-1$
-        procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }    
-    
-	// using invalid function in assignment expr
-    @Test public void testCreateUpdateProcedure31() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Declare integer var1;\n";         //$NON-NLS-1$
-        procedure = procedure + "var1 = 'x' + ROWS_UPDATED;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// using a variable being used inside a subcomand
-    @Test public void testCreateUpdateProcedure32() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Declare integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select var1 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// variable resolution, variables declared in differrent blocks local variables
-	// should override, outer block variables still valid afetr inner block is declared
-	// fails as variable being compared against incorrect type
-    @Test public void testCreateUpdateProcedure33() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(var1 =1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE timestamp var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where var1 = pm1.g1.e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = var1 +1;\n";                 //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// physical elements used on criteria of the if statement
-    @Test public void testCreateUpdateProcedure34() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol pm1.g1.e2 is specified with an unknown group context"); //$NON-NLS-1$
-    }
-    
-	// virtual elements used on criteria of the if statement
-    @Test public void testCreateUpdateProcedure35() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.e1) and var1=1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// physical elements used on criteria of the if statement
-    @Test public void testCreateUpdateProcedure36() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }          
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure37() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(TRANSLATE CRITERIA ON (vm1.g1.e1) WITH (vm1.g1.e1 = 1))\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// validating Translate CRITERIA, elements on it should be virtual group elements
-	// but can use variables
-    @Test public void testCreateUpdateProcedure38() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (pm1.g1.e2 = var1);\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// physical elements used on criteria of the if statement
-    @Test public void testCreateUpdateProcedure39() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(pm1.g1.e2 =1 and var1=1)\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure40() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1))\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure41() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure42() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-	// TranslateCriteria on criteria of the if statement
-    @Test public void testCreateUpdateProcedure43() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (g1.e1 = 1);\n";         //$NON-NLS-1$
-//        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n";
-//        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n";
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        
-        metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);
-
-        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
-		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
-		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
-		Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
-        QueryResolver.resolveCommand(procCommand, externalMetadata, true, metadata, AnalysisRecord.createNonRecordingRecord());
-    }
-    
-	// special variable CHANGING compared against integer no implicit conversion available
-    @Test public void testCreateUpdateProcedure44() {
-        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.INSERT_PROCEDURE);
-    }
-    
-	// special variable CHANGING compared against integer no implicit conversion available
-    @Test public void testCreateUpdateProcedure45() throws Exception {
-        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
-        
-        metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.INSERT_PROCEDURE, procedure);        
-        
-		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
-		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
-		
-    	Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
-        QueryResolver.resolveCommand(procCommand, externalMetadata, true, metadata, AnalysisRecord.createNonRecordingRecord());
-    }
-    
-	// special variable CHANGING compared against integer no implicit conversion available
-    @Test public void testCreateUpdateProcedure46() throws Exception {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        Command procCommand = QueryParser.getQueryParser().parseCommand(procedure);
-        
-        metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure);        
-        
-		GroupSymbol virtualGroup = new GroupSymbol("vm1.g1"); //$NON-NLS-1$
-		virtualGroup.setMetadataID(metadata.getGroupID("vm1.g1")); //$NON-NLS-1$
-
-		Map externalMetadata = getProcedureExternalMetadata(virtualGroup, metadata);        	
-        QueryResolver.resolveCommand(procCommand, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
-    }
-
-	// TranslateCriteria on criteria of the if statement
-	@Test public void testCreateUpdateProcedure47() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "if(HAS CRITERIA ON (e1))\n"; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e2 from pm1.g1 where TRANSLATE CRITERIA ON (e1) WITH (vm1.g1.e1 = pm1.g1.e1);\n"; //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// validating Translate CRITERIA, elements(left elements on  on it should be virtual group elements
-	@Test public void testCreateUpdateProcedure48() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = 1, INPUT.e2 = 2);\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving Translate CRITERIA, right element should be present on the command
-	@Test public void testCreateUpdateProcedure49() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e1 = pm1.g2.e1);\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving criteria selector(on HAS CRITERIA), elements on it should be virtual group elements
-	@Test public void testCreateUpdateProcedure50() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "if(HAS CRITERIA ON (vm1.g1.E1, vm1.g1.e1, INPUT.e1))\n";                 //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving Translate CRITERIA, right side expression in the translate criteria should be elements on the command
-	@Test public void testCreateUpdateProcedure51() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "var1=1;\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (vm1.g1.e2 = var1+vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// validating Translate CRITERIA, elements on it should be virtual group elements
-	// but can use variables, gut left exprs should always be virtual elements
-	@Test public void testCreateUpdateProcedure52() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "Select pm1.g1.e1 from pm1.g1 where Translate CRITERIA WITH (var1 = vm1.g1.e2, vm1.g1.e1 = 2);\n"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving AssignmentStatement, variable type and assigned type 
-	// do not match and no implicit conversion available
-	@Test public void testCreateUpdateProcedure53() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "var1 = INPUT.e4;"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-	
-	// resolving AssignmentStatement, variable type and assigned type 
-	// do not match, but implicit conversion available
-	@Test public void testCreateUpdateProcedure54() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "var1 = 1+1;"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}
-    
-	// resolving AssignmentStatement, variable type and assigned type 
-	// do not match, but implicit conversion available
-	@Test public void testCreateUpdateProcedure55() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-		procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
-		procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
-		procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-		procedure = procedure + "END\n"; //$NON-NLS-1$
-
-		String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpResolveUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.UPDATE_PROCEDURE);
-	}	
-
-    // no user command provided - should throw resolver exception
-    @Test public void testCreateUpdateProcedure56() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = 1+ROWS_UPDATED;"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        helpResolveException(procedure, FakeMetadataFactory.example1Cached(), "Error Code:ERR.015.008.0012 Message:Unable to resolve update procedure as the virtual group context is ambiguous."); //$NON-NLS-1$
-    }
-    
-    @Test public void testDefect14912_CreateUpdateProcedure57_FunctionWithElementParamInAssignmentStatement() {
-        // Tests that the function params are resolved before the function for assignment statements
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = badFunction(badElement);"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"badElement\" is not defined by any relevant group."); //$NON-NLS-1$
-    }
-    
-	// addresses Cases 4624.  Before change to UpdateProcedureResolver,
-    // this case failed with assertion exception.
-    @Test public void testCase4624() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "VARIABLES.ROWS_UPDATED = 0;\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "var1 = {b'false'};\n"; //$NON-NLS-1$
-        procedure = procedure + "IF(var1 = {b 'true'})\n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "SELECT Rack_ID, RACK_MDT_TYPE INTO #racks FROM Bert_MAP.BERT3.RACK;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userCommand, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: Bert_MAP.BERT3.RACK"); //$NON-NLS-1$
-    }
-
-	// addresses Cases 5474.  
-    @Test public void testCase5474() {
-        String procedure = "CREATE VIRTUAL PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer VARIABLES.NLEVELS;\n"; //$NON-NLS-1$
-        procedure = procedure + "VARIABLES.NLEVELS = SELECT COUNT(*) FROM (SELECT oi.e1 AS Col1, oi.e2 AS Col2, oi.e3 FROM pm1.g2 AS oi) AS TOBJ, pm2.g2 AS TModel WHERE TModel.e3 = TOBJ.e3;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
-    }
-    
-    @Test public void testIssue174102() throws Exception {
-        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE string crit = 'WHERE pm1.sq2.in = \"test\"';\n"; //$NON-NLS-1$
-        procedure = procedure + "CREATE LOCAL TEMPORARY TABLE #TTable (e1 string);"; //$NON-NLS-1$
-        procedure = procedure + "EXECUTE STRING ('SELECT e1 FROM pm1.sq2 ' || crit ) AS e1 string INTO #TTable;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        helpResolve(procedure, FakeMetadataFactory.example1Cached(), null);
-    }
-    
-    // Address Issue 174519.
-    // Expected result is resolver failure, but with different error.
-    @Test public void testIssue174519() {
-        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE string VARIABLES.l_in = pm1.sq1.in;\n"; //$NON-NLS-1$
-        procedure = procedure + "INSERT INTO #temp \n"; //$NON-NLS-1$
-        procedure = procedure + "SELECT pm1.sq3.e1 FROM pm1.sq3 WHERE pm1.sq3.in = VARIABLES.l_in;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
-        helpResolveException("EXEC pm1.sq1(1)", metadata, "Error Code:ERR.015.008.0010 Message:INSERT statement must have the same number of elements and values specified.  This statement has 0 elements and 0 values."); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
- 	private QueryMetadataInterface exampleStoredProcedure(String procedure) {
-		FakeMetadataFacade metadata = FakeMetadataFactory.example1();
-        
-        FakeMetadataObject pm1 = metadata.getStore().findObject("pm1",FakeMetadataObject.MODEL); //$NON-NLS-1$
-        FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
-        FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2);  //$NON-NLS-1$
-        FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null);  //$NON-NLS-1$
-        QueryNode sq2n1 = new QueryNode("pm1.sq1", procedure); //$NON-NLS-1$ 
-        FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1);  //$NON-NLS-1$
-
-        metadata.getStore().addObject(rs2);
-        metadata.getStore().addObject(sq1);
-        
-        return metadata;
-	}
-    
     @Test public void testIsXMLQuery1() throws Exception {
         helpTestIsXMLQuery("SELECT * FROM pm1.g1", false);     //$NON-NLS-1$
     }
@@ -2508,7 +1487,7 @@
         e1.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
                
         // Expected right expression
-        Constant e2 = new Constant(new TimestampUtil().createDate(96, 0, 31), DataTypeManager.DefaultDataClasses.DATE);
+        Constant e2 = new Constant(TimestampUtil.createDate(96, 0, 31), DataTypeManager.DefaultDataClasses.DATE);
         Function f1 = new Function("convert", new Expression[] { e2, new Constant(DataTypeManager.DefaultDataTypes.TIMESTAMP)}); //$NON-NLS-1$
         f1.makeImplicit();
                
@@ -2526,20 +1505,7 @@
         
     @Test public void testFailedConversion_defect9725() throws Exception{
     	helpResolveException("select * from pm3.g1 where pm3.g1.e4 > {b 'true'}", "Error Code:ERR.015.008.0027 Message:The expressions in this criteria are being compared but are of differing types (timestamp and boolean) and no implicit conversion is available:  pm3.g1.e4 > TRUE"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    /**
-     *  Constants will now auto resolve if they are consistently representable in the target type
-     */
-    @Test public void testDefect23257() throws Exception{
-    	StoredProcedure command = (StoredProcedure)helpResolve("EXEC pm5.vsp59()"); //$NON-NLS-1$
-        
-        CommandStatement cs = (CommandStatement)((CreateUpdateProcedureCommand)command.getSubCommand()).getBlock().getStatements().get(1);
-        
-        Insert insert = (Insert)cs.getCommand();
-        
-        assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression)insert.getValues().get(1)).getType());
-    }  
+    } 
             
     @Test public void testLookupFunction() {     
         String sql = "SELECT lookup('pm1.g1', 'e1', 'e2', e2) AS x, lookup('pm1.g1', 'e4', 'e3', e3) AS y FROM pm1.g1"; //$NON-NLS-1$
@@ -2627,39 +1593,6 @@
         assertEquals("Did not match expected criteria", expected, actual); //$NON-NLS-1$
     }    
     
-    @Test public void testVirtualProcedure(){
-        helpResolve("EXEC pm1.vsp1()");   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedure2(){
-        helpResolve("EXEC pm1.vsp14()");   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedurePartialParameterReference() {
-        helpResolve("EXEC pm1.vsp58(5)"); //$NON-NLS-1$
-    }
-    
-    //cursor starts with "#" Defect14924
-    @Test public void testVirtualProcedureInvalid1(){
-    	helpResolveException("EXEC pm1.vsp32()","Cursor names cannot begin with \"#\" as that indicates the name of a temporary table: #mycursor.");   //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    @Test public void testVirtualProcedureWithOrderBy() {
-        helpResolve("EXEC pm1.vsp29()");   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedureWithTempTableAndOrderBy() {
-        helpResolve("EXEC pm1.vsp33()");   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedureWithConstAndOrderBy() {
-        helpResolve("EXEC pm1.vsp34()");   //$NON-NLS-1$
-    }
-    
-    @Test public void testVirtualProcedureWithNoFromAndOrderBy() {
-        helpResolve("EXEC pm1.vsp28()");   //$NON-NLS-1$
-    }
-
     /** select e1 from pm1.g1 where e2 BETWEEN 1000 AND 2000 */
     @Test public void testBetween1(){
         String sql = "select e1 from pm1.g1 where e2 BETWEEN 1000 AND 2000"; //$NON-NLS-1$
@@ -3107,53 +2040,7 @@
             example_12968(), AnalysisRecord.createNonRecordingRecord());
     }
 
-    @Test public void testDefect13029_CorrectlySetUpdateProcedureTempGroupIDs() {
-        StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
-            .append("\nBEGIN") //$NON-NLS-1$
-            .append("\nDECLARE string var1;") //$NON-NLS-1$
-            .append("\nvar1 = '';") //$NON-NLS-1$
-            .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
-            .append("\n  BEGIN") //$NON-NLS-1$
-            .append("\n    LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor2") //$NON-NLS-1$
-            .append("\n    BEGIN") //$NON-NLS-1$
-            .append("\n      var1 = CONCAT(var1, CONCAT(' ', loopCursor2.e1));") //$NON-NLS-1$
-            .append("\n    END") //$NON-NLS-1$
-            .append("\n  END") //$NON-NLS-1$
-            .append("\nEND"); //$NON-NLS-1$
-            
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, proc.toString());
 
-        // parse
-        Command userCommand = helpParse(userUpdateStr);
-
-        // resolve
-        try {
-            QueryResolver.resolveCommand(userCommand, metadata);
-        } catch(MetaMatrixException e) {
-            fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage());     //$NON-NLS-1$ //$NON-NLS-2$
-        }
-        
-        Command command = ((ProcedureContainer)userCommand).getSubCommand();
-        Map tempIDs = command.getTemporaryMetadata();
-        assertNotNull(tempIDs);
-        assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
-        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
-        
-        Command subCommand = (Command)command.getSubCommands().get(0);
-        tempIDs = subCommand.getTemporaryMetadata();
-        assertNotNull(tempIDs);
-        assertNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
-        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
-
-        subCommand = (Command)command.getSubCommands().get(1);
-        tempIDs = subCommand.getTemporaryMetadata();
-        assertNotNull(tempIDs);
-        assertNotNull(tempIDs.get("LOOPCURSOR")); //$NON-NLS-1$
-        assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
-
-    }
-
     @Test public void testUnionQueryWithNull() throws Exception{
     	helpResolve("SELECT NULL, e2 FROM pm1.g2 UNION ALL SELECT e1, e2 FROM pm1.g3"); //$NON-NLS-1$
     	helpResolve("SELECT e1, e2 FROM pm1.g1 UNION ALL SELECT NULL, e2 FROM pm1.g2 UNION ALL SELECT e1, e2 FROM pm1.g3"); //$NON-NLS-1$
@@ -3200,99 +2087,7 @@
         helpResolve("SELECT 'a', 19, {b'true'}, 13.999 INTO #myTempTable"); //$NON-NLS-1$
         helpResolve("SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g1"); //$NON-NLS-1$
     }
-    
-    @Test public void testSelectIntoInProcNoFrom() {
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                            .append("BEGIN\n") //$NON-NLS-1$
-                                            .append("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1;\n") //$NON-NLS-1$
-                                            .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                            .append("END\n"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        
-        procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("SELECT 'a', 19, {b'true'}, 13.999 INTO #myTempTable;\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    @Test public void testSelectIntoInProc() {
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                            .append("BEGIN\n") //$NON-NLS-1$
-                                            .append("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2;\n") //$NON-NLS-1$
-                                            .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                            .append("END\n"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        
-        procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g2;\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    //baseline test to ensure that a declare assignment cannot contain the declared variable
-    @Test public void testDeclareStatement() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer VARIABLES.var1 = VARIABLES.var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    @Test public void testDynamicIntoInProc() {
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2' as e1 string, e2 string, e3 string, e4 string INTO #myTempTable;\n") //$NON-NLS-1$
-                                .append("select e1 from #myTempTable;\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    @Test public void testDynamicStatement() {
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("execute string 'SELECT e1, e2, e3, e4 FROM pm1.g2';\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
-    @Test public void testDynamicStatementType() {
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-                                .append("BEGIN\n") //$NON-NLS-1$
-                                .append("DECLARE object VARIABLES.X = null;\n") //$NON-NLS-1$
-                                .append("execute string VARIABLES.X;\n") //$NON-NLS-1$
-                                .append("ROWS_UPDATED =0;\n") //$NON-NLS-1$
-                                .append("END\n"); //$NON-NLS-1$
-        helpFailUpdateProcedure(procedure.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
+                
     //procedural relational mapping
     @Test public void testProcInVirtualGroup1(){
         String sql = "select e1 from pm1.vsp26 where param1=1 and param2='a'"; //$NON-NLS-1$
@@ -3334,122 +2129,6 @@
         helpResolve(sql);
     }
         
-    @Test public void testMaterializedTransformation() {
-        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, false);
-        
-        Command command = helpResolve(userSql, metadata, analysis);
-
-        assertEquals("Command different than user sql", "SELECT MATVIEW.E1 FROM MATVIEW", command.toString().toUpperCase()); //$NON-NLS-1$ //$NON-NLS-2$
-        assertTrue("Command contains no subcommands", 1 == command.getSubCommands().size()); //$NON-NLS-1$
-        
-        String expectedTransformationSql = "SELECT * FROM MatTable.MatTable"; //$NON-NLS-1$
-        Command transCommand = (Command) command.getSubCommands().get(0);
-
-        assertEquals("Commands don't match", expectedTransformationSql, transCommand.toString()); //$NON-NLS-1$
-        
-        assertEquals("Wrong number of projected symbols", 1, transCommand.getProjectedSymbols().size()); //$NON-NLS-1$
-        assertEquals("wrong projected symbol", "MatTable.MatTable.e1", transCommand.getProjectedSymbols().get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        Collection annotations = analysis.getAnnotations();
-        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
-        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
-        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
-
-        //System.out.println(annotations);
-
-    }
-
-    @Test public void testMaterializedTransformationLoading() {
-        String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, false);
-        
-        Command command = helpResolve(userSql, metadata, analysis);
-        assertEquals("Command different than user sql", "SELECT MATVIEW.E1 INTO MATTABLE.MATSTAGE FROM MATVIEW", command.toString().toUpperCase()); //$NON-NLS-1$ //$NON-NLS-2$
-        assertTrue("Command contains no subcommands", 1 == command.getSubCommands().size()); //$NON-NLS-1$
-        
-        String expectedTransformationSql = "SELECT x FROM MatSrc.MatSrc"; //$NON-NLS-1$
-        Command transCommand = (Command) command.getSubCommands().get(0);
-        assertEquals("Commands don't match", expectedTransformationSql, transCommand.toString()); //$NON-NLS-1$
-        
-        assertEquals("Wrong number of projected symbols", 1, transCommand.getProjectedSymbols().size()); //$NON-NLS-1$
-        assertEquals("wrong projected symbol", "x", transCommand.getProjectedSymbols().get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        Collection annotations = analysis.getAnnotations();
-        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
-        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
-        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
-        
-        //System.out.println(annotations);
-        
-    }    
-    
-    @Test public void testMaterializedTransformationNoCache() {
-        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, false);
-        
-        Command command = helpResolve(userSql, metadata, analysis);
-        assertEquals("Command different than user sql", "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MATVIEW.MATVIEW", command.toString().toUpperCase()); //$NON-NLS-1$ //$NON-NLS-2$
-        assertTrue("Command contains no subcommands", 1 == command.getSubCommands().size()); //$NON-NLS-1$
-        
-        String expectedTransformationSql = "SELECT x FROM MatSrc.MatSrc OPTION NOCACHE"; //$NON-NLS-1$
-        Command transCommand = (Command) command.getSubCommands().get(0);
-        assertEquals("Commands don't match", expectedTransformationSql, transCommand.toString()); //$NON-NLS-1$
-        
-        assertEquals("Wrong number of projected symbols", 1, transCommand.getProjectedSymbols().size()); //$NON-NLS-1$
-        assertEquals("wrong projected symbol", "x", transCommand.getProjectedSymbols().get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        Collection annotations = analysis.getAnnotations();
-        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
-        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
-        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
-    }
-    
-    //related to defect 14423
-    @Test public void testMaterializedTransformationNoCache2() {
-        String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, false);
-        
-        Command command = helpResolve(userSql, metadata, analysis);
-        assertEquals("Command different than user sql", "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE", command.toString().toUpperCase()); //$NON-NLS-1$ //$NON-NLS-2$
-        assertTrue("Command contains no subcommands", 1 == command.getSubCommands().size()); //$NON-NLS-1$
-        
-        String expectedTransformationSql = "SELECT x FROM MatSrc.MatSrc OPTION NOCACHE"; //$NON-NLS-1$
-        Command transCommand = (Command) command.getSubCommands().get(0);
-        assertEquals("Commands don't match", expectedTransformationSql, transCommand.toString()); //$NON-NLS-1$
-        
-        assertEquals("Wrong number of projected symbols", 1, transCommand.getProjectedSymbols().size()); //$NON-NLS-1$
-        assertEquals("wrong projected symbol", "x", transCommand.getProjectedSymbols().get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
-        
-        Collection annotations = analysis.getAnnotations();
-        assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
-        assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
-        assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
-    }
-    
-    @Test public void testNoCacheInTransformation(){
-        String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
-        AnalysisRecord analysis = new AnalysisRecord(false, true, false);
-        
-        Command command = helpResolve(userSql, metadata, analysis);
-        assertEquals("Command different than user sql", "SELECT VGROUP.E1 FROM VGROUP", command.toString().toUpperCase()); //$NON-NLS-1$ //$NON-NLS-2$
-        assertTrue("Command contains no subcommands", 1 == ((Command)command.getSubCommands().get(0)).getSubCommands().size()); //$NON-NLS-1$
-        
-        String expectedTransformationSql = "SELECT x FROM MatSrc.MatSrc OPTION NOCACHE"; //$NON-NLS-1$
-        Command transCommand = (Command)((Command) command.getSubCommands().get(0)).getSubCommands().get(0);
-        assertEquals("Commands don't match", expectedTransformationSql, transCommand.toString()); //$NON-NLS-1$
-    }
-	
     @Test public void testProcParamComparison_defect13653() {
         String userSql = "SELECT * FROM (EXEC mmspTest1.MMSP5('a')) AS a, (EXEC mmsptest1.mmsp6('b')) AS b"; //$NON-NLS-1$
         
@@ -3518,7 +2197,7 @@
     	inputSetElements.add(inputSetElement);
     	externalMetadata.put(inputSet, inputSetElements);
         Query command = (Query)helpParse(sql);
-        QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
         Collection groups = GroupCollectorVisitor.getGroups(command, false);
         assertFalse(groups.contains(inputSet));
     }
@@ -3536,7 +2215,7 @@
     	param.setType(String.class);
     	procPrarms.add(param);
     	externalMetadata.put(procGroup, procPrarms);
-        QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
         CreateUpdateProcedureCommand proc = (CreateUpdateProcedureCommand)command;
         Query query = (Query)proc.getSubCommands().get(0);
         ElementSymbol inElement = (ElementSymbol)((CompareCriteria)query.getCriteria()).getLeftExpression();
@@ -3606,40 +2285,10 @@
         assertEquals(0, command.updatingModelCount(metadata));
     }
     
-    @Test public void testCommandUpdating3() throws Exception{
-        StringBuffer procedure = new StringBuffer("CREATE PROCEDURE  ") //$NON-NLS-1$
-        .append("BEGIN\n") //$NON-NLS-1$
-        .append("INSERT INTO pm1.g1 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
-        .append("ROWS_UPDATED = INSERT INTO pm1.g2 (e1) VALUES (input.e1);\n") //$NON-NLS-1$
-        .append("END\n"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        Command command = helpResolveUpdateProcedure(procedure.toString(), userUpdateStr,
-                                   FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        assertEquals(2, command.updatingModelCount(metadata));
-    }
-    
     @Test public void testCommandUpdatingCount5() throws Exception{
         Command command = helpResolve("SELECT pm1.g1.e1 FROM pm1.g1 UNION SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY e1"); //$NON-NLS-1$
         assertEquals(0, command.updatingModelCount(metadata));
     }
-
-    @Test public void testCommandUpdatingCount6() throws Exception{
-        String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "if(INPUT.e1 = 10)\n";         //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
-        procedure = procedure + "INSERT INTO pm1.g1 (e2) VALUES (Input.e2);\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n";         //$NON-NLS-1$
-
-        String userUpdateStr = "INSERT into vm1.g1 (e1) values('x')"; //$NON-NLS-1$
-        
-        Command command = helpResolveUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.INSERT_PROCEDURE);
-        assertEquals(2, command.updatingModelCount(metadata));
-    }
     
     /** case 3955 */
     @Test public void testCommandUpdatingCountPhysicalInsert() throws Exception{
@@ -3688,20 +2337,7 @@
         
         assertEquals(2, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
     }
-	
-	@Test public void testCommandUpdatingCountFromLastStatement() throws Exception {
-        String procedure = "CREATE VIRTUAL PROCEDURE  \n"; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "declare integer x = convert(pm1.sq1.in, integer) + 5;\n"; //$NON-NLS-1$
-        procedure = procedure + "insert into pm1.g1 values (null, null, null, null);"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-        
-        QueryMetadataInterface metadata = exampleStoredProcedure(procedure);
-        Command command = helpResolve(helpParse("exec pm1.sq1(1)"), metadata, null); //$NON-NLS-1$
-        
-        assertEquals(1, command.updatingModelCount(new TempMetadataAdapter(metadata, new TempMetadataStore())));
-	}
-		    
+			    
     @Test public void testCommandUpdatingCountFromMetadata() throws Exception {
         FakeMetadataFacade metadata = FakeMetadataFactory.example1();
         FakeMetadataObject proc = metadata.getStore().findObject("pm1.sp1", FakeMetadataObject.PROCEDURE); //$NON-NLS-1$
@@ -3903,205 +2539,6 @@
         helpResolveException(sql, "Group does not exist: temp_table"); //$NON-NLS-1$ 
     }
     
-    @Test public void testInvalidVirtualProcedure2(){
-        helpResolveException("EXEC pm1.vsp12()", FakeMetadataFactory.example1Cached(), "Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    // variable declared is of special type ROWS_RETURNED
-    @Test public void testDeclareRowsUpdated() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer rows_updated;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Variable rows_updated was previously declared."); //$NON-NLS-1$
-    }
-    
-    // validating INPUT element assigned
-    @Test public void testAssignInput() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "INPUT.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"INPUT.e1\" cannot be assigned a value.  Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
-    }
-    
-    // validating CHANGING element assigned
-    @Test public void testAssignChanging() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "CHANGING.e1 = Select pm1.g1.e1 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element symbol \"CHANGING.e1\" cannot be assigned a value.  Only declared VARIABLES can be assigned values."); //$NON-NLS-1$
-    }
-    
-    // variables cannot be used among insert elements
-    @Test public void testVariableInInsert() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, var1) values (1, 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userQuery, 
-                FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'var1': Element \"var1\" is not defined by any relevant group.]"); //$NON-NLS-1$
-    }
-    
-    // variables cannot be used among insert elements
-    @Test public void testVariableInInsert2() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure = procedure + "Insert into pm1.g1 (pm1.g1.e2, INPUT.x) values (1, 2);\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
-        helpFailUpdateProcedure(procedure, userQuery, 
-                FakeMetadataObject.Props.UPDATE_PROCEDURE, "Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'INPUT.x': Symbol INPUT.x is specified with an unknown group context]"); //$NON-NLS-1$
-    }
-    
-    //should resolve first to the table's column
-    @Test public void testVariableInInsert3() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "DECLARE integer e2;\n"; //$NON-NLS-1$
-        procedure = procedure + "Insert into pm1.g1 (e2) values (1);\n"; //$NON-NLS-1$
-        procedure = procedure + "ROWS_UPDATED =0;\n";         //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
-
-        helpResolveUpdateProcedure(procedure, userQuery, 
-                FakeMetadataObject.Props.UPDATE_PROCEDURE); 
-    }
-    
-    @Test public void testAmbigousInput() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
-        procedure = procedure + "select e1;\n"; //$NON-NLS-1$
-        procedure = procedure + "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(procedure, userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Element \"e1\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
-    }
-    
-    @Test public void testLoopRedefinition() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  declare string var1;") //$NON-NLS-1$
-        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
-        .append("\n  BEGIN") //$NON-NLS-1$
-        .append("\n    LOOP ON (SELECT pm1.g2.e1 FROM pm1.g2 WHERE loopCursor.e1 = pm1.g2.e1) AS loopCursor") //$NON-NLS-1$
-        .append("\n    BEGIN") //$NON-NLS-1$
-        .append("\n      var1 = CONCAT(var1, CONCAT(' ', loopCursor.e1));") //$NON-NLS-1$
-        .append("\n    END") //$NON-NLS-1$
-        .append("\n  END") //$NON-NLS-1$
-        .append("\n  END"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$
-    }
-    
-    @Test public void testLoopRedefinition2(){
-        helpResolveException("EXEC pm1.vsp11()", FakeMetadataFactory.example1Cached(), "Nested Loop can not use the same cursor name as that of its parent."); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    @Test public void testTempGroupElementShouldNotBeResolable() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  select 1 as a into #temp;") //$NON-NLS-1$
-        .append("\n  select #temp.a from pm1.g1;") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
-    }
-    
-    @Test public void testTempGroupElementShouldNotBeResolable1() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  select 1 as a into #temp;") //$NON-NLS-1$
-        .append("\n  insert into #temp (a) values (#temp.a);") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
-    }
-    
-    @Test public void testVariableResolutionWithIntervening() {
-        StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  declare string x;") //$NON-NLS-1$
-        .append("\n  x = '1';") //$NON-NLS-1$
-        .append("\n  declare string y;") //$NON-NLS-1$
-        .append("\n  y = '1';") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        helpResolve(proc.toString()); 
-    }
-    
-    @Test public void testProcedureScoping() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        //note that this declare takes presedense over the proc INPUT.e1 and CHANGING.e1 variables
-        .append("\n  declare integer e1 = 1;") //$NON-NLS-1$
-        .append("\n  e1 = e1;") //$NON-NLS-1$
-        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
-        .append("\n  BEGIN") //$NON-NLS-1$
-        //inside the scope of the loop, an unqualified e1 should resolve to the loop variable group
-        .append("\n    variables.e1 = convert(e1, integer);") //$NON-NLS-1$
-        .append("\n  END") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        Update command = (Update)helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
-                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
-        
-        Block block = ((CreateUpdateProcedureCommand)command.getSubCommand()).getBlock();
-        
-        AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1);
-        assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getCanonicalName());
-        assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getValue()).getGroupSymbol().getCanonicalName());
-        
-        Block inner = ((LoopStatement)block.getStatements().get(2)).getBlock();
-        
-        assStmt = (AssignmentStatement)inner.getStatements().get(0);
-        
-        ElementSymbol value = ElementCollectorVisitor.getElements(assStmt.getValue(), false).iterator().next();
-        
-        assertEquals("LOOPCURSOR", value.getGroupSymbol().getCanonicalName()); //$NON-NLS-1$
-    }
-    
     @Test public void testResolveUnqualifiedCriteria() throws Exception{
         Criteria criteria = QueryParser.getQueryParser().parseCriteria("e1 = 1"); //$NON-NLS-1$
            
@@ -4136,64 +2573,9 @@
         param.setType(DataTypeManager.DefaultDataClasses.STRING);
         procPrarms.add(param);
         externalMetadata.put(proc, procPrarms);
-        QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
     }
-    
-    @Test public void testProcedureCreate() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
-        .append("\n  select e1 from t1;") //$NON-NLS-1$
-        .append("\n  create local temporary table t1 (e1 string, e2 integer);") //$NON-NLS-1$
-        .append("\n  select e2 from t1;") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
         
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
-    }
-    
-    /**
-     * it is not ok to redefine the loopCursor 
-     */
-    @Test public void testProcedureCreate1() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  LOOP ON (SELECT pm1.g1.e1 FROM pm1.g1) AS loopCursor") //$NON-NLS-1$
-        .append("\n  BEGIN") //$NON-NLS-1$
-        .append("\n  create local temporary table loopCursor (e1 string);") //$NON-NLS-1$
-        .append("\nEND") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Cannot create temporary table \"loopCursor\". A table with the same name already exists."); //$NON-NLS-1$
-    }
-    
-    @Test public void testProcedureCreateDrop() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n drop table t1;") //$NON-NLS-1$
-        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpFailUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE, "Group does not exist: t1"); //$NON-NLS-1$
-    }
-    
-    @Test public void testProcedureCreateDrop1() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  create local temporary table t1 (e1 string);") //$NON-NLS-1$
-        .append("\n  drop table t1;") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE);
-    }
-    
     @Test public void testBatchedUpdateResolver() throws Exception {
         String update1 = "update pm1.g1 set e1 =1"; //$NON-NLS-1$
         String update2 = "update pm2.g1 set e1 =1"; //$NON-NLS-1$
@@ -4259,31 +2641,7 @@
         
         helpResolveException(sql);
     }
-            
-    @Test public void testCreateAfterImplicitTempTable() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  select e1 into #temp from pm1.g1;") //$NON-NLS-1$
-        .append("\n  create local temporary table #temp (e1 string);") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
-    }
-    
-    @Test public void testInsertAfterCreate() {
-        StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
-        .append("\nBEGIN") //$NON-NLS-1$
-        .append("\n  create local temporary table #temp (e1 string, e2 string);") //$NON-NLS-1$
-        .append("\n  insert into #temp (e1) values ('a');") //$NON-NLS-1$
-        .append("\nEND"); //$NON-NLS-1$
-        
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-        helpResolveUpdateProcedure(proc.toString(), userUpdateStr, FakeMetadataObject.Props.UPDATE_PROCEDURE); 
-    }
-    
+                
     @Test public void testUpdateError() {
         String userUpdateStr = "UPDATE vm1.g2 SET e1='x'"; //$NON-NLS-1$
         
@@ -4313,7 +2671,7 @@
     }
     
     @Test public void testXMLJoinFail() {
-        String query = "select * from xmltest.doc1, xmltest.doc1"; //$NON-NLS-1$
+        String query = "select * from xmltest.doc1, xmltest.doc2"; //$NON-NLS-1$
          
         helpResolveException(query, "Error Code:ERR.015.008.0003 Message:Only one XML document may be specified in the FROM clause of a query."); //$NON-NLS-1$
     }
@@ -4497,57 +2855,7 @@
 		
 		TestResolver.helpResolveException(sql, FakeMetadataFactory.exampleBQTCached(), "Error Code:ERR.015.008.0007 Message:Incorrect number of parameters specified on the stored procedure pm4.spTest9 - expected 1 but got 2"); //$NON-NLS-1$
 	}	
-	
-	/**
-	 * delete procedures should not reference input or changing vars.
-	 */
-	@Test public void testDefect16451() {
-		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure += "BEGIN\n"; //$NON-NLS-1$
-        procedure += "Select pm1.g1.e2 from pm1.g1 where e1 = input.e1;\n"; //$NON-NLS-1$
-        procedure += "ROWS_UPDATED = 0;"; //$NON-NLS-1$
-        procedure += "END\n"; //$NON-NLS-1$
-        
-        String userUpdateStr = "delete from vm1.g1 where e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-									 FakeMetadataObject.Props.DELETE_PROCEDURE, "Symbol input.e1 is specified with an unknown group context"); //$NON-NLS-1$
-	}
-	
-    @Test public void testInvalidVirtualProcedure3() throws Exception {
-    	helpResolveException("EXEC pm1.vsp18()", "Group does not exist: temptable"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    // variable resolution, variable comapred against
-    // differrent datatype element for which there is no implicit transformation)
-    @Test public void testCreateUpdateProcedure2() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure += "BEGIN\n"; //$NON-NLS-1$
-        procedure += "DECLARE boolean var1;\n"; //$NON-NLS-1$
-        procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e4 = convert(var1, string), pm1.g1.e1 = var1;\n"; //$NON-NLS-1$
-        procedure += "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1=1"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-				 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e4' with expected type double to expression 'convert(var1, string)'"); //$NON-NLS-1$
-    }
-    
-    // special variable INPUT compared against invalid type
-    @Test public void testInvalidInputInUpdate() {
-        String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
-        procedure += "BEGIN\n"; //$NON-NLS-1$
-        procedure += "DECLARE integer var1;\n"; //$NON-NLS-1$
-        procedure += "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
-        procedure += "ROWS_UPDATED = UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e1;\n"; //$NON-NLS-1$
-        procedure += "END\n"; //$NON-NLS-1$
-
-        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
-        
-		helpFailUpdateProcedure(procedure, userUpdateStr,
-				 FakeMetadataObject.Props.UPDATE_PROCEDURE, "Error Code:ERR.015.008.0041 Message:Cannot set symbol 'pm1.g1.e2' with expected type integer to expression 'INPUT.e1'"); //$NON-NLS-1$
-    }
-    
+	    
     @Test public void testUpdateSetClauseReferenceType() {
     	String sql = "UPDATE pm1.g1 SET pm1.g1.e1 = 1, pm1.g1.e2 = ?;"; //$NON-NLS-1$
     	

Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -398,7 +398,7 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
         
-        QueryResolver.resolveCommand(command, externalMetadata, false, FakeMetadataFactory.example1Cached(), AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, FakeMetadataFactory.example1Cached(), AnalysisRecord.createNonRecordingRecord());
     
         // Verify results        
         Collection vars = TestResolver.getVariables(command);

Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -58,7 +58,7 @@
         
         QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
         
-        return QueryRewriter.rewrite(command, null, FakeMetadataFactory.example1Cached(), null);
+        return QueryRewriter.rewrite(command, FakeMetadataFactory.example1Cached(), null);
     }
 
     private void helpCheckElements(OrderBy langObj,

Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -52,13 +52,14 @@
 import com.metamatrix.query.sql.lang.CompoundCriteria;
 import com.metamatrix.query.sql.lang.Criteria;
 import com.metamatrix.query.sql.lang.MatchCriteria;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
 import com.metamatrix.query.sql.lang.Query;
 import com.metamatrix.query.sql.lang.QueryCommand;
 import com.metamatrix.query.sql.lang.SPParameter;
 import com.metamatrix.query.sql.lang.SetCriteria;
 import com.metamatrix.query.sql.lang.SetQuery;
 import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.Update;
+import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
 import com.metamatrix.query.sql.symbol.Constant;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.symbol.ExpressionSymbol;
@@ -125,42 +126,24 @@
         return actual;
     }    
     
-	private String getReWrittenProcedure(String procedure, String userUpdateStr, String procedureType) {
+	private String getRewritenProcedure(String procedure, String userUpdateStr, String procedureType) throws QueryParserException, QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
         QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
 
-        try {
-            Command userCommand = QueryParser.getQueryParser().parseCommand(userUpdateStr);       
-            QueryResolver.resolveCommand(userCommand, metadata);
-    		QueryRewriter.rewrite(userCommand, null, metadata, null);
-    		return userCommand.getSubCommands().get(0).toString();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
+        return getRewritenProcedure(userUpdateStr, metadata);
+	}
+
+	private String getRewritenProcedure(String userUpdateStr,
+			QueryMetadataInterface metadata) throws QueryParserException,
+			QueryResolverException, MetaMatrixComponentException,
+			QueryMetadataException, QueryValidatorException {
+		ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr); 
+        QueryResolver.resolveCommand(userCommand, metadata);
+        CreateUpdateProcedureCommand proc = (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
+		QueryRewriter.rewrite(userCommand, metadata, null);
+		Command result = QueryRewriter.rewrite(proc, metadata, null);
+		return result.toString();
 	}
 	
-	private void helpFailUpdateProcedure(String procedure, String userUpdateStr, String procedureType) {
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
-
-        Command userCommand = null;       
-        try {
-            QueryParser parser = new QueryParser();
-            userCommand = parser.parseCommand(userUpdateStr);
-            QueryResolver.resolveCommand(userCommand, metadata);            
-        } catch(MetaMatrixException e) {
-            e.printStackTrace();
-			fail("Exception during parsing/resolution (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
-        }
-
-		QueryValidatorException exception = null;
-        try {		
-			QueryRewriter.rewrite(userCommand, null, metadata, null);
-        } catch(QueryValidatorException e) {
-        	exception = e;
-        }
-
-		assertNotNull("Expected a QueryValidatorException but got none.", exception); //$NON-NLS-1$
-	}
-
     static Command helpTestRewriteCommand(String original, String expected) { 
         try {
             return helpTestRewriteCommand(original, expected, FakeMetadataFactory.example1Cached());
@@ -172,7 +155,7 @@
     static Command helpTestRewriteCommand(String original, String expected, QueryMetadataInterface metadata) throws MetaMatrixException { 
         Command command = QueryParser.getQueryParser().parseCommand(original);            
         QueryResolver.resolveCommand(command, metadata);
-        Command rewriteCommand = QueryRewriter.rewrite(command, null, metadata, null);
+        Command rewriteCommand = QueryRewriter.rewrite(command, metadata, null);
         assertEquals("Rewritten command was not expected", expected, rewriteCommand.toString()); //$NON-NLS-1$
         return rewriteCommand;
     }
@@ -823,7 +806,7 @@
     }
     
     // HAS Criteria
-    @Test public void testRewriteProcedure1() {
+    @Test public void testRewriteProcedure1() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -839,14 +822,14 @@
 		rewritProc = rewritProc + "BEGIN\n";		 //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 		
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.INSERT_PROCEDURE);
 				
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
     // HAS Criteria
-    @Test public void testRewriteProcedure2() {
+    @Test public void testRewriteProcedure2() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -867,14 +850,14 @@
 		rewritProc = rewritProc + "SELECT vm1.g1.e1 FROM vm1.g1 WHERE "+FALSE_STR+";\n"; //$NON-NLS-1$ //$NON-NLS-2$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.INSERT_PROCEDURE);
 				
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
     // HAS Criteria
-    @Test public void testRewriteProcedure3() {
+    @Test public void testRewriteProcedure3() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -895,13 +878,13 @@
 		rewritProc = rewritProc + "SELECT vm1.g1.e1 FROM vm1.g1 WHERE "+FALSE_STR+";\n"; //$NON-NLS-1$ //$NON-NLS-2$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.INSERT_PROCEDURE);
 				
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
-    @Test public void testRewriteProcedure4() {
+    @Test public void testRewriteProcedure4() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -918,14 +901,14 @@
 		rewritProc = rewritProc + "SELECT vm1.g1.e1 FROM vm1.g1 WHERE "+FALSE_STR+";\n"; //$NON-NLS-1$ //$NON-NLS-2$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 		
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.INSERT_PROCEDURE);
 				
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }    
     
     // CHANGING
-    @Test public void testRewriteProcedure5() {
+    @Test public void testRewriteProcedure5() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -941,14 +924,14 @@
 		rewritProc = rewritProc + "BEGIN\n";		 //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 		
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
     // CHANGING
-    @Test public void testRewriteProcedure6() {
+    @Test public void testRewriteProcedure6() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -963,14 +946,14 @@
 		rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 		
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }     
     
     // TRANSLATE CRITERIA
-    @Test public void testRewriteProcedure7() {
+    @Test public void testRewriteProcedure7() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -987,14 +970,14 @@
 		rewritProc = rewritProc + "SELECT e2 FROM pm1.g1 WHERE pm1.g1.e2 = 10;\n";				 //$NON-NLS-1$
 		rewritProc = rewritProc + "END";		 //$NON-NLS-1$
 		
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
     // TRANSLATE CRITERIA
-    @Test public void testRewriteProcedure8() {
+    @Test public void testRewriteProcedure8() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -1011,14 +994,14 @@
 		rewritProc = rewritProc + "SELECT e2 FROM pm1.g1 WHERE convert(sqrt(pm1.g1.e2), integer) = 10;\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 		
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
     // rewrite input/ changing variables
-    @Test public void testRewriteProcedure9() {
+    @Test public void testRewriteProcedure9() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "Declare String var1;\n"; //$NON-NLS-1$
@@ -1039,14 +1022,14 @@
 		rewritProc = rewritProc + "END\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.INSERT_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    @Test public void testRewriteProcedure10() {
+    @Test public void testRewriteProcedure10() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1061,14 +1044,14 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e2 + 20) = ((pm1.g1.e2 + 20) + 50);\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
 	// virtual group elements used in procedure in if statement(HAS CRITERIA)
-    @Test public void testRewriteProcedure11() {
+    @Test public void testRewriteProcedure11() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
@@ -1083,7 +1066,7 @@
 		rewritProc = rewritProc + "var1 = '40';\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
@@ -1091,7 +1074,7 @@
     
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
 	// with complex query transform
-    @Test public void testRewriteProcedure12() {
+    @Test public void testRewriteProcedure12() throws Exception {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1106,7 +1089,7 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1 WHERE CONCAT(e1, 'z') = CONCAT(CONCAT(e1, 'z'), 'y');\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
@@ -1114,7 +1097,7 @@
     
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
 	// with complex query transform
-    @Test public void testRewriteProcedure13() {
+    @Test public void testRewriteProcedure13() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1129,14 +1112,14 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1 WHERE (CONCAT(e1, 'z') = CONCAT(CONCAT(e1, 'z'), 'y')) AND (convert(CONCAT(e1, 'k'), integer) = 1);\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    @Test public void testRewriteProcedure14() {
+    @Test public void testRewriteProcedure14() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1151,14 +1134,14 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1 WHERE sqrt(e4) = 1.0;\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
 	
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    @Test public void testRewriteProcedure15() {
+    @Test public void testRewriteProcedure15() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1173,14 +1156,14 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1 WHERE e2 = 0;\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
 	
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    @Test public void testRewriteProcedure16() {
+    @Test public void testRewriteProcedure16() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1195,14 +1178,14 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1 WHERE e4 = 0.02;\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
 	
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    @Test public void testRewriteProcedure17() {
+    @Test public void testRewriteProcedure17() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1217,14 +1200,14 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1 WHERE "+FALSE_STR+";\n"; //$NON-NLS-1$ //$NON-NLS-2$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
 	
 	// Bug 8212 elements in INPUT and CHANGING special groups are cese sensitive
-    @Test public void testRewriteProcedure18() {
+    @Test public void testRewriteProcedure18() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "Select Input.E1, Input.e2, CHANGING.e2, CHANGING.E1 from pm1.g1;\n"; //$NON-NLS-1$
@@ -1237,7 +1220,7 @@
 		rewritProc = rewritProc + "SELECT 'x', 1, TRUE, TRUE FROM pm1.g1;\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.INSERT_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
@@ -1245,7 +1228,7 @@
 	
 	// elements being set in updates are dropped if INPUT var is not available, unless a default is available
     // Note that this test is a little odd in that it is an update inside of an insert
-    @Test public void testRewriteProcedure19() {
+    @Test public void testRewriteProcedure19() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "update pm1.g1 set e1=Input.E1, e2=Input.e2, e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1258,7 +1241,7 @@
         rewritProc = rewritProc + "UPDATE pm1.g1 SET e1 = 'xyz', e2 = 1, e3 = TRUE;\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.INSERT_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
@@ -1267,7 +1250,7 @@
 	// elements being set in updates are dropped if INPUT var is not available, unless a default is supplied
     
     //this test fails because the default for E1 'xyz' cannot be converted into a integer
-    @Test public void testRewriteProcedure21() {
+    @Test(expected=QueryValidatorException.class) public void testRewriteProcedure21() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "update pm1.g1 set e1=convert(Input.E1, integer)+INPUT.E2, e2=Input.e2, e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1280,10 +1263,10 @@
         rewritProc = rewritProc + "UPDATE pm1.g1 SET e3 = TRUE;\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		this.helpFailUpdateProcedure(procedure, userQuery, FakeMetadataObject.Props.INSERT_PROCEDURE);
+		this.getRewritenProcedure(procedure, userQuery, FakeMetadataObject.Props.INSERT_PROCEDURE);
 	}
     
-    @Test public void testRewriteProcedure21a() {
+    @Test public void testRewriteProcedure21a() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "update pm1.g1 set e1=convert(Input.E1, integer)+INPUT.E2, e2=Input.e2, e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1296,15 +1279,14 @@
         rewritProc = rewritProc + "UPDATE pm1.g1 SET e1 = null, e2 = null, e3 = TRUE;\n"; //$NON-NLS-1$
         rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-        String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+        String procReturned = this.getRewritenProcedure(procedure, userQuery, 
                                                         FakeMetadataObject.Props.INSERT_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
 
-	
 	// none of input variables on update statement changing
-    @Test public void testRewriteProcedure22() {
+    @Test public void testRewriteProcedure22() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "update pm1.g1 set e1=convert(Input.E1, integer)+INPUT.E2, e2=Input.e2;\n"; //$NON-NLS-1$
@@ -1316,14 +1298,14 @@
 		rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
 	
 	// none of input variables on update statement changing
-    @Test public void testRewriteProcedure23() {
+    @Test public void testRewriteProcedure23() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "update pm1.g1 set e2=Input.e2, e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1335,14 +1317,14 @@
 		rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
     
     //with an insert, defaults are used
-    @Test public void testRewriteProcedure23a() {
+    @Test public void testRewriteProcedure23a() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "update pm1.g1 set e2=Input.e2, e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1355,14 +1337,14 @@
         rewritProc = rewritProc + "UPDATE pm1.g1 SET e2 = null, e3 = TRUE;\n"; //$NON-NLS-1$
         rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-        String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+        String procReturned = this.getRewritenProcedure(procedure, userQuery, 
                 FakeMetadataObject.Props.INSERT_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
     
 	// elements being set in updates are dropped if INPUT var is not available
-    @Test public void testRewriteProcedure24() {
+    @Test public void testRewriteProcedure24() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "UPDATE pm1.g1 SET e2=Input.e2 WHERE TRANSLATE LIKE CRITERIA ON (e1) WITH (e1=concat(pm1.g1.e1, '%'));\n"; //$NON-NLS-1$
@@ -1375,14 +1357,14 @@
         rewritProc = rewritProc + "UPDATE pm1.g1 SET e2 = 1 WHERE concat(pm1.g1.e1, '%') LIKE 'mnopxyz_';\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
 
 	// INPUT vars in insert statements replaced by default variable when user's inser ignores values
-    @Test public void testRewriteProcedure25() {
+    @Test public void testRewriteProcedure25() throws Exception {
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "INSERT into pm1.g1 (e1,e2,e3,e4) values (Input.e1, Input.e2, Input.e3, Input.e4);"; //$NON-NLS-1$
@@ -1395,14 +1377,14 @@
         rewritProc = rewritProc + "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('xyz', 1, TRUE, 123.456);\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.INSERT_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
 	
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-	@Test public void testRewriteProcedure26() {
+	@Test public void testRewriteProcedure26() throws Exception {
 		String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
 		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1417,14 +1399,14 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e2 = (pm1.g1.e2 + 50);\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
 		assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
 	}
 	
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-	@Test public void testRewriteProcedure27() {
+	@Test public void testRewriteProcedure27() throws Exception {
 		String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
 		procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1439,7 +1421,7 @@
 		rewritProc = rewritProc + "SELECT pm1.g1.e2 FROM pm1.g1, pm1.g2 WHERE "+FALSE_STR+";\n"; //$NON-NLS-1$ //$NON-NLS-2$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
 		assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
@@ -1455,7 +1437,7 @@
      * descriptor couldn't be found for the "minus" operation for the two types 
      * integer and MetaMatrix's null type.
      */
-    @Test public void testRewriteProcedure_9380() {
+    @Test public void testRewriteProcedure_9380() throws Exception {
         
         String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -1475,7 +1457,7 @@
         rewritProc = rewritProc + "DECLARE integer var2;\n"; //$NON-NLS-1$
         rewritProc = rewritProc + "END"; //$NON-NLS-1$
 
-        String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+        String procReturned = this.getRewritenProcedure(procedure, userQuery, 
                 FakeMetadataObject.Props.UPDATE_PROCEDURE);
 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
@@ -1513,7 +1495,7 @@
         QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
         
         // rewrite
-        Command rewriteCommand = QueryRewriter.rewrite(command, null, null, null);
+        Command rewriteCommand = QueryRewriter.rewrite(command, null, null);
         
         List<SPParameter> parameters = ((StoredProcedure)rewriteCommand).getParameters();
 
@@ -1524,14 +1506,6 @@
         }  
     }
     
-    @Test public void testRewriteRecursive() {
-        Command c = helpTestRewriteCommand("SELECT e2 FROM vm1.g33", "SELECT e2 FROM vm1.g33"); //$NON-NLS-1$ //$NON-NLS-2$
-        Command innerCommand = c.getSubCommands().get(0);
-        
-        assertEquals("Inner command not rewritten", "SELECT e2 FROM pm1.g1 WHERE e2 = 2", innerCommand.toString()); //$NON-NLS-1$ //$NON-NLS-2$
-        
-    }
-    
     @Test public void testRewriteFunctionThrowsEvaluationError() {
         FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached(); 
         Criteria origCrit = parseCriteria("5 / 0 = 5", metadata); //$NON-NLS-1$
@@ -1559,7 +1533,7 @@
         }       
     }
     
-    @Test public void testDefect13458() {
+    @Test public void testDefect13458() throws Exception {
     	
 		String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n";		 //$NON-NLS-1$
@@ -1576,7 +1550,7 @@
 		rewritProc = rewritProc + "SELECT vm1.g1.e1 FROM vm1.g1;\n"; //$NON-NLS-1$
 		rewritProc = rewritProc + "END"; //$NON-NLS-1$
 		
-		String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+		String procReturned = this.getRewritenProcedure(procedure, userQuery, 
 				FakeMetadataObject.Props.DELETE_PROCEDURE);				
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
     }
@@ -1761,9 +1735,9 @@
         Properties props = new Properties();
         props.setProperty(ContextProperties.SESSION_ID, "1"); //$NON-NLS-1$
         context.setEnvironmentProperties(props);
-        Command rewriteCommand = QueryRewriter.rewrite(command, null, null, context);
+        Command rewriteCommand = QueryRewriter.rewrite(command, null, context);
         
-        assertEquals("SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'", rewriteCommand.toString()); //$NON-NLS-1$
+        assertEquals("EXEC pm1.sq2('1')", rewriteCommand.toString()); //$NON-NLS-1$
     }
 
     @Ignore(value="It's not generally possible to invert a narrowing conversion")
@@ -1796,22 +1770,15 @@
         
         String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
 
-        QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.INSERT_PROCEDURE, procedure);
-        
-        QueryParser parser = new QueryParser();
-        Command userCommand = parser.parseCommand(userQuery);
-        QueryResolver.resolveCommand(userCommand, metadata);
-        
         try {       
-            QueryRewriter.rewrite(userCommand, null, metadata, null);
+            getRewritenProcedure(procedure, userQuery, FakeMetadataObject.Props.INSERT_PROCEDURE);
             fail("exception expected"); //$NON-NLS-1$
         } catch (QueryValidatorException e) {
             assertEquals("Infinite loop detected, procedure will not be executed.", e.getMessage()); //$NON-NLS-1$
         }
-                
     }
     
-    @Test public void testRewriteWhile1() {
+    @Test public void testRewriteWhile1() throws Exception {
         
         String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n";       //$NON-NLS-1$
@@ -1827,7 +1794,7 @@
         rewritProc = rewritProc + "BEGIN\n";         //$NON-NLS-1$
         rewritProc = rewritProc + "END"; //$NON-NLS-1$
         
-        String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+        String procReturned = this.getRewritenProcedure(procedure, userQuery, 
                 FakeMetadataObject.Props.INSERT_PROCEDURE);
                 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
@@ -1836,7 +1803,7 @@
     /**
      * Tests that VariableSubstitutionVisitor does not cause an NPE on count(*)
      */
-    @Test public void testRewriteProcedureWithCount() {
+    @Test public void testRewriteProcedureWithCount() throws Exception {
         
         String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n";         //$NON-NLS-1$
@@ -1850,7 +1817,7 @@
         rewritProc = rewritProc + "SELECT COUNT(*) FROM pm1.g1;\n";         //$NON-NLS-1$
         rewritProc = rewritProc + "END"; //$NON-NLS-1$
         
-        String procReturned = this.getReWrittenProcedure(procedure, userQuery, 
+        String procReturned = this.getRewritenProcedure(procedure, userQuery, 
                 FakeMetadataObject.Props.INSERT_PROCEDURE);
                 
         assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
@@ -1878,12 +1845,12 @@
         String userUpdateStr = "UPDATE vm1.g1 SET e1 = 'x' WHERE e2 = 5"; //$NON-NLS-1$
         
         FakeMetadataFacade metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.UPDATE_PROCEDURE, procedure1, procedure2);
+        
+        String rewriten = getRewritenProcedure(userUpdateStr, metadata);
         
-        Update command = (Update)helpTestRewriteCommand(userUpdateStr, userUpdateStr, metadata);
-                     
         String expected = "CREATE PROCEDURE\nBEGIN\nDECLARE string var1 = 'x';\nROWS_UPDATED = UPDATE vm1.g2 SET e1 = var1;\nEND"; //$NON-NLS-1$
         
-        assertEquals(expected, command.getSubCommand().toString());
+        assertEquals(expected, rewriten);
     }
     
     @Test public void testRemoveEmptyLoop() {
@@ -1989,7 +1956,7 @@
         SetQuery union = (SetQuery)QueryParser.getQueryParser().parseCommand(unionQuery);
         QueryResolver.resolveCommand(union, FakeMetadataFactory.example1Cached());
         
-        union = (SetQuery)QueryRewriter.rewrite(union, null, FakeMetadataFactory.example1Cached(), null);
+        union = (SetQuery)QueryRewriter.rewrite(union, FakeMetadataFactory.example1Cached(), null);
         
         for (QueryCommand query : union.getQueryCommands()) {
             List<SingleElementSymbol> projSymbols = query.getProjectedSymbols();
@@ -2083,16 +2050,6 @@
     }
     
     /**
-     * Should fail since null is not allowed as an input
-     * @throws Exception
-     */
-    @Test(expected=QueryValidatorException.class) public void testProcWithNull() throws Exception {
-        String sql = "exec pm1.vsp26(1, null)"; //$NON-NLS-1$
-        
-    	helpTestRewriteCommand(sql, "", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
-    }
-
-    /**
      * Test <code>QueryRewriter</code>'s ability to rewrite a query that 
      * contains an aggregate function which uses a <code>CASE</code> 
      * expression which contains <code>BETWEEN</code> criteria as its value.

Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestCreateUpdateProcedureCommand.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestCreateUpdateProcedureCommand.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestCreateUpdateProcedureCommand.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -182,9 +182,6 @@
         field = clazz.getDeclaredField("projectedSymbols"); //$NON-NLS-1$
         field.setAccessible( true );
         assertNotNull(field.get(cloned));
-        field = clazz.getDeclaredField("resultsCommand"); //$NON-NLS-1$
-        field.setAccessible( true );
-        assertNotNull(field.get(cloned));
     }
     
     /**

Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestElementSymbolOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestElementSymbolOptimizer.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestElementSymbolOptimizer.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -55,7 +55,7 @@
         Command command = QueryParser.getQueryParser().parseCommand(sql);
 
         final boolean USE_METADATA_COMMANDS = true;
-        QueryResolver.resolveCommand(command, externalMetadata, USE_METADATA_COMMANDS, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
         
         return command;      
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -22,6 +22,8 @@
 
 package com.metamatrix.query.validator;
 
+import static org.junit.Assert.*;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -33,7 +35,7 @@
 import java.util.Map;
 import java.util.Set;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixException;
@@ -52,7 +54,9 @@
 import com.metamatrix.query.resolver.QueryResolver;
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
 import com.metamatrix.query.sql.lang.SPParameter;
+import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 import com.metamatrix.query.sql.visitor.SQLStringVisitor;
@@ -61,14 +65,8 @@
 import com.metamatrix.query.unittest.FakeMetadataObject;
 import com.metamatrix.query.unittest.FakeMetadataStore;
 
-public class TestValidator extends TestCase {
+public class TestValidator {
 
-	// ################################## FRAMEWORK ################################
-	
-	public TestValidator(String name) { 
-		super(name);
-	}	
-    
     public static Map getStoredProcedureExternalMetadata(GroupSymbol virtualProc, QueryMetadataInterface metadata)
     throws QueryMetadataException, MetaMatrixComponentException {
 
@@ -325,16 +323,9 @@
 	public static Command helpResolve(String sql, QueryMetadataInterface metadata, Map externalMetadata) { 
 		Command command = null;
 		
-		// parse
 		try { 
 			command = QueryParser.getQueryParser().parseCommand(sql);
-		} catch(Exception e) { 
-            throw new MetaMatrixRuntimeException(e);
-		}	
-		
-		// resolve
-		try { 
-			QueryResolver.resolveCommand(command, externalMetadata, true, metadata, AnalysisRecord.createNonRecordingRecord());
+			QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
 		} catch(Exception e) {
             throw new MetaMatrixRuntimeException(e);
 		} 
@@ -406,10 +397,9 @@
 
         try {
         	
-	        Command command = helpResolve(userUpdateStr, metadata);
-        	
-            ValidatorReport report = Validator.validate(command, metadata); 
-            //System.out.println("\nReport = \n" + report);
+	        ProcedureContainer command = (ProcedureContainer)helpResolve(userUpdateStr, metadata);
+        	CreateUpdateProcedureCommand cmd = (CreateUpdateProcedureCommand)QueryResolver.expandCommand(command, metadata, null);
+            ValidatorReport report = Validator.validate(cmd, metadata); 
         
             // Get invalid objects from report
             Collection actualObjs = new ArrayList();
@@ -423,178 +413,178 @@
 	// ################################## ACTUAL TESTS ################################
 	
 	
-    public void testSelectStarWhereNoElementsAreNotSelectable() {
+    @Test public void testSelectStarWhereNoElementsAreNotSelectable() {
         helpValidate("SELECT * FROM pm1.g5", new String[] {"SELECT * FROM pm1.g5"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-	public void testValidateSelect1() {        
+	@Test public void testValidateSelect1() {        
         helpValidate("SELECT e1, e2 FROM test.group", new String[] {"e1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testValidateSelect2() {        
+	@Test public void testValidateSelect2() {        
         helpValidate("SELECT e2 FROM test.group", new String[] {}, exampleMetadata()); //$NON-NLS-1$
 	}
  
-	public void testValidateCompare1() {        
+	@Test public void testValidateCompare1() {        
         helpValidate("SELECT e2 FROM vTest.vMap WHERE e2 = 'a'", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
 	}
 
-    public void testValidateCompare4() {        
+    @Test public void testValidateCompare4() {        
         helpValidate("SELECT e3 FROM vTest.vMap WHERE e3 LIKE 'a'", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
-    public void testValidateCompare6() {        
+    @Test public void testValidateCompare6() {        
         helpValidate("SELECT e0 FROM vTest.vMap WHERE e0 BETWEEN 1000 AND 2000", new String[] {}, exampleMetadata()); //$NON-NLS-1$
     }
 
-	public void testValidateCompareInHaving2() {        
+	@Test public void testValidateCompareInHaving2() {        
         helpValidate("SELECT e2 FROM vTest.vMap GROUP BY e2 HAVING e2 IS NULL", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
 	}
 
-	public void testValidateCompareInHaving3() {        
+	@Test public void testValidateCompareInHaving3() {        
         helpValidate("SELECT e2 FROM vTest.vMap GROUP BY e2 HAVING e2 IN ('a')", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
 	}
 
-    public void testValidateCompareInHaving4() {        
+    @Test public void testValidateCompareInHaving4() {        
         helpValidate("SELECT e3 FROM vTest.vMap GROUP BY e3 HAVING e3 LIKE 'a'", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
-    public void testValidateCompareInHaving5() {        
+    @Test public void testValidateCompareInHaving5() {        
         helpValidate("SELECT e2 FROM vTest.vMap GROUP BY e2 HAVING e2 BETWEEN 1000 AND 2000", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
-	public void testInvalidAggregate1() {        
+	@Test public void testInvalidAggregate1() {        
         helpValidate("SELECT SUM(e3) FROM test.group GROUP BY e2", new String[] {"SUM(e3)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testInvalidAggregate2() {        
+	@Test public void testInvalidAggregate2() {        
         helpValidate("SELECT e3 FROM test.group GROUP BY e2", new String[] {"e3"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testInvalidAggregate3() {        
+	@Test public void testInvalidAggregate3() {        
         helpValidate("SELECT SUM(e2) FROM test.group GROUP BY e2", new String[] {"SUM(e2)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testInvalidAggregate4() {        
+	@Test public void testInvalidAggregate4() {        
         helpValidate("SELECT AVG(e2) FROM test.group GROUP BY e2", new String[] {"AVG(e2)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
     
-    public void testInvalidAggregate5() {
+    @Test public void testInvalidAggregate5() {
         helpValidate("SELECT e1 || 'x' frOM pm1.g1 GROUP BY e2 + 1", new String[] {"e1"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testInvalidAggregate6() {
+    @Test public void testInvalidAggregate6() {
         helpValidate("SELECT e2 + 1 frOM pm1.g1 GROUP BY e2 + 1 HAVING e1 || 'x' > 0", new String[] {"e1"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testInvalidAggregate7() {
+    @Test public void testInvalidAggregate7() {
         helpValidate("SELECT StringKey, SUM(length(StringKey || 'x')) + 1 AS x FROM BQT1.SmallA GROUP BY StringKey || 'x' HAVING space(MAX(length((StringKey || 'x') || 'y'))) = '   '", //$NON-NLS-1$
                      new String[] {"StringKey"}, FakeMetadataFactory.exampleBQTCached() ); //$NON-NLS-1$
     }
     
-    public void testInvalidAggregate8() {
+    @Test public void testInvalidAggregate8() {
         helpValidate("SELECT max(ObjectValue) FROM BQT1.SmallA GROUP BY StringKey", //$NON-NLS-1$
                      new String[] {"MAX(ObjectValue)"}, FakeMetadataFactory.exampleBQTCached() ); //$NON-NLS-1$
     }
     
-    public void testInvalidAggregateIssue190644() {
+    @Test public void testInvalidAggregateIssue190644() {
         helpValidate("SELECT e3 + 1 from pm1.g1 GROUP BY e2 + 1 HAVING e2 + 1 = 5", new String[] {"e3"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidAggregate1() {
+    @Test public void testValidAggregate1() {
         helpValidate("SELECT (e2 + 1) * 2 frOM pm1.g1 GROUP BY e2 + 1", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ 
     }
 
-    public void testValidAggregate2() {
+    @Test public void testValidAggregate2() {
         helpValidate("SELECT e2 + 1 frOM pm1.g1 GROUP BY e2 + 1", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ 
     }
 
-    public void testValidAggregate3() {
+    @Test public void testValidAggregate3() {
         helpValidate("SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
             "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end", //$NON-NLS-1$
             new String[] {}, FakeMetadataFactory.exampleBQTCached());
     }
-	public void testInvalidHaving1() {        
+	@Test public void testInvalidHaving1() {        
         helpValidate("SELECT e3 FROM test.group HAVING e3 > 0", new String[] {"e3"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testInvalidHaving2() {        
+	@Test public void testInvalidHaving2() {        
         helpValidate("SELECT e3 FROM test.group HAVING concat(e3,'a') > 0", new String[] {"e3"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
  
-	public void testNestedAggregateInHaving() {        
+	@Test public void testNestedAggregateInHaving() {        
         helpValidate("SELECT e0 FROM test.group GROUP BY e0 HAVING SUM(COUNT(e0)) > 0", new String[] {"COUNT(e0)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-    public void testNestedAggregateInSelect() {        
+    @Test public void testNestedAggregateInSelect() {        
         helpValidate("SELECT SUM(COUNT(e0)) FROM test.group GROUP BY e0", new String[] {"COUNT(e0)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testValidateCaseInGroupBy() {        
+    @Test public void testValidateCaseInGroupBy() {        
         helpValidate("SELECT SUM(e2) FROM pm1.g1 GROUP BY CASE e2 WHEN 0 THEN 1 ELSE 2 END", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ 
     }
     
-    public void testValidateFunctionInGroupBy() {        
+    @Test public void testValidateFunctionInGroupBy() {        
         helpValidate("SELECT SUM(e2) FROM pm1.g1 GROUP BY (e2 + 1)", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ 
     }
 
-    public void testInvalidScalarSubqueryInGroupBy() {        
+    @Test public void testInvalidScalarSubqueryInGroupBy() {        
         helpValidate("SELECT COUNT(*) FROM pm1.g1 GROUP BY (SELECT 1)", new String[] { "(SELECT 1)" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testInvalidConstantInGroupBy() {        
+    @Test public void testInvalidConstantInGroupBy() {        
         helpValidate("SELECT COUNT(*) FROM pm1.g1 GROUP BY 1", new String[] { "1" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testInvalidReferenceInGroupBy() {        
+    @Test public void testInvalidReferenceInGroupBy() {        
         helpValidate("SELECT COUNT(*) FROM pm1.g1 GROUP BY ?", new String[] { "?" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateObjectType1() {
+    @Test public void testValidateObjectType1() {
         helpValidate("SELECT DISTINCT * FROM test.group", new String[] {"test.\"group\".e2", "test.\"group\".e3", "test.\"group\".e4", "test.\"group\".e5"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
     }
 
-    public void testValidateObjectType2() {
+    @Test public void testValidateObjectType2() {
         helpValidate("SELECT * FROM test.group ORDER BY e1, e2", new String[] {"e2"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateObjectType3() {
+    @Test public void testValidateObjectType3() {
         helpValidate("SELECT e2 AS x FROM test.group ORDER BY x", new String[] {"x"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testValidateNonComparableType() {
+    @Test public void testValidateNonComparableType() {
         helpValidate("SELECT e3 FROM test.group ORDER BY e3", new String[] {"e3"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
     }
  
-    public void testValidateNonComparableType1() {
+    @Test public void testValidateNonComparableType1() {
         helpValidate("SELECT e3 FROM test.group union SELECT e3 FROM test.group", new String[] {"e3"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateNonComparableType2() {
+    @Test public void testValidateNonComparableType2() {
         helpValidate("SELECT e3 FROM test.group GROUP BY e3", new String[] {"e3"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testValidateNonComparableType3() {
+    @Test public void testValidateNonComparableType3() {
         helpValidate("SELECT e3 FROM test.group intersect SELECT e3 FROM test.group", new String[] {"e3"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateNonComparableType4() {
+    @Test public void testValidateNonComparableType4() {
         helpValidate("SELECT e3 FROM test.group except SELECT e3 FROM test.group", new String[] {"e3"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testValidateIntersectAll() {
+    @Test public void testValidateIntersectAll() {
         helpValidate("SELECT e3 FROM pm1.g1 intersect all SELECT e3 FROM pm1.g1", new String[] {"SELECT e3 FROM pm1.g1 INTERSECT ALL SELECT e3 FROM pm1.g1"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testValidateSetSelectInto() {
+    @Test public void testValidateSetSelectInto() {
         helpValidate("SELECT e3 into #temp FROM pm1.g1 intersect all SELECT e3 FROM pm1.g1", new String[] {"SELECT e3 INTO #temp FROM pm1.g1 INTERSECT ALL SELECT e3 FROM pm1.g1"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testInsert1() {
+    @Test public void testInsert1() {
         helpValidate("INSERT INTO test.group (e0) VALUES (null)", new String[] {"e0"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testInsert2() throws Exception {
+    @Test public void testInsert2() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
 
         Command command = QueryParser.getQueryParser().parseCommand("INSERT INTO test.group (e0) VALUES (p1)"); //$NON-NLS-1$
@@ -608,12 +598,12 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
 
-        QueryResolver.resolveCommand(command, externalMetadata, true, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
 
         helpRunValidator(command, new String[] {}, metadata);
     }
 
-    public void testInsert3() throws Exception {
+    @Test public void testInsert3() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
 
         Command command = QueryParser.getQueryParser().parseCommand("INSERT INTO test.group (e0) VALUES (p1+2)"); //$NON-NLS-1$
@@ -627,13 +617,13 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
 
-        QueryResolver.resolveCommand(command, externalMetadata, true, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
 
         helpRunValidator(command, new String[] {}, metadata);
     }
     
 	// non-null, no-default elements not left
-    public void testInsert4() throws Exception {
+    @Test public void testInsert4() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata1();
 
         Command command = QueryParser.getQueryParser().parseCommand("INSERT INTO test.group (e0) VALUES (2)"); //$NON-NLS-1$
@@ -644,7 +634,7 @@
     }
     
 	// non-null, no-default elements left
-    public void testInsert5() throws Exception {
+    @Test public void testInsert5() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata1();
 
         Command command = QueryParser.getQueryParser().parseCommand("INSERT INTO test.group (e1, e2) VALUES ('x', 'y')"); //$NON-NLS-1$
@@ -653,7 +643,7 @@
         helpRunValidator(command, new String[] {"test.\"group\".e0"}, metadata); //$NON-NLS-1$
     }    
 
-    public void testValidateInsertElements1() throws Exception {
+    @Test public void testValidateInsertElements1() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
 
         Command command = QueryParser.getQueryParser().parseCommand("INSERT INTO test.group2 (e0, e1, e2) VALUES (5, 'x', 'y')"); //$NON-NLS-1$
@@ -662,7 +652,7 @@
         helpRunValidator(command, new String[] {"e2", "e0"}, metadata); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateInsertElements2() throws Exception {
+    @Test public void testValidateInsertElements2() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
 
         Command command = QueryParser.getQueryParser().parseCommand("INSERT INTO test.group2 (e1) VALUES ('y')"); //$NON-NLS-1$
@@ -672,19 +662,19 @@
         helpRunValidator(command, new String[] {}, metadata);
     }
 
-    public void testValidateInsertElements3_autoIncNotRequired() throws Exception {
+    @Test public void testValidateInsertElements3_autoIncNotRequired() throws Exception {
     	helpValidate("INSERT INTO test.group (e0) VALUES (1)", new String[] {}, exampleMetadata3()); //$NON-NLS-1$
     }
 
-    public void testUpdate1() {
+    @Test public void testUpdate1() {
         helpValidate("UPDATE test.group SET e0=null", new String[] {"e0"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
         
-    public void testUpdate2() {
+    @Test public void testUpdate2() {
         helpValidate("UPDATE test.group SET e0=1, e0=2", new String[] {"e0"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
-    public void testUpdate3() throws Exception {
+    @Test public void testUpdate3() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
         
         Command command = QueryParser.getQueryParser().parseCommand("UPDATE test.group SET p1=1"); //$NON-NLS-1$
@@ -698,12 +688,12 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
         
-        QueryResolver.resolveCommand(command, externalMetadata, true, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
                 
         helpRunValidator(command, new String[] {"p1"}, metadata); //$NON-NLS-1$
     }
 
-    public void testUpdate4() throws Exception {
+    @Test public void testUpdate4() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
 
         Command command = QueryParser.getQueryParser().parseCommand("UPDATE test.group SET e0=p1"); //$NON-NLS-1$
@@ -717,12 +707,12 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
 
-        QueryResolver.resolveCommand(command, externalMetadata, true, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
 
         helpRunValidator(command, new String[] {}, metadata);
     }
 
-    public void testUpdate5() throws Exception {
+    @Test public void testUpdate5() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
 
         Command command = QueryParser.getQueryParser().parseCommand("UPDATE test.group SET e0=p1+2"); //$NON-NLS-1$
@@ -736,11 +726,11 @@
         Map externalMetadata = new HashMap();
         externalMetadata.put(sqGroup, sqParams);
 
-        QueryResolver.resolveCommand(command, externalMetadata, true, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
         helpRunValidator(command, new String[] {}, metadata);
     }
 
-    public void testValidateUpdateElements1() throws Exception {
+    @Test public void testValidateUpdateElements1() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
 
         Command command = QueryParser.getQueryParser().parseCommand("UPDATE test.group2 SET e0 = 5, e1 = 'x', e2 = 'y'"); //$NON-NLS-1$
@@ -749,7 +739,7 @@
         helpRunValidator(command, new String[] {"e2", "e0"}, metadata); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateUpdateElements2() throws Exception {
+    @Test public void testValidateUpdateElements2() throws Exception {
         QueryMetadataInterface metadata = exampleMetadata();
 
         Command command = QueryParser.getQueryParser().parseCommand("UPDATE test.group2 SET e1 = 'x'"); //$NON-NLS-1$
@@ -757,93 +747,93 @@
 
         helpRunValidator(command, new String[] {}, metadata);
     }
-    public void testXMLQuery1() {
+    @Test public void testXMLQuery1() {
     	helpValidate("SELECT * FROM vm1.doc1", new String[] {}, exampleMetadata()); //$NON-NLS-1$
     }
 
-    public void testXMLQuery2() {
+    @Test public void testXMLQuery2() {
     	helpValidate("SELECT * FROM vm1.doc1 where a2='x'", new String[] {}, exampleMetadata()); //$NON-NLS-1$
     }
 
-    public void testXMLQuery3() {
+    @Test public void testXMLQuery3() {
     	helpValidate("SELECT * FROM vm1.doc1 order by a2", new String[] {}, exampleMetadata()); //$NON-NLS-1$
     }
 
-    public void testXMLQuery6() {
+    @Test public void testXMLQuery6() {
     	helpValidate("SELECT * FROM vm1.doc1 UNION SELECT * FROM vm1.doc1", new String[] {"\"xml\"", "SELECT * FROM vm1.doc1 UNION SELECT * FROM vm1.doc1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public void testXMLQueryWithLimit() {
+    @Test public void testXMLQueryWithLimit() {
     	helpValidate("SELECT * FROM vm1.doc1 limit 1", new String[] {"SELECT * FROM vm1.doc1 LIMIT 1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** test rowlimit function is valid */
-    public void testXMLQueryRowLimit() {
+    @Test public void testXMLQueryRowLimit() {
         helpValidate("SELECT * FROM vm1.doc1 where 2 = RowLimit(a2)", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
     
     /** rowlimit function operand must be nonnegative integer */
-    public void testXMLQueryRowLimit1() {
+    @Test public void testXMLQueryRowLimit1() {
         helpValidate("SELECT * FROM vm1.doc1 where RowLimit(a2)=-1", new String[] {"RowLimit(a2) = -1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** rowlimit function operand must be nonnegative integer */
-    public void testXMLQueryRowLimit2() {
+    @Test public void testXMLQueryRowLimit2() {
         helpValidate("SELECT * FROM vm1.doc1 where RowLimit(a2)='x'", new String[] {"RowLimit(a2) = 'x'"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     /** rowlimit function cannot be nested within another function (this test inserts an implicit type conversion) */
-    public void testXMLQueryRowLimitNested() {
+    @Test public void testXMLQueryRowLimitNested() {
         helpValidate("SELECT * FROM vm1.doc1 where RowLimit(a2)=a2", new String[] {"RowLimit(a2) = a2"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** rowlimit function cannot be nested within another function */
-    public void testXMLQueryRowLimitNested2() {
+    @Test public void testXMLQueryRowLimitNested2() {
         helpValidate("SELECT * FROM vm1.doc1 where convert(RowLimit(a2), string)=a2", new String[] {"convert(RowLimit(a2), string) = a2"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     /** rowlimit function operand must be nonnegative integer */
-    public void testXMLQueryRowLimit3a() {
+    @Test public void testXMLQueryRowLimit3a() {
         helpValidate("SELECT * FROM vm1.doc1 where RowLimit(a2) = convert(a2, integer)", new String[] {"RowLimit(a2) = convert(a2, integer)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     /** rowlimit function operand must be nonnegative integer */
-    public void testXMLQueryRowLimit3b() {
+    @Test public void testXMLQueryRowLimit3b() {
         helpValidate("SELECT * FROM vm1.doc1 where convert(a2, integer) = RowLimit(a2)", new String[] {"convert(a2, integer) = RowLimit(a2)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
     /** rowlimit function arg must be an element symbol */
-    public void testXMLQueryRowLimit4() {
+    @Test public void testXMLQueryRowLimit4() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit('x') = 3", new String[] {"rowlimit('x')"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** rowlimit function arg must be an element symbol */
-    public void testXMLQueryRowLimit5() {
+    @Test public void testXMLQueryRowLimit5() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(concat(a2, 'x')) = 3", new String[] {"rowlimit(concat(a2, 'x'))"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     /** rowlimit function arg must be a single conjunct */
-    public void testXMLQueryRowLimitConjunct() {
+    @Test public void testXMLQueryRowLimitConjunct() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) = 3 OR a2 = 'x'", new String[] {"(rowlimit(a2) = 3) OR (a2 = 'x')"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** rowlimit function arg must be a single conjunct */
-    public void testXMLQueryRowLimitCompound() {
+    @Test public void testXMLQueryRowLimitCompound() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) = 3 AND a2 = 'x'", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
     /** rowlimit function arg must be a single conjunct */
-    public void testXMLQueryRowLimitCompound2() {
+    @Test public void testXMLQueryRowLimitCompound2() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) = 3 AND concat(a2, 'y') = 'xy'", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
     /** rowlimit function arg must be a single conjunct */
-    public void testXMLQueryRowLimitCompound3() {
+    @Test public void testXMLQueryRowLimitCompound3() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) = 3 AND (concat(a2, 'y') = 'xy' OR concat(a2, 'y') = 'zy')", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }    
 
     /** each rowlimit function arg must be a single conjunct */
-    public void testXMLQueryRowLimitCompound4() {
+    @Test public void testXMLQueryRowLimitCompound4() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) = 3 AND rowlimit(c2) = 4", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }    
 
@@ -852,118 +842,118 @@
      * invalidated here (could be two different elements but in the same 
      * mapping class - needs to be caught in XMLPlanner)
      */
-    public void testXMLQueryRowLimitCompound5() {
+    @Test public void testXMLQueryRowLimitCompound5() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) = 3 AND rowlimit(a2) = 4", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }    
 
-    public void testXMLQueryRowLimitInvalidCriteria() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria() {
         helpValidate("SELECT * FROM vm1.doc1 where not(rowlimit(a2) = 3)", new String[] {"NOT (rowlimit(a2) = 3)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitInvalidCriteria2() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria2() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) IN (3)", new String[] {"rowlimit(a2) IN (3)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
-    public void testXMLQueryRowLimitInvalidCriteria3() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria3() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) LIKE 'x'", new String[] {"rowlimit(a2) LIKE 'x'"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitInvalidCriteria4() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria4() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) IS NULL", new String[] {"rowlimit(a2) IS NULL"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitInvalidCriteria5() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria5() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) IN (SELECT e0 FROM vTest.vMap)", new String[] {"rowlimit(a2) IN (SELECT e0 FROM vTest.vMap)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitInvalidCriteria6() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria6() {
         helpValidate("SELECT * FROM vm1.doc1 where 2 = CASE WHEN rowlimit(a2) = 2 THEN 2 END", new String[] {"2 = CASE WHEN rowlimit(a2) = 2 THEN 2 END"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitInvalidCriteria6a() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria6a() {
         helpValidate("SELECT * FROM vm1.doc1 where 2 = CASE rowlimit(a2) WHEN 2 THEN 2 END", new String[] {"2 = CASE rowlimit(a2) WHEN 2 THEN 2 END"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
-    public void testXMLQueryRowLimitInvalidCriteria7() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria7() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) BETWEEN 2 AND 3", new String[] {"rowlimit(a2) BETWEEN 2 AND 3"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitInvalidCriteria8() {
+    @Test public void testXMLQueryRowLimitInvalidCriteria8() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimit(a2) = ANY (SELECT e0 FROM vTest.vMap)", new String[] {"rowlimit(a2) = ANY (SELECT e0 FROM vTest.vMap)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
     /** using rowlimit pseudo-function in non-XML query is invalid */
-    public void testNonXMLQueryRowLimit() {        
+    @Test public void testNonXMLQueryRowLimit() {        
         helpValidate("SELECT e2 FROM vTest.vMap WHERE rowlimit(e1) = 2", new String[] {"rowlimit(e1)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
     /** test rowlimitexception function is valid */
-    public void testXMLQueryRowLimitException() {
+    @Test public void testXMLQueryRowLimitException() {
         helpValidate("SELECT * FROM vm1.doc1 where 2 = RowLimitException(a2)", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
     
     /** rowlimitexception function operand must be nonnegative integer */
-    public void testXMLQueryRowLimitException1() {
+    @Test public void testXMLQueryRowLimitException1() {
         helpValidate("SELECT * FROM vm1.doc1 where RowLimitException(a2)=-1", new String[] {"RowLimitException(a2) = -1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** rowlimitexception function operand must be nonnegative integer */
-    public void testXMLQueryRowLimitException2() {
+    @Test public void testXMLQueryRowLimitException2() {
         helpValidate("SELECT * FROM vm1.doc1 where RowLimitException(a2)='x'", new String[] {"RowLimitException(a2) = 'x'"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     /** rowlimitexception function cannot be nested within another function (this test inserts an implicit type conversion) */
-    public void testXMLQueryRowLimitExceptionNested() {
+    @Test public void testXMLQueryRowLimitExceptionNested() {
         helpValidate("SELECT * FROM vm1.doc1 where RowLimitException(a2)=a2", new String[] {"RowLimitException(a2) = a2"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** rowlimitexception function cannot be nested within another function */
-    public void testXMLQueryRowLimitExceptionNested2() {
+    @Test public void testXMLQueryRowLimitExceptionNested2() {
         helpValidate("SELECT * FROM vm1.doc1 where convert(RowLimitException(a2), string)=a2", new String[] {"convert(RowLimitException(a2), string) = a2"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     /** rowlimitexception function operand must be nonnegative integer */
-    public void testXMLQueryRowLimitException3a() {
+    @Test public void testXMLQueryRowLimitException3a() {
         helpValidate("SELECT * FROM vm1.doc1 where RowLimitException(a2) = convert(a2, integer)", new String[] {"RowLimitException(a2) = convert(a2, integer)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     /** rowlimitexception function operand must be nonnegative integer */
-    public void testXMLQueryRowLimitException3b() {
+    @Test public void testXMLQueryRowLimitException3b() {
         helpValidate("SELECT * FROM vm1.doc1 where convert(a2, integer) = RowLimitException(a2)", new String[] {"convert(a2, integer) = RowLimitException(a2)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
     /** rowlimitexception function arg must be an element symbol */
-    public void testXMLQueryRowLimitException4() {
+    @Test public void testXMLQueryRowLimitException4() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception('x') = 3", new String[] {"rowlimitexception('x')"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** rowlimitexception function arg must be an element symbol */
-    public void testXMLQueryRowLimitException5() {
+    @Test public void testXMLQueryRowLimitException5() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(concat(a2, 'x')) = 3", new String[] {"rowlimitexception(concat(a2, 'x'))"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     /** rowlimitexception function arg must be a single conjunct */
-    public void testXMLQueryRowLimitExceptionConjunct() {
+    @Test public void testXMLQueryRowLimitExceptionConjunct() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) = 3 OR a2 = 'x'", new String[] {"(rowlimitexception(a2) = 3) OR (a2 = 'x')"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /** rowlimitexception function arg must be a single conjunct */
-    public void testXMLQueryRowLimitExceptionCompound() {
+    @Test public void testXMLQueryRowLimitExceptionCompound() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) = 3 AND a2 = 'x'", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
     /** rowlimitexception function arg must be a single conjunct */
-    public void testXMLQueryRowLimitExceptionCompound2() {
+    @Test public void testXMLQueryRowLimitExceptionCompound2() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) = 3 AND concat(a2, 'y') = 'xy'", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
     /** rowlimitexception function arg must be a single conjunct */
-    public void testXMLQueryRowLimitExceptionCompound3() {
+    @Test public void testXMLQueryRowLimitExceptionCompound3() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) = 3 AND (concat(a2, 'y') = 'xy' OR concat(a2, 'y') = 'zy')", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }    
 
     /** each rowlimitexception function arg must be a single conjunct */
-    public void testXMLQueryRowLimitExceptionCompound4() {
+    @Test public void testXMLQueryRowLimitExceptionCompound4() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) = 3 AND rowlimitexception(c2) = 4", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }    
 
@@ -972,106 +962,106 @@
      * invalidated here (could be two different elements but in the same 
      * mapping class - needs to be caught in XMLPlanner)
      */
-    public void testXMLQueryRowLimitExceptionCompound5() {
+    @Test public void testXMLQueryRowLimitExceptionCompound5() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) = 3 AND rowlimitexception(a2) = 4", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }    
 
-    public void testXMLQueryRowLimitExceptionInvalidCriteria() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria() {
         helpValidate("SELECT * FROM vm1.doc1 where not(rowlimitexception(a2) = 3)", new String[] {"NOT (rowlimitexception(a2) = 3)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitExceptionInvalidCriteria2() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria2() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) IN (3)", new String[] {"rowlimitexception(a2) IN (3)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
-    public void testXMLQueryRowLimitExceptionInvalidCriteria3() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria3() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) LIKE 'x'", new String[] {"rowlimitexception(a2) LIKE 'x'"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitExceptionInvalidCriteria4() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria4() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) IS NULL", new String[] {"rowlimitexception(a2) IS NULL"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitExceptionInvalidCriteria5() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria5() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) IN (SELECT e0 FROM vTest.vMap)", new String[] {"rowlimitexception(a2) IN (SELECT e0 FROM vTest.vMap)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitExceptionInvalidCriteria6() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria6() {
         helpValidate("SELECT * FROM vm1.doc1 where 2 = CASE WHEN rowlimitexception(a2) = 2 THEN 2 END", new String[] {"2 = CASE WHEN rowlimitexception(a2) = 2 THEN 2 END"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitExceptionInvalidCriteria6a() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria6a() {
         helpValidate("SELECT * FROM vm1.doc1 where 2 = CASE rowlimitexception(a2) WHEN 2 THEN 2 END", new String[] {"2 = CASE rowlimitexception(a2) WHEN 2 THEN 2 END"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
-    public void testXMLQueryRowLimitExceptionInvalidCriteria7() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria7() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) BETWEEN 2 AND 3", new String[] {"rowlimitexception(a2) BETWEEN 2 AND 3"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
-    public void testXMLQueryRowLimitExceptionInvalidCriteria8() {
+    @Test public void testXMLQueryRowLimitExceptionInvalidCriteria8() {
         helpValidate("SELECT * FROM vm1.doc1 where rowlimitexception(a2) = ANY (SELECT e0 FROM vTest.vMap)", new String[] {"rowlimitexception(a2) = ANY (SELECT e0 FROM vTest.vMap)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
     /** using rowlimit pseudo-function in non-XML query is invalid */
-    public void testNonXMLQueryRowLimitException() {        
+    @Test public void testNonXMLQueryRowLimitException() {        
         helpValidate("SELECT e2 FROM vTest.vMap WHERE rowlimitexception(e1) = 2", new String[] {"rowlimitexception(e1)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }    
 
     /** using context pseudo-function in non-XML query is invalid */
-    public void testNonXMLQueryContextOperator() {        
+    @Test public void testNonXMLQueryContextOperator() {        
         helpValidate("SELECT e2 FROM vTest.vMap WHERE context(e1, e1) = 2", new String[] {"context(e1, e1)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }      
     
-    public void testValidateSubquery1() {        
+    @Test public void testValidateSubquery1() {        
         helpValidate("SELECT e2 FROM (SELECT e2 FROM vTest.vMap WHERE e2 = 'a') AS x", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
-    public void testValidateSubquery2() {        
+    @Test public void testValidateSubquery2() {        
         helpValidate("SELECT e2 FROM (SELECT e3 FROM vTest.vMap) AS x, vTest.vMap WHERE e2 = 'a'", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
     
-    public void testValidateSubquery3() {        
+    @Test public void testValidateSubquery3() {        
         helpValidate("SELECT * FROM pm1.g1, (EXEC pm1.sq1( )) AS alias", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
     }
 
-    public void testValidateUnionWithSubquery() {        
+    @Test public void testValidateUnionWithSubquery() {        
         helpValidate("SELECT e2 FROM test.group2 union all SELECT e3 FROM test.group union all select * from (SELECT e1 FROM test.group) as subquery1", new String[] {"e1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateExistsSubquery() {        
+    @Test public void testValidateExistsSubquery() {        
         helpValidate("SELECT e2 FROM test.group2 WHERE EXISTS (SELECT e2 FROM vTest.vMap WHERE e2 = 'a')", new String[] {}, exampleMetadata()); //$NON-NLS-1$ 
     }
 
-    public void testValidateScalarSubquery() {        
+    @Test public void testValidateScalarSubquery() {        
         helpValidate("SELECT e2, (SELECT e1 FROM vTest.vMap WHERE e2 = '3') FROM test.group2", new String[] {"e1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$ 
     }
 
-    public void testValidateAnyCompareSubquery() {        
+    @Test public void testValidateAnyCompareSubquery() {        
         helpValidate("SELECT e2 FROM test.group2 WHERE e1 < ANY (SELECT e1 FROM test.group)", new String[] {"e1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateAllCompareSubquery() {        
+    @Test public void testValidateAllCompareSubquery() {        
         helpValidate("SELECT e2 FROM test.group2 WHERE e1 = ALL (SELECT e1 FROM test.group)", new String[] {"e1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateSomeCompareSubquery() {        
+    @Test public void testValidateSomeCompareSubquery() {        
         helpValidate("SELECT e2 FROM test.group2 WHERE e1 <= SOME (SELECT e1 FROM test.group)", new String[] {"e1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateCompareSubquery() {        
+    @Test public void testValidateCompareSubquery() {        
         helpValidate("SELECT e2 FROM test.group2 WHERE e1 >= (SELECT e1 FROM test.group WHERE e1 = 1)", new String[] {"e1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateInClauseSubquery() {        
+    @Test public void testValidateInClauseSubquery() {        
         helpValidate("SELECT e2 FROM test.group2 WHERE e1 IN (SELECT e1 FROM test.group)", new String[] {"e1"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testValidateExec1() {
+    @Test public void testValidateExec1() {
         helpValidate("EXEC pm1.sq1()", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
     }
     
 	// variable declared is of special type INPUT
-    public void testCreateUpdateProcedure1() {
+    @Test public void testCreateUpdateProcedure1() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer INPUT;\n"; //$NON-NLS-1$
@@ -1085,7 +1075,7 @@
     }
     
 	// variable declared is of special type CHANGING
-    public void testCreateUpdateProcedure3() {
+    @Test public void testCreateUpdateProcedure3() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer CHANGING;\n"; //$NON-NLS-1$
@@ -1099,7 +1089,7 @@
     }
 
 	// valid variable declared
-    public void testCreateUpdateProcedure4() {
+    @Test public void testCreateUpdateProcedure4() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1113,7 +1103,7 @@
     }
     
 	// validating criteria selector(on HAS CRITERIA), elements on it should be virtual group elements
-    public void testCreateUpdateProcedure5() {
+    @Test public void testCreateUpdateProcedure5() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1130,7 +1120,7 @@
     }
     
 	// validating Translate CRITERIA, elements on it should be virtual group elements
-    public void testCreateUpdateProcedure7() {
+    @Test public void testCreateUpdateProcedure7() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1145,7 +1135,7 @@
     }
     
 	// ROWS_UPDATED not assigned
-    public void testCreateUpdateProcedure8() {
+    @Test public void testCreateUpdateProcedure8() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1159,7 +1149,7 @@
     }
 
 	// validating AssignmentStatement, ROWS_UPDATED element assigned
-    public void testCreateUpdateProcedure9() {
+    @Test public void testCreateUpdateProcedure9() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1175,7 +1165,7 @@
     
 	// validating AssignmentStatement, variable type and assigned type 
 	// do not match
-    public void testCreateUpdateProcedure10() {
+    @Test public void testCreateUpdateProcedure10() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1191,7 +1181,7 @@
 
 	// validating AssignmentStatement, more than one project symbol on the
 	// command
-    public void testCreateUpdateProcedure11() {
+    @Test public void testCreateUpdateProcedure11() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1207,7 +1197,7 @@
     
 	// validating AssignmentStatement, more than one project symbol on the
 	// command
-    public void testCreateUpdateProcedure12() {
+    @Test public void testCreateUpdateProcedure12() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1222,7 +1212,7 @@
     }
     
 	// TranslateCriteria on criteria of the if statement
-    public void testCreateUpdateProcedure13() {
+    @Test public void testCreateUpdateProcedure13() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1240,7 +1230,7 @@
     }
     
 	// INPUT ised in command
-    public void testCreateUpdateProcedure16() {
+    @Test public void testCreateUpdateProcedure16() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1256,7 +1246,7 @@
     
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
 	// elements on with should be on ON
-    public void testCreateUpdateProcedure17() {
+    @Test public void testCreateUpdateProcedure17() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1272,7 +1262,7 @@
     
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
 	// failure, aggregate function in query transform
-    public void testCreateUpdateProcedure18() {
+    @Test public void testCreateUpdateProcedure18() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1288,7 +1278,7 @@
     
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
 	// failure, aggregate function in query transform
-    public void testCreateUpdateProcedure18a() {
+    @Test public void testCreateUpdateProcedure18a() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1305,7 +1295,7 @@
 	
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
 	// failure, translated criteria elements not present on groups of command
-    public void testCreateUpdateProcedure19() {
+    @Test public void testCreateUpdateProcedure19() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1320,7 +1310,7 @@
 	}
 	
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    public void testCreateUpdateProcedure20() {
+    @Test public void testCreateUpdateProcedure20() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1335,7 +1325,7 @@
 	}
 
 	// variables cannot be used among insert elements
-    public void testCreateUpdateProcedure23() {
+    @Test public void testCreateUpdateProcedure23() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1350,7 +1340,7 @@
 	}
 	
 	// variables cannot be used among insert elements
-    public void testCreateUpdateProcedure24() {
+    @Test public void testCreateUpdateProcedure24() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1365,7 +1355,7 @@
 	}
 
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    public void testCreateUpdateProcedure25() {
+    @Test public void testCreateUpdateProcedure25() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1380,7 +1370,7 @@
 	}
 
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    public void testCreateUpdateProcedure26() {
+    @Test public void testCreateUpdateProcedure26() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1395,7 +1385,7 @@
 	}
 
 	// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
-    public void testCreateUpdateProcedure27() {
+    @Test public void testCreateUpdateProcedure27() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1409,7 +1399,7 @@
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 	}
     
-    public void testCreateUpdateProcedure28() {
+    @Test public void testCreateUpdateProcedure28() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1424,7 +1414,7 @@
 	}
 
     // using aggregate function within a procedure - defect #8394
-    public void testCreateUpdateProcedure31() {
+    @Test public void testCreateUpdateProcedure31() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE string MaxTran;\n"; //$NON-NLS-1$
@@ -1439,7 +1429,7 @@
     }
     
 	// assigning null values to known datatype variable
-	public void testCreateUpdateProcedure32() {
+	@Test public void testCreateUpdateProcedure32() {
 		String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
 		procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
 		procedure = procedure + "DECLARE string var;\n"; //$NON-NLS-1$
@@ -1453,7 +1443,7 @@
 				FakeMetadataObject.Props.UPDATE_PROCEDURE);
 	}
     
-    public void testDefect13643() {
+    @Test public void testDefect13643() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1470,7 +1460,7 @@
                 FakeMetadataObject.Props.UPDATE_PROCEDURE);
     }
     
-    public void testValidHaving() {
+    @Test public void testValidHaving() {
         helpValidate(
             "SELECT DISTINCT ProdHier.prod_num " + //$NON-NLS-1$
             "FROM Sales, ProdHier, Cust " + //$NON-NLS-1$
@@ -1480,7 +1470,7 @@
             new String[] { }, FakeMetadataFactory.exampleSymphony());
     } 
     
-    public void testValidHaving2() {
+    @Test public void testValidHaving2() {
         String sql =  "SELECT intkey FROM bqt1.smalla WHERE intkey = 1 " + //$NON-NLS-1$
             "GROUP BY intkey HAVING intkey = 1";         //$NON-NLS-1$
         QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();        
@@ -1495,15 +1485,15 @@
         }        
     } 
     
-    public void testVirtualProcedure(){
+    @Test public void testVirtualProcedure(){
           helpValidate("EXEC pm1.vsp1()", new String[] { }, FakeMetadataFactory.example1Cached());  //$NON-NLS-1$
     }
         
-    public void testSelectWithNoFrom() {        
+    @Test public void testSelectWithNoFrom() {        
         helpValidate("SELECT 5", new String[] {}, exampleMetadata()); //$NON-NLS-1$
     }
     
-    public void testSelectIntoTempGroup() {
+    @Test public void testSelectIntoTempGroup() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g2;\n";         //$NON-NLS-1$
@@ -1519,7 +1509,7 @@
     /**
      * Defect 24346
      */
-    public void testInvalidSelectIntoTempGroup() {
+    @Test public void testInvalidSelectIntoTempGroup() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "SELECT e1, e2, e3, e4 INTO #myTempTable FROM pm1.g2;\n";         //$NON-NLS-1$
@@ -1536,7 +1526,7 @@
     /**
      * Defect 24346 with type mismatch
      */
-    public void testInvalidSelectIntoTempGroup1() {
+    @Test public void testInvalidSelectIntoTempGroup1() {
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
         procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
         procedure = procedure + "create local temporary table #myTempTable (e1 integer);\n";         //$NON-NLS-1$
@@ -1551,7 +1541,7 @@
     }
 
     
-    public void testSelectIntoPhysicalGroup() {
+    @Test public void testSelectIntoPhysicalGroup() {
         helpValidate("SELECT e1, e2, e3, e4 INTO pm1.g1 FROM pm1.g2", new String[] { }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
         
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
@@ -1566,15 +1556,15 @@
                 FakeMetadataObject.Props.UPDATE_PROCEDURE);
     }
     
-    public void testSelectIntoPhysicalGroupNotUpdateable_Defect16857() {
+    @Test public void testSelectIntoPhysicalGroupNotUpdateable_Defect16857() {
         helpValidate("SELECT e0, e1, e2 INTO test.group3 FROM test.group2", new String[] {"test.group3"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testSelectIntoElementsNotUpdateable() {
+    @Test public void testSelectIntoElementsNotUpdateable() {
     	helpValidate("SELECT e0, e1, e2 INTO test.group2 FROM test.group3", new String[] {"test.group2"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testInvalidSelectIntoTooManyElements() {
+    @Test public void testInvalidSelectIntoTooManyElements() {
     	helpValidate("SELECT e1, e2, e3, e4, 'val' INTO pm1.g1 FROM pm1.g2", new String[] {"SELECT e1, e2, e3, e4, 'val' INTO pm1.g1 FROM pm1.g2"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
         
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
@@ -1589,7 +1579,7 @@
                 FakeMetadataObject.Props.UPDATE_PROCEDURE);
     }
     
-    public void testInvalidSelectIntoTooFewElements() {
+    @Test public void testInvalidSelectIntoTooFewElements() {
     	helpValidate("SELECT e1, e2, e3 INTO pm1.g1 FROM pm1.g2", new String[] {"SELECT e1, e2, e3 INTO pm1.g1 FROM pm1.g2"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
         
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
@@ -1604,7 +1594,7 @@
                 FakeMetadataObject.Props.UPDATE_PROCEDURE);
     }
     
-    public void testInvalidSelectIntoIncorrectTypes() {
+    @Test public void testInvalidSelectIntoIncorrectTypes() {
         helpValidate("SELECT e1, convert(e2, string), e3, e4 INTO pm1.g1 FROM pm1.g2", new String[] {"SELECT e1, convert(e2, string), e3, e4 INTO pm1.g1 FROM pm1.g2"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
         
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
@@ -1619,11 +1609,11 @@
                 FakeMetadataObject.Props.UPDATE_PROCEDURE);
     }
     
-    public void testSelectIntoWithStar() {
+    @Test public void testSelectIntoWithStar() {
         helpResolve("SELECT * INTO pm1.g1 FROM pm1.g2", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
     }
     
-    public void testInvalidSelectIntoWithStar() {
+    @Test public void testInvalidSelectIntoWithStar() {
         helpValidate("SELECT * INTO pm1.g1 FROM pm1.g2, pm1.g1", new String[] {"SELECT * INTO pm1.g1 FROM pm1.g2, pm1.g1"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
         
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
@@ -1638,7 +1628,7 @@
                 FakeMetadataObject.Props.UPDATE_PROCEDURE);
     }
     
-    public void testSelectIntoVirtualGroup() {
+    @Test public void testSelectIntoVirtualGroup() {
         helpValidate("SELECT e1, e2, e3, e4 INTO vm1.g1 FROM pm1.g2", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
         
         String procedure = "CREATE PROCEDURE  "; //$NON-NLS-1$
@@ -1653,26 +1643,26 @@
                 FakeMetadataObject.Props.UPDATE_PROCEDURE);
     }
     
-    public void testVirtualProcedure2(){
+    @Test public void testVirtualProcedure2(){
           helpValidate("EXEC pm1.vsp13()", new String[] { }, FakeMetadataFactory.example1Cached());  //$NON-NLS-1$
     }
 
     //procedure that has another procedure in the transformation
-    public void testVirtualProcedure3(){
+    @Test public void testVirtualProcedure3(){
         helpValidate("EXEC pm1.vsp27()", new String[] { }, FakeMetadataFactory.example1Cached());  //$NON-NLS-1$
     }
     
-    public void testNonEmbeddedSubcommand_defect11000() {        
+    @Test public void testNonEmbeddedSubcommand_defect11000() {        
         helpValidate("SELECT e0 FROM vTest.vGroup", new String[0], exampleMetadata()); //$NON-NLS-1$ 
     }
     
-    public void testValidateObjectInComparison() throws Exception {
+    @Test public void testValidateObjectInComparison() throws Exception {
         String sql = "SELECT IntKey FROM BQT1.SmallA WHERE ObjectValue = 5";   //$NON-NLS-1$
         ValidatorReport report = helpValidate(sql, new String[] {"ObjectValue = 5"}, FakeMetadataFactory.exampleBQTCached()); //$NON-NLS-1$
         assertEquals("Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used in comparison: ObjectValue = 5.", report.toString()); //$NON-NLS-1$
     }
 
-    public void testValidateAssignmentWithFunctionOnParameter_InServer() throws Exception{
+    @Test public void testValidateAssignmentWithFunctionOnParameter_InServer() throws Exception{
         String sql = "EXEC pm1.vsp36(5)";  //$NON-NLS-1$
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         
@@ -1684,7 +1674,7 @@
         assertEquals(0, report.getItems().size());                      
     }
 
-    public void testDefect9917() throws Exception{
+    @Test public void testDefect9917() throws Exception{
     	QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         String sql = "SELECT lookup('pm1.g1', 'e1a', 'e2', e2) AS x, lookup('pm1.g1', 'e4', 'e3', e3) AS y FROM pm1.g1"; //$NON-NLS-1$
         Command command = new QueryParser().parseCommand(sql);
@@ -1705,7 +1695,7 @@
         }
     }
     
-    public void testLookupKeyElementComparable() throws Exception {
+    @Test public void testLookupKeyElementComparable() throws Exception {
     	QueryMetadataInterface metadata = exampleMetadata2();
         String sql = "SELECT lookup('test.group', 'e2', 'e3', convert(e2, blob)) AS x FROM test.group"; //$NON-NLS-1$
         Command command = QueryParser.getQueryParser().parseCommand(sql);
@@ -1715,7 +1705,7 @@
         assertEquals("Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used as LOOKUP key columns: test.\"group\".e3.", report.toString()); //$NON-NLS-1$
     }
     
-    public void testDefect12107() throws Exception{
+    @Test public void testDefect12107() throws Exception{
     	QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         String sql = "SELECT SUM(DISTINCT lookup('pm1.g1', 'e2', 'e2', e2)) FROM pm1.g1"; //$NON-NLS-1$
         Command command = helpResolve(sql, metadata);
@@ -1730,13 +1720,13 @@
         
         GroupSymbol group = new GroupSymbol(procName);
         Map externalMetadata = getStoredProcedureExternalMetadata(group, metadata);
-        QueryResolver.resolveCommand(command, externalMetadata, false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
         
         // Validate
         return Validator.validate(command, metadata);         
     }
 
-    public void testValidateDynamicCommandWithNonTempGroup_InModeler() throws Exception{
+    @Test public void testValidateDynamicCommandWithNonTempGroup_InModeler() throws Exception{
         // SQL is same as pm1.vsp36() in example1 
         String sql = "CREATE VIRTUAL PROCEDURE BEGIN execute string 'select ' || '1' as X integer into pm1.g3; END";  //$NON-NLS-1$        
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
@@ -1747,7 +1737,7 @@
         assertEquals("Wrong number of elements being SELECTed INTO the target table. Expected 4 elements, but was 1.", report.toString()); //$NON-NLS-1$
     }
     
-    public void testDynamicDupUsing() throws Exception {
+    @Test public void testDynamicDupUsing() throws Exception {
         String sql = "CREATE VIRTUAL PROCEDURE BEGIN execute string 'select ' || '1' as X integer into #temp using id=1, id=2; END";  //$NON-NLS-1$        
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         
@@ -1757,7 +1747,7 @@
         assertEquals("Elements cannot appear more than once in a SET or USING clause.  The following elements are duplicated: [\"USING\".id]", report.toString()); //$NON-NLS-1$
     }    
     
-    public void testValidateAssignmentWithFunctionOnParameter_InModeler() throws Exception{
+    @Test public void testValidateAssignmentWithFunctionOnParameter_InModeler() throws Exception{
         // SQL is same as pm1.vsp36() in example1 
         String sql = "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; x = pm1.vsp36.param1 * 2; SELECT x; END";  //$NON-NLS-1$        
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
@@ -1767,7 +1757,7 @@
         assertEquals(0, report.getItems().size());                      
     }
     
-    public void testDefect12533() {
+    @Test public void testDefect12533() {
         String sql = "SELECT BQT1.SmallA.DateValue, BQT2.SmallB.ObjectValue FROM BQT1.SmallA, BQT2.SmallB " +  //$NON-NLS-1$
             "WHERE BQT1.SmallA.DateValue = BQT2.SmallB.DateValue AND BQT1.SmallA.ObjectValue = BQT2.SmallB.ObjectValue " + //$NON-NLS-1$
             "AND BQT1.SmallA.IntKey < 30 AND BQT2.SmallB.IntKey < 30 ORDER BY BQT1.SmallA.DateValue"; //$NON-NLS-1$
@@ -1777,7 +1767,7 @@
         helpValidate(sql, new String[] {"BQT1.SmallA.ObjectValue = BQT2.SmallB.ObjectValue"}, metadata);  //$NON-NLS-1$ 
     }
 
-    public void testDefect16772() throws Exception{
+    @Test public void testDefect16772() throws Exception{
         String sql = "CREATE VIRTUAL PROCEDURE BEGIN IF (pm1.vsp42.param1 > 0) SELECT 1 AS x; ELSE SELECT 0 AS x; END"; //$NON-NLS-1$
         
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
@@ -1787,12 +1777,12 @@
         assertEquals("Expected report to have no validation failures", false, report.hasItems()); //$NON-NLS-1$
     }
 	
-	public void testDefect14886() throws Exception{        
+	@Test public void testDefect14886() throws Exception{        
         String sql = "CREATE VIRTUAL PROCEDURE BEGIN END";  //$NON-NLS-1$        
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         
         Command command = new QueryParser().parseCommand(sql);
-        QueryResolver.resolveCommand(command, new HashMap(), false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, new HashMap(), metadata, AnalysisRecord.createNonRecordingRecord());
         
         // Validate
         ValidatorReport report = Validator.validate(command, metadata); 
@@ -1800,14 +1790,14 @@
         assertEquals(1, report.getItems().size());  	
     }
 	
-    public void testDefect21389() throws Exception{        
+    @Test public void testDefect21389() throws Exception{        
         String sql = "CREATE VIRTUAL PROCEDURE BEGIN SELECT * INTO #temptable FROM pm1.g1; INSERT INTO #temptable (e1) VALUES ('a'); END"; //$NON-NLS-1$      
         FakeMetadataFacade metadata = FakeMetadataFactory.example1();
         FakeMetadataObject e1 = metadata.getStore().findObject("pm1.g1.e1", FakeMetadataObject.ELEMENT); //$NON-NLS-1$
         e1.putProperty(FakeMetadataObject.Props.UPDATE, Boolean.FALSE);
         
         Command command = new QueryParser().parseCommand(sql);
-        QueryResolver.resolveCommand(command, new HashMap(), false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, new HashMap(), metadata, AnalysisRecord.createNonRecordingRecord());
         
         // Validate
         ValidatorReport report = Validator.validate(command, metadata); 
@@ -1815,18 +1805,18 @@
         assertEquals(0, report.getItems().size());      
     }
     
-    public void testMakeNotDep() {
+    @Test public void testMakeNotDep() {
         helpValidate("select group2.e1, group3.e2 from group2, group3 WHERE group2.e0 = group3.e0 OPTION MAKENOTDEP group2, group3", new String[0], exampleMetadata()); //$NON-NLS-1$
     }
-    public void testInvalidMakeNotDep() {
+    @Test public void testInvalidMakeNotDep() {
     	helpValidate("select group2.e1, group3.e2 from group2, group3 WHERE group2.e0 = group3.e0 OPTION MAKEDEP group2 MAKENOTDEP group2, group3", new String[] {"OPTION MAKEDEP group2 MAKENOTDEP group2, group3"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testInvalidLimit() {
+    @Test public void testInvalidLimit() {
         helpValidate("SELECT * FROM pm1.g1 LIMIT -5", new String[] {"LIMIT -5"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testInvalidLimit_Offset() {
+    @Test public void testInvalidLimit_Offset() {
     	helpValidate("SELECT * FROM pm1.g1 LIMIT -1, 100", new String[] {"LIMIT -1, 100"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
@@ -1838,7 +1828,7 @@
      * 
      * This virtual procedure calls a physical stored procedure directly.  
      */
-    public void testCase4237() {
+    @Test public void testCase4237() {
 
         FakeMetadataFacade metadata = helpCreateCase4237VirtualProcedureMetadata();
         Map externalMetadata = helpCreateCase4237ExternalMetadata(metadata);
@@ -1852,7 +1842,7 @@
      * This test was already working before the case was logged, due for some reason
      * to the exec() statement being inside an inline view.  This is a control test. 
      */
-    public void testCase4237InlineView() {
+    @Test public void testCase4237InlineView() {
 
         FakeMetadataFacade metadata = helpCreateCase4237VirtualProcedureMetadata();
         Map externalMetadata = helpCreateCase4237ExternalMetadata(metadata);
@@ -1917,32 +1907,32 @@
         return new FakeMetadataFacade(store);
     }       
     
-    public void testSelectIntoWithNull() {
+    @Test public void testSelectIntoWithNull() {
         helpValidate("SELECT null, null, null, null INTO pm1.g1 FROM pm1.g2", new String[] {}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
     }
         
-    public void testDropNonTemporary() {
+    @Test public void testDropNonTemporary() {
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         Command command = helpResolve("drop table pm1.g1", metadata); //$NON-NLS-1$
         helpRunValidator(command, new String[] {command.toString()}, FakeMetadataFactory.example1Cached()); 
     }
     
-    public void testNestedContexts() {
+    @Test public void testNestedContexts() {
         helpValidate("SELECT * FROM vm1.doc1 where context(a0, context(a0, a2))='x'", new String[] {"context(a0, context(a0, a2))"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testValidContextElement() {
+    @Test public void testValidContextElement() {
         helpValidate("SELECT * FROM vm1.doc1 where context(1, a2)='x'", new String[] {"context(1, a2)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testInsertIntoVirtualWithQuery() throws Exception {
+    @Test public void testInsertIntoVirtualWithQuery() throws Exception {
         QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
         Command command = helpResolve("insert into vm1.g1 select 1, 2, true, 3", metadata); //$NON-NLS-1$
         ValidatorReport report = Validator.validate(command, metadata);
         assertTrue(report.getItems().isEmpty());
     }
     
-    public void testDynamicIntoDeclaredTemp() throws Exception {
+    @Test public void testDynamicIntoDeclaredTemp() throws Exception {
         StringBuffer procedure = new StringBuffer("CREATE VIRTUAL PROCEDURE  ") //$NON-NLS-1$
                                 .append("BEGIN\n") //$NON-NLS-1$
                                 .append("CREATE LOCAL TEMPORARY TABLE x (column1 string);") //$NON-NLS-1$
@@ -1957,7 +1947,7 @@
         assertEquals(report.toString(), 0, report.getItems().size());
     }
     
-    public void testVariablesGroupSelect() {
+    @Test public void testVariablesGroupSelect() {
         String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
         procedure += "BEGIN\n"; //$NON-NLS-1$
         procedure += "DECLARE integer VARIABLES.var1 = 1;\n"; //$NON-NLS-1$
@@ -1970,34 +1960,34 @@
         helpRunValidator(command, new String[] {"variables"}, metadata); //$NON-NLS-1$
     }
     
-    public void testClobEquals() {
+    @Test public void testClobEquals() {
         TestValidator.helpValidate("SELECT * FROM test.group where e4 = '1'", new String[] {"e4 = '1'"}, TestValidator.exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$ 
     }
     
     /**
      *  Should not fail since the update changing set is not really criteria
      */
-    public void testUpdateWithClob() {
+    @Test public void testUpdateWithClob() {
         TestValidator.helpValidate("update test.group set e4 = ?", new String[] {}, TestValidator.exampleMetadata2()); //$NON-NLS-1$ 
     }
 
-    public void testBlobLessThan() {
+    @Test public void testBlobLessThan() {
         TestValidator.helpValidate("SELECT * FROM test.group where e3 < ?", new String[] {"e3 < ?"}, TestValidator.exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$ 
     }
     
-	public void testValidateCompare2() {        
+	@Test public void testValidateCompare2() {        
         helpValidate("SELECT e2 FROM test.group WHERE e4 IS NULL", new String[] {}, exampleMetadata2()); //$NON-NLS-1$ 
 	}
 
-	public void testValidateCompare3() {        
+	@Test public void testValidateCompare3() {        
         helpValidate("SELECT e2 FROM test.group WHERE e4 IN ('a')", new String[] {"e4 IN ('a')"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-    public void testValidateCompare5() {        
+    @Test public void testValidateCompare5() {        
         helpValidate("SELECT e2 FROM test.group WHERE e4 BETWEEN '1' AND '2'", new String[] {"e4 BETWEEN '1' AND '2'"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-	public void testValidateCompareInHaving1() {        
+	@Test public void testValidateCompareInHaving1() {        
         helpValidate("SELECT e1 FROM test.group GROUP BY e1 HAVING convert(e1, clob) = 'a'", new String[] {"convert(e1, clob) = 'a'"}, exampleMetadata2()); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestResultSetCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestResultSetCache.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestResultSetCache.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -30,18 +30,16 @@
 
 import org.junit.Test;
 
-import com.metamatrix.cache.FakeCache.FakeCacheFactory;
+import com.metamatrix.cache.FakeCache;
 import com.metamatrix.common.buffer.impl.SizeUtility;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 
 public class TestResultSetCache {
     
     @Test public void testSetAndGetResultsForSession() throws Exception{
-    	Properties props = new Properties();
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_CONN);
-    	ResultSetCache cache = new ResultSetCache(props, new FakeCacheFactory());
+    	ResultSetCache cache = new ResultSetCache();
+    	cache.setScope(ResultSetCache.RS_CACHE_SCOPE_CONN);
+    	cache.start(new FakeCache.FakeCacheFactory());
     	CacheID id1 = new CacheID("12345", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
     	List[] result1 = new List[]{new ArrayList()};
     	cache.setResults(id1, new CacheResults(result1, 1, true ), "req1");  //$NON-NLS-1$
@@ -53,11 +51,8 @@
     }
     
     @Test public void testSetAndGetResultsForVDB() throws Exception{
-    	Properties props = new Properties();
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB);
-    	ResultSetCache cache = new ResultSetCache(props, new FakeCacheFactory());
+    	ResultSetCache cache = new ResultSetCache();
+    	cache.start(new FakeCache.FakeCacheFactory());
     	CacheID id1 = new CacheID("vdb1", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
     	List[] result1 = new List[]{new ArrayList()};
     	cache.setResults(id1, new CacheResults(result1, 1, true) , "req1");  //$NON-NLS-1$
@@ -68,44 +63,9 @@
     	assertEquals(cache.getResults(id2, new int[]{1, 500}).getResults(), result2); 
     }
     
-//    @Test public void testRemoveConnection() throws Exception{
-//    	Properties props = new Properties();
-//    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-//    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
-//    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_CONN);
-//    	ResultSetCache cache = new ResultSetCache(props);
-//    	CacheID id1 = new CacheID("12345", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
-//    	List[] result1 = new List[]{new ArrayList()};
-//    	cache.setResults(id1, new CacheResults(result1, 0, true ));  //$NON-NLS-1$//$NON-NLS-2$
-//    	CacheID id2 = new CacheID("12346",  "select * from table2");  //$NON-NLS-1$//$NON-NLS-2$
-//    	List[] result2 = new List[]{new ArrayList()};
-//    	cache.setResults(id2, new CacheResults(result2, 0, true) );  //$NON-NLS-1$//$NON-NLS-2$
-//    	cache.removeConnection(id1.getScopeID());
-//    	assertNull(cache.getResults(id1, new int[]{0, 500})); //$NON-NLS-1$
-//    }
-//    
-//    @Test public void testRemoveVDB() throws Exception{
-//    	Properties props = new Properties();
-//    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-//    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
-//    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB);
-//    	ResultSetCache cache = new ResultSetCache(props);
-//    	CacheID id1 = new CacheID("vdb1", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
-//    	List[] result1 = new List[]{new ArrayList()};
-//    	cache.setResults(id1, new CacheResults(result1, 0, true ));  //$NON-NLS-1$//$NON-NLS-2$
-//    	CacheID id2 = new CacheID("vdb2", "select * from table2");  //$NON-NLS-1$//$NON-NLS-2$
-//    	List[] result2 = new List[]{new ArrayList()};
-//    	cache.setResults(id2, new CacheResults(result2, 0, true ));  //$NON-NLS-1$//$NON-NLS-2$
-//    	cache.removeVDB(id1.getScopeID());
-//    	assertNull(cache.getResults(id1, new int[]{0, 500})); //$NON-NLS-1$
-//    }
-    
     @Test public void testClearAllCache() throws Exception{
-    	Properties props = new Properties();
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB);
-    	ResultSetCache cache = new ResultSetCache(props, new FakeCacheFactory());
+    	ResultSetCache cache = new ResultSetCache();
+    	cache.start(new FakeCache.FakeCacheFactory());
     	CacheID id1 = new CacheID("vdb1", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
     	List[] result1 = new List[]{new ArrayList()};
     	cache.setResults(id1, new CacheResults(result1, 1, true), "req1" );  //$NON-NLS-1$
@@ -117,11 +77,9 @@
     }
     
     @Test public void testSetAndGetResultsForSession1() throws Exception{
-    	Properties props = new Properties();
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_CONN);
-    	ResultSetCache cache = new ResultSetCache(props, new FakeCacheFactory());
+    	ResultSetCache cache = new ResultSetCache();
+    	cache.setScope(ResultSetCache.RS_CACHE_SCOPE_CONN);
+    	cache.start(new FakeCache.FakeCacheFactory());
     	CacheID id1 = new CacheID("12345", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
     	List row1 = new ArrayList();
     	row1.add("1"); //$NON-NLS-1$
@@ -138,11 +96,9 @@
     }
     
     @Test public void testSetAndGetResultsForSession2() throws Exception{
-    	Properties props = new Properties();
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_CONN);
-    	ResultSetCache cache = new ResultSetCache(props, new FakeCacheFactory());
+    	ResultSetCache cache = new ResultSetCache();
+    	cache.setScope(ResultSetCache.RS_CACHE_SCOPE_CONN);
+    	cache.start(new FakeCache.FakeCacheFactory());
     	CacheID id1 = new CacheID("12345", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
     	List row1 = new ArrayList();
     	row1.add("1"); //$NON-NLS-1$
@@ -163,17 +119,15 @@
     }
     
     @Test public void testMaxSize() throws Exception{
-    	Properties props = new Properties();
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "1"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_CONN);
-    	ResultSetCache cache = new ResultSetCache(props, new FakeCacheFactory());
+    	ResultSetCache cache = new ResultSetCache();
+    	cache.setMaxEntrySize(600000);
+    	cache.start(new FakeCache.FakeCacheFactory());
     	CacheID id1 = new CacheID("vdb1", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
     	CacheResults result1 = createResults(500000, 1, 1, true);
     	CacheID id2 = new CacheID("vdb2", "select * from table2");  //$NON-NLS-1$//$NON-NLS-2$
     	CacheResults result2 = createResults(500000, 1, 1, true);
     	CacheID id3 = new CacheID("vdb1", "select * from table3");  //$NON-NLS-1$//$NON-NLS-2$
-    	CacheResults result3 = createResults(500000, 1, 1, true);
+    	CacheResults result3 = createResults(700000, 1, 1, true);
     	//add two results
     	cache.setResults(id1, result1, "req1" );   //$NON-NLS-1$
     	cache.setResults(id2, result2, "req2" );   //$NON-NLS-1$
@@ -200,7 +154,6 @@
     	return cr;
     }
     
-    
     @Test public void testComputeSize() throws Exception{
     	int cnt = 1000000;
     	List[] results = new List[cnt];
@@ -215,21 +168,18 @@
     	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
     	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
     	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_CONN);
-    	ResultSetCache cache = new ResultSetCache(props, new FakeCacheFactory());
+    	ResultSetCache cache = new ResultSetCache();
     	CacheID id1 = new CacheID("vdb1", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
     	CacheResults result = new CacheResults(results, 1, true);
     	cache.setResults(id1, result, "req1" );  //$NON-NLS-1$
     	
-        int size = (SizeUtility.IS_64BIT ? 296000000 : 256000000);
+        int size = (SizeUtility.IS_64BIT ? 304000016 : 260000016);
     	assertEquals(size, result.getSize());
     }
     
     @Test(expected=MetaMatrixRuntimeException.class) public void testBatchNotContiguous() throws Exception{
-    	Properties props = new Properties();
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, "0"); //$NON-NLS-1$
-    	props.setProperty(ResultSetCache.RS_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_CONN);
-    	ResultSetCache cache = new ResultSetCache(props, new FakeCacheFactory());
+    	ResultSetCache cache = new ResultSetCache();
+    	cache.start(new FakeCache.FakeCacheFactory());
     	CacheID id1 = new CacheID("vdb1", "select * from table1");  //$NON-NLS-1$//$NON-NLS-2$
     	CacheResults result1 = createResults(1000, 1, 100, false);
     	CacheResults result3 = createResults(2000, 102, 200, true);

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -42,7 +42,6 @@
 import org.teiid.connector.api.ConnectorPropertyNames;
 import org.teiid.connector.api.ExecutionContext;
 import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
-import org.teiid.dqp.internal.pooling.connector.ConnectionPool;
 import org.teiid.dqp.internal.pooling.connector.FakeSourceConnectionFactory;
 import org.teiid.dqp.internal.process.DQPWorkContext;
 
@@ -50,7 +49,6 @@
 import com.metamatrix.common.application.ApplicationEnvironment;
 import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
 import com.metamatrix.dqp.service.ConnectorStatus;
 import com.metamatrix.dqp.service.DQPServiceNames;
 import com.metamatrix.dqp.service.FakeMetadataService;
@@ -155,44 +153,7 @@
         }
         cm.stop();
     }
-    
-    @Test public void testCaching() throws Exception {
-    	ConnectorManager cm = new ConnectorManager();
-        Properties props = new Properties();
-        props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
-        props.setProperty(ConnectorPropertyNames.USE_RESULTSET_CACHE, Boolean.TRUE.toString());
-        props.setProperty(ConnectionPool.SOURCE_CONNECTION_TEST_INTERVAL, String.valueOf(-1));
-        startConnectorManager(cm, props);
-        ConnectorWrapper wrapper = cm.getConnector();
-        FakeConnector fc = (FakeConnector)wrapper.getActualConnector();
-        assertEquals(0, fc.getConnectionCount());
-        assertEquals(0, fc.getExecutionCount());
-        AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
-        request.setUseResultSetCache(true);
-        QueueResultsReceiver receiver = new QueueResultsReceiver();
-        cm.executeRequest(receiver, request);
-        AtomicResultsMessage arm = receiver.getResults().poll(1000, TimeUnit.MILLISECONDS);
-        assertEquals(-1, arm.getFinalRow());
-        //get the last batch - it will be 0 sized
-        cm.requstMore(request.getAtomicRequestID());
-        assertNotNull(receiver.getResults().poll(1000, TimeUnit.MILLISECONDS));
-        cm.closeRequest(request.getAtomicRequestID());
-        assertEquals(1, fc.getConnectionCount());
-        assertEquals(1, fc.getExecutionCount());
-
-        //this request should hit the cache
-        AtomicRequestMessage request1 = TestConnectorWorkItem.createNewAtomicRequestMessage(2, 1);
-        request1.setUseResultSetCache(true);
-        QueueResultsReceiver receiver1 = new QueueResultsReceiver();
-        cm.executeRequest(receiver1, request1);
-        arm = receiver1.getResults().poll(1000, TimeUnit.MILLISECONDS);
-        assertEquals(5, arm.getFinalRow());
-        assertEquals(1, fc.getConnectionCount());
-        assertEquals(1, fc.getExecutionCount());
         
-        cm.stop();
-    }
-    
     @Test public void testDefect19049() throws Exception {
         ConnectorManager cm = new ConnectorManager();
         Properties props = new Properties();

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -66,7 +66,7 @@
         csm = new ConnectorManager();
         csm.setConnectorWorkerPool(Mockito.mock(WorkerPool.class));
         csm.setConnector(new ConnectorWrapper(new FakeConnector()));
-        csm.setWorkItemFactory(new ConnectorWorkItemFactory(csm, null, true));
+        csm.setWorkItemFactory(new ConnectorWorkItemFactory(csm, true));
     }
 
     void helpAssureOneState() {

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -61,7 +61,7 @@
     public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata) throws Exception {
         // Prepare sql 
         Command command = QueryParser.getQueryParser().parseCommand(sql);
-        QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, false, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
         
         // Create components
         MetadataService mdSvc = Mockito.mock(MetadataService.class);
@@ -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);
+        MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env, "MyVDB", "1"); //$NON-NLS-1$ //$NON-NLS-2$
                      
         return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();    
     }
@@ -138,7 +138,7 @@
         // Initialize components
         ApplicationEnvironment env = new ApplicationEnvironment();
         env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
-        MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env);
+        MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env, "MyVDB", "1"); //$NON-NLS-1$ //$NON-NLS-2$
                      
         DQPWorkContext workContext = new DQPWorkContext();
         workContext.setVdbName("MyVDB"); //$NON-NLS-1$
@@ -182,8 +182,8 @@
         while(iter.hasNext()) {
             String type = (String) iter.next();
             Class typeClass = DataTypeManager.getDataTypeClass(type);
-            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$
+            MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, "vdb", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+            Map columnMetadata = processor.getDefaultColumn("t", "c", typeClass); //$NON-NLS-1$ //$NON-NLS-2$
             verifyColumn(columnMetadata, type);            
         }               
     }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -111,7 +111,7 @@
         
         Request request = new Request();
         Command command = QueryParser.getQueryParser().parseCommand(QUERY);
-        QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, true, metadata, AnalysisRecord.createNonRecordingRecord());
+        QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
         
         RequestMessage message = new RequestMessage();
         DQPWorkContext workContext = new DQPWorkContext();

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -112,7 +112,7 @@
         Command command = TestResolver.helpResolve(userSql, wrapper, analysis);               
                 
         // Plan
-        command = QueryRewriter.rewrite(command, null, wrapper, null);
+        command = QueryRewriter.rewrite(command, wrapper, null);
         FakeCapabilitiesFinder fakeFinder = new FakeCapabilitiesFinder();
         fakeFinder.addCapabilities(multiModel, TestOptimizer.getTypicalCapabilities()); 
 

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -126,7 +126,7 @@
         QueryResolver.resolveCommand(command, metadata);
         
         AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(CONN_ID, svc, Mockito.mock(VDBService.class), "foo", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-        ValidatorReport report = Validator.validate(command, metadata, visitor, true);
+        ValidatorReport report = Validator.validate(command, metadata, visitor);
         if(report.hasItems()) {
             ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
             

Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBufferService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBufferService.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBufferService.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -57,7 +57,7 @@
     private static final String DEFAULT_MAX_OPEN_FILES = "10"; //$NON-NLS-1$
     
     // Instance
-    private BufferManager bufferMgr;
+    private BufferManagerImpl bufferMgr;
 	private File bufferDir;
 	
 	@Inject

Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java	2009-12-09 20:52:08 UTC (rev 1629)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -239,15 +239,6 @@
      * @since 4.3
      */
     public void clearConnectorBindingCache(String connectorBindingName) throws MetaMatrixComponentException {
-    	ConnectorBinding binding = getConnectorBinding(connectorBindingName);
-    	if (binding != null) {
-            ConnectorManager mgr = getConnectorManager(binding, false);
-            if (mgr != null ) {            
-                mgr.clearCache();
-                return;
-            }
-        }
-        throw new ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector_manager_for_{0}_1", new Object[] { connectorBindingName })); //$NON-NLS-1$       
     }    
 
     /** 

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -42,9 +42,9 @@
     }
 
     public StaticMetadataProvider exampleProvider() throws Exception {
-        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$
+        MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, "vdb", "1"); //$NON-NLS-1$ //$NON-NLS-2$ 
+        Map col1 = processor.getDefaultColumn("table", "col1", String.class); //$NON-NLS-1$ //$NON-NLS-2$ 
+        Map col2 = processor.getDefaultColumn("table", "col2", Integer.class); //$NON-NLS-1$ //$NON-NLS-2$ 
         
         Map[] columnMetadata = new Map[] {
             col1, col2

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-12-09 20:52:08 UTC (rev 1629)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java	2009-12-09 21:41:41 UTC (rev 1630)
@@ -44,10 +44,10 @@
     }
 
     private StaticMetadataProvider example1() throws Exception {
-        MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null);
+    	MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, "vdb", "1"); //$NON-NLS-1$ //$NON-NLS-2$
         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$
+            processor.getDefaultColumn("table", "c1", String.class), //$NON-NLS-1$ //$NON-NLS-2$ 
+            processor.getDefaultColumn("table", "c2", Integer.class) //$NON-NLS-1$ //$NON-NLS-2$ 
         };               
         
         return StaticMetadataProvider.createWithData(columnMetadata, 0);
@@ -81,7 +81,7 @@
 
     public void testGetIntValue() throws Exception {
         Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
-        Integer value = new Integer(10); //$NON-NLS-1$
+        Integer value = new Integer(10); 
         
         Map columnMetadata = new HashMap();
         columnMetadata.put(property, value); 
@@ -94,7 +94,7 @@
 
     public void testGetBooleanValue() throws Exception {
         Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
-        Boolean value = Boolean.TRUE; //$NON-NLS-1$
+        Boolean value = Boolean.TRUE; 
         
         Map columnMetadata = new HashMap();
         columnMetadata.put(property, value); 



More information about the teiid-commits mailing list