teiid SVN: r1662 - in trunk: client/src/main/java/com/metamatrix/jdbc/api and 14 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-14 13:48:26 -0500 (Mon, 14 Dec 2009)
New Revision: 1662
Removed:
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParseCommandType.java
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java
trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java
trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java
trunk/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java
trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
TEIID-897 TEIID-906 initial changes to autowrap mode and adding the ability to use a set statement to control execution variables.
Modified: trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -68,9 +68,6 @@
// Treat the double quoted strings as variables in the command
private boolean ansiQuotedIdentifiers = true;
- //whether query plan is allowed or not
- private boolean queryPlanAllowed = true;
-
private boolean showPlan = false;
private int rowLimit;
@@ -204,7 +201,7 @@
*/
public String getTxnAutoWrapMode() {
if (txnAutoWrapMode == null) {
- return ExecutionProperties.AUTO_WRAP_OPTIMISTIC;
+ return ExecutionProperties.TXN_WRAP_AUTO;
}
return txnAutoWrapMode;
}
@@ -217,10 +214,9 @@
public void setTxnAutoWrapMode(String txnAutoWrapMode) throws MetaMatrixProcessingException {
if (txnAutoWrapMode != null) {
txnAutoWrapMode = txnAutoWrapMode.toUpperCase();
- if (!(txnAutoWrapMode.equals(ExecutionProperties.AUTO_WRAP_OFF)
- || txnAutoWrapMode.equals(ExecutionProperties.AUTO_WRAP_ON)
- || txnAutoWrapMode.equals(ExecutionProperties.AUTO_WRAP_OPTIMISTIC)
- || txnAutoWrapMode.equals(ExecutionProperties.AUTO_WRAP_PESSIMISTIC))) {
+ if (!(txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_OFF)
+ || txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_ON)
+ || txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_AUTO))) {
throw new MetaMatrixProcessingException(CommonCommPlugin.Util.getString("RequestMessage.invalid_txnAutoWrap", txnAutoWrapMode)); //$NON-NLS-1$
}
}
@@ -315,14 +311,6 @@
this.ansiQuotedIdentifiers = ansiQuotedIdentifiers;
}
- public void setQueryPlanAllowed(boolean allowed) {
- queryPlanAllowed = allowed;
- }
-
- public boolean isQueryPlanAllowed() {
- return queryPlanAllowed;
- }
-
/**
* @return Returns the showPlan.
* @since 4.3
Modified: trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -30,8 +30,6 @@
*/
public interface ExecutionProperties {
-
-
/** Execution property name for XML format */
public static final String PROP_XML_FORMAT = "XMLFormat"; //$NON-NLS-1$
@@ -39,7 +37,7 @@
public static final String PROP_XML_VALIDATION = "XMLValidation"; //$NON-NLS-1$
/** Execution property name for transaction auto wrap mode */
- public static final String PROP_TXN_AUTO_WRAP = "txnAutoWrap"; //$NON-NLS-1$
+ public static final String PROP_TXN_AUTO_WRAP = "autoCommitTxn"; //$NON-NLS-1$
/** Execution property name for partial results mode */
public static final String PROP_PARTIAL_RESULTS_MODE = "partialResultsMode"; //$NON-NLS-1$
@@ -52,22 +50,18 @@
/** Transaction auto wrap constant - never wrap a command execution in a transaction
* and allow multi-source updates to occur outside of a transaction. */
- public static final String AUTO_WRAP_OFF = "OFF"; //$NON-NLS-1$
+ public static final String TXN_WRAP_OFF = "OFF"; //$NON-NLS-1$
/** Transaction auto wrap constant - always wrap every non-transactional command
* execution in a transaction. */
- public static final String AUTO_WRAP_ON = "ON"; //$NON-NLS-1$
+ public static final String TXN_WRAP_ON = "ON"; //$NON-NLS-1$
- /** Transaction auto wrap constant - pessimistic mode assumes that any command
- * execution might require a transaction to be wrapped around it. To determine
- * this an extra server call is made to check whether the command requires
- * a transaction and a transaction will be automatically started. This is most
- * accurate and safe, but has a performance impact. */
- public static final String AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"; //$NON-NLS-1$
+ /**
+ * Transaction auto wrap constant - checks if a command
+ * requires a transaction and will be automatically wrap it.
+ */
+ public static final String TXN_WRAP_AUTO = "AUTO"; //$NON-NLS-1$
- /** Transaction auto wrap constant */
- public static final String AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"; //$NON-NLS-1$
-
/**
* Whether to use result set cache if it is available
* @since 4.2
@@ -104,6 +98,5 @@
*/
public static final String SQL_OPTION_SHOWPLAN = "SHOWPLAN"; //$NON-NLS-1$
- public static final String PLAN_NOT_ALLOWED = "planNotAllowed"; //$NON-NLS-1$
}
\ No newline at end of file
Modified: trunk/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java
===================================================================
--- trunk/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -60,7 +60,7 @@
message.setStyleSheet("myStyleSheet"); //$NON-NLS-1$
message.setExecutionPayload("myExecutionPayload"); //$NON-NLS-1$
try {
- message.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
+ message.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_ON);
} catch (MetaMatrixProcessingException e) {
throw new RuntimeException(e);
}
@@ -89,7 +89,7 @@
assertEquals(new Date(12345678L), copy.getProcessingTimestamp());
assertEquals("myStyleSheet", copy.getStyleSheet()); //$NON-NLS-1$
assertEquals("myExecutionPayload", copy.getExecutionPayload()); //$NON-NLS-1$
- assertEquals(ExecutionProperties.AUTO_WRAP_ON, copy.getTxnAutoWrapMode()); //$NON-NLS-1$
+ assertEquals(ExecutionProperties.TXN_WRAP_ON, copy.getTxnAutoWrapMode()); //$NON-NLS-1$
assertTrue(copy.getValidationMode());
assertEquals("xMLFormat", copy.getXMLFormat()); //$NON-NLS-1$
assertTrue(copy.getShowPlan());
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -201,38 +201,6 @@
private String disableLocalTxn;
- /**
- * A setting that controls how connections created by this DataSource manage transactions for client
- * requests when client applications do not use transactions. Because a Teiid virtual database
- * will likely deal with multiple underlying information sources, Teiid will execute
- * all client requests within the contexts of transactions. This method determines the semantics
- * of creating such transactions when the client does not explicitly do so.
- * <p>
- * The allowable values for this property are:
- * <ul>
- * <li>"<code>OFF</code>" - Nothing is ever wrapped in a transaction and the server will execute
- * multi-source updates happily but outside a transaction. This is least safe but highest performance.
- * The {@link #TXN_AUTO_WRAP_OFF} constant value is provided for convenience.</li>
- * <li>"<code>ON</code>" - Always wrap every command in a transaction. This is most safe but lowest
- * performance.
- * The {@link #TXN_AUTO_WRAP_ON} constant value is provided for convenience.</li>
- * <li>"<code>PESSIMISTIC</code>" - Assume that any command might require a transaction. Make a server
- * call to check whether the command being executed needs a transaction and wrap the command in a
- * transaction if necessary. This will auto wrap in exactly the cases where it is needed but requires
- * an extra server call on every command execution (including queries). This is as safe as ON, but
- * lower performance than OFF for cases where no transaction is actually needed (like queries).
- * This is the default value.
- * The {@link #TXN_AUTO_WRAP_PESSIMISTIC} constant value is provided for convenience.</li>
- * <li>"<code>OPTIMISTIC</code>" - same as OFF but assume that no command not in a transaction actually
- * needs one. In other words, we're letting the user decide when to use and not use a transaction and
- * assuming they are doing it correctly. Only difference from OFF is that if the user executes a command
- * that requires a transaction but they don't use one, we will detect this and throw an exception. This
- * provides the safety of ON or PESSIMISTIC mode but better performance in the common case of queries
- * that are not multi-source.
- * The {@link #TXN_AUTO_WRAP_OPTIMISTIC} constant value is provided for convenience.</li>
- * </ul>
- * </p>
- */
private String transactionAutoWrap;
private boolean ansiQuotedIdentifiers = true;
@@ -252,35 +220,21 @@
* Transaction auto wrap constant - never wrap a command execution in a transaction
* and allow multi-source updates to occur outside of a transaction.
*/
- public static final String TXN_AUTO_WRAP_OFF = "OFF"; //$NON-NLS-1$
+ public static final String TXN_WRAP_OFF = ExecutionProperties.TXN_WRAP_OFF;
/**
* Transaction auto wrap constant - always wrap every non-transactional command
* execution in a transaction.
*/
- public static final String TXN_AUTO_WRAP_ON = "ON"; //$NON-NLS-1$
+ public static final String TXN_WRAP_ON = ExecutionProperties.TXN_WRAP_ON;
/**
- * Transaction auto wrap constant - pessimistic mode assumes that any command
- * execution might require a transaction to be wrapped around it. To determine
- * this an extra server call is made to check whether the command requires
- * a transaction and a transaction will be automatically started. This is most
- * accurate and safe, but has a performance impact.
+ * Transaction auto wrap constant - checks if a command
+ * requires a transaction and will be automatically wrap it.
*/
- public static final String TXN_AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"; //$NON-NLS-1$
+ public static final String TXN_WRAP_AUTO = ExecutionProperties.TXN_WRAP_AUTO;
/**
- * Transaction auto wrap constant - optimistic mode assumes that non-transactional
- * commands typically do not require a transaction due to a multi-source update,
- * so no transaction is created. In this respect, this mode is identical to
- * {@link #TXN_AUTO_WRAP_OFF}. However, these modes differ because if we
- * discover during server execution that multiple sources will be updated by
- * a particular command, an exception is thrown to indicate that the command
- * cannot be executed. This is the default mode.
- */
- public static final String TXN_AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"; //$NON-NLS-1$
-
- /**
* String to hold additional properties that are not represented with an explicit getter/setter
*/
private String additionalProperties;
@@ -733,7 +687,8 @@
}
/**
- * @see #getTxnAutoWrap()
+ * @deprecated
+ * @see #getAutoCommitTxn()
* @return
*/
public String getTransactionAutoWrap() {
@@ -741,7 +696,8 @@
}
/**
- * @see #setTxnAutoWrap(String)
+ * @deprecated
+ * @see #setAutoCommitTxn(String)
* @param transactionAutoWrap
*/
public void setTransactionAutoWrap(String transactionAutoWrap) {
@@ -758,13 +714,13 @@
* @return the current setting, or null if the property has not been set and the default mode will
* be used.
*/
- public String getTxnAutoWrap() {
+ public String getAutoCommitTxn() {
return this.transactionAutoWrap;
}
/**
* Sets the setting for how connections are created by this DataSource manage transactions
- * for client requests when client applications do not use transactions.
+ * for client requests with autoCommit = true.
* Because a virtual database will likely deal with multiple underlying information sources,
* Teiid will execute all client requests within the contexts of transactions.
* This method determines the semantics of creating such transactions when the client does not
@@ -774,28 +730,18 @@
* <ul>
* <li>"<code>OFF</code>" - Nothing is ever wrapped in a transaction and the server will execute
* multi-source updates happily but outside a transaction. This is least safe but highest performance.
- * The {@link #TXN_AUTO_WRAP_OFF} constant value is provided for convenience.</li>
+ * The {@link #TXN_WRAP_OFF} constant value is provided for convenience.</li>
* <li>"<code>ON</code>" - Always wrap every command in a transaction. This is most safe but lowest
* performance.
- * The {@link #TXN_AUTO_WRAP_ON} constant value is provided for convenience.</li>
- * <li>"<code>PESSIMISTIC</code>" - Assume that any command might require a transaction. Make a server
- * call to check whether the command being executed needs a transaction and wrap the command in a
- * transaction if necessary. This will auto wrap in exactly the cases where it is needed but requires
- * an extra server call on every command execution (including queries). This is as safe as ON, but
- * lower performance than OFF for cases where no transaction is actually needed (like queries).
- * The {@link #TXN_AUTO_WRAP_PESSIMISTIC} constant value is provided for convenience.</li>
- * <li>"<code>OPTIMISTIC</code>" - same as OFF but assume that no command not in a transaction actually
- * needs one. In other words, we're letting the user decide when to use and not use a transaction and
- * assuming they are doing it correctly. Only difference from OFF is that if the user executes a command
- * that requires a transaction but they don't use one, we will detect this and throw an exception. This
- * provides the safety of ON or PESSIMISTIC mode but better performance in the common case of queries
- * that are not multi-source.
- * The {@link #TXN_AUTO_WRAP_OPTIMISTIC} constant value is provided for convenience.</li>
+ * The {@link #TXN_WRAP_ON} constant value is provided for convenience.</li>
+ * <li>"<code>AUTO</code>" - checks if a command requires a transaction and will be automatically wrap it.
+ * This is the default mode.
+ * The {@link #TXN_WRAP_AUTO} constant value is provided for convenience.</li>
* </ul>
* </p>
* @param transactionAutoWrap The transactionAutoWrap to set
*/
- public void setTxnAutoWrap(String transactionAutoWrap) {
+ public void setAutoCommitTxn(String transactionAutoWrap) {
this.transactionAutoWrap = transactionAutoWrap;
}
@@ -865,21 +811,18 @@
return null; // no longer require an app server name, 'cause will look on classpath
}
final String trimmedAutoWrap = autoWrap.trim();
- if( TXN_AUTO_WRAP_ON.equals(trimmedAutoWrap) ) {
+ if( TXN_WRAP_ON.equals(trimmedAutoWrap) ) {
return null;
}
- if( TXN_AUTO_WRAP_OFF.equals(trimmedAutoWrap) ) {
+ if( TXN_WRAP_OFF.equals(trimmedAutoWrap) ) {
return null;
}
- if( TXN_AUTO_WRAP_OPTIMISTIC.equals(trimmedAutoWrap) ) {
+ if( TXN_WRAP_AUTO.equals(trimmedAutoWrap) ) {
return null;
}
- if( TXN_AUTO_WRAP_PESSIMISTIC.equals(trimmedAutoWrap) ) {
- return null;
- }
Object[] params = new Object[] {
- TXN_AUTO_WRAP_ON, TXN_AUTO_WRAP_OFF, TXN_AUTO_WRAP_OPTIMISTIC, TXN_AUTO_WRAP_PESSIMISTIC };
+ TXN_WRAP_ON, TXN_WRAP_OFF, TXN_WRAP_AUTO };
return JDBCPlugin.Util.getString("MMDataSource.Invalid_trans_auto_wrap_mode", params); //$NON-NLS-1$
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -74,7 +74,7 @@
/**
* Returns true if the driver thinks that it can open a connection to the given URL. Typically drivers will return true if
* they understand the subprotocol specified in the URL and false if they don't. Expected URL format is
- * jdbc:metamatrix:VDB@pathToPropertyFile;version=1;logFile=<logFile.log>;logLevel=<logLevel>;txnAutoWrap=<?>
+ * jdbc:metamatrix:VDB@pathToPropertyFile;version=1;logFile=<logFile.log>;logLevel=<logLevel>;property=<?>
*
* @param The URL used to establish a connection.
* @return A boolean value indicating whether the driver understands the subprotocol.
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -134,7 +134,7 @@
// set default properties if not overridden
String overrideProp = info.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP);
if ( overrideProp == null || overrideProp.trim().length() == 0 ) {
- info.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.AUTO_WRAP_OPTIMISTIC);
+ info.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.TXN_WRAP_AUTO);
}
// Get default fetch size
@@ -177,6 +177,10 @@
this.disableLocalTransactions = Boolean.valueOf(this.propInfo.getProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)).booleanValue();
}
+ protected Properties getConnectionProperties() {
+ return this.propInfo;
+ }
+
ClientSideDQP getDQP() {
return this.dqp;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -152,7 +152,7 @@
* These include required and any optional properties specified in the URL.
* Expected URL format -- jdbc:metamatrix:local:VDB@server:port;version=1;user=logon;
* password=pw;logFile=<logFile.log>;
- * logLevel=<logLevel>;txnAutoWrap=<?>;credentials=mycredentials
+ * logLevel=<logLevel>;credentials=mycredentials
* @param The URL needed to be parsed.
* @param The properties object which is to be updated with properties in the URL.
* @throws SQLException if the URL is not in the expected format.
@@ -195,7 +195,7 @@
* Typically drivers will return true if they understand the subprotocol specified
* in the URL and false if they don't.
* Expected URL format is
- * jdbc:metamatrix:subprotocol:VDB@server:port;version=1;logFile=<logFile.log>;logLevel=<logLevel>;txnAutoWrap=<?>
+ * jdbc:metamatrix:subprotocol:VDB@server:port;version=1;logFile=<logFile.log>;logLevel=<logLevel>;
* @param The URL used to establish a connection.
* @return A boolean value indicating whether the driver understands the subprotocol.
* @throws SQLException, should never occur
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -45,12 +45,13 @@
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.util.SqlUtil;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.message.ParameterInfo;
@@ -154,6 +155,8 @@
//Map<out/inout/return param index --> index in results>
protected Map outParamIndexMap = new HashMap();
+ private Pattern setStatement = Pattern.compile("\\s*set\\s*(\\w+)\\s*=\\s*(\\w*)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+
/**
* Factory Constructor
* @param driverConnection
@@ -174,7 +177,7 @@
this.driverConnection = driverConnection;
this.resultSetType = resultSetType;
this.resultSetConcurrency = resultSetConcurrency;
- this.execProps = PropertiesUtils.clone(getConnectionProperties());
+ this.execProps = new Properties(this.driverConnection.getConnectionProperties());
// Set initial fetch size
String fetchSizeStr = this.execProps.getProperty(ExecutionProperties.PROP_FETCH_SIZE);
@@ -403,8 +406,20 @@
throws SQLException, MMSQLException {
checkStatement();
resetExecutionState();
- RequestMessage reqMessage = createRequestMessage(commands,
- isBatchedCommand, requiresResultSet);
+
+ //handle set statement
+ if (commands.length == 1 && requiresResultSet != Boolean.TRUE) {
+ Matcher match = setStatement.matcher(commands[0]);
+ if (match.matches()) {
+ String key = match.group(1);
+ String value = match.group(2);
+ this.driverConnection.getConnectionProperties().setProperty(key, value);
+ this.updateCounts = new int[] {1};
+ return;
+ }
+ }
+
+ RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, requiresResultSet);
ResultsMessage resultsMsg = null;
try {
resultsMsg = sendRequestMessageAndWait(reqMessage);
@@ -704,17 +719,12 @@
}
}
- protected Properties getConnectionProperties() {
- return driverConnection.propInfo;
- }
-
/**
* Helper method for copy the connection properties to request message.
* @param res Request message that these properties to be copied to.
- * @param props Connection properties.
* @throws MMSQLException
*/
- protected void copyPropertiesToRequest(RequestMessage res, Properties props) throws MMSQLException {
+ protected void copyPropertiesToRequest(RequestMessage res) throws MMSQLException {
// Get partial mode
String partial = getExecutionProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE);
res.setPartialResults(Boolean.valueOf(partial).booleanValue());
@@ -748,8 +758,6 @@
// Get result set cache mode
String rsCache = getExecutionProperty(ExecutionProperties.RESULT_SET_CACHE_MODE);
res.setUseResultSetCache(Boolean.valueOf(rsCache).booleanValue());
-
- res.setQueryPlanAllowed(!Boolean.valueOf(getExecutionProperty(ExecutionProperties.PLAN_NOT_ALLOWED)).booleanValue());
}
/**
@@ -844,7 +852,7 @@
reqMsg.setRowLimit(this.maxRows);
// Get connection properties and set them onto request message
- copyPropertiesToRequest(reqMsg, getConnectionProperties());
+ copyPropertiesToRequest(reqMsg);
reqMsg.setExecutionId(this.currentRequestID);
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -178,7 +178,7 @@
* This method parses the URL and adds properties to the the properties object. These include required and any optional
* properties specified in the URL.
* Expected URL format --
- * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;txnAutoWrap=<?>;credentials=mycredentials;
+ * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;credentials=mycredentials;
*
* @param The URL needed to be parsed.
* @param The properties object which is to be updated with properties in the URL.
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -46,7 +46,7 @@
protected static final int STD_PORT_NUMBER = 7001;
protected static final String STD_LOG_FILE = UnitTestUtil.getTestScratchPath() + "/unitTestLogFile"; //$NON-NLS-1$
protected static final int STD_LOG_LEVEL = 2;
- protected static final String STD_TXN_AUTO_WRAP = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ protected static final String STD_TXN_WRAP = MMDataSource.TXN_WRAP_AUTO;
protected static final String STD_PARTIAL_MODE = "false"; //$NON-NLS-1$
protected static final String STD_CONFIG_FILE = UnitTestUtil.getTestDataPath() + "/bqt/bqt.properties"; //$NON-NLS-1$
protected static final String STD_ALTERNATE_SERVERS = "unitTestServerName2:7001,unitTestServerName2:7002,unitTestServerName3:7001"; //$NON-NLS-1$
@@ -70,7 +70,7 @@
dataSource.setDatabaseName(STD_DATABASE_NAME);
dataSource.setPortNumber(STD_PORT_NUMBER);
dataSource.setDataSourceName(STD_DATA_SOURCE_NAME);
- dataSource.setTransactionAutoWrap(STD_TXN_AUTO_WRAP);
+ dataSource.setTransactionAutoWrap(STD_TXN_WRAP);
dataSource.setPartialResultsMode(STD_PARTIAL_MODE);
dataSource.setSecure(true);
dataSource.setAlternateServers(STD_ALTERNATE_SERVERS);
@@ -280,7 +280,7 @@
public void testGetTransactionAutoWrap() {
final String result = dataSource.getTransactionAutoWrap();
- assertEquals(result,STD_TXN_AUTO_WRAP);
+ assertEquals(result,STD_TXN_WRAP);
}
public void testGetShowPlan() {
@@ -393,17 +393,14 @@
public void testReasonWhyInvalidTransactionAutoWrap1() {
- helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_AUTO_WRAP_OFF, VALID); //$NON-NLS-1$
+ helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_WRAP_OFF, VALID); //$NON-NLS-1$
}
public void testReasonWhyInvalidTransactionAutoWrap2() {
- helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_AUTO_WRAP_ON, VALID); //$NON-NLS-1$
+ helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_WRAP_ON, VALID); //$NON-NLS-1$
}
public void testReasonWhyInvalidTransactionAutoWrap3() {
- helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_AUTO_WRAP_OPTIMISTIC, VALID); //$NON-NLS-1$
+ helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_WRAP_AUTO, VALID); //$NON-NLS-1$
}
- public void testReasonWhyInvalidTransactionAutoWrap4() {
- helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC, VALID); //$NON-NLS-1$
- }
public void testReasonWhyInvalidTransactionAutoWrap5() {
helpTestReasonWhyInvalid("TransactionAutoWrap", "off", INVALID); // lowercase value //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -523,11 +520,11 @@
final String vdbName = "vdbName"; //$NON-NLS-1$
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = false;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, false, secure,
- "jdbc:teiid:vdbName@mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName"); //$NON-NLS-1$
}
public void testBuildURL3() {
@@ -535,11 +532,11 @@
final String vdbName = "vdbName"; //$NON-NLS-1$
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = false;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
// Test secure protocol
@@ -548,11 +545,11 @@
final String vdbName = "vdbName"; //$NON-NLS-1$
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = true;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mms://hostname:7001;ApplicationName=JDBC;serverURL=mms://hostname:7001;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mms://hostname:7001;ApplicationName=JDBC;serverURL=mms://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
/*
@@ -566,11 +563,11 @@
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
final String alternateServers = "hostName:7002,hostName2:7001,hostName2:7002"; //$NON-NLS-1$
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = false;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
/*
@@ -584,11 +581,11 @@
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
final String alternateServers = "hostName:7002,hostName2:7001,hostName2:7002"; //$NON-NLS-1$
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = true;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
/*
@@ -603,11 +600,11 @@
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
final String alternateServers = "hostName:7002,hostName2,hostName2:7002"; //$NON-NLS-1$
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = false;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
public void testBuildURL_AdditionalProperties() {
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -54,12 +54,12 @@
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:jvdb@mms://localhost:1234")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://127.0.0.1:1234;logLevel=2")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://127.0.0.1:1234")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://127.0.0.1:1234,localhost.mydomain.com:63636;logLevel=2")); //$NON-NLS-1$
@@ -79,7 +79,7 @@
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;stickyConnections=false;socketsPerVM=4")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:vdb@mm://my_host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
}
@@ -114,7 +114,7 @@
public void testParseURL3() throws SQLException{
Properties p = new Properties();
- MMDriver.getInstance().parseURL("jdbc:metamatrix:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;txnAutoWrap=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
+ MMDriver.getInstance().parseURL("jdbc:metamatrix:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;autoCommitTxn=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -27,6 +27,7 @@
import java.sql.ResultSet;
import java.util.Arrays;
import java.util.List;
+import java.util.Properties;
import org.junit.Test;
import org.mockito.Mockito;
@@ -59,4 +60,13 @@
assertTrue(Arrays.equals(new int[] {1, 2}, statement.executeBatch()));
}
+ @Test public void testSetStatement() throws Exception {
+ MMConnection conn = Mockito.mock(MMConnection.class);
+ Properties p = new Properties();
+ Mockito.stub(conn.getConnectionProperties()).toReturn(p);
+ MMStatement statement = new MMStatement(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ assertFalse(statement.execute("set foo = bar")); //$NON-NLS-1$
+ assertEquals("bar", p.get("foo")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -48,22 +48,22 @@
// // Windows Path
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties")); //$NON-NLS-1$
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
// Alternative windows path
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
// Abosolute path (Unix or windows)
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
// relative path
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
// File URL should be supported (not sure)
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@file:///c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
@@ -103,7 +103,7 @@
@Test public void testParseURL3() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;txnAutoWrap=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -48,12 +48,12 @@
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:jvdb@mms://localhost:1234")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://127.0.0.1:1234;logLevel=2")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://127.0.0.1:1234")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://127.0.0.1:1234,localhost.mydomain.com:63636;logLevel=2")); //$NON-NLS-1$
@@ -76,7 +76,7 @@
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;stickyConnections=false;socketsPerVM=4")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://my_host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
}
@@ -110,7 +110,7 @@
@Test public void testParseURL3() throws SQLException{
Properties p = new Properties();
- SocketProfile.parseURL("jdbc:teiid:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;txnAutoWrap=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
+ SocketProfile.parseURL("jdbc:teiid:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;autoCommitTxn=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2009-12-14 18:48:26 UTC (rev 1662)
@@ -26,7 +26,7 @@
<entry>
Treats the user command as if all source commands are executed
within the scope of the same transaction. The
- <link linkend="autowrap">AutoWrap</link>
+ <link linkend="autowrap">AutoCommitTxn</link>
execution property controls the behavior of command level
transactions.
</entry>
@@ -45,13 +45,13 @@
</tgroup>
</table>
<sect1 id="autowrap">
- <title>AutoWrap Execution Property</title>
+ <title>AutoCommitTxn Execution Property</title>
<para>Since user level commands may execute multiple source
- commands, users can specify the AutoWrap execution property to
+ commands, users can specify the AutoCommitTxn execution property to
control the transactional behavior of a user command when not in a
local or global transaction.</para>
<table>
- <title>AutoWrap Settings</title>
+ <title>AutoCommitTxn Settings</title>
<tgroup cols="2">
<colspec colwidth="1*" />
<colspec colwidth="3*" />
@@ -74,19 +74,9 @@
safest, but may be burdonsome on performance.</entry>
</row>
<row>
- <entry>OPTIMISTIC</entry>
+ <entry>AUTO</entry>
<entry>
- <emphasis>This is the default setting.</emphasis>
- Will not automatically wrap a command in a transaction, instead
- throw an exception if the command executed is
- <link linkend="updating_model_count">transactionally unsafe.</link>
- to execute outside of a transaction.
- </entry>
- </row>
- <row>
- <entry>PESSIMISTIC</entry>
- <entry>
- Will automatically wrap commands in a transaction, but only if
+ This is the default setting. Will automatically wrap commands in a transaction, but only if
the command seems to be
<link linkend="updating_model_count">transactionally unsafe.</link>
</entry>
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -32,9 +32,6 @@
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.Option;
import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.Statement;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.xquery.XQueryExpression;
import com.metamatrix.query.xquery.saxon.SaxonXQueryExpression;
@@ -44,9 +41,6 @@
* QueryParser can be reused but is NOT thread-safe as the parser uses an
* input stream. Putting multiple queries into the same stream will result
* in unpredictable and most likely incorrect behavior.</p>
- *
- * <p>In the future this class may hide a single- or multi-thread cache
- * of parsed queries. </p>
*/
public class QueryParser {
@@ -66,7 +60,7 @@
private static final String XQUERY_DECLARE = "declare"; //$NON-NLS-1$
private static final String XML_OPEN_BRACKET = "<"; //$NON-NLS-1$
- private static final String BOGUS_SELECT = "select x "; //$NON-NLS-1$
+ private static final String XML_CLOSE_BRACKET = ">"; //$NON-NLS-1$
private SQLParser parser;
@@ -119,37 +113,39 @@
throw new QueryParserException(QueryPlugin.Util.getString("QueryParser.emptysql")); //$NON-NLS-1$
}
- // For XQueries
- int type = getCommandType(sql);
- if (type == Command.TYPE_XQUERY || type == Command.TYPE_UNKNOWN){
+ QueryParserException qpe = null;
+ try {
+ Command result = parseCommandWithParser(sql, parseInfo);
+ return result;
+ } catch (QueryParserException e) {
+ qpe = e;
+ }
+
+ try {
+ // Check for OPTION
+ Option option = null;
+ int closeBracket = sql.lastIndexOf(XML_CLOSE_BRACKET);
+ int optionIndex = sql.toUpperCase().lastIndexOf(ReservedWords.OPTION);
+ if (optionIndex != -1 && optionIndex > closeBracket){
+ String optionSQL = sql.substring(optionIndex);
+ option = getOption(optionSQL, parseInfo);
+ sql = sql.substring(0, optionIndex-1);
+ }
- try {
-
- // Check for OPTION
- Option option = null;
- int optionIndex = sql.toUpperCase().lastIndexOf(ReservedWords.OPTION);
- if (optionIndex != -1){
- String optionSQL = sql.substring(optionIndex);
- option = getOption(optionSQL);
- sql = sql.substring(0, optionIndex-1);
- }
-
- XQueryExpression expr = new SaxonXQueryExpression();
- expr.compileXQuery(sql);
- XQuery xquery = new XQuery(sql, expr);
- if (option != null){
- xquery.setOption(option);
- }
- return xquery;
- } catch (MetaMatrixProcessingException e) {
- if (type == Command.TYPE_XQUERY){
- throw new QueryParserException(QueryPlugin.Util.getString("QueryParser.xqueryCompilation", e.getMessage())); //$NON-NLS-1$
- } // else let unknown query type fall through to code below for better error handling
+ XQueryExpression expr = new SaxonXQueryExpression();
+ expr.compileXQuery(sql);
+ XQuery xquery = new XQuery(sql, expr);
+ if (option != null){
+ xquery.setOption(option);
}
+ return xquery;
+ } catch (MetaMatrixProcessingException e) {
+ if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
+ throw new QueryParserException(e, QueryPlugin.Util.getString("QueryParser.xqueryCompilation")); //$NON-NLS-1$
+ }
}
- Command result = parseCommandWithParser(sql, parseInfo);
- return result;
+ throw qpe;
}
/**
@@ -157,10 +153,18 @@
* @param optionSQL option SQL
* @return Option object
*/
- private Option getOption(String optionSQL) throws QueryParserException {
- String sql = BOGUS_SELECT + optionSQL;
- Command command = parseCommandWithParser(sql, new ParseInfo());
- return command.getOption();
+ private Option getOption(String optionSQL, ParseInfo parseInfo) throws QueryParserException {
+ Option result = null;
+ try{
+ result = getSqlParser(optionSQL).option(parseInfo);
+
+ } catch(ParseException pe) {
+ throw convertParserException(pe);
+
+ } catch(TokenMgrError tme) {
+ handleTokenMgrError(tme);
+ }
+ return result;
}
/**
@@ -184,35 +188,6 @@
}
/**
- * Takes a SQL string representing an SQL statement
- * and returns the procedure object representation.
- * @param stmt SQL statement string
- * @return Statement Procedure object representation
- * @throws QueryParserException if parsing fails
- * @throws IllegalArgumentException if stmt is null
- */
- Statement parseStatement(String stmt) throws QueryParserException {
- if(stmt == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString("QueryParser.nullSqlCrit")); //$NON-NLS-1$
- }
-
- ParseInfo dummyInfo = new ParseInfo();
-
- Statement result = null;
- try{
- result = getSqlParser(stmt).statement(dummyInfo);
-
- } catch(ParseException pe) {
- throw convertParserException(pe);
-
- } catch(TokenMgrError tme) {
- handleTokenMgrError(tme);
- }
- return result;
- }
-
-
- /**
* Takes a SQL string representing an SQL criteria (i.e. just the WHERE
* clause) and returns the object representation.
* @param sql SQL criteria (WHERE clause) string
@@ -240,65 +215,11 @@
return result;
}
- /**
- * Takes a SQL string representing a block
- * and returns the object representation.
- * @param block Block string
- * @return Block Block object representation
- * @throws QueryParserException if parsing fails
- * @throws IllegalArgumentException if sql is null
- */
- Block parseBlock(String block) throws QueryParserException {
- if(block == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString("QueryParser.nullBlock")); //$NON-NLS-1$
- }
-
- ParseInfo dummyInfo = new ParseInfo();
-
- Block result = null;
- try{
- result = getSqlParser(block).block(dummyInfo);
-
- } catch(ParseException pe) {
- throw convertParserException(pe);
-
- } catch(TokenMgrError tme) {
- handleTokenMgrError(tme);
- }
- return result;
- }
-
private QueryParserException convertParserException(ParseException pe) {
return new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", pe.getMessage())); //$NON-NLS-1$
}
/**
- * Takes a SQL string representing a criteria selector
- * and returns the object representation.
- * @param selector criteria selector string
- * @return CriteriaSelector CriteriaSelector object representation
- * @throws QueryParserException if parsing fails
- * @throws IllegalArgumentException if sql is null
- */
- CriteriaSelector parseCriteriaSelector(String selector) throws QueryParserException {
- if(selector == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString("QueryParser.nullSqlCrit")); //$NON-NLS-1$
- }
-
- CriteriaSelector result = null;
- try{
- result = getSqlParser(selector).criteriaSelector();
-
- } catch(ParseException pe) {
- throw convertParserException(pe);
-
- } catch(TokenMgrError tme) {
- handleTokenMgrError(tme);
- }
- return result;
- }
-
- /**
* Takes a SQL string representing an SQL expression
* and returns the object representation.
* @param sql SQL expression string
@@ -363,54 +284,4 @@
throw new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", tme.getMessage())); //$NON-NLS-1$
}
- /**
- * Takes a SQL string and determines the command type, as defined in the constants
- * of {@link com.metamatrix.query.sql.lang.Command}.
- * @param sql SQL string
- * @return Command type code, as defined in {@link com.metamatrix.query.sql.lang.Command}.
- * Note: not all XQuery queries will necessarily be detected - if type UNKNOWN is indicated
- * it's possible it is an XQuery.
- * @throws IllegalArgumentException if sql is null
- */
- public static int getCommandType(String sql) {
- if(sql == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString("QueryParser.emptysql")); //$NON-NLS-1$
- }
-
- // Shortcut for most XQuery commands
- if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
- return Command.TYPE_XQUERY;
- }
-
- int startCommand = -1;
- for(int index = 0; index < sql.length(); index++) {
- char c = sql.charAt(index);
- if(Character.isLetter(c) || c == '{') {
- startCommand = index;
- break;
- }
- }
-
- if(startCommand == -1) {
- return Command.TYPE_UNKNOWN;
- }
-
- String commandWord = sql.substring(startCommand, Math.min(startCommand+6, sql.length())).toUpperCase();
- if(commandWord.startsWith(ReservedWords.SELECT)) {
- return Command.TYPE_QUERY;
- } else if(commandWord.startsWith(ReservedWords.INSERT)) {
- return Command.TYPE_INSERT;
- } else if(commandWord.startsWith(ReservedWords.UPDATE)) {
- return Command.TYPE_UPDATE;
- } else if(commandWord.startsWith(ReservedWords.DELETE)) {
- return Command.TYPE_DELETE;
- } else if(commandWord.startsWith(ReservedWords.EXEC) || commandWord.startsWith("{")) { //$NON-NLS-1$
- return Command.TYPE_STORED_PROCEDURE;
- } else if(commandWord.startsWith(ReservedWords.CREATE)) {
- return Command.TYPE_UPDATE_PROCEDURE;
- } else {
- return Command.TYPE_UNKNOWN;
- }
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -310,20 +310,6 @@
}
}
- // validate the updating model count if transaction is optimistic
- // Error if orig = 0 and command > 0 OR if orig = 1 and command <> 1
- if (procEnv.getContext().isOptimisticTransaction()) {
- final int origModelCount = dynamicCommand.getUpdatingModelCount();
- final int newModelCount = command.updatingModelCount(metadata);
- if ((origModelCount == 0 || origModelCount == 1)
- && newModelCount > origModelCount) {
- Object[] params = new Object[] { new Integer(newModelCount),
- new Integer(origModelCount) };
- throw new QueryProcessingException(QueryExecPlugin.Util
- .getString("ExecDynamicSqlInstruction.1", params)); //$NON-NLS-1$
- }
- }
-
// do a recursion check
// Add group to recursion stack
CommandContext context = procEnv.getContext();
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-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -82,8 +82,6 @@
private Stack<String> recursionStack = null;
- private boolean optimisticTransaction = false;
-
private SecurityFunctionEvaluator securityFunctionEvaluator;
private Object tempTableStore;
@@ -148,7 +146,6 @@
if (context.recursionStack != null) {
this.recursionStack = (Stack)context.recursionStack.clone();
}
- setOptimisticTransaction(context.isOptimisticTransaction());
this.setSecurityFunctionEvaluator(context.getSecurityFunctionEvaluator());
this.planToProcessConverter = context.planToProcessConverter;
this.queryProcessorFactory = context.queryProcessorFactory;
@@ -373,20 +370,6 @@
}
/**
- * @param optimisticTransaction The optimisticTransaction to set.
- */
- public void setOptimisticTransaction(boolean optimisticTransaction) {
- this.optimisticTransaction = optimisticTransaction;
- }
-
- /**
- * @return Returns the optimisticTransaction.
- */
- public boolean isOptimisticTransaction() {
- return optimisticTransaction;
- }
-
- /**
* @return Returns the securityFunctionEvaluator.
*/
public SecurityFunctionEvaluator getSecurityFunctionEvaluator() {
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-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -359,21 +359,15 @@
boolean startAutoWrapTxn = false;
- if(ExecutionProperties.AUTO_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
+ if(ExecutionProperties.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
startAutoWrapTxn = true;
} else if ( processingCommand.updatingModelCount(metadata) > 1) {
- if (ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
- String msg = DQPPlugin.Util.getString("Request.txn_needed_wrong_mode", requestId); //$NON-NLS-1$
- throw new MetaMatrixComponentException(msg);
- } else if (ExecutionProperties.AUTO_WRAP_PESSIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
+ if (ExecutionProperties.TXN_WRAP_AUTO.equals(requestMsg.getTxnAutoWrapMode())){
startAutoWrapTxn = true;
- } else if (ExecutionProperties.AUTO_WRAP_OFF.equals(requestMsg.getTxnAutoWrapMode())) {
+ } else if (ExecutionProperties.TXN_WRAP_OFF.equals(requestMsg.getTxnAutoWrapMode())) {
LogManager.logDetail(LogConstants.CTX_DQP, DQPPlugin.Util.getString("Request.potentially_unsafe")); //$NON-NLS-1$
}
}
- if(ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
- this.context.setOptimisticTransaction(true);
- }
if (startAutoWrapTxn) {
if (transactionService == null) {
@@ -542,7 +536,7 @@
}
}
- private void createAnalysisRecord(Command command) throws QueryValidatorException{
+ private void createAnalysisRecord(Command command) {
Option option = command.getOption();
boolean getPlan = requestMsg.getShowPlan();
boolean debug = false;
@@ -551,11 +545,6 @@
debug = option.getDebug();
}
- if (getPlan && !requestMsg.isQueryPlanAllowed()){
- final String message = DQPPlugin.Util.getString("Request.query_plan_not_allowed"); //$NON-NLS-1$
- throw new QueryValidatorException(message);
- }
-
this.analysisRecord = new AnalysisRecord(getPlan, getPlan, debug);
}
Modified: trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties 2009-12-14 18:48:26 UTC (rev 1662)
@@ -371,9 +371,8 @@
Request.txn.info.resume=Resumed transaction "{0}".
Request.txn.info.export=Exported transaction "{0}".
Request.txn.info.suspend=Suspended transaction "{0}".
-Request.txn_needed_wrong_mode=Detected request "{0}" with multiple updates when using txnAutoWrap=OPTIMISTIC. If you are using MetaMatrix Enterprise, you can set txnAutoWrap=OFF to avoid using a transaction or txnAutoWrap=PESSIMISTIC to automatically create a transaction when needed. If you are not using MetaMatrix Enterprise, no transaction manager is provided and transactions are not supported. In that case, you can set txnAutoWrap=OFF to allow transaction methods to be called and ignored without actual transaction support. WARNING: Setting txnAutowrap=OFF and using transaction methods is risky because transactions will not be executed atomically and rollback will not occur!
Request.transaction_not_supported=Autowrap transaction required, but transaction support is disabled
-Request.potentially_unsafe=The request is modifying more than 1 model without any containing transaction (txnAutoWrap = OFF). This is potentially unsafe as the updates cannot be rolled back as a single unit.
+Request.potentially_unsafe=The request is modifying more than 1 model without any containing transaction (autoCommitTxn = OFF). This is potentially unsafe as the updates cannot be rolled back as a single unit.
Request.no_result_set=Statement does not return a result set.
Request.result_set=Statement returns a result set, not an update count.
Request.wsdl_user_not_authorized=The anonymous user is not authorized for this action.
@@ -405,28 +404,9 @@
ResultBatch.update_count_unavailable=Unable to retrieve an update count from this batch.
ServerConnectionInfo.invalid_context=Invalid portable context string. Unable to reinstantiate a ServerConnectionInfo from the string :{0}
ServerConnectionInfo.invalid_url=The url "{0}" is invalid and could not be parsed. The url should be of the form mm[s]://host[,host2,host3...]:port[,port2,port3...]
-ServerFacadeImpl.invalid_txnautowrap=Invalid transaction autowrap mode "{0}"
-ServerFacadeImpl.invalid_beginRow=Invalid beginRow {0}: beginRow must be >= 1
-ServerFacadeImpl.invalid_endRow=Invalid maxEndRow {0}: beginRow must be <= maxEndRow
-ServerFacadeImpl.invalid_waitTime=Invalid waitTime {0}: waitTime must be >= 0
-ServerFacadeImpl.invalid_connInfo=The server facade expects an instance of ServerConnectionInfo.
-ServerFacadeImpl.null_requestInfo=The request info must not be null.
-ServerFacadeImpl.invalid_requestInfo=The server facade expects an instance of ServerRequest.
-ServerFacadeImpl.invalid_cursorType=The cursor type must be one of {ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE}.
-ServerFacadeImpl.invalid_fetchSize=The fetch size must be >= 0
-ServerFacadeImpl.invalid_requestType=The request type must be one of {RequestInfo.REQUEST_TYPE_STATEMENT,RequestInfo.REQUEST_TYPE_PREPARED_STATEMENT,RequestInfo.REQUEST_TYPE_CALLABLE_STATEMENT}.
-ServerFacadeImpl.invalid_sql=The SQL command must not be null.
-ServerFacadeImpl.invalid_txnAutowrap=The transaction autowrap mode must be one of {RequestInfo.AUTOWRAP_OFF,RequestInfo.AUTOWRAP_ON,RequestInfo.AUTOWRAP_OPTIMISTIC,RequestInfo.AUTOWRAP_PESSIMISTIC}.
ServerSessionContext.invalid_context=Invalid portable context string. Unable to reinstantiate a server session context from the string :{0}
ServerSessionContext.null_context=The portable session context should not be null.
ServerConnectionInfo.invalid_encoding=Invalid encoded object within the portable string. Unable to reinstantiate an object from the encoded string :{0}
-ServerFacadeImpl.timeout=Timed out while waiting for a response.
-ServerFacadeImpl.null_connInfo=The connection info must not be null.
-ServerFacadeImpl.null_URL=The server URL must not be null.
-ServerFacadeImpl.null_user=The user name must not be null.
-ServerFacadeImpl.null_pwd=The password must not be null.
-ServerFacadeImpl.null_vdb=The VDB name must not be null.
-ServerFacadeImpl.updates_not_supported=The server facade does not support metadata requests for INSERT, UPDATE, DELETE, or SELECT...INTO statements.
ResultBatch.not_last_batch=This method can only be called on the last batch of results.
ResultBatch.not_out_param=The parameter at index {0} must be of type RETURN, OUT, or INOUT
CacheResults.Trying_to_cache_unexpected_results=Trying to cache unexpected results. Expected request ID "{0}"; Got request ID "{1}"
Deleted: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParseCommandType.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParseCommandType.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParseCommandType.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -1,92 +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.parser;
-
-import com.metamatrix.query.sql.lang.*;
-import junit.framework.*;
-
-public class TestParseCommandType extends TestCase {
-
- // ################################## FRAMEWORK ################################
-
- public TestParseCommandType(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
- private void helpTest(String sql, int expectedType) {
- int actualType = QueryParser.getCommandType(sql);
- assertEquals("Did not get expected type", expectedType, actualType); //$NON-NLS-1$
- }
-
- // ################################## ACTUAL TESTS ################################
-
- public void testQuery1() {
- helpTest("SELECT a FROM g", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testQuery2() {
- helpTest("select a FROM g", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testQuery3() {
- helpTest("select", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testSetQuery1() {
- helpTest("SELECT a FROM g UNION SELECT b from z", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testSetQuery2() {
- helpTest("(Select a FROM g UNION SELECT b from z) union select c from r order by s", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testInsert() {
- helpTest("insert g (b) values (1)", Command.TYPE_INSERT); //$NON-NLS-1$
- }
-
- public void testUpdate() {
- helpTest("update g set b=1", Command.TYPE_UPDATE); //$NON-NLS-1$
- }
-
- public void testDelete() {
- helpTest("delete from g where x=1", Command.TYPE_DELETE); //$NON-NLS-1$
- }
-
- public void testUnknown1() {
- helpTest("", Command.TYPE_UNKNOWN); //$NON-NLS-1$
- }
-
- public void testUnknown2() {
- helpTest("abc select", Command.TYPE_UNKNOWN); //$NON-NLS-1$
- }
-
- public void testUnknown3() {
- helpTest("selec", Command.TYPE_UNKNOWN); //$NON-NLS-1$
- }
-
- public void testUnknown4() {
- helpTest("selec ", Command.TYPE_UNKNOWN); //$NON-NLS-1$
- }
-}
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -24,6 +24,7 @@
import static org.junit.Assert.*;
+import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -139,66 +140,30 @@
}
}
- private void helpBlockTest(String block, String expectedString, Block expectedBlock) {
- Block actualBlock = null;
- String actualString = null;
- try {
- actualBlock = QueryParser.getQueryParser().parseBlock(block);
- actualString = actualBlock.toString();
-
- } catch(Throwable e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+ private void helpBlockTest(String block, String expectedString, Block expectedBlock) throws ParseException {
+ Block actualBlock = new SQLParser(new StringReader(block)).block(new ParseInfo());
+ String actualString = actualBlock.toString();
assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
assertEquals("Block does not match: ", expectedBlock, actualBlock); //$NON-NLS-1$
}
- private void helpCriteriaSelectorTest(String selector, String expectedString, CriteriaSelector expectedSelector) {
-
- CriteriaSelector actualSelector = null;
- String actualString = null;
- try {
- actualSelector = QueryParser.getQueryParser().parseCriteriaSelector(selector);
- actualString = actualSelector.toString();
-
- } catch(Throwable e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+ private void helpCriteriaSelectorTest(String selector, String expectedString, CriteriaSelector expectedSelector) throws ParseException {
+ CriteriaSelector actualSelector = new SQLParser(new StringReader(selector)).criteriaSelector();
+ String actualString = actualSelector.toString();
assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
assertEquals("CriteriaSelector does not match: ", expectedSelector, actualSelector); //$NON-NLS-1$
}
- private void helpCriteriaTest(String crit, String expectedString, Criteria expectedCrit) {
-
- Criteria actualCrit = null;
- String actualString = null;
- try {
- //actualCrit = QueryParser.getQueryParser().parsePredicateCriteria(crit);
- actualCrit = QueryParser.getQueryParser().parseCriteria(crit);
- actualString = actualCrit.toString();
-
- } catch(Throwable e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+ private void helpCriteriaTest(String crit, String expectedString, Criteria expectedCrit) throws QueryParserException {
+ Criteria actualCrit = QueryParser.getQueryParser().parseCriteria(crit);
+ String actualString = actualCrit.toString();
assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
assertEquals("Criteria does not match: ", expectedCrit, actualCrit); //$NON-NLS-1$
-
}
- private void helpStmtTest(String stmt, String expectedString, Statement expectedStmt) {
- Statement actualStmt = null;
- String actualString = null;
- try {
- actualStmt = QueryParser.getQueryParser().parseStatement(stmt);
- actualString = actualStmt.toString();
-
- } catch(Throwable e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+ private void helpStmtTest(String stmt, String expectedString, Statement expectedStmt) throws ParseException {
+ Statement actualStmt = new SQLParser(new StringReader(stmt)).statement(new ParseInfo());
+ String actualString = actualStmt.toString();
assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
assertEquals("Language objects do not match: ", expectedStmt, actualStmt); //$NON-NLS-1$
}
@@ -3184,10 +3149,8 @@
/**
* Try nesting subquery in double parentheses - parsing fails. 'exec' is not handled as
* robustly as other types of commands that can appear in a from clause subquery.
- *
- * deferred, not important enough
*/
- public void DEFERRED_testStoredQuerySubqueryMultipleParens(){
+ public void testStoredQuerySubqueryMultipleParens(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
SPParameter parameter = new SPParameter(1, new Constant("param1")); //$NON-NLS-1$
@@ -3205,14 +3168,14 @@
helpTest("SELECT X.A FROM ((exec proc1('param1'))) AS X", "SELECT X.A FROM (EXEC proc1('param1')) AS X", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testErrorStatement(){
+ @Test public void testErrorStatement() throws Exception {
RaiseErrorStatement errStmt = new RaiseErrorStatement(new Constant("Test only")); //$NON-NLS-1$
helpStmtTest("ERROR 'Test only';", "ERROR 'Test only';", //$NON-NLS-1$ //$NON-NLS-2$
errStmt);
}
- @Test public void testIfStatement(){
+ @Test public void testIfStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
Statement ifStmt = new DeclareStatement(a, shortType);
@@ -3264,7 +3227,7 @@
stmt);
}*/
- @Test public void testCriteriaSelector0(){
+ @Test public void testCriteriaSelector0() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3274,7 +3237,7 @@
helpCriteriaSelectorTest("IS NULL CRITERIA ON (a)", "IS NULL CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector1(){
+ @Test public void testCriteriaSelector1() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3284,7 +3247,7 @@
helpCriteriaSelectorTest("= CRITERIA ON (a)", "= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector2(){
+ @Test public void testCriteriaSelector2() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3294,7 +3257,7 @@
helpCriteriaSelectorTest("<> CRITERIA ON (a)", "<> CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector3(){
+ @Test public void testCriteriaSelector3() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3304,7 +3267,7 @@
helpCriteriaSelectorTest("< CRITERIA ON (a)", "< CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector4(){
+ @Test public void testCriteriaSelector4() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3314,7 +3277,7 @@
helpCriteriaSelectorTest("> CRITERIA ON (a)", "> CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector5(){
+ @Test public void testCriteriaSelector5() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3324,7 +3287,7 @@
helpCriteriaSelectorTest(">= CRITERIA ON (a)", ">= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector6(){
+ @Test public void testCriteriaSelector6() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3334,7 +3297,7 @@
helpCriteriaSelectorTest("<= CRITERIA ON (a)", "<= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector7(){
+ @Test public void testCriteriaSelector7() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3345,7 +3308,7 @@
}
- @Test public void testCriteriaSelector8(){
+ @Test public void testCriteriaSelector8() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3355,7 +3318,7 @@
helpCriteriaSelectorTest("IN CRITERIA ON (a)", "IN CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector9(){
+ @Test public void testCriteriaSelector9() throws Exception {
//ElementSymbol a = new ElementSymbol("a");
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3365,7 +3328,7 @@
helpCriteriaSelectorTest("CRITERIA", "CRITERIA", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector10(){
+ @Test public void testCriteriaSelector10() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3376,7 +3339,7 @@
}
/**HAS IS NULL CRITERIA ON (a)*/
- @Test public void testHasIsNullCriteria(){
+ @Test public void testHasIsNullCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3393,7 +3356,7 @@
}
/**HAS LIKE CRITERIA ON (a)*/
- @Test public void testHasLikeCriteria(){
+ @Test public void testHasLikeCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3409,7 +3372,7 @@
hasSelector);
}
- @Test public void testHasEQCriteria(){
+ @Test public void testHasEQCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3425,7 +3388,7 @@
hasSelector);
}
- @Test public void testHasNECriteria(){
+ @Test public void testHasNECriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3442,7 +3405,7 @@
}
/**HAS IN CRITERIA ON (a)*/
- @Test public void testHasInCriteria(){
+ @Test public void testHasInCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3459,7 +3422,7 @@
}
/**HAS COMPARE_LT CRITERIA ON (a)*/
- @Test public void testHasLTCriteria(){
+ @Test public void testHasLTCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3476,7 +3439,7 @@
}
/**HAS COMPARE_LE CRITERIA ON (a)*/
- @Test public void testHasLECriteria(){
+ @Test public void testHasLECriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3493,7 +3456,7 @@
}
/**HAS COMPARE_GT CRITERIA ON (a)*/
- @Test public void testHasGTCriteria(){
+ @Test public void testHasGTCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3510,7 +3473,7 @@
}
/**HAS COMPARE_GE CRITERIA ON (a)*/
- @Test public void testHasGECriteria(){
+ @Test public void testHasGECriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3527,7 +3490,7 @@
}
/**HAS BETWEEN CRITERIA ON (a)*/
- @Test public void testHasBetweenCriteria(){
+ @Test public void testHasBetweenCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3543,7 +3506,7 @@
hasSelector);
}
- @Test public void testTranslateCriteria(){
+ @Test public void testTranslateCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3569,7 +3532,7 @@
}
- @Test public void testAssignStatement(){
+ @Test public void testAssignStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List symbols = new ArrayList();
@@ -3600,7 +3563,7 @@
helpStmtTest("a = 'aString';", "a = 'aString';", exprStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testAssignStatement2(){
+ @Test public void testAssignStatement2() throws Exception {
Insert insert = new Insert();
insert.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
List vars = new ArrayList();
@@ -3619,7 +3582,7 @@
}
- @Test public void testDeclareStatement(){
+ @Test public void testDeclareStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type);
@@ -3627,7 +3590,7 @@
helpStmtTest("DECLARE short a;","DECLARE short a;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testDeclareStatementWithAssignment(){
+ @Test public void testDeclareStatementWithAssignment() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type, new Constant(null));
@@ -3635,7 +3598,7 @@
helpStmtTest("DECLARE short a = null;","DECLARE short a = null;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testDeclareStatementWithAssignment1(){
+ @Test public void testDeclareStatementWithAssignment1() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("string"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type, sampleQuery());
@@ -3643,7 +3606,7 @@
helpStmtTest("DECLARE string a = SELECT a1 FROM g WHERE a2 = 5;","DECLARE string a = SELECT a1 FROM g WHERE a2 = 5;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testStatement() {
+ @Test public void testStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement declStmt = new DeclareStatement(a, type);
@@ -3653,7 +3616,7 @@
stmt);
}
- @Test public void testBlock() {
+ @Test public void testBlock() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement declStmt = new DeclareStatement(a, type);
@@ -3664,7 +3627,7 @@
block);
}
- @Test public void testCommandStatement(){
+ @Test public void testCommandStatement() throws Exception {
Query query = sampleQuery();
Command sqlCmd = query;
@@ -3695,7 +3658,7 @@
return query;
}
- @Test public void testDynamicCommandStatement(){
+ @Test public void testDynamicCommandStatement() throws Exception {
List symbols = new ArrayList();
ElementSymbol a1 = new ElementSymbol("a1"); //$NON-NLS-1$
@@ -3718,7 +3681,7 @@
}
//sql is a variable, also uses the as, into, and update clauses
- @Test public void testDynamicCommandStatement1(){
+ @Test public void testDynamicCommandStatement1() throws Exception {
List symbols = new ArrayList();
ElementSymbol a1 = new ElementSymbol("a1"); //$NON-NLS-1$
@@ -3746,7 +3709,7 @@
cmdStmt);
}
- @Test public void testDynamicCommandStatementWithUsing(){
+ @Test public void testDynamicCommandStatementWithUsing() throws Exception {
SetClauseList using = new SetClauseList();
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -5478,7 +5441,7 @@
helpTest(sql, sqlExpected, query);
}
- @Test public void testLoopStatement(){
+ @Test public void testLoopStatement() throws Exception {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5510,7 +5473,7 @@
+"\n"+"END", loopStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testLoopStatementWithOrderBy(){
+ @Test public void testLoopStatementWithOrderBy() throws Exception {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5546,7 +5509,7 @@
+"\n"+"END", loopStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testWhileStatement(){
+ @Test public void testWhileStatement() throws Exception {
ElementSymbol x = new ElementSymbol("x", false); //$NON-NLS-1$
Function f = new Function("+", new Expression[] { x, new Constant(new Integer(1)) }); //$NON-NLS-1$
Statement assignmentStmt = new AssignmentStatement(x, f);
@@ -5560,12 +5523,12 @@
+"\n"+"END", whileStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testBreakStatement(){
+ @Test public void testBreakStatement() throws Exception {
Statement breakStmt = new BreakStatement();
helpStmtTest("break;", "BREAK;", breakStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testContinueStatement(){
+ @Test public void testContinueStatement() throws Exception {
Statement contStmt = new ContinueStatement();
helpStmtTest("continue;", "CONTINUE;", contStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
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-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -109,14 +109,12 @@
}
}
- static void helpTestProcess(boolean optimistic, ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail,
- ProcessorDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
+ static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
// Process twice, testing reset and clone method of Processor plan
for (int i=1; i<=2; i++) {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
CommandContext context = new CommandContext("pID", null, null, null, null); //$NON-NLS-1$
context.getNextRand(0);
- context.setOptimisticTransaction(optimistic);
context.setProcessDebug(DEBUG);
QueryProcessor processor = new QueryProcessor(procPlan, context, bufferMgr, dataMgr);
TupleSourceID tsID = processor.getResultsID();
@@ -194,12 +192,12 @@
}
private void helpTestProcess(ProcessorPlan procPlan, int expectedRows, FakeDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
- helpTestProcess(false, procPlan, expectedRows, null, false, dataMgr);
+ helpTestProcess(procPlan, expectedRows, null, false, dataMgr);
}
static void helpTestProcess(boolean optimistic, ProcessorPlan procPlan, List[] expectedResults,
ProcessorDataManager dataMgr, boolean shouldFail) throws SQLException, MetaMatrixCoreException {
- helpTestProcess(optimistic, procPlan, 0, expectedResults, shouldFail, dataMgr);
+ helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr);
}
// Helper to create a list of elements - used in creating sample data
@@ -1654,38 +1652,7 @@
helpTestProcessFailure(false, plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE STRING 'select e1 from pm1.g1'\" with the SQL statement \"'select e1 from pm1.g1'\" due to: The datatype 'string' for element 'E1' in the dynamic SQL cannot be implicitly converted to 'integer'."); //$NON-NLS-1$
}
-
- @Test public void testDynamicCommandInvalidModelUpdateCountEqualOne() throws Exception {
- //Test invalid update model count
- //Set update model count to 1 while actual is 2
- 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", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
- + "INSERT INTO pm1.g1 (e1) VALUES (pm1.sq1.in);UPDATE pm1.g2 SET e1 = 'Next'; END"); //$NON-NLS-1$
- FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1); //$NON-NLS-1$
-
- QueryNode sq2n2 = new QueryNode("pm1.sq2", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
- + "execute string 'EXEC pm1.sq1(''First'')' as e1 string UPDATE 1; END"); //$NON-NLS-1$
- FakeMetadataObject sq2 = FakeMetadataFactory.createVirtualProcedure("pm1.sq2", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n2); //$NON-NLS-1$
-
- metadata.getStore().addObject(rs2);
- metadata.getStore().addObject(sq1);
- metadata.getStore().addObject(sq2);
-
- String userUpdateStr = "EXEC pm1.sq2('test')"; //$NON-NLS-1$
-
- FakeDataManager dataMgr = exampleDataManager(metadata);
-
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
-
- helpTestProcessFailure(true, plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE STRING 'EXEC pm1.sq1(''First'')' AS e1 string UPDATE 1\" with the SQL statement \"'EXEC pm1.sq1(''First'')'\" due to: The actual model update count '2' is greater than the expected value of '1'. This is potentially unsafe in OPTIMISTIC transaction mode. Please adjust the UPDATE clause of the dynamic SQL statement."); //$NON-NLS-1$
- }
-
+
@Test public void testDynamicCommandWithTwoDynamicStatements() throws Exception {
//Tests dynamic query with two consecutive DynamicCommands. The first without an AS clause and returning different results.
FakeMetadataFacade metadata = FakeMetadataFactory.example1();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -209,7 +209,7 @@
public void helpTestVisibilityFails(String sql) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
- reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_OFF);
+ reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_OFF);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString()); //$NON-NLS-1$
@@ -235,7 +235,7 @@
RequestMessage reqMsg = exampleRequestMessage(sql);
DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new MetaMatrixSessionID(sessionid), userName));
if (txnAutoWrap) {
- reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
+ reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_ON);
}
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
16 years, 4 months
teiid SVN: r1661 - trunk/connector-api/src/main/resources.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-14 13:21:21 -0500 (Mon, 14 Dec 2009)
New Revision: 1661
Modified:
trunk/connector-api/src/main/resources/connector-base.xml
Log:
TEIID-168 removing result set caching from the connectors
Modified: trunk/connector-api/src/main/resources/connector-base.xml
===================================================================
--- trunk/connector-api/src/main/resources/connector-base.xml 2009-12-14 16:45:10 UTC (rev 1660)
+++ trunk/connector-api/src/main/resources/connector-base.xml 2009-12-14 18:21:21 UTC (rev 1661)
@@ -12,13 +12,6 @@
<PropertyDefinition Name="ServiceClassName" DisplayName="Service Class Name" ShortDescription="" DefaultValue="com.metamatrix.server.connector.service.ConnectorService" IsRequired="true" IsModifiable="false" />
<PropertyDefinition Name="MaxResultRows" DisplayName="Maximum Result Rows" ShortDescription="" DefaultValue="10000" IsRequired="true" PropertyType="Integer" IsExpert="true" />
<PropertyDefinition Name="SynchWorkers" DisplayName="Synchronous Workers" ShortDescription="Whether worker threads will be bound to connections. Asynch connectors should set this value to false." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
- <PropertyDefinition Name="ResultSetCacheEnabled" DisplayName="ResultSet Cache Enabled" ShortDescription="" DefaultValue="false" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
- <PropertyDefinition Name="ResultSetCacheMaxSize" DisplayName="ResultSet Cache Maximum Size (megabytes)" ShortDescription="" DefaultValue="20" PropertyType="Integer" IsExpert="true" />
- <PropertyDefinition Name="ResultSetCacheMaxAge" DisplayName="ResultSet Cache Maximum Age (milliseconds)" ShortDescription="" DefaultValue="3600000" PropertyType="Long" IsExpert="true" />
- <PropertyDefinition Name="ResultSetCacheScope" DisplayName="ResultSet Cache Scope" ShortDescription="" DefaultValue="vdb" IsExpert="true">
- <AllowedValue>vdb</AllowedValue>
- <AllowedValue>session</AllowedValue>
- </PropertyDefinition>
<PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Set to true if this is an XA Connector" DefaultValue="false" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
<PropertyDefinition Name="ConnectionPoolEnabled" DisplayName="Connection Pool Enabled" ShortDescription="Enable the use of connection pooling with this connector." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
<PropertyDefinition Name="UseCredentialMap" DisplayName="Requires Credential Map" ShortDescription="Set to true if this connector requires credentials to be passed via a credential map." DefaultValue="false" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
16 years, 4 months
teiid SVN: r1660 - in branches/JCA: common-internal/src/main/java/com/metamatrix/platform/security/api and 9 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-14 11:45:10 -0500 (Mon, 14 Dec 2009)
New Revision: 1660
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java
branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java
branches/JCA/engine/src/main/java/org/teiid/cache/
branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
Log:
TEIID-833: adding VDB deployer
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,28 @@
+/*
+ * 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.adminapi;
+
+import java.io.Serializable;
+
+public enum Visibility implements Serializable{
+ PUBLIC,PRIVATE;
+}
\ No newline at end of file
Added: branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
===================================================================
--- branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java (rev 0)
+++ branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,36 @@
+/*
+ * 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.platform.security.api;
+
+import java.util.Collection;
+
+public class AuthorizationPoliciesHolder {
+ private Collection<AuthorizationPolicy> policies;
+
+ public void setAuthorizationPolicies(Collection<AuthorizationPolicy> policies) {
+ this.policies = policies;
+ }
+
+ public Collection<AuthorizationPolicy> getAuthorizationPolicies(){
+ return this.policies;
+ }
+}
Added: branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
===================================================================
(Binary files differ)
Property changes on: branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java (rev 0)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,29 @@
+package com.metamatrix.common.comm;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+public class ClientServiceRegistryImpl implements ClientServiceRegistry{
+
+ private ConcurrentHashMap<String, Object> localServices = new ConcurrentHashMap<String, Object>();
+ private ConcurrentHashMap<String, String> loggingContext = new ConcurrentHashMap<String, String>();
+
+ public ClientServiceRegistryImpl() {
+ }
+
+ public <T> T getClientService(Class<T> iface) {
+ return (T)this.localServices.get(iface.getName());
+ }
+
+ public Object getClientService(String iface) {
+ return localServices.get(iface);
+ }
+
+ public <T> void registerClientService(Class<T> iface, T instance, String loggingContext) {
+ this.localServices.put(iface.getName(), instance);
+ this.loggingContext.put(iface.getName(), loggingContext);
+ }
+
+ public String getLoggingContextForService(String iface) {
+ return this.loggingContext.get(iface);
+ }
+}
Added: branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,135 @@
+/*
+ * 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.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.metamatrix.cache.Cache;
+import com.metamatrix.cache.CacheConfiguration;
+import com.metamatrix.cache.CacheFactory;
+import com.metamatrix.cache.CacheListener;
+import com.metamatrix.cache.Cache.Type;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class DefaultCacheFactory implements CacheFactory, Serializable {
+ private static final long serialVersionUID = -5541424157695857527L;
+
+ DefaultCache cacheRoot = new DefaultCache("Teiid");
+ private volatile boolean destroyed = false;
+
+ @Override
+ public void destroy() {
+ this.destroyed = true;
+ }
+
+ @Override
+ public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+ if (!destroyed) {
+ Cache node = cacheRoot.addChild(type.location());
+ return node;
+ }
+ throw new MetaMatrixRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
+ }
+
+ class DefaultCache<K, V> implements Cache<K, V>, Serializable {
+ Map<K, V> map = new HashMap();
+ Map<String, Cache> children = new HashMap();
+ String name;
+
+ public DefaultCache(String name) {
+ this.name = name;
+ }
+ public void addListener(CacheListener listener) {
+ }
+
+ public void clear() {
+ map.clear();
+ }
+
+ public V get(K key) {
+ return map.get(key);
+ }
+
+ public Set<K> keySet() {
+ return map.keySet();
+ }
+
+ public V put(K key, V value) {
+ return map.put(key, value);
+ }
+
+ public V remove(K key) {
+ return map.remove(key);
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public Collection<V> values() {
+ return map.values();
+ }
+
+ @Override
+ public void removeListener() {
+ }
+
+ @Override
+ public Cache addChild(String name) {
+ if (children.get(name) != null) {
+ return children.get(name);
+ }
+
+ Cache c = new DefaultCache(name);
+ children.put(name, c);
+ return c;
+ }
+
+ @Override
+ public Cache getChild(String name) {
+ return children.get(name);
+ }
+
+ @Override
+ public List<Cache> getChildren() {
+ return new ArrayList<Cache>(children.values());
+ }
+
+ @Override
+ public boolean removeChild(String name) {
+ Object obj = children.remove(name);
+ return obj != null;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+ }
+
+}
Added: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,46 @@
+/*
+ * 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.datamgr.impl;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+public class ConnectorManagerRepository implements Serializable{
+ private static final long serialVersionUID = -1611063218178314458L;
+
+ private Map<String, ConnectorManager> repo = new ConcurrentHashMap<String, ConnectorManager>();
+
+ public void addConnectorManager(String connectorName, ConnectorManager mgr) {
+ this.repo.put(connectorName, mgr);
+ }
+
+ public ConnectorManager getConnectorManager(String connectorName) {
+ return this.repo.get(connectorName);
+ }
+
+ public ConnectorManager removeConnectorManager(String connectorName) {
+ return this.repo.remove(connectorName);
+ }
+}
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,133 @@
+/*
+ * 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.jboss.deployers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+
+public class ConnectorBindingDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ManagedObjectCreator {
+ protected Logger log = Logger.getLogger(getClass());
+ private ManagedObjectFactory mof;
+
+ private ConnectorManagerRepository connectorManagerRepository;
+
+ public ConnectorBindingDeployer() {
+ super(ManagedConnectionFactoryDeploymentGroup.class);
+ setRelativeOrder(3000);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException {
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+ ConnectorManagerGroup cmGroup = new ConnectorManagerGroup();
+
+ for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+ String connectorDefinition = data.getConnectionDefinition();
+ if (connectorDefinition.equals("org.teiid.connector.api.Connector")) {
+ String connectorName = data.getJndiName();
+
+ ConnectorManager cm = null;
+ try {
+ cm = createConnectorManger("java:"+connectorName);
+ cm.start();
+ cmGroup.addConnectorManager(cm);
+ } catch (ApplicationLifecycleException e) {
+ throw new DeploymentException(e);
+ }
+
+ // Add the references to the mgr as loaded.
+ this.connectorManagerRepository.addConnectorManager("java:"+connectorName, cm);
+
+ log.info("Teiid Connector Started = " + connectorName); //$NON-NLS-1$
+ }
+ }
+
+ if (!cmGroup.getConnectorManagers().isEmpty()) {
+ unit.addAttachment(ConnectorManagerGroup.class, cmGroup);
+ }
+ }
+
+
+ ConnectorManager createConnectorManger(String deployedConnectorName) {
+ ConnectorManager mgr = new ConnectorManager(deployedConnectorName);
+ return mgr;
+ }
+
+ public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+ this.connectorManagerRepository = repo;
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) {
+ super.undeploy(unit, group);
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+ for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+ String connectorDefinition = data.getConnectionDefinition();
+ if (connectorDefinition.equals("org.teiid.connector.api.Connector")) {
+ String connectorName = data.getJndiName();
+ ConnectorManager cm = this.connectorManagerRepository.removeConnectorManager("java:"+connectorName);
+ if (cm != null) {
+ cm.stop();
+ }
+ log.info("Teiid Connector Stopped = " + connectorName); //$NON-NLS-1$
+ }
+ }
+ }
+
+ @Override
+ public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects)
+ throws DeploymentException {
+ //TODO: Need to link CM--> CB as management objects. rareddy
+ // ConnectorManagerGroup cmGroup = unit.removeAttachment(ConnectorManagerGroup.class);
+ // if (cmGroup != null) {
+ // for (ConnectorManager mgr:cmGroup.getConnectorManagers()) {
+ // ManagedObject mo = this.mof.initManagedObject(mgr, ConnectorManager.class, mgr.getName(), mgr.getName());
+ // if (mo == null) {
+ // throw new DeploymentException("could not create managed object");
+ // }
+ // managedObjects.put(mo.getName(), mo);
+ // }
+ // }
+ }
+
+
+ public void setManagedObjectFactory(ManagedObjectFactory mof) {
+ this.mof = mof;
+ }
+}
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,40 @@
+/*
+ * 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.jboss.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+
+public class ConnectorManagerGroup {
+ private List<ConnectorManager> mgrs = new ArrayList<ConnectorManager>();
+
+ public void addConnectorManager(ConnectorManager cm) {
+ this.mgrs.add(cm);
+ }
+
+ public List<ConnectorManager> getConnectorManagers(){
+ return this.mgrs;
+ }
+}
Added: branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
===================================================================
--- branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java (rev 0)
+++ branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,48 @@
+/*
+ * 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.internal.core.index;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.virtual.VirtualFile;
+
+import com.metamatrix.core.util.ObjectConverterUtil;
+
+public class VirtualRandomAccessFile {
+ File indexFile;
+ String mode;
+
+ public VirtualRandomAccessFile(VirtualFile file, String mode) throws IOException{
+ this.indexFile = File.createTempFile(file.getName(), null);
+ ObjectConverterUtil.write(file.openStream(), indexFile);
+ this.mode = mode;
+ }
+
+ public SafeRandomAccessFile getSafeRandomAccessFile() throws IOException {
+ return new SafeRandomAccessFile(indexFile, mode);
+ }
+
+ public void close() {
+ indexFile.delete();
+ }
+}
Added: branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,70 @@
+/*
+ * 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.deployers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.vfs.spi.deployer.MultipleVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Overriding the base MultipleVFSParsingDeployer so that the parse method is supplied with VFSDeploymentUnit.
+ * @param <T>
+ */
+public abstract class BaseMultipleVFSParsingDeployer<T> extends MultipleVFSParsingDeployer<T> {
+
+ public BaseMultipleVFSParsingDeployer(Class<T> output,Map<String, Class<?>> mappings, String suffix, Class<?> suffixClass) {
+ super(output, mappings, suffix, suffixClass);
+ }
+
+ public BaseMultipleVFSParsingDeployer(Class<T> output,Map<String, Class<?>> mappings) {
+ super(output, mappings);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected T mergeFiles(VFSDeploymentUnit unit, T root,List<VirtualFile> files, Set<String> missingFiles) throws Exception {
+ Map<Class<?>, List<Object>> metadata = new HashMap<Class<?>, List<Object>>();
+ for (VirtualFile file : files) {
+ Class<?> clazz = matchFileToClass(unit, file);
+ List<Object> instances = metadata.get(clazz);
+ if (instances == null) {
+ instances = new ArrayList<Object>();
+ metadata.put(clazz, instances);
+ }
+ Object instance = parse(unit, clazz, file, root);
+ instances.add(instance);
+ }
+ return mergeMetaData(unit, root, metadata, missingFiles);
+ }
+
+ @Override
+ protected <U> U parse(Class<U> expectedType, VirtualFile file, Object root) throws Exception{
+ throw new UnsupportedOperationException("This will be never invoked");
+ }
+ protected abstract <U> U parse(VFSDeploymentUnit unit, Class<U> expectedType, VirtualFile file, Object root) throws Exception;
+}
Added: branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,55 @@
+/*
+ * 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.deployers;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.Visibility;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+
+import com.metamatrix.core.vdb.ModelType;
+
+public class DynamicVDBDeployer extends AbstractVFSParsingDeployer<VDBMetaData> {
+
+ public DynamicVDBDeployer() {
+ super(VDBMetaData.class);
+ setSuffix("-vdb.xml");
+ }
+
+ @Override
+ protected VDBMetaData parse(VFSDeploymentUnit unit, VirtualFile file, VDBMetaData root) throws Exception {
+ VDBMetaData def = DefParser.load(file.openStream());
+
+ // Set the additional model properties which are traditionally on the VDB based Models.
+ for(ModelMetaData model:def.getModels()) {
+ model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+ model.setVisibility(Visibility.PUBLIC);
+ model.setSupportsMultiSourceBindings(false);
+ }
+
+ def.setUrl(unit.getRoot().toURL());
+ log.debug("VDB "+unit.getRoot().getName()+" has been parsed.");
+ return def;
+ }
+}
Added: branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,96 @@
+/*
+ * 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.deployers;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.plugins.context.zip.ZipEntryContext;
+import org.teiid.adminapi.Visibility;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.metadata.index.IndexConstants;
+import org.teiid.metadata.index.IndexMetadataFactory;
+
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class SystemVDBDeployer {
+ private VDBRepository vdbRepository;
+
+
+ public void start() {
+ ModelMetaData model = new ModelMetaData();
+ model.setName(CoreConstants.SYSTEM_MODEL);
+ model.setVisibility(Visibility.PUBLIC);
+
+ VDBMetaData deployment = new VDBMetaData();
+ deployment.setName(CoreConstants.SYSTEM_VDB);
+
+ deployment.addModel(model);
+
+ try {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB);
+ if (url == null) {
+ throw new MetaMatrixRuntimeException("System.vdb not found in classpath");
+ }
+ SystemVDBContext systemVDB = new SystemVDBContext(url);
+ VirtualFile vdb = new VirtualFile(systemVDB.getRoot());
+ List<VirtualFile> children = vdb.getChildrenRecursively(new VirtualFileFilter() {
+ @Override
+ public boolean accepts(VirtualFile file) {
+ return file.getName().endsWith(IndexConstants.NAME_DELIM_CHAR+IndexConstants.INDEX_EXT);
+ }
+ });
+
+ IndexMetadataFactory imf = new IndexMetadataFactory();
+ for (VirtualFile f: children) {
+ imf.addIndexFile(f);
+ }
+ this.vdbRepository.addMetadataStore(deployment, imf.getMetadataStore());
+ } catch (URISyntaxException e) {
+ throw new MetaMatrixRuntimeException(e, "Failed to deploy "+CoreConstants.SYSTEM_VDB);
+ } catch (IOException e) {
+ throw new MetaMatrixRuntimeException(e, "Failed to deploy "+CoreConstants.SYSTEM_VDB);
+ }
+ }
+
+ public void stop() {
+ this.vdbRepository.removeVDB(CoreConstants.SYSTEM_VDB, 1);
+ }
+
+ public void setVDBRepository(VDBRepository repo) {
+ this.vdbRepository = repo;
+ }
+
+ private static class SystemVDBContext extends ZipEntryContext{
+ private static final long serialVersionUID = -6504988258841073415L;
+
+ protected SystemVDBContext(URL url) throws IOException, URISyntaxException {
+ super(url,true);
+ }
+ }
+}
16 years, 4 months
teiid SVN: r1656 - in trunk/engine/src: main/java/com/metamatrix/query/optimizer/relational/rules and 9 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-11 18:05:15 -0500 (Fri, 11 Dec 2009)
New Revision: 1656
Added:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.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/TestRuleChooseDependent.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
Log:
TEIID-900 changing to more uniformly propagate the no cache hint and to make the table specific no cache apply only to one level
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-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -445,7 +445,7 @@
if(command instanceof Insert){
Insert insert = (Insert)command;
if (insert.getQueryExpression() != null) {
- PlanNode plan = createQueryPlan(insert.getQueryExpression());
+ PlanNode plan = generatePlan(insert.getQueryExpression());
attachLast(sourceNode, plan);
mergeTempMetadata(insert.getQueryExpression(), insert);
projectNode.setProperty(NodeConstants.Info.INTO_GROUP, insert.getGroup());
@@ -694,16 +694,14 @@
MetaMatrixComponentException, QueryResolverException,
QueryValidatorException, QueryMetadataException {
if (nestedCommand instanceof QueryCommand) {
+ //remove unnecessary order by
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;
}
@@ -712,6 +710,8 @@
mergeTempMetadata(nestedCommand, parentCommand);
PlanNode childRoot = generatePlan(nestedCommand);
node.addFirstChild(childRoot);
+ List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
+ node.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(group, projectCols, metadata));
} else {
QueryMetadataInterface actualMetadata = metadata;
if (actualMetadata instanceof TempMetadataAdapter) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -208,7 +208,20 @@
//update the parent plan with the staged aggregates and the new projected symbols
List<SingleElementSymbol> projectedViewSymbols = (List<SingleElementSymbol>)NodeEditor.findNodePreOrder(child, NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
- SymbolMap newParentMap = SymbolMap.createSymbolMap(child.getGroups().iterator().next(), projectedViewSymbols);
+ List<ElementSymbol> updatedVirturalElement = new ArrayList<ElementSymbol>(virtualElements);
+
+ //hack to introduce aggregate symbols to the parent view TODO: this should change the metadata properly.
+ GroupSymbol virtualGroup = child.getGroups().iterator().next();
+ for (int i = updatedVirturalElement.size(); i < projectedViewSymbols.size(); i++) {
+ SingleElementSymbol symbol = projectedViewSymbols.get(i);
+ String name = symbol.getShortName();
+ String virtualElementName = virtualGroup.getCanonicalName() + ElementSymbol.SEPARATOR + name;
+ ElementSymbol virtualElement = new ElementSymbol(virtualElementName);
+ virtualElement.setGroupSymbol(virtualGroup);
+ virtualElement.setType(symbol.getType());
+ updatedVirturalElement.add(virtualElement);
+ }
+ SymbolMap newParentMap = SymbolMap.createSymbolMap(updatedVirturalElement, projectedViewSymbols);
child.setProperty(NodeConstants.Info.SYMBOL_MAP, newParentMap);
Map<AggregateSymbol, ElementSymbol> projectedMap = new HashMap<AggregateSymbol, ElementSymbol>();
Iterator<AggregateSymbol> aggIter = aggregates.iterator();
@@ -303,7 +316,7 @@
List<SingleElementSymbol> projectedViewSymbols = QueryRewriter.deepClone(projectedSymbols, SingleElementSymbol.class);
- SymbolMap viewMapping = SymbolMap.createSymbolMap(NodeEditor.findParent(unionSource, NodeConstants.Types.SOURCE).getGroups().iterator().next(), projectedSymbols);
+ SymbolMap viewMapping = SymbolMap.createSymbolMap(NodeEditor.findParent(unionSource, NodeConstants.Types.SOURCE).getGroups().iterator().next(), projectedSymbols, metadata);
for (AggregateSymbol agg : aggregates) {
agg = (AggregateSymbol)agg.clone();
ExpressionMappingVisitor.mapExpressions(agg, viewMapping.asMap());
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -415,7 +414,7 @@
Criteria crit = (Criteria)critNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- Collection elements = getElementsIncriteria(crit);
+ Collection<ElementSymbol> elements = getElementsIncriteria(crit);
boolean removeAps = satisfyAccessPatterns(aps, elements);
if (removeAps) {
@@ -426,8 +425,8 @@
Collections.sort(aps);
}
- static Collection getElementsIncriteria(Criteria crit) {
- Collection elements = new HashSet();
+ static Collection<ElementSymbol> getElementsIncriteria(Criteria crit) {
+ Collection<ElementSymbol> elements = new HashSet<ElementSymbol>();
boolean first = true;
if(crit instanceof CompoundCriteria) {
CompoundCriteria compCrit = (CompoundCriteria) crit;
@@ -450,7 +449,7 @@
* @param elements
* @return
*/
- static boolean satisfyAccessPatterns(List<AccessPattern> aps, Collection elements) {
+ static boolean satisfyAccessPatterns(List<AccessPattern> aps, Collection<ElementSymbol> elements) {
for (AccessPattern ap : aps) {
ap.getUnsatisfied().removeAll(elements);
if (ap.getUnsatisfied().isEmpty()) {
@@ -484,39 +483,28 @@
satisfyAccessPatterns(critNode, sourceNode);
SymbolMap symbolMap = (SymbolMap) sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
-
+ SymbolMap childMap = symbolMap;
+
// Move criteria to first child of union - names are the same, so no symbol mapping
- LinkedList unionChildren = new LinkedList();
+ LinkedList<PlanNode> unionChildren = new LinkedList<PlanNode>();
collectUnionChildren(setOp, unionChildren);
int movedCount = 0;
- Iterator childIter = unionChildren.iterator();
- PlanNode firstChild = (PlanNode) childIter.next();
- GroupSymbol sourceGroup = sourceNode.getGroups().iterator().next();
-
- PlanNode firstBranchNode = NodeEditor.findNodePreOrder(firstChild, NodeConstants.Types.PROJECT);
-
- if(createConvertedSelectNode(critNode, virtualGroup, firstBranchNode, symbolMap)) {
- movedCount++;
- }
- // Find project cols on first branch
- List firstProjectCols = (List) firstBranchNode.getProperty(NodeConstants.Info.PROJECT_COLS);
-
- // For each of the remaining children of the union, push separately
- while(childIter.hasNext()) {
- PlanNode childNode = (PlanNode) childIter.next();
-
+ for (PlanNode planNode : unionChildren) {
// Find first project node
- PlanNode projectNode = NodeEditor.findNodePreOrder(childNode, NodeConstants.Types.PROJECT);
+ PlanNode projectNode = NodeEditor.findNodePreOrder(planNode, NodeConstants.Types.PROJECT);
- // Create symbol map
- symbolMap = SymbolMap.createSymbolMap(sourceGroup, firstProjectCols, (List) projectNode.getProperty(NodeConstants.Info.PROJECT_COLS));
+ if (childMap == null) {
+ childMap = SymbolMap.createSymbolMap(symbolMap.getKeys(), (List) projectNode.getProperty(NodeConstants.Info.PROJECT_COLS));
+ }
// Move the node
- if(createConvertedSelectNode(critNode, virtualGroup, projectNode, symbolMap)) {
+ if(createConvertedSelectNode(critNode, virtualGroup, projectNode, childMap)) {
movedCount++;
}
+
+ childMap = null; //create a new symbol map for the other children
}
//TODO - the logic here could be made more intelligent about EXCEPT and INTERSECT.
@@ -588,7 +576,7 @@
return false;
}
- Collection scalarSubqueries = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(converted);
+ Collection<SubqueryContainer> scalarSubqueries = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(converted);
if (!scalarSubqueries.isEmpty()){
return false;
}
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-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -113,7 +113,7 @@
// 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();
+ Map symbolMap = SymbolMap.createSymbolMap(virtualGroup, (List<SingleElementSymbol>)transformCmd.getProjectedSymbols(), metadata).asMap();
procCommand.setSymbolMap(symbolMap);
}
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-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -551,18 +551,6 @@
return groupInfo;
}
- public static List resolveElements(GroupSymbol group, QueryMetadataInterface metadata, List elementIDs) throws MetaMatrixComponentException, QueryMetadataException {
- GroupInfo groupInfo = getGroupInfo(group, metadata);
- List result = new ArrayList(elementIDs.size());
- for (Iterator iterator = elementIDs.iterator(); iterator.hasNext();) {
- Object id = iterator.next();
- ElementSymbol symbol = groupInfo.getSymbol(id);
- assert symbol != null;
- result.add(symbol);
- }
- return result;
- }
-
/**
* When access patterns are flattened, they are an approximation the user
* may need to enter as criteria.
@@ -590,11 +578,18 @@
}
while (j.hasNext()) {
List elements = metadata.getElementIDsInAccessPattern(j.next());
- elements = resolveElements(group, metadata, elements);
+ GroupInfo groupInfo = getGroupInfo(group, metadata);
+ List result = new ArrayList(elements.size());
+ for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
+ Object id = iterator.next();
+ ElementSymbol symbol = groupInfo.getSymbol(id);
+ assert symbol != null;
+ result.add(symbol);
+ }
if (flatten) {
- accessPatterns.addAll(elements);
+ accessPatterns.addAll(result);
} else {
- accessPatterns.add(new AccessPattern(elements));
+ accessPatterns.add(new AccessPattern(result));
}
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -26,11 +26,14 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.core.util.Assertion;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -100,27 +103,10 @@
}
public static final SymbolMap createSymbolMap(GroupSymbol virtualGroup,
- List<? extends SingleElementSymbol> projectCols) {
- return createSymbolMap(virtualGroup, projectCols, projectCols);
+ List<? extends SingleElementSymbol> projectCols, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ return createSymbolMap(ResolverUtil.resolveElementsInGroup(virtualGroup, metadata), projectCols);
}
- public static final SymbolMap createSymbolMap(GroupSymbol virtualGroup,
- List<? extends SingleElementSymbol> projectCols,
- List<? extends SingleElementSymbol> mappedCols) {
- String virtualGroupName = virtualGroup.getName();
- List<ElementSymbol> virtualElements = new LinkedList<ElementSymbol>();
- for (SingleElementSymbol symbol : projectCols) {
- String name = symbol.getShortName();
- String virtualElementName = virtualGroupName + ElementSymbol.SEPARATOR + name;
- ElementSymbol virtualElement = new ElementSymbol(virtualElementName);
- virtualElement.setGroupSymbol(virtualGroup);
- virtualElement.setType(symbol.getType());
- virtualElements.add(virtualElement);
- }
-
- return createSymbolMap(virtualElements, mappedCols);
- }
-
public static final SymbolMap createSymbolMap(List<ElementSymbol> virtualElements,
List<? extends Expression> mappedCols) {
Assertion.assertTrue(virtualElements.size() == mappedCols.size());
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -48,9 +48,9 @@
super();
// Load some default VDBs
- addVdb(null, null, FakeMetadataFactory.exampleBQT());
- addVdb("bqt", "1", FakeMetadataFactory.exampleBQT()); //$NON-NLS-1$ //$NON-NLS-2$
- addVdb("example1", "1", FakeMetadataFactory.example1()); //$NON-NLS-1$ //$NON-NLS-2$
+ addVdb(null, null, FakeMetadataFactory.exampleBQTCached());
+ addVdb("bqt", "1", FakeMetadataFactory.exampleBQTCached()); //$NON-NLS-1$ //$NON-NLS-2$
+ addVdb("example1", "1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
}
private String getKey(String vdbName, String vdbVersion) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -22,7 +22,7 @@
package com.metamatrix.query.optimizer;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
import com.metamatrix.query.processor.ProcessorPlan;
@@ -31,69 +31,69 @@
import com.metamatrix.query.validator.TestValidator;
-public class TestAccessPatterns extends TestCase {
+public class TestAccessPatterns {
/**
* The virtual access patterns should get satisfied
*/
- public void testVirtualAccessPatternPassing() {
+ @Test public void testVirtualAccessPatternPassing() {
String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1 and e1='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT test.\"group\".e0, test.\"group\".e2 FROM test.\"group\" WHERE (test.\"group\".e0 = 1) AND (test.\"group\".e1 = '2')"}); //$NON-NLS-1$
}
- public void testVirtualAccessPatternPassing1() {
+ @Test public void testVirtualAccessPatternPassing1() {
String sql = "delete from vm1.g37 where e1 = 1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {});
}
- public void testVirtualAccessPatternFailing() {
+ @Test public void testVirtualAccessPatternFailing() {
String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testVirtualAccessPatternFailing1() {
+ @Test public void testVirtualAccessPatternFailing1() {
String sql = "delete from vm1.g37"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern1() throws Exception {
+ @Test public void testAccessPattern1() throws Exception {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql,
TestValidator.exampleMetadata4(),
new String[] {"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
}
- public void testAccessPattern2() {
+ @Test public void testAccessPattern2() {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern3() {
+ @Test public void testAccessPattern3() {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and e2='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern4() throws Exception {
+ @Test public void testAccessPattern4() throws Exception {
String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
}
- public void testAccessPattern5() {
+ @Test public void testAccessPattern5() {
String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1)"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern6() {
+ @Test public void testAccessPattern6() {
String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT e1, e0, e2 FROM test.\"group\""}); //$NON-NLS-1$
}
- public void testAccessPattern7() {
+ @Test public void testAccessPattern7() {
String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM vTest.vGroup where e0=1)"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern8() {
+ @Test public void testAccessPattern8() {
String sql = "SELECT e0, e2 FROM vTest.vGroup"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
@@ -102,7 +102,7 @@
* Tests two access nodes, each with access patterns, but one already
* satisfied by user criteria - the other should be made dependent
*/
- public void testNodesBothHaveAccessPatterns1() throws Exception {
+ @Test public void testNodesBothHaveAccessPatterns1() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1, pm4.g2 where pm4.g2.e5 = 'abc' and pm4.g1.e1 = pm4.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 = 'abc'"}, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
@@ -113,7 +113,7 @@
* satisfied by user criteria - the other should be made dependent
* (same query written slightly different).
*/
- public void testNodesBothHaveAccessPatterns1a() throws Exception {
+ @Test public void testNodesBothHaveAccessPatterns1a() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g2, pm4.g1 where pm4.g2.e1 = pm4.g1.e1 and pm4.g2.e5 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 = 'abc'"}, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
@@ -123,7 +123,7 @@
* Self join - tests that both access nodes are satisfied by the select
* criteria (therefore merge join should be used)
*/
- public void testSelfJoinAccessPatterns() throws Exception {
+ @Test public void testSelfJoinAccessPatterns() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1, pm4.g1 as g1A where pm4.g1.e1 = 'abc' and g1A.e1 = 'abc' and pm4.g1.e2 = g1A.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g1A.e2 FROM pm4.g1 AS g1A WHERE g1A.e1 = 'abc'", "SELECT pm4.g1.e2, pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
@@ -145,41 +145,41 @@
});
}
- public void testAccessPatternsFails() {
+ @Test public void testAccessPatternsFails() {
TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2, pm4.g2 as g2A where pm4.g2.e2 = 123 and pm4.g2.e1 = g2A.e5", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPatternsFails2() {
+ @Test public void testAccessPatternsFails2() {
TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPatternFails() {
+ @Test public void testUnionWithAccessPatternFails() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1 from pm4.g1 where pm4.g1.e2 = 1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPatternFails2() {
+ @Test public void testUnionWithAccessPatternFails2() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1 from pm4.g1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPattern() {
+ @Test public void testUnionWithAccessPattern() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testUnionWithAccessPattern2() {
+ @Test public void testUnionWithAccessPattern2() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc' and pm4.g1.e2 = 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e1 FROM pm4.g1 WHERE (pm4.g1.e1 = 'abc') AND (pm4.g1.e2 = 1)" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testAccessPatternPartialMatch() throws Exception {
+ @Test public void testAccessPatternPartialMatch() throws Exception {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e1 and pm4.g2.e2 = 123", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
new String[] { "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE (g_0.e2 = 123) AND (g_0.e1 IN (<dependent values>))", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
@@ -190,7 +190,7 @@
* completely different query plan which can't satisfy the access pattern.
* @see #testAccessPatternPartialMatch
*/
- public void testAccessPatternFails3() {
+ @Test public void testAccessPatternFails3() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e1 or pm4.g2.e2 = 123", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null,
@@ -201,7 +201,7 @@
* Access patterns on models that support joins requires that the access patterns are satisfied prior to
* RulePlanJoins
*/
- public void testAccessPatternsGroupsInSameModelFails() {
+ @Test public void testAccessPatternsGroupsInSameModelFails() {
TestOptimizer.helpPlan("select pm5.g1.e1 from pm5.g1, pm5.g2 where pm5.g1.e1 = pm5.g2.e1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
@@ -211,7 +211,7 @@
// ACCESS PATTERNS
// ==================================================================================
- public void testPushingCriteriaThroughFrameAccessPattern0() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern0() {
TestOptimizer.helpPlan("select * from vm1.g9 where vm1.g9.e1='abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'", //$NON-NLS-1$
"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
@@ -220,17 +220,17 @@
/**
* pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
*/
- public void testPushingCriteriaThroughFrameAccessPattern1() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern1() {
TestOptimizer.helpPlan("select * from vm1.g1, vm1.g10 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g10.e1", FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), //$NON-NLS-1$
null, TestOptimizer.SHOULD_FAIL );
}
- public void testPushingCriteriaThroughFrameAccessPattern2() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern2() {
TestOptimizer.helpPlan("select e1 from vm1.g11 where vm1.g11.e1='abc' and vm1.g11.e2=123", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm4.g2.e1 FROM pm4.g2 WHERE (pm4.g2.e1 = 'abc') AND (pm4.g2.e2 = 123)" }); //$NON-NLS-1$
}
- public void testPushingCriteriaThroughFrameAccessPattern3() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern3() {
TestOptimizer.helpPlan("select * from vm1.g1, vm1.g9 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g9.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] {"SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'", //$NON-NLS-1$
"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
@@ -240,7 +240,7 @@
/**
* pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
*/
- public void testPushingCriteriaThroughFrameAccessPattern4() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern4() {
TestOptimizer.helpPlan("select * from vm1.g10 where vm1.g10.e1='abc'", FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), //$NON-NLS-1$
null, TestOptimizer.SHOULD_FAIL );
}
@@ -248,7 +248,7 @@
/**
* TODO: in this case we should perform a criteria optimization to create set criteria
*/
- public void testCase6425() {
+ @Test public void testCase6425() {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e1 = '2'"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -258,7 +258,7 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
- public void testCase6425_2() {
+ @Test public void testCase6425_2() {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR (e1 = '2' AND e2 = 3)"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -268,7 +268,7 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
- public void testCase6425_4() throws Exception {
+ @Test public void testCase6425_4() throws Exception {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e2 = '2'"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -279,7 +279,7 @@
/*
* Criteria was preventing rule choose dependent from creating the appropriate dependent join
*/
- public void testMultiAccessPatternWithCriteria() throws Exception {
+ @Test public void testMultiAccessPatternWithCriteria() throws Exception {
String sql = "SELECT pm1.g1.* FROM pm4.g1, pm5.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1 and pm5.g1.e1 = pm1.g1.e1 and pm5.g1.e2 like '%x' "; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -23,7 +23,6 @@
package com.metamatrix.query.optimizer;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -41,7 +40,6 @@
import com.metamatrix.query.processor.relational.RelationalNode;
import com.metamatrix.query.processor.relational.RelationalPlan;
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.GroupCollectorVisitor;
import com.metamatrix.query.unittest.FakeMetadataFacade;
@@ -137,13 +135,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestOptimizer.helpGetCommand("select pm1.g1.e1 from pm1.g1, pm2.g1 where pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(), Collections.EMPTY_LIST); //$NON-NLS-1$
-
- Option option = new Option();
- option.addDependentGroup("pm2.g1"); //$NON-NLS-1$
- command.setOption(option);
-
- ProcessorPlan plan = TestOptimizer.helpPlanCommand(command, FakeMetadataFactory.example1Cached(), capFinder,
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm2.g1 where pm1.g1.e1 = pm2.g1.e1 option makedep pm2.g1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm2.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
checkDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
@@ -173,11 +165,9 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestOptimizer.helpGetCommand("select pm1.g1.e1, pm2.g1.e1 from pm1.g1 MAKEDEP INNER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(), Collections.EMPTY_LIST); //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1, pm2.g1.e1 from pm1.g1 MAKEDEP INNER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm2.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- ProcessorPlan plan = TestOptimizer.helpPlanCommand(command, FakeMetadataFactory.example1Cached(), capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm2.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
checkNotDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, new int[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -22,44 +22,72 @@
package com.metamatrix.query.optimizer;
+import static com.metamatrix.query.optimizer.TestOptimizer.*;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
+import org.junit.Test;
+import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
-public class TestInlineView extends TestCase {
+public class TestInlineView {
+
+ public static FakeMetadataFacade createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
- public void testANSIJoinInlineView() throws Exception {
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ caps.setFunctionSupport("case", true); //$NON-NLS-1$
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ return metadata;
+ }
+
+ @Test public void testANSIJoinInlineView() throws Exception {
runTest(createANSIJoinInlineView());
}
- public void testInlineView() throws Exception {
+ @Test public void testInlineView() throws Exception {
runTest(createInlineView());
}
- public void testInlineViewWithDistinctAndOrderBy() throws Exception {
+ @Test public void testInlineViewWithDistinctAndOrderBy() throws Exception {
runTest(createInlineViewWithDistinctAndOrderBy());
}
- public void testInlineViewOfVirtual() throws Exception{
+ @Test public void testInlineViewOfVirtual() throws Exception{
runTest(createInlineViewOfVirtual());
}
- public void testInlineViewWithOuterOrderAndGroup() throws Exception {
+ @Test public void testInlineViewWithOuterOrderAndGroup() throws Exception {
runTest(createInlineViewWithOuterOrderAndGroup());
}
- public void testInlineViewsInUnions() throws Exception {
+ @Test public void testInlineViewsInUnions() throws Exception {
runTest(crateInlineViewsInUnions());
}
- public void testUnionInInlineView() throws Exception{
+ @Test public void testUnionInInlineView() throws Exception{
runTest(createUnionInInlineView());
}
@@ -83,8 +111,6 @@
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineView() throws Exception {
String userQuery = "select bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa from (select count(bqt1.smalla.intkey) as aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, bqt1.smallb " + //$NON-NLS-1$
@@ -106,8 +132,6 @@
return new InlineViewCase("testInlineView", userQuery, optimizedQuery, //$NON-NLS-1$
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineViewWithDistinctAndOrderBy() throws Exception {
String userQuery = "select Q1.a from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2"; //$NON-NLS-1$
@@ -130,7 +154,6 @@
}
-
public static InlineViewCase createInlineViewOfVirtual() throws Exception{
String userQuery = "select q1.A from (select count(intkey) as a, intkey, stringkey from vqt.smalla group by intkey, stringkey) q1 inner join vqt.smallb as q2 on q1.intkey = q2.a12345 where q1.a = 2"; //$NON-NLS-1$
String optimizedQuery = "SELECT v_0.c_1 FROM (SELECT g_0.IntKey AS c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey, g_0.StringKey HAVING COUNT(g_0.IntKey) = 2) AS v_0, BQT1.SmallA AS g_1 WHERE v_0.c_0 = Concat(g_1.StringKey, g_1.StringNum)"; //$NON-NLS-1$
@@ -147,8 +170,6 @@
return new InlineViewCase("testInlineViewOfVirtual", userQuery, optimizedQuery, //$NON-NLS-1$
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineViewWithOuterOrderAndGroup() throws Exception {
String userQuery = "select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b"; //$NON-NLS-1$
@@ -170,8 +191,6 @@
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase crateInlineViewsInUnions() throws Exception {
String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b)"; //$NON-NLS-1$
String optimizedQuery = "SELECT v_1.c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM bqt1.smalla AS g_2 WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN bqt1.smallb AS g_3 ON v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_0) AS c_0 FROM (SELECT DISTINCT COUNT(g_0.IntKey) AS c_0, g_0.IntKey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.IntKey HAVING ((COUNT(g_0.IntKey) + g_0.IntKey) = 2) AND (COUNT(g_0.IntKey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0"; //$NON-NLS-1$
@@ -196,8 +215,6 @@
}
-
-
public static InlineViewCase createUnionInInlineView() throws Exception{
String userQuery = "select t1.intkey from (select case when q1.a=1 then 2 else 1 end as a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b)) as q3, bqt1.smallb as t1 where q3.a = t1.intkey order by t1.intkey"; //$NON-NLS-1$
@@ -228,7 +245,7 @@
protected void runTest(InlineViewCase testCase) throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = TestOptimizer.createInlineViewMetadata(capFinder);
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
ProcessorPlan plan = TestOptimizer.helpPlan(testCase.userQuery, metadata, null, capFinder, new String[] {testCase.optimizedQuery}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -236,4 +253,60 @@
TestOptimizer.checkSubPlanCount(plan, 0);
}
+
+ @Test public void testAliasCreationWithInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select a, b from (select distinct count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ checkSubPlanCount(plan, 0);
+ }
+
+ @Test public void testAliasPreservationWithInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ checkSubPlanCount(plan, 0);
+ }
+
+ /**
+ * Order by's will be added to the atomic queries
+ */
+ @Test public void testCrossSourceInlineView() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select * from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a, bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey = q2.intkey where q1.a = 1", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ checkSubPlanCount(plan, 0);
+ }
+
}
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-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -28,7 +28,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -182,13 +181,13 @@
throw new MetaMatrixRuntimeException(err);
}
- return helpPlanCommand(command, md, capFinder, expectedAtomic, shouldSucceed ? ComparisonMode.CORRECTED_COMMAND_STRING : ComparisonMode.FAILED_PLANNING);
+ return helpPlanCommand(command, md, capFinder, null, expectedAtomic, shouldSucceed ? ComparisonMode.CORRECTED_COMMAND_STRING : ComparisonMode.FAILED_PLANNING);
}
public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, List bindings, CapabilitiesFinder capFinder, String[] expectedAtomic, ComparisonMode mode) throws QueryParserException, QueryResolverException, QueryValidatorException, MetaMatrixComponentException {
Command command = helpGetCommand(sql, md, bindings);
- return helpPlanCommand(command, md, capFinder, expectedAtomic, mode);
+ return helpPlanCommand(command, md, capFinder, null, expectedAtomic, mode);
}
@@ -218,13 +217,13 @@
return command;
}
- public static ProcessorPlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, String[] expectedAtomic, ComparisonMode mode) {
+ public static ProcessorPlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, String[] expectedAtomic, ComparisonMode mode) {
if (capFinder == null){
capFinder = getGenericFinder();
}
// Collect atomic queries
- ProcessorPlan plan = getPlan(command, md, capFinder, mode != ComparisonMode.FAILED_PLANNING);
+ ProcessorPlan plan = getPlan(command, md, capFinder, analysisRecord, mode != ComparisonMode.FAILED_PLANNING);
if (mode == ComparisonMode.CORRECTED_COMMAND_STRING) {
checkAtomicQueries(expectedAtomic, plan, md, capFinder);
@@ -237,14 +236,14 @@
public static void checkAtomicQueries(String[] expectedAtomic,
ProcessorPlan plan) {
- Set actualQueries = getAtomicQueries(plan);
+ Set<String> actualQueries = getAtomicQueries(plan);
if (actualQueries.size() != 1 || expectedAtomic.length != 1) {
// Compare atomic queries
HashSet<String> expectedQueries = new HashSet<String>(Arrays.asList(expectedAtomic));
assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$
} else {
- assertEquals("Did not get expected atomic query: ", expectedAtomic[0], (String)actualQueries.iterator().next()); //$NON-NLS-1$
+ assertEquals("Did not get expected atomic query: ", expectedAtomic[0], actualQueries.iterator().next()); //$NON-NLS-1$
}
}
@@ -274,10 +273,12 @@
assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$
}
- public static ProcessorPlan getPlan(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, boolean shouldSucceed) {
+ static ProcessorPlan getPlan(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, boolean shouldSucceed) {
// plan
ProcessorPlan plan = null;
- AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
+ if (analysisRecord == null) {
+ analysisRecord = new AnalysisRecord(false, false, DEBUG);
+ }
if (shouldSucceed) {
try {
//do planning
@@ -318,27 +319,22 @@
return plan;
}
- public static Set getAtomicQueries(ProcessorPlan plan) {
- Iterator atomicQueries = getAtomicCommands(plan).iterator();
+ public static Set<String> getAtomicQueries(ProcessorPlan plan) {
+ Set<Command> atomicQueries = new HashSet<Command>();
+ if(plan instanceof RelationalPlan) {
+ getAtomicCommands( ((RelationalPlan)plan).getRootNode(), atomicQueries );
+ }
- Set stringQueries = new HashSet();
+ Set<String> stringQueries = new HashSet<String>();
- while (atomicQueries.hasNext()) {
- stringQueries.add(atomicQueries.next().toString());
+ for (Command command : atomicQueries) {
+ stringQueries.add(command.toString());
}
return stringQueries;
}
- public static Set getAtomicCommands(ProcessorPlan plan) {
- Set atomicQueries = new HashSet();
- if(plan instanceof RelationalPlan) {
- getAtomicCommands( ((RelationalPlan)plan).getRootNode(), atomicQueries );
- }
- return atomicQueries;
- }
-
- private static void getAtomicCommands(RelationalNode node, Set atomicQueries) {
+ private static void getAtomicCommands(RelationalNode node, Set<Command> atomicQueries) {
if(node instanceof AccessNode) {
AccessNode accessNode = (AccessNode) node;
atomicQueries.add( accessNode.getCommand());
@@ -397,7 +393,7 @@
* @param relationalNode
* @return int[]
*/
- public static void collectCounts(RelationalNode relationalNode, int[] counts, Class<?>[] types) {
+ static void collectCounts(RelationalNode relationalNode, int[] counts, Class<?>[] types) {
Class<?> nodeType = relationalNode.getClass();
if(nodeType.equals(JoinNode.class)) {
JoinStrategy strategy = ((JoinNode)relationalNode).getJoinStrategy();
@@ -608,7 +604,7 @@
new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
List vm1g4e = FakeMetadataFactory.createElements(vm1g4,
- new String[] { "e1", "e1" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
List vm1g5e = FakeMetadataFactory.createElements(vm1g5,
new String[] { "e1" }, //$NON-NLS-1$
@@ -4262,8 +4258,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1", //$NON-NLS-1$
@@ -4282,8 +4277,7 @@
caps.setCapabilitySupport(Capability.QUERY_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE e1 WHEN 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", //$NON-NLS-1$
@@ -4318,8 +4312,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1", //$NON-NLS-1$
@@ -4338,8 +4331,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", //$NON-NLS-1$
@@ -4840,7 +4832,7 @@
ProcessorPlan subplan = (ProcessorPlan) subplans.iterator().next();
// Collect atomic queries
- Set actualQueries = getAtomicQueries(subplan);
+ Set<String> actualQueries = getAtomicQueries(subplan);
// Compare atomic queries
HashSet<String> expectedQueries = new HashSet<String>(Arrays.asList(new String[] { "SELECT bqt1.smalla.datevalue FROM bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smalla.intkey) AND (bqt1.smalla.stringkey = bqt1.smalla.stringkey)"})); //$NON-NLS-1$
@@ -5770,7 +5762,7 @@
ProcessorPlan plan = helpPlan(
"select a.e1, b.e1 from vm2.g1 a, vm2.g1 b where a.e1 = b.e1 and a.e2 in (select e2 from vm1.g1)", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT g_1.e1, g_3.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_1.e1 = g_3.e1) AND (g_1.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT g_0.e1, g_2.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_0.e1 = g_2.e1) AND (g_0.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -5851,72 +5843,7 @@
ComparisonMode.EXACT_COMMAND_STRING );
}
-
- public static FakeMetadataFacade createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- caps.setFunctionSupport("case", true); //$NON-NLS-1$
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- return metadata;
- }
- /**
- * Order by's will be added to the atomic queries
- */
- @Test public void testCrossSourceInlineView() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select * from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a, bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey = q2.intkey where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- checkSubPlanCount(plan, 0);
- }
-
- @Test public void testAliasPreservationWithInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
- }
-
//since this does not support convert, it should not be collapsed
@Test public void testBadCollapseUnion() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -5950,7 +5877,7 @@
}
@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$
+ ProcessorPlan plan = helpPlan("insert into vm1.g37 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] {} );
checkNodeTypes(plan, new int[] {
@@ -6655,19 +6582,7 @@
checkNodeTypes(plan, FULL_PUSHDOWN);
}
-
- @Test public void testAliasCreationWithInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
- ProcessorPlan plan = helpPlan("select a, b from (select distinct count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
- }
-
@Test public void testCase6364() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
@@ -6821,6 +6736,6 @@
TestOptimizer.SHOULD_SUCCEED);
}
- private static final boolean DEBUG = false;
+ public static final boolean DEBUG = false;
}
Added: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -0,0 +1,141 @@
+/*
+ * 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 static com.metamatrix.query.optimizer.TestOptimizer.*;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.analysis.QueryAnnotation;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.optimizer.TestOptimizer;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestMaterialization {
+
+ @Test public void testMaterializedTransformation() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ 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$
+ }
+
+ @Ignore("we no longer auto detect this case, if we need this logic it will have to be added to the rewriter since it changes select into to an insert")
+ @Test public void testMaterializedTransformationLoading() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ 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 testMaterializedTransformationNoCache() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ 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() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ 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() throws Exception {
+ String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testTableNoCacheDoesntCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -22,10 +22,13 @@
package com.metamatrix.query.optimizer.relational.rules;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Collection;
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.teiid.dqp.internal.process.TestPreparedStatement;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -51,31 +54,14 @@
/**
* Tests {@link RuleChooseAccessPattern}
*/
-public class TestRuleAccessPatternValidation extends TestCase {
+public class TestRuleAccessPatternValidation {
- private static final FakeMetadataFacade METADATA = FakeMetadataFactory.example1();
+ private static final FakeMetadataFacade METADATA = FakeMetadataFactory.example1Cached();
- private PlanHints planHints;
-
private static final boolean DEBUG = false;
- private static CapabilitiesFinder FINDER = new DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities());;
+ private static CapabilitiesFinder FINDER = new DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities());
- // ################################## FRAMEWORK ################################
-
- /**
- * Constructor for TestRuleChooseAccessPattern.
- */
- public TestRuleAccessPatternValidation(String name) {
- super(name);
- }
-
- public void setUp() {
- this.planHints = new PlanHints();
- }
-
- // ################################## TEST HELPERS ################################
-
/**
* @param command the query to be turned into a test query plan
* @param expectedChosenPredicates expected criteria predicates that should
@@ -112,7 +98,7 @@
p.initialize(query, null, METADATA, FINDER, null, null);
PlanNode planNode = p.generatePlan(query);
- final RuleStack rules = RelationalPlanner.buildRules(planHints);
+ final RuleStack rules = RelationalPlanner.buildRules(new PlanHints());
PlanNode testPlan = helpExecuteRules(rules, planNode, METADATA, DEBUG);
@@ -149,7 +135,7 @@
* This test demonstrates that APs are ignored for inserts
* CASE 3966
*/
- public void testInsertWithAccessPattern_Case3966() throws Exception {
+ @Test public void testInsertWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "insert into pm4.g1 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )" ); //$NON-NLS-1$
}
@@ -157,7 +143,7 @@
* This test demonstrates that a satisfied AP does not fail.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "delete from pm4.g1 where e1 = 'test' and e2 = 1" ); //$NON-NLS-1$
}
@@ -165,7 +151,7 @@
* This test demonstrates that unsatisfied AP fails.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966_2() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966_2() throws Exception {
try {
this.helpTestAccessPatternValidation( "delete from pm4.g1" ); //$NON-NLS-1$
fail("Expected QueryPlannerException, but did not get one"); //$NON-NLS-1$
@@ -177,7 +163,7 @@
}
}
- public void testUpdateWithAccessPattern_Case3966() throws Exception {
+ @Test public void testUpdateWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "update pm4.g1 set e1 = 'test1' where e1 = 'test' and e2 = 1" ); //$NON-NLS-1$
}
@@ -185,7 +171,7 @@
* This test demonstrates that unsatisfied AP fails.
* Found testing fix for 3966.
*/
- public void testUpdateWithAccessPattern_Case3966_2() throws Exception {
+ @Test public void testUpdateWithAccessPattern_Case3966_2() throws Exception {
try {
this.helpTestAccessPatternValidation( "update pm4.g1 set e1 = 'test'" ); //$NON-NLS-1$
fail("Expected QueryPlannerException, but did not get one"); //$NON-NLS-1$
@@ -201,7 +187,7 @@
* This test demonstrates that APs are ignored for inserts through a virtual layer
* CASE 3966
*/
- public void testInsertWithAccessPattern_Case3966_VL() throws Exception {
+ @Test public void testInsertWithAccessPattern_Case3966_VL() throws Exception {
this.helpTestAccessPatternValidation( "insert into vm1.g37 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )" ); //$NON-NLS-1$
}
@@ -210,7 +196,7 @@
* through a virtual layer does not fail.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966_VL() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966_VL() throws Exception {
this.helpTestAccessPatternValidation( "delete from vm1.g37 where e1 = 'test' and e2 = 1" ); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -71,7 +71,7 @@
/* Make Neither Side Dependent */
private static final int NEITHER_SIDE = 3;
- private FakeMetadataFacade metadata;
+ private FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
// ################################## FRAMEWORK ################################
@@ -79,15 +79,6 @@
super(name);
}
- public void setUp() {
- // set up resolver metadata
- metadata = FakeMetadataFactory.example1();
- }
-
- public void tearDown() {
- metadata = null;
- }
-
// ################################## TEST HELPERS ################################
public PlanNode createAccessNode(Collection groupSymbols) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -26,8 +26,6 @@
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
@@ -41,7 +39,7 @@
public class TestRulePlaceAccess extends TestCase {
- private static final QueryMetadataInterface METADATA = FakeMetadataFactory.example1();
+ private static final QueryMetadataInterface METADATA = FakeMetadataFactory.example1Cached();
// ################################## FRAMEWORK ################################
@@ -58,7 +56,7 @@
* Object element ids) for a physical group will be found and added
* as a property of an ACCESS node.
*/
- public void testAddAccessPatterns2(){
+ public void testAddAccessPatterns2() throws Exception {
Query query = new Query();
From from = new From();
@@ -70,31 +68,17 @@
select.addSymbol(new AllSymbol());
query.setSelect(select);
- try {
- group.setMetadataID(METADATA.getGroupID("pm4.g2")); //$NON-NLS-1$
- } catch (QueryMetadataException e) {
- fail(e.getMessage());
- } catch (MetaMatrixComponentException e) {
- fail(e.getMessage());
- }
+ group.setMetadataID(METADATA.getGroupID("pm4.g2")); //$NON-NLS-1$
PlanNode n1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
n1.setProperty(NodeConstants.Info.ATOMIC_REQUEST, query);
n1.addGroup(group);
- try {
- RulePlaceAccess.addAccessPatternsProperty(n1, METADATA);
- } catch (QueryMetadataException e) {
- fail(e.getMessage());
- } catch (MetaMatrixComponentException e) {
- fail(e.getMessage());
- }
+ RulePlaceAccess.addAccessPatternsProperty(n1, METADATA);
Collection accessPatterns = (Collection)n1.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
assertNotNull(accessPatterns);
assertTrue("Expected two access patterns, got " + accessPatterns.size(), accessPatterns.size() == 2); //$NON-NLS-1$
-// assertTrue(accessPatterns.contains(FakeMetadata.ELEMENT_IDS_1));
-// assertTrue(accessPatterns.contains(FakeMetadata.ELEMENT_IDS_2));
}
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-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -32,6 +32,9 @@
import org.junit.Test;
import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import com.metamatrix.query.optimizer.relational.RelationalPlanner;
@@ -46,7 +49,6 @@
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.util.CommandContext;
@@ -65,7 +67,7 @@
}
@Test public void testPushAcrossFrameWithAccessNode() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ QueryMetadataInterface metadata = new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore());
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$
RelationalPlanner p = new RelationalPlanner();
@@ -74,7 +76,7 @@
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)));
+ sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(), (List<SingleElementSymbol>)child.getFirstChild().getProperty(Info.PROJECT_COLS), metadata));
//add a dummy access node
PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
accessNode.addGroups(child.getFirstChild().getGroups());
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -642,7 +642,7 @@
// Slightly modify metadata to set max set size to just a few rows - this
// will allow us to test the dependent overflow case
- FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -711,8 +711,6 @@
capFinder.addCapabilities("pm4", depcaps); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Slightly modify metadata to set max set size to just a few rows - this
- // will allow us to test the dependent overflow case
FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
Command command = TestProcessor.helpParse(sql);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -100,7 +100,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
@@ -259,7 +259,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
@@ -340,7 +340,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
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-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -481,9 +481,8 @@
} );
- } catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -505,9 +504,8 @@
new List[] {
Arrays.asList(new Object[] { new Integer(1) }),
} );
- }catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -1990,7 +1988,7 @@
sampleData1(dataManager);
// Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1());
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
// Run query
helpProcess(plan, dataManager, expected);
@@ -3915,7 +3913,7 @@
sampleData1(dataManager);
// Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1());
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
// Run query
helpProcess(plan, dataManager, expected);
@@ -6515,7 +6513,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -237,7 +237,7 @@
QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g1 = createUpdatableVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
- QueryNode vm2g1n1 = new QueryNode("vm2.g1", "SELECT * FROM pm1.g1, pm1.g2 where pm1.g1.e2 = pm1.g2.e2"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm2g1n1 = new QueryNode("vm2.g1", "SELECT pm1.g1.* FROM pm1.g1, pm1.g2 where pm1.g1.e2 = pm1.g2.e2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm2g1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm2.g1", vm2, vm2g1n1); //$NON-NLS-1$
QueryNode vm1g1n1_defect10711 = new QueryNode("vm1.g1a", "SELECT * FROM vm1.g1 as X"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -405,8 +405,8 @@
new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
List vm1g11e = createElements(vm1g11,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ new String[] { "e1", "e2", "e3", "e4", "e5", "e6"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
List vm1g12e = createElements(vm1g12,
new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
@@ -480,8 +480,8 @@
new String[] { "ve1", "ve2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
List vm1g37e = createElements(vm1g37,
- new String[] { "e1", "e2", "e3", "e4", "e5" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.DOUBLE });
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
List vm1g38e = createElements(vm1g38,
new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
@@ -1008,7 +1008,7 @@
FakeMetadataObject vgvp6e4 = FakeMetadataFactory.createElement("vm1.vgvp6.ve4", vgvp6, DataTypeManager.DefaultDataTypes.INTEGER, 3); //$NON-NLS-1$
//virtual group with two elements. One selectable, one not.
- QueryNode vm1g35n1 = new QueryNode("vm1.g35", "SELECT e2 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm1g35n1 = new QueryNode("vm1.g35", "SELECT e1, e2 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g35 = createVirtualGroup("vm1.g35", vm1, vm1g35n1); //$NON-NLS-1$
FakeMetadataObject vm1g35e1 = FakeMetadataFactory.createElement("vm1.g35.e1", vm1g35, DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
vm1g35e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
@@ -2007,7 +2007,7 @@
QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM vm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g1 = createUpdatableVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
- QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g2 = createUpdatableVirtualGroup("vm1.g2", vm1, vm1g2n1); //$NON-NLS-1$
// Create virtual elements
@@ -2016,9 +2016,9 @@
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE },
new Object[] { "xyz", Integer.getInteger("123"), Boolean.valueOf("true"), Double.valueOf("123.456")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
List vm1g2e = createElementsWithDefaults(vm1g2,
- new String[] { "e1", "e2", "e3" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN },
- new Object[] { "abc", Integer.getInteger("456"), Boolean.valueOf("false")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE },
+ new Object[] { "abc", Integer.getInteger("456"), Boolean.valueOf("false"), null}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vm1g1.putProperty(procedureType, procedure1);
vm1g2.putProperty(procedureType, procedure2);
@@ -3302,12 +3302,22 @@
new String[] { "e1" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING});
+ FakeMetadataObject physGroup1 = createPhysicalGroup("MatTable.MatTable1", physModel); //$NON-NLS-1$
+ List physElements1 = createElements(physGroup,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING});
+
+ FakeMetadataObject physGroupStage1 = createPhysicalGroup("MatTable.MatStage1", physModel); //$NON-NLS-1$
+ List physStageElements1 = createElements(physGroupStage,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING});
+
FakeMetadataObject physGroup_virtSrc = createPhysicalGroup("MatSrc.MatSrc", physModel_virtSrc); //$NON-NLS-1$
List physElements_virtSrc = createElements(physGroup_virtSrc,
new String[] { "X" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING});
- QueryNode virtTrans = new QueryNode("MatView.MatView", "SELECT x FROM MatSrc.MatSrc"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode virtTrans = new QueryNode("MatView.MatView", "SELECT x as e1 FROM MatSrc.MatSrc"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject virtGroup = createVirtualGroup("MatView.MatView", virtModel, virtTrans); //$NON-NLS-1$
List virtElements = createElements(virtGroup,
new String[] { "e1" }, //$NON-NLS-1$
@@ -3323,6 +3333,15 @@
new String[] { "e1" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING});
+ QueryNode virtTrans1 = new QueryNode("MatView.MatView1", "SELECT e1 FROM MatView.MatView where e1 = 1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject virtGroup1 = createVirtualGroup("MatView.MatView1", virtModel, virtTrans1); //$NON-NLS-1$
+ List virtElements1 = createElements(virtGroup1,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING});
+
+ virtGroup1.putProperty(FakeMetadataObject.Props.MAT_GROUP, physGroup1);
+ virtGroup1.putProperty(FakeMetadataObject.Props.MAT_STAGE, physGroupStage1);
+
FakeMetadataStore store = new FakeMetadataStore();
store.addObject(virtModel);
store.addObject(physModel);
@@ -3331,13 +3350,18 @@
store.addObjects(physElements);
store.addObject(physGroupStage);
store.addObjects(physStageElements);
+ store.addObject(physGroup1);
+ store.addObjects(physElements1);
+ store.addObject(physGroupStage1);
+ store.addObjects(physStageElements1);
store.addObject(physGroup_virtSrc);
store.addObjects(physElements_virtSrc);
store.addObject(virtGroup);
store.addObjects(virtElements);
store.addObject(vGroup);
store.addObjects(vElements);
-
+ store.addObject(virtGroup1);
+ store.addObjects(virtElements1);
return new FakeMetadataFacade(store);
}
16 years, 4 months
teiid SVN: r1655 - in trunk/engine/src: test/java/com/metamatrix/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-11 17:59:31 -0500 (Fri, 11 Dec 2009)
New Revision: 1655
Modified:
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
Log:
TEIID-904 fix for procedure relational failing even though there are no parameters
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-11 22:49:47 UTC (rev 1654)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2009-12-11 22:59:31 UTC (rev 1655)
@@ -378,14 +378,15 @@
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));
+ if (!accessPatternElementNames.isEmpty()) {
+ List<TempMetadataID> accessPatternIds = new LinkedList<TempMetadataID>();
+
+ for (String name : accessPatternElementNames) {
+ accessPatternIds.add(metadata.getMetadataStore().getTempElementID(name));
+ }
+
+ id.setAccessPatterns(Arrays.asList(new TempMetadataID("procedure access pattern", accessPatternIds))); //$NON-NLS-1$
}
-
- id.setAccessPatterns(Arrays.asList(new TempMetadataID("procedure access pattern", accessPatternIds))); //$NON-NLS-1$
}
group.setMetadataID(id);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2009-12-11 22:49:47 UTC (rev 1654)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2009-12-11 22:59:31 UTC (rev 1655)
@@ -738,4 +738,20 @@
}
+ @Test public void testProcRelationalWithNoInputs() {
+ String sql = "select e1 from pm1.vsp2 order by e1 desc limit 1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList("c") //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
}
16 years, 4 months
teiid SVN: r1654 - in trunk/engine/src: test/java/com/metamatrix/query/sql/proc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-11 17:49:47 -0500 (Fri, 11 Dec 2009)
New Revision: 1654
Modified:
trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java
trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java
Log:
TEIID-905 fix for block clone
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java 2009-12-11 22:46:42 UTC (rev 1653)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java 2009-12-11 22:49:47 UTC (rev 1654)
@@ -22,26 +22,28 @@
package com.metamatrix.query.sql.proc;
-import java.util.*;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
import com.metamatrix.core.util.EquivalenceUtil;
+import com.metamatrix.query.sql.LanguageObject;
+import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
/**
* <p> This class represents a group of <code>Statement</code> objects. The
* statements are stored on this object in the order in which they are added.</p>
*/
-public class Block implements LanguageObject {
+public class Block implements LanguageObject {
// list of statements on this block
- private List statements;
+ private List<Statement> statements;
/**
* Constructor for Block.
*/
public Block() {
- statements = new ArrayList();
+ statements = new ArrayList<Statement>();
}
/**
@@ -57,7 +59,7 @@
* Get all the statements contained on this block.
* @return A list of <code>Statement</code>s contained in this block
*/
- public List getStatements() {
+ public List<Statement> getStatements() {
return statements;
}
@@ -65,7 +67,7 @@
* Set the statements contained on this block.
* @param statements A list of <code>Statement</code>s contained in this block
*/
- public void setStatements(List statements) {
+ public void setStatements(List<Statement> statements) {
this.statements = statements;
}
@@ -91,11 +93,8 @@
*/
public Object clone() {
Block copy = new Block();
- if(!statements.isEmpty()) {
- Iterator stmtIter = statements.iterator();
- while(stmtIter.hasNext()) {
- copy.addStatement((Statement) stmtIter.next());
- }
+ for (Statement statement : statements) {
+ copy.addStatement((Statement)statement.clone());
}
return copy;
}
@@ -129,18 +128,7 @@
* @return Hash code
*/
public int hashCode() {
- // For speed, this hash code relies only on the hash codes of its select
- // and criteria clauses, not on the from, order by, or option clauses
- int myHash = 0;
-
- myHash = HashCodeUtil.hashCode(myHash, this.getStatements());
- if(!this.getStatements().isEmpty()) {
- Iterator stmtIter = this.getStatements().iterator();
- while(stmtIter.hasNext()) {
- myHash = HashCodeUtil.hashCode(myHash, stmtIter.next());
- }
- }
- return myHash;
+ return statements.hashCode();
}
/**
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java 2009-12-11 22:46:42 UTC (rev 1653)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java 2009-12-11 22:49:47 UTC (rev 1654)
@@ -60,13 +60,13 @@
public void testGetStatements1() {
Block b1 = sample1();
- List stmts = b1.getStatements();
+ List<Statement> stmts = b1.getStatements();
assertTrue("Incorrect number of statements in the Block", (stmts.size() == 4)); //$NON-NLS-1$
}
public void testGetStatements2() {
Block b1 = sample1();
- Statement stmt = (Statement) b1.getStatements().get(1);
+ Statement stmt = b1.getStatements().get(1);
assertTrue("Incorrect statement in the Block", stmt.equals(TestCommandStatement.sample1())); //$NON-NLS-1$
}
@@ -79,7 +79,7 @@
public void testaddStatement2() {
Block b1 = (Block) sample2().clone();
b1.addStatement(TestCommandStatement.sample2());
- Statement stmt = (Statement) b1.getStatements().get(4);
+ Statement stmt = b1.getStatements().get(4);
assertTrue("Incorrect statement in the Block", stmt.equals(TestCommandStatement.sample2())); //$NON-NLS-1$
}
@@ -102,5 +102,12 @@
int equals = -1;
UnitTestUtil.helpTestEquivalence(equals, b1, b2);
}
+
+ public void testClone() {
+ Block b1 = sample1();
+ Block b2 = (Block)b1.clone();
+ UnitTestUtil.helpTestEquivalence(0, b1, b2);
+ assertNotSame(b1.getStatements().get(0), b2.getStatements().get(0));
+ }
}
16 years, 4 months
teiid SVN: r1653 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/query.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-11 17:46:42 -0500 (Fri, 11 Dec 2009)
New Revision: 1653
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
Log:
Teiid 781 - changes to support running from hudson
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-12-11 22:46:22 UTC (rev 1652)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-12-11 22:46:42 UTC (rev 1653)
@@ -55,6 +55,8 @@
protected int queryTimeout = -1;
protected ConnectionStrategy connStrategy;
+
+ private Throwable applicationException=null;
public AbstractQueryTransactionTest() {
super();
@@ -156,6 +158,7 @@
@Override
public void setup() throws QueryTestFailedException {
+ this.applicationException = null;
this.setConnection(connStrategy.getConnection());
setupDataStore();
@@ -272,6 +275,30 @@
@Override
public XAConnection getXAConnection() {
return null;
+
}
+ @Override
+ public void setApplicationException(Throwable t) {
+ this.applicationException = t;
+
+ }
+
+ @Override
+ public boolean exceptionOccurred() {
+ return (super.exceptionOccurred() ? super.exceptionOccurred() : this.applicationException != null);
+
+ }
+
+ @Override
+ public Throwable getApplicationException() {
+ // TODO Auto-generated method stub
+ return this.applicationException;
+ }
+
+
+
+
+
+
}
16 years, 4 months
teiid SVN: r1652 - in trunk/test-integration/db/src/main/java/org/teiid/test: client/ctc and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-11 17:46:22 -0500 (Fri, 11 Dec 2009)
New Revision: 1652
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
Log:
Teiid 781 - changes to support running from hudson
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -103,89 +103,10 @@
}
-// private void testScenarios() throws Exception {
-//
-//
-//// String teiid_home = deployProperties.getProperty("teiid.home");
-//// File f = new File(teiid_home);
-//// if (f.exists() && f.isDirectory()) {
-//// FileUtils.removeDirectoryAndChildren(f);
-//// }
-//
-// this.overrides = getSubstitutedProperties(ConfigPropertyLoader.getInstance().getProperties());
-//
-// ConfigPropertyLoader.getInstance().setProperties(this.overrides);
-//
-// String scenaios_dir = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_DIR);
-// if (scenaios_dir == null) {
-// throw new TransactionRuntimeException("scenariodir property was not defined");
-// }
-//
-// File files[] = FileUtils.findAllFilesInDirectoryHavingExtension(scenaios_dir,
-// ".properties");
-// if (files == null || files.length == 0)
-// throw new QueryTestFailedException((new StringBuilder()).append(
-// "No scenario files found in directory ").append(scenaios_dir)
-// .toString());
-//
-//
-// // List<String> queryFiles = new ArrayList<String>(files.length);
-// for (int i = 0; i < files.length; i++) {
-// // overrides need to be reset because all overrides are cleared out after each query set
-// ConfigPropertyLoader.getInstance().setProperties(overrides);
-//
-// runTest(files[i]);
-// }
-//
-//
-// }
-// private void runScenariox() throws Exception {
-// String scenario_file = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_FILE);
-// if (scenario_file == null) {
-// throw new TransactionRuntimeException(TestProperties.PROP_SCENARIO_FILE + " property was not defined");
-// }
-//
-// Properties sc_props = PropertiesUtils.load(scenario_file);
-// Properties sc_updates = getSubstitutedProperties(sc_props);
-// if (!sc_updates.isEmpty()) {
-// sc_props.putAll(sc_props);
-// }
-//
-// String scenario_name = FileUtils.getBaseFileNameWithoutExtension(scenario_file);
-//
-// TestLogger.log("Starting scenario " + scenario_name);
-//
-// this.overrides = getSubstitutedProperties(ConfigPropertyLoader.getInstance().getProperties());
-//
-//
-// // update the URL with the vdb that is to be used
-// String url = ConfigPropertyLoader.getInstance().getProperty(DriverConnection.DS_URL);
-// String vdb_name = ConfigPropertyLoader.getInstance().getProperty(DataSourceConnection.DS_DATABASENAME);
-//
-// Assert.assertNotNull(DataSourceConnection.DS_DATABASENAME + " property not set, need it for the vdb name", vdb_name);
-// url = StringUtil.replace(url, "${vdb}", vdb_name);
-//
-// this.overrides.setProperty(DriverConnection.DS_URL, url);
-//
-// ConfigPropertyLoader.getInstance().setProperties(this.overrides);
-//
-// QueryScenario set = new CTCQueryScenario(scenario_name, ConfigPropertyLoader.getInstance().getProperties());
-//
-// TransactionContainer tc = getTransactionContainter();
-//
-// runTestCase(set, tc);
-//
-// TestLogger.log("Completed scenario " + scenario_name);
-//
-//
-// }
-
-
private void runScenario() throws Exception {
-
String scenario_file = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_FILE);
if (scenario_file == null) {
throw new TransactionRuntimeException(TestProperties.PROP_SCENARIO_FILE + " property was not defined");
@@ -273,8 +194,8 @@
userTxn.init(querySetID, queryidentifier, sqlObject);
// run test
-
tc.runTransaction(userTxn);
+
testResults.add(userTxn.getTestResult());
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -56,8 +56,6 @@
private TestResult rs = null;
private boolean errorExpected = false;
-
- private Throwable resultException = null;
private String sql = null;
@@ -81,7 +79,6 @@
rs = null;
errorExpected = false;
- resultException = null;
}
@@ -125,7 +122,7 @@
TestLogger.logDebug("expected error: " + this.errorExpected);
try {
- System.out.println("QueryID: " + this.querySetID + ":"
+ System.out.println(this.querySet.getQueryScenarioIdentifier() + ":" + this.querySetID + ":"
+ this.queryIdentifier);
// need to set this so the underlying query execution handles an
// error properly.
@@ -134,9 +131,8 @@
execute(sql);
} catch (Throwable t) {
+ this.setApplicationException(t);
- resultException = t;
-
} finally {
// Capture resp time
endTS = System.currentTimeMillis();
@@ -156,19 +152,26 @@
// this.internalResultSet;
ResultsGenerator genResults = this.querySet.getResultsGenerator();
+
+ Throwable resultException = null;
resultException = (this.getLastException() != null ? this
- .getLastException() : resultException);
+ .getLastException() : this.getApplicationException());
+
+
if (resultException != null) {
- if (this.exceptionExpected()) {
- testStatus = TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION;
- } else {
- testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
- }
+ if (this.exceptionExpected()) {
+ testStatus = TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION;
+ } else {
+ testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
+ }
}
+
+
+
if (this.querySet.getResultsMode().equalsIgnoreCase(
TestProperties.RESULT_MODES.COMPARE)) {
if (testStatus != TestResult.RESULT_STATE.TEST_EXCEPTION) {
@@ -272,4 +275,7 @@
}
+
+
+
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -162,7 +162,7 @@
if (!expectedResults.isException()) {
// The actual exception was expected, but the expected results was not
- throw new QueryTestFailedException(eMsg + "TThe actual exception was expected, but the Expected results wasn't an exception. Actual exception: '" //$NON-NLS-1$
+ throw new QueryTestFailedException(eMsg + "The actual result was an exception, but the Expected results wasn't an exception. Actual exception: '" //$NON-NLS-1$
+ actualException.getMessage() + "'"); //$NON-NLS-1$
}
// We got an exception that we expected - convert actual exception to ResultsHolder
@@ -198,7 +198,11 @@
compareExceptions(actualResults, expectedResults, eMsg);
+ } else if (expectedResults.isException()) {
+ throw new QueryTestFailedException(eMsg + "The Expected result was an exception, but the Actual results wasn't an exception. Expected exception: '" //$NON-NLS-1$
+ + expectedResults.getExceptionMsg() + "'"); //$NON-NLS-1$
+
} else {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -64,7 +64,6 @@
protected void runTest(TransactionQueryTestCase test) {
debug("Start runTest: " + test.getTestName());
- try {
debug(" before(test)");
@@ -74,10 +73,32 @@
test.before();
debug(" test.testcase");
+
+ try {
+
// run the test
test.testCase();
+
+ } catch (Throwable e) {
+ if (!test.exceptionExpected()) {
+ e.printStackTrace();
+ debug("Error: " + e.getMessage());
+ test.setApplicationException(e);
+
+ }
+ }
+
+ if (test.exceptionExpected() && !test.exceptionOccurred()) {
+ TransactionRuntimeException t = new TransactionRuntimeException(
+ "Expected exception, but one did not occur for test: "
+ + this.getClass().getName() + "."
+ + test.getTestName());
+ test.setApplicationException(t);
+ }
+
+
debug(" test.after");
test.after();
@@ -87,25 +108,9 @@
debug("End runTest: " + test.getTestName());
- } catch (TransactionRuntimeException tre) {
- throw tre;
- } catch (Throwable e) {
- if (!test.exceptionExpected()) {
- e.printStackTrace();
- debug("Error: " + e.getMessage());
- throw new TransactionRuntimeException(e.getMessage());
- }
- }
- if (test.exceptionExpected() && !test.exceptionOccurred()) {
- throw new TransactionRuntimeException(
- "Expected exception, but one did not occur for test: "
- + this.getClass().getName() + "."
- + test.getTestName());
- }
-
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -135,15 +135,6 @@
void setConnection(Connection conn);
/**
- * Called to set the properties used to initialize prior to execution.
- *
- * @param props
- *
- * @since
- */
-// void setExecutionProperties(Properties props);
-
- /**
* Override <code>before</code> if there is behavior that needs to be
* performed prior to {@link #testCase()} being called.
*
@@ -203,5 +194,9 @@
boolean exceptionExpected();
boolean exceptionOccurred();
+
+ void setApplicationException(Throwable t);
+
+ Throwable getApplicationException();
}
16 years, 4 months
teiid SVN: r1651 - trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors.
by teiid-commits@lists.jboss.org
Author: jdoyle
Date: 2009-12-11 15:52:34 -0500 (Fri, 11 Dec 2009)
New Revision: 1651
Modified:
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java
Log:
TEIID-896
INSERT failing with SF connector on types other than a string
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2009-12-11 19:59:37 UTC (rev 1650)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2009-12-11 20:52:34 UTC (rev 1651)
@@ -64,7 +64,7 @@
String val;
if(value instanceof ILiteral) {
ILiteral literalValue = (ILiteral)value;
- val = this.stripQutes((String)literalValue.getValue());
+ val = this.stripQutes(literalValue.getValue().toString());
} else {
val = value.toString();
}
16 years, 4 months
teiid SVN: r1650 - in trunk/connectors/connector-salesforce/src: main/java/com/metamatrix/connector/salesforce/connection and 4 other directories.
by teiid-commits@lists.jboss.org
Author: jdoyle
Date: 2009-12-11 14:59:37 -0500 (Fri, 11 Dec 2009)
New Revision: 1650
Added:
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/AbstractUpdateExecution.java
Removed:
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java
Modified:
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Constants.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java
trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java
Log:
TEIID-180
Consider using Salesforce retrieve() rather than generic query() call for queries with IN criteria
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Constants.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Constants.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Constants.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -45,5 +45,7 @@
public static final String RESTRICTED_MULTISELECT_PICKLIST_TYPE = "restrictedmultiselectpicklist"; //$NON-NLS-1$
public static final String SUPPORTS_QUERY = "Supports Query";
+
+ public static final String SUPPORTS_RETRIEVE = "Supports Retrieve";
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -40,12 +40,15 @@
import com.metamatrix.connector.salesforce.Messages;
import com.metamatrix.connector.salesforce.connection.impl.ConnectionImpl;
import com.metamatrix.connector.salesforce.execution.DataPayload;
+import com.metamatrix.connector.salesforce.execution.DeleteExecutionImpl;
import com.metamatrix.connector.salesforce.execution.DeletedResult;
+import com.metamatrix.connector.salesforce.execution.InsertExecutionImpl;
import com.metamatrix.connector.salesforce.execution.ProcedureExecutionParentImpl;
import com.metamatrix.connector.salesforce.execution.QueryExecutionImpl;
-import com.metamatrix.connector.salesforce.execution.UpdateExecutionParent;
+import com.metamatrix.connector.salesforce.execution.UpdateExecutionImpl;
import com.metamatrix.connector.salesforce.execution.UpdatedResult;
import com.sforce.soap.partner.QueryResult;
+import com.sforce.soap.partner.sobject.SObject;
public class SalesforceConnection extends BasicConnection {
@@ -99,7 +102,15 @@
public UpdateExecution createUpdateExecution(ICommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new UpdateExecutionParent(command, this, metadata, executionContext, connectorEnv);
+ UpdateExecution result = null;
+ if(command instanceof org.teiid.connector.language.IDelete) {
+ result = new DeleteExecutionImpl(command, this, metadata, executionContext, connectorEnv);
+ } else if (command instanceof org.teiid.connector.language.IInsert) {
+ result = new InsertExecutionImpl(command, this, metadata, executionContext, connectorEnv);
+ } else if (command instanceof org.teiid.connector.language.IUpdate) {
+ result = new UpdateExecutionImpl(command, this, metadata, executionContext, connectorEnv);
+ }
+ return result;
}
@@ -158,4 +169,11 @@
Calendar endCalendar) throws ConnectorException {
return connection.getDeleted(objectName, startCalendar, endCalendar);
}
+
+ public QueryResult retrieve(String fieldList, String sObjectType, String[] ids) throws ConnectorException {
+ SObject[] objects = connection.retrieve(fieldList, sObjectType, ids);
+ QueryResult result = new QueryResult(true, "teiid_created_result",
+ objects, objects.length);
+ return result;
+ }
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -330,4 +330,14 @@
throw new ConnectorException(e, e.getMessage());
}
}
+
+ public SObject[] retrieve(String fieldList, String sObjectType, String[] ids) throws ConnectorException {
+ try {
+ return binding.retrieve(fieldList, sObjectType, ids);
+ } catch (ApiFault e) {
+ throw new ConnectorException(e.getMessage());
+ } catch (RemoteException e) {
+ throw new ConnectorException(e, e.getMessage());
+ }
+ }
}
Copied: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/AbstractUpdateExecution.java (from rev 1625, trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java)
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/AbstractUpdateExecution.java (rev 0)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/AbstractUpdateExecution.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.salesforce.execution;
+
+import java.util.ArrayList;
+
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.DataNotAvailableException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.api.UpdateExecution;
+import org.teiid.connector.basic.BasicExecution;
+import org.teiid.connector.language.ICommand;
+import org.teiid.connector.language.ICompareCriteria;
+import org.teiid.connector.language.ICriteria;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+
+import com.metamatrix.connector.salesforce.Util;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
+import com.metamatrix.connector.salesforce.execution.visitors.IQueryProvidingVisitor;
+import com.sforce.soap.partner.QueryResult;
+import com.sforce.soap.partner.sobject.SObject;
+
+/**
+ *
+ * Parent class to the Update, Delete, and Insert execution classes.
+ * Provisions the correct impl and contains some common code to
+ * get IDs of Salesforce objects.
+ *
+ */
+public abstract class AbstractUpdateExecution extends BasicExecution implements UpdateExecution {
+
+ protected SalesforceConnection connection;
+ protected RuntimeMetadata metadata;
+ protected ExecutionContext context;
+ protected ConnectorEnvironment connectorEnv;
+ protected ICommand command;
+ protected int result;
+
+ public AbstractUpdateExecution(ICommand command, SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context,
+ ConnectorEnvironment connectorEnv) {
+ this.connection = salesforceConnection;
+ this.metadata = metadata;
+ this.context = context;
+ this.connectorEnv = connectorEnv;
+ this.command = command;
+ }
+
+ @Override
+ public void cancel() throws ConnectorException {
+ }
+
+ @Override
+ public void close() throws ConnectorException {
+ }
+
+ @Override
+ public int[] getUpdateCounts() throws DataNotAvailableException,
+ ConnectorException {
+ return new int[] {result};
+ }
+
+ public RuntimeMetadata getMetadata() {
+ return metadata;
+ }
+
+ public ConnectorEnvironment getConnectorEnv() {
+ return connectorEnv;
+ }
+
+ public SalesforceConnection getConnection() {
+ return connection;
+ }
+
+ String[] getIDs(ICriteria criteria, IQueryProvidingVisitor visitor) throws ConnectorException {
+ String[] Ids = null;
+ if (visitor.hasOnlyIDCriteria()) {
+ try {
+ String Id = ((ICompareCriteria)criteria).getRightExpression().toString();
+ Id = Util.stripQutes(Id);
+ Ids = new String[] { Id };
+ } catch (ClassCastException cce) {
+ throw new RuntimeException(
+ "Error: The delete criteria is not a CompareCriteria");
+ }
+
+ } else if (visitor.hasCriteria()) {
+ String query = visitor.getQuery();
+ QueryResult results = getConnection().query(query, context.getBatchSize(), Boolean.FALSE);
+ if (null != results && results.getSize() > 0) {
+ ArrayList<String> idList = new ArrayList<String>(results
+ .getRecords().length);
+ for (int i = 0; i < results.getRecords().length; i++) {
+ SObject sObject = results.getRecords(i);
+ idList.add(sObject.getId());
+ }
+ Ids = idList.toArray(new String[0]);
+ }
+ }
+ return Ids;
+ }
+}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -21,22 +21,33 @@
*/
package com.metamatrix.connector.salesforce.execution;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IDelete;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
import com.metamatrix.connector.salesforce.execution.visitors.DeleteVisitor;
-public class DeleteExecutionImpl {
+public class DeleteExecutionImpl extends AbstractUpdateExecution {
- public int execute(IDelete delete, UpdateExecutionParent parent) throws ConnectorException {
-
- int result = 0;
- DeleteVisitor dVisitor = new DeleteVisitor(parent.getMetadata());
- dVisitor.visitNode(delete);
- String[] Ids = parent.getIDs(delete.getCriteria(), dVisitor);
+
+ public DeleteExecutionImpl(ICommand command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context,
+ ConnectorEnvironment connectorEnv) {
+ super(command, salesforceConnection, metadata, context, connectorEnv);
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ DeleteVisitor dVisitor = new DeleteVisitor(getMetadata());
+ dVisitor.visitNode(command);
+ String[] Ids = getIDs(((IDelete)command).getCriteria(), dVisitor);
if(null != Ids && Ids.length > 0) {
- result = parent.getConnection().delete(Ids);
+ result = getConnection().delete(Ids);
}
- return result;
}
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -22,21 +22,32 @@
package com.metamatrix.connector.salesforce.execution;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IInsert;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
import com.metamatrix.connector.salesforce.execution.visitors.InsertVisitor;
-public class InsertExecutionImpl {
+public class InsertExecutionImpl extends AbstractUpdateExecution {
- public int execute(IInsert insert,
- UpdateExecutionParent salesforceUpdateExecution) throws ConnectorException {
-
- InsertVisitor visitor = new InsertVisitor(salesforceUpdateExecution.getMetadata());
- visitor.visit(insert);
+ public InsertExecutionImpl(ICommand command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context,
+ ConnectorEnvironment connectorEnv) {
+ super(command, salesforceConnection, metadata, context, connectorEnv);
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ InsertVisitor visitor = new InsertVisitor(getMetadata());
+ visitor.visit((IInsert)command);
DataPayload data = new DataPayload();
data.setType(visitor.getTableName());
data.setMessageElements(visitor.getMessageElements());
- return salesforceUpdateExecution.getConnection().create(data);
+ result = getConnection().create(data);
}
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -118,18 +118,28 @@
connectorEnv.getLogger().logInfo(
getLogPreamble() + "Incoming Query: " + query.toString());
IFrom from = ((IQuery)query).getFrom();
+ String finalQuery;
if(from.getItems().get(0) instanceof IJoin) {
visitor = new JoinQueryVisitor(metadata);
+ visitor.visitNode(query);
+ finalQuery = visitor.getQuery().trim();
+ connectorEnv.getLogger().logInfo(
+ getLogPreamble() + "Executing Query: " + finalQuery);
+
+ results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
} else {
visitor = new SelectVisitor(metadata);
+ visitor.visitNode(query);
+ if(visitor.canRetrieve()) {
+ results = connection.retrieve(visitor.getRetrieveFieldList(),
+ visitor.getTableName(), visitor.getIdInCriteria());
+ } else {
+ finalQuery = visitor.getQuery().trim();
+ connectorEnv.getLogger().logInfo(
+ getLogPreamble() + "Executing Query: " + finalQuery);
+ results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
+ }
}
- visitor.visitNode(query);
- String finalQuery;
- finalQuery = visitor.getQuery().trim();
- connectorEnv.getLogger().logInfo(
- getLogPreamble() + "Executing Query: " + finalQuery);
-
- results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
}
@SuppressWarnings("unchecked")
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -27,29 +27,39 @@
import javax.xml.namespace.QName;
import org.apache.axis.message.MessageElement;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IElement;
import org.teiid.connector.language.ILiteral;
import org.teiid.connector.language.ISetClause;
import org.teiid.connector.language.IUpdate;
import org.teiid.connector.metadata.runtime.Element;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.salesforce.Util;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
import com.metamatrix.connector.salesforce.execution.visitors.UpdateVisitor;
-public class UpdateExecutionImpl {
+public class UpdateExecutionImpl extends AbstractUpdateExecution {
- public int execute(IUpdate update, UpdateExecutionParent parent)
- throws ConnectorException {
- int result = 0;
- UpdateVisitor visitor = new UpdateVisitor(parent
- .getMetadata());
- visitor.visit(update);
- String[] Ids = parent.getIDs(update.getCriteria(), visitor);
+ public UpdateExecutionImpl(ICommand command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context,
+ ConnectorEnvironment connectorEnv) {
+ super(command, salesforceConnection, metadata, context, connectorEnv);
+ }
+ @Override
+ public void execute() throws ConnectorException {
+ UpdateVisitor visitor = new UpdateVisitor(getMetadata());
+ visitor.visit((IUpdate)command);
+ String[] Ids = getIDs(((IUpdate)command).getCriteria(), visitor);
+
if (null != Ids && Ids.length > 0) {
List<MessageElement> elements = new ArrayList<MessageElement>();
- for (ISetClause clause : update.getChanges().getClauses()) {
+ for (ISetClause clause : ((IUpdate)command).getChanges().getClauses()) {
IElement element = clause.getSymbol();
Element column = element.getMetadataObject();
String val = ((ILiteral) clause.getValue())
@@ -69,9 +79,7 @@
updateDataList.add(data);
}
- result = parent.getConnection().update(updateDataList);
+ result = getConnection().update(updateDataList);
}
- return result;
}
-
}
Deleted: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -1,139 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.connector.salesforce.execution;
-
-import java.util.ArrayList;
-
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.DataNotAvailableException;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.UpdateExecution;
-import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-
-import com.metamatrix.connector.salesforce.Util;
-import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
-import com.metamatrix.connector.salesforce.execution.visitors.IQueryProvidingVisitor;
-import com.sforce.soap.partner.QueryResult;
-import com.sforce.soap.partner.sobject.SObject;
-
-/**
- *
- * Parent class to the Update, Delete, and Insert execution classes.
- * Provisions the correct impl and contains some common code to
- * get IDs of Salesforce objects.
- *
- */
-public class UpdateExecutionParent extends BasicExecution implements UpdateExecution {
-
- private SalesforceConnection connection;
- private RuntimeMetadata metadata;
- private ExecutionContext context;
- private ConnectorEnvironment connectorEnv;
- private ICommand command;
- private int result;
-
- public UpdateExecutionParent(ICommand command, SalesforceConnection salesforceConnection,
- RuntimeMetadata metadata, ExecutionContext context,
- ConnectorEnvironment connectorEnv) {
- this.connection = salesforceConnection;
- this.metadata = metadata;
- this.context = context;
- this.connectorEnv = connectorEnv;
- this.command = command;
- }
-
- @Override
- public void cancel() throws ConnectorException {
- }
-
- @Override
- public void close() throws ConnectorException {
- }
-
- @Override
- public void execute() throws ConnectorException {
- if(command instanceof org.teiid.connector.language.IDelete) {
- DeleteExecutionImpl ex = new DeleteExecutionImpl();
- result = ex.execute(((IDelete)command), this);
- } else if (command instanceof org.teiid.connector.language.IInsert) {
- InsertExecutionImpl ex = new InsertExecutionImpl();
- result = ex.execute(((IInsert)command), this);
- } else if (command instanceof org.teiid.connector.language.IUpdate) {
- UpdateExecutionImpl ex = new UpdateExecutionImpl();
- result = ex.execute(((IUpdate)command), this);
- }
- }
-
- @Override
- public int[] getUpdateCounts() throws DataNotAvailableException,
- ConnectorException {
- return new int[] {result};
- }
-
- public RuntimeMetadata getMetadata() {
- return metadata;
- }
-
- public ConnectorEnvironment getConnectorEnv() {
- return connectorEnv;
- }
-
- public SalesforceConnection getConnection() {
- return connection;
- }
-
- String[] getIDs(ICriteria criteria, IQueryProvidingVisitor visitor) throws ConnectorException {
- String[] Ids = null;
- if (visitor.hasOnlyIDCriteria()) {
- try {
- String Id = ((ICompareCriteria)criteria).getRightExpression().toString();
- Id = Util.stripQutes(Id);
- Ids = new String[] { Id };
- } catch (ClassCastException cce) {
- throw new RuntimeException(
- "Error: The delete criteria is not a CompareCriteria");
- }
-
- } else if (visitor.hasCriteria()) {
- String query = visitor.getQuery();
- QueryResult results = getConnection().query(query, context.getBatchSize(), Boolean.FALSE);
- if (null != results && results.getSize() > 0) {
- ArrayList<String> idList = new ArrayList<String>(results
- .getRecords().length);
- for (int i = 0; i < results.getRecords().length; i++) {
- SObject sObject = results.getRecords(i);
- idList.add(sObject.getId());
- }
- Ids = idList.toArray(new String[0]);
- }
- }
- return Ids;
- }
-}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -76,6 +76,10 @@
protected Group table;
boolean onlyIDCriteria;
protected Boolean queryAll = Boolean.FALSE;
+
+ // support for invoking a retrieve when possible.
+ protected IInCriteria idInCriteria = null;
+
public CriteriaVisitor( RuntimeMetadata metadata ) {
this.metadata = metadata;
@@ -322,9 +326,12 @@
private void appendCriteria( IInCriteria criteria ) throws ConnectorException {
StringBuffer queryString = new StringBuffer();
+ IExpression leftExp = criteria.getLeftExpression();
+ if(isIdColumn(leftExp)) {
+ idInCriteria = criteria;
+ }
+ queryString.append(getValue(leftExp));
queryString.append(' ');
- queryString.append(getValue(criteria.getLeftExpression()));
- queryString.append(' ');
if (criteria.isNegated()) {
queryString.append("NOT ");
}
@@ -354,7 +361,7 @@
return result;
}
- private String getValue( IExpression expr ) throws ConnectorException {
+ protected String getValue( IExpression expr ) throws ConnectorException {
String result;
if (expr instanceof IElement) {
IElement element = (IElement)expr;
@@ -378,7 +385,7 @@
}
List<Element> columnIds = table.getChildren();
for (Element element : columnIds) {
- String name = table.getName() + '.' + element.getName();
+ String name = table.getName() + '.' + element.getNameInSource();
columnElementsByName.put(name, element);
// influences queryAll behavior
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -51,6 +51,7 @@
private int idIndex = -1; // index of the ID select symbol.
protected List<ISelectSymbol> selectSymbols;
protected StringBuffer limitClause = new StringBuffer();
+ private Boolean supportsRetrieve;
public SelectVisitor(RuntimeMetadata metadata) {
super(metadata);
@@ -112,6 +113,7 @@
if(fromItem instanceof IGroup) {
table = ((IGroup)fromItem).getMetadataObject();
String supportsQuery = (String)table.getProperties().get(Constants.SUPPORTS_QUERY);
+ supportsRetrieve = Boolean.valueOf((String)table.getProperties().get(Constants.SUPPORTS_RETRIEVE));
if (!Boolean.valueOf(supportsQuery)) {
throw new ConnectorException(table.getNameInSource() + " "
+ Messages.getString("CriteriaVisitor.query.not.supported"));
@@ -198,4 +200,37 @@
return queryAll;
}
+
+ public String getRetrieveFieldList() throws ConnectorException {
+ assertRetrieveValidated();
+ StringBuffer result = new StringBuffer();
+ addSelectSymbols(table.getNameInSource(), result);
+ return result.toString();
+ }
+
+
+ public String[] getIdInCriteria() throws ConnectorException {
+ assertRetrieveValidated();
+ List<IExpression> expressions = this.idInCriteria.getRightExpressions();
+ String[] result = new String[expressions.size()];
+ for(int i = 0; i < expressions.size(); i++) {
+ result[i] = getValue(expressions.get(i));
+ }
+ return result;
+ }
+
+ private void assertRetrieveValidated() throws AssertionError {
+ if(!hasOnlyIDCriteria()) {
+ throw new AssertionError("Must call hasOnlyIdInCriteria() before this method");
+ }
+ }
+
+ public boolean hasOnlyIdInCriteria() {
+ return hasOnlyIDCriteria() && idInCriteria != null;
+ }
+
+ public boolean canRetrieve() {
+ return supportsRetrieve && hasOnlyIDCriteria();
+ }
+
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -21,8 +21,6 @@
*/
package com.metamatrix.connector.salesforce.execution.visitors;
-import java.util.Iterator;
-
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.language.IUpdate;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -132,23 +132,37 @@
visitor.visit(command);
assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (NOT (Account.AccountName LIKE '%foo')) OR (Account.Stuff = 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
}
+
- // I can't really write this test until I see what teiid is going to pass the connectro based upon the user query.
- // SELECT Account.Name AS c_0, Contact.Name AS c_1 FROM Contact LEFT OUTER JOIN Account ON Account.Id = Contact.AccountId
+ @Test public void testIN() throws Exception {
+ IQuery command = (IQuery)translationUtility.parseCommand("select * from Account where Industry IN (1,2,3)"); //$NON-NLS-1$
+ SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
+ visitor.visit(command);
+ assertFalse(visitor.hasOnlyIDCriteria());
+ assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE Industry IN('1','2','3')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
+
+ }
+
+ @Test public void testOnlyIDsIN() throws Exception {
+ // this can resolve to a better performing retrieve call
+ IQuery command = (IQuery)translationUtility.parseCommand("select * from Account where ID IN (1,2,3)"); //$NON-NLS-1$
+ SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
+ visitor.visit(command);
+ assertTrue(visitor.hasOnlyIdInCriteria());
+ assertEquals("Account", visitor.getTableName());
+ assertEquals("Account.id, Account.AccountName, Account.Stuff, Account.Industry", visitor.getRetrieveFieldList());
+ assertEquals(new String[]{"1", "2", "3"}, visitor.getIdInCriteria());
+ }
+
@Test public void testJoin() throws Exception {
IQuery command = (IQuery)translationUtility.parseCommand("SELECT Account.Name, Contact.Name FROM Contact LEFT OUTER JOIN Account ON Account.Id = Contact.AccountId"); //$NON-NLS-1$
-
SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.AccountName, Contact.ContactName FROM Contact", visitor.getQuery().toString().trim()); //$NON-NLS-1$
- // SELECT Contact.Id, Contact.Name, Account.Name FROM Contact WHERE Account.Industry != 'media'
- // Looks like using q names will work, but we need to distinguish between the parent and child table somehow cannot send
- // SELECT Contact.Id, Contact.Name, Account.Name FROM Contact, Account WHERE Account.Industry != 'media'
}
@Test public void testJoin2() throws Exception {
IQuery command = (IQuery)translationUtility.parseCommand("SELECT Account.Name, Contact.Name FROM Account LEFT OUTER JOIN Contact ON Account.Id = Contact.AccountId"); //$NON-NLS-1$
-
SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.AccountName, (SELECT Contact.ContactName FROM Contacts) FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
16 years, 4 months