Author: shawkins
Date: 2010-10-19 11:39:47 -0400 (Tue, 19 Oct 2010)
New Revision: 2659
Added:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi
trunk/documentation/developer-guide/src/main/docbook/en-US/Book_Info.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/Developer_Guide.xml
trunk/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/Util.java
Removed:
trunk/client/src/main/java/org/teiid/adminapi/ProcessObject.java
trunk/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
trunk/client/src/main/java/org/teiid/net/socket/AdminApiServerDiscovery.java
trunk/client/src/test/java/org/teiid/net/socket/TestAdminApiServerDiscovery.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeSQLVisitor.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeUtil.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/PathFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java
trunk/connectors/translator-jdbc/src/test/resources/ModeShape.vdb
trunk/documentation/developer-guide/src/main/docbook/en-US/main.xml
Modified:
trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/client/src/main/java/org/teiid/adminapi/Admin.java
trunk/client/src/main/java/org/teiid/adminapi/AdminFactory.java
trunk/client/src/main/java/org/teiid/adminapi/Translator.java
trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
trunk/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/client/src/main/java/org/teiid/net/socket/Handshake.java
trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties
trunk/client/src/main/resources/vdb-deployer.xsd
trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java
trunk/common-core/src/main/java/org/teiid/core/util/ApplicationInfo.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/modeshape/TestModeShapeSqlTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
trunk/console/src/main/resources/META-INF/rhq-plugin.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml
trunk/documentation/developer-guide/pom.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/appendix-a.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/appendix-b.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/develop-adapter.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/extending-jdbc.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/introduction.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/security.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
trunk/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
trunk/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java
trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
trunk/engine/src/main/java/org/teiid/query/processor/BatchedUpdatePlan.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolveVirtualGroupCriteriaVisitor.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/QueryCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubquerySetCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/AssignmentStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/DeclareStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/Statement.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/ScalarSubquery.java
trunk/engine/src/main/java/org/teiid/query/sql/util/UpdateProcedureGenerator.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInlineViewImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestOrderByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
trunk/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java
trunk/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
trunk/engine/src/test/java/org/teiid/query/parser/TestCallableStatementParsing.java
trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestStaticSymbolMappingVisitor.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
trunk/jboss-integration/pom.xml
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.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/TestResultsSummary.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.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/client/ctc/XMLGenerateResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
forward merge from 7.1.1 v 2657 TEIID-1309 validating multi-source project into TEIID-1237
initial check in to clean up assignment symantics and to expand procedure usage.
Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -37,7 +37,6 @@
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminFactory;
import org.teiid.adminapi.CacheStatistics;
-import org.teiid.adminapi.ProcessObject;
import org.teiid.adminapi.PropertyDefinition;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
@@ -132,9 +131,9 @@
@Doc(text = "Cancel a request")
public static void cancelRequest(
@Doc(text = "session id") String sessionId,
- @Doc(text = "request id") long requestId)
+ @Doc(text = "execution id") long executionId)
throws AdminException {
- getAdmin().cancelRequest(sessionId, requestId);
+ getAdmin().cancelRequest(sessionId, executionId);
}
@Doc(text = "Clear the given cache")
@@ -183,13 +182,6 @@
return getAdmin().getTemplatePropertyDefinitions(templateName);
}
- @Doc(text = "Get the ProcessObject instances for the given identifier")
- public static Collection<ProcessObject> getProcesses(
- @Doc(text = "identifier") String processIdentifier)
- throws AdminException {
- return getAdmin().getProcesses(processIdentifier);
- }
-
@Doc(text = "Get all Request instances")
public static Collection<Request> getRequests() throws AdminException {
return getAdmin().getRequests();
@@ -224,11 +216,10 @@
return getAdmin().getVDBs();
}
- @Doc(text = "Get WorkerPoolStatistics for the given WorkManager")
- public static WorkerPoolStatistics getWorkManagerStats(
- @Doc(text = "identifier") String identifier)
+ @Doc(text = "Get thread pool statistics for Teiid")
+ public static WorkerPoolStatistics getWorkerPoolStats()
throws AdminException {
- return getAdmin().getWorkManagerStats(identifier);
+ return getAdmin().getWorkerPoolStats();
}
@Doc(text = "Get cache statistics for given cache type")
@@ -256,14 +247,6 @@
getAdmin().setAnyAuthenticatedForDataRole(vdbName, vdbVersion, dataRole,
anyAuthenticated);
}
- @Doc(text = "Set a runtime property")
- public static void setRuntimeProperty(
- @Doc(text = "name") String propertyName,
- @Doc(text = "value") String propertyValue)
- throws AdminException {
- getAdmin().setRuntimeProperty(propertyName, propertyValue);
- }
-
@Doc(text = "Terminate a session and associated requests")
public static void terminateSession(
@Doc(text = "session id") String sessionId) throws AdminException {
@@ -365,7 +348,7 @@
return getAdmin().getDataSourceTemplateNames();
}
- @Doc(text = "Get the current Admin connection")
+ @Doc(text = "Get the current org.teiid.adminapi.Admin instance for direct use.
Note: Used for advanced usecases to bypass AdminShell methods")
public static Admin getAdmin() {
if (internalAdmin == null) {
throw new NullPointerException("Not connected. You must call a
\"connectAsAdmin\" method or choose an active connection via
\"useConnection\"."); //$NON-NLS-1$
Modified:
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
---
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -4,7 +4,15 @@
<!-- Deployer specific Stuff -->
<bean name="VDBStructure"
class="org.teiid.deployers.VDBStructure" />
- <bean name="VDBRepository"
class="org.teiid.deployers.VDBRepository"/>
+
+ <bean name="SystemFunctionManager"
class="org.teiid.query.function.SystemFunctionManager">
+ <property name="allowEnvFunction">false</property>
+ </bean>
+
+ <bean name="VDBRepository"
class="org.teiid.deployers.VDBRepository">
+ <property name="systemFunctionManager"><inject
bean="SystemFunctionManager"/></property>
+ </bean>
+
<bean name="SecurityHelper"
class="org.teiid.jboss.JBossSecurityHelper"/>
<bean name="JBossLifeCycleListener"
class="org.teiid.jboss.JBossLifeCycleListener"/>
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-10-18 19:03:20 UTC (rev
2658)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-10-19 15:39:47 UTC (rev
2659)
@@ -39,7 +39,8 @@
<LI><B>Materialized View Performance</B> - materialized view tables
will now automatically create and use non-unique secondary indexes for unique constraints
and indexes defined on the view.
<LI><B>Binary Web Service Calls</B> - the ws translator now
provides an invokeHttp procedure to return the blob contents and string content type of an
http/https call.
<LI><B>Improved clustering support</B> - see the Admin Guide
chapter on clustering.
- <LI><B>IPv6 support</B> - Teiid can started using IPv6 bind address
and can be used with JDBC connection.
+ <LI><B>IPv6 support</B> - Teiid can started using IPv6 bind address
and can be used with JDBC connection.
+ <LI><B>SESSION_ID</b> - A new system function
"SESSION_ID" is added to the system function library.
</UL>
<h2><a name="Compatibility">Compatibility
Issues</a></h2>
@@ -48,11 +49,17 @@
</ul>
<h4>from 7.1</h4>
<ul>
+ <li>Subqueries are no longer allowed to be SELECT INTO.
+ <li>INSERT/UPDATE/DELETE cannot be used to create implicit return cursors in
non-update virtual procedures. You can instead use "integer_var = UPDATE ...; SELECT
integer_var;".
<li>The SYSADMIN schema was created to hold procedures and tables that should not
be generally accessible. SYS and pg_catalog are now always accessible - permissions do
not apply to these schemas. The SYS.getBinaryVDBResource, SYS.getCharacterVDBResource,
and SYS.getVDBResourcePaths have been replaced with the
SYSADMIN.VDBResources table. The Matviews table and the
refreshMatView/refreshMatViewRow procedures were also moved into SYSADMIN.
<li>Overwriting an existing VDB will cause old connections to be terminated.
Production systems should rely on VDB versioning.
<li>The jdbc:metamatrix JDBC URL prefix is no longer accepted. Use jdbc:teiid
instead.
<li>Model visibility no longer restricts access to tables and procedures.
Setting visible to false will only hide entries from system tables. Data roles should be
used to restrict data access.
+ <li>Admin API "getWorkManagerStats" methods renamed to
"getWorkerPoolStats". Also, "setRuntimeProperty" and
"getProcesses" methods were removed.
+ <li>By default the "ENV" system function is now turned off. To enable
it, edit the teiid-jboss-beans.xml configuration file.
+ <li>The use of VARIABLES.ROWCOUNT is now reserved. Use a different
+ <li>Direct assignments in virtual procedures using stored procedures (e.g. var =
EXEC foo()) are only valid if the procedure has a return parameter and no result set.
</ul>
<h4>from 7.0</h4>
<ul>
Modified: trunk/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-10-18 19:03:20 UTC (rev
2658)
+++ trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-10-19 15:39:47 UTC (rev
2659)
@@ -75,13 +75,6 @@
void deleteVDB(String vdbName, int vdbVersion) throws AdminException;
/**
- * Set a process level property.
- * @param propertyName - name of the property
- * @param propertyValue - value of the property
- */
- void setRuntimeProperty(String propertyName, String propertyValue) throws
AdminException;
-
- /**
* Get the VDBs that currently deployed in the system
*
* @return Collection of {@link VDB}s. There could be multiple VDBs with the
@@ -116,13 +109,12 @@
Translator getTranslator(String deployedName) throws AdminException;
/**
- * Get the Work Manager stats that correspond to the specified identifier pattern.
+ * Get the Worker Pool statistics in runtime engine.
*
- * @param identifier - an identifier for the queues {@link QueueWorkerPool}.
- * @return Collection of {@link QueueWorkerPool}
+ * @return {@link WorkerPoolStatistics}
* @throws AdminException
*/
- WorkerPoolStatistics getWorkManagerStats(String identifier) throws AdminException;
+ WorkerPoolStatistics getWorkerPoolStats() throws AdminException;
/**
* Get the Caches that correspond to the specified identifier pattern
@@ -169,18 +161,6 @@
*/
Collection<Transaction> getTransactions() throws AdminException;
-
- /**
- * Get the processes that correspond to the specified identifier pattern.
- *
- * @param processIdentifier the unique identifier for for a {@link
org.teiid.adminapi.ProcessObject ProcessObject}
- * in the system or "{@link org.teiid.adminapi.AdminObject#WILDCARD
WILDCARD}"
- * if all Processes are desired.
- * @return Collection of {@link org.teiid.adminapi.ProcessObject ProcessObject}
- * @throws AdminException if there's a system error.
- */
- Collection<ProcessObject> getProcesses(String processIdentifier) throws
AdminException;
-
/**
* Clear the cache or caches specified by the cacheIdentifier.
* @param cacheType Cache Type
@@ -211,11 +191,11 @@
* Cancel Request
*
* @param sessionId session Identifier for the request.
- * @param requestId request Identifier
+ * @param executionId request Identifier
*
* @throws AdminException
*/
- void cancelRequest(String sessionId, long requestId) throws AdminException;
+ void cancelRequest(String sessionId, long executionId) throws AdminException;
/**
* Mark the given global transaction as rollback only.
Modified: trunk/client/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -28,9 +28,7 @@
import java.lang.reflect.Proxy;
import java.util.Properties;
-import org.teiid.client.security.LogonException;
import org.teiid.client.util.ExceptionUtil;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.PropertiesUtils;
import org.teiid.jdbc.JDBCPlugin;
import org.teiid.net.CommunicationException;
@@ -42,29 +40,26 @@
/**
- * Singleton factory for ServerAdmins.
- * @since 4.3
+ * Singleton factory for class for creating Admin connections to the Teiid
*/
public class AdminFactory {
- private static final int DEFAULT_BOUNCE_WAIT = 2000;
-
private final class AdminProxy implements InvocationHandler {
- private Admin target;
- private ServerConnection registry;
+ private Admin admin;
+ private ServerConnection serverConnection;
private boolean closed;
public AdminProxy(Properties p) throws ConnectionException, CommunicationException
{
- this.registry = serverConnectionFactory.getConnection(p);
- this.target = registry.getService(Admin.class);
+ this.serverConnection = serverConnectionFactory.getConnection(p);
+ this.admin = serverConnection.getService(Admin.class);
}
private synchronized Admin getTarget() throws AdminComponentException {
if (closed) {
throw new
AdminComponentException(JDBCPlugin.Util.getString("admin_conn_closed"));
//$NON-NLS-1$
}
- return target;
+ return admin;
}
@Override
@@ -81,11 +76,7 @@
return method.invoke(getTarget(), args);
} catch (InvocationTargetException e) {
if (ExceptionUtil.getExceptionOfType(e, CommunicationException.class) != null) {
- this.target = null;
- if (method.getName().endsWith("restart")) { //$NON-NLS-1$
- bounceSystem(true);
- return null;
- }
+ this.admin = null;
}
throw e.getTargetException();
}
@@ -96,53 +87,22 @@
return;
}
this.closed = true;
- if (registry != null) {
- registry.close();
+ if (serverConnection != null) {
+ serverConnection.close();
}
- }
-
- public void bounceSystem(boolean waitUntilDone) {
- if (!waitUntilDone) {
- return;
- }
- //we'll wait 2 seconds for the server to come up
- try {
- Thread.sleep(bounceWait);
- } catch (InterruptedException e) {
- throw new TeiidRuntimeException(e);
- }
-
- //we'll wait 30 seconds for the server to come back up
- for (int i = 0; i < 15; i++) {
- try {
- getTarget().getProcesses(AdminObject.WILDCARD);
- return;
- } catch (Exception e) {
- //reestablish a connection and retry
- try {
- Thread.sleep(bounceWait);
- } catch (InterruptedException ex) {
- throw new TeiidRuntimeException(ex);
- }
- }
- }
- }
+ }
}
public static final String DEFAULT_APPLICATION_NAME = "Admin"; //$NON-NLS-1$
- /**Singleton instance*/
- private static AdminFactory instance = new
AdminFactory(SocketServerConnectionFactory.getInstance(), DEFAULT_BOUNCE_WAIT);
+ private static AdminFactory instance = new
AdminFactory(SocketServerConnectionFactory.getInstance());
private ServerConnectionFactory serverConnectionFactory;
- private int bounceWait;
- AdminFactory(ServerConnectionFactory connFactory, int bounceWait) {
+ AdminFactory(ServerConnectionFactory connFactory) {
this.serverConnectionFactory = connFactory;
- this.bounceWait = bounceWait;
}
- /**Get the singleton instance*/
public static AdminFactory getInstance() {
return instance;
}
@@ -155,11 +115,7 @@
* @param password
* @param serverURL
* @return
- * @throws LogonException
* @throws AdminException
- * @throws CommunicationException
- * @throws LogonException
- * @since 4.3
*/
public Admin createAdmin(String userName,
char[] password,
@@ -174,12 +130,9 @@
* @param userName
* @param password
* @param serverURL
+ * @param applicationName
* @return
- * @throws LogonException
* @throws AdminException
- * @throws CommunicationException
- * @throws LogonException
- * @since 4.3
*/
public Admin createAdmin(String userName,
char[] password,
Deleted: trunk/client/src/main/java/org/teiid/adminapi/ProcessObject.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/ProcessObject.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/client/src/main/java/org/teiid/adminapi/ProcessObject.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -1,140 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi;
-
-import java.net.InetAddress;
-import java.util.Date;
-
-
-/**
- * A Process in the Teiid System
- *
- * <p>The identifier pattern for a Process is
<code>"processName"</code>.
- * This Process identifier is considered to be unique across the system.</p>
- * @since 4.3
- */
-public interface ProcessObject extends
- AdminObject {
-
-
- /**
- * Get the Host name
- *
- * @return String host name where the process is running
- * @since 4.3
- */
- public String getHostName();
-
- /**
- * Get the Process name
- *
- * @return String A unique identifier for this Process.
- * @since 4.3
- */
- public String getProcessName();
-
-
- /**
- * Get the port number for this Process
- *
- * @return listener port for this host
- * @since 4.3
- */
- public int getPort();
-
- /**
- * Get the IP address for the Process
- * @return the IP address for the Process
- * @since 4.3
- */
- public InetAddress getInetAddress();
-
- /**
- * Is this process enabled in Configuration
- *
- * @return whether this process is enabled.
- * @since 4.3
- */
- public boolean isEnabled();
-
- /**
- * @return amount of free memory for this Java process.
- */
- public long getFreeMemory();
-
-
- /**
- * @return thread count for this Java process.
- */
- public int getThreadCount();
-
- /**
- * @return total memory allocated for this Java process.
- */
- public long getTotalMemory();
-
-
- /**
- * @return whether this process is running.
- * @since 4.3
- */
- public boolean isRunning();
-
- /**
- * @return Returns the objectsRead.
- * @since 4.3
- */
- public long getObjectsRead();
-
- /**
- * @return Returns the objectsWritten.
- * @since 4.3
- */
- public long getObjectsWritten();
-
-
- /**
- * @return Returns the maxSockets.
- * @since 4.3
- */
- public int getMaxSockets();
-
- /**
- * @return Returns the sockets.
- * @since 4.3
- */
- public int getSockets();
-
- /**
- * @return Returns the startTime.
- * @since 4.3
- */
- public Date getStartTime();
-
-
- /**
- * @return Returns the queueWorkerPool.
- * @since 4.3
- */
- public WorkerPoolStatistics getQueueWorkerPool();
-}
Deleted: trunk/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-
-
-public abstract class TeiidAdmin implements Admin, Serializable {
-
- @Override
- public Collection<ProcessObject> getProcesses(String processIdentifier) throws
AdminException {
- ArrayList<ProcessObject> list = new ArrayList<ProcessObject>();
- //list.add(manager.getProcess());
- return list;
- }
-
- @Override
- public void setRuntimeProperty(String propertyName, String propertyValue) throws
AdminException {
- throw new AdminProcessingException("feature coming soon..");
- }
-}
Modified: trunk/client/src/main/java/org/teiid/adminapi/Translator.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Translator.java 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/client/src/main/java/org/teiid/adminapi/Translator.java 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -31,4 +31,10 @@
* @return
*/
public String getType();
+
+ /**
+ * Get the Translator description
+ * @return
+ */
+ public String getDescription();
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -30,7 +30,7 @@
public interface DQPManagement {
List<RequestMetadata> getRequestsForSession(String sessionId) ;
List<RequestMetadata> getRequests();
- WorkerPoolStatisticsMetadata getWorkManagerStatistics(String identifier);
+ WorkerPoolStatisticsMetadata getWorkerPoolStatistics();
void terminateSession(String terminateeId);
boolean cancelRequest(String sessionId, long requestId) throws AdminException;
Collection<String> getCacheTypes();
@@ -43,4 +43,5 @@
List<RequestMetadata> getLongRunningRequests();
List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion)
throws AdminException;
CacheStatisticsMetadata getCacheStatistics(String cacheType);
+ List<List> executeQuery(String vdbName, int version, String command, long
timoutInMilli) throws AdminException;
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
===================================================================
---
trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -81,7 +81,7 @@
CompositeMetaType composite = (CompositeMetaType) metaType;
CompositeValueSupport session = new CompositeValueSupport(composite);
- session.set(APPLICATION_NAME, SimpleValueSupport.wrap(object.getName()));
+ session.set(APPLICATION_NAME, SimpleValueSupport.wrap(object.getApplicationName()));
session.set(CREATED_TIME, SimpleValueSupport.wrap(object.getCreatedTime()));
session.set(CLIENT_HOST_NAME, SimpleValueSupport.wrap(object.getClientHostName()));
session.set(IP_ADDRESS, SimpleValueSupport.wrap(object.getIPAddress()));
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
---
trunk/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -41,7 +41,7 @@
public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
private static final long serialVersionUID = -3454161477587996138L;
private String type;
- private Class executionClass;
+ private Class<?> executionClass;
private String description;
@Override
@@ -83,7 +83,7 @@
return this.executionClass;
}
- public void setExecutionFactoryClass(Class clazz) {
+ public void setExecutionFactoryClass(Class<?> clazz) {
this.executionClass = clazz;
addProperty(EXECUTION_FACTORY_CLASS, clazz.getName());
}
@@ -93,7 +93,7 @@
return this.description;
}
- @XmlAttribute(name = "description", required = true)
+ @XmlAttribute(name = "description")
public void setDescription(String desc) {
this.description = desc;
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -336,8 +336,7 @@
*/
public List getCurrentRecord() throws SQLException {
checkClosed();
- List wholeRecord = batchResults.getCurrentRow();
- return wholeRecord.subList(0, wholeRecord.size() - getOffset());
+ return batchResults.getCurrentRow();
}
/*
* @see java.sql.ResultSet#getType()
@@ -1062,6 +1061,9 @@
* @throws SQLException
*/
public boolean isAfterLast() throws SQLException {
+ if (getFinalRowNumber() == -1) {
+ return false;
+ }
// return true if the current row has a next row
// it is also not the last
return !hasNext() && this.getAbsoluteRowNumber() > BEFORE_FIRST_ROW
&& this.getAbsoluteRowNumber() > getFinalRowNumber();
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -478,8 +478,8 @@
try {
resultsMsg = sendRequestMessageAndWait(reqMessage);
} catch ( Throwable ex ) {
- String msg =
JDBCPlugin.Util.getString("MMStatement.Error_executing_stmt",
reqMessage.getCommandString()); //$NON-NLS-1$
- logger.log(Level.SEVERE, msg, ex);
+ String msg =
JDBCPlugin.Util.getString("MMStatement.Error_executing_stmt",
reqMessage.getCommandString()); //$NON-NLS-1$
+ logger.log(ex instanceof SQLException?Level.WARNING:Level.SEVERE, msg, ex);
throw TeiidSQLException.create(ex, msg);
}
@@ -881,7 +881,7 @@
* Send out request message with necessary states.
*/
protected ResultsMessage sendRequestMessageAndWait(RequestMessage reqMsg)
- throws SQLException, InterruptedException, TimeoutException {
+ throws SQLException, InterruptedException {
this.currentRequestID = this.driverConnection.nextRequestID();
// Create a request message
reqMsg.setExecutionPayload(this.payload);
@@ -925,7 +925,7 @@
}
if (commandStatus == TIMED_OUT) {
- throw new
TimeoutException(JDBCPlugin.Util.getString("MMStatement.Timeout_before_complete"));
//$NON-NLS-1$
+ throw new
TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Timeout_before_complete"));
//$NON-NLS-1$
}
return result;
}
Deleted: trunk/client/src/main/java/org/teiid/net/socket/AdminApiServerDiscovery.java
===================================================================
---
trunk/client/src/main/java/org/teiid/net/socket/AdminApiServerDiscovery.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/client/src/main/java/org/teiid/net/socket/AdminApiServerDiscovery.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.net.socket;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.ProcessObject;
-import org.teiid.client.security.LogonResult;
-import org.teiid.net.HostInfo;
-import org.teiid.net.TeiidURL;
-
-
-/**
- * Will discover hosts based upon an anon admin api call.
- */
-public class AdminApiServerDiscovery extends UrlServerDiscovery {
-
- /**
- * If the FIREWALL_HOST property is set, then this host name will be used instead of the
process
- * names returned by the AdminApi
- */
- public static final String USE_URL_HOST =
"AdminApiServerDiscovery.useUrlHost"; //$NON-NLS-1$
-
- public static final int DISCOVERY_TIMEOUT = 120000;
-
- static class ClusterInfo {
- volatile long lastDiscoveryTime;
- volatile List<HostInfo> knownHosts = new ArrayList<HostInfo>();
- }
-
- private static Map<String, ClusterInfo> clusterInfo =
Collections.synchronizedMap(new HashMap<String, ClusterInfo>());
-
- private boolean useUrlHost;
-
- @Override
- public void init(TeiidURL url, Properties p) {
- super.init(url, p);
- //TODO: this could be on a per cluster basis
- useUrlHost = Boolean.valueOf(p.getProperty(USE_URL_HOST)).booleanValue();
- }
-
- @Override
- public List<HostInfo> getKnownHosts(LogonResult result,
- SocketServerInstance instance) {
- if (result == null) {
- return super.getKnownHosts(result, instance);
- }
- ClusterInfo info = clusterInfo.get(result.getClusterName());
- if (info == null) {
- info = new ClusterInfo();
- }
- synchronized (info) {
- if (instance != null
- && (info.lastDiscoveryTime < System.currentTimeMillis() -
DISCOVERY_TIMEOUT || info.knownHosts.isEmpty())) {
- Admin serverAdmin = instance.getService(Admin.class);
- try {
- Collection<ProcessObject> processes = serverAdmin.getProcesses("*");
//$NON-NLS-1$
- info.knownHosts.clear();
- for (ProcessObject processObject : processes) {
- if (!processObject.isEnabled() || !processObject.isRunning()) {
- continue;
- }
- info.knownHosts.add(new
HostInfo(useUrlHost?instance.getHostInfo().getHostName():processObject.getInetAddress().getHostName(),
processObject.getPort()));
- }
- info.lastDiscoveryTime = System.currentTimeMillis();
- } catch (AdminException e) {
- //ignore - will get an update on the next successful connection
- }
- }
- if (info.knownHosts.size() == 0) {
- return super.getKnownHosts(result, instance);
- }
- return new ArrayList<HostInfo>(info.knownHosts);
- }
- }
-}
Modified: trunk/client/src/main/java/org/teiid/net/socket/Handshake.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/Handshake.java 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/client/src/main/java/org/teiid/net/socket/Handshake.java 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -37,7 +37,7 @@
private static final long serialVersionUID = 7839271224736355515L;
- private String version = ApplicationInfo.getInstance().getMajorReleaseNumber();
+ private String version = ApplicationInfo.getInstance().getReleaseNumber();
private byte[] publicKey;
/**
@@ -51,7 +51,7 @@
* @param version The version to set.
*/
public void setVersion() {
- this.version = ApplicationInfo.getInstance().getMajorReleaseNumber();
+ this.version = ApplicationInfo.getInstance().getReleaseNumber();
}
/**
Modified: trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties
===================================================================
--- trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -108,7 +108,7 @@
StaticMetadataProvider.Invalid_column=Invalid column index: {0}
DeferredMetadataProvider.Invalid_data=Invalid data for DeferredMetadataProvider: {0},
{1}
FilteredResultsMetadata.Invalid_index=Invalid column index: {0}
-MMStatement.Timeout_ocurred_in_Statement.=Timeout ocurred in Statement.
+MMStatement.Timeout_ocurred_in_Statement.=Timeout occurred in Statement.
MMStatement.Error_timing_out.=Error timing out.
MMStatement.Bad_timeout_value=Invalid timeout value supplied. Valid range is greater than
or equal to zero.
WarningUtil.Failures_occurred=Partial results failures occurred
Modified: trunk/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- trunk/client/src/main/resources/vdb-deployer.xsd 2010-10-18 19:03:20 UTC (rev 2658)
+++ trunk/client/src/main/resources/vdb-deployer.xsd 2010-10-19 15:39:47 UTC (rev 2659)
@@ -71,6 +71,7 @@
</xs:sequence>
<xs:attribute name="name" type="xs:string"
use="required"/>
<xs:attribute name="type" type="xs:string"
use="required"/>
+ <xs:attribute name="description"
type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="data-role" minOccurs="0"
maxOccurs="unbounded">
Modified: trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -33,13 +33,14 @@
@Test public void testMapping() {
SessionMetadata session = new SessionMetadata();
session.setSessionId("test");
-
+ session.setApplicationName("foo");
SessionMetadataMapper smm = new SessionMetadataMapper();
MetaValue mv = smm.createMetaValue(smm.getMetaType(), session);
SessionMetadata session1 = smm.unwrapMetaValue(mv);
assertEquals(session.getSessionId(), session1.getSessionId());
+ assertEquals(session.getApplicationName(), session1.getApplicationName());
}
}
Modified: trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -85,6 +85,7 @@
TranslatorMetaData t1 = new TranslatorMetaData();
t1.setName("oracleOverride");
t1.setType("oracle");
+ t1.setDescription("hello world");
t1.addProperty("my-property", "my-value");
List<Translator> list = new ArrayList<Translator>();
list.add(t1);
@@ -160,7 +161,7 @@
assertEquals("oracleOverride", translator.getName());
assertEquals("oracle", translator.getType());
assertEquals("my-value",
translator.getPropertyValue("my-property"));
-
+ assertEquals("hello world", translator.getDescription());
List<DataPolicy> roles = vdb.getDataPolicies();
assertTrue(roles.size() == 1);
Deleted: trunk/client/src/test/java/org/teiid/net/socket/TestAdminApiServerDiscovery.java
===================================================================
---
trunk/client/src/test/java/org/teiid/net/socket/TestAdminApiServerDiscovery.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/client/src/test/java/org/teiid/net/socket/TestAdminApiServerDiscovery.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.net.socket;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.ProcessObject;
-import org.teiid.client.security.LogonResult;
-import org.teiid.net.HostInfo;
-import org.teiid.net.TeiidURL;
-
-
-public class TestAdminApiServerDiscovery extends TestCase {
-
- public void testFirewallHost() throws Exception {
- AdminApiServerDiscovery discovery = new AdminApiServerDiscovery();
- Properties p = new Properties();
- p.setProperty(AdminApiServerDiscovery.USE_URL_HOST, Boolean.TRUE.toString());
- TeiidURL mmurl = new TeiidURL("foo", 1, false); //$NON-NLS-1$
- discovery.init(mmurl, p);
- HostInfo knownHost = mmurl.getHostInfo().get(0);
- //we will start off using the url host
- assertEquals(1, discovery.getKnownHosts(null, null).size());
-
- SocketServerInstance instance = Mockito.mock(SocketServerInstance.class);
- Admin serverAdmin = Mockito.mock(Admin.class);
-
- List<ProcessObject> processes = new ArrayList<ProcessObject>();
- ProcessObject p1 = Mockito.mock(ProcessObject.class);
- Mockito.stub(p1.getPort()).toReturn(5);
- processes.add(p1);
- ProcessObject p2 = Mockito.mock(ProcessObject.class);
- Mockito.stub(p2.isEnabled()).toReturn(true);
- Mockito.stub(p2.isRunning()).toReturn(true);
- Mockito.stub(p2.getPort()).toReturn(6);
- Mockito.stub(p2.getInetAddress()).toReturn(InetAddress.getByName("0.0.0.0"));
//$NON-NLS-1$
- processes.add(p2);
- Mockito.stub(serverAdmin.getProcesses("*")).toReturn(processes);
//$NON-NLS-1$
- Mockito.stub(instance.getService(Admin.class)).toReturn(serverAdmin);
- Mockito.stub(instance.getHostInfo()).toReturn(knownHost);
-
- discovery.connectionSuccessful(knownHost);
- List<HostInfo> knownHosts = discovery.getKnownHosts(new LogonResult(),
instance);
-
- assertEquals(1, knownHosts.size());
- HostInfo h = knownHosts.get(0);
- //the returned host should have the url name, but the process port
- assertEquals("foo", h.getHostName()); //$NON-NLS-1$
- assertEquals(6, h.getPortNumber());
- }
-
-}
Modified: trunk/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java
===================================================================
---
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServiceRegistry.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -29,13 +29,12 @@
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.client.DQP;
-import org.teiid.client.security.ILogon;
import org.teiid.client.util.ExceptionUtil;
import org.teiid.client.xa.XATransactionException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
-
+@SuppressWarnings("nls")
public class TestSocketServiceRegistry extends TestCase {
interface Foo{
@@ -53,7 +52,7 @@
public void testAdminExceptionConversion() throws Exception {
- Method m = Admin.class.getMethod("getProcesses", new Class[]
{String.class});
+ Method m = Admin.class.getMethod("getCacheStats", new Class[]
{String.class});
Throwable t = ExceptionUtil.convertException(m, new TeiidComponentException());
Modified: trunk/common-core/src/main/java/org/teiid/core/util/ApplicationInfo.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/ApplicationInfo.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/common-core/src/main/java/org/teiid/core/util/ApplicationInfo.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -70,10 +70,6 @@
return props.getProperty("build.releaseNumber"); //$NON-NLS-1$
}
- public String getMajorReleaseNumber() {
- return getReleaseNumber().substring(0, getReleaseNumber().lastIndexOf('.'));
- }
-
public int getMajorReleaseVersion() {
String version = getReleaseNumber().substring(0,
getReleaseNumber().indexOf('.'));
return Integer.parseInt(version);
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -134,8 +134,14 @@
}
}
- protected void setSizeContraints(Statement statement) throws SQLException {
- statement.setFetchSize(fetchSize);
+ protected void setSizeContraints(Statement statement) {
+ try {
+ statement.setFetchSize(fetchSize);
+ } catch (SQLException e) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL))
{
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestIdentifier(),
" could not set fetch size: ", fetchSize); //$NON-NLS-1$
+ }
+ }
}
protected synchronized Statement getStatement() throws SQLException {
@@ -185,7 +191,7 @@
warning = toAdd.getNextWarning();
toAdd.setNextException(null);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR,
MessageLevel.DETAIL)) {
- LogManager.logDetail(context.getRequestIdentifier() + " Warning: ",
warning); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestIdentifier() +
" Warning: ", warning); //$NON-NLS-1$
}
context.addWarning(toAdd);
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -563,7 +563,7 @@
* @param modifier
*/
public void registerFunctionModifier(String name, FunctionModifier modifier) {
- this.functionModifiers.put(name, modifier);
+ this.functionModifiers.put(name.toLowerCase(), modifier);
}
/**
@@ -603,7 +603,7 @@
*/
public String translateLiteralTime(Time timeValue) {
if (!hasTimeType()) {
- return "{ts '1970-01-01 " + formatDateValue(timeValue) +
"'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return translateLiteralTimestamp(new Timestamp(timeValue.getTime()));
}
return "{t '" + formatDateValue(timeValue) + "'}";
//$NON-NLS-1$ //$NON-NLS-2$
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -38,6 +38,7 @@
public AccessExecutionFactory() {
setSupportsOrderBy(false);
+ setDatabaseVersion("2003"); //$NON-NLS-1$
}
@Override
Copied:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java
(from rev 2654,
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java)
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java
(rev 0)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/IdentifierFunctionModifier.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -0,0 +1,94 @@
+/*
+ * 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.translator.jdbc.modeshape;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.NamedTable;
+import org.teiid.language.SQLConstants;
+import org.teiid.metadata.Column;
+import org.teiid.translator.jdbc.FunctionModifier;
+
+
+/**
+ * Function to translate ColumnReferences to selector names
+ * @since 7.1
+ */
+public class IdentifierFunctionModifier extends FunctionModifier {
+
+ public List<?> translate(Function function) {
+
+ List<Object> objs = new ArrayList<Object>();
+
+ List<Expression> parms = function.getParameters();
+
+ objs.add(function.getName().substring(function.getName().indexOf('_') + 1));
+ objs.add(SQLConstants.Tokens.LPAREN);
+
+ for (Iterator<Expression> iter = parms.iterator(); iter.hasNext();)
+ {
+ Expression expr = iter.next();
+ if (expr instanceof ColumnReference) {
+ boolean dotAll = false;
+ boolean useSelector = false;
+ ColumnReference cr = (ColumnReference)expr;
+ Column c = cr.getMetadataObject();
+ if (c != null) {
+ if
("\"mode:properties\"".equalsIgnoreCase(c.getNameInSource())) {
//$NON-NLS-1$
+ dotAll = true;
+ useSelector = true;
+ } else if
("\"mode:path\"".equalsIgnoreCase(c.getNameInSource())) {
//$NON-NLS-1$
+ useSelector = true;
+ }
+ }
+ if (useSelector) {
+ NamedTable nt = ((ColumnReference)expr).getTable();
+ if (nt.getCorrelationName() != null) {
+ objs.add(nt.getCorrelationName());
+ } else {
+ objs.add(nt);
+ }
+ } else {
+ objs.add(expr);
+ }
+ if (dotAll) {
+ objs.add(".*"); //$NON-NLS-1$
+ }
+ } else {
+ objs.add(expr);
+ }
+ if (iter.hasNext()) {
+ objs.add(", "); //$NON-NLS-1$
+ }
+ }
+
+ objs.add(SQLConstants.Tokens.RPAREN);
+ return objs;
+ }
+
+}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -29,174 +29,224 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Expression;
+import org.teiid.language.Comparison;
import org.teiid.language.Function;
import org.teiid.language.LanguageObject;
import org.teiid.language.Literal;
-import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.Comparison.Operator;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-
-
/**
* Translator class for accessing the ModeShape JCR repository.
*/
-@Translator(name="modeshape", description="A translator for open source
Modeshape JCA repository")
+@Translator(name="modeshape", description="A translator for the open
source Modeshape JCR Repository")
public class ModeShapeExecutionFactory extends JDBCExecutionFactory {
public ModeShapeExecutionFactory() {
setDatabaseVersion("2.0"); //$NON-NLS-1$
+ setUseBindVariables(false);
}
@Override
public void start() throws TranslatorException {
super.start();
- registerFunctionModifier("PATH", new PathFunctionModifier());
-
- //add in type conversion
- ConvertModifier convertModifier = new ConvertModifier();
-
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new
AliasModifier("UpperCase")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE,new
AliasModifier("LowerCase")); //$NON-NLS-1$
- convertModifier.addTypeMapping("boolean", FunctionModifier.BOOLEAN);
//$NON-NLS-1$
- convertModifier.addTypeMapping("smallint", FunctionModifier.BYTE,
FunctionModifier.SHORT); //$NON-NLS-1$
- convertModifier.addTypeMapping("integer", FunctionModifier.INTEGER);
//$NON-NLS-1$
- convertModifier.addTypeMapping("bigint", FunctionModifier.LONG);
//$NON-NLS-1$
- convertModifier.addTypeMapping("real", FunctionModifier.FLOAT);
//$NON-NLS-1$
- convertModifier.addTypeMapping("float8", FunctionModifier.DOUBLE);
//$NON-NLS-1$
- convertModifier.addTypeMapping("numeric(38)",
FunctionModifier.BIGINTEGER); //$NON-NLS-1$
- convertModifier.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL);
//$NON-NLS-1$
- convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR);
//$NON-NLS-1$
- convertModifier.addTypeMapping("varchar(4000)", FunctionModifier.STRING);
//$NON-NLS-1$
- convertModifier.addTypeMapping("date", FunctionModifier.DATE);
//$NON-NLS-1$
- convertModifier.addTypeMapping("time", FunctionModifier.TIME);
//$NON-NLS-1$
- convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP);
//$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new
FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList(function.getParameters().get(0), " + TIMESTAMP
'1970-01-01'"); //$NON-NLS-1$
- }
- });
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new
FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("cast(date_trunc('second', ",
function.getParameters().get(0), ") AS time)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new
ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD"));
//$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new
ConvertModifier.FormatModifier("to_char", "HH24:MI:SS"));
//$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new
ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD
HH24:MI:SS.UF")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new
FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- Expression stringValue = function.getParameters().get(0);
- return Arrays.asList("CASE WHEN ", stringValue, " THEN 'true'
WHEN not(", stringValue, ") THEN 'false' END"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
- }
- });
- convertModifier.addSourceConversion(new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- ((Literal)function.getParameters().get(1)).setValue("integer");
//$NON-NLS-1$
- return null;
- }
- }, FunctionModifier.BOOLEAN);
-
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
-
-
- LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Started"); //$NON-NLS-1$
-
+ registerFunctionModifier("JCR_ISCHILDNODE", new
IdentifierFunctionModifier()); //$NON-NLS-1$
+ registerFunctionModifier("JCR_ISDESCENDANTNODE", new
IdentifierFunctionModifier()); //$NON-NLS-1$
+ registerFunctionModifier("JCR_ISSAMENODE", new IdentifierFunctionModifier());
//$NON-NLS-1$
+ registerFunctionModifier("JCR_REFERENCE", new IdentifierFunctionModifier());
//$NON-NLS-1$
+ registerFunctionModifier("JCR_CONTAINS", new IdentifierFunctionModifier());
//$NON-NLS-1$
+
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "ModeShape Translator
Started"); //$NON-NLS-1$
}
- /**
- * Create the {@link SQLConversionVisitor} that will perform translation. Typical
custom
- * JDBC connectors will not need to create custom conversion visitors, rather
implementors
- * should override existing {@link JDBCExecutionFactory} methods.
- * @return the {@link SQLConversionVisitor}
- */
- public SQLConversionVisitor getSQLConversionVisitor() {
- return new ModeShapeSQLVisitor(this);
- }
-
-
- @Override
- public List<?> translate(LanguageObject obj, ExecutionContext context) {
- if (obj instanceof NamedTable) {
- NamedTable nt = (NamedTable) obj;
- List<String> ntlist = new ArrayList<String>(1);
- ntlist.add(ModeShapeUtil.createJCRName(nt.getMetadataObject().getNameInSource()));
- return ntlist;
- } else if (obj instanceof ColumnReference) {
- ColumnReference elem = (ColumnReference) obj;
-
- String nameInSource = "NoNameInSource";
- if (elem.getMetadataObject() != null) {
- nameInSource = elem.getMetadataObject().getNameInSource();
-
- List<String> ntlist = new ArrayList<String>(1);
- ntlist.add(ModeShapeUtil.createJCRName(nameInSource));
-
- return ntlist;
- }
- }
-
- return super.translate(obj, context);
- }
-
-
- @Override
- public String translateLiteralBoolean(Boolean booleanValue) {
- if(booleanValue.booleanValue()) {
- return "TRUE"; //$NON-NLS-1$
- }
- return "FALSE"; //$NON-NLS-1$
- }
-
@Override
public String translateLiteralDate(Date dateValue) {
- return "DATE '" + formatDateValue(dateValue) + "'";
//$NON-NLS-1$//$NON-NLS-2$
+ return "CAST('" + formatDateValue(dateValue) + "' AS
DATE)"; //$NON-NLS-1$//$NON-NLS-2$
}
@Override
public String translateLiteralTime(Time timeValue) {
- return "TIME '" + formatDateValue(timeValue) + "'";
//$NON-NLS-1$//$NON-NLS-2$
+ return "CAST('" + formatDateValue(timeValue) + "' AS
DATE)"; //$NON-NLS-1$//$NON-NLS-2$
}
@Override
public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "TIMESTAMP '" + formatDateValue(timestampValue) +
"'"; //$NON-NLS-1$//$NON-NLS-2$
+ return "CAST('" + formatDateValue(timestampValue) + "' AS
DATE)"; //$NON-NLS-1$//$NON-NLS-2$
}
@Override
- public int getTimestampNanoPrecision() {
- return 6;
+ public String translateLiteralBoolean(Boolean booleanValue) {
+ return "CAST('" + booleanValue.toString() + "' AS
BOOLEAN)"; //$NON-NLS-1$//$NON-NLS-2$
}
@Override
public List<String> getSupportedFunctions() {
List<String> supportedFunctions = new ArrayList<String>();
supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("PATH"); //$NON-NLS-1$
- supportedFunctions.add("NAME"); //$NON-NLS-1$
- supportedFunctions.add("ISCHILDNODE"); //$NON-NLS-1$
-
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add("JCR_ISCHILDNODE"); //$NON-NLS-1$
+ supportedFunctions.add("JCR_ISDESCENDANTNODE"); //$NON-NLS-1$
+ supportedFunctions.add("JCR_ISSAMENODE"); //$NON-NLS-1$
+ supportedFunctions.add("JCR_REFERENCE"); //$NON-NLS-1$
+ supportedFunctions.add("JCR_CONTAINS"); //$NON-NLS-1$
return supportedFunctions;
-
}
+
+ @Override
+ public List<?> translate(LanguageObject obj, ExecutionContext context) {
+ if (obj instanceof Comparison) {
+ Comparison compare = (Comparison)obj;
+ if (compare.getLeftExpression().getType() == TypeFacility.RUNTIME_TYPES.BOOLEAN
+ && compare.getLeftExpression() instanceof Function
+ && compare.getRightExpression() instanceof Literal) {
+ boolean isTrue =
Boolean.TRUE.equals(((Literal)compare.getRightExpression()).getValue());
+ if ((isTrue && compare.getOperator() == Operator.EQ) || (!isTrue
&& compare.getOperator() == Operator.NE)) {
+ return Arrays.asList(compare.getLeftExpression());
+ }
+ if ((!isTrue && compare.getOperator() == Operator.EQ) || (isTrue
&& compare.getOperator() == Operator.NE)) {
+ return Arrays.asList("NOT ", compare.getLeftExpression());
//$NON-NLS-1$
+ }
+ }
+ } else if (obj instanceof Not) {
+ Not not = (Not)obj;
+ return Arrays.asList("NOT ", not.getCriteria()); //$NON-NLS-1$
+ }
+ return super.translate(obj, context);
+ }
@Override
public boolean useBindVariables() {
return false;
}
+ @Override
+ public boolean supportsAggregatesAvg() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesCountStar() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesCount() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesEnhancedNumeric() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesMax() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesMin() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesSum() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsHaving() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSelectExpression() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCaseExpressions() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCorrelatedSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsExistsCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInCriteriaSubquery() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrderByNullOrdering() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaAll() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaSome() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSearchedCaseExpressions() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return false;
+ }
+
}
Deleted:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeSQLVisitor.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeSQLVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeSQLVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,95 +0,0 @@
-package org.teiid.translator.jdbc.modeshape;
-
-import static org.teiid.language.SQLConstants.Reserved.BY;
-import static org.teiid.language.SQLConstants.Reserved.ORDER;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.language.ColumnReference;
-import org.teiid.language.DerivedColumn;
-import org.teiid.language.Expression;
-import org.teiid.language.OrderBy;
-import org.teiid.language.Select;
-import org.teiid.language.SortSpecification;
-import org.teiid.language.SQLConstants.Tokens;
-import org.teiid.metadata.Column;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-
-public class ModeShapeSQLVisitor extends SQLConversionVisitor {
-
- private Map<String, Column> columnMap = new HashMap<String, Column>();
- private Map<String, Column> aliasMap = new HashMap<String, Column>();
-
- public ModeShapeSQLVisitor(JDBCExecutionFactory ef) {
- super(ef);
-
- }
-
- public void visit(Select query) {
-
- // if the query has an order by, then
- // need to cache the columns so that the
- // order by column name can be replaced by its
- // correlating select column that has the nameInSource
- if (query.getOrderBy() == null) {
- super.visit(query);
- return;
- }
-
- List<DerivedColumn> selectSymbols = query.getDerivedColumns();
- Iterator<DerivedColumn> symbolIter = selectSymbols.iterator();
- while (symbolIter.hasNext()) {
- DerivedColumn symbol = symbolIter.next();
- Expression expression = symbol.getExpression();
-
- if (symbol.getAlias() != null) {
-
- }
- // cache the columns so that order by
- if (expression instanceof ColumnReference) {
- ColumnReference colRef = (ColumnReference) expression;
- if (colRef.getMetadataObject() != null) {
- Column element = colRef.getMetadataObject();
- if (symbol.getAlias() != null) {
- aliasMap.put(symbol.getAlias(), element);
- }
- columnMap.put(element.getName(), element);
- }
- }
- }
-
- super.visit(query);
- }
-
- public void visit(OrderBy obj) {
- buffer.append(ORDER)
- .append(Tokens.SPACE)
- .append(BY)
- .append(Tokens.SPACE);
-
- List<SortSpecification> specs = obj.getSortSpecifications();
- for (SortSpecification spec : specs) {
- String specName = spec.getExpression().toString();
- Column col = null;
-
- col = aliasMap.get(specName);
- if (col == null) {
- col = columnMap.get(specName);
- }
- if (col != null) {
- buffer.append(ModeShapeUtil.createJCRName(col.getNameInSource()))
- .append(" ")
- .append(spec.getOrdering().toString());
-
- } else {
- buffer.append(obj.getSortSpecifications());
- }
- }
-
- }
-
-}
Deleted:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeUtil.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeUtil.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeUtil.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,27 +0,0 @@
-package org.teiid.translator.jdbc.modeshape;
-
-public class ModeShapeUtil {
-
- public static final String createJCRName(String name) {
- return "[" + ModeShapeUtil.trimTics(name) + "]";
- }
-
- /**
- * Because the Teiid Designer Import from JDBC adds tic's to a nameInSource that has
special characters,
- * they have to be removed when building the sql syntax
- * @param name
- * @return
- */
- public static final String trimTics(String name) {
- String rtn = name;
- if (rtn.startsWith("'")) {
- rtn = rtn.substring(1);
- }
-
- if (rtn.endsWith("'")) {
- rtn = rtn.substring(0, rtn.indexOf("'"));
- }
- return rtn;
- }
-
-}
Deleted:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/PathFunctionModifier.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/PathFunctionModifier.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/PathFunctionModifier.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.modeshape;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.language.Expression;
-import org.teiid.language.Function;
-import org.teiid.translator.jdbc.FunctionModifier;
-
-
-/**
- * Function to translate the PATH function
- * @since 7.1
- */
-public class PathFunctionModifier extends FunctionModifier {
-
- public PathFunctionModifier() {
- super();
- }
-
- public List<?> translate(Function function) {
- List<Object> objs = new ArrayList<Object>();
-
- List<Expression> parms = function.getParameters();
-
- for (Expression s : parms)
- {
- String v = s.toString();
- v.replace('\'', ' ');
- objs.add(v);
- }
-
- return objs;
- }
-
-}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -206,6 +206,11 @@
}
@Override
+ public boolean hasTimeType() {
+ return getDatabaseVersion().compareTo(V_2005) >= 0;
+ }
+
+ @Override
public boolean supportsCommonTableExpressions() {
return true;
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -25,11 +25,14 @@
package org.teiid.translator.jdbc.sybase;
import java.sql.CallableStatement;
+import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.LinkedList;
import java.util.List;
import org.teiid.language.Command;
@@ -37,10 +40,10 @@
import org.teiid.language.Limit;
import org.teiid.language.OrderBy;
import org.teiid.language.SetQuery;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
@@ -60,6 +63,7 @@
public SybaseExecutionFactory() {
setDatabaseVersion(TWELVE_5);
+ setSupportsFullOuterJoins(false);
}
public void start() throws TranslatorException {
@@ -173,13 +177,13 @@
return Arrays.asList("stuff(stuff(convert(varchar, ",
function.getParameters().get(0), ", 102), 5, 1, '-'), 8, 1,
'-')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- /**
- * Written to only support version 15
- * @param function
- * @return
- */
+ //TODO: this looses the milliseconds
protected List<?> convertTimestampToString(Function function) {
- return Arrays.asList("stuff(convert(varchar, ",
function.getParameters().get(0), ", 123), 11, 1, ' ')"); //$NON-NLS-1$
//$NON-NLS-2$
+ LinkedList<Object> result = new LinkedList<Object>();
+ result.addAll(convertDateToString(function));
+ result.add(' ');
+ result.addAll(convertTimeToString(function));
+ return result;
}
@Override
@@ -365,4 +369,15 @@
}
super.bindValue(stmt, param, paramType, i);
}
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "CAST('" + formatDateValue(timestampValue) +"' AS
DATETIME)"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "CAST('" + formatDateValue(dateValue) +"' AS
DATE)"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
Copied: trunk/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi (from rev
2654, branches/7.1.x/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi
(rev 0)
+++ trunk/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi 2010-10-19
15:39:47 UTC (rev 2659)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:diagram="http://www.metamatrix.com/metamodels/Diagram"
xmlns:mmcore="http://www.metamatrix.com/metamodels/Core"
xmlns:mmfunction="http://www.metamatrix.com/metamodels/MetaMatrixFun...
+ <mmcore:ModelAnnotation
xmi:uuid="mmuuid:ab62e724-42e6-4dc3-a79b-b232e388b2a4"
primaryMetamodelUri="http://www.metamatrix.com/metamodels/MetaMatrix...
modelType="FUNCTION" ProducerName="Teiid Designer"
ProducerVersion="7.1.0.v20100829-1858-H223-M2"/>
+ <diagram:DiagramContainer
xmi:uuid="mmuuid:e34ae0e1-b34f-4889-9a64-3bdcc9d82411">
+ <diagram xmi:uuid="mmuuid:f4269ae0-b411-4b34-b051-5186948278af"
type="packageDiagramType"
target="mmuuid/ab62e724-42e6-4dc3-a79b-b232e388b2a4">
+ <diagramEntity xmi:uuid="mmuuid:056149af-ef62-4a02-9497-430ec4748dc5"
name="JCR_ISCHILDNODE"
modelObject="mmuuid/ecf2b4a4-40fe-4cab-b84a-93a26c0560c7"
xPosition="20" yPosition="20"/>
+ <diagramEntity xmi:uuid="mmuuid:540e49b4-9034-4de6-bcb6-8c30f2bc6fd6"
name="JCR_ISDESCENDANTNODE"
modelObject="mmuuid/6387763f-0397-4abc-a2ca-46c9c0f793bd"
xPosition="40" yPosition="30"/>
+ <diagramEntity xmi:uuid="mmuuid:87c6912c-78eb-4e60-a0b5-1b0cb0c2a368"
name="JCR_ISSAMENODE"
modelObject="mmuuid/4ecc9ba6-a383-4196-a261-1860cc3ee88c"
xPosition="60" yPosition="40"/>
+ <diagramEntity xmi:uuid="mmuuid:12901a36-f796-4ed1-8dba-68a4493abffb"
name="JCR_CONTAINS"
modelObject="mmuuid/a84444b6-79b4-45bc-97bf-745503dabc03"
xPosition="80" yPosition="50"/>
+ <diagramEntity xmi:uuid="mmuuid:e3725579-e657-455f-845b-ddd1c5690ff8"
name="JCR_REFERENCE"
modelObject="mmuuid/c562c350-eaf8-4992-a9c0-5450ef188761"
xPosition="100" yPosition="60"/>
+ </diagram>
+ </diagram:DiagramContainer>
+ <mmcore:AnnotationContainer
xmi:uuid="mmuuid:c3c82dbf-1339-4354-b23d-7135aa430b21"/>
+ <mmfunction:ScalarFunction
xmi:uuid="mmuuid:ecf2b4a4-40fe-4cab-b84a-93a26c0560c7"
name="JCR_ISCHILDNODE" category="JCR"
pushDown="REQUIRED">
+ <inputParameters xmi:uuid="mmuuid:23fd3fce-de13-4b11-957d-a44c2ac6da43"
name="path" type="string"/>
+ <inputParameters xmi:uuid="mmuuid:68bafab4-98f7-472d-81cb-38e6bf2aa096"
name="path" type="string"/>
+ <returnParameter xmi:uuid="mmuuid:151394ed-8654-4e9a-a081-f3bf02b71b2d"
type="boolean"/>
+ </mmfunction:ScalarFunction>
+ <mmfunction:ScalarFunction
xmi:uuid="mmuuid:6387763f-0397-4abc-a2ca-46c9c0f793bd"
name="JCR_ISDESCENDANTNODE" category="JCR"
pushDown="REQUIRED">
+ <inputParameters xmi:uuid="mmuuid:c3a1f10b-58a5-4c5b-a94f-bac009b31284"
name="path" type="string"/>
+ <inputParameters xmi:uuid="mmuuid:403500a9-f48b-4603-8d92-2011944baa9d"
name="path" type="string"/>
+ <returnParameter xmi:uuid="mmuuid:ae90df19-106a-481d-b905-68a9c2493316"
type="boolean"/>
+ </mmfunction:ScalarFunction>
+ <mmfunction:ScalarFunction
xmi:uuid="mmuuid:4ecc9ba6-a383-4196-a261-1860cc3ee88c"
name="JCR_ISSAMENODE" category="JCR"
pushDown="REQUIRED">
+ <inputParameters xmi:uuid="mmuuid:94a8a68c-4744-4cdb-9ad8-23417e5aff56"
name="path" type="string"/>
+ <inputParameters xmi:uuid="mmuuid:004473ae-2199-43d0-b4bd-fd996fa18b7b"
name="path" type="string"/>
+ <returnParameter xmi:uuid="mmuuid:8ab20d78-fd6a-400a-9e03-70be996b4cc6"
type="boolean"/>
+ </mmfunction:ScalarFunction>
+ <mmfunction:ScalarFunction
xmi:uuid="mmuuid:a84444b6-79b4-45bc-97bf-745503dabc03"
name="JCR_CONTAINS" category="JCR" pushDown="REQUIRED">
+ <inputParameters xmi:uuid="mmuuid:ae2e922c-bd03-4f02-9e23-2f50fc88c497"
name="selectorOrProperty" type="string"/>
+ <inputParameters xmi:uuid="mmuuid:10e90221-2ffc-4145-ae3b-494384b823d3"
name="searchExpr" type="string"/>
+ <returnParameter xmi:uuid="mmuuid:dab3ded9-9fbf-458f-ade5-4e77b010022b"
type="boolean"/>
+ </mmfunction:ScalarFunction>
+ <mmfunction:ScalarFunction
xmi:uuid="mmuuid:c562c350-eaf8-4992-a9c0-5450ef188761"
name="JCR_REFERENCE" category="JCR" pushDown="REQUIRED">
+ <inputParameters xmi:uuid="mmuuid:aa8e27e8-3fc9-46b9-9c1a-c407af6ee5a6"
name="selectorOrProperty" type="string"/>
+ <returnParameter xmi:uuid="mmuuid:d9de7a7d-a84e-4775-9931-5516f4a1a940"
type="string"/>
+ </mmfunction:ScalarFunction>
+</xmi:XMI>
Deleted:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc;
-
-import static org.junit.Assert.assertEquals;
-import junit.framework.Assert;
-
-import org.mockito.Mockito;
-import org.teiid.cdk.api.TranslationUtility;
-import org.teiid.cdk.unittest.FakeTranslationFactory;
-import org.teiid.language.Command;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.ExecutionContext;
-
-
-public class FakeMetadataFactory {
-
- public static final String PARTS_VDB = "/PartsSupplier.vdb"; //$NON-NLS-1$
- public static final String BQT_VDB = "/bqt.vdb"; //$NON-NLS-1$
-
- public static Command helpTranslate(String vdbFileName, String sql) {
- TranslationUtility util = null;
- if (PARTS_VDB.equals(vdbFileName)) {
- util = new TranslationUtility(FakeMetadataFactory.class.getResource(vdbFileName));
- } else if (BQT_VDB.equals(vdbFileName)){
- util = FakeTranslationFactory.getInstance().getBQTTranslationUtility();
- } else {
- Assert.fail("unknown vdb"); //$NON-NLS-1$
- }
- return util.parseCommand(sql);
- }
-
- public static void helpTestVisitor(String vdb, String input, String expectedOutput,
JDBCExecutionFactory translator) throws TranslatorException {
- // Convert from sql to objects
- Command obj = helpTranslate(vdb, input);
-
- TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class),
translator);
- tc.translateCommand(obj);
-
- // Check stuff
- assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
//$NON-NLS-1$
- }
-
-}
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -377,9 +377,9 @@
}
@Test public void testVisitISelectWithComment() throws Exception {
- String expected = "SELECT /*teiid sessionid:ConnectionID,
requestid:RequestID.PartID*/ g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4
WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >=
200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC"; //$NON-NLS-1$
+ String expected = "SELECT /*teiid sessionid:ConnectionID,
requestid:RequestID.PartID*/ g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4
WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >=
200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestQueryImpl.example(false)));
- expected = "SELECT /*teiid sessionid:ConnectionID,
requestid:RequestID.PartID*/ DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias,
g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100
>= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC"; //$NON-NLS-1$
+ expected = "SELECT /*teiid sessionid:ConnectionID,
requestid:RequestID.PartID*/ DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias,
g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100
>= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC";
//$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestQueryImpl.example(true)));
}
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -51,7 +51,7 @@
return helpTranslate(vdbFileName, null, sql);
}
- public static Command helpTranslate(String vdbFileName, String udf, String sql) {
+ public static TranslationUtility getTranslationUtility(String vdbFileName, String
udf) {
TranslationUtility util = null;
if (PARTS_VDB.equals(vdbFileName)) {
util = new TranslationUtility(TranslationHelper.class.getResource(vdbFileName));
@@ -62,16 +62,24 @@
}
if (udf != null) {
- try {
- Collection <FunctionMethod> methods =
FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream());
- util.setUDF(methods);
- } catch (IOException e) {
- throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
- } catch (JAXBException e) {
- throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
- }
+ loadUDFs(udf, util);
}
- return util.parseCommand(sql);
+ return util;
+ }
+
+ public static void loadUDFs(String udf, TranslationUtility util) {
+ try {
+ Collection <FunctionMethod> methods =
FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream());
+ util.setUDF(methods);
+ } catch (IOException e) {
+ throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
+ } catch (JAXBException e) {
+ throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
+ }
+ }
+
+ public static Command helpTranslate(String vdbFileName, String udf, String sql) {
+ return getTranslationUtility(vdbFileName, udf).parseCommand(sql);
}
public static void helpTestVisitor(String vdb, String input, String expectedOutput,
JDBCExecutionFactory translator) throws TranslatorException {
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/modeshape/TestModeShapeSqlTranslator.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/modeshape/TestModeShapeSqlTranslator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/modeshape/TestModeShapeSqlTranslator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,18 +22,21 @@
package org.teiid.translator.jdbc.modeshape;
-import static org.junit.Assert.assertEquals;
+import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.mockito.Mockito;
import org.teiid.cdk.api.TranslationUtility;
-import org.teiid.core.util.UnitTestUtil;
import org.teiid.language.Command;
-import org.teiid.language.LanguageFactory;
-import org.teiid.translator.ExecutionContext;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
+import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.jdbc.TranslatedCommand;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.TranslationHelper;
/**
*/
@@ -41,67 +44,66 @@
public class TestModeShapeSqlTranslator {
private static ModeShapeExecutionFactory TRANSLATOR;
+ private static TranslationUtility UTIL;
+ private static String UDF = "/JCRFunctions.xmi"; //$NON-NLS-1$;
- private static String MODESHAPE_VDB = (UnitTestUtil.getTestDataPath() != null ?
UnitTestUtil
- .getTestDataPath()
- : "src/test/resources")
- + "/ModeShape.vdb";
-
-
@BeforeClass
public static void setUp() throws TranslatorException {
TRANSLATOR = new ModeShapeExecutionFactory();
TRANSLATOR.setUseBindVariables(false);
TRANSLATOR.start();
-
+ UTIL = new TranslationUtility(getMetadata());
+ TranslationHelper.loadUDFs(UDF, UTIL);
}
+
+ public static TransformationMetadata getMetadata() {
+ MetadataStore store = new MetadataStore();
+ Schema modeshape = RealMetadataFactory.createPhysicalModel("modeshape",
store);
+ Table nt_base = RealMetadataFactory.createPhysicalGroup("nt_base",
modeshape);
+ nt_base.setNameInSource("\"nt:base\"");
+ List<Column> cols = RealMetadataFactory.createElements(nt_base, new String[] {
"mode_path",
+ "mode_properties", "jcr_primaryType", "prop" }, new
String[] {
+ TypeFacility.RUNTIME_NAMES.STRING,
+ TypeFacility.RUNTIME_NAMES.STRING,
+ TypeFacility.RUNTIME_NAMES.STRING,
+ TypeFacility.RUNTIME_NAMES.STRING });
+ cols.get(0).setNameInSource("\"mode:path\"");
+ cols.get(1).setNameInSource("\"mode:properties\"");
+ cols.get(2).setNameInSource("\"jcr:primaryType\"");
+ return RealMetadataFactory.createTransformationMetadata(store,
"modeshape");
+ }
- public void helpTestVisitor(TranslationUtility util, String input,
- String expectedOutput) throws TranslatorException {
- // Convert from sql to objects
- Command obj = util.parseCommand(input);
-
- TranslatedCommand tc = new TranslatedCommand(Mockito
- .mock(ExecutionContext.class), TRANSLATOR);
- tc.translateCommand(obj);
- assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
//$NON-NLS-1$
+ public void helpTestVisitor(String input, String expectedOutput) throws
TranslatorException {
+ Command obj = UTIL.parseCommand(input, true, true);
+ TranslationHelper.helpTestVisitor(expectedOutput, TRANSLATOR, obj);
}
@Test
public void testSelectAllFromBase() throws Exception {
String input = "select * from nt_base"; //$NON-NLS-1$
- String output = "SELECT [jcr:primaryType] FROM [nt:base]"; //$NON-NLS-1$
+ String output = "SELECT g_0.\"mode:path\",
g_0.\"mode:properties\", g_0.\"jcr:primaryType\", g_0.prop FROM
\"nt:base\" AS g_0"; //$NON-NLS-1$
- helpTestVisitor(new TranslationUtility(MODESHAPE_VDB), input, output);
+ helpTestVisitor(input, output);
}
@Test
- public void testSelectColumnFromBase() throws Exception {
- String input = "select jcr_primaryType from nt_base"; //$NON-NLS-1$
- String output = "SELECT [jcr:primaryType] FROM [nt:base]"; //$NON-NLS-1$
+ public void testPredicate() throws Exception {
- helpTestVisitor(new TranslationUtility(MODESHAPE_VDB), input, output);
+ String input = "SELECT x.jcr_primaryType from nt_base inner join nt_base as x on
jcr_issamenode(nt_base.mode_path, x.mode_path) = true where
jcr_isdescendantnode(nt_base.mode_path, 'x/y/z') = true and
jcr_reference(nt_base.mode_properties) = 'x'"; //$NON-NLS-1$
+ String output = "SELECT g_1.\"jcr:primaryType\" FROM
\"nt:base\" AS g_0 INNER JOIN \"nt:base\" AS g_1 ON issamenode(g_0,
g_1) WHERE isdescendantnode(g_0, 'x/y/z') AND reference(g_0.*) =
'x'"; //$NON-NLS-1$
- }
+ helpTestVisitor(input, output);
- @Test
- public void testWhereClause() throws Exception {
-
- String input = "SELECT jcr_primaryType from nt_base WHERE jcr_primaryType =
'relational:column'"; //$NON-NLS-1$
- String output = "SELECT [jcr:primaryType] FROM [nt:base] WHERE [jcr:primaryType] =
'relational:column'"; //$NON-NLS-1$
-
- helpTestVisitor(new TranslationUtility(MODESHAPE_VDB), input, output);
-
}
@Test
public void testOrderBy() throws Exception {
String input = "SELECT jcr_primaryType from nt_base ORDER BY
jcr_primaryType"; //$NON-NLS-1$
- String output = "SELECT [jcr:primaryType] FROM [nt:base] ORDER BY
[jcr:primaryType] ASC"; //$NON-NLS-1$
+ String output = "SELECT g_0.\"jcr:primaryType\" AS c_0 FROM
\"nt:base\" AS g_0 ORDER BY c_0"; //$NON-NLS-1$
- helpTestVisitor(new TranslationUtility(MODESHAPE_VDB), input, output);
+ helpTestVisitor(input, output);
}
@@ -109,12 +111,10 @@
public void testUsingLike() throws Exception {
String input = "SELECT jcr_primaryType from nt_base WHERE jcr_primaryType LIKE
'%relational%'"; //$NON-NLS-1$
- String output = "SELECT [jcr:primaryType] FROM [nt:base] WHERE [jcr:primaryType]
LIKE '%relational%'"; //$NON-NLS-1$
+ String output = "SELECT g_0.\"jcr:primaryType\" FROM
\"nt:base\" AS g_0 WHERE g_0.\"jcr:primaryType\" LIKE
'%relational%'"; //$NON-NLS-1$
- helpTestVisitor(new TranslationUtility(MODESHAPE_VDB), input, output);
+ helpTestVisitor(input, output);
}
-
-
}
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -487,11 +487,11 @@
// Source = TIME
@Test public void testTimeToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59),
java.sql.Time.class), "string", "to_char({ts '1970-01-01
23:59:59'}, 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59),
java.sql.Time.class), "string", "to_char(to_date('1970-01-01
23:59:59', 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS')");
//$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTimeToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59),
java.sql.Time.class), "timestamp", "cast({ts '1970-01-01 23:59:59'}
AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59),
java.sql.Time.class), "timestamp", "cast(to_date('1970-01-01
23:59:59', 'YYYY-MM-DD HH24:MI:SS') AS timestamp)"); //$NON-NLS-1$
//$NON-NLS-2$
}
// Source = TIMESTAMP
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -559,7 +559,7 @@
helpTestVisitor(getTestVDB(),
"select {t '13:59:59'} FROM parts", //$NON-NLS-1$
null,
- "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS");
//$NON-NLS-1$
+ "SELECT to_date('1970-01-01 13:59:59', 'YYYY-MM-DD
HH24:MI:SS') FROM PARTS"); //$NON-NLS-1$
}
@Test public void testTimestampLiteral() throws Exception {
@@ -722,7 +722,7 @@
RealMetadataFactory.createElements(dual, new String[] {"something"},
new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
- return new TransformationMetadata(null, store, null, null);
+ return new TransformationMetadata(null, store, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
}
public void helpTestVisitor(String vdb, String input, String expectedOutput) throws
TranslatorException {
@@ -731,7 +731,7 @@
@Test public void testLimitWithNestedInlineView() throws Exception {
String input = "select max(intkey), stringkey from (select intkey, stringkey
from bqt1.smalla order by intkey limit 100) x group by stringkey"; //$NON-NLS-1$
- String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM
(SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY intkey) WHERE ROWNUM <=
100) x GROUP BY x.stringkey"; //$NON-NLS-1$
+ String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM
(SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY SmallA.IntKey) WHERE ROWNUM
<= 100) x GROUP BY x.stringkey"; //$NON-NLS-1$
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -36,6 +36,7 @@
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.jdbc.TranslationHelper;
@@ -158,7 +159,7 @@
obj.setNativeType("uniqueidentifier"); //$NON-NLS-1$
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
- QueryMetadataInterface metadata = new TransformationMetadata(null, store, null,
null);
+ QueryMetadataInterface metadata = new TransformationMetadata(null, store, null,
null, FakeMetadataFactory.SFM.getSystemFunctions());
TranslationUtility tu = new TranslationUtility(metadata);
Command command = tu.parseCommand("select max(x) from bar");
//$NON-NLS-1$
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -105,7 +105,7 @@
LANG_FACTORY.createLiteral("date", String.class)},
//$NON-NLS-1$
java.sql.Date.class);
- helpGetString1(func, "cast(stuff(stuff(convert(varchar, {ts '1989-03-03
07:08:12.0'}, 102), 5, 1, '-'), 8, 1, '-') AS datetime)");
//$NON-NLS-1$
+ helpGetString1(func, "cast(stuff(stuff(convert(varchar,
CAST('1989-03-03 07:08:12.0' AS DATETIME), 102), 5, 1, '-'), 8, 1,
'-') AS datetime)"); //$NON-NLS-1$
}
/********************END of cast(date AS INPUT) ******************/
@@ -129,7 +129,7 @@
LANG_FACTORY.createLiteral("time", String.class)},
//$NON-NLS-1$
java.sql.Time.class);
- helpGetString1(func, "cast('1970-01-01 ' + convert(varchar, {ts
'1989-03-03 07:08:12.0'}, 8) AS datetime)"); //$NON-NLS-1$
+ helpGetString1(func, "cast('1970-01-01 ' + convert(varchar,
CAST('1989-03-03 07:08:12.0' AS DATETIME), 8) AS datetime)"); //$NON-NLS-1$
}
/********************END of cast(time AS INPUT) ******************/
@@ -152,7 +152,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)},
//$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "{ts '1970-01-01 12:02:03'}");
//$NON-NLS-1$
+ helpGetString1(func, "CAST('1970-01-01 12:02:03.0' AS
DATETIME)"); //$NON-NLS-1$
}
@Test public void testDateToTimestamp() throws Exception {
@@ -162,7 +162,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)},
//$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "{d '1989-03-03'}"); //$NON-NLS-1$
+ helpGetString1(func, "CAST('1989-03-03' AS DATE)");
//$NON-NLS-1$
}
/********************END of cast(timestamp AS INPUT) ******************/
@@ -185,7 +185,7 @@
LANG_FACTORY.createLiteral("string", String.class)},
//$NON-NLS-1$
String.class);
- helpGetString1(func, "stuff(convert(varchar, {ts '2003-11-01
12:05:02.0'}, 123), 11, 1, ' ')"); //$NON-NLS-1$
+ helpGetString1(func, "stuff(stuff(convert(varchar, CAST('2003-11-01
12:05:02.0' AS DATETIME), 102), 5, 1, '-'), 8, 1, '-')
convert(varchar, CAST('2003-11-01 12:05:02.0' AS DATETIME), 8)");
//$NON-NLS-1$
}
@Test public void testDateToString() throws Exception {
@@ -196,7 +196,7 @@
LANG_FACTORY.createLiteral("string", String.class)},
//$NON-NLS-1$
String.class);
- helpGetString1(func, "stuff(stuff(convert(varchar, {d
'2003-11-01'}, 102), 5, 1, '-'), 8, 1, '-')");
//$NON-NLS-1$
+ helpGetString1(func, "stuff(stuff(convert(varchar,
CAST('2003-11-01' AS DATE), 102), 5, 1, '-'), 8, 1, '-')");
//$NON-NLS-1$
}
@Test public void testTimeToString() throws Exception {
@@ -207,7 +207,7 @@
LANG_FACTORY.createLiteral("string", String.class)},
//$NON-NLS-1$
String.class);
- helpGetString1(func, "convert(varchar, {ts '1970-01-01 03:10:01'},
8)"); //$NON-NLS-1$
+ helpGetString1(func, "convert(varchar, CAST('1970-01-01 03:10:01.0'
AS DATETIME), 8)"); //$NON-NLS-1$
}
@Test public void testBigDecimalToString() throws Exception {
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -189,21 +189,21 @@
public void testDateLiteral() {
helpTestVisitor(getTestVDB(),
"select {d '2002-12-31'} FROM parts", //$NON-NLS-1$
- "SELECT {d '2002-12-31'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT CAST('2002-12-31' AS DATE) FROM PARTS");
//$NON-NLS-1$
}
@Test
public void testTimeLiteral() {
helpTestVisitor(getTestVDB(),
"select {t '13:59:59'} FROM parts", //$NON-NLS-1$
- "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS");
//$NON-NLS-1$
+ "SELECT CAST('1970-01-01 13:59:59.0' AS DATETIME) FROM
PARTS"); //$NON-NLS-1$
}
@Test
public void testTimestampLiteral() {
helpTestVisitor(getTestVDB(),
"select {ts '2002-12-31 13:59:59'} FROM parts",
//$NON-NLS-1$
- "SELECT {ts '2002-12-31 13:59:59.0'} FROM PARTS");
//$NON-NLS-1$
+ "SELECT CAST('2002-12-31 13:59:59.0' AS DATETIME) FROM
PARTS"); //$NON-NLS-1$
}
@Test
Deleted: trunk/connectors/translator-jdbc/src/test/resources/ModeShape.vdb
===================================================================
(Binary files differ)
Modified:
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
===================================================================
---
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -47,6 +47,7 @@
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.ldap.IQueryToLdapSearchParser;
@@ -303,7 +304,7 @@
}
// Create the facade from the store
- return new TransformationMetadata(null, new
CompositeMetadataStore(metadataStore), null, null);
+ return new TransformationMetadata(null, new
CompositeMetadataStore(metadataStore), null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
}
}
Modified:
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
===================================================================
---
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -186,8 +186,7 @@
}
resultBatch = new ArrayList<List<Object>>();
- for(int resultIndex = 0; resultIndex < results.getSize(); resultIndex++) {
- SObject sObject = results.getRecords().get(resultIndex);
+ for(SObject sObject : results.getRecords()) {
List<Object[]> result = getObjectData(sObject);
for(Iterator<Object[]> i = result.iterator(); i.hasNext(); ) {
resultBatch.add(Arrays.asList(i.next()));
Modified:
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
===================================================================
---
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -38,6 +38,7 @@
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.salesforce.execution.visitors.JoinQueryVisitor;
import org.teiid.translator.salesforce.execution.visitors.SelectVisitor;
@@ -95,7 +96,7 @@
Column obj = contactCols.get(i);
obj.setNameInSource(contactNameInSource[i]);
}
- return new TransformationMetadata(null, new CompositeMetadataStore(store), null,
null);
+ return new TransformationMetadata(null, new CompositeMetadataStore(store), null,
null, FakeMetadataFactory.SFM.getSystemFunctions());
}
private static TranslationUtility translationUtility = new
TranslationUtility(exampleSalesforce());
Modified: trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -64,63 +64,80 @@
public class DQPManagementView implements PluginConstants {
private static ManagedComponent mc = null;
- private static final Log LOG =
LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- private static final MetaValueFactory metaValueFactory =
MetaValueFactory.getInstance();
-
- private static final String VDB_EXT = ".vdb";
+ private static final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private static final MetaValueFactory metaValueFactory = MetaValueFactory
+ .getInstance();
+ private static final String VDB_EXT = ".vdb"; //$NON-NLS-1$
+
public DQPManagementView() {
}
/*
* Metric methods
*/
- public Object getMetric(ProfileServiceConnection connection, String componentType,
String identifier, String metric, Map<String, Object> valueMap) {
+ public Object getMetric(ProfileServiceConnection connection,
+ String componentType, String identifier, String metric,
+ Map<String, Object> valueMap) {
Object resultObject = new Object();
if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
- resultObject = getPlatformMetric(connection, componentType, metric, valueMap);
+ resultObject = getPlatformMetric(connection, componentType, metric,
+ valueMap);
} else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
- resultObject = getVdbMetric(connection, componentType, identifier,metric, valueMap);
+ resultObject = getVdbMetric(connection, componentType, identifier,
+ metric, valueMap);
}
return resultObject;
}
- private Object getPlatformMetric(ProfileServiceConnection connection, String
componentType, String metric,
- Map<String, Object> valueMap) {
+ private Object getPlatformMetric(ProfileServiceConnection connection,
+ String componentType, String metric, Map<String, Object> valueMap) {
Object resultObject = new Object();
- if (metric .equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+ if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
resultObject = new Double(getQueryCount(connection).doubleValue());
- } else if
(metric .equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+ } else if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
resultObject = new Double(getSessionCount(connection).doubleValue());
- } else if
(metric .equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
- Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(connection), longRunningQueries);
- resultObject = new Double(longRunningQueries.size());
- } else if (metric.equals(PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE))
{
+ } else if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+ Collection<Request> longRunningQueries = new ArrayList<Request>();
+ getRequestCollectionValue(getLongRunningQueries(connection),
+ longRunningQueries);
+ resultObject = new Double(longRunningQueries.size());
+ } else if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE)) {
try {
- resultObject = ProfileServiceUtil.doubleValue(getUsedBufferSpace(connection));
+ resultObject = ProfileServiceUtil
+ .doubleValue(getUsedBufferSpace(connection));
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_BUFFER_USAGE; //$NON-NLS-1$
LOG.error(msg, e);
}
- } else if (metric.startsWith(Admin.Cache.PREPARED_PLAN_CACHE.toString()+".")
//$NON-NLS-1$
- ||
metric.startsWith(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString()+".")) {
//$NON-NLS-1$
+ } else if (metric.startsWith(Admin.Cache.PREPARED_PLAN_CACHE.toString()
+ + ".") //$NON-NLS-1$
+ || metric.startsWith(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE
+ .toString()
+ + ".")) { //$NON-NLS-1$
return getCacheProperty(connection, metric);
}
return resultObject;
}
-
- private Object getCacheProperty(ProfileServiceConnection connection, String metric) {
+
+ private Object getCacheProperty(ProfileServiceConnection connection,
+ String metric) {
int dotIndex = metric.indexOf('.');
String cacheType = metric.substring(0, dotIndex);
- String property = metric.substring(dotIndex+1);
- CompositeValueSupport mv = (CompositeValueSupport)getCacheStats(connection, cacheType);
- MetaValue v = mv.get(property);
- return ((SimpleValue)v).getValue();
+ String property = metric.substring(dotIndex + 1);
+ CompositeValueSupport mv = (CompositeValueSupport) getCacheStats(
+ connection, cacheType);
+ MetaValue v = mv.get(property);
+ return ((SimpleValue) v).getValue();
}
private Object getVdbMetric(ProfileServiceConnection connection,
@@ -129,19 +146,27 @@
Object resultObject = new Object();
- if (metric .equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
+ if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getErrorCount(connection, (String) valueMap.get(VDB.NAME));
- } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
+ resultObject = getErrorCount(connection, (String) valueMap
+ .get(VDB.NAME));
+ } else if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getVDBStatus(connection, (String) valueMap.get(VDB.NAME));
- } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
+ resultObject = getVDBStatus(connection, (String) valueMap
+ .get(VDB.NAME));
+ } else if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
resultObject = new Double(getQueryCount(connection).doubleValue());
- } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
+ } else if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
resultObject = new Double(getSessionCount(connection).doubleValue());
- } else if
(metric.equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
+ } else if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(connection), longRunningQueries);
+ getRequestCollectionValue(getLongRunningQueries(connection),
+ longRunningQueries);
resultObject = new Double(longRunningQueries.size());
}
return resultObject;
@@ -151,12 +176,17 @@
* Operation methods
*/
- public void executeOperation(ProfileServiceConnection connection, ExecutedResult
operationResult, final Map<String, Object> valueMap) {
+ public void executeOperation(ProfileServiceConnection connection,
+ ExecutedResult operationResult, final Map<String, Object> valueMap) {
- if
(operationResult.getComponentType().equals(PluginConstants.ComponentType.Platform.NAME))
{
- executePlatformOperation(connection,
operationResult, operationResult.getOperationName(), valueMap);
- } else if
(operationResult.getComponentType().equals( PluginConstants.ComponentType.VDB.NAME)) {
- executeVdbOperation(connection, operationResult, operationResult .getOperationName(),
valueMap);
+ if (operationResult.getComponentType().equals(
+ PluginConstants.ComponentType.Platform.NAME)) {
+ executePlatformOperation(connection, operationResult,
+ operationResult.getOperationName(), valueMap);
+ } else if (operationResult.getComponentType().equals(
+ PluginConstants.ComponentType.VDB.NAME)) {
+ executeVdbOperation(connection, operationResult, operationResult
+ .getOperationName(), valueMap);
}
}
@@ -199,8 +229,9 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
- Platform.Operations.KILL_TRANSACTION, args);
+ executeManagedOperation(connection, getRuntimeEngineDeployer(
+ connection, mc), Platform.Operations.KILL_TRANSACTION,
+ args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_TRANSACTION; //$NON-NLS-1$
LOG.error(msg, e);
@@ -210,8 +241,8 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
- Platform.Operations.KILL_SESSION, args);
+ executeManagedOperation(connection, getRuntimeEngineDeployer(
+ connection, mc), Platform.Operations.KILL_SESSION, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_SESSION; //$NON-NLS-1$
LOG.error(msg, e);
@@ -223,31 +254,35 @@
metaValueFactory.create(requestID),
metaValueFactory.create(sessionID) };
try {
- executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
- Platform.Operations.KILL_REQUEST, args);
+ executeManagedOperation(connection, getRuntimeEngineDeployer(
+ connection, mc), Platform.Operations.KILL_REQUEST, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_REQUEST; //$NON-NLS-1$
LOG.error(msg, e);
}
} else if (operationName.equals(Platform.Operations.DEPLOY_VDB_BY_URL)) {
String vdbUrl = (String) valueMap.get(Operation.Value.VDB_URL);
- String deployName = (String) valueMap.get(Operation.Value.VDB_DEPLOY_NAME);
+ String deployName = (String) valueMap
+ .get(Operation.Value.VDB_DEPLOY_NAME);
Object vdbVersion = valueMap.get(Operation.Value.VDB_VERSION);
- //strip off vdb extension if user added it
- if (deployName.endsWith(VDB_EXT)){
- deployName = deployName.substring(0, deployName.lastIndexOf(VDB_EXT));
+ // strip off vdb extension if user added it
+ if (deployName.endsWith(VDB_EXT)) {
+ deployName = deployName.substring(0, deployName
+ .lastIndexOf(VDB_EXT));
}
- if (vdbVersion!=null){
- deployName = deployName + "." + ((Integer)vdbVersion).toString() + VDB_EXT;
//$NON-NLS-1$
+ if (vdbVersion != null) {
+ deployName = deployName
+ + "." + ((Integer) vdbVersion).toString() + VDB_EXT; //$NON-NLS-1$
}
- //add vdb extension if there was no version
- if (!deployName.endsWith(VDB_EXT)){
- deployName = deployName + VDB_EXT;
+ // add vdb extension if there was no version
+ if (!deployName.endsWith(VDB_EXT)) {
+ deployName = deployName + VDB_EXT;
}
-
+
try {
URL url = new URL(vdbUrl);
- DeploymentUtils.deployArchive(deployName, connection.getDeploymentManager(), url,
false);
+ DeploymentUtils.deployArchive(deployName, connection
+ .getDeploymentManager(), url, false);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.DEPLOY_VDB_BY_URL; //$NON-NLS-1$
LOG.error(msg, e);
@@ -259,6 +294,7 @@
private void executeVdbOperation(ProfileServiceConnection connection,
ExecutedResult operationResult, final String operationName,
final Map<String, Object> valueMap) {
+ Collection<ArrayList<String>> sqlResultsObject = new
ArrayList<ArrayList<String>>();
Collection<Request> resultObject = new ArrayList<Request>();
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
String vdbName = (String) valueMap
@@ -285,6 +321,25 @@
getRequestCollectionValue(requestMetaValue, resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
+ } else if (operationName.equals(VDB.Operations.GET_MATVIEWS)) {
+ List<String> fieldNameList = operationResult.getFieldNameList();
+ MetaValue resultsMetaValue = executeMaterializedViewQuery(
+ connection, formatVdbName(vdbName), Integer
+ .parseInt(vdbVersion));
+ getResultsCollectionValue(resultsMetaValue, sqlResultsObject);
+ operationResult.setContent(createReportResultListForMatViewQuery(
+ fieldNameList, sqlResultsObject.iterator()));
+ } else if (operationName.equals(VDB.Operations.RELOAD_MATVIEW)) {
+ MetaValue resultsMetaValue = reloadMaterializedView(connection,
+ formatVdbName(vdbName), Integer.parseInt(vdbVersion),
+ (String) valueMap.get(Operation.Value.MATVIEW_SCHEMA),
+ (String) valueMap.get(Operation.Value.MATVIEW_TABLE),
+ (Boolean) valueMap.get(Operation.Value.INVALIDATE_MATVIEW));
+ if (resultsMetaValue==null) {
+ operationResult.setContent("failure - see log for details"); //$NON-NLS-1$
+ } else {
+ operationResult.setContent("data successfully refreshed!"); //$NON-NLS-1$
+ }
}
}
@@ -293,6 +348,11 @@
* Helper methods
*/
+ private String formatVdbName(String vdbName) {
+
+ return vdbName.substring(0, vdbName.indexOf(".")); //$NON-NLS-1$
+ }
+
public MetaValue getProperties(ProfileServiceConnection connection,
final String component) {
@@ -300,7 +360,8 @@
MetaValue args = null;
try {
- propertyValue = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ propertyValue = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
PluginConstants.Operation.GET_PROPERTIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_PROPERTIES; //$NON-NLS-1$
@@ -317,9 +378,10 @@
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ requestsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
- PluginConstants.Operation.GET_REQUESTS, args);
+ PluginConstants.Operation.GET_REQUESTS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_REQUESTS; //$NON-NLS-1$
LOG.error(msg, e);
@@ -329,6 +391,61 @@
}
+ protected MetaValue executeMaterializedViewQuery(
+ ProfileServiceConnection connection, String vdbName, int vdbVersion) {
+
+ MetaValue resultsCollection = null;
+ MetaValue[] args = new MetaValue[] {
+ MetaValueFactory.getInstance().create(vdbName),
+ MetaValueFactory.getInstance().create(vdbVersion),
+ MetaValueFactory.getInstance().create(
+ Operation.Value.MAT_VIEW_QUERY),
+ MetaValueFactory.getInstance()
+ .create(Long.parseLong("9999999")) }; //$NON-NLS-1$
+
+ try {
+ resultsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
+ VDB.Operations.EXECUTE_QUERIES, args);
+ } catch (Exception e) {
+ final String msg = "Exception executing operation: " +
VDB.Operations.EXECUTE_QUERIES; //$NON-NLS-1$
+ LOG.error(msg, e);
+ }
+
+ return resultsCollection;
+
+ }
+
+ protected MetaValue reloadMaterializedView(
+ ProfileServiceConnection connection, String vdbName,
+ int vdbVersion, String schema, String table, Boolean invalidate) {
+
+ MetaValue result = null;
+ String matView = schema + "." + table; //$NON-NLS-1$
+ String query = PluginConstants.Operation.Value.MAT_VIEW_REFRESH;
+ query = query.replace("param1", matView); //$NON-NLS-1$
+ query = query.replace("param2", invalidate.toString()); //$NON-NLS-1$
+ MetaValue[] args = new MetaValue[] {
+ MetaValueFactory.getInstance().create(vdbName),
+ MetaValueFactory.getInstance().create(vdbVersion),
+ MetaValueFactory.getInstance().create(query),
+ MetaValueFactory.getInstance()
+ .create(Long.parseLong("9999999")) }; //$NON-NLS-1$
+
+ try {
+ result = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
+ VDB.Operations.EXECUTE_QUERIES, args);
+ } catch (Exception e) {
+ final String msg = "Exception executing operation: " +
VDB.Operations.RELOAD_MATVIEW; //$NON-NLS-1$
+ LOG.error(msg, e);
+
+ }
+
+ return result;
+
+ }
+
protected MetaValue getRequestsForVDB(ProfileServiceConnection connection,
String vdbName, int vdbVersion) {
@@ -338,7 +455,8 @@
MetaValueFactory.getInstance().create(vdbVersion) };
try {
- requestsCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ requestsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
PluginConstants.ComponentType.VDB.Operations.GET_REQUESTS,
args);
} catch (Exception e) {
@@ -356,7 +474,8 @@
MetaValue args = null;
try {
- transactionsCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ transactionsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
Platform.Operations.GET_TRANSACTIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_TRANSACTIONS; //$NON-NLS-1$
@@ -373,7 +492,8 @@
MetaValue args = null;
try {
- sessionCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ sessionCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
PluginConstants.Operation.GET_SESSIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_SESSIONS; //$NON-NLS-1$
@@ -401,7 +521,7 @@
final String msg = "Exception in getVDBStatus(): " + e.getMessage();
//$NON-NLS-1$
LOG.error(msg, e);
}
-
+
if (mcVdb == null) {
return Status.INACTIVE.toString();
}
@@ -425,14 +545,14 @@
} catch (Exception e) {
final String msg = "Exception getting the AdminApi in " + operation;
//$NON-NLS-1$
LOG.error(msg, e);
+ throw new RuntimeException(e);
}
}
}
- throw new Exception("No operation found with given name =" + operation);
//$NON-NLS-1$
+ throw new Exception("No operation found with given name = " + operation);
//$NON-NLS-1$
}
-
/**
* @param mc
* @return
@@ -468,7 +588,7 @@
}
return mc;
}
-
+
public static MetaValue getManagedProperty(
ProfileServiceConnection connection, ManagedComponent mc,
String property) throws Exception {
@@ -481,10 +601,10 @@
LOG.error(msg, e);
}
- if (managedProperty!=null){
- return managedProperty.getValue();
+ if (managedProperty != null) {
+ return managedProperty.getValue();
}
-
+
throw new Exception("No property found with given name =" + property);
//$NON-NLS-1$
}
@@ -560,13 +680,18 @@
}
return count;
}
-
- protected MetaValue getCacheStats(ProfileServiceConnection connection, String type) {
+
+ protected MetaValue getCacheStats(ProfileServiceConnection connection,
+ String type) {
try {
- return executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
- Platform.Operations.GET_CACHE_STATS, SimpleValueSupport.wrap(type));
+ return executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
+ Platform.Operations.GET_CACHE_STATS, SimpleValueSupport
+ .wrap(type));
} catch (Exception e) {
- LOG.error("Exception executing operation: " +
Platform.Operations.GET_CACHE_STATS, e); //$NON-NLS-1$
+ LOG
+ .error(
+ "Exception executing operation: " + Platform.Operations.GET_CACHE_STATS,
e); //$NON-NLS-1$
}
return null;
}
@@ -578,7 +703,8 @@
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ requestsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
Platform.Operations.GET_LONGRUNNINGQUERIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_LONGRUNNINGQUERIES; //$NON-NLS-1$
@@ -588,14 +714,13 @@
return requestsCollection;
}
- protected MetaValue getUsedBufferSpace(
- ProfileServiceConnection connection) {
+ protected MetaValue getUsedBufferSpace(ProfileServiceConnection connection) {
MetaValue usedBufferSpace = null;
try {
- usedBufferSpace = getManagedProperty(connection, getBufferService(connection, mc),
- Platform.Operations.GET_BUFFER_USAGE);
+ usedBufferSpace = getManagedProperty(connection, getBufferService(
+ connection, mc), Platform.Operations.GET_BUFFER_USAGE);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_BUFFER_USAGE; //$NON-NLS-1$
LOG.error(msg, e);
@@ -603,32 +728,66 @@
return usedBufferSpace;
}
-
- private void getRequestCollectionValue(MetaValue pValue,Collection<Request> list)
{
+
+ private void getRequestCollectionValue(MetaValue pValue,
+ Collection<Request> list) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
if (value.getMetaType().isComposite()) {
RequestMetadataMapper rmm = new RequestMetadataMapper();
RequestMetadata request = rmm.unwrapMetaValue(value);
list.add(request);
} else {
- throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
+ throw new IllegalStateException(pValue
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
}
+ private void getResultsCollectionValue(MetaValue pValue,
+ Collection<ArrayList<String>> list) {
+ MetaType metaType = pValue.getMetaType();
+ if (metaType.isCollection()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
+ if (value.getMetaType().isCollection()) {
+ ArrayList<String> row = (ArrayList<String>) MetaValueFactory
+ .getInstance().unwrap(value);
+ list.add(row);
+ }
+ }
+ }
+ }
+
+ private void getResultsCollectionValueForMatViewRefresh(MetaValue pValue,
+ Collection<ArrayList<String>> list) {
+ MetaType metaType = pValue.getMetaType();
+ for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ if (value.getMetaType().isCollection()) {
+ ArrayList<String> row = (ArrayList<String>) MetaValueFactory
+ .getInstance().unwrap(value);
+ list.add(row);
+ }
+ }
+
+ }
+
public static <T> void getTransactionCollectionValue(MetaValue pValue,
Collection<Transaction> list) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
if (value.getMetaType().isComposite()) {
- Transaction transaction = (Transaction)
MetaValueFactory.getInstance().unwrap(value);
+ Transaction transaction = (Transaction) MetaValueFactory
+ .getInstance().unwrap(value);
list.add(transaction);
} else {
- throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
+ throw new IllegalStateException(pValue
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -638,12 +797,15 @@
Collection<Session> list) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
if (value.getMetaType().isComposite()) {
- Session Session = (Session) MetaValueFactory.getInstance().unwrap(value);
+ Session Session = (Session) MetaValueFactory.getInstance()
+ .unwrap(value);
list.add(Session);
} else {
- throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
+ throw new IllegalStateException(pValue
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -653,14 +815,17 @@
Collection<Session> list, String vdbName) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
if (value.getMetaType().isComposite()) {
- Session session = (Session) MetaValueFactory.getInstance().unwrap(value);
+ Session session = (Session) MetaValueFactory.getInstance()
+ .unwrap(value);
if (session.getVDBName().equals(vdbName)) {
list.add(session);
}
} else {
- throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
+ throw new IllegalStateException(pValue
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -693,4 +858,30 @@
return reportResultList;
}
+ private Collection createReportResultListForMatViewQuery(
+ List fieldNameList, Iterator objectIter) {
+ Collection reportResultList = new ArrayList();
+
+ // Iterate through rows
+ while (objectIter.hasNext()) {
+ ArrayList<Object> columnValues = (ArrayList<Object>) objectIter
+ .next();
+
+ Class cls = null;
+ try {
+ Iterator fieldIter = fieldNameList.iterator();
+ Map reportValueMap = new HashMap<String, Object>();
+ // Iterate through columns with a row
+ for (Object columnValue : columnValues) {
+ String fieldName = (String) fieldIter.next();
+ reportValueMap.put(fieldName, columnValue);
+ }
+ reportResultList.add(reportValueMap);
+ } catch (Throwable e) {
+ System.err.println(e);
+ }
+ }
+ return reportResultList;
+ }
+
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -82,7 +82,8 @@
*
*/
public class VDBComponent extends Facet {
- private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
/*
* (non-Javadoc)
@@ -122,8 +123,14 @@
} else if (name.equals(Platform.Operations.KILL_SESSION)) {
valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
Operation.Value.SESSION_ID).getLongValue());
+ } else if (name.equals(VDB.Operations.RELOAD_MATVIEW)) {
+ valueMap.put(Operation.Value.MATVIEW_SCHEMA, configuration.getSimple(
+ Operation.Value.MATVIEW_SCHEMA).getStringValue());
+ valueMap.put(Operation.Value.MATVIEW_TABLE, configuration.getSimple(
+ Operation.Value.MATVIEW_TABLE).getStringValue());
+ valueMap.put(Operation.Value.INVALIDATE_MATVIEW, configuration.getSimple(
+ Operation.Value.INVALIDATE_MATVIEW).getBooleanValue());
}
-
}
/*
@@ -134,9 +141,10 @@
@Override
public AvailabilityType getAvailability() {
// TODO Remove vdb version after no longer viable in Teiid
- String version = this.resourceConfiguration.getSimpleValue(
- "version", null);
- String status = DQPManagementView.getVDBStatus(getConnection(), this.name);
+ String version = this.resourceConfiguration.getSimpleValue("version",
+ null);
+ String status = DQPManagementView.getVDBStatus(getConnection(),
+ this.name);
if (status.equals("ACTIVE")) {
return AvailabilityType.UP;
}
@@ -165,8 +173,9 @@
String name = request.getName();
LOG.debug("Measurement name = " + name); //$NON-NLS-1$
- Object metricReturnObject = view.getMetric(getConnection(), getComponentType(), this
- .getComponentIdentifier(), name, valueMap);
+ Object metricReturnObject = view.getMetric(getConnection(),
+ getComponentType(), this.getComponentIdentifier(), name,
+ valueMap);
try {
if (request.getName().equals(
@@ -200,10 +209,11 @@
.getName()
.equals(
PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
- if (((String) metricReturnObject).equals("ACTIVE")) {
+ if (((String) metricReturnObject)
+ .equals("ACTIVE")) {
report.addData(new MeasurementDataTrait(
request, "UP"));
- }else{
+ } else {
report.addData(new MeasurementDataTrait(
request, "DOWN"));
}
@@ -350,7 +360,7 @@
ManagedComponent mcVdb = null;
try {
- mcVdb = ProfileServiceUtil.getManagedComponent( getConnection(),
+ mcVdb = ProfileServiceUtil.getManagedComponent(getConnection(),
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -371,8 +381,8 @@
"description", String.class);
String vdbStatus = ProfileServiceUtil.getSimpleValue(mcVdb, "status",
String.class);
- String connectionType = ProfileServiceUtil.getSimpleValue(mcVdb,
"connectionType",
- String.class);
+ String connectionType = ProfileServiceUtil.getSimpleValue(mcVdb,
+ "connectionType", String.class);
String vdbURL = ProfileServiceUtil.getSimpleValue(mcVdb, "url",
String.class);
@@ -614,7 +624,8 @@
new PropertySimple("type", translatorType),
new PropertySimple("propertyName", propertyName),
new PropertySimple("propertyValue", propertyValue));
- // Only want translator name and value to show up for the first row,
+ // Only want translator name and value to show up for the
+ // first row,
// so we will blank them out here.
translatorName = "";
translatorType = "";
@@ -655,10 +666,10 @@
@Override
public ProfileServiceConnection getConnection() {
- return
((PlatformComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ return ((PlatformComponent) this.resourceContext
+ .getParentResourceComponent()).getConnection();
}
-
@Override
public EmsConnection getEmsConnection() {
// TODO Auto-generated method stub
Modified:
trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
===================================================================
---
trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -134,6 +134,10 @@
.getPropertyDefinitions();
PropertyDefinition listPropDefinition = (PropertyDefinition) propDefs
.get(LISTNAME);
+
+ if (listPropDefinition == null) {
+ continue;
+ }
PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList)
listPropDefinition)
.getMemberDefinition();
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -97,13 +97,16 @@
public static interface Operations {
- public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
+ public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
+ public final static String EXECUTE_QUERIES = "executeQuery"; //$NON-NLS-1$
public final static String GET_LONGRUNNINGQUERIES =
"getLongRunningRequests"; //$NON-NLS-1$
public final static String KILL_REQUEST = "cancelRequest"; //$NON-NLS-1$
public final static String KILL_SESSION = "terminateSession";
//$NON-NLS-1$
public final static String GET_PROPERTIES = "getProperties"; //$NON-NLS-1$
public final static String GET_REQUESTS = "getRequestsUsingVDB";
//$NON-NLS-1$
public final static String GET_SESSIONS = "getSessions"; //$NON-NLS-1$
+ public final static String GET_MATVIEWS = "getMaterializedViews";
//$NON-NLS-1$
+ public final static String RELOAD_MATVIEW = "reloadMaterializedView";
//$NON-NLS-1$
}
@@ -227,7 +230,11 @@
* @since 1.0
*/
public static interface Value {
- public final static String STOP_NOW = "stopNow"; //$NON-NLS-1$
+ public final static String STOP_NOW = "stopNow"; //$NON-NLS-1$
+ public final static String MAT_VIEW_QUERY = "select SchemaName, Name,
TargetSchemaName, TargetName, " + //$NON-NLS-1$
+ "Valid, LoadState, Updated, Cardinality from SYSADMIN.MATVIEWS "
+ //$NON-NLS-1$
+ "where SchemaName != 'pg_catalog'"; //$NON-NLS-1$
+ public final static String MAT_VIEW_REFRESH = "exec
SYSADMIN.refreshMatView('param1','param2');"; //$NON-NLS-1$
public final static String WAIT_UNTIL_FINISHED = "waitUntilFinished";
//$NON-NLS-1$
public final static String INCLUDE_SOURCE_QUERIES = "includeSourceQueries";
//$NON-NLS-1$
@@ -243,6 +250,9 @@
public final static String VDB_VERSION = "vdbVersion"; //$NON-NLS-1$
public final static String NAME = "Name"; //$NON-NLS-1$
public final static String VALUE = "Value"; //$NON-NLS-1$
+ public final static String MATVIEW_SCHEMA = "schema"; //$NON-NLS-1$
+ public final static String MATVIEW_TABLE = "table"; //$NON-NLS-1$
+ public final static String INVALIDATE_MATVIEW = "invalidate"; //$NON-NLS-1$
}
Modified: trunk/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-18 19:03:20 UTC (rev
2658)
+++ trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-19 15:39:47 UTC (rev
2659)
@@ -469,6 +469,56 @@
</results>
</operation>
+ <operation name="getMaterializedViews" displayName="List
Materialized View Info"
+ description="List any Materialized Views for this VDB">
+
+ <results>
+
+ <c:list-property name="list" displayName="Materialized
Views"
+ description="List information related to Materialized Views, if any, for this
VDB"
+ required="false">
+ <c:map-property name="map">
+ <c:simple-property displayName="Schema Name"
+ name="schemaName" type="string" description="Name of the
schema that is materialized" />
+ <c:simple-property displayName="Name" name="name"
+ type="string" description="Name of the materialized table"
/>
+ <c:simple-property displayName="Target Schema Name"
+ name="targetSchemaName" type="string" description="Name
of the materialized schema" />
+ <c:simple-property displayName="Target Name"
+ name="targetName" type="string" description="Name of
target table" />
+ <c:simple-property displayName="Valid"
+ name="valid" type="string" description="Indicates if
data in table is valid for use" />
+ <c:simple-property displayName="Current State"
+ name="loadState" type="string" description="Processing
time for the request" />
+ <c:simple-property displayName="Last Updated"
+ name="updated" type="integer" description="Last time of
data refresh" />
+ <c:simple-property displayName="Cardinality"
+ name="cardinality" type="integer" description="Row
count" />
+ </c:map-property>
+ </c:list-property>
+ </results>
+ </operation>
+
+ <operation name="reloadMaterializedView" displayName="Refresh a
Materialized View"
+ description="Refresh a given any Materialized View for this VDB">
+ <parameters>
+ <c:simple-property displayName="Materialized View Schema"
+ name="schema" type="string" required="true"
+ description="The schema name of the Materialized View to refresh" />
+ <c:simple-property displayName="Materialized View Name"
+ name="table" type="string" required="true"
+ description="The name of the Materialized View to refresh" />
+ <c:simple-property displayName="Invalidate Current Materialized View
Table"
+ name="invalidate" type="boolean" required="true"
default="false"
+ description="If yes, will block all queries against the current Materialized
View table until data is refreshed." />
+ </parameters>
+
+ <results>
+ <c:simple-property displayName="Result"
name="operationResult"
+ type="string" description="Result of refresh" />
+ </results>
+ </operation>
+
<metric displayName="Status" defaultOn="true"
dataType="trait"
displayType="summary" category="availability"
property="status"
description="The status of this VDB" />
@@ -611,9 +661,8 @@
description="Indicates if the role is mapped to any authenticated user"
readOnly="false" required="false" />
<c:simple-property name="description"
- displayName="Description" type="string"
- description="Description of this data role"
- readOnly="true" required="false" />
+ displayName="Description" type="string"
description="Description of this data role"
+ readOnly="true" required="false" />
<c:list-property name="mappedRoleNameList"
readOnly="false" required="false" displayName="Mapped Role
Names"
description="Mapped role names for this data role">
@@ -633,9 +682,11 @@
createDeletePolicy="both" creationDataType="configuration">
<resource-configuration>
- <c:simple-property name="name" displayName="Name"
description="Name of the translator" readOnly="true"
required="false" />
- <c:simple-property name="description"
displayName="Description" description="Description the translator"
readOnly="true" required="false" />
-
+ <c:simple-property name="name" displayName="Name"
+ description="Name of the translator" readOnly="true"
required="false" />
+ <c:simple-property name="description"
displayName="Description"
+ description="Description the translator" readOnly="true"
required="false" />
+
<c:list-property name="translatorList" readOnly="true"
required="false" displayName="Properties"
description="Translator properties">
<c:map-property name="properties" readOnly="true">
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -79,13 +79,13 @@
Details of the failed attempt including invalid users, which
domains were consulted, etc. will be in the server log with appropriate
levels of severity.</para>
- <note>
- <para>The security-domain defined for the JDBC connection and Admin
connections are separate.
- The default name of JDBC connection's security-domain is
"teiid-security". The default name for Admin connection
- is "jmx-console". For the Admin connection's security domain,
the user is allowed
- to change which LoginModule that "jmx-console" pointing to, however
should not change the name of the domain, as this name is
- shared between the "admin-console" application.</para>
- </note>
+ <note>
+ <para>The security-domain defined for the JDBC connection and Admin
connections are separate.
+ The default name of JDBC connection's security-domain is
"teiid-security". The default name for Admin connection
+ is "jmx-console". For the Admin connection's security
domain, the user is allowed
+ to change which LoginModule that "jmx-console" pointing to,
however should not change the name of the domain, as this name is
+ shared between the "admin-console" application.</para>
+ </note>
<section>
<title>Built-in LoginModules</title>
@@ -93,14 +93,139 @@
<para>The UsersRolesLoginModule, which utilizes simple text files
to authenticate users and to define
their groups. The teiid-jboss-beans.xml configuration file contains an example of
how to use UsersRolesLoginModule.
- Note that this is typically not for production use.
+ Note that this is typically not for production use and is strongly recommended that
you replace this login module. Please
+ also note that, you can install multiple login modules as part of single
security domain configuration and configure them
+ to part of login process. For example, for "teiid-security"
domain, you can configure a file based and also LDAP based login modules,
+ and have your user authenticated with either both or single login module.
</para>
<para>See <ulink
url="http://community.jboss.org/docs/DOC-11253">LDAP LoginModule
configuration</ulink> for utilizing LDAP based authentication.
- If you want use a your own Custom Login module, check out the Developer's
Guide for instructions.
+ If you want write your own Custom Login module, check out the Developer's
Guide for instructions.
</para>
</section>
- </section>
+ <section>
+ <title>Security at Data Source level</title>
+ <para>In some use cases, user might need to pass-in different
credentials to their data sources based on the logged in user
+ than using the shared credentials for all the logged users. To support this
feature, JBoss AS and Teiid provide multiple different
+ login modules to be used in conjunction with Teiid's main security
domain. See this
+ <ulink
url="http://community.jboss.org/docs/DOC-9350">document</... for
details on configuration. Note that the below
+ directions need to be used in conjunction with this document.</para>
+
+ <section>
+ <title>CallerIdentity and Trusted Payload</title>
+ <para>If client wants to pass in simple text password or a
certificate or a custom serialized object
+ as token credential to the data source, user can configure
"CallerIdentity" login module.
+ Using this login module, user can pass-in same credential that user
logged into Teiid security domain to the
+ data source. Here is a sample configuration, this needs to be configured
in "teiid-jboss-beans.xml" file.
+ </para>
+
+ <programlisting><![CDATA[
+ <application-policy xmlns="urn:jboss:security-beans:1.0"
name="teiid-security">
+ <authentication>
+
+ <login-module
code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required">
+ <module-option name =
"password-stacking">useFirstPass</module-option>
+ <module-option
name="usersProperties">props/teiid-security-users.properties</module-option>
+ <module-option
name="rolesProperties">props/teiid-security-roles.properties</module-option>
+ </login-module>
+
+ <login-module
code="org.jboss.resource.security.CallerIdentityLoginModule"
flag="required">
+ <module-option name =
"password-stacking">useFirstPass</module-option>
+ <module-option name =
"managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+ </login-module>
+
+ </authentication>
+ </application-policy>
+ ]]></programlisting>
+
+ <para>In the -ds.xml file that is defined as the
"managedConnectionFactoryName" in the above configuration,
+ you need to add the following element</para>
+
+ <programlisting><![CDATA[
+ <security-domain>teiid-security</security-domain>
+ ]]></programlisting>
+
+ <para>In the above configuration example, in the primary login module
"UsersRolesLoginModule" is setup to hold the
+ passwords in the file, and when user logs in with password, the same password
will be also set on the logged in Subject after
+ authentication. This credentials can be extracted by the data source by
asking for Subject's private credentials.</para>
+
+ <para>To use a certificate or serialized object instead of plain
password as the token, simply replace the simple text password
+ with Base64 encoded contents of the serialized object. Please note that,
encoding and decoding of this object
+ is strictly up to the user as JBoss AS and Teiid will only act like
carrier of the information from
+ login module to connection factory. Using this CallerIdentity module, the
connection pool for data source is segmented
+ by Subject.</para>
+ </section>
+ <section>
+ <title>Role Based Credential Map</title>
+ <para>In some use cases, the users are divided by their functionality
and they have varied level of security access to
+ data sources. These types of users are identified by their roles as to what
they have access to. In the above "CallerIdentity"
+ login scenario, that may be too fine-grained security at data sources, that
can lead resource exhaustion as every user has
+ their own separate connection.
+ Using Role based security gives a balance, where the users with same role are
treated equally
+ for authentication purposes at the data source. Teiid provides a login module
called "RoleBasedCredentialMap"
+ for this purposes, where administrator can define a role based authentication
module, where given the role of the user
+ from the primary login module, this module will hold credentail to that role.
So, it is container of credentials that
+ map to different roles. If a user has multiple roles, the first role that has
the credential will be chosen.
+ Below find the sample configuration.</para>
+
+ <programlisting><![CDATA[
+ <application-policy xmlns="urn:jboss:security-beans:1.0"
name="teiid-security">
+ <authentication>
+
+ <login-module
code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required">
+ <module-option name =
"password-stacking">useFirstPass</module-option>
+ <module-option
name="usersProperties">props/teiid-security-users.properties</module-option>
+ <module-option
name="rolesProperties">props/teiid-security-roles.properties</module-option>
+ </login-module>
+
+ <login-module
code="org.teiid.jboss.RoleBasedCredentialMapIdentityLoginModule"
flag="required">
+ <module-option name =
"password-stacking">useFirstPass</module-option>
+ <module-option
name="credentialMap">props/teiid-credentialmap.properties</module-option>
+ <module-option name =
"managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+ </login-module>
+
+ </authentication>
+ </application-policy>
+ ]]></programlisting>
+ <para>In the -ds.xml file that is defined as the
"managedConnectionFactoryName" in the above configuration,
+ you need to add the following element</para>
+
+ <programlisting><![CDATA[
+ <security-domain>teiid-security</security-domain>
+ ]]></programlisting>
+
+ <para>In the above configuration example, in the primary login module
"UsersRolesLoginModule" is setup for logging in
+ the primary user and assign some roles. The
"RoleBasedCredentialMap" login module is configured to hold
+ role to password information in the file defined by "credentialMap"
property. When user logs in, the role information
+ from the primary login module is taken, and extracts the role's passsword
and attaches as
+ a private credential to the Subject. If you want use this for role based
trusted token, you can configure the Base64 based
+ endcoding/decoded object as defined above.</para>
+
+ <para>You can also encrypt the password instead of plain text password
using this module. Just include the encrypted
+ password in the file defined by the "credentialMap" property, and
define following properties in
+ the "RoleBasedCredentialMap" login module.</para>
+
+ <programlisting><![CDATA[
+ <login-module
code="org.teiid.jboss.RoleBasedCredentialMapIdentityLoginModule"
flag="required">
+ <module-option name =
"password-stacking">useFirstPass</module-option>
+ <module-option
name="credentialMap">props/teiid-credentialmap.properties</module-option>
+ <module-option name =
"managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+
+ <!-- below properties are only required when passwords are encrypted
-->
+ <module-option name =
"pbealgo">PBEWithMD5AndDES</module-option>
+ <module-option name =
"pbepass">testPBEIdentityLoginModule</module-option>
+ <module-option name =
"salt">abcdefgh</module-option>
+ <module-option name =
"iterationCount">19</module-option>
+ </login-module>
+ ]]></programlisting>
+
+ <para>For full details about encryption of the password, please follow
this
+ <ulink
url="http://community.jboss.org/docs/DOC-9703">document</...
+ "A KeyStore based login module for encrypting a datasource
password" section. Be sure to give the same configuration elements
+ in the above configuration, as they are used to encrypt the
password.</para>
+ </section>
+ </section>
+ </section>
<section id="ssl_config">
<title>Configuring SSL</title>
@@ -134,7 +259,7 @@
enabled = traffic will be secured using the other configuration
properties.</para></listitem>
<listitem><para>sslProtocol- Type of SSL protocol to be used.
Default is TLSv1</para></listitem>
<listitem><para>keystoreType - Keystore type created by the
keytool. Default "JKS" is used.</para></listitem>
- <listitem><para>authenticationMode - anonymous|1-way|2-way, Type
of <link linkend="ssl_aut">SSL Authentication
Mode</link>.</para></listitem>
+ <listitem><para>authenticationMode - anonymous|1-way|2-way, Type
of <link linkend="ssl_auth">SSL Authentication
Mode</link>.</para></listitem>
<listitem><para>keymanagementAlgorithm - Type of key algorithm
used. Default
is based upon the VM, e.g. "SunX509"</para></listitem>
<listitem><para>keystoreFilename - The file name of the keystore,
which contains the
Modified:
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml
===================================================================
---
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -142,7 +142,8 @@
</entry>
<entry>
<para>Determines whether XML documents returned by XML
document models will be validated
- against their schema after processing. See the <link
linkend="document_validation">document validation</link>
section.</para>
+ against their schema after processing. See the Reference
Guide's "XML SELECT Command" chapter and
+ "document validation" section.</para>
</entry>
</row>
<row>
Modified:
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml
===================================================================
---
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -8,7 +8,7 @@
<para>This chapter will shows you various security configurations
that can be used with Teiid in securing your data access. Note that data level
- security (<link linkend="entitlements">data roles</link>) are
explained in separate chapter.</para>
+ security called as "data roles" are explained in Reference Guide. This
chapter pertains to transport level security.</para>
<section id="default_security">
<title>Default Security</title>
Modified: trunk/documentation/developer-guide/pom.xml
===================================================================
--- trunk/documentation/developer-guide/pom.xml 2010-10-18 19:03:20 UTC (rev 2658)
+++ trunk/documentation/developer-guide/pom.xml 2010-10-19 15:39:47 UTC (rev 2659)
@@ -36,7 +36,7 @@
</dependency>
</dependencies>
<configuration>
- <sourceDocumentName>main.xml</sourceDocumentName>
+ <sourceDocumentName>Developer_Guide.xml</sourceDocumentName>
<imageResource>
<directory>${basedir}/src/main/docbook/en-US</directory>
<excludes>
Copied: trunk/documentation/developer-guide/src/main/docbook/en-US/Book_Info.xml (from rev
2654, branches/7.1.x/documentation/developer-guide/src/main/docbook/en-US/Book_Info.xml)
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/Book_Info.xml
(rev 0)
+++ trunk/documentation/developer-guide/src/main/docbook/en-US/Book_Info.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -0,0 +1,37 @@
+<?xml version="1.0" ?>
+<!DOCTYPE bookinfo PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd' [
+<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+
+<bookinfo>
+ <title>Teiid - Scalable Information Integration</title>
+ <subtitle>Teiid Developer's Guide</subtitle>
+ <releaseinfo>&versionNumber;</releaseinfo>
+ <productnumber>&versionNumber;</productnumber>
+ <issuenum>1</issuenum>
+
+ <abstract>
+ <para>
+ This guide contains information for developers creating custom solutions
+ with Teiid. It covers creating JEE JCA connectors with the Teiid framework,
+ Teiid Translators, Teiid User Defined Functions (UDFs) as well as related topics.
+ </para>
+ </abstract>
+
+ <corpauthor>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="Common_Content/images/title_logo.svg"/>
+ </imageobject>
+ </inlinemediaobject>
+ </corpauthor>
+
+ <copyright>
+ <year>©rightYear;</year>
+ <holder>©rightHolder;</holder>
+ </copyright>
+
+ <xi:include href="../../../../../docbook/en-US/legal_notice.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</bookinfo>
Copied: trunk/documentation/developer-guide/src/main/docbook/en-US/Developer_Guide.xml
(from rev 2654,
branches/7.1.x/documentation/developer-guide/src/main/docbook/en-US/Developer_Guide.xml)
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/Developer_Guide.xml
(rev 0)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/Developer_Guide.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -0,0 +1,23 @@
+<?xml version='1.0'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+
+<book>
+ <xi:include href="Book_Info.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+ <xi:include href="content/introduction.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/develop-adapter.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/translator-api.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/extending-jdbc.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/udf.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/adminapi.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/logging.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/security.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/appendix-a.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/appendix-b.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+
+</book>
+
Modified:
trunk/documentation/developer-guide/src/main/docbook/en-US/content/appendix-a.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/appendix-a.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/appendix-a.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -2,56 +2,70 @@
<title>ra.xml file Template</title>
<para> This appendix contains an example of the ra.xml file that can be used as a
template
when creating a new Connector.</para>
- <programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
-
+ <programlisting role="XML"
language="XML"><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
<connector
xmlns="http://java.sun.com/xml/ns/j2ee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
-
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
- version="1.5">
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd" version="1.5">
<vendor-name>${comapany-name}</vendor-name>
<eis-type>${type-of-connector}</eis-type>
<resourceadapter-version>1.0</resourceadapter-version>
<license>
- <description>
- ${license text}
- </description>
+ <description>${license text}</description>
<license-required>true</license-required>
</license>
+
<resourceadapter>
<resourceadapter-class>org.teiid.resource.spi.BasicResourceAdapter</resourceadapter-class>
-
<outbound-resourceadapter>
<connection-definition>
-
<managedconnectionfactory-class>${connection-factory-class}</managedconnectionfactory-class>
+
<managedconnectionfactory-class>${connection-factory}</managedconnectionfactory-class>
<!-- repeat for every configuration property -->
<config-property>
-
<description>{$display:"${short-name}",$description:"${description}",
$allowed:[${value-list}], $required:"${required-boolean}",
$defaultValue:"${default-value}"}</description>
-
<config-property-name>${property-name}</config-property-name>
-
<config-property-type>${property-type}</config-property-type>
-
<config-property-value>${optional-property-value}</config-property-value>
+ <description>
+
{$display:"${short-name}",$description:"${description}",$allowed:[${value-list}],
+ $required:"${required-boolean}",
$defaultValue:"${default-value}"}
+ </description>
+ <config-property-name>${property-name}</config-property-name>
+ <config-property-type>${property-type}</config-property-type>
+
<config-property-value>${optional-property-value}</config-property-value>
</config-property>
-
+
<!-- use the below as is if you used the Connection Factory interface
-->
-
-
<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
-
<connectionfactory-impl-class>org.teiid.resource.spi.WrappedConnectionFactory</connectionfactory-impl-class>
-
<connection-interface>javax.resource.cci.Connection</connection-interface>
-
<connection-impl-class>org.teiid.resource.spi.WrappedConnection</connection-impl-class>
+ <connectionfactory-interface>
+ javax.resource.cci.ConnectionFactory
+ </connectionfactory-interface>
+ <connectionfactory-impl-class>
+ org.teiid.resource.spi.WrappedConnectionFactory
+ </connectionfactory-impl-class>
+
+ <connection-interface>
+ javax.resource.cci.Connection
+ </connection-interface>
+
+ <connection-impl-class>
+ org.teiid.resource.spi.WrappedConnection
+ </connection-impl-class>
+
</connection-definition>
-
+
<transaction-support>NoTransaction</transaction-support>
-
- <authentication-mechanism>
+
+ <authentication-mechanism>
<authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
-
<credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
- </authentication-mechanism>
- <reauthentication-support>false</reauthentication-support>
+ <credential-interface>
+ javax.resource.spi.security.PasswordCredential
+ </credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+
</outbound-resourceadapter>
+
</resourceadapter>
+
</connector>]]></programlisting>
<para>${...} indicates a value to be supplied by the developer.</para>
-</appendix>
\ No newline at end of file
+</appendix>
Modified:
trunk/documentation/developer-guide/src/main/docbook/en-US/content/appendix-b.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/appendix-b.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/appendix-b.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,23 +1,42 @@
<appendix id="advanced_topics">
<title>Advanced Topics</title>
<section>
- <title>Security Migration From Previous Versions</title>
- <para>It is recommended that customers who have utilized the internal JDBC
membership domain from releases
- prior to MetaMatrix 5.5 migrate those users and groups to an LDAP compliant
directory server. Several free
- and open source directory servers can be used including:</para>
- <para>
- The Fedora Directory Server
- <ulink
url="http://directory.fedoraproject.org/">http://directory.f...
- </para>
- <para>
- Open LDAP
- <ulink
url="http://www.openldap.org/">http://www.openldap.org/</...
- </para>
- <para>
- Apache Directory Server
- <ulink
url="http://directory.apache.org/">http://directory.apache.o...
- </para>
- <para>See the JBossAS security documentation for using an LDAP directory
server. If there are additional questions or the need for guidance in the migration
process, please contact
- technical support.</para>
+ <title>Security Migration From Previous Versions</title>
+ <para>
+ It is recommended that customers who have utilized the internal JDBC membership
+ domain from releases prior to MetaMatrix 5.5 migrate those users and groups to
+ an LDAP compliant directory server.
+ </para>
+ <para>
+ Refer to the JBoss Application Server security documentation for using
+ an LDAP directory server. If there are additional questions or the need
+ for guidance in the migration process, please contact technical support.
+ </para>
+
+
+ <para>
+ Several free and open source directory servers include:
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ The Fedora Directory Server - <ulink
url="http://directory.fedoraproject.org/"/>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Open LDAP - <ulink
url="http://www.openldap.org/"/>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Apache Directory Server - <ulink
url="http://directory.apache.org/"/>
+ </para>
+ </listitem>
+ </itemizedlist>
+
+
</section>
+
</appendix>
\ No newline at end of file
Modified:
trunk/documentation/developer-guide/src/main/docbook/en-US/content/develop-adapter.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/develop-adapter.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/develop-adapter.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -10,11 +10,11 @@
developers, we provided a base implementation framework.
If you already have a JCA Connector or some other mechanism to get data from your
source system, you can skip this chapter.</para>
- <para>If you are not familiar with JCA API, please read the <ulink
url="http://java.sun.com/j2ee/connector/">JCA 1.5
Specification</ulink>.
+ <para>If you are not familiar with JCA API, please read the JCA 1.5
Specification at <ulink
url="http://java.sun.com/j2ee/connector/"/>.
There are lot of online tutorials on how to design and build a JCA Connector. The
below we show you to build very simple connector,
however building actual connector that supports transactions, security can get much
more complex.</para>
- <para>Check out the following links <ulink
url="http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch7.chapt.htm...
on JBoss</ulink> </para>
+ <para>Refer to the JBoss Application Server Connectors documentation at
<ulink
url="http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch7.chapt.htm...
<section>
<title>Using the Teiid Framework</title>
@@ -45,46 +45,44 @@
attribute for each configuration variable, and then provide both
"getter" and "setter" methods for them.
Note to use only "java.lang" objects as the attributes, DO NOT use
Java primitives for defining and accessing the properties.
See the following code for an example.</para>
- <programlisting><![CDATA[public class MyManagedConnectionFactory
extends BasicManagedConnectionFactory {
- @Override
- public Object createConnectionFactory() throws ResourceException {
- return new MyConnectionFactory();
- }
-
- // config property name (metadata for these are defined inside the ra.xml)
- String userName;
- public String getUserName() {
- return this.userName;
- }
- public void setUserName(String name) {
- this.userName = name;
- }
-
- // config property count (metadata for these are defined inside the ra.xml)
- Integer count;
- public Integer getCount() {
- return this.count;
- }
- public void setCount(Integer value) {
- this.count = value;
- }
+ <programlisting language="Java"
role="JAVA"><![CDATA[public class MyManagedConnectionFactory extends
BasicManagedConnectionFactory
+{
+ @Override
+ public Object createConnectionFactory() throws ResourceException
+ {
+ return new MyConnectionFactory();
+ }
+
+ // config property name (metadata for these are defined inside the ra.xml)
+ String userName;
+ public String getUserName() { return this.userName; }
+ public void setUserName(String name){ this.userName = name; }
+
+ // config property count (metadata for these are defined inside the ra.xml)
+ Integer count;
+ public Integer getCount() { return this.count; }
+ public void setCount(Integer value) { this.count = value; }
+
}]]></programlisting>
</section>
<section>
<title>Define the Connection Factory class</title>
<para>Extend the <code>BasicConnectionFactory</code> class, and
provide a implementation for the "getConnection()" method.</para>
- <programlisting><![CDATA[public class MyConnectionFactory extends
BasicConnectionFactory {
- @Override
- public MyConnection getConnection() throws ResourceException {
- return new MyConnection();
- }
+ <programlisting language="Java"
role="JAVA"><![CDATA[public class MyConnectionFactory extends
BasicConnectionFactory
+{
+ @Override
+ public MyConnection getConnection() throws ResourceException
+ {
+ return new MyConnection();
+ }
}]]></programlisting>
<para>Since the Managed connection object created the
"ConnectionFactory" class it has access to all the configuration
parameters, if "getConnection" method needs to do pass any of
credentials to the underlying EIS system.
The Connection Factory class can also get reference to the calling user's
<code>javax.security.auth.Subject</code> during
"getConnection" method by calling
-
- <programlisting><![CDATA[Subject subject =
ConnectionContext.getSubject();]]></programlisting>
+ </para>
+ <programlisting language="Java"
role="JAVA"><![CDATA[Subject subject =
ConnectionContext.getSubject();]]></programlisting>
+ <para>
This "Subject" object can give access to logged-in user's
credentials and roles that are defined. Note that this may be null.
</para>
<para>Note that you can define "security-domain" for this
resource adapter, that is separate from
@@ -98,29 +96,34 @@
of the Connection object in the Translator. If your
connection is stateful, then override "isAlive()" and
"cleanup()" methods and provide proper implementations. These are called
to check if a Connection is stale or need to flush them from the connection
pool etc. by the Container.</para>
- <programlisting><![CDATA[public class MyConnection extends
BasicConnection {
-
- public void doSomeOperation(command){
- // do some operation with EIS system..
- // This is method you use in the Translator, you should know
- // what need to be done here for your source..
- }
+ <programlisting language="Java"
role="JAVA"><![CDATA[public class MyConnection extends BasicConnection
+{
+ public void doSomeOperation(command)
+ {
+ // do some operation with EIS system..
+ // This is method you use in the Translator, you should know
+ // what need to be done here for your source..
+ }
- @Override
- public boolean isAlive() {
- return true;
- }
- @Override
- public void cleanUp() {
+ @Override
+ public boolean isAlive()
+ {
+ return true;
+ }
+
+ @Override
+ public void cleanUp()
+ {
- }
+ }
}]]></programlisting>
</section>
<section>
<title>XA Transactions</title>
- <para>If you EIS source can participate in XA transactions, then on
your <link linkend="connection">Connection</link> object,
- override the "getXAResource()" method and provide the
"XAResource" object for the EIS system.
+ <para>If your EIS source can participate in XA transactions, then on
your Connection object,
+ override the "getXAResource()" method and provide the
"XAResource" object for the EIS system.
+ Refer to <xref linkend="connection"/>.
Also, You need to extend the "BasicResourceAdapter" class and
provide implementation for method
"public XAResource[] getXAResources(ActivationSpec[] specs)" to
participate in crash recovery. </para>
@@ -131,17 +134,26 @@
<section>
<title>Define the configuration properties in a "ra.xml"
file</title>
- <para>Define a "ra.xml" file (sample shown in the <link
linkend="appendix_a">appendix-a</link>) in "META-INF"
directory of your RAR file.
- For every configuration property defined inside the <link
linkend="managed_connection_factory">ManagedConnectionFactory</link>
+ <para>
+ Define a "ra.xml" file in "META-INF" directory of your
RAR file.
+ An example file is provided in <xref linkend="appendix_a"/>.
+ </para>
+ <para>
+ For every configuration property defined inside the ManagedConnectionFactory
class, define the following XML configuration
fragment inside the "ra.xml" file. These properties are used by
user to configure instance of this Connector inside a
Container. Also, during the startup the Container reads these properties from
this file and knows how to inject
- provided values in the "-ds.xml" file into a instance of
"ManagedConnectionFactory" to create the Connection.</para>
- <programlisting><![CDATA[<config-property>
-
<description>{$display:"${display-name}",$description:"${description}",
$allowed="${allowed}", $required="${true|false}",
$defaultValue="${default-value}"}</description>
- <config-property-name>${property-name}</config-property-name>
- <config-property-type>${property-type}</config-property-type>
- <config-property-value>${optioal-property-value}</config-property-value>
+ provided values in the "-ds.xml" file into a instance of
"ManagedConnectionFactory" to create the Connection.
+ Refer to <xref linkend="managed_connection_factory"/>.
+ </para>
+ <programlisting role="XML"
language="XML"><![CDATA[<config-property>
+ <description>
+ {$display:"${display-name}",$description:"${description}",
$allowed="${allowed}",
+ $required="${true|false}", $defaultValue="${default-value}"}
+ </description>
+ <config-property-name>${property-name}</config-property-name>
+ <config-property-type>${property-type}</config-property-type>
+ <config-property-value>${optioal-property-value}</config-property-value>
</config-property>]]></programlisting>
<para>The format and contents of "<description>"
element may be used as extended metadata for tooling. The special format must begin and
end with curly braces e.g. {...}. This use of the special format and all properties is
optional. Property names begin with '$' and are separated from the value with
':'. Double quotes identifies a single value. A pair of square brackets, e.g.
[...], containing comma separated double quoted entries denotes a list value.
@@ -193,37 +205,39 @@
<para>Maven: If you are using maven, use <packaging>
element value as "rar". Teiid uses maven, you can look at any of
the "connector" projects for sample "pom.xml" file.
Here is sample pom.xml file.</para>
- <programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
-<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>connector-{name}</artifactId>
- <groupId>org.company.project</groupId>
- <name>Name Connector</name>
- <packaging>rar</packaging>
- <description>This connector is a sample</description>
+ <programlisting role="XML"
language="XML"><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
+<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>connector-{name}</artifactId>
+ <groupId>org.company.project</groupId>
+ <name>Name Connector</name>
+ <packaging>rar</packaging>
+ <description>This connector is a sample</description>
- <dependencies>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
</project>]]></programlisting>
</listitem>
</itemizedlist>
<para>Make sure that the RAR file, under its "META-INF" directory
has the "ra.xml" file. If you are using maven
- see <ulink
url="http://maven.apache.org/plugins/maven-rar-plugin/"><... the
root of the RAR file,
+ refer to <ulink
url="http://maven.apache.org/plugins/maven-rar-plugin/"/>. In the root of
the RAR file,
you can embed the JAR file containing your connector code and any dependent
library JAR files. </para>
</section>
@@ -239,25 +253,29 @@
<itemizedlist>
<listitem>
- <para>Create "${name}-ds.xml" file, and copy it into
"deploy" directory of JBoss AS.
- <programlisting><![CDATA[<!DOCTYPE connection-factories
PUBLIC
- "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
- "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+ <para>
+ Create "${name}-ds.xml" file, and copy it into
"deploy" directory of JBoss AS.
+ </para>
+ <programlisting language="XML"
role="XML"><![CDATA[<!DOCTYPE connection-factories PUBLIC
+ "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
"http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
<connection-factories>
- <no-tx-connection-factory>
- <jndi-name>${jndi-name}</jndi-name>
- <rar-name>${name}.rar</rar-name>
-
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
-
- <!-- define all the properties defined in the "ra.xml" that required
or needs to be modified from defaults -->
- <!-- each property is defined in single element -->
- <config-property name="prop-name"
type="java.lang.String">prop-value</config-property>
-
- </no-tx-connection-factory>
+ <no-tx-connection-factory>
+ <jndi-name>${jndi-name}</jndi-name>
+ <rar-name>${name}.rar</rar-name>
+
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!--
+ define all the properties defined in the "ra.xml" that required or needs to
be
+ modified from defaults each property is defined in single element
+ -->
+ <config-property name="prop-name"
type="java.lang.String">prop-value</config-property>
+
+</no-tx-connection-factory>
</connection-factories>]]></programlisting>
- There are lot more properties that you can define for pooling,
transactions, security etc in this file.
- Check JBoss AS documentation for all the avaialble properties.
+ <para>
+ There are lot more properties that you can define for pooling,
transactions, security etc in this file.
+ Check JBoss AS documentation for all the avaialble properties.
</para>
</listitem>
<listitem>
Modified:
trunk/documentation/developer-guide/src/main/docbook/en-US/content/extending-jdbc.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/extending-jdbc.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/extending-jdbc.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -40,7 +40,7 @@
<section>
<title>Capabilities Extension</title>
<para>This extension must override the methods that begin with
"supports" that describe translator capabilities.
- For all the available translator capabilities please see <link
linkend="translator_capabilities">this</link>.</para>
+ Refer to <xref linkend="translator_capabilities"/> for all the
available translator capabilities.</para>
<para>The most common example is adding
support for a scalar function – this requires both declaring that the translator
has the capability
@@ -59,15 +59,20 @@
<para>Change basic SQL syntax options. See the useXXX methods, e.g.
useSelectLimit returns true for SQLServer to indicate that limits are applied in the
SELECT clause.</para>
</listitem>
<listitem>
- <para>Register one or more <link
linkend="function_modifiers">FunctionModifiers</link> that define how a
scalar function should be modified or transformed.</para>
+ <para>Register one or more FunctionModifiers that define how a scalar
function should be modified or transformed.</para>
</listitem>
<listitem>
- <para>Modify a LanguageObject. - see the translate, translateXXX, and
<link
linkend="function_modifiers">FunctionModifiers</link>.translate
methods. Modify the passed in object and return null to indicate that the standard syntax
output should be used.</para>
+ <para>Modify a LanguageObject. - see the translate, translateXXX, and
FunctionModifiers.translate methods. Modify the passed in object and return null to
indicate that the standard syntax output should be used.</para>
</listitem>
<listitem>
- <para>Change the way SQL strings are formed for a LanguageObject. - -
see the translate, translateXXX, and <link
linkend="function_modifiers">FunctionModifiers</link>.translate
methods. Return a list of parts, which can contain strings and LanguageObjects, that will
be appended in order to the SQL string. If the in coming LanguageObject appears in the
returned list it will not be translated again.</para>
+ <para>Change the way SQL strings are formed for a LanguageObject. - -
see the translate, translateXXX, and FunctionModifiers.translate methods. Return a list
of parts, which can contain strings and LanguageObjects, that will be appended in order to
the SQL string. If the in coming LanguageObject appears in the returned list it will not
be translated again.</para>
</listitem>
</itemizedlist>
+
+ <para>
+ Refer to <xref linkend="function_modifiers"/>.
+ </para>
+
</section>
<section>
@@ -86,7 +91,7 @@
<section>
<title>Adding Function Support</title>
- <para>See <link linkend="udfs">User Defined
Functions</link> for adding new functions to Teiid. This example will show you how
to declare support for the function
+ <para>Refer to <xref linkend="udfs"/> for adding new
functions to Teiid. This example will show you how to declare support for the function
and modify how the function is passed to the data source.</para>
<para>Following is a summary of all coding steps in supporting a new scalar
function:</para>
<orderedlist>
@@ -99,25 +104,27 @@
</orderedlist>
<para>There is a capabilities method getSupportedFunctions() that declares
all supported scalar functions.</para>
<informalexample>
- <para>An example of an extended capabilities class to add support for the
“abs” absolute value function:</para>
- <programlisting><![CDATA[package my.connector;
-
+ <para>An example of an extended capabilities class to add support for the
"abs" absolute value function:</para>
+ <programlisting language="Java"
role="JAVA"><![CDATA[package my.connector;
+
import java.util.ArrayList;
import java.util.List;
-public class ExtendedJDBCExecutionFactory extends JDBCExecutionFactory {
- @Override
- public List getSupportedFunctions() {
- List supportedFunctions = new ArrayList();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS");
- return supportedFunctions;
- }
+public class ExtendedJDBCExecutionFactory extends JDBCExecutionFactory
+{
+ @Override
+ public List getSupportedFunctions()
+ {
+ List supportedFunctions = new ArrayList();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+ supportedFunctions.add("ABS");
+ return supportedFunctions;
+ }
}]]></programlisting></informalexample>
<para>In general, it is a good idea to call super.getSupportedFunctions()
to ensure that you retain any function
support provided by the translator you are extending.</para>
<para>This may be all that is needed to support a Teiid function if the
JDBC data source supports the
- same syntax as Teiid. The built-in SQL translation will translate most
functions as: “function(arg1, arg2, …)”.</para>
+ same syntax as Teiid. The built-in SQL translation will translate most
functions as: "function(arg1, arg2, …)".</para>
<section id="function_modifiers">
<title>Using FunctionModifiers</title>
<para>In some cases you may need to translate the function differently or
even insert
@@ -129,18 +136,19 @@
<informalexample>
<para>An example of overriding the translate method to change the MOD(a, b)
function into an infix operator for Sybase (a % b). The translate method returns a list
of strings and language objects that will be assembled by the translator into a final
string. The strings will be used as is and the language objects will be further processed
by the translator.</para>
- <programlisting><![CDATA[public class ModFunctionModifier implements
FunctionModifier {
-
- public List translate(Function function) {
- List parts = new ArrayList();
- parts.add("(");
- Expression[] args = function.getParameters();
- parts.add(args[0]);
- parts.add(" % ");
- parts.add(args[1]);
- parts.add(")");
- return parts;
- }
+ <programlisting language="Java"
role="JAVA"><![CDATA[public class ModFunctionModifier implements
FunctionModifier
+{
+ public List translate(Function function)
+ {
+ List parts = new ArrayList();
+ parts.add("(");
+ Expression[] args = function.getParameters();
+ parts.add(args[0]);
+ parts.add(" % ");
+ parts.add(args[1]);
+ parts.add(")");
+ return parts;
+ }
}]]></programlisting>
</informalexample>
@@ -150,8 +158,8 @@
<table frame='all'>
<title>Common Modifiers</title>
<tgroup cols='2' align='left' colsep='1'
rowsep='1'>
- <colspec colname='c1' colwidth=".4*"/>
- <colspec colname='c2' colwidth="1*"/>
+ <colspec colname='c1' colwidth="2*"/>
+ <colspec colname='c2' colwidth="5*"/>
<thead>
<row>
<entry><para>Modifier</para></entry>
@@ -161,7 +169,7 @@
<tbody>
<row>
<entry><para>AliasModifier</para></entry>
- <entry><para>Handles simply renaming a function (“ucase” to
“upper” for example)</para></entry>
+ <entry><para>Handles simply renaming a function
("ucase" to "upper" for example)</para></entry>
</row>
<row>
<entry><para>EscapeSyntaxModifier</para></entry>
@@ -172,18 +180,20 @@
</table>
<para>To register the function modifiers for your supported functions,
you must call the <code>ExecutionFactory.registerFunctionModifier(String
name, FunctionModifier modifier)</code> method.
- <programlisting><![CDATA[public class ExtendedJDBCExecutionFactory extends
JDBCExecutionFactory
-
- @Override
- public void start() {
- super.start();
-
- // register functions.
- registerFunctionModifier("abs", new MyAbsModifier());
- registerFunctionModifier("concat", new AliasModifier(“concat2”));
- }
-}]]></programlisting></para>
- <para>Support for the two functions being registered (“abs” and “concat”)
must be declared
+ </para>
+ <programlisting language="Java"
role="JAVA"><![CDATA[public class ExtendedJDBCExecutionFactory extends
JDBCExecutionFactory
+{
+ @Override
+ public void start()
+ {
+ super.start();
+
+ // register functions.
+ registerFunctionModifier("abs", new MyAbsModifier());
+ registerFunctionModifier("concat", new
AliasModifier("concat2"));
+ }
+}]]></programlisting>
+ <para>Support for the two functions being registered ("abs" and
"concat") must be declared
in the capabilities as well. Functions that do not have modifiers registered will
be translated as usual.
</para>
</section>
@@ -192,10 +202,13 @@
<section>
<title>Installing Extensions</title>
<para>Once you have developed an extension to the JDBC translator, you must
install it into the Teiid Server.
- The process of <link
linkend="translator_package">packaging</link> or <link
linkend="translator_deploy">deploying</link> the
+ The process of packaging or deploying the
extended JDBC translators is exactly as any other other translator. Since the RDMS is
accessible already through its JDBC
driver, there is no need to develop a resource adapter for this source as JBoss AS
provides a wrapper JCA connector (DataSource)
for any JDBC driver.
</para>
+ <para>
+ Refer to <xref linkend="translator_package"/> and <xref
linkend="translator_deploy"/> for more details.
+ </para>
</section>
</chapter>
Modified:
trunk/documentation/developer-guide/src/main/docbook/en-US/content/introduction.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/introduction.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/introduction.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -8,7 +8,7 @@
<section>
<title>Introduction to the Teiid Connector Architecture</title>
- <itemizedlist>
+ <orderedlist>
<para>Integrating data from a Enterprise Information System (EIS) into Teiid, is
separated into two parts.</para>
<listitem>
<para>A Translator, which is required.</para>
@@ -16,20 +16,20 @@
<listitem>
<para>An optional Resource Adapter, which will typically be a JCA Resource
Adapter (also called a JEE Connector) </para>
</listitem>
- </itemizedlist>
+ </orderedlist>
<para>A Translator is used to:</para>
- <itemizedlist>
+ <orderedlist>
<listitem>
- <para>Translate a Teiid-specific command into a native command.</para>
+ <para>Translate a Teiid-specific command into a native command,</para>
</listitem>
<listitem>
- <para>Execute the command.</para>
+ <para>Execute the command,</para>
</listitem>
<listitem>
<para>Return batches of results translated to expected Teiid
types.</para>
</listitem>
- </itemizedlist>
+ </orderedlist>
<para>A Resource Adapter:</para>
<itemizedlist>
@@ -37,9 +37,11 @@
<para>Handles all communications with individual enterprise information
system (EIS), which can include databases, data feeds, flat files, etc.</para>
</listitem>
<listitem>
- <para>Can be a <ulink
url="http://java.sun.com/j2ee/connector/">JCA Connector</ulink> or any
other custom connection provider.
+ <para>Can be a JCA Connector or any other custom connection provider.
The reason Teiid recommends and uses JCA is this specification defines how one can
write, package, and configure access to EIS system in consistent manner.
There are also various commercial/open source software vendors already providing
JCA Connectors to access a variety of back-end systems.</para>
+ <para>
+ Refer to <ulink
url="http://java.sun.com/j2ee/connector/"/>.</para>
</listitem>
<listitem>
<para>Abstracts Translators from many common concerns, such as connection
information, resource pooling, or authentication.</para>
@@ -55,47 +57,76 @@
you can use one of these enterprise information systems, you do not need to develop
a custom one.
</para>
<para>Teiid offers the following translators:</para>
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>JDBC:</emphasis>
- Works with many relational databases. The JDBC translator is validated against
the following database
- systems: Oracle, Microsoft SQL Server, IBM DB2, MySQL, Postgres, Derby, Sybase,
H2, and HSQL. In addition, the JDBC Translator can
- often be used with other 3rd-party drivers and provides a wide range of
extensibility options to
- specialize behavior against those drivers.
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>File:</emphasis>
- Provides a procedural way to access the file system to handle text files.
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>WS:</emphasis> Provides procedural access to XML content
via Web Services.
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>LDAP:</emphasis> Accesses to LDAP directory services.
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis>Salesforce:</emphasis> Works with Salesforce interfaces.
- </para>
- </listitem>
- </itemizedlist>
+
+ <variablelist>
+ <varlistentry>
+ <term>JDBC Translator</term>
+ <listitem>
+ <para>
+ Works with many relational databases. The JDBC translator is validated
+ against the following database systems: Oracle, Microsoft SQL Server,
+ IBM DB2, MySQL, Postgres, Derby, Sybase, H2, and HSQL. In addition, the
+ JDBC Translator can often be used with other 3rd-party drivers and
provides
+ a wide range of extensibility options to specialize behavior against those
+ drivers.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>File Translator</term>
+ <listitem>
+ <para>
+ Provides a procedural way to access the file system to handle text files.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>WS Translator</term>
+ <listitem>
+ <para>
+ Provides procedural access to XML content using Web Services.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>LDAP Translator</term>
+ <listitem>
+ <para>
+ Accesses to LDAP directory services.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Salesforce Translator</term>
+ <listitem>
+ <para>
+ Works with Salesforce interfaces.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+
<section>
<title>Custom Translators</title>
- <orderedlist numeration="arabic">
- <para>High-level Translator development procedure:</para>
+
+ <para>
+ Below are the high-level steps for creating custom Translators. This guide covers
+ how to do each of these steps in detail. It also provides additional information
for
+ advanced topics, such as streaming large objects.
+ </para>
+
+ <para>
+ For sample Translator code, refer to the Teiid source code at
+ <ulink
url="http://anonsvn.jboss.org/repos/teiid/trunk/connectors/"/>.
+ </para>
+
+ <orderedlist>
<listitem>
- <para><link linkend="custom_ra_intro"></link>Create a
new or reuse an existing Resource Adapater for the EIS system, to be used with this
Translator</para>
+ <para>Create a new or reuse an existing Resource Adapater for the EIS
system, to be used with this Translator.</para>
+ <para>Refer to <xref
linkend="custom_ra_intro"/>.</para>
</listitem>
<listitem>
- <para>Implement the required classes defined by the <link
linkend="translator_api">Translator API</link>.</para>
+ <para>Implement the required classes defined by the Translator
API.</para>
<itemizedlist>
<listitem>
<para>Create an ExecutionFactory – Extend the
<code>org.teiid.translator.ExecutionFactory</code> class</para>
@@ -104,29 +135,27 @@
<para>Create relevant Executions (and sub-interfaces) – specifies how
to execute each type of command</para>
</listitem>
</itemizedlist>
+ <para>Refer to <xref
linkend="translator_api"/>.</para>
</listitem>
<listitem>
- <para>Define the <link
linkend="translator_package">template</link> for exposing configuration
properties.</para>
+ <para>Define the template for exposing configuration properties.
+ Refer to <xref linkend="translator_package"/>.</para>
</listitem>
<listitem>
- <para><link linkend="translator_deploy">Deploy</link>
your Translator.</para>
- <itemizedlist>
- <listitem>
- <para>Deploy a Virtual Database (VDB) utilizing your
Translator.</para>
- </listitem>
- </itemizedlist>
+ <para>Deploy your Translator.
+ Refer to <xref linkend="translator_deploy"/>.</para>
</listitem>
+ <listitem>
+ <para>Deploy a Virtual Database (VDB) that uses your
Translator.</para>
+ </listitem>
<listitem>
<para>Execute queries via Teiid.</para>
</listitem>
</orderedlist>
- <para>
- This guide covers how to do each of these steps in detail. It also provides
additional information for
- advanced topics, such as streaming large objects. For sample
- Translator code, please check the <ulink
url="http://anonsvn.jboss.org/repos/teiid/trunk/connectors/">... source
code</ulink>
- </para>
+
+
+ </section>
</section>
- </section>
<section>
<title>Do You Need a New Resource Adapter?</title>
<para>As mentioned above, for every Translator that needs to gather data from
external source systems, it requires a resource adapter.
@@ -160,7 +189,8 @@
<orderedlist numeration="arabic">
<para>High-level Resource Adapter development procedure:</para>
<listitem>
- <para>Understand the <ulink
url="http://java.sun.com/j2ee/connector/">JEE Connector</ulink>
specification to have basic idea about what JCA connectors are how they are developed and
packaged.</para>
+ <para>Understand the JEE Connector specification to have basic idea
about what JCA connectors are how they are developed and packaged.</para>
+ <para>Refer to <ulink
url="http://java.sun.com/j2ee/connector/"/>.</para>
</listitem>
<listitem>
<para>Gather all necessary information about your Enterprise Information
System (EIS). You will need
@@ -198,16 +228,16 @@
</itemizedlist>
</listitem>
<listitem>
- <para><link linkend="ra_package">Package</link> your
resource adapter.</para>
+ <para>Package your resource adapter. Refer to <xref
linkend="ra_package"/>.</para>
</listitem>
<listitem>
- <para><link linkend="ra_package">Deploy</link> your
resource adapter.</para>
+ <para>Deploy your resource adapter. Refer to <xref
linkend="ra_package"/>.</para>
</listitem>
</orderedlist>
<para>
This guide covers how to do each of these steps in detail. It also provides
additional information for
- advanced topics, such as transactions. For a sample
- resource adapter code, please check the <ulink
url="http://anonsvn.jboss.org/repos/teiid/trunk/connectors/">... Source
code</ulink>
+ advanced topics, such as transactions. For sample
+ resource adapter code refer to the Teiid Source code at <ulink
url="http://anonsvn.jboss.org/repos/teiid/trunk/connectors/"/>.
</para>
</section>
</section>
@@ -217,13 +247,13 @@
<para>Teiid is highly extensible in other ways:</para>
<itemizedlist>
<listitem>
- <para>You may add <link linkend="udfs">User Defined
Functions</link>.</para>
+ <para>You may add User Defined Functions. Refer to <xref
linkend="udfs"/>.</para>
</listitem>
<listitem>
- <para>You may adapt <link
linkend="logging">logging</link> to your needs, which is especially
useful for custom audit or command logging.</para>
+ <para>You may adapt logging to your needs, which is especially useful for
custom audit or command logging. Refer to <xref
linkend="logging"/>.</para>
</listitem>
<listitem>
- <para>You may change the <link
linkend="custom_security">security</link> subsystem for custom
authentication and authorization.</para>
+ <para>You may change the subsystem for custom authentication and
authorization. Refer to <xref
linkend="custom_login_modules"/>.</para>
</listitem>
</itemizedlist>
</section>
Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -8,23 +8,23 @@
<section id="custom_logging">
<title>Customized Logging</title>
<para>
- The Teiid system provides a wealth of information via logging. To
- control logging level, contexts, and log locations, you should be
- familiar with
- <ulink
url="http://logging.apache.org/log4j/">log4j</ulink>
- and the container's jboss-log4j.xml configuration file.
- Teiid also provides a <profile>/conf/jboss-teiid-log4j.xml containing
much of information from chapter.
- Check out Admin Guide for more details about different Teiid contexts
available.
+ The Teiid system provides a wealth of information using logging. To control logging
level,
+ contexts, and log locations, you should be familiar with log4j and the
container's
+ <filename>jboss-log4j.xml</filename> configuration file. Teiid also
provides a
+
<filename><replaceable>PROFILE</replaceable>/conf/jboss-teiid-log4j.xml</filename>
containing
+ much of information from this chapter. Refer to the Administrator Guide for more
details about
+ different Teiid contexts available. Refer to <ulink
url="http://logging.apache.org/log4j/"/>
+ for more information about log4j.
</para>
<para>
If the default log4j logging mechanisms are not sufficient for your
- logging needs you may need a different appender - see
- <ulink
url="http://logging.apache.org/log4j/1.2/apidocs/index.html">... log4j
javadocs</ulink>.
+ logging needs you may need a different appender, refer to the log4j javadocs at
+ <ulink
url="http://logging.apache.org/log4j/1.2/apidocs/index.html"/>.
Note that log4j already provides quite a few appenders including JMS, RDBMS,
and SMTP.
</para>
- <para>If you want a custom appender, follow the Log4J directions to write a
custom appender. See instructions
- <ulink
url="http://logging.apache.org/log4net/release/faq.html">her...;.
If you develop a custom
+ <para>If you want a custom appender, follow the Log4J directions to write a
custom appender. Refer to
+ the instructions at <ulink
url="http://logging.apache.org/log4net/release/faq.html"/>. If you develop a
custom
logging solution, the implementation jar should be placed in the
"lib" directory of the JBoss AS server profile
Teiid is installed in.
</para>
Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/security.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/security.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/security.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -8,37 +8,88 @@
<para>
LoginModules are an essential part of the JAAS security
framework and provide Teiid customizable user authentication and the
- ability to reuse existing LoginModules defined for JBossAS. See
- <ulink
-
url="http://docs.jboss.org/jbossas/admindevel326/html/ch8.chapter.ht...
Security</ulink>
- for general information on configuring security in JBossAS.</para>
+ ability to reuse existing LoginModules defined for JBossAS. Refer to
+ the JBoss Application Server security documentation for information about
+ configuring security in JBoss Application Server,
+ <ulink
url="http://docs.jboss.org/jbossas/admindevel326/html/ch8.chapter.ht...;.
+ </para>
<section>
<title>Built-in LoginModules</title>
- <para>JBossAS provides several LoginModules for common authentication needs,
such as authenticating from text files or LDAP.
- The below are are some of the available in JBoss AS </para>
+ <para>
+ JBoss Application Server provides several LoginModules for common
+ authentication needs, such as authenticating from text files or LDAP.
+ </para>
- <para>See for all the available <ulink
url="http://community.jboss.org/docs/DOC-11287"> login
modules.</ulink></para>
+ <para>
+ Below are are some of those available in JBoss Application Server:
+ </para>
+
+ <variablelist>
- <para>See <ulink
url="http://community.jboss.org/docs/DOC-12510">UserRoles LoginModule
configuration</ulink>
- for utilizing simple file based authentication.</para>
- <para>See <ulink
url="http://community.jboss.org/docs/DOC-11253">LDAP LoginModule
configuration</ulink> for
- utilizing LDAP based authentication. </para>
- <para>See <ulink
url="http://community.jboss.org/docs/DOC-9511">Database LoginModule
configuration</ulink> for
- utilizing Database based authentication. </para>
+ <varlistentry>
+ <term>UserRoles LoginModule</term>
+ <listitem>
+ <para>
+ Login module that uses simple file based authentication.
+ </para>
+ <para>
+ Refer to <ulink
url="http://community.jboss.org/docs/DOC-12510"/>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>LDAP LoginModule</term>
+ <listitem>
+ <para>
+ Login module that uses LDAP based authentication.
+ </para>
+ <para>
+ Refer to <ulink
url="http://community.jboss.org/docs/DOC-11253"/>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Database LoginModule</term>
+ <listitem>
+ <para>
+ Login module that uses Database-based authentication.
+ </para>
+ <para>
+ Refer to <ulink
url="http://community.jboss.org/docs/DOC-9511"/>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Cert LoginModule</term>
+ <listitem>
+ <para>
+ Login module that uses X509 certificate based authentication.
+ </para>
+ <para>
+ See <ulink
url="http://community.jboss.org/docs/DOC-9160"/>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
- <para>See <ulink
url="http://community.jboss.org/docs/DOC-9160">Cert LoginModule
configuration</ulink> for
- utilizing X509 certificate based authentication. </para>
- </section>
+ <para>
+ For all the available login modules refer to <ulink
url="http://community.jboss.org/docs/DOC-11287"/>.
+ </para>
+
+ </section>
+
<section>
<title>Custom LoginModules</title>
<para>
- If your authentication needs go beyond the provided LoginModules, please consult the
- <ulink
url="http://java.sun.com/j2se/1.5.0/docs/guide/security/jaas/JAASLMD...
development guide</ulink>.
+ If your authentication needs go beyond the provided LoginModules, please refer
+ to the JAAS development guide at
+ <ulink
url="http://java.sun.com/j2se/1.5.0/docs/guide/security/jaas/JAASLMD...;.
There are also numerous guides available.
</para>
- <para>If you are extending one of the built-in LoginModules, please see
- <ulink
url="http://community.jboss.org/docs/DOC-9466">this</ulin...
+ <para>If you are extending one of the built-in LoginModules, refer to
+ <ulink
url="http://community.jboss.org/docs/DOC-9466"/>.</para>
</section>
</chapter>
\ No newline at end of file
Modified:
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -32,22 +32,26 @@
<para>Every software program requires some external configuration, that
defines ways user can alter the behavior of a program.
If this translator needs configurable properties define a variable for every
property as an attribute in the extended
"ExecutionFactory" class. Then define a "get" and
"set" methods for each of them. Also, annotate each "get" method with
- <code>@TranslatorProperty</code> annotation and provide the
metadata about the property. For example, if you need a
- property called "foo",
- <programlisting><![CDATA[private String foo =
"balh";
-
+ <code>@TranslatorProperty</code> annotation and provide the
metadata about the property.
+ </para>
+ <para>
+ For example, if you need a property called "foo", by providing
the annotation on
+ these properties, the Teiid tooling will automatically interrogate and
provide
+ graphical way to configure your Translator.
+ </para>
+ <programlisting language="Java"
role="JAVA"><![CDATA[private String foo = "blah";
@TranslatorProperty(display="Foo property", description="description about
Foo")
-public String getFoo() {
- return foo;
+public String getFoo()
+{
+ return foo;
}
-public void setFoo(String value) {
- return this.foo = value;
+public void setFoo(String value)
+{
+ return this.foo = value;
}]]> </programlisting>
-
- by providing the annotation on these properties, the Teiid tooling
will automatically interrogate and
- provide graphical way to configure your
- Translator. Only java primitive (int), primitive object wrapper
(java.lang.Integer), or Enum types are supported as Translator properties.
+ <para>
+ Only java primitive (int), primitive object wrapper
(java.lang.Integer), or Enum types are supported as Translator properties.
The default value will be derived from calling the getter, if
available, on a newly constructed instance.
All properties <emphasis>should</emphasis> have a default
value. If there is no applicable default, then the property should be marked in the
annotation as required.
Initialization will fail if a required property value is not
provided.
@@ -84,7 +88,7 @@
<title>TranslatorCapabilities</title>
<para>These are various methods that typically begin with method
signature "supports" on the "ExecutionFactory"
class. These methods need to be overridden to describe the execution
- capabilities of the Translator. See <link
linkend="translator_capabilities">Translator Capabilities</link> for
more on these methods.</para>
+ capabilities of the Translator. Refer to <xref
linkend="translator_capabilities"/> for more on these methods.</para>
</section>
<section>
@@ -161,16 +165,19 @@
</para>
</section>
</section>
+
<section>
- <title>Executing Commands</title>
- <section>
+ <title>Executing Commands</title>
+ <section>
<title>Execution Modes</title>
- <para>
- The Teiid query engine uses the "ExecutionFactory" class to obtain the
"Execution" interface for the command it is
- executing. The actual queries themselves are sent to translators in the form of a set
of objects, which are further
- described in <link linkend="command_language">Command
Language</link>.
- translators are allowed to support any subset of the available execution
modes.
- </para>
+ <para>
+ The Teiid query engine uses the "ExecutionFactory" class to obtain the
"Execution"
+ interface for the command it is executing. The actual queries themselves are
sent
+ to translators in the form of a set of objects, which are further described in
+ Command Language. Refer to <xref linkend="command_language"/>.
Translators are
+ allowed to support any subset of the available execution modes.
+ </para>
+
<table frame='all'>
<title>Types of Execution Modes</title>
<tgroup cols='3' align='left' colsep='1'
rowsep='1'>
@@ -311,9 +318,8 @@
package. These objects can be combined to represent any possible
command that Teiid may send to the Translator. However, it is possible
to notify Teiid that your Translator can only accept certain kinds of
- constructs via the capabilities defined on the "ExecutionFactory" class. See
the section on using
- <link linkend="translator_capabilities">Translator
Capabilities</link>
- for more information.
+ constructs via the capabilities defined on the "ExecutionFactory" class.
Refer to
+ <xref linkend="translator_capabilities"/> for more information.
</para>
<para>The language objects all extend from the
<code>LanguageObject</code> interface.
Language objects should be thought of as a tree where each node is a
@@ -322,7 +328,7 @@
<para>All commands sent to your Translator are in the form of these
language trees, where the root of the tree is a subclass of
<code>Command</code>.
Command has several sub-interfaces, namely:
-
+ </para>
<itemizedlist>
<listitem><para><code>QueryExpression</code></para></listitem>
<listitem><para><code>Insert</code></para></listitem>
@@ -331,11 +337,13 @@
<listitem><para><code>BatchedUpdates</code></para></listitem>
<listitem><para><code>Call</code></para></listitem>
</itemizedlist>
-
- Important components of these commands are expressions, criteria, and joins, which are
examined
- in closer detail below. Also see the <ulink
url="&javaDocUrl;">Teiid JavaDocs</ulink>
- for more on the classes and interfaces described here.
- </para>
+
+ <para>
+ Important components of these commands are expressions, criteria, and joins,
+ which are examined in closer detail below. For more on the classes and interfaces
+ described here, refer to the Teiid JavaDocs <ulink
url="&javaDocUrl;"/>.
+ </para>
+
<section>
<title>Expressions</title>
<para>An expression represents a single value in context, although in
@@ -430,9 +438,8 @@
<code>Join</code>
s with a single root. This latter form
is the ANSI perfered style. If you wish all pushdown queries containing joins to
be in ANSI style have the
- capability "useAnsiJoin" return true. See
- <link linkend="command_form_capabilities">Command Form
Capabilities</link>
- for more information.
+ capability "useAnsiJoin" return true. Refer to
+ <xref linkend="command_form_capabilities"/> for more
information.
</para>
</section>
<section>
@@ -550,7 +557,7 @@
<section>
<title>Runtime Metadata</title>
- <para>Teiid uses a library of metadata, known as "runtime metadata” for
+ <para>Teiid uses a library of metadata, known as "runtime metadata"
for
each virtual database that is deployed in Teiid. The runtime metadata
is a subset of metadata as defined by models in the Teiid models that
compose the virtual database. While builing your VDB in the Designer, you can define
what
@@ -586,14 +593,12 @@
<title>Obtaining Metadata Properties</title>
<para>The process of getting a Table's properties is sometimes needed
for translator development. For example
to get the "NameInSource" property or all extension
properties:</para>
- <programlisting><![CDATA[
-//getting the Table metadata from an Table is straight-forward
+ <programlisting language="Java"
role="JAVA"><![CDATA[//getting the Table metadata from an Table is
straight-forward
Table table = runtimeMetadata.getTable("table-name");
String contextName = table.getNameInSource();
//The props will contain extension properties
-Map<String, String> props = table.getProperties();
- ]]></programlisting>
+Map<String, String> props = table.getProperties();]]></programlisting>
</example>
</section>
@@ -669,8 +674,7 @@
not processing order.</para>
<para>Write code to execute your visitor using the utility methods on
DelegatingHierarchyVisitor:</para>
- <programlisting><![CDATA[
-// Get object tree
+ <programlisting language="Java"
role="JAVA"><![CDATA[// Get object tree
LanguageObject objectTree = …
// Create your visitor initialize as necessary
@@ -680,8 +684,7 @@
DelegatingHierarchyVisitor.preOrderVisit(visitor, objectTree);
// Retrieve state collected while visiting
-int count = visitor.getCount();
- ]]></programlisting>
+int count = visitor.getCount();]]></programlisting>
</section>
</section>
<section id="translator_capabilities">
@@ -706,9 +709,9 @@
<table frame='all'>
<title>Available Capabilities</title>
<tgroup cols='3' align='left' colsep='1'
rowsep='1'>
- <colspec colname='c1' colwidth="1.5*" />
+ <colspec colname='c1' colwidth="1*" />
<colspec colname='c2' colwidth="1*" />
- <colspec colname='c3' colwidth="2*" />
+ <colspec colname='c3' colwidth="3*" />
<thead>
<row>
<entry>
@@ -832,7 +835,7 @@
<para/>
</entry>
<entry>
- <para>Translator can support comparison criteria with the
operator "=”.</para>
+ <para>Translator can support comparison criteria with the
operator "=".</para>
</entry>
</row>
<row>
@@ -843,7 +846,7 @@
<para/>
</entry>
<entry>
- <para>Translator can support comparison criteria with the
operator ">” or "<".</para>
+ <para>Translator can support comparison criteria with the
operator ">" or "<".</para>
</entry>
</row>
<row>
@@ -1148,7 +1151,7 @@
<para />
</entry>
<entry>
- <para>Translator can support "searched” CASE expressions
anywhere that expressions are
+ <para>Translator can support "searched" CASE
expressions anywhere that expressions are
accepted.</para>
</entry>
</row>
@@ -1306,8 +1309,8 @@
<para>The method
<code>ExecutionFactory.getSupportedFunctions()</code> can be
used to specify which scalar functions the Translator supports. The
set of possible functions is based on the set of functions supported
- by Teiid. This set can be found in the <ulink
url="&docUrl;">Reference</ulink>
- documentation. If the Translator states that it supports a function,
+ by Teiid. This set can be found in the Reference documentation at
+ <ulink url="&docUrl;"/>. If the Translator states that
it supports a function,
it must support all type combinations and overloaded forms of that
function.</para>
<para>There are also five standard operators that can also be specified in the
@@ -1358,9 +1361,9 @@
<section>
<title>Data Types</title>
<para>Teiid supports three large object runtime data types: blob,
- clob, and xml. A blob is a “binary large object”, a clob is a
- “character large object”, and “xml” is a “xml
- document”. Columns modeled as a blob, clob, or xml are treated similarly by
+ clob, and xml. A blob is a "binary large object", a clob is a
+ "character large object", and "xml" is a "xml
+ document". Columns modeled as a blob, clob, or xml are treated similarly by
the translator framework to support memory-safe streaming. </para>
</section>
<section>
@@ -1408,7 +1411,7 @@
<para>When the "keepAlive" alive flag is set, then the execution object
is only closed when user's Statement is closed.</para>
- <programlisting><![CDATA[executionContext.keepExecutionAlive(true);]]></programlisting>
+ <programlisting language="Java"
role="JAVA"><![CDATA[executionContext.keepExecutionAlive(true);]]></programlisting>
</section>
@@ -1424,17 +1427,21 @@
<section id="translator_package">
<title>Packaging</title>
- <para>Once the "ExecutionFactory" class is implemented, package
it in a JAR file. The only
- additional requirement is provide a file called "jboss-beans.xml" in
the "META-INF" directory of the JAR file, with
- following contents.
- <programlisting><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
+ <para>
+ Once the "ExecutionFactory" class is implemented, package it in a JAR
file. The only
+ additional requirement is provide a file called "jboss-beans.xml" in
the "META-INF"
+ directory of the JAR file, with following contents. Replace ${name} with name of
your
+ translator, and replace ${execution-factory-class} with your overridden
ExecutionFactory
+ class name. This will register the Translator for use with tooling and Admin
API.
+ </para>
+ <programlisting role="XML"
language="XML"><![CDATA[<?xml version="1.0"
encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
+
<bean name="translator-${name}-template"
class="org.teiid.templates.TranslatorDeploymentTemplate">
<property name="info"><inject
bean="translator-${name}"/></property>
<property name="managedObjectFactory"><inject
bean="ManagedObjectFactory"/></property>
</bean>
-
+
<bean name="translator-${name}"
class="org.teiid.templates.TranslatorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="TranslatorDeploymentTemplateInfoFactory"/>
@@ -1444,11 +1451,10 @@
<parameter class="java.lang.String">${name}</parameter>
</constructor>
</bean>
-
+
</deployment>]]></programlisting>
- replace ${name} with name of your translator, and replace
${execution-factory-class} with your
- overridden ExecutionFactory class name. This will register the Translator
for use with tooling and Admin API.</para>
+
</section>
<section id="translator_deploy">
Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -95,7 +95,7 @@
functions score and contains:
</para>
<informalexample>
- <programlisting>SELECT score(1), ID, FREEDATA FROM Docs WHERE contains(freedata,
'nick', 1) > 0</programlisting>
+ <programlisting language="SQL">SELECT score(1), ID, FREEDATA FROM Docs
WHERE contains(freedata, 'nick', 1) > 0</programlisting>
</informalexample>
<para>
The
@@ -136,7 +136,9 @@
<listitem>
<para>
Create a new translator jar containing your custom
- ExecutionFactory. See <link
linkend="translator_package">packaging</link> and <link
linkend="translator_deploy">deployment</link> instructions for using
the jar.</para>
+ ExecutionFactory. Refer to <xref linkend="translator_package"/> and
+ <xref linkend="translator_deploy"/> for instructions on using the
JAR file.
+ </para>
</listitem>
</itemizedlist>
</section>
@@ -163,8 +165,7 @@
<listitem>
<para>
Number of input arguments and types must match the function metadata defined
- in section
- <link linkend="define_udf">Install user-defined
functions</link>
+ in <xref linkend="define_udf"/>.
</para>
</listitem>
<listitem>
@@ -181,22 +182,24 @@
This <code>CommandContext</code> parameter does not need to be delared in
the function metadata.</para>
<example>
<title>Sample code</title>
- <programlisting><![CDATA[package org.something;
+ <programlisting language="Java"
role="JAVA"><![CDATA[package org.something;
-public class TempConv {
-
- /**
- * Converts the given Celsius temperature to Fahrenheit, and returns the
- * value.
- * @param doubleCelsiusTemp
- * @return Fahrenheit
- */
- public static Double celsiusToFahrenheit(Double doubleCelsiusTemp){
- if (doubleCelsiusTemp == null) {
- return null;
- }
- return (doubleCelsiusTemp)*9/5 + 32;
- }
+public class TempConv
+{
+ /**
+ * Converts the given Celsius temperature to Fahrenheit, and returns the
+ * value.
+ * @param doubleCelsiusTemp
+ * @return Fahrenheit
+ */
+ public static Double celsiusToFahrenheit(Double doubleCelsiusTemp)
+ {
+ if (doubleCelsiusTemp == null)
+ {
+ return null;
+ }
+ return (doubleCelsiusTemp)*9/5 + 32;
+ }
}]]></programlisting>
</example>
</section>
Deleted: trunk/documentation/developer-guide/src/main/docbook/en-US/main.xml
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/main.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/documentation/developer-guide/src/main/docbook/en-US/main.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,60 +0,0 @@
-<?xml version='1.0' encoding="UTF-8"?>
-<!--
-
- JBoss, Home of Professional Open Source.
- Copyright (C) 2008 Red Hat, Inc.
- Licensed to Red Hat, Inc. under one or more contributor
- license agreements. See the copyright.txt file in the
- distribution for a full listing of individual contributors.
-
- 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.
-
--->
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-
-<book>
-
- <bookinfo>
- <title>Teiid - Scalable Information Integration</title>
- <subtitle>Teiid Developer's Guide</subtitle>
- <releaseinfo>&versionNumber;</releaseinfo>
- <productnumber>&versionNumber;</productnumber>
- <issuenum>1</issuenum>
- <copyright>
- <year>©rightYear;</year>
- <holder>©rightHolder;</holder>
- </copyright>
- <xi:include href="../../../../../docbook/en-US/legal_notice.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- </bookinfo>
-
- <toc/>
-
- <xi:include href="content/introduction.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/develop-adapter.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/translator-api.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/extending-jdbc.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/udf.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/adminapi.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/logging.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/security.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/appendix-a.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/appendix-b.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
-
-</book>
-
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
<chapter id="scalar_functions">
<title>Scalar Functions</title>
<para>
@@ -1862,9 +1865,10 @@
<para><code>ENV(key)</code></para>
</entry>
<entry>
- <para>Retrieve an environment property. The only key
- currently allowed is ‘sessionid’, although this will expand
- in the future.</para>
+ <para>Retrieve a system environment property. The only key specific
to the current session is ‘sessionid’.
+ However the preferred mechanism for getting the session id is with the
session_id() function.
+ To prevent untrusted access to system properties, the use of this
function must be specifically enabled in the &jboss-beans; file.
+ </para>
</entry>
<entry>
<para>key in {string}, return is string</para>
@@ -1872,6 +1876,17 @@
</row>
<row>
<entry>
+ <para><code>SESSION_ID()</code></para>
+ </entry>
+ <entry>
+ <para>Retrieve the string form of the current session
id.</para>
+ </entry>
+ <entry>
+ <para>return is string</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para><code>USER()</code></para>
</entry>
<entry>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1236,8 +1236,9 @@
<para>Subqueries supported in the criteria of the outer query include
subqueries in an IN clause, subqueries using the ANY/SOME or ALL predicate quantifier, and
subqueries using the EXISTS predicate. </para>
<example>
<title>Example Subquery in WHERE Using EXISTS</title>
- <programlisting>SELECT a FROM X WHERE EXISTS (SELECT b, c FROM Y WHERE
c=3)</programlisting>
+ <programlisting>SELECT a FROM X WHERE EXISTS (SELECT 1 FROM Y WHERE
c=X.a)</programlisting>
</example>
+ <note><para>EXISTS subqueries should typically follow the convention
"SELECT 1 FROM ..." to prevent unnecessary evaluation of select
expressions.</para></note>
<para>
The following usages of subqueries must each select only one column, but can
return any number of rows.
</para>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1277,7 +1277,15 @@
You must deploy a separate data source for each source defined in the xml
file.
</para>
</note>
-
+
+ <note>
+ <para>
+ If you would like to use "SOURCE_NAME" in your transformations to
control which sources are accessed or updated,
+ you would manually need to add this extra column on your view table in
+ the Designer. This column will not be automatically added on the source
table, when you import
+ the medata from source.
+ </para>
+ </note>
</section>
</chapter>
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -47,7 +47,7 @@
private static final long serialVersionUID = 6304443387337336957L;
private int rowOffset;
- private List<List> tuples;
+ private List<List<?>> tuples;
// Optional state
private boolean terminationFlag = false;
@@ -73,7 +73,7 @@
* @param tuples array of List objects, each of which is
* a single tuple
*/
- public TupleBatch(int beginRow, List[] tuples) {
+ public TupleBatch(int beginRow, List<?>[] tuples) {
this.rowOffset = beginRow;
this.tuples = Arrays.asList(tuples);
}
@@ -124,7 +124,7 @@
return tuples.get(rowIndex-rowOffset);
}
- public List<List> getTuples() {
+ public List<List<?>> getTuples() {
return tuples;
}
@@ -182,7 +182,7 @@
if (types == null) {
types = preservedTypes;
}
- tuples = new ArrayList<List>();
+ tuples = new ArrayList<List<?>>();
for (List tuple : BatchSerializer.readBatch(in, types)) {
tuples.add(tuple);
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -170,7 +170,7 @@
}
result.setLeftQuery(translate(union.getLeftQuery()));
result.setRightQuery(translate(union.getRightQuery()));
- result.setOrderBy(translate(union.getOrderBy()));
+ result.setOrderBy(translate(union.getOrderBy(), true));
result.setLimit(translate(union.getLimit()));
result.setWith(translate(union.getWith()));
return result;
@@ -211,7 +211,7 @@
Select q = new Select(translatedSymbols, query
.getSelect().isDistinct(), items,
translate(query.getCriteria()), translate(query.getGroupBy()),
- translate(query.getHaving()), translate(query.getOrderBy()));
+ translate(query.getHaving()), translate(query.getOrderBy(), false));
q.setLimit(translate(query.getLimit()));
q.setWith(translate(query.getWith()));
return q;
@@ -443,7 +443,7 @@
return new org.teiid.language.GroupBy(translatedItems);
}
- public org.teiid.language.OrderBy translate(OrderBy orderBy) {
+ public org.teiid.language.OrderBy translate(OrderBy orderBy, boolean set) {
if(orderBy == null){
return null;
}
@@ -454,10 +454,10 @@
Ordering direction = items.get(i).isAscending() ? Ordering.ASC:
Ordering.DESC;
SortSpecification orderByItem = null;
- if(symbol instanceof AliasSymbol || !items.get(i).isUnrelated()){
+ if(items.get(i).isUnrelated() || (!set && symbol instanceof
ElementSymbol)){
+ orderByItem = new SortSpecification(direction, translate(symbol));
+ } else {
orderByItem = new SortSpecification(direction, new ColumnReference(null,
symbol.getOutputName(), null, symbol.getType()));
- } else {
- orderByItem = new SortSpecification(direction, translate(symbol));
}
orderByItem.setNullOrdering(items.get(i).getNullOrdering());
translatedItems.add(orderByItem);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -472,7 +472,7 @@
return this.requests.get(processorID);
}
- public WorkerPoolStatisticsMetadata getWorkManagerStatistics() {
+ public WorkerPoolStatisticsMetadata getWorkerPoolStatistics() {
return this.processWorkerPool.getStats();
}
@@ -497,8 +497,8 @@
}
}
- public boolean cancelRequest(String sessionId, long requestId) throws
TeiidComponentException {
- RequestID requestID = new RequestID(sessionId, requestId);
+ public boolean cancelRequest(String sessionId, long executionId) throws
TeiidComponentException {
+ RequestID requestID = new RequestID(sessionId, executionId);
return cancelRequest(requestID);
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -110,9 +110,8 @@
for (Iterator<SPParameter> params = spParams.iterator(); params.hasNext();) {
SPParameter param = params.next();
if (param.getParameterType() == SPParameter.RETURN_VALUE) {
- continue;
- }
- if (param.getExpression() instanceof Reference && index > inParameterCount)
{
+ inParameterCount++;
+ } else if (param.getExpression() instanceof Reference && index >
inParameterCount) {
//assume it's an output parameter
this.prepPlan.getReferences().remove(param.getExpression());
continue;
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 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -78,9 +78,7 @@
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Limit;
-import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.QueryCommand;
-import org.teiid.query.sql.lang.SetQuery;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.GroupSymbol;
@@ -203,20 +201,8 @@
}
protected void createCommandContext() throws QueryValidatorException {
- boolean returnsResultSet = false;
- this.returnsUpdateCount = true;
- if(userCommand instanceof Query) {
- Query query = (Query)userCommand;
- returnsResultSet = query.getInto() == null;
- returnsUpdateCount = !returnsResultSet;
- } else if (userCommand instanceof SetQuery) {
- returnsResultSet = true;
- returnsUpdateCount = false;
- } else if (userCommand instanceof StoredProcedure) {
- returnsUpdateCount = false;
- StoredProcedure proc = (StoredProcedure)userCommand;
- returnsResultSet = proc.returnsResultSet();
- }
+ boolean returnsResultSet = userCommand.returnsResultSet();
+ this.returnsUpdateCount = !(userCommand instanceof StoredProcedure) &&
!returnsResultSet;
if ((this.requestMsg.getResultsMode() == ResultsMode.UPDATECOUNT &&
!returnsUpdateCount)
|| (this.requestMsg.getResultsMode() == ResultsMode.RESULTSET &&
!returnsResultSet)) {
throw new
QueryValidatorException(QueryPlugin.Util.getString(this.requestMsg.getResultsMode()==ResultsMode.RESULTSET?"Request.no_result_set":"Request.result_set"));
//$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -422,7 +422,7 @@
//TODO: support fetching more than 1 batch
boolean fromBuffer = false;
- if (batch == null || !(batch.containsRow(this.begin))) {
+ if (batch == null || !(batch.containsRow(this.begin) || (batch.getTerminationFlag()
&& batch.getEndRow() <= this.begin))) {
if (savedBatch != null && savedBatch.containsRow(this.begin)) {
batch = savedBatch;
} else {
@@ -441,7 +441,7 @@
} else if (fromBuffer && isForwardOnly()) {
savedBatch = batch;
}
- List<List> memoryRows = batch.getTuples();
+ List<List<?>> memoryRows = batch.getTuples();
batch = new TupleBatch(beginRow, memoryRows.subList(beginRow -
batch.getBeginRow(), endRow - batch.getBeginRow() + 1));
batch.setTerminationFlag(last);
} else if (!fromBuffer){
@@ -561,7 +561,7 @@
public boolean requestCancel() throws TeiidComponentException {
synchronized (this) {
- if (this.isCanceled) {
+ if (this.isCanceled || this.closeRequested) {
return false;
}
this.isCanceled = true;
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -330,5 +330,15 @@
return actualMetadata.getNativeType(elementID);
}
+
+ @Override
+ public boolean isMultiSource(Object modelId) throws QueryMetadataException,
TeiidComponentException {
+ return multiSourceModels.contains(getFullName(modelId));
+ }
+
+ @Override
+ public boolean isMultiSourceElement(Object elementId) {
+ return elementId instanceof MultiSourceElement;
+ }
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -37,7 +37,6 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.query.analysis.AnalysisRecord;
-import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.relational.PlanToProcessConverter;
@@ -45,19 +44,19 @@
import org.teiid.query.processor.relational.AccessNode;
import org.teiid.query.processor.relational.GroupingNode;
import org.teiid.query.processor.relational.NullNode;
+import org.teiid.query.processor.relational.ProjectIntoNode;
import org.teiid.query.processor.relational.ProjectNode;
import org.teiid.query.processor.relational.RelationalNode;
import org.teiid.query.processor.relational.RelationalNodeUtil;
+import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.processor.relational.UnionAllNode;
-import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.resolver.util.ResolverUtil;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ExpressionSymbol;
-import org.teiid.query.sql.symbol.Function;
import org.teiid.query.util.CommandContext;
@@ -66,6 +65,9 @@
private Set<String> multiSourceModels;
private DQPWorkContext workContext;
+ private boolean multiSource;
+ private boolean update;
+
public MultiSourcePlanToProcessConverter(QueryMetadataInterface metadata,
IDGenerator idGenerator, AnalysisRecord analysisRecord,
CapabilitiesFinder capFinder, Set<String> multiSourceModels,
@@ -74,6 +76,22 @@
this.multiSourceModels = multiSourceModels;
this.workContext = workContext;
}
+
+ @Override
+ public synchronized RelationalPlan convert(PlanNode planNode)
+ throws QueryPlannerException, TeiidComponentException {
+ RelationalPlan result = null;
+ try {
+ result = super.convert(planNode);
+ return result;
+ } finally {
+ if (result != null && update && multiSource) {
+ result.setMultisourceUpdate(true);
+ }
+ update = false;
+ multiSource = false;
+ }
+ }
protected RelationalNode convertNode(PlanNode planNode) throws QueryPlannerException,
TeiidComponentException {
RelationalNode node = super.convertNode(planNode);
@@ -84,6 +102,8 @@
} catch (TeiidProcessingException e) {
throw new QueryPlannerException(e, e.getMessage());
}
+ } else if (node instanceof ProjectIntoNode) {
+ throw new AssertionError("Multisource insert with query expression not allowed
not allowed, should have been caught in validation."); //$NON-NLS-1$
}
return node;
@@ -148,7 +168,7 @@
}
default:
{
-
+ multiSource = true;
UnionAllNode unionNode = new UnionAllNode(getID());
unionNode.setElements(accessNode.getElements());
@@ -160,23 +180,20 @@
// More than 1 access node - replace with a union
if (RelationalNodeUtil.isUpdate(accessNode.getCommand())) {
-
+ update = true;
GroupingNode groupNode = new GroupingNode(getID());
AggregateSymbol sumCount = new AggregateSymbol("SumCount",
NonReserved.SUM, false, (Expression)accessNode.getElements().get(0)); //$NON-NLS-1$
- List outputElements = new ArrayList();
+ List<Expression> outputElements = new ArrayList<Expression>(1);
outputElements.add(sumCount);
groupNode.setElements(outputElements);
groupNode.addChild(unionNode);
ProjectNode projectNode = new ProjectNode(getID());
- // two converts because, the 2nd one does not resolve because of no
metadata about the expression.
- Function convertFunc = new Function(FunctionLibrary.CONVERT, new
Expression[] {new Constant(new Long(0)), new
Constant(DataTypeManager.DefaultDataTypes.INTEGER)});
- ResolverVisitor.resolveLanguageObject(convertFunc, metadata);
- Function convertFunc2 = new Function(FunctionLibrary.CONVERT, new
Expression[] {sumCount, new Constant(DataTypeManager.DefaultDataTypes.INTEGER)});
- convertFunc2.setFunctionDescriptor(convertFunc.getFunctionDescriptor());
- Expression rowCount = new ExpressionSymbol("RowCount",
convertFunc2); //$NON-NLS-1$
- outputElements = new ArrayList();
+ Expression intSum = ResolverUtil.convertExpression(sumCount,
DataTypeManager.DefaultDataTypes.STRING, metadata);
+
+ Expression rowCount = new ExpressionSymbol("RowCount", intSum);
//$NON-NLS-1$
+ outputElements = new ArrayList<Expression>(1);
outputElements.add(rowCount);
projectNode.setElements(outputElements);
projectNode.setSelectSymbols(outputElements);
@@ -184,8 +201,6 @@
parent = projectNode;
}
-
- parent.setMultiSource(true);
return parent;
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -66,7 +66,7 @@
public SessionMetadata createSession(String userName,
Credentials credentials,
String applicationName,
- Properties properties, boolean admin)
+ Properties properties, boolean admin,
boolean authenticate)
throws LoginException, SessionServiceException;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -56,7 +56,8 @@
// Special user function
public static final String USER = "user"; //$NON-NLS-1$
// Special environment variable lookup function
- public static final String ENV = "env"; //$NON-NLS-1$
+ public static final String ENV = "env"; //$NON-NLS-1$
+ public static final String SESSION_ID = "session_id"; //$NON-NLS-1$
// Special pseudo-functions only for XML queries
public static final String CONTEXT = "context"; //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1240,6 +1240,10 @@
return value;
}
+ public static Object session_id(CommandContext context) {
+ return context.getConnectionID();
+ }
+
// ================= Function - MODIFYTIMEZONE ========================
public static Object modifyTimeZone(Timestamp value, String originalTimezoneString,
String targetTimezoneString) {
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -72,46 +72,27 @@
* Function lookup and invocation use: Function name (uppercase) to Map (recursive
tree)
*/
private Map treeRoot = new HashMap();
+ private boolean validateClass;
/**
* Construct a new tree with the given source of function metadata.
* @param source The metadata source
*/
public FunctionTree(FunctionMetadataSource source) {
- // Load data structures
- addSource(source);
+ this(source, false);
}
-
+
/**
- * Construct a new tree with the given collection of sources.
- * @param sources The collection of function metadata sources ({@link
org.teiid.query.function.FunctionMetadataSource})
+ * Construct a new tree with the given source of function metadata.
+ * @param source The metadata source
*/
- FunctionTree(Collection sources) {
+ public FunctionTree(FunctionMetadataSource source, boolean validateClass) {
// Load data structures
- addSources(sources);
+ this.validateClass = validateClass;
+ addSource(source);
}
/**
- * Add a collection of functions to the data structures.
- * @param sources The function metadata sources ({@link
org.teiid.query.function.FunctionMetadataSource})
- */
- private void addSources(Collection sources) {
- if(sources == null) {
- return;
- }
-
- Iterator sourceIter = sources.iterator();
- while(sourceIter.hasNext()) {
- Object sourceObj = sourceIter.next();
- if(sourceObj instanceof FunctionMetadataSource) {
- addSource((FunctionMetadataSource) sourceObj);
- } else {
- Assertion.failed(QueryPlugin.Util.getString("ERR.015.001.0044",
sourceObj.getClass().getName())); //$NON-NLS-1$
- }
- }
- }
-
- /**
* Add all functions from a metadata source to the data structures.
* @param source The source of the functions
*/
@@ -294,7 +275,7 @@
// Defect 20007 - Ignore the invocation method if pushdown is not required.
if (method.getPushdown() == FunctionMethod.CAN_PUSHDOWN || method.getPushdown()
== FunctionMethod.CANNOT_PUSHDOWN) {
try {
- Class methodClass =
source.getInvocationClass(method.getInvocationClass());
+ Class<?> methodClass =
source.getInvocationClass(method.getInvocationClass());
ReflectionHelper helper = new ReflectionHelper(methodClass);
try {
invocationMethod =
helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
@@ -304,15 +285,31 @@
requiresContext = true;
}
} catch (ClassNotFoundException e) {
- // Failed to load class, so can't load method - this will fail at
invocation time.
- // We don't fail here because this situation can occur in the modeler,
which does
- // not have the function jar files. The modeler never invokes, so this
isn't a
- // problem.
+ if (validateClass) {
+ throw new TeiidRuntimeException(e, "ERR.015.001.0047",
QueryPlugin.Util.getString("FunctionTree.no_class", method.getName(),
method.getInvocationClass())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (NoSuchMethodException e) {
+ throw new TeiidRuntimeException(e, "ERR.015.001.0047",
QueryPlugin.Util.getString("FunctionTree.no_method", method,
method.getInvocationClass(), method.getInvocationMethod())); //$NON-NLS-1$ //$NON-NLS-2$
} catch (Exception e) {
- throw new TeiidRuntimeException(e, "ERR.015.001.0047",
QueryPlugin.Util.getString("ERR.015.001.0047", new
Object[]{method.getInvocationClass(), invocationMethod, inputTypes})); //$NON-NLS-1$
//$NON-NLS-2$
+ throw new TeiidRuntimeException(e, "ERR.015.001.0047",
QueryPlugin.Util.getString("ERR.015.001.0047", method,
method.getInvocationClass(), method.getInvocationMethod())); //$NON-NLS-1$ //$NON-NLS-2$
}
- if(invocationMethod != null &&
!FunctionTree.isValidMethod(invocationMethod)) {
- throw new TeiidRuntimeException("ERR.015.001.0047",
QueryPlugin.Util.getString("ERR.015.001.0047", new
Object[]{method.getInvocationClass(), invocationMethod, inputTypes})); //$NON-NLS-1$
//$NON-NLS-2$
+ if (invocationMethod != null) {
+ // Check return type is non void
+ Class<?> methodReturn = invocationMethod.getReturnType();
+ if(methodReturn.equals(Void.TYPE)) {
+ throw new TeiidRuntimeException("ERR.015.001.0047",
QueryPlugin.Util.getString("FunctionTree.not_void", method.getName(),
invocationMethod)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Check that method is public
+ int modifiers = invocationMethod.getModifiers();
+ if(! Modifier.isPublic(modifiers)) {
+ throw new TeiidRuntimeException("ERR.015.001.0047",
QueryPlugin.Util.getString("FunctionTree.not_public", method.getName(),
invocationMethod)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Check that method is static
+ if(! Modifier.isStatic(modifiers)) {
+ throw new TeiidRuntimeException("ERR.015.001.0047",
QueryPlugin.Util.getString("FunctionTree.not_static", method.getName(),
invocationMethod)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
} else {
inputTypes.add(0, CommandContext.class);
@@ -342,33 +339,6 @@
node.put(DESCRIPTOR_KEY, descriptor);
}
- /**
- * Validate a method looked up by reflection. The method should have a non-void return
type
- * and be a public static method.
- * @param method Method to validate
- * @return True if valid
- */
- static boolean isValidMethod(Method method) {
- // Check return type is non void
- Class methodReturn = method.getReturnType();
- if(methodReturn.equals(Void.TYPE)) {
- return false;
- }
-
- // Check that method is public
- int modifiers = method.getModifiers();
- if(! Modifier.isPublic(modifiers)) {
- return false;
- }
-
- // Check that method is static
- if(! Modifier.isStatic(modifiers)) {
- return false;
- }
-
- return true;
- }
-
/**
* Look up a function descriptor by signature in the tree. If none is
* found, null is returned.
Modified: trunk/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -32,30 +32,28 @@
public class SystemFunctionManager {
- private static FunctionTree systemFunctionTree;
+ private FunctionTree systemFunctionTree;
+ private boolean allowEnvFunction = true;
- static {
- // Create the system source and add it to the source list
- SystemSource systemSource = new SystemSource();
-
- // Validate the system source - should never fail
- ActivityReport report = new ActivityReport("Function Validation");
//$NON-NLS-1$
- validateSource(systemSource, report);
- if(report.hasItems()) {
- // Should never happen as SystemSource doesn't change
- System.err.println(QueryPlugin.Util.getString("ERR.015.001.0005",
report)); //$NON-NLS-1$
- }
-
- systemFunctionTree = new FunctionTree(systemSource);
- }
+ public FunctionTree getSystemFunctions() {
+ if(systemFunctionTree == null) {
+ // Create the system source and add it to the source list
+ SystemSource systemSource = new SystemSource(this.allowEnvFunction);
-
- public static FunctionTree getSystemFunctions() {
+ // Validate the system source - should never fail
+ ActivityReport report = new ActivityReport("Function Validation");
//$NON-NLS-1$
+ validateSource(systemSource, report);
+ if(report.hasItems()) {
+ // Should never happen as SystemSourcTe doesn't change
+ System.err.println(QueryPlugin.Util.getString("ERR.015.001.0005",
report)); //$NON-NLS-1$
+ }
+ systemFunctionTree = new FunctionTree(systemSource, true);
+ }
return systemFunctionTree;
}
- public static FunctionLibrary getSystemFunctionLibrary() {
- return new FunctionLibrary(systemFunctionTree, new FunctionTree(new
UDFSource(Collections.EMPTY_LIST)));
+ public FunctionLibrary getSystemFunctionLibrary() {
+ return new FunctionLibrary(getSystemFunctions(), new FunctionTree(new
UDFSource(Collections.EMPTY_LIST)));
}
/**
@@ -64,8 +62,16 @@
* @param source Source of function metadata
* @param report Report to update with any problems
*/
- private static void validateSource(FunctionMetadataSource source, ActivityReport
report) {
+ private void validateSource(FunctionMetadataSource source, ActivityReport report) {
Collection functionMethods = source.getFunctionMethods();
FunctionMetadataValidator.validateFunctionMethods(functionMethods,report);
}
+
+ public boolean isAllowEnvFunction() {
+ return allowEnvFunction;
+ }
+
+ public void setAllowEnvFunction(boolean allowEnvFunction) {
+ this.allowEnvFunction = allowEnvFunction;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -55,7 +55,7 @@
/**
* Construct a source of system metadata.
*/
- public SystemSource() {
+ public SystemSource(boolean allowEnvFunction) {
// +, -, *, /
addArithmeticFunction(SourceSystemFunctions.ADD_OP,
QueryPlugin.Util.getString("SystemSource.Add_desc"), "plus",
QueryPlugin.Util.getString("SystemSource.Add_result_desc")); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
addArithmeticFunction(SourceSystemFunctions.SUBTRACT_OP,
QueryPlugin.Util.getString("SystemSource.Subtract_desc"), "minus",
QueryPlugin.Util.getString("SystemSource.Subtract_result_desc")); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
@@ -158,7 +158,10 @@
addLookupFunctions();
addUserFunction();
addCurrentDatabaseFunction();
- addEnvFunction();
+ if (allowEnvFunction) {
+ addEnvFunction();
+ }
+ addSessionIdFunction();
addCommandPayloadFunctions();
addIfNullFunctions();
@@ -787,6 +790,12 @@
new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING,
QueryPlugin.Util.getString("SystemSource.Env_result")), false,
FunctionMethod.SESSION_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
+ private void addSessionIdFunction() {
+ functions.add(
+ new FunctionMethod(FunctionLibrary.SESSION_ID,
QueryPlugin.Util.getString("SystemSource.session_id_desc"), MISCELLANEOUS,
FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "session_id", null,
//$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING,
QueryPlugin.Util.getString("SystemSource.session_id_result")), false,
FunctionMethod.SESSION_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
private void addCommandPayloadFunctions() {
functions.add(
new FunctionMethod("commandpayload",
QueryPlugin.Util.getString("SystemSource.CommandPayload_desc0"), MISCELLANEOUS,
FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "commandPayload", //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -508,5 +508,15 @@
public Object getPrimaryKey(Object metadataID) {
return null;
}
+
+ @Override
+ public boolean isMultiSource(Object modelId) {
+ return false;
+ }
+
+ @Override
+ public boolean isMultiSourceElement(Object elementId) {
+ return false;
+ }
}
Modified:
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -373,5 +373,15 @@
public Object getPrimaryKey(Object metadataID) {
return actualMetadata.getPrimaryKey(metadataID);
}
+
+ @Override
+ public boolean isMultiSource(Object modelId) throws QueryMetadataException,
TeiidComponentException {
+ return actualMetadata.isMultiSource(modelId);
+ }
+
+ @Override
+ public boolean isMultiSourceElement(Object elementId) {
+ return actualMetadata.isMultiSourceElement(elementId);
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -680,4 +680,8 @@
FunctionLibrary getFunctionLibrary();
Object getPrimaryKey(Object metadataID);
+
+ boolean isMultiSource(Object modelId) throws QueryMetadataException,
TeiidComponentException;
+
+ boolean isMultiSourceElement(Object elementId);
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -65,7 +65,6 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.UDFSource;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.mapping.relational.QueryNode;
@@ -145,7 +144,7 @@
* TransformationMetadata constructor
* @param context Object containing the info needed to lookup metadta.
*/
- public TransformationMetadata(VDBMetaData vdbMetadata, final CompositeMetadataStore
store, Map<String, Resource> vdbEntries, Collection <FunctionMethod>
udfMethods) {
+ public TransformationMetadata(VDBMetaData vdbMetadata, final CompositeMetadataStore
store, Map<String, Resource> vdbEntries, Collection <FunctionMethod>
udfMethods, FunctionTree systemFunctions) {
ArgCheck.isNotNull(store);
this.vdbMetaData = vdbMetadata;
this.store = store;
@@ -157,7 +156,7 @@
if (udfMethods == null) {
udfMethods = Collections.emptyList();
}
- this.functionLibrary = new
FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(udfMethods)));
+ this.functionLibrary = new FunctionLibrary(systemFunctions, new FunctionTree(new
UDFSource(udfMethods), true));
}
//==================================================================================
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -224,7 +224,10 @@
if (command.getType() == Command.TYPE_DYNAMIC){
instruction = new
ExecDynamicSqlInstruction(parentProcCommand,((DynamicCommand)command), metadata,
idGenerator, capFinder );
}else{
- instruction = new
CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan);
+ instruction = new
CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan,
+ command.getType() == Command.TYPE_INSERT
+ || command.getType() == Command.TYPE_UPDATE
+ || command.getType() == Command.TYPE_DELETE);
}
if(debug) {
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -263,7 +263,7 @@
*/
public void visit(Query obj) {
if (obj.getOrderBy() != null || obj.getLimit() != null) {
- visitor.namingContext.aliasColumns = true && !stripColumnAliases;
+ visitor.namingContext.aliasColumns = !stripColumnAliases;
}
visitNode(obj.getFrom());
visitNode(obj.getCriteria());
@@ -360,8 +360,10 @@
if (needsAlias) {
element = new AliasSymbol(element.getShortName(),
(SingleElementSymbol)expr);
- obj.getOrderByItems().get(i).setSymbol(element);
+ } else if (expr instanceof ElementSymbol) {
+ element = (ElementSymbol)expr;
}
+ item.setSymbol(element);
element.setOutputName(name);
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/BatchedUpdatePlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/BatchedUpdatePlan.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/processor/BatchedUpdatePlan.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -143,7 +143,7 @@
openPlan();
}
// Execute nextBatch() on each plan in sequence
- List<List> currentBatch =
updatePlans[planIndex].nextBatch().getTuples(); // Can throw BlockedException
+ List<List<?>> currentBatch =
updatePlans[planIndex].nextBatch().getTuples(); // Can throw BlockedException
for (int i = 0; i < currentBatch.size(); i++, commandIndex++) {
updateCounts[commandIndex] = currentBatch.get(i);
}
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -41,10 +41,12 @@
protected String rsName;
protected ProcessorPlan plan;
+ private boolean update;
- public CreateCursorResultSetInstruction(String rsName, ProcessorPlan plan){
+ public CreateCursorResultSetInstruction(String rsName, ProcessorPlan plan, boolean
update){
this.rsName = rsName;
this.plan = plan;
+ this.update = update;
}
/**
@@ -64,6 +66,16 @@
}
procEnv.executePlan(plan, rsName);
+
+ if (update) {
+ boolean hasNext = procEnv.iterateCursor(rsName);
+ if (hasNext) {
+ procEnv.getContext().getVariableContext().setValue(ProcedurePlan.ROWCOUNT,
procEnv.getCurrentRow(rsName).get(0));
+ } else {
+ procEnv.getContext().getVariableContext().setValue(ProcedurePlan.ROWCOUNT, 0);
+ }
+ procEnv.removeResults(rsName);
+ }
}
/**
@@ -71,7 +83,7 @@
*/
public CreateCursorResultSetInstruction clone(){
ProcessorPlan clonedPlan = this.plan.clone();
- return new CreateCursorResultSetInstruction(this.rsName, clonedPlan);
+ return new CreateCursorResultSetInstruction(this.rsName, clonedPlan, update);
}
public String toString(){
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -191,7 +191,7 @@
.createNonRecordingRecord(), procEnv
.getContext());
- CreateCursorResultSetInstruction inst = new
CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan) {
+ CreateCursorResultSetInstruction inst = new
CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan,
dynamicCommand.getIntoGroup() != null) {
@Override
public void process(ProcedurePlan procEnv)
throws BlockedException, TeiidComponentException,
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -47,7 +47,7 @@
private List elements;
public LoopInstruction(Program loopProgram, String rsName, ProcessorPlan plan) {
- super(rsName, plan);
+ super(rsName, plan, false);
this.loopProgram = loopProgram;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -100,7 +100,9 @@
private static ElementSymbol ROWS_UPDATED =
new
ElementSymbol(ProcedureReservedWords.VARIABLES+"."+ProcedureReservedWords.ROWS_UPDATED);
//$NON-NLS-1$
- private static int NO_ROWS_UPDATED = 0;
+ static ElementSymbol ROWCOUNT =
+ new
ElementSymbol(ProcedureReservedWords.VARIABLES+"."+ProcedureReservedWords.ROWCOUNT);
//$NON-NLS-1$
+
private VariableContext currentVarContext;
private boolean isUpdateProcedure = true;
@@ -393,13 +395,14 @@
private void createVariableContext() {
this.currentVarContext = new VariableContext(true);
- this.currentVarContext.setValue(ROWS_UPDATED, new Integer(NO_ROWS_UPDATED));
+ this.currentVarContext.setValue(ROWS_UPDATED, 0);
+ this.currentVarContext.setValue(ROWCOUNT, 0);
}
private TupleSource getUpdateCountAsToupleSource() {
Object rowCount = currentVarContext.getValue(ROWS_UPDATED);
if(rowCount == null) {
- rowCount = new Integer(NO_ROWS_UPDATED);
+ rowCount = 0;
}
return CollectionTupleSource.createUpdateCountTupleSource((Integer)rowCount);
}
@@ -415,7 +418,7 @@
return this.currentVarContext;
}
- public CursorState executePlan(ProcessorPlan command, String rsName)
+ public void executePlan(ProcessorPlan command, String rsName)
throws TeiidComponentException, TeiidProcessingException {
CursorState state = this.cursorStates.get(rsName.toUpperCase());
@@ -438,12 +441,10 @@
this.currentState = state;
}
//force execution to the first batch
- this.currentState.ts.hasNext();
-
+ this.currentState.ts.hasNext();
this.cursorStates.put(rsName.toUpperCase(), this.currentState);
this.currentState = null;
}
- return state;
}
/**
@@ -536,7 +537,7 @@
return state;
}
- public void removeResults(String rsName) throws TeiidComponentException {
+ public void removeResults(String rsName) {
String rsKey = rsName.toUpperCase();
CursorState state = this.cursorStates.remove(rsKey);
if (state != null) {
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -88,8 +88,6 @@
/** Child nodes, usually just 1 or 2 */
private RelationalNode[] children = new RelationalNode[2];
- private boolean multiSource;
-
protected RelationalNode() {
}
@@ -599,11 +597,4 @@
return processingState;
}
- public boolean isMultiSource() {
- return multiSource;
- }
-
- public void setMultiSource(boolean multiSource) {
- this.multiSource = multiSource;
- }
}
\ No newline at end of file
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -29,13 +29,12 @@
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBatch;
-import org.teiid.common.buffer.TupleBuffer;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.language.SQLConstants;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.TempMetadataAdapter;
-import org.teiid.query.processor.BatchCollector;
+import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.QueryProcessor;
@@ -58,8 +57,9 @@
private List<WithQueryCommand> with;
private List<WithQueryCommand> withToProcess;
- private BatchCollector withBatchCollector;
+ private QueryProcessor withProcessor;
private TempTableStore tempTableStore;
+ private boolean multisourceUpdate;
/**
* Constructor for RelationalPlan.
@@ -127,22 +127,26 @@
}
while (!withToProcess.isEmpty()) {
WithQueryCommand withCommand = withToProcess.get(0);
- if (withBatchCollector == null) {
+ if (withProcessor == null) {
ProcessorPlan plan = withCommand.getCommand().getProcessorPlan();
- QueryProcessor qp = new QueryProcessor(plan, getContext(),
this.root.getBufferManager(), this.root.getDataManager());
- withBatchCollector = qp.createBatchCollector();
+ withProcessor = new QueryProcessor(plan, getContext(), this.root.getBufferManager(),
this.root.getDataManager());
+ Create create = new Create();
+ create.setColumns(withCommand.getColumns());
+ create.setTable(withCommand.getGroupSymbol());
+ this.root.getDataManager().registerRequest(getContext(), create,
TempMetadataAdapter.TEMP_MODEL.getID(), null, 0);
}
- TupleBuffer tb = withBatchCollector.collectTuples();
- Create create = new Create();
- create.setColumns(withCommand.getColumns());
- create.setTable(withCommand.getGroupSymbol());
- this.root.getDataManager().registerRequest(getContext(), create,
TempMetadataAdapter.TEMP_MODEL.getID(), null, 0);
- Insert insert = new Insert(withCommand.getGroupSymbol(), withCommand.getColumns(),
null);
- insert.setTupleSource(tb.createIndexedTupleSource(true));
- this.root.getDataManager().registerRequest(getContext(), insert,
TempMetadataAdapter.TEMP_MODEL.getID(), null, 0);
+ while (true) {
+ TupleBatch batch = withProcessor.nextBatch();
+ Insert insert = new Insert(withCommand.getGroupSymbol(),
withCommand.getColumns(), null);
+ insert.setTupleSource(new
CollectionTupleSource(batch.getTuples().iterator()));
+ this.root.getDataManager().registerRequest(getContext(), insert,
TempMetadataAdapter.TEMP_MODEL.getID(), null, 0);
+ if (batch.getTerminationFlag()) {
+ break;
+ }
+ }
this.tempTableStore.setUpdatable(withCommand.getGroupSymbol().getCanonicalName(),
false);
withToProcess.remove(0);
- withBatchCollector = null;
+ withProcessor = null;
}
}
this.root.open();
@@ -179,7 +183,7 @@
this.root.reset();
if (this.with != null) {
withToProcess = null;
- withBatchCollector = null;
+ withProcessor = null;
for (WithQueryCommand withCommand : this.with) {
withCommand.getCommand().getProcessorPlan().reset();
}
@@ -227,8 +231,15 @@
this.outputCols = outputCols;
}
+ public void setMultisourceUpdate(boolean multisourceUpdate) {
+ this.multisourceUpdate = multisourceUpdate;
+ }
+
@Override
public boolean requiresTransaction(boolean transactionalReads) {
+ if (multisourceUpdate) {
+ return true;
+ }
if (this.with != null) {
if (transactionalReads) {
return true;
@@ -239,9 +250,6 @@
}
}
}
- if (this.root.isMultiSource()) {
- return true;
- }
return requiresTransaction(transactionalReads, root);
}
@@ -257,7 +265,7 @@
}
if (node instanceof ProjectIntoNode) {
if (((ProjectIntoNode)node).getMode() == Mode.ITERATOR) {
- return false;
+ return transactionalReads;
}
return true;
} else if (node instanceof AccessNode) {
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -96,7 +96,7 @@
// Get old parameters as they may have expressions set on them - collect
// those expressions to copy later into the resolved parameters
- List oldParams = storedProcedureCommand.getParameters();
+ List<SPParameter> oldParams = storedProcedureCommand.getParameters();
boolean namedParameters = storedProcedureCommand.displayNamedParameters();
@@ -104,7 +104,7 @@
// as if named parameters were used. Even though the StoredProcedure was not
// parsed that way, the user may have entered no parameters with the intention
// of relying on all default values of all optional parameters.
- if (oldParams.size() == 0) {
+ if (oldParams.size() == 0 || (oldParams.size() == 1 &&
storedProcedureCommand.isCalledWithReturn())) {
storedProcedureCommand.setDisplayNamedParameters(true);
namedParameters = true;
}
@@ -113,81 +113,99 @@
// the procedure was parsed with named or unnamed parameters, the keys
// for this map will either be the String names of the parameters or
// the Integer indices, as entered in the user query
- Map inputExpressions = new HashMap();
- Iterator oldParamIter = oldParams.iterator();
- while(oldParamIter.hasNext()) {
- SPParameter param = (SPParameter) oldParamIter.next();
- if(param.getExpression() != null) {
- if (namedParameters) {
- if (inputExpressions.put(param.getName().toUpperCase(),
param.getExpression()) != null) {
- throw new
QueryResolverException(QueryPlugin.Util.getString("ExecResolver.duplicate_named_params",
param.getName().toUpperCase())); //$NON-NLS-1$
- }
- } else {
- inputExpressions.put(new Integer(param.getIndex()),
param.getExpression());
+ Map<Object, Expression> inputExpressions = new HashMap<Object,
Expression>();
+ for (SPParameter param : oldParams) {
+ if(param.getExpression() == null) {
+ continue;
+ }
+ if (namedParameters && param.getParameterType() !=
SPParameter.RETURN_VALUE) {
+ if (inputExpressions.put(param.getName().toUpperCase(),
param.getExpression()) != null) {
+ throw new
QueryResolverException(QueryPlugin.Util.getString("ExecResolver.duplicate_named_params",
param.getName().toUpperCase())); //$NON-NLS-1$
}
+ } else {
+ inputExpressions.put(param.getIndex(), param.getExpression());
}
}
storedProcedureCommand.clearParameters();
-
+ int origInputs = inputExpressions.size();
/*
* Take the values set from the stored procedure implementation, and match up
with the
* types of parameter it is from the metadata and then reset the newly joined
parameters
* into the stored procedure command. If it is a result set get those columns
and place
* them into the stored procedure command as well.
*/
- List metadataParams = storedProcedureInfo.getParameters();
- List clonedMetadataParams = new ArrayList();
+ List<SPParameter> metadataParams = storedProcedureInfo.getParameters();
+ List<SPParameter> clonedMetadataParams = new
ArrayList<SPParameter>(metadataParams.size());
int inputParams = 0;
- Iterator paramIter = metadataParams.iterator();
- while(paramIter.hasNext()){
- SPParameter metadataParameter = (SPParameter)paramIter.next();
+ int outParams = 0;
+ boolean hasReturnValue = false;
+ for (SPParameter metadataParameter : metadataParams) {
if( (metadataParameter.getParameterType()==ParameterInfo.IN) ||
(metadataParameter.getParameterType()==ParameterInfo.INOUT)){
inputParams++;
+ } else if (metadataParameter.getParameterType() == ParameterInfo.OUT) {
+ outParams++;
+ } else if (metadataParameter.getParameterType() ==
ParameterInfo.RETURN_VALUE) {
+ hasReturnValue = true;
}
SPParameter clonedParam = (SPParameter)metadataParameter.clone();
clonedMetadataParams.add(clonedParam);
storedProcedureCommand.setParameter(clonedParam);
}
+
+ if (storedProcedureCommand.isCalledWithReturn() && !hasReturnValue) {
+ throw new
QueryResolverException(QueryPlugin.Util.getString("ExecResolver.return_expected",
storedProcedureCommand.getGroup())); //$NON-NLS-1$
+ }
- if(!namedParameters && (inputParams != inputExpressions.size())) {
- throw new QueryResolverException("ERR.015.008.0007",
QueryPlugin.Util.getString("ERR.015.008.0007", new Object[] {new
Integer(inputParams), new Integer(inputExpressions.size()),
storedProcedureCommand.getGroup().toString()})); //$NON-NLS-1$ //$NON-NLS-2$
+ if(!namedParameters && (inputParams > inputExpressions.size())) {
+ throw new QueryResolverException("ERR.015.008.0007",
QueryPlugin.Util.getString("ERR.015.008.0007", inputParams, origInputs,
storedProcedureCommand.getGroup())); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
// Walk through the resolved parameters and set the expressions from the
// input parameters
- paramIter = clonedMetadataParams.iterator();
int exprIndex = 1;
HashSet<String> expected = new HashSet<String>();
- while(paramIter.hasNext()) {
- SPParameter param = (SPParameter) paramIter.next();
- if(param.getParameterType() == ParameterInfo.IN || param.getParameterType()
== ParameterInfo.INOUT) {
-
- if (namedParameters) {
- String nameKey = param.getName();
- nameKey = metadata.getShortElementName(nameKey);
- nameKey = nameKey.toUpperCase();
- Expression expr = (Expression)inputExpressions.remove(nameKey);
- // With named parameters, have to check on optional params and
default values
- if (expr == null) {
- expr = ResolverUtil.getDefault(param.getParameterSymbol(),
metadata);
- param.setUsingDefault(true);
- expected.add(nameKey);
- }
- param.setExpression(expr);
- } else {
- Expression expr = (Expression)inputExpressions.remove(new
Integer(exprIndex));
- param.setExpression(expr);
- }
- exprIndex++;
+ if (storedProcedureCommand.isCalledWithReturn() && hasReturnValue) {
+ for (SPParameter param : clonedMetadataParams) {
+ if (param.getParameterType() == SPParameter.RETURN_VALUE) {
+ Expression expr = inputExpressions.remove(exprIndex++);
+ param.setExpression(expr);
+ }
+ }
+ }
+ for (SPParameter param : clonedMetadataParams) {
+ if(param.getParameterType() == SPParameter.RESULT_SET ||
param.getParameterType() == SPParameter.RETURN_VALUE) {
+ continue;
}
+ if (namedParameters) {
+ String nameKey = param.getName();
+ nameKey = metadata.getShortElementName(nameKey);
+ nameKey = nameKey.toUpperCase();
+ Expression expr = inputExpressions.remove(nameKey);
+ // With named parameters, have to check on optional params and default
values
+ if (expr == null && param.getParameterType() !=
ParameterInfo.OUT) {
+ expr = ResolverUtil.getDefault(param.getParameterSymbol(), metadata);
+ param.setUsingDefault(true);
+ expected.add(nameKey);
+ }
+ param.setExpression(expr);
+ } else {
+ if(param.getParameterType() == SPParameter.OUT) {
+ continue;
+ }
+ Expression expr = inputExpressions.remove(exprIndex++);
+ param.setExpression(expr);
+ }
}
// Check for leftovers, i.e. params entered by user w/ wrong/unknown names
- if (namedParameters && !inputExpressions.isEmpty()) {
- throw new
QueryResolverException(QueryPlugin.Util.getString("ExecResolver.invalid_named_params",
inputExpressions.keySet(), expected)); //$NON-NLS-1$
+ if (!inputExpressions.isEmpty()) {
+ if (namedParameters) {
+ throw new
QueryResolverException(QueryPlugin.Util.getString("ExecResolver.invalid_named_params",
inputExpressions.keySet(), expected)); //$NON-NLS-1$
+ }
+ throw new QueryResolverException("ERR.015.008.0007",
QueryPlugin.Util.getString("ERR.015.008.0007", inputParams, origInputs,
storedProcedureCommand.getGroup().toString())); //$NON-NLS-1$ //$NON-NLS-2$
}
// Create temporary metadata that defines a group based on either the stored
proc
Modified:
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -34,6 +34,7 @@
import org.teiid.api.exception.query.QueryParserException;
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.api.exception.query.UnresolvedSymbolDescription;
+import org.teiid.client.metadata.ParameterInfo;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogManager;
@@ -56,6 +57,8 @@
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.DynamicCommand;
import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.lang.SubqueryContainer;
import org.teiid.query.sql.proc.AssignmentStatement;
import org.teiid.query.sql.proc.Block;
@@ -161,9 +164,14 @@
ElementSymbol updateCount = new ElementSymbol(countVar);
updateCount.setType(DataTypeManager.DefaultDataClasses.INTEGER);
symbols.add(updateCount);
- ProcedureContainerResolver.addScalarGroup(ProcedureReservedWords.VARIABLES,
metadata.getMetadataStore(), externalGroups, symbols);
}
-
+
+ String countVar = ProcedureReservedWords.VARIABLES + ElementSymbol.SEPARATOR +
ProcedureReservedWords.ROWCOUNT;
+ ElementSymbol updateCount = new ElementSymbol(countVar);
+ updateCount.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ symbols.add(updateCount);
+
+ ProcedureContainerResolver.addScalarGroup(ProcedureReservedWords.VARIABLES,
metadata.getMetadataStore(), externalGroups, symbols);
resolveBlock(procCommand, procCommand.getBlock(), externalGroups, metadata,
procCommand.isUpdateProcedure(), analysis);
}
@@ -209,6 +217,22 @@
TempMetadataStore discoveredMetadata = resolveEmbeddedCommand(metadata,
externalGroups, subCommand, analysis);
+ if (subCommand instanceof StoredProcedure) {
+ StoredProcedure sp = (StoredProcedure)subCommand;
+ for (SPParameter param : sp.getParameters()) {
+ if (!(param.getExpression() instanceof ElementSymbol)) {
+ continue;
+ }
+ switch (param.getParameterType()) {
+ case ParameterInfo.INOUT:
+ case ParameterInfo.OUT:
+ case ParameterInfo.RETURN_VALUE:
+ sp.setCallableStatement(true);
+ break;
+ }
+ }
+ }
+
if (discoveredMetadata != null) {
metadata.getMetadataStore().getData().putAll(discoveredMetadata.getData());
}
@@ -231,9 +255,12 @@
dynamicCommand.setAsColumns(Collections.EMPTY_LIST);
}
}
- //this could be the last select statement, set the projected symbol
- //on the virtual procedure command
- command.setResultsCommand(subCommand);
+
+ if (subCommand.returnsResultSet()) {
+ //this could be the last select statement, set the projected symbol
+ //on the virtual procedure command
+ command.setResultsCommand(subCommand);
+ }
}
break;
Modified:
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolveVirtualGroupCriteriaVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolveVirtualGroupCriteriaVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolveVirtualGroupCriteriaVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -34,7 +34,6 @@
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
-import org.teiid.query.sql.navigator.PreOrderNavigator;
import org.teiid.query.sql.proc.CriteriaSelector;
import org.teiid.query.sql.proc.TranslateCriteria;
import org.teiid.query.sql.symbol.ElementSymbol;
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -361,18 +361,9 @@
if (expr != null) {
expr = rewriteExpressionDirect(expr);
exprStmt.setExpression(expr);
- if (expr instanceof ScalarSubquery) {
- ScalarSubquery ss = (ScalarSubquery)expr;
- if(ss.getCommand().getType() == Command.TYPE_UPDATE) {
- Update update = (Update)ss.getCommand();
- if (update.getChangeList().isEmpty()) {
- exprStmt.setExpression(new Constant(INTEGER_ZERO));
- }
- }
- }
}
return exprStmt;
- case Statement.TYPE_COMMAND:
+ case Statement.TYPE_COMMAND:
CommandStatement cmdStmt = (CommandStatement) statement;
rewriteSubqueryContainer(cmdStmt, false);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -40,6 +40,8 @@
public static final String INPUTS = "INPUTS"; //$NON-NLS-1$
public static final String ROWS_UPDATED = "ROWS_UPDATED"; //$NON-NLS-1$
+
+ public static final String ROWCOUNT = "ROWCOUNT"; //$NON-NLS-1$
public static final String CHANGING = "CHANGING"; //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -340,4 +340,8 @@
return EquivalenceUtil.areEqual(this.cacheHint, cmd.cacheHint) &&
EquivalenceUtil.areEqual(this.option, cmd.option);
}
+
+ public boolean returnsResultSet() {
+ return false;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -255,5 +255,10 @@
public void setAsClauseSet(boolean asClauseSet) {
this.asClauseSet = asClauseSet;
}
+
+ @Override
+ public boolean returnsResultSet() {
+ return intoGroup == null;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -444,4 +444,9 @@
public Query getProjectedQuery() {
return this;
}
+
+ @Override
+ public boolean returnsResultSet() {
+ return into == null;
+ }
} // END CLASS
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/QueryCommand.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/QueryCommand.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/QueryCommand.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -74,4 +74,9 @@
}
public abstract Query getProjectedQuery();
+
+ @Override
+ public boolean returnsResultSet() {
+ return true;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -34,6 +34,7 @@
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.query.QueryPlugin;
+import org.teiid.query.metadata.StoredProcedureInfo;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -71,9 +72,8 @@
//whether parameters should be displayed in traditional indexed
//manor, or as named parameters
private boolean displayNamedParameters;
-
+ private boolean calledWithReturn;
private boolean isCallableStatement;
-
private boolean isProcedureRelational;
/**
@@ -154,8 +154,6 @@
Integer key = new Integer(parameter.getIndex());
if(parameter.getParameterType() == ParameterInfo.RESULT_SET){
resultSetParameterKey = key;
- }else if(parameter.getParameterType() == ParameterInfo.RETURN_VALUE){
- returnsScalarValue = true;
}
mapOfParameters.put(key, parameter);
@@ -213,25 +211,19 @@
copy.setModelID(getModelID());
copy.setProcedureName(getProcedureName());
copy.setProcedureCallableName(getProcedureCallableName());
- copy.returnsScalarValue = returnsScalarValue();
copy.setProcedureID(getProcedureID());
- copy.setGroup((GroupSymbol)getGroup().clone());
+ copy.setGroup(getGroup().clone());
if (getTemporaryMetadata() != null){
copy.setTemporaryMetadata(new HashMap(getTemporaryMetadata()));
}
copy.callableName = callableName;
-
+ copy.calledWithReturn = calledWithReturn;
List<SPParameter> params = getParameters();
for(int i=0; i<params.size(); i++) {
copy.setParameter((SPParameter)params.get(i).clone());
}
copy.resultSetParameterKey = resultSetParameterKey;
this.copyMetadataState(copy);
-
- if(this.group != null) {
- copy.setGroup((GroupSymbol)this.group.clone());
- }
-
copy.displayNamedParameters = displayNamedParameters;
copy.isCallableStatement = isCallableStatement;
copy.isProcedureRelational = isProcedureRelational;
@@ -243,7 +235,12 @@
}
public boolean returnsScalarValue(){
- return returnsScalarValue;
+ for (SPParameter param : this.mapOfParameters.values()) {
+ if (param.getParameterType() == SPParameter.RETURN_VALUE) {
+ return true;
+ }
+ }
+ return false;
}
public boolean returnParameters() {
@@ -413,7 +410,16 @@
} // for
return map;
- }
+ }
+
+ public void setCalledWithReturn(boolean calledWithReturn) {
+ this.calledWithReturn = calledWithReturn;
+ }
+
+ public boolean isCalledWithReturn() {
+ return calledWithReturn;
+ }
+
}
Modified:
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -56,7 +56,7 @@
* </UL>
*/
public class SubqueryCompareCriteria extends AbstractCompareCriteria
-implements SubqueryContainer, ContextReference {
+implements SubqueryContainer<QueryCommand>, ContextReference {
private static AtomicInteger ID = new AtomicInteger();
@@ -71,14 +71,14 @@
private int predicateQuantifier = ALL;
- private Command command;
+ private QueryCommand command;
private String id = "$scc/id" + ID.getAndIncrement(); //$NON-NLS-1$
public SubqueryCompareCriteria(){
super();
}
- public SubqueryCompareCriteria(Expression leftExpression, Command subCommand, int
operator, int predicateQuantifier) {
+ public SubqueryCompareCriteria(Expression leftExpression, QueryCommand subCommand,
int operator, int predicateQuantifier) {
setLeftExpression(leftExpression);
setCommand(subCommand);
setOperator(operator);
@@ -119,7 +119,7 @@
this.predicateQuantifier = predicateQuantifier;
}
- public Command getCommand() {
+ public QueryCommand getCommand() {
return this.command;
}
@@ -127,7 +127,7 @@
* Set the subquery command (either a SELECT or a procedure execution).
* @param command Command to execute to get the values for the criteria
*/
- public void setCommand(Command command) {
+ public void setCommand(QueryCommand command) {
this.command = command;
}
@@ -199,9 +199,9 @@
leftCopy = (Expression) getLeftExpression().clone();
}
- Command copyCommand = null;
+ QueryCommand copyCommand = null;
if(getCommand() != null) {
- copyCommand = (Command) getCommand().clone();
+ copyCommand = (QueryCommand) getCommand().clone();
}
return new SubqueryCompareCriteria(leftCopy, copyCommand, this.getOperator(),
this.getPredicateQuantifier());
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SubquerySetCriteria.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubquerySetCriteria.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubquerySetCriteria.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -36,11 +36,11 @@
* of values returned from a subquery. This criteria can be represented as
* "<expression> IN (SELECT ...)".
*/
-public class SubquerySetCriteria extends AbstractSetCriteria implements
SubqueryContainer, ContextReference {
+public class SubquerySetCriteria extends AbstractSetCriteria implements
SubqueryContainer<QueryCommand>, ContextReference {
private static AtomicInteger ID = new AtomicInteger();
- private Command command;
+ private QueryCommand command;
private String id = "$ssc/id" + ID.getAndIncrement(); //$NON-NLS-1$
/**
@@ -50,7 +50,7 @@
super();
}
- public SubquerySetCriteria(Expression expression, Command subCommand) {
+ public SubquerySetCriteria(Expression expression, QueryCommand subCommand) {
setExpression(expression);
setCommand(subCommand);
}
@@ -69,7 +69,7 @@
* Set the subquery command (either a SELECT or a procedure execution).
* @param command Command to execute to get the values for the criteria
*/
- public void setCommand(Command command) {
+ public void setCommand(QueryCommand command) {
this.command = command;
}
@@ -77,7 +77,7 @@
* Get the subquery command used to produce the values for this SetCriteria.
* @return Command Command to execute
*/
- public Command getCommand() {
+ public QueryCommand getCommand() {
return this.command;
}
@@ -134,9 +134,9 @@
copy = (Expression) getExpression().clone();
}
- Command copyCommand = null;
+ QueryCommand copyCommand = null;
if(getCommand() != null) {
- copyCommand = (Command) getCommand().clone();
+ copyCommand = (QueryCommand) getCommand().clone();
}
SubquerySetCriteria criteriaCopy = new SubquerySetCriteria(copy, copyCommand);
Modified:
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -386,6 +386,7 @@
}
public void visit(Query obj) {
preVisitVisitor(obj);
+ visitNodes(obj.getWith());
visitNode(obj.getSelect());
visitNode(obj.getInto());
visitNode(obj.getFrom());
@@ -435,6 +436,7 @@
}
public void visit(SetQuery obj) {
preVisitVisitor(obj);
+ visitNodes(obj.getWith());
visitNodes(obj.getQueryCommands());
visitNode(obj.getOrderBy());
visitNode(obj.getLimit());
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/AssignmentStatement.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/proc/AssignmentStatement.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/sql/proc/AssignmentStatement.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -26,6 +26,8 @@
import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ScalarSubquery;
@@ -41,8 +43,8 @@
// the variable to which a value is assigned
private ElementSymbol variable;
-
private Expression value;
+ private Command command;
/**
* Constructor for AssignmentStatement.
@@ -51,15 +53,43 @@
super();
}
- public AssignmentStatement(ElementSymbol variable, Command value) {
+ public AssignmentStatement(ElementSymbol variable, QueryCommand value) {
this.variable = variable;
this.value = new ScalarSubquery(value);
}
+ @Deprecated
+ public AssignmentStatement(ElementSymbol variable, Command value) {
+ this.variable = variable;
+ if (value instanceof QueryCommand) {
+ this.value = new ScalarSubquery((QueryCommand)value);
+ } else {
+ this.command = value;
+ }
+ }
+
public AssignmentStatement(ElementSymbol variable, Expression value) {
this.variable = variable;
this.value = value;
}
+
+ @Deprecated
+ public Command getCommand() {
+ if (command != null) {
+ return command;
+ }
+ if (value instanceof ScalarSubquery && ((ScalarSubquery)value).getCommand()
instanceof Query) {
+ Query query = (Query)((ScalarSubquery)value).getCommand();
+ if (query.getInto() != null) {
+ return query;
+ }
+ }
+ return null;
+ }
+
+ public void setCommand(Command command) {
+ this.command = command;
+ }
/**
* @see #getExpression()
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -28,6 +28,9 @@
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -77,6 +80,21 @@
* @param statement The <code>Statement</code> to be added to the block
*/
public void addStatement(Statement statement) {
+ if (statement instanceof AssignmentStatement) {
+ AssignmentStatement stmt = (AssignmentStatement)statement;
+ Command cmd = stmt.getCommand();
+ if (cmd != null) {
+ statements.add(new CommandStatement(cmd));
+ stmt.setCommand(null);
+ stmt.setExpression(null);
+ String fullName =
ProcedureReservedWords.VARIABLES+ElementSymbol.SEPARATOR+ProcedureReservedWords.ROWCOUNT;
+ if (stmt.getVariable().getCanonicalName().equals(ProcedureReservedWords.ROWCOUNT)
+ || stmt.getVariable().getCanonicalName().equals(fullName)) {
+ return;
+ }
+ stmt.setExpression(new ElementSymbol(fullName));
+ }
+ }
statements.add(statement);
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/DeclareStatement.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/DeclareStatement.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/DeclareStatement.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -25,6 +25,7 @@
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -67,6 +68,11 @@
super(variable, value);
this.varType = varType;
}
+
+ @Deprecated public DeclareStatement(ElementSymbol variable, String varType, Command
value) {
+ super(variable, value);
+ this.varType = varType;
+ }
/**
* Get the type of this variable declared in this statement.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/Statement.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/Statement.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/Statement.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -82,6 +82,8 @@
*/
public static final int TYPE_BREAK = 9;
+ public static final int TYPE_UPDATE = 10;
+
/**
* Return type of statement to make it easier to build switch statements by statement
type.
* @return Type from TYPE constants
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/ScalarSubquery.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/ScalarSubquery.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/ScalarSubquery.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -25,7 +25,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.teiid.query.sql.LanguageVisitor;
-import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.SubqueryContainer;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -38,11 +38,11 @@
* of this could be used wherever an Expression is legal, but it is
* specifically needed for the SELECT clause.
*/
-public class ScalarSubquery implements Expression, SubqueryContainer, ContextReference {
+public class ScalarSubquery implements Expression, SubqueryContainer<QueryCommand>,
ContextReference {
private static AtomicInteger ID = new AtomicInteger();
- private Command command;
+ private QueryCommand command;
private Class<?> type;
private int hashCode;
private String id = "$sc/id" + ID.getAndIncrement(); //$NON-NLS-1$
@@ -55,7 +55,7 @@
super();
}
- public ScalarSubquery(Command subqueryCommand){
+ public ScalarSubquery(QueryCommand subqueryCommand){
this.setCommand(subqueryCommand);
}
@@ -104,7 +104,7 @@
this.type = type;
}
- public Command getCommand() {
+ public QueryCommand getCommand() {
return this.command;
}
@@ -112,7 +112,7 @@
* Sets the command. Also modifies the hash code of this object, so
* caution should be used in using this method.
*/
- public void setCommand(Command command){
+ public void setCommand(QueryCommand command){
this.command = command;
this.hashCode = command.hashCode();
}
@@ -152,9 +152,9 @@
* @see java.lang.Object#clone()
*/
public Object clone() {
- Command copyCommand = null;
+ QueryCommand copyCommand = null;
if(getCommand() != null) {
- copyCommand = (Command) getCommand().clone();
+ copyCommand = (QueryCommand) getCommand().clone();
}
ScalarSubquery clone = new ScalarSubquery(copyCommand);
//Don't invoke the lazy-loading getType()
Modified:
trunk/engine/src/main/java/org/teiid/query/sql/util/UpdateProcedureGenerator.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/util/UpdateProcedureGenerator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/sql/util/UpdateProcedureGenerator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -81,7 +81,7 @@
return null;
}
- GroupSymbol pGroup = (GroupSymbol)query.getFrom().getGroups().iterator().next();
+ GroupSymbol pGroup = query.getFrom().getGroups().iterator().next();
String pGroupName = pGroup.getName();
if(pGroup.getDefinition() != null) {
pGroupName = pGroup.getDefinition();
@@ -104,7 +104,7 @@
insert.setGroup(new GroupSymbol(pGroupName));
insert.setVariables(variables);
insert.setValues(values);
- AssignmentStatement assignStmt = new AssignmentStatement(rowsUpdated,
insert);
+ AssignmentStatement assignStmt = new AssignmentStatement(rowsUpdated, insert);
Block b = new Block();
b.addStatement(assignStmt);
cupc = new CreateUpdateProcedureCommand(b);
@@ -123,7 +123,7 @@
update.addChange(variable, value);
}
update.setCriteria(new TranslateCriteria(new CriteriaSelector()));
- AssignmentStatement assignStmt = new AssignmentStatement(rowsUpdated,
update);
+ AssignmentStatement assignStmt = new AssignmentStatement(rowsUpdated, update);
Block b = new Block();
b.addStatement(assignStmt);
cupc = new CreateUpdateProcedureCommand(b);
@@ -134,7 +134,7 @@
Delete delete = new Delete();
delete.setGroup(new GroupSymbol(pGroupName));
delete.setCriteria(new TranslateCriteria(new CriteriaSelector()));
- AssignmentStatement assignStmt = new AssignmentStatement(rowsUpdated,
delete);
+ AssignmentStatement assignStmt = new AssignmentStatement(rowsUpdated, delete);
Block b = new Block();
b.addStatement(assignStmt);
cupc = new CreateUpdateProcedureCommand(b);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -659,8 +659,6 @@
public void visit( DynamicCommand obj ) {
append(EXECUTE);
append(SPACE);
- append(STRING);
- append(SPACE);
visitNode(obj.getSql());
if (obj.isAsClauseSet()) {
@@ -926,42 +924,48 @@
public void visit( StoredProcedure obj ) {
addCacheHint(obj.getCacheHint());
+ if (obj.isCalledWithReturn()) {
+ for (SPParameter param : obj.getParameters()) {
+ if (param.getParameterType() == SPParameter.RETURN_VALUE) {
+ if (param.getExpression() == null) {
+ append("?"); //$NON-NLS-1$
+ } else {
+ visitNode(param.getExpression());
+ }
+ }
+ }
+ append(SPACE);
+ append(Tokens.EQ);
+ append(SPACE);
+ }
// exec clause
append(EXEC);
append(SPACE);
append(obj.getProcedureName());
append("("); //$NON-NLS-1$
- List params = obj.getInputParameters();
- if (params != null) {
- Iterator iter = params.iterator();
- while (iter.hasNext()) {
- SPParameter param = (SPParameter)iter.next();
+ boolean first = true;
+ for (SPParameter param : obj.getParameters()) {
+ if (param.getParameterType() == SPParameter.RETURN_VALUE ||
param.getParameterType() == SPParameter.RESULT_SET || param.getExpression() == null) {
+ continue;
+ }
+ if (first) {
+ first = false;
+ } else {
+ append(", "); //$NON-NLS-1$
+ }
+ if (obj.displayNamedParameters()) {
+
append(escapeSinglePart(ElementSymbol.getShortName(param.getParameterSymbol().getOutputName())));
+ append(" => "); //$NON-NLS-1$
+ }
- if (obj.displayNamedParameters()) {
-
append(escapeSinglePart(ElementSymbol.getShortName(param.getParameterSymbol().getOutputName())));
- append(" => "); //$NON-NLS-1$
- }
-
- if (param.getExpression() == null) {
- if (param.getName() != null) {
- outputDisplayName(obj.getParamFullName(param));
- } else {
- append("?"); //$NON-NLS-1$
- }
- } else {
- boolean addParens = !obj.displayNamedParameters() &&
param.getExpression() instanceof CompareCriteria;
- if (addParens) {
- append(Tokens.LPAREN);
- }
- visitNode(param.getExpression());
- if (addParens) {
- append(Tokens.RPAREN);
- }
- }
- if (iter.hasNext()) {
- append(", "); //$NON-NLS-1$
- }
+ boolean addParens = !obj.displayNamedParameters() &&
param.getExpression() instanceof CompareCriteria;
+ if (addParens) {
+ append(Tokens.LPAREN);
}
+ visitNode(param.getExpression());
+ if (addParens) {
+ append(Tokens.RPAREN);
+ }
}
append(")"); //$NON-NLS-1$
@@ -1358,19 +1362,11 @@
visitNode(obj.getVariable());
if (obj.getExpression() != null) {
append(" = "); //$NON-NLS-1$
- addStatementArgument(obj.getExpression());
+ visitNode(obj.getExpression());
}
append(";"); //$NON-NLS-1$
}
- private void addStatementArgument( Expression expr ) {
- if (expr instanceof ScalarSubquery) {
- visitNode(((ScalarSubquery)expr).getCommand());
- } else {
- visitNode(expr);
- }
- }
-
public void visit( IfStatement obj ) {
append(IF);
append("("); //$NON-NLS-1$
@@ -1485,7 +1481,7 @@
public void visit( RaiseErrorStatement obj ) {
append(ERROR);
append(SPACE);
- addStatementArgument(obj.getExpression());
+ visitNode(obj.getExpression());
append(";"); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -42,7 +42,6 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.EquivalenceUtil;
-import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.FunctionLibrary;
@@ -64,6 +63,7 @@
import org.teiid.query.sql.lang.DependentSetCriteria;
import org.teiid.query.sql.lang.Drop;
import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.ExistsCriteria;
import org.teiid.query.sql.lang.GroupBy;
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.lang.Into;
@@ -76,25 +76,32 @@
import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.lang.SetClause;
import org.teiid.query.sql.lang.SetClauseList;
import org.teiid.query.sql.lang.SetCriteria;
import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.lang.SubqueryFromClause;
import org.teiid.query.sql.lang.SubquerySetCriteria;
import org.teiid.query.sql.lang.TextTable;
import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.WithQueryCommand;
import org.teiid.query.sql.lang.XMLTable;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.lang.XMLTable.XMLColumn;
import org.teiid.query.sql.navigator.PreOrderNavigator;
import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.CommandStatement;
import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
import org.teiid.query.sql.proc.CriteriaSelector;
import org.teiid.query.sql.proc.DeclareStatement;
import org.teiid.query.sql.proc.HasCriteria;
import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.LoopStatement;
import org.teiid.query.sql.proc.TranslateCriteria;
import org.teiid.query.sql.proc.WhileStatement;
import org.teiid.query.sql.symbol.AggregateSymbol;
@@ -226,6 +233,10 @@
validateHasProjectedSymbols(obj);
validateGroupSupportsUpdate(obj.getGroup());
validateInsert(obj);
+
+ if (obj.getQueryExpression() != null) {
+ validateMultisourceInsert(obj.getGroup());
+ }
}
@Override
@@ -267,6 +278,7 @@
}
public void visit(SubquerySetCriteria obj) {
+ validateSubquery(obj);
if (isNonComparable(obj.getExpression())) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0027",
obj),obj); //$NON-NLS-1$
}
@@ -300,8 +312,21 @@
public void visit(Into obj) {
GroupSymbol target = obj.getGroup();
validateGroupSupportsUpdate(target);
+ validateMultisourceInsert(obj.getGroup());
}
+ private void validateMultisourceInsert(GroupSymbol group) {
+ try {
+ if (getMetadata().isMultiSource(getMetadata().getModelID(group.getMetadataID()))) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.multisource_insert",
group), group); //$NON-NLS-1$
+ }
+ } catch (QueryMetadataException e) {
+ handleException(e);
+ } catch (TeiidComponentException e) {
+ handleException(e);
+ }
+ }
+
public void visit(Function obj) {
if(FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
try {
@@ -367,16 +392,34 @@
ElementSymbol variable = obj.getVariable();
- String groupName = variable.getGroupSymbol().getCanonicalName();
+ validateAssignment(obj, variable);
+ }
+
+ @Override
+ public void visit(CommandStatement obj) {
+ if (obj.getCommand() instanceof StoredProcedure) {
+ StoredProcedure proc = (StoredProcedure)obj.getCommand();
+ for (SPParameter param : proc.getParameters()) {
+ if ((param.getParameterType() == SPParameter.RETURN_VALUE
+ || param.getParameterType() == SPParameter.OUT) && param.getExpression()
instanceof ElementSymbol) {
+ validateAssignment(obj, (ElementSymbol)param.getExpression());
+ }
+ }
+ }
+ }
+ private void validateAssignment(LanguageObject obj,
+ ElementSymbol variable) {
+ String groupName = variable.getGroupSymbol().getCanonicalName();
+ //This will actually get detected by the resolver, since we inject an automatic
declaration.
if(groupName.equals(ProcedureReservedWords.CHANGING) ||
groupName.equals(ProcedureReservedWords.INPUTS)) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0012",
ProcedureReservedWords.INPUTS, ProcedureReservedWords.CHANGING), obj); //$NON-NLS-1$
}
-
- }
+ }
@Override
public void visit(ScalarSubquery obj) {
+ validateSubquery(obj);
Collection<SingleElementSymbol> projSymbols =
obj.getCommand().getProjectedSymbols();
//Scalar subquery should have one projected symbol (query with one expression
@@ -413,9 +456,11 @@
// varible cannot be one of the special variables
if(elementname.equals(ProcedureReservedWords.ROWS_UPDATED)) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0017", new
Object[] {ProcedureReservedWords.ROWS_UPDATED}), obj); //$NON-NLS-1$
+ } else if(elementname.equals(ProcedureReservedWords.ROWCOUNT)) {
+ handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0017", new
Object[] {ProcedureReservedWords.ROWCOUNT}), obj); //$NON-NLS-1$
}
- visit((AssignmentStatement)obj);
+ validateAssignment(obj, obj.getVariable());
}
public void visit(IfStatement obj) {
@@ -790,7 +835,7 @@
if(!getMetadata().elementSupports(nextElmnt.getMetadataID(),
SupportConstants.Element.DEFAULT_VALUE) &&
!getMetadata().elementSupports(nextElmnt.getMetadataID(),
SupportConstants.Element.NULL) &&
!getMetadata().elementSupports(nextElmnt.getMetadataID(),
SupportConstants.Element.AUTO_INCREMENT) &&
- !(nextElmnt.getMetadataID() instanceof MultiSourceElement)) {
+ !getMetadata().isMultiSourceElement(nextElmnt.getMetadataID())) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0053", new
Object[] {insertGroup, nextElmnt}), nextElmnt); //$NON-NLS-1$
}
}
@@ -847,7 +892,7 @@
}
Object metadataID = elementID.getMetadataID();
- if (metadataID instanceof MultiSourceElement){
+ if (getMetadata().isMultiSourceElement(metadataID)){
handleValidationError(QueryPlugin.Util.getString("multi_source_update_not_allowed",
elementID), elementID); //$NON-NLS-1$
}
@@ -1028,6 +1073,7 @@
* @since 4.3
*/
public void visit(SubqueryCompareCriteria obj) {
+ validateSubquery(obj);
if (isNonComparable(obj.getLeftExpression())) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0027",
obj),obj); //$NON-NLS-1$
}
@@ -1356,5 +1402,32 @@
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.xmlserialize_type"),
obj); //$NON-NLS-1$
}
}
-
+
+ @Override
+ public void visit(ExistsCriteria obj) {
+ validateSubquery(obj);
+ }
+
+ @Override
+ public void visit(SubqueryFromClause obj) {
+ validateSubquery(obj);
+ }
+
+ @Override
+ public void visit(LoopStatement obj) {
+ validateSubquery(obj);
+ }
+
+ @Override
+ public void visit(WithQueryCommand obj) {
+ validateSubquery(obj);
+ }
+
+ //TODO: it may be simplier to catch this in the parser
+ private void validateSubquery(SubqueryContainer subQuery) {
+ if (subQuery.getCommand() instanceof Query &&
((Query)subQuery.getCommand()).getInto() != null) {
+
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.subquery_insert"),
subQuery.getCommand()); //$NON-NLS-1$
+ }
+ }
+
}
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-10-19 15:39:47
UTC (rev 2659)
@@ -457,7 +457,7 @@
}
{
(command = queryExpression(info) |
- command = storedProcedure(info) |
+ command = storedProcedure(info, new StoredProcedure()) |
command = insert(info) |
command = update(info) |
command = delete(info) |
@@ -574,9 +574,9 @@
Statement stmt = null;
}
{
- (stmt = sqlStatement(info) |
+ (LOOKAHEAD(3) stmt = assignStatement(info) |
+ stmt = sqlStatement(info) |
stmt = errorStatement(info) |
- stmt = assignStatement(info) |
stmt = declareStatement(info) |
stmt = continueStatement(info) |
stmt = breakStatement(info)
@@ -819,7 +819,7 @@
String var = null;
Constant type = null;
ElementSymbol variableID = null;
- Expression value = null;
+ LanguageObject value = null;
}
{
<DECLARE>
@@ -828,13 +828,18 @@
{
variableID = new ElementSymbol(var);
}
- [<EQ>
+ [(nonReserved(":=")|<EQ>)
value = assignStatementOperand(info)
]
{
- declStmt = new DeclareStatement(variableID, (String)type.getValue(), value);
- return declStmt;
+ if (value instanceof Expression) {
+ return new DeclareStatement(variableID, (String)type.getValue(),
(Expression)value);
+ }
+ if (value instanceof QueryCommand) {
+ return new DeclareStatement(variableID, (String)type.getValue(), new
ScalarSubquery((QueryCommand)value));
+ }
+ return new DeclareStatement(variableID, (String)type.getValue(), (Command)value);
}
}
@@ -844,22 +849,26 @@
*/
AssignmentStatement assignStatement(ParseInfo info) :
{
- Expression value = null;
+ LanguageObject value = null;
String var = null;
ElementSymbol elementID = null;
}
{
-
var = id()
{
elementID = new ElementSymbol(var);
}
- <EQ>
+ (nonReserved(":=")|<EQ>)
value = assignStatementOperand(info)
{
- AssignmentStatement assignStmt = new AssignmentStatement(elementID, value);
- return assignStmt;
+ if (value instanceof Expression) {
+ return new AssignmentStatement(elementID, (Expression)value);
+ }
+ if (value instanceof QueryCommand) {
+ return new AssignmentStatement(elementID, (QueryCommand)value);
+ }
+ return new AssignmentStatement(elementID, (Command)value);
}
}
@@ -868,26 +877,22 @@
* arbitrarily deeply in parentheses.
* @throws ParseException if parsing failed
*/
-Expression assignStatementOperand(ParseInfo info) :
+LanguageObject assignStatementOperand(ParseInfo info) :
{
LanguageObject value = null;
}
{
(
- LOOKAHEAD(<INSERT><INTO>) (value = insert(info)) |
- value = update(info) |
- value = delete(info) |
- value = storedProcedure(info) |
- LOOKAHEAD(expression(info)) (value = expression(info)) |
- value = queryExpression(info)
+ LOOKAHEAD(<INSERT><INTO>) (value = insert(info)) | //deprecated
+ value = update(info) | //deprecated
+ value = delete(info) | //deprecated
+ LOOKAHEAD(expression(info)) (value = expression(info)) |
+ value = queryExpression(info) //deprecated should be a scalar subquery
)
{
- if (value instanceof Expression) {
- return (Expression)value;
- }
- return new ScalarSubquery((Command)value);
+ return value;
}
}
@@ -899,10 +904,26 @@
{
CommandStatement cmdStmt = null;
Command cmd = null;
+ String var = null;
+ ElementSymbol elementID = null;
+ StoredProcedure storedProcedure = null;
}
{
- (LOOKAHEAD((<EXECUTE>|<EXEC>) <STRING>) (cmd =
dynamicCommand(info)) |
- cmd = userCommand(info)
+ (LOOKAHEAD(2) (cmd = userCommand(info)) |
+ cmd = dynamicCommand(info) |
+ (
+ var = id()
+ {
+ storedProcedure = new StoredProcedure();
+ elementID = new ElementSymbol(var);
+ SPParameter parameter = new SPParameter(1, SPParameter.RETURN_VALUE,
"return"); //$NON-NLS-1$
+ parameter.setExpression(elementID);
+ storedProcedure.setParameter(parameter);
+ storedProcedure.setCalledWithReturn(true);
+ }
+ (nonReserved(":=")|<EQ>)
+ cmd = storedProcedure(info, storedProcedure)
+ )
)
{
@@ -1013,7 +1034,7 @@
SetClauseList setClauseList = null;
}
{
- (<EXECUTE>|<EXEC>) <STRING>
+ (<EXECUTE>|<EXEC>) [(<STRING>|<IMMEDIATE>)]
sql = expression(info)
{
dcStmt.setSql(sql);
@@ -1133,6 +1154,7 @@
{
parameter = new SPParameter(parameterIndex++, SPParameter.RETURN_VALUE,
"return"); //$NON-NLS-1$
storedProcedure.setParameter(parameter);
+ storedProcedure.setCalledWithReturn(true);
}
]
<CALL> procName = id()
@@ -1166,9 +1188,8 @@
* * Parse stored query command
* @throws ParseException if parsing failed
*/
-StoredProcedure storedProcedure(ParseInfo info) :
+StoredProcedure storedProcedure(ParseInfo info, StoredProcedure storedProcedure) :
{
- StoredProcedure storedProcedure = new StoredProcedure();
String procName = null;
Option option = null;
}
@@ -1187,7 +1208,7 @@
LOOKAHEAD(<ID> <EQ>)
storedProcedure = executeNamedParams(info, storedProcedure)
|
- storedProcedure = executeUnnamedParams(info, storedProcedure, 1)
+ storedProcedure = executeUnnamedParams(info, storedProcedure,
storedProcedure.getParameters().size() + 1)
)
<RPAREN>
@@ -2261,7 +2282,7 @@
]
lparen = <LPAREN>
( command = queryExpression(info) |
- command = storedProcedure(info) )
+ command = storedProcedure(info, new StoredProcedure()) )
<RPAREN>
[<AS>]
aliasID = id()
@@ -2492,14 +2513,21 @@
}
}
-Command subquery(ParseInfo info) :
+QueryCommand subquery(ParseInfo info) :
{
- Command subquery = null;
+ QueryCommand subquery = null;
+ StoredProcedure proc = null;
}
{
<LPAREN>
- ( subquery = queryExpression(info) |
- subquery = storedProcedure(info) )
+ ( subquery = queryExpression(info) |
+ (
+ proc = storedProcedure(info, new StoredProcedure()) //deprecated
+ )
+ {
+ subquery = new Query(new Select(Arrays.asList(new AllSymbol())), new
From(Arrays.asList(new SubqueryFromClause("x", proc))), null, null, null);
+ }
+ )
<RPAREN>
{
return subquery;
@@ -2514,7 +2542,7 @@
SubqueryCompareCriteria subqueryCompareCriteria(ParseInfo info, Expression expression) :
{
SubqueryCompareCriteria subqueryCrit = null;
- Command subquery = null;
+ QueryCommand subquery = null;
Token operator = null;
Token quantifier = null;
@@ -2645,7 +2673,7 @@
{
Expression value = null;
List setList = new ArrayList();
- Command command = null;
+ QueryCommand command = null;
boolean negated = false;
AbstractSetCriteria criteria = null;
}
@@ -3091,7 +3119,7 @@
Expression expression = null;
Token symbol = null;
Constant literal = null;
- Command subquery = null;
+ QueryCommand subquery = null;
}
{
(
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-10-19 15:39:47
UTC (rev 2659)
@@ -41,7 +41,12 @@
ERR.015.001.0044 = Function metadata source is of invalid type: {0}
ERR.015.001.0045 = Function method is of invalid type: {0}
ERR.015.001.0046 = The function "{0}" will not be added because a function with
the same name and signature already exists.
-ERR.015.001.0047 = Unexpected exception while loading {0}.{1} with args= {2}
+ERR.015.001.0047 = Unexpected exception while loading "{1}.{2}" for UDF
"{0}"
+FunctionTree.not_void = UDF "{0}" method "{1}" must not return void.
+FunctionTree.not_public = UDF "{0}" method "{1}" must be public.
+FunctionTree.not_static = UDF "{0}" method "{1}" must be static.
+FunctionTree.no_class = Could not load UDF "{0}", since its invocation class
"{1}" could not be found.
+FunctionTree.no_method = UDF "{0}" could not loaded, since no method on class
"{1}" with name "{2}" has a matching type signature.
ERR.015.001.0048 = Unable to represent average value from {0} / {1}
ERR.015.001.0050 = Unable to compute aggregate function {0} on data of type {1}
ERR.015.001.0052 = {0} must be non-null.
@@ -187,6 +192,7 @@
ValidationVisitor.limit_not_valid_for_xml=The limit clause cannot be used on an XML
document query.
ValidationVisitor.translated_or=Translated user criteria must not contain OR criteria
ValidationVisitor.union_insert = Select into is not allowed under a set operation: {0}.
+ValidationVisitor.multisource_insert = A multi-source table, {0}, cannot be used in an
INSERT with query expression or SELECT INTO statement.
ERR.015.012.0029 = INSERT, UPDATE, and DELETE not allowed on XML documents
ERR.015.012.0030 = Commands used in stored procedure language not allowed on XML
documents
ERR.015.012.0031 = Queries against XML documents can not have a GROUP By clause
@@ -617,6 +623,8 @@
SystemSource.decode_arg1=Clob
SystemSource.decode_arg2=The encoding
SystemSource.decode_result=byte representation Blob
+SystemSource.session_id_desc=Returns the session id of the currently logged in user
+SystemSource.session_id_result=Returns the session id of the currently logged in user
TempMetadataAdapter.Element_____{0}_____not_found._1=Element ''{0}'' not
found.
TempMetadataAdapter.Group_____{0}_____not_found._1=Group ''{0}'' not
found.
ExpressionEvaluator.Must_push=Function {0} is marked in the function metadata as a
function that must be evaluated at the source.
@@ -625,6 +633,7 @@
Evaluator.xmlserialize=XMLSerialize: data exception - not an xml document
Evaluator.xmlquery=Error evaluating XMLQuery: {0}
ExecResolver.Param_convert_fail=Unable to convert procedural parameter of type {0} to
expected type {1}
+ExecResolver.return_expected=Procedure {0} does not have a return value.
DynamicCommandResolver.SQL_String=Expected dynamic command sql to be of type STRING
instead of type {0}.
UnionQueryResolver.type_conversion=The Expression {0} used in a nested UNION ORDER BY
clause cannot be implicitly converted from type {1} to type {2}.
ValidationVisitor.select_into_no_implicit_conversion=There is no implicit conversion
between the source element type ({0}) and the target element type ({1}) at position {2} of
the query: {3}
@@ -689,6 +698,7 @@
ValidationVisitor.context_required=The XQuery requires a context item, but none exists in
the PASSING clause.
ValidationVisitor.xmlserialize_type=XMLSERIALIZE expects a STRING, CLOB, or BLOB value.
ValidationVisitor.invalid_encoding=Encoding {0} is not valid.
+ValidationVisitor.subquery_insert=SELECT INTO should not be used in a subquery.
UpdateProcedureResolver.only_variables=Element symbol "{0}" cannot be assigned
a value. Only declared VARIABLES can be assigned values.
MappingLoader.unknown_node_type=Unknown Node Type "{0}" being loaded by the XML
mapping document.
MappingLoader.invalid_criteria_node=Invalid criteria node found; A criteria node must
have criteria specified or it must be a default node.
@@ -818,6 +828,8 @@
# services (003)
Request.Invalid_character_in_query=Bind variables (represented as "?") were
found but are allowed only in prepared or callable statements.
+Request.no_result_set=The query does not return an update count.
+Request.result_set=The query does not return a result set.
ProcessWorker.wrongdata=Wrong type of data found or no data found; expecting streamable
object from the buffer manager.
ProcessWorker.LobError=An error occurred during streaming of Lob Chunks to Client.
@@ -860,5 +872,4 @@
RequestWorkItem.cache_nondeterministic=Caching command '{0}'' at a session
level, but less deterministic functions were evaluated.
not_found_cache=Results not found in cache
failed_to_unwrap_connection=Failed to unwrap the source connection.
-connection_factory_not_found=Failed to the Connection Factory with JNDI name {0}. Please
check the name for spelling or deploy the Connection Factory with specified name.
-multi_source_update_not_allowed=Update of the column {0} is not allowed.
\ No newline at end of file
+connection_factory_not_found=Failed to the Connection Factory with JNDI name {0}. Please
check the name for spelling or deploy the Connection Factory with specified name.
\ No newline at end of file
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInlineViewImpl.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInlineViewImpl.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestInlineViewImpl.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -48,7 +48,7 @@
}
public void testGetQuery() throws Exception {
- assertEquals("SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS
myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4
HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC",
example().getQuery().toString()); //$NON-NLS-1$
+ assertEquals("SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS
myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4
HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC",
example().getQuery().toString()); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestOrderByImpl.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestOrderByImpl.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestOrderByImpl.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,33 +22,26 @@
package org.teiid.dqp.internal.datamgr;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.teiid.language.OrderBy;
import org.teiid.language.SortSpecification;
+import org.teiid.query.sql.symbol.ElementSymbol;
-public class TestOrderByImpl extends TestCase {
+public class TestOrderByImpl {
- /**
- * Constructor for TestOrderByImpl.
- * @param name
- */
- public TestOrderByImpl(String name) {
- super(name);
- }
-
public static org.teiid.query.sql.lang.OrderBy helpExample() {
- ArrayList elements = new ArrayList();
+ ArrayList<ElementSymbol> elements = new ArrayList<ElementSymbol>();
elements.add(TestElementImpl.helpExample("vm1.g1", "e1"));
//$NON-NLS-1$ //$NON-NLS-2$
elements.add(TestElementImpl.helpExample("vm1.g1", "e2"));
//$NON-NLS-1$ //$NON-NLS-2$
elements.add(TestElementImpl.helpExample("vm1.g1", "e3"));
//$NON-NLS-1$ //$NON-NLS-2$
elements.add(TestElementImpl.helpExample("vm1.g1", "e4"));
//$NON-NLS-1$ //$NON-NLS-2$
- ArrayList types = new ArrayList();
+ ArrayList<Boolean> types = new ArrayList<Boolean>();
types.add(Boolean.TRUE);
types.add(Boolean.FALSE);
types.add(Boolean.TRUE);
@@ -57,17 +50,13 @@
}
public static OrderBy example() throws Exception {
- return TstLanguageBridgeFactory.factory.translate(helpExample());
+ return TstLanguageBridgeFactory.factory.translate(helpExample(), false);
}
- public void testGetItems() throws Exception {
- List items = example().getSortSpecifications();
+ @Test public void testGetItems() throws Exception {
+ List<SortSpecification> items = example().getSortSpecifications();
assertNotNull(items);
assertEquals(4, items.size());
- for (Iterator i = items.iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof SortSpecification);
- }
-
}
}
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,21 +22,22 @@
package org.teiid.dqp.internal.process;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.junit.Test;
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.query.processor.HardcodedDataManager;
import org.teiid.query.unittest.FakeMetadataFactory;
-import junit.framework.TestCase;
-
-
-public class TestCallableStatement extends TestCase {
+@SuppressWarnings("nls")
+public class TestCallableStatement {
- public void testMissingInput() throws Exception {
+ @Test public void testMissingInput() throws Exception {
String sql = "{? = call pm4.spTest9()}"; //$NON-NLS-1$
try {
@@ -47,7 +48,7 @@
}
}
- public void testReturnParameter() throws Exception {
+ @Test public void testReturnParameter() throws Exception {
String sql = "{? = call pm4.spTest9(?)}"; //$NON-NLS-1$
List values = new ArrayList();
@@ -57,7 +58,7 @@
expected[0] = Arrays.asList(1);
HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("EXEC pm4.spTest9(1)", expected);
+ dataManager.addData("? = EXEC pm4.spTest9(1)", expected);
TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager,
FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
}
@@ -66,7 +67,7 @@
* same result as above, but the return parameter is not specified
* TODO: it would be best if the return parameter were not actually returned here, since
it wasn't specified in the initial sql
*/
- public void testNoReturnParameter() throws Exception {
+ @Test public void testNoReturnParameter() throws Exception {
String sql = "{call pm4.spTest9(?)}"; //$NON-NLS-1$
List values = new ArrayList();
@@ -81,7 +82,7 @@
TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager,
FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
}
- public void testOutParameter() throws Exception {
+ @Test public void testOutParameter() throws Exception {
String sql = "{call pm2.spTest8(?, ?)}"; //$NON-NLS-1$
List values = new ArrayList();
@@ -96,7 +97,18 @@
TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager,
FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
}
- public void testInputExpression() throws Exception {
+ @Test(expected=QueryResolverException.class) public void testInvalidReturn() throws
Exception {
+ String sql = "{? = call pm2.spTest8(?, ?)}"; //$NON-NLS-1$
+
+ List values = Arrays.asList(2);
+
+ List[] expected = new List[0];
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager,
FakeMetadataFactory.exampleBQTCached(), true, FakeMetadataFactory.exampleBQTVDB());
+ }
+
+ @Test public void testInputExpression() throws Exception {
String sql = "{call pm2.spTest8(1, ?)}"; //$NON-NLS-1$
List[] expected = new List[1];
Modified:
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -24,15 +24,13 @@
import java.lang.reflect.Method;
+import junit.framework.TestCase;
+
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.UnitTestUtil;
-import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.FunctionTree;
import org.teiid.query.function.metadata.FunctionMethod;
-import junit.framework.TestCase;
-
public class TestFunctionDescriptorImpl extends TestCase {
/**
@@ -72,10 +70,6 @@
return null;
}
- // Validate method
- if(! FunctionTree.isValidMethod(method)) {
- return null;
- }
return method;
}
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -57,6 +57,7 @@
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.query.util.CommandContext;
import org.teiid.translator.SourceSystemFunctions;
@@ -78,7 +79,7 @@
private static final Class<Date> T_DATE =
DataTypeManager.DefaultDataClasses.DATE;
private static final Class<Timestamp> T_TIMESTAMP =
DataTypeManager.DefaultDataClasses.TIMESTAMP;
- private FunctionLibrary library = new
FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(Collections.EMPTY_LIST)));
+ private FunctionLibrary library = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new
UDFSource(Collections.EMPTY_LIST)));
@Before public void setUp() {
TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00"));
//$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,96 +22,120 @@
package org.teiid.query.function;
-import java.util.ArrayList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.mockito.Mockito;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.logging.LogManager;
-import org.teiid.query.function.FunctionForm;
-import org.teiid.query.function.FunctionLibrary;
-import org.teiid.query.function.FunctionMetadataSource;
-import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.SystemFunctionManager;
-import org.teiid.query.function.UDFSource;
import org.teiid.query.function.metadata.FunctionCategoryConstants;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.function.metadata.FunctionParameter;
import org.teiid.query.function.source.SystemSource;
+import org.teiid.query.unittest.FakeMetadataFactory;
+@SuppressWarnings("nls")
+public class TestFunctionTree {
-public class TestFunctionTree extends TestCase {
-
- // ################################## FRAMEWORK ################################
-
- public TestFunctionTree(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
- // ################################## ACTUAL TESTS ################################
-
/**
* Walk through all functions by metadata and verify that we can look
* each one up by signature
*/
- public void testWalkTree() {
- SystemSource source = new SystemSource();
+ @Test public void testWalkTree() {
+ SystemSource source = new SystemSource(false);
FunctionTree ft = new FunctionTree(source);
- Collection categories = ft.getCategories();
- Iterator catIter = categories.iterator();
- while(catIter.hasNext()) {
- String category = (String) catIter.next();
- LogManager.logInfo("test", "Category: " + category);
//$NON-NLS-1$ //$NON-NLS-2$
-
- Collection functions = ft.getFunctionForms(category);
- Iterator functionIter = functions.iterator();
- while(functionIter.hasNext()) {
- FunctionForm form = (FunctionForm) functionIter.next();
- LogManager.logInfo("test", "\tFunction: " +
form.getDisplayString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ Collection<String> categories = ft.getCategories();
+ for (String category : categories) {
+ Collection<FunctionForm> functions = ft.getFunctionForms(category);
+ assertTrue(functions.size() > 0);
}
}
- /**
- * Test what happens when a function is loaded that does not have a class in the
- * classpath. This *should* be ok as long as the function is not invoked.
- */
- public void testUnloadableFunction() {
- // Create dummy source
- FunctionMetadataSource dummySource = new FunctionMetadataSource() {
- public Collection getFunctionMethods() {
- // Build dummy method
- FunctionMethod method = new FunctionMethod(
- "dummy", null, "no category",
"nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
- new FunctionParameter[0],
- new FunctionParameter("output",
DataTypeManager.DefaultDataTypes.STRING) ); //$NON-NLS-1$
+ public String z() {
+ return null;
+ }
+
+ protected static String x() {
+ return null;
+ }
+
+ public static String y() {
+ return null;
+ }
+
+ @Test public void testLoadErrors() {
+ FunctionMethod method = new FunctionMethod(
+ "dummy", null, null, FunctionMethod.CAN_PUSHDOWN,
"nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+ new FunctionParameter[0],
+ new FunctionParameter("output",
DataTypeManager.DefaultDataTypes.STRING)); //$NON-NLS-1$
+
+ //allowed, since we're not validating the class
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method))));
+
+ //should fail, no class
+ try {
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
+
+ method.setInvocationClass(TestFunctionTree.class.getName());
+
+ //should fail, no method
+ try {
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
+
+ method.setInvocationMethod("testLoadErrors");
+
+ //should fail, not void
+ try {
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
+
+ method.setInvocationMethod("x");
+
+ //should fail, not public
+ try {
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
+
+ method.setInvocationMethod("z");
+
+ //should fail, not static
+ try {
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
- // Wrap method in a list
- List methods = new ArrayList();
- methods.add(method);
- return methods;
- }
-
- public Class getInvocationClass(String className) throws ClassNotFoundException {
- throw new ClassNotFoundException("Could not find class " +
className); //$NON-NLS-1$
- }
- };
+ method.setInvocationMethod("y");
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(dummySource.getFunctionMethods())));
+ //valid!
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
}
- public void testNullCategory() {
+ @Test public void testNullCategory() {
FunctionMetadataSource fms = Mockito.mock(FunctionMetadataSource.class);
Mockito.stub(fms.getFunctionMethods()).toReturn(Arrays.asList(new FunctionMethod(
- "dummy", null, null, FunctionMethod.MUST_PUSHDOWN,
"nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
+ "dummy", null, null, FunctionMethod.MUST_PUSHDOWN,
"nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
new FunctionParameter[0],
new FunctionParameter("output",
DataTypeManager.DefaultDataTypes.STRING) //$NON-NLS-1$
)));
Modified:
trunk/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -43,7 +43,7 @@
// ################################## ACTUAL TESTS ################################
public void testValidate() {
- SystemSource source = new SystemSource();
+ SystemSource source = new SystemSource(false);
ActivityReport report = new ActivityReport("Test Report");
//$NON-NLS-1$
FunctionMetadataValidator.validateFunctionMethods(source.getFunctionMethods(),
report);
Modified:
trunk/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -80,7 +80,7 @@
vdb.addModel(buildModel("x"));
vdb.addModel(buildModel("x1"));
- return new TransformationMetadata(vdb, cms, null, null);
+ return new TransformationMetadata(vdb, cms, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
}
ModelMetaData buildModel(String name) {
@@ -113,7 +113,7 @@
model2.setVisible(true);
vdb.addModel(model2);
- TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null);
+ TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
assertEquals(2, result.size());
@@ -121,7 +121,7 @@
model.setVisible(false);
- tm = new TransformationMetadata(vdb, cms, null, null);
+ tm = new TransformationMetadata(vdb, cms, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
assertEquals(1, result.size());
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,7 +22,11 @@
package org.teiid.query.optimizer;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
@@ -35,18 +39,16 @@
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.UDFSource;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.optimizer.QueryOptimizer;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
@@ -4253,7 +4255,7 @@
caps.setFunctionSupport("xyz", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FunctionLibrary funcLibrary = new
FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
FakeMetadataFacade metadata = new
FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -27,8 +27,8 @@
import org.junit.Test;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.dqp.internal.datamgr.LanguageBridgeFactory;
import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.optimizer.relational.AliasGenerator;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.TestResolver;
import org.teiid.query.rewriter.QueryRewriter;
@@ -39,7 +39,7 @@
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.unittest.FakeMetadataFactory;
-
+@SuppressWarnings("nls")
public class TestAliasGenerator {
private Command helpTest(String sql,
@@ -159,7 +159,10 @@
@Test public void testStripAliases1() throws Exception {
String sql = "select intkey as a, stringkey as b from BQT1.SmallA ORDER BY a,
b"; //$NON-NLS-1$
String expected = "SELECT BQT1.SmallA.intkey, BQT1.SmallA.stringkey FROM
BQT1.SmallA ORDER BY BQT1.SmallA.intkey, BQT1.SmallA.stringkey"; //$NON-NLS-1$
- helpTest(sql, expected, false, true, FakeMetadataFactory.exampleBQTCached());
+ Command command = helpTest(sql, expected, false, true,
FakeMetadataFactory.exampleBQTCached());
+ LanguageBridgeFactory lbf = new
LanguageBridgeFactory(FakeMetadataFactory.exampleBQTCached());
+ org.teiid.language.Command c = lbf.translate(command);
+ assertEquals("SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY
SmallA.IntKey, SmallA.StringKey", c.toString());
}
}
Modified:
trunk/engine/src/test/java/org/teiid/query/parser/TestCallableStatementParsing.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/parser/TestCallableStatementParsing.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/parser/TestCallableStatementParsing.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -29,7 +29,7 @@
import org.teiid.query.parser.QueryParser;
import org.teiid.query.sql.lang.StoredProcedure;
-
+@SuppressWarnings("nls")
public class TestCallableStatementParsing {
private void helpTestIllegalCall(String call) {
@@ -46,7 +46,7 @@
assertTrue(sp.isCallableStatement());
assertEquals(returnValue, sp.returnsScalarValue());
assertEquals("procedure_name", sp.getProcedureName()); //$NON-NLS-1$
- assertEquals("EXEC procedure_name(?, ?, ?)", sp.toString());
//$NON-NLS-1$
+ assertEquals((returnValue ? "? = ":"") +"EXEC
procedure_name(?, ?, ?)", sp.toString()); //$NON-NLS-1$
}
@Test public void testCallNoParams() throws QueryParserException {
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -29,10 +29,8 @@
import java.util.List;
import org.junit.Test;
-import org.teiid.query.parser.QueryParser;
import org.teiid.query.sql.lang.AbstractCompareCriteria;
import org.teiid.query.sql.lang.CacheHint;
-import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.Delete;
@@ -776,8 +774,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -800,8 +797,7 @@
elseQuery.setFrom(elseFrom);
elseQuery.setCriteria(criteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -832,12 +828,12 @@
cmd.setBlock(block);
TestParser.helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+
//$NON-NLS-1$
- " IF(HAS IN CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2 = 5;
END"+ //$NON-NLS-1$
+ " IF(HAS IN CRITERIA ON (a)) BEGIN var1 = (SELECT a1 FROM g WHERE a2 =
5); END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g, /*+ optional */
h WHERE a2 = 5; END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS IN CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS IN CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g, /*+ optional */ h WHERE a2 =
5;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g, /*+ optional */ h WHERE a2 =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
@Test public void testStoredQueryWithOption(){
@@ -1126,7 +1122,7 @@
sp.setCallableStatement(true);
CacheHint hint = new CacheHint();
sp.setCacheHint(hint);
- TestParser.helpTest(sql, "/*+ cache */ EXEC proc()", sp);
//$NON-NLS-1$
+ TestParser.helpTest(sql, "/*+ cache */ ? = EXEC proc()", sp);
//$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -3549,38 +3549,17 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
-
Expression expr = new Constant("aString"); //$NON-NLS-1$
- AssignmentStatement queryStmt = new AssignmentStatement(a, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(a, query);
AssignmentStatement exprStmt = new AssignmentStatement(a, expr);
- helpStmtTest("a = SELECT a1 FROM g WHERE a2 = 5;", "a = SELECT a1
FROM g WHERE a2 = 5;", //$NON-NLS-1$ //$NON-NLS-2$
+ helpStmtTest("a = SELECT a1 FROM g WHERE a2 = 5;", "a = (SELECT a1
FROM g WHERE a2 = 5);", //$NON-NLS-1$ //$NON-NLS-2$
queryStmt);
helpStmtTest("a = 'aString';", "a =
'aString';", exprStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testAssignStatement2() throws Exception {
- Insert insert = new Insert();
- insert.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
- List vars = new ArrayList();
- vars.add(new ElementSymbol("a")); //$NON-NLS-1$
-
- insert.setVariables(vars);
- List values = new ArrayList();
- values.add(new Reference(0));
- insert.setValues(values);
-
- //Command insertCmd = insert;
- AssignmentStatement insertStmt = new AssignmentStatement(new
ElementSymbol("b"), insert); //$NON-NLS-1$
-
- helpStmtTest("b = INSERT INTO g (a) VALUES (?);", "b = INSERT INTO
g (a) VALUES (?);", //$NON-NLS-1$ //$NON-NLS-2$
- insertStmt);
-
- }
-
@Test public void testDeclareStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
@@ -3602,7 +3581,7 @@
String type = new String("string"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type, new
ScalarSubquery(sampleQuery()));
- 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$
+ 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() throws Exception {
@@ -3675,7 +3654,7 @@
CommandStatement cmdStmt = new CommandStatement(sqlCmd);
- helpStmtTest("exec string 'SELECT a1 FROM g WHERE a2 = 5' as a1
string into #g;", "EXECUTE STRING 'SELECT a1 FROM g WHERE a2 = 5' AS a1
string INTO #g;", //$NON-NLS-1$ //$NON-NLS-2$
+ helpStmtTest("exec string 'SELECT a1 FROM g WHERE a2 = 5' as a1
string into #g;", "EXECUTE 'SELECT a1 FROM g WHERE a2 = 5' AS a1 string
INTO #g;", //$NON-NLS-1$ //$NON-NLS-2$
cmdStmt);
}
@@ -3704,7 +3683,7 @@
CommandStatement cmdStmt = new CommandStatement(sqlCmd);
- helpStmtTest("execute string z as a1 string, a2 integer into #g update
1;", "EXECUTE STRING z AS a1 string, a2 integer INTO #g UPDATE 1;",
//$NON-NLS-1$ //$NON-NLS-2$
+ helpStmtTest("execute string z as a1 string, a2 integer into #g update
1;", "EXECUTE z AS a1 string, a2 integer INTO #g UPDATE 1;", //$NON-NLS-1$
//$NON-NLS-2$
cmdStmt);
}
@@ -3722,7 +3701,7 @@
CommandStatement cmdStmt = new CommandStatement(sqlCmd);
- helpStmtTest("execute string z using a=b;", "EXECUTE STRING z
USING a = b;", //$NON-NLS-1$ //$NON-NLS-2$
+ helpStmtTest("execute immediate z using a=b;", "EXECUTE z USING a
= b;", //$NON-NLS-1$ //$NON-NLS-2$
cmdStmt);
}
@@ -3744,27 +3723,25 @@
/** original test */
@Test public void testCreateUpdateProcedureCommand(){
helpTestCreateUpdateProcedureCommandCase3025("CREATE
PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
- "IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = SELECT a1 FROM g WHERE a2
= 5;\nEND\n"+ //$NON-NLS-1$
- "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = SELECT b1 FROM g WHERE a2 =
5;\nEND\n" + //$NON-NLS-1$
+ "IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = (SELECT a1 FROM g WHERE
a2 = 5);\nEND\n"+ //$NON-NLS-1$
+ "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = (SELECT b1 FROM g WHERE a2 =
5);\nEND\n" + //$NON-NLS-1$
" END"); //$NON-NLS-1$
}
- /** test that a command in parens isn't parsed as a ScalarSubquery */
@Test public void testCreateUpdateProcedureCommandCase3025_1(){
helpTestCreateUpdateProcedureCommandCase3025("CREATE
PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = (SELECT a1 FROM g WHERE a2
= 5);\nEND\n"+ //$NON-NLS-1$
- "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = SELECT b1 FROM g WHERE a2 =
5;\nEND\n" + //$NON-NLS-1$
+ "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = (SELECT b1 FROM g WHERE a2 =
5);\nEND\n" + //$NON-NLS-1$
" END"); //$NON-NLS-1$
}
- /** test that a command in DOUBLE parens isn't parsed as a ScalarSubquery */
@Test public void testCreateUpdateProcedureCommandCase3025_2(){
helpTestCreateUpdateProcedureCommandCase3025("CREATE
PROCEDURE\nBEGIN\nDECLARE short var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = ((SELECT a1 FROM g WHERE
a2 = 5) );\nEND\n"+ //$NON-NLS-1$
- "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = SELECT b1 FROM g WHERE a2 =
5;\nEND\n" + //$NON-NLS-1$
+ "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = (SELECT b1 FROM g WHERE a2 =
5);\nEND\n" + //$NON-NLS-1$
" END"); //$NON-NLS-1$
}
@@ -3790,8 +3767,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -3810,7 +3786,7 @@
elseQuery.setCriteria(criteria);
Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -3842,9 +3818,9 @@
cmd.setBlock(block);
helpTest(procedureString, "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$
- "IF(HAS IS NULL CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS IS NULL CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE a2 =
5;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE a2 =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
@@ -3853,7 +3829,7 @@
String procedureString = "CREATE PROCEDURE\nBEGIN\nDECLARE short
var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = (concat('x',
'y') );\nEND\n"+ //$NON-NLS-1$
- "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = SELECT b1 FROM g WHERE a2 =
5;\nEND\n" + //$NON-NLS-1$
+ "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = (SELECT b1 FROM g WHERE a2 =
5);\nEND\n" + //$NON-NLS-1$
" END"; //$NON-NLS-1$
helpTestCreateUpdateProcedureCommandCase3025_Expression(procedureString);
@@ -3864,7 +3840,7 @@
String procedureString = "CREATE PROCEDURE\nBEGIN\nDECLARE short
var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = ((concat('x',
'y') ));\nEND\n"+ //$NON-NLS-1$
- "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = SELECT b1 FROM g WHERE a2 =
5;\nEND\n" + //$NON-NLS-1$
+ "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = (SELECT b1 FROM g WHERE a2 =
5);\nEND\n" + //$NON-NLS-1$
" END"; //$NON-NLS-1$
helpTestCreateUpdateProcedureCommandCase3025_Expression(procedureString);
@@ -3875,7 +3851,7 @@
String procedureString = "CREATE PROCEDURE\nBEGIN\nDECLARE short
var1;"+ //$NON-NLS-1$
"IF(HAS IS NULL CRITERIA ON (a))\nBEGIN\nvar1 = concat('x',
'y') ;\nEND\n"+ //$NON-NLS-1$
- "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = SELECT b1 FROM g WHERE a2 =
5;\nEND\n" + //$NON-NLS-1$
+ "ELSE\nBEGIN\nDECLARE short var2;\nvar2 = (SELECT b1 FROM g WHERE a2 =
5);\nEND\n" + //$NON-NLS-1$
" END"; //$NON-NLS-1$
helpTestCreateUpdateProcedureCommandCase3025_Expression(procedureString);
@@ -3887,7 +3863,7 @@
String expectedString = "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$
"IF(HAS IS NULL CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 =
concat('x', 'y');"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE a2 =
5;"+"\n"+"END"+"\n"+"END"; //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE a2 =
5);"+"\n"+"END"+"\n"+"END"; //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
@@ -3921,8 +3897,7 @@
elseQuery.setFrom(from);
elseQuery.setCriteria(criteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -3979,8 +3954,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -3998,8 +3972,7 @@
elseQuery.setFrom(from);
elseQuery.setCriteria(criteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4032,9 +4005,9 @@
" IF(HAS CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2 = 5;
END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE a2 = 5;
END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE a2 =
5;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE a2 =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
@Test public void testCreateUpdateProcedureCommand0(){
@@ -4059,8 +4032,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4078,8 +4050,7 @@
elseQuery.setFrom(from);
elseQuery.setCriteria(criteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4112,9 +4083,9 @@
" IF(HAS CRITERIA) BEGIN var1 = SELECT a1 FROM g WHERE a2 = 5; END"+
//$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE a2 = 5;
END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS CRITERIA)"+"\n"+"BEGIN"+"\n"+
"var1 = SELECT a1 FROM g WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS CRITERIA)"+"\n"+"BEGIN"+"\n"+
"var1 = (SELECT a1 FROM g WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE a2 =
5;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE a2 =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/**IF statement with has LIKE criteria */
@@ -4140,8 +4111,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4159,8 +4129,7 @@
elseQuery.setFrom(from);
elseQuery.setCriteria(criteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4194,9 +4163,9 @@
" IF(HAS LIKE CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2 =
5; END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE a2 = 5;
END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS LIKE CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS LIKE CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE a2 =
5;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE a2 =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/**IF statement with has IN criteria */
@@ -4222,8 +4191,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4241,8 +4209,7 @@
elseQuery.setFrom(from);
elseQuery.setCriteria(criteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4276,9 +4243,9 @@
" IF(HAS IN CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2 = 5;
END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE a2 = 5;
END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS IN CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS IN CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE a2 =
5;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE a2 =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/**IF statement with has <> criteria */
@@ -4304,8 +4271,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4323,8 +4289,7 @@
elseQuery.setFrom(from);
elseQuery.setCriteria(criteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4358,9 +4323,9 @@
" IF(HAS <> CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2
= 5; END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE a2 = 5;
END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE a2 =
5;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE a2 =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/**Has criteria in WHERE clause*/
@@ -4386,8 +4351,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4418,8 +4382,7 @@
//has criteria for else block
elseQuery.setCriteria(hasSelector2);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4448,9 +4411,9 @@
" IF(HAS <> CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2
= 5; END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE HAS
CRITERIA ON (a); END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE HAS CRITERIA ON
(a);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE HAS CRITERIA ON
(a));"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$
}
/** Translate criteria (empty criteriaSelector in WHERE clause*/
@@ -4476,8 +4439,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4511,8 +4473,7 @@
TranslateCriteria transCriteria = new TranslateCriteria(critSelector2, critList);
elseQuery.setCriteria(transCriteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4539,11 +4500,11 @@
helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+ //$NON-NLS-1$
" IF(HAS <> CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2
= 5; END"+ //$NON-NLS-1$
- " ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE TRANSLATE
CRITERIA ON (a) WITH (a = 5); END" + //$NON-NLS-1$
+ " ELSE BEGIN DECLARE short var2; var2 = (SELECT b1 FROM g WHERE TRANSLATE
CRITERIA ON (a) WITH (a = 5)); END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE TRANSLATE CRITERIA ON (a) WITH (a =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE TRANSLATE CRITERIA ON (a) WITH (a =
5));"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/** Translate criteria (is null criteriaSelector in WHERE clause*/
@@ -4569,8 +4530,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4604,8 +4564,7 @@
TranslateCriteria transCriteria = new TranslateCriteria(critSelector2, critList);
elseQuery.setCriteria(transCriteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4634,9 +4593,9 @@
" IF(HAS <> CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2
= 5; END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE TRANSLATE
IS NULL CRITERIA ON (a) WITH (a = 5); END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE TRANSLATE IS NULL CRITERIA ON (a) WITH (a
= 5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE TRANSLATE IS NULL CRITERIA ON (a) WITH (a
= 5));"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/** Translate criteria ( only with WHERE clause) */
@@ -4662,8 +4621,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4697,8 +4655,7 @@
elseQuery.setCriteria(transCriteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4727,9 +4684,9 @@
" IF(HAS <> CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2
= 5; END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE TRANSLATE
CRITERIA WITH (a = 5); END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE TRANSLATE CRITERIA WITH (a =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE TRANSLATE CRITERIA WITH (a =
5));"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/** Translate criteria ( only with WHERE clause) */
@@ -4755,8 +4712,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4795,8 +4751,7 @@
elseQuery.setCriteria(transCriteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4825,9 +4780,9 @@
" IF(HAS <> CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2
= 5; END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE TRANSLATE
CRITERIA WITH (a = 5, m = 6); END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE TRANSLATE CRITERIA WITH (a = 5, m =
6);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE TRANSLATE CRITERIA WITH (a = 5, m =
6));"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
@@ -4854,8 +4809,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4888,8 +4842,7 @@
elseQuery.setCriteria(transCrit);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4918,9 +4871,9 @@
" IF(HAS <> CRITERIA ON (a)) BEGIN var1 = SELECT a1 FROM g WHERE a2
= 5; END"+ //$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE TRANSLATE
CRITERIA; END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = SELECT a1 FROM g
WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS <> CRITERIA ON
(a))"+"\n"+"BEGIN"+"\n"+ "var1 = (SELECT a1 FROM g
WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE TRANSLATE
CRITERIA;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE TRANSLATE
CRITERIA);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/**IF statement with has criteria no on */
@@ -4946,8 +4899,7 @@
query.setFrom(from);
query.setCriteria(criteria);
- Command queryCmd = query;
- AssignmentStatement queryStmt = new AssignmentStatement(var1, queryCmd);
+ AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
Block ifBlock = new Block();
ifBlock.addStatement(queryStmt);
@@ -4965,8 +4917,7 @@
elseQuery.setFrom(from);
elseQuery.setCriteria(criteria);
- Command elseQueryCmd = elseQuery;
- AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQueryCmd);
+ AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
Block elseBlock = new Block();
List elseStmts = new ArrayList();
@@ -4993,9 +4944,9 @@
" IF(HAS CRITERIA) BEGIN var1 = SELECT a1 FROM g WHERE a2 = 5; END"+
//$NON-NLS-1$
" ELSE BEGIN DECLARE short var2; var2 = SELECT b1 FROM g WHERE a2 = 5;
END" + //$NON-NLS-1$
" END", "CREATE
PROCEDURE"+"\n"+"BEGIN"+"\n"+"DECLARE short
var1;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "IF(HAS CRITERIA)"+"\n"+"BEGIN"+"\n"+
"var1 = SELECT a1 FROM g WHERE a2 = 5;"+"\n"+ //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "IF(HAS CRITERIA)"+"\n"+"BEGIN"+"\n"+
"var1 = (SELECT a1 FROM g WHERE a2 = 5);"+"\n"+ //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"END"+"\n"+"ELSE"+"\n"+"BEGIN"+"\n"+"DECLARE
short var2;"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "var2 = SELECT b1 FROM g WHERE a2 =
5;"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "var2 = (SELECT b1 FROM g WHERE a2 =
5);"+"\n"+"END"+"\n"+"END", cmd);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
@Test public void testSubquerySetCriteria0() {
@@ -5070,7 +5021,8 @@
StoredProcedure exec = new StoredProcedure();
exec.setProcedureName("m.sq1"); //$NON-NLS-1$
- SubquerySetCriteria subCrit = new SubquerySetCriteria(expr, exec);
+ Query query = new Query(new Select(Arrays.asList(new AllSymbol())), new
From(Arrays.asList(new SubqueryFromClause("x", exec))), null, null, null);
+ SubquerySetCriteria subCrit = new SubquerySetCriteria(expr, query);
Query outer = new Query();
outer.setSelect(select);
@@ -5078,7 +5030,7 @@
outer.setCriteria(subCrit);
helpTest("SELECT a FROM db.g WHERE b IN (EXEC m.sq1())", //$NON-NLS-1$
- "SELECT a FROM db.g WHERE b IN (EXEC m.sq1())", //$NON-NLS-1$
+ "SELECT a FROM db.g WHERE b IN (SELECT * FROM (EXEC m.sq1()) AS
x)", //$NON-NLS-1$
outer);
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -72,4 +72,23 @@
assertEquals(2, bi.nextTuple().get(0));
}
+ @Test public void testReset2() throws Exception {
+ BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] {
+ Arrays.asList(1),
+ Arrays.asList(2),
+ }, 2));
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x")),
"test", TupleSourceType.PROCESSOR);
+ bi.setBuffer(tb, true); //$NON-NLS-1$
+ bi.hasNext();
+ bi.mark();
+ bi.nextTuple();
+ bi.nextTuple();
+ assertNull(bi.nextTuple());
+ bi.reset();
+ bi.hasNext();
+ assertEquals(1, bi.getCurrentIndex());
+ assertEquals(1, bi.nextTuple().get(0));
+ }
+
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -62,7 +62,6 @@
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.UDFSource;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -5272,7 +5271,7 @@
caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FunctionLibrary funcLibrary = new
FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
FakeMetadataFacade metadata = new
FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
processPreparedStatement(sql, expected, dataManager, capFinder,
@@ -5320,7 +5319,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
- FunctionLibrary funcLibrary = new
FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
FakeMetadataFacade metadata = new
FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
processPreparedStatement(sql, expected, dataManager, capFinder,
@@ -6243,7 +6242,7 @@
new List[] { Arrays.asList(new Object[] { new Integer(1) }
)});
// Create expected results
- List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(1)})};
+ List[] expected = new List[] { Arrays.asList(0)};
// Run query
helpProcess(plan, dataManager, expected);
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,7 +22,8 @@
package org.teiid.query.processor.eval;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -59,6 +60,7 @@
import org.teiid.query.sql.symbol.TestCaseExpression;
import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
import org.teiid.query.sql.util.ValueIterator;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
@SuppressWarnings("nls")
@@ -192,7 +194,7 @@
e2.setType(String.class);
Function func = new Function("concat", new Expression[] { e1, e2 });
//$NON-NLS-1$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new
Class[] { String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new
Class[] { String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -214,7 +216,7 @@
e2.setType(String.class);
Function func = new Function("concat", new Expression[] { e2, e1 });
//$NON-NLS-1$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new
Class[] { String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new
Class[] { String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -235,7 +237,7 @@
e1.setType(Integer.class);
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
e1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -307,7 +309,7 @@
@Test public void testUser() throws Exception {
Function func = new Function("user", new Expression[] {});
//$NON-NLS-1$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("user", new
Class[] {} ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("user", new
Class[] {} ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
@@ -324,7 +326,7 @@
*/
@Test public void testEnv() throws Exception {
Function func = new Function("env", new Expression[] {});
//$NON-NLS-1$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("env", new Class[]
{String.class} ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("env", new
Class[] {String.class} ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
@@ -350,7 +352,7 @@
} else {
parameterSignature = new Class[] { String.class };
}
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("commandpayload",
parameterSignature ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("commandpayload",
parameterSignature ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.List;
+import org.junit.Ignore;
import org.junit.Test;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryProcessingException;
@@ -41,6 +42,7 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.optimizer.QueryOptimizer;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
@@ -62,6 +64,7 @@
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.FakeMetadataObject;
import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorFailure;
@@ -70,7 +73,7 @@
@SuppressWarnings({"unchecked", "nls"})
public class TestProcedureProcessor {
- public static ProcessorPlan getProcedurePlan(String userQuery, FakeMetadataFacade
metadata) throws Exception {
+ public static ProcessorPlan getProcedurePlan(String userQuery, QueryMetadataInterface
metadata) throws Exception {
return getProcedurePlan(userQuery, metadata, /*capabilitiesFinder*/null);
}
@@ -1514,7 +1517,7 @@
helpTestProcessFailure(plan,
dataMgr,
- "Couldn't execute the dynamic SQL command
\"EXECUTE STRING 'EXEC pm1.sq2(''First'')' AS e1 string, e2
integer\" with the SQL statement \"'EXEC
pm1.sq2(''First'')'\" due to: There is a recursive invocation of
group 'PM1.SQ2'. Please correct the SQL.", metadata); //$NON-NLS-1$
+ "Couldn't execute the dynamic SQL command
\"EXECUTE 'EXEC pm1.sq2(''First'')' AS e1 string, e2
integer\" with the SQL statement \"'EXEC
pm1.sq2(''First'')'\" due to: There is a recursive invocation of
group 'PM1.SQ2'. Please correct the SQL.", metadata); //$NON-NLS-1$
}
@Test public void testDynamicCommandIncorrectProjectSymbolCount() throws Exception {
@@ -1544,7 +1547,7 @@
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL
command \"EXECUTE STRING 'EXEC pm1.sq1(''First'')' AS e1
string, e2 integer\" with the SQL statement \"'EXEC
pm1.sq1(''First'')'\" due to: The dynamic sql string contains an
incorrect number of elements.", metadata); //$NON-NLS-1$
+ helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL
command \"EXECUTE 'EXEC pm1.sq1(''First'')' AS e1 string, e2
integer\" with the SQL statement \"'EXEC
pm1.sq1(''First'')'\" due to: The dynamic sql string contains an
incorrect number of elements.", metadata); //$NON-NLS-1$
}
@Test public void testDynamicCommandPositional() throws Exception {
@@ -1596,7 +1599,7 @@
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcessFailure(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'.", metadata); //$NON-NLS-1$
+ helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL
command \"EXECUTE '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'.", metadata); //$NON-NLS-1$
}
@Test public void testDynamicCommandWithTwoDynamicStatements() throws Exception {
@@ -2648,5 +2651,16 @@
helpTestProcess(plan, expected, new HardcodedDataManager(), metadata);
}
+ @Ignore
+ @Test public void testProcReturn() throws Exception {
+ TransformationMetadata metadata = RealMetadataFactory.exampleBQTCached();
+ String userQuery = "EXEC TEIIDSP7(1)"; //$NON-NLS-1$
+ HardcodedDataManager dataMgr = new HardcodedDataManager();
+ ProcessorPlan plan = getProcedurePlan(userQuery, metadata);
+ dataMgr.addData("VARIABLES.x = EXEC spTest9(1)", new List[]
{Arrays.asList(3)});
+ List[] expected = new List[] {Arrays.asList(new Object[] {new Integer(3)})};
+ helpTestProcess(plan, expected, dataMgr, metadata);
+ }
+
private static final boolean DEBUG = false;
}
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,7 +22,7 @@
package org.teiid.query.processor.relational;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -36,13 +36,11 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.TupleBatch;
-import org.teiid.common.buffer.TupleSource;
import org.teiid.common.buffer.impl.BufferManagerImpl;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.aggregate.AggregateFunction;
import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.processor.FakeTupleSource;
@@ -52,6 +50,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -272,7 +271,7 @@
// Set grouping elements to null
List groupingElements = new ArrayList();
- groupingElements.add(col1); //$NON-NLS-1$
+ groupingElements.add(col1);
node.setGroupingElements(groupingElements);
CommandContext context = new CommandContext("pid", "test",
null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -309,7 +308,7 @@
col2.setType(Integer.class);
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
col2 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -320,7 +319,7 @@
node.setElements(outputElements);
List groupingElements = new ArrayList();
- groupingElements.add(col1); //$NON-NLS-1$
+ groupingElements.add(col1);
node.setGroupingElements(groupingElements);
CommandContext context = new CommandContext("pid", "test",
null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -434,7 +433,7 @@
node.setElements(outputElements);
List groupingElements = new ArrayList();
- groupingElements.add(col1); //$NON-NLS-1$
+ groupingElements.add(col1);
node.setGroupingElements(groupingElements);
return node;
}
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -39,14 +39,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.processor.FakeDataManager;
-import org.teiid.query.processor.relational.JoinNode;
-import org.teiid.query.processor.relational.JoinStrategy;
-import org.teiid.query.processor.relational.MergeJoinStrategy;
-import org.teiid.query.processor.relational.NestedLoopJoinStrategy;
-import org.teiid.query.processor.relational.PartitionedSortJoin;
-import org.teiid.query.processor.relational.RelationalNode;
import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.JoinType;
@@ -54,6 +47,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -209,7 +203,7 @@
case FUNCTION_CRITERIA :
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class }); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class }); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
CompareCriteria joinCriteria = new CompareCriteria(es2,
CompareCriteria.EQ, func);
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -28,6 +28,8 @@
import java.util.List;
import java.util.Map;
+import junit.framework.TestCase;
+
import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
@@ -37,20 +39,17 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.processor.ProcessorDataManager;
-import org.teiid.query.processor.relational.ProjectNode;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
-import junit.framework.TestCase;
-
/**
*/
public class TestProjectNode extends TestCase {
@@ -213,7 +212,7 @@
elements.add(es1);
Function func = new Function("concat", new Expression[] { es1, new
Constant("abc")}); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionDescriptor fd =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new
Class[] { DataTypeManager.DefaultDataClasses.STRING,
DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
+ FunctionDescriptor fd =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new
Class[] { DataTypeManager.DefaultDataClasses.STRING,
DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
func.setFunctionDescriptor(fd);
func.setType(DataTypeManager.DefaultDataClasses.STRING);
ExpressionSymbol expr = new ExpressionSymbol("expr", func);
//$NON-NLS-1$
@@ -237,7 +236,7 @@
elements.add(es1);
Function func = new Function("convert", new Expression[] { es1, new
Constant("integer")}); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionDescriptor fd =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("convert", new
Class[] { DataTypeManager.DefaultDataClasses.STRING,
DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
+ FunctionDescriptor fd =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("convert", new
Class[] { DataTypeManager.DefaultDataClasses.STRING,
DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
func.setFunctionDescriptor(fd);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
ExpressionSymbol expr = new ExpressionSymbol("expr", func);
//$NON-NLS-1$
@@ -260,7 +259,7 @@
elements.add(es1);
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.STRING);
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,7 +22,8 @@
package org.teiid.query.processor.relational;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import java.util.ArrayList;
import java.util.Arrays;
@@ -40,7 +41,6 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.processor.BatchIterator;
import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.processor.ProcessorDataManager;
@@ -51,6 +51,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
public class TestSelectNode {
@@ -236,7 +237,7 @@
elements.add(es1);
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
CompareCriteria crit = new CompareCriteria(func, CompareCriteria.EQ, new
Constant(new Integer(1)));
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,7 +22,13 @@
package org.teiid.query.resolver;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -50,13 +56,11 @@
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.function.FunctionDescriptor;
import org.teiid.query.function.FunctionLibrary;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.parser.QueryParser;
-import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.resolver.util.BindVariableVisitor;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.ProcedureReservedWords;
@@ -1400,7 +1404,7 @@
String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
- FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
+ FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] {
srcType, DataTypeManager.DefaultDataClasses.STRING });
Function conversion = new Function(fd.getName(), new Expression[] { expression, new
Constant(tgtTypeName) });
@@ -1436,7 +1440,7 @@
String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
- FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
+ FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] {
srcType, DataTypeManager.DefaultDataClasses.STRING });
Function conversion = new Function(fd.getName(), new Expression[] { expression, new
Constant(tgtTypeName) });
@@ -1886,7 +1890,7 @@
//String sql = "select intkey from SmallA where user() =
'bqt2'";
// Expected left expression
- FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
+ FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.USER, new Class[] {
});
Function user = new Function(fd.getName(), new Expression[] {});
user.setFunctionDescriptor(fd);
@@ -2238,13 +2242,13 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED = Select pm1.g1.e2 from pm1.g1 where
e2=INPUTS.e2;\n"; //$NON-NLS-1$
+ procedure = procedure + "ROWS_UPDATED = (Select pm1.g1.e2 from pm1.g1 where
e2=INPUTS.e2);\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
String userUpdateStr = "UPDATE vm1.g1 SET e2=40"; //$NON-NLS-1$
Command command = helpResolveUpdateProcedure(procedure, userUpdateStr);
- assertEquals("CREATE PROCEDURE\nBEGIN\nDECLARE integer var1;\nROWS_UPDATED =
SELECT pm1.g1.e2 FROM pm1.g1 WHERE e2 = INPUTS.e2;\nEND", command.toString());
+ assertEquals("CREATE PROCEDURE\nBEGIN\nDECLARE integer var1;\nROWS_UPDATED =
(SELECT pm1.g1.e2 FROM pm1.g1 WHERE e2 = INPUTS.e2);\nEND", command.toString());
}
@Test public void testDefect16894_resolverException_1() {
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1872,7 +1872,7 @@
String rewriten = getRewritenProcedure(userUpdateStr, metadata);
- String expected = "CREATE PROCEDURE\nBEGIN\nDECLARE string var1 =
'x';\nROWS_UPDATED = UPDATE vm1.g2 SET e1 = var1;\nEND"; //$NON-NLS-1$
+ String expected = "CREATE PROCEDURE\nBEGIN\nDECLARE string var1 =
'x';\nUPDATE vm1.g2 SET e1 = var1;\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND";
//$NON-NLS-1$
assertEquals(expected, rewriten);
}
Modified:
trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -181,7 +181,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 where e4 > 5",
//$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1,
pm1.g1.e2) VALUES (INPUTS.a, INPUTS.e2);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nINSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2)
VALUES (INPUTS.a, INPUTS.e2);\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND");
//$NON-NLS-1$
}
public void testCreateInsertCommand2(){ //put a constant in select statement
@@ -189,7 +189,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, 5 from pm1.g1 where e4 > 5", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1)
VALUES (INPUTS.a);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nINSERT INTO pm1.g1 (pm1.g1.e1) VALUES
(INPUTS.a);\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND"); //$NON-NLS-1$
}
public void testCreateInsertCommand3(){
@@ -197,7 +197,7 @@
"vm1.g2", //$NON-NLS-1$
"select * from pm1.g2 where e4 > 5", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1,
pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUTS.e1, INPUTS.e2, INPUTS.e3,
INPUTS.e4);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nINSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2,
pm1.g2.e3, pm1.g2.e4) VALUES (INPUTS.e1, INPUTS.e2, INPUTS.e3, INPUTS.e4);\nROWS_UPDATED =
VARIABLES.ROWCOUNT;\nEND"); //$NON-NLS-1$
}
public void testCreateInsertCommand4(){ //test group alias
@@ -205,7 +205,7 @@
"vm1.g2", //$NON-NLS-1$
"select * from pm1.g2 as g_alias", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g2 (pm1.g2.e1,
pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (INPUTS.e1, INPUTS.e2, INPUTS.e3,
INPUTS.e4);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nINSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3,
pm1.g2.e4) VALUES (INPUTS.e1, INPUTS.e2, INPUTS.e3, INPUTS.e4);\nROWS_UPDATED =
VARIABLES.ROWCOUNT;\nEND"); //$NON-NLS-1$
}
public void testCreateInsertCommand5(){
@@ -213,7 +213,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 as g_alias where e4 > 5",
//$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e1,
pm1.g1.e2) VALUES (INPUTS.a, INPUTS.e2);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nINSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES
(INPUTS.a, INPUTS.e2);\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND"); //$NON-NLS-1$
}
public void testCreateUpdateCommand(){
@@ -221,7 +221,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 where e4 > 5",
//$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e1 =
INPUTS.a, e2 = INPUTS.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nUPDATE pm1.g1 SET e1 = INPUTS.a, e2 =
INPUTS.e2 WHERE TRANSLATE CRITERIA;\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND");
//$NON-NLS-1$
}
public void testCreateDeleteCommand(){
@@ -229,7 +229,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 where e4 > 5",
//$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = DELETE FROM pm1.g1 WHERE
TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nDELETE FROM pm1.g1 WHERE TRANSLATE
CRITERIA;\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND"); //$NON-NLS-1$
}
public void testCreateInsertCommand1_fail(){
@@ -342,7 +342,7 @@
"vm1.g3", //$NON-NLS-1$
"SELECT e1, e2 FROM pm1.g3", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1,
pm1.g3.e2) VALUES (INPUTS.e1, INPUTS.e2);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nINSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e2)
VALUES (INPUTS.e1, INPUTS.e2);\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND");
//$NON-NLS-1$
}
// Check that e2 is not required (it is auto-incremented)
@@ -351,7 +351,7 @@
"vm1.g4", //$NON-NLS-1$
"SELECT e1, e3 FROM pm1.g3", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g3 (pm1.g3.e1,
pm1.g3.e3) VALUES (INPUTS.e1, INPUTS.e3);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nINSERT INTO pm1.g3 (pm1.g3.e1, pm1.g3.e3)
VALUES (INPUTS.e1, INPUTS.e3);\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND");
//$NON-NLS-1$
}
// Check that e1 is required (it is not-nullable, not auto-incrementable, and has no
default value)
@@ -369,7 +369,7 @@
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 where e4 > 5",
//$NON-NLS-1$
TestUpdateProcedureGenerator.example1(false),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e2 =
INPUTS.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nUPDATE pm1.g1 SET e2 = INPUTS.e2 WHERE
TRANSLATE CRITERIA;\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND"); //$NON-NLS-1$
}
// Verify that elements that are not updateable are exlcluded from update and delete
procedures
@@ -378,7 +378,7 @@
"vm1.g1", //$NON-NLS-1$
"SELECT e1, e2 FROM pm1.g1", //$NON-NLS-1$
TestUpdateProcedureGenerator.example1(false),
- "CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e2)
VALUES (INPUTS.e2);\nEND"); //$NON-NLS-1$
+ "CREATE PROCEDURE\nBEGIN\nINSERT INTO pm1.g1 (pm1.g1.e2) VALUES
(INPUTS.e2);\nROWS_UPDATED = VARIABLES.ROWCOUNT;\nEND"); //$NON-NLS-1$
}
}
Modified:
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -1416,7 +1416,7 @@
q1.setFrom(from);
AssignmentStatement assigStmt = new AssignmentStatement(new
ElementSymbol("a"), q1); //$NON-NLS-1$
- helpTest(assigStmt, "a = SELECT x FROM g;"); //$NON-NLS-1$
+ helpTest(assigStmt, "a = (SELECT x FROM g);"); //$NON-NLS-1$
}
public void testCriteriaSelector1() {
@@ -1722,7 +1722,7 @@
obj.setAsClauseSet(true);
obj.setIntoGroup(new GroupSymbol("#g")); //$NON-NLS-1$
- helpTest(obj, "EXECUTE STRING 'SELECT a1 FROM g WHERE a2 = 5' AS a1
string INTO #g"); //$NON-NLS-1$
+ helpTest(obj, "EXECUTE 'SELECT a1 FROM g WHERE a2 = 5' AS a1 string
INTO #g"); //$NON-NLS-1$
}
public void testScalarSubquery() {
@@ -1849,21 +1849,7 @@
helpTest(sq, expected);
}
-
- public void testNullExpressionInNamedParameter() {
-
- String expected = "EXEC sp1(PARAM => sp1.PARAM)"; //$NON-NLS-1$
-
- StoredProcedure sp = new StoredProcedure();
- sp.setDisplayNamedParameters(true);
- sp.setProcedureName("sp1"); //$NON-NLS-1$
- SPParameter param = new SPParameter(0, ParameterInfo.IN, "sp1.PARAM");
//$NON-NLS-1$
- sp.setParameter(param);
-
- helpTest(sp, expected);
- }
-
public void testLimit() {
Query query = new Query();
Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
Modified:
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestStaticSymbolMappingVisitor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestStaticSymbolMappingVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestStaticSymbolMappingVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -37,6 +37,7 @@
import org.teiid.query.sql.lang.IsNullCriteria;
import org.teiid.query.sql.lang.MatchCriteria;
import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.lang.StoredProcedure;
@@ -233,7 +234,7 @@
public void testVisitSubquerySetCriteria() {
SubquerySetCriteria ssc = new SubquerySetCriteria();
ssc.setExpression(new Function("length", new Expression[]
{exampleElement(true, 0)})); //$NON-NLS-1$
- ssc.setCommand(new Insert());
+ ssc.setCommand(new Query());
helpTest(ssc,getSymbolMap());
}
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -36,7 +36,6 @@
import org.teiid.core.util.ArgCheck;
import org.teiid.core.util.Assertion;
import org.teiid.query.function.FunctionLibrary;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.mapping.xml.MappingBaseNode;
import org.teiid.query.mapping.xml.MappingDocument;
@@ -58,7 +57,7 @@
public FakeMetadataFacade(FakeMetadataStore store) {
this.store = store;
- this.functionLibrary = SystemFunctionManager.getSystemFunctionLibrary();
+ this.functionLibrary = FakeMetadataFactory.SFM.getSystemFunctionLibrary();
}
public FakeMetadataFacade(FakeMetadataStore store, FunctionLibrary funcLibrary) {
@@ -204,7 +203,7 @@
FakeMetadataObject group = (FakeMetadataObject) groupID;
QueryNode queryNode = (QueryNode) group.getProperty(FakeMetadataObject.Props.PLAN);
if (queryNode.getQuery() == null) {
- throw new QueryMetadataException("no query");
+ throw new QueryMetadataException("no query");//$NON-NLS-1$
}
return queryNode;
}
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -39,6 +39,7 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.metadata.Table;
+import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.mapping.xml.MappingAttribute;
import org.teiid.query.mapping.xml.MappingDocument;
@@ -51,6 +52,7 @@
@SuppressWarnings("nls")
public class FakeMetadataFactory {
+ public static SystemFunctionManager SFM = new SystemFunctionManager();
private static FakeMetadataFacade CACHED_EXAMPLE1 = example1();
private static FakeMetadataFacade CACHED_AGGREGATES = exampleAggregates();
@@ -430,8 +432,8 @@
FakeMetadataObject vm1g38 = createVirtualGroup("vm1.g38", vm1,
vm1g38n1); //$NON-NLS-1$
// Create virtual groups
- QueryNode vm1g39n1 = new QueryNode("vm1.g39", "SELECT * FROM
pm1.g39"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g39 = createUpdatableVirtualGroup("vm1.g39", vm1,
vm1g39n1, "CREATE VIRTUAL PROCEDURE BEGIN LOOP ON (SELECT pm1.g1.e2 FROM pm1.g1 where
pm1.g1.e2=3) AS mycursor begin update pm1.g1 set pm1.g1.e1 = input.e1 where pm1.g1.e1 =
input.e1; update pm1.g1 set pm1.g1.e2 = input.e2 where pm1.g1.e2 = input.e2; END
END"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm1g39n1 = new QueryNode("vm1.g39", "SELECT * FROM
pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g39 = createUpdatableVirtualGroup("vm1.g39", vm1,
vm1g39n1, "CREATE PROCEDURE BEGIN LOOP ON (SELECT pm1.g1.e2 FROM pm1.g1 where
pm1.g1.e2=3) AS mycursor begin update pm1.g1 set pm1.g1.e1 = input.e1 where pm1.g1.e1 =
input.e1; ROWS_UPDATED = ROWS_UPDATED + ROWCOUNT;\nupdate pm1.g1 set pm1.g1.e2 = input.e2
where pm1.g1.e2 = input.e2; END END"); //$NON-NLS-1$ //$NON-NLS-2$
// Create virtual elements
List vm1g39e = createElements(vm1g39,
@@ -968,7 +970,7 @@
vm1g37.putProperty(FakeMetadataObject.Props.INSERT_PROCEDURE, "CREATE
PROCEDURE BEGIN ROWS_UPDATED = INSERT INTO pm4.g1(e1, e2, e3, e4) values(INPUT.e1,
INPUT.e2, INPUT.e3, INPUT.e4); END"); //$NON-NLS-1$
vm1g37.putProperty(FakeMetadataObject.Props.DELETE_PROCEDURE, "CREATE
PROCEDURE BEGIN ROWS_UPDATED = DELETE FROM pm4.g1 where translate criteria; END");
//$NON-NLS-1$
- QueryNode vspqn37 = new QueryNode("vsp37", "CREATE VIRTUAL
PROCEDURE BEGIN DECLARE integer x; VARIABLES.x=5; INSERT INTO vm1.g1(e2)
values(VARIABLES.x); END"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn37 = new QueryNode("vsp37", "CREATE VIRTUAL
PROCEDURE BEGIN DECLARE integer x; VARIABLES.x=5; INSERT INTO vm1.g1(e2)
values(VARIABLES.x); SELECT ROWCOUNT; END"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vsp37 = createVirtualProcedure("pm1.vsp37", pm1,
Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn37); //$NON-NLS-1$
QueryNode vspqn33 = new QueryNode("vsp33", new
StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$//$NON-NLS-2$
@@ -1003,10 +1005,8 @@
// QueryNode vgvpn7 = new QueryNode("vm1.vgvp7", "SELECT P.e2 as
ve1, P.e1 as ve2 FROM (EXEC pm1.vsp47(vm1.vgvp7.ve1, vm1.vgvp7.ve2)) as P");
//$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vgvp7 = createVirtualGroup("vm1.vgvp7", vm1,
vgvpn7); //$NON-NLS-1$
FakeMetadataObject vgvp7e1 =
FakeMetadataFactory.createElement("vm1.vgvp7.ve1", vgvp7,
DataTypeManager.DefaultDataTypes.INTEGER, 0); //$NON-NLS-1$
- vgvp7e1.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp7e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp7e2 =
FakeMetadataFactory.createElement("vm1.vgvp7.ve2", vgvp7,
DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
- vgvp7e2.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp7e2.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp7e3 =
FakeMetadataFactory.createElement("vm1.vgvp7.ve3", vgvp7,
DataTypeManager.DefaultDataTypes.STRING, 2); //$NON-NLS-1$
FakeMetadataObject vgvp7e4 =
FakeMetadataFactory.createElement("vm1.vgvp7.ve4", vgvp7,
DataTypeManager.DefaultDataTypes.STRING, 3); //$NON-NLS-1$
@@ -1026,60 +1026,48 @@
QueryNode vgvpn1 = new QueryNode("vm1.vgvp1", "SELECT P.e1 as ve3 FROM
(EXEC pm1.vsp26(vm1.vgvp1.ve1, vm1.vgvp1.ve2)) as P"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vgvp1 = createVirtualGroup("vm1.vgvp1", vm1, vgvpn1);
//$NON-NLS-1$
FakeMetadataObject vgvp1e1 =
FakeMetadataFactory.createElement("vm1.vgvp1.ve1", vgvp1,
DataTypeManager.DefaultDataTypes.INTEGER, 0); //$NON-NLS-1$
- vgvp1e1.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp1e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp1e2 =
FakeMetadataFactory.createElement("vm1.vgvp1.ve2", vgvp1,
DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
- vgvp1e2.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp1e2.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp1e3 =
FakeMetadataFactory.createElement("vm1.vgvp1.ve3", vgvp1,
DataTypeManager.DefaultDataTypes.STRING, 2); //$NON-NLS-1$
QueryNode vgvpn2 = new QueryNode("vm1.vgvp2", "SELECT P.e1 as ve3 FROM
(EXEC pm1.vsp26(vm1.vgvp2.ve1, vm1.vgvp2.ve2)) as P where P.e1='a'");
//$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vgvp2 = createVirtualGroup("vm1.vgvp2", vm1, vgvpn2);
//$NON-NLS-1$
FakeMetadataObject vgvp2e1 =
FakeMetadataFactory.createElement("vm1.vgvp2.ve1", vgvp2,
DataTypeManager.DefaultDataTypes.INTEGER, 0); //$NON-NLS-1$
- vgvp2e1.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp2e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp2e2 =
FakeMetadataFactory.createElement("vm1.vgvp2.ve2", vgvp2,
DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
- vgvp2e2.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp2e2.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp2e3 =
FakeMetadataFactory.createElement("vm1.vgvp2.ve3", vgvp2,
DataTypeManager.DefaultDataTypes.STRING, 2); //$NON-NLS-1$
QueryNode vgvpn3 = new QueryNode("vm1.vgvp3", "SELECT P.e1 as ve3 FROM
(EXEC pm1.vsp26(vm1.vgvp3.ve1, vm1.vgvp3.ve2)) as P, pm1.g2 where P.e1=g2.e1");
//$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vgvp3 = createVirtualGroup("vm1.vgvp3", vm1, vgvpn3);
//$NON-NLS-1$
FakeMetadataObject vgvp3e1 =
FakeMetadataFactory.createElement("vm1.vgvp3.ve1", vgvp3,
DataTypeManager.DefaultDataTypes.INTEGER, 0); //$NON-NLS-1$
- vgvp3e1.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp3e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp3e2 =
FakeMetadataFactory.createElement("vm1.vgvp3.ve2", vgvp3,
DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
- vgvp3e2.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp3e2.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp3e3 =
FakeMetadataFactory.createElement("vm1.vgvp3.ve3", vgvp3,
DataTypeManager.DefaultDataTypes.STRING, 2); //$NON-NLS-1$
QueryNode vgvpn4 = new QueryNode("vm1.vgvp4", "SELECT P.e1 as ve3 FROM
(EXEC pm1.vsp26(vm1.vgvp4.ve1, vm1.vgvp4.ve2)) as P, vm1.g1 where P.e1=g1.e1");
//$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vgvp4 = createVirtualGroup("vm1.vgvp4", vm1, vgvpn4);
//$NON-NLS-1$
FakeMetadataObject vgvp4e1 =
FakeMetadataFactory.createElement("vm1.vgvp4.ve1", vgvp4,
DataTypeManager.DefaultDataTypes.INTEGER, 0); //$NON-NLS-1$
- vgvp4e1.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp4e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp4e2 =
FakeMetadataFactory.createElement("vm1.vgvp4.ve2", vgvp4,
DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
- vgvp4e2.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp4e2.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp4e3 =
FakeMetadataFactory.createElement("vm1.vgvp4.ve3", vgvp4,
DataTypeManager.DefaultDataTypes.STRING, 2); //$NON-NLS-1$
QueryNode vgvpn5 = new QueryNode("vm1.vgvp5", "SELECT * FROM vm1.vgvp4
where vm1.vgvp4.ve1=vm1.vgvp5.ve1 and vm1.vgvp4.ve2=vm1.vgvp5.ve2"); //$NON-NLS-1$
//$NON-NLS-2$
FakeMetadataObject vgvp5 = createVirtualGroup("vm1.vgvp5", vm1, vgvpn5);
//$NON-NLS-1$
FakeMetadataObject vgvp5e1 =
FakeMetadataFactory.createElement("vm1.vgvp5.ve1", vgvp5,
DataTypeManager.DefaultDataTypes.INTEGER, 0); //$NON-NLS-1$
- vgvp5e1.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp5e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp5e2 =
FakeMetadataFactory.createElement("vm1.vgvp5.ve2", vgvp5,
DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
- vgvp5e2.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp5e2.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp5e3 =
FakeMetadataFactory.createElement("vm1.vgvp5.ve3", vgvp5,
DataTypeManager.DefaultDataTypes.STRING, 2); //$NON-NLS-1$
QueryNode vgvpn6 = new QueryNode("vm1.vgvp6", "SELECT P.e1 as ve3, P.e2
as ve4 FROM (EXEC pm1.vsp26(vm1.vgvp6.ve1, vm1.vgvp6.ve2)) as P"); //$NON-NLS-1$
//$NON-NLS-2$
FakeMetadataObject vgvp6 = createVirtualGroup("vm1.vgvp6", vm1, vgvpn6);
//$NON-NLS-1$
FakeMetadataObject vgvp6e1 =
FakeMetadataFactory.createElement("vm1.vgvp6.ve1", vgvp6,
DataTypeManager.DefaultDataTypes.INTEGER, 0); //$NON-NLS-1$
- vgvp6e1.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp6e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp6e2 =
FakeMetadataFactory.createElement("vm1.vgvp6.ve2", vgvp6,
DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
- vgvp6e2.putProperty(FakeMetadataObject.Props.IS_PROC_INPUT, Boolean.TRUE);
vgvp6e2.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
FakeMetadataObject vgvp6e3 =
FakeMetadataFactory.createElement("vm1.vgvp6.ve3", vgvp6,
DataTypeManager.DefaultDataTypes.STRING, 2); //$NON-NLS-1$
FakeMetadataObject vgvp6e4 =
FakeMetadataFactory.createElement("vm1.vgvp6.ve4", vgvp6,
DataTypeManager.DefaultDataTypes.INTEGER, 3); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -190,7 +190,6 @@
public static final String NATIVE_TYPE = "nativeType"; // String
//$NON-NLS-1$
public static final String MAX_VALUE = "maxValue"; // String
//$NON-NLS-1$
public static final String MIN_VALUE = "minValue"; // String
//$NON-NLS-1$
- public static final String IS_PROC_INPUT = "isProcedureInputElement";
// String //$NON-NLS-1$
public static final String DISTINCT_VALUES = "distinctValues"; //
Integer //$NON-NLS-1$
public static final String NULL_VALUES = "nullValues"; // Integer
//$NON-NLS-1$
public static final String MODELED_TYPE = "modeledType"; // String
//$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -209,8 +209,8 @@
spTest8a.setResultSet(rs2a);
Schema pm4 = createPhysicalModel("pm4", metadataStore); //$NON-NLS-1$
- ProcedureParameter rs4p1 = createParameter("inkey", ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
- ProcedureParameter rs4p2 = createParameter("ret",
ParameterInfo.RETURN_VALUE, DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
+ ProcedureParameter rs4p1 = createParameter("ret",
ParameterInfo.RETURN_VALUE, DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
+ ProcedureParameter rs4p2 = createParameter("inkey", ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
createStoredProcedure("spTest9", pm4, Arrays.asList(rs4p1, rs4p2),
"spTest9"); //$NON-NLS-1$ //$NON-NLS-2$
Schema pm3 = createPhysicalModel("pm3", metadataStore); //$NON-NLS-1$
@@ -256,11 +256,17 @@
createStoredProcedure("spRetOut", pm4,
Arrays.asList(createParameter("ret", ParameterInfo.RETURN_VALUE,
DataTypeManager.DefaultDataTypes.INTEGER),
createParameter("x", ParameterInfo.OUT,
DataTypeManager.DefaultDataTypes.INTEGER)), "spRetOut"); //$NON-NLS-1$
//$NON-NLS-2$
-
+
+ ColumnSet<Procedure> vsprs7 = createResultSet("TEIIDSP7.vsprs1",
new String[] { "StringKey" }, new String[] {
DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ ProcedureParameter vsp7p1 = createParameter("p1", ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
+ QueryNode vspqn7 = new QueryNode("TEIIDSP7", "CREATE VIRTUAL
PROCEDURE BEGIN declare integer x; x = exec spTest9(p1); select convert(x, string);
END"); //$NON-NLS-1$ //$NON-NLS-2$
+ Procedure vsp7 = createVirtualProcedure("TEIIDSP7", mmspTest1,
Arrays.asList(vsp7p1), vspqn7); //$NON-NLS-1$
+ vsp7.setResultSet(vsprs7);
+
return createTransformationMetadata(metadataStore, "bqt");
}
- private static TransformationMetadata createTransformationMetadata(
+ public static TransformationMetadata createTransformationMetadata(
MetadataStore metadataStore, String vdbName) {
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
VDBMetaData vdbMetaData = new VDBMetaData();
@@ -269,7 +275,7 @@
for (Schema schema : metadataStore.getSchemas().values()) {
vdbMetaData.addModel(FakeMetadataFactory.createModel(schema.getName(),
schema.isPhysical()));
}
- return new TransformationMetadata(vdbMetaData, store, null, null);
+ return new TransformationMetadata(vdbMetaData, store, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
}
/**
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -22,9 +22,7 @@
package org.teiid.query.validator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -41,6 +39,7 @@
import org.junit.Test;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
@@ -59,7 +58,6 @@
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.ProcedureContainer;
import org.teiid.query.sql.lang.SPParameter;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -348,68 +346,75 @@
try {
ValidatorReport report = Validator.validate(command, metadata);
- // Get invalid objects from report
- Collection actualObjs = new ArrayList();
- report.collectInvalidObjects(actualObjs);
-
- // Compare expected and actual objects
- Set expectedStrings = new HashSet(Arrays.asList(expectedStringArray));
- Set actualStrings = new HashSet();
- Iterator objIter = actualObjs.iterator();
- while(objIter.hasNext()) {
- LanguageObject obj = (LanguageObject) objIter.next();
- actualStrings.add(SQLStringVisitor.getSQLString(obj));
- }
-
- if(expectedStrings.size() == 0 && actualStrings.size() > 0) {
- fail("Expected no failures but got some: " +
report.getFailureMessage()); //$NON-NLS-1$
- } else if(actualStrings.size() == 0 && expectedStrings.size() > 0)
{
- fail("Expected some failures but got none for sql = " +
command); //$NON-NLS-1$
- } else {
- assertEquals("Expected and actual sets of strings are not the same:
", expectedStrings, actualStrings); //$NON-NLS-1$
- }
+ examineReport(command, expectedStringArray, report);
return report;
} catch(TeiidException e) {
throw new TeiidRuntimeException(e);
}
}
+ private static void examineReport(Object command,
+ String[] expectedStringArray, ValidatorReport report) {
+ // Get invalid objects from report
+ Collection actualObjs = new ArrayList();
+ report.collectInvalidObjects(actualObjs);
+
+ // Compare expected and actual objects
+ Set<String> expectedStrings = new HashSet(Arrays.asList(expectedStringArray));
+ Set<String> actualStrings = new HashSet<String>();
+ Iterator objIter = actualObjs.iterator();
+ while(objIter.hasNext()) {
+ LanguageObject obj = (LanguageObject) objIter.next();
+ actualStrings.add(SQLStringVisitor.getSQLString(obj));
+ }
+
+ if(expectedStrings.size() == 0 && actualStrings.size() > 0) {
+ fail("Expected no failures but got some: " + report.getFailureMessage());
//$NON-NLS-1$
+ } else if(actualStrings.size() == 0 && expectedStrings.size() > 0) {
+ fail("Expected some failures but got none for sql = " + command);
//$NON-NLS-1$
+ } else {
+ assertEquals("Expected and actual sets of strings are not the same: ",
expectedStrings, actualStrings); //$NON-NLS-1$
+ }
+ }
+
private void helpValidateProcedure(String procedure, String userUpdateStr, String
procedureType) {
QueryMetadataInterface metadata =
FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
try {
-
- Command command = helpResolve(userUpdateStr, metadata);
- //System.out.println(command.printCommandTree());
- ValidatorReport report = Validator.validate(command, metadata);
- //System.out.println("\nReport = \n" + report);
-
- // Get invalid objects from report
- Collection actualObjs = new ArrayList();
- report.collectInvalidObjects(actualObjs);
- if(actualObjs.size() > 0) {
- fail("Expected no failures but got some: " +
report.getFailureMessage()); //$NON-NLS-1$
- }
+ validateProcedure(userUpdateStr, metadata);
} catch(TeiidException e) {
throw new TeiidRuntimeException(e);
}
}
+
+ private void validateProcedure(String userUpdateStr,
+ QueryMetadataInterface metadata) throws QueryResolverException,
+ QueryMetadataException, TeiidComponentException,
+ QueryValidatorException {
+ ProcedureContainer command = (ProcedureContainer)helpResolve(userUpdateStr, metadata);
+
+ Command proc = QueryResolver.expandCommand(command, metadata,
AnalysisRecord.createNonRecordingRecord());
+
+ ValidatorReport report = Validator.validate(proc, metadata);
+ if(report.hasItems()) {
+ throw new QueryValidatorException(report.getFailureMessage());
+ }
+
+ report = Validator.validate(command, metadata);
+ if(report.hasItems()) {
+ throw new QueryValidatorException(report.getFailureMessage());
+ }
+ }
private void helpFailProcedure(String procedure, String userUpdateStr, String
procedureType) {
QueryMetadataInterface metadata =
FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
try {
-
- ProcedureContainer command = (ProcedureContainer)helpResolve(userUpdateStr,
metadata);
- CreateUpdateProcedureCommand cmd =
(CreateUpdateProcedureCommand)QueryResolver.expandCommand(command, metadata, null);
- ValidatorReport report = Validator.validate(cmd, metadata);
-
- // Get invalid objects from report
- Collection actualObjs = new ArrayList();
- report.collectInvalidObjects(actualObjs);
- assertTrue("Expected some failures but got none for procedure = " +
procedure, !actualObjs.isEmpty()); //$NON-NLS-1$
+ validateProcedure(userUpdateStr, metadata);
+ fail("Expected failures for " + procedure);
+ } catch (QueryValidatorException e) {
} catch(TeiidException e) {
throw new RuntimeException(e);
}
@@ -2032,11 +2037,47 @@
@Test public void testValidateScalarSubqueryTooManyColumns() {
helpValidate("SELECT e2, (SELECT e1, e2 FROM pm1.g1 WHERE e2 = '3')
FROM pm1.g2", new String[] {"SELECT e1, e2 FROM pm1.g1 WHERE e2 =
'3'"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ @Test public void testInvalidIntoSubquery() {
+ helpValidate("SELECT e2, (SELECT e1, e2 INTO #x FROM pm1.g1 WHERE e2 =
'3') FROM pm1.g2", new String[] {"SELECT e1, e2 INTO #x FROM pm1.g1
WHERE e2 = '3'"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+ @Test public void testInvalidIntoSubquery1() {
+ helpValidate("SELECT e2 FROM pm1.g2 WHERE EXISTS (SELECT e1, e2 INTO #x FROM
pm1.g1 WHERE e2 = '3')", new String[] {"SELECT e1, e2 INTO #x FROM
pm1.g1 WHERE e2 = '3'"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ @Test public void testInvalidIntoSubquery2() {
+ helpValidate("SELECT * FROM (SELECT e1, e2 INTO #x FROM pm1.g1 WHERE e2 =
'3') x", new String[] {"SELECT e1, e2 INTO #x FROM pm1.g1 WHERE e2 =
'3'"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testInvalidIntoSubquery3() {
+ helpValidate("SELECT e2 FROM pm1.g2 WHERE e2 in (SELECT e1, e2 INTO #x FROM
pm1.g1 WHERE e2 = '3')", new String[] {"SELECT e1, e2 INTO #x FROM
pm1.g1 WHERE e2 = '3'"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ @Test public void testInvalidIntoSubquery4() throws Exception {
+ StringBuffer procedure = new StringBuffer("CREATE VIRTUAL PROCEDURE\n")
//$NON-NLS-1$
+ .append("BEGIN\n") //$NON-NLS-1$
+ .append("loop on (SELECT e1, e2 INTO #x FROM pm1.g1
WHERE e2 = '3') as x\n") //$NON-NLS-1$
+ .append("BEGIN\nSELECT 1;\nEND\nSELECT
1\n;END\n"); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+
+ // Validate
+ ValidatorReport report = helpValidateInModeler("pm1.vsp36",
procedure.toString(), metadata); //$NON-NLS-1$
+ examineReport(procedure, new String[] {"SELECT e1, e2 INTO #x FROM pm1.g1
WHERE e2 = '3'"}, report);
+ }
+
@Test public void testDisallowUpdateOnMultisourceElement() throws Exception {
Set<String> models = new HashSet<String>();
models.add("pm1");
ValidatorReport report = helpValidateInModeler("pm1.vsp36",
"UPDATE PM1.G1 set SOURCE_NAME='blah'", new
MultiSourceMetadataWrapper(FakeMetadataFactory.example1(), models)); //$NON-NLS-1$
assertEquals(report.toString(), 1, report.getItems().size());
}
+
+ @Test public void testDisallowProjectIntoMultiSource() throws Exception {
+ Set<String> models = new HashSet<String>();
+ models.add("pm1");
+ helpValidate("insert into pm1.g1 select * from pm1.g1", new String[]
{"pm1.g1"}, new MultiSourceMetadataWrapper(FakeMetadataFactory.example1(),
models)); //$NON-NLS-1$
+ }
+
}
Modified: trunk/jboss-integration/pom.xml
===================================================================
--- trunk/jboss-integration/pom.xml 2010-10-18 19:03:20 UTC (rev 2658)
+++ trunk/jboss-integration/pom.xml 2010-10-19 15:39:47 UTC (rev 2659)
@@ -68,8 +68,13 @@
<artifactId>jboss-aop-mc-int</artifactId>
<version>2.0.6.GA</version>
<scope>provided</scope>
- </dependency>
-
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx</artifactId>
+ <version>2.0.3.SP1</version>
+ <scope>provided</scope>
+ </dependency>
<!-- these for just running profile service remotely -->
<dependency>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -23,6 +23,7 @@
package org.teiid.adminapi.jboss;
import java.io.InputStream;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -59,7 +60,6 @@
import org.teiid.adminapi.PropertyDefinition;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
-import org.teiid.adminapi.TeiidAdmin;
import org.teiid.adminapi.Transaction;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.VDB;
@@ -75,7 +75,7 @@
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.jboss.IntegrationPlugin;
-public class Admin extends TeiidAdmin {
+public class Admin implements org.teiid.adminapi.Admin, Serializable {
private static final String CONNECTOR_PREFIX = "connector-"; //$NON-NLS-1$
private static final ProfileKey DEFAULT_PROFILE_KEY = new
ProfileKey(ProfileKey.DEFAULT);
private static final long serialVersionUID = 7081309086056911304L;
@@ -293,10 +293,10 @@
}
@Override
- public void cancelRequest(String sessionId, long requestId) throws AdminException{
+ public void cancelRequest(String sessionId, long executionId) throws AdminException{
try {
ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- ManagedUtil.executeOperation(mc, "cancelRequest",
SimpleValueSupport.wrap(sessionId), SimpleValueSupport.wrap(requestId));//$NON-NLS-1$
+ ManagedUtil.executeOperation(mc, "cancelRequest",
SimpleValueSupport.wrap(sessionId), SimpleValueSupport.wrap(executionId));//$NON-NLS-1$
} catch (Exception e) {
throw new AdminComponentException(e.getMessage(), e);
}
@@ -355,10 +355,10 @@
}
@Override
- public WorkerPoolStatistics getWorkManagerStats(String identifier) throws AdminException
{
+ public WorkerPoolStatistics getWorkerPoolStats() throws AdminException {
try {
ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- MetaValue value = ManagedUtil.executeOperation(mc,
"getWorkManagerStatistics", SimpleValueSupport.wrap(identifier));//$NON-NLS-1$
+ MetaValue value = ManagedUtil.executeOperation(mc,
"getWorkerPoolStatistics");//$NON-NLS-1$
return (WorkerPoolStatistics)MetaValueFactory.getInstance().unwrap(value,
WorkerPoolStatisticsMetadata.class);
} catch (Exception e) {
throw new AdminComponentException(e.getMessage(), e);
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java (from
rev 2654,
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java
(rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.teiid.jboss;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Sep 26, 2007
+ * @version $Revision$
+ */
+class ResourceActions
+{
+ static ClassLoader getContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ static URL findResource(final URLClassLoader cl, final String name)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>()
+ {
+ public URL run()
+ {
+ return cl.findResource(name);
+ }
+ });
+ }
+
+ static InputStream openStream(final URL url) throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new
PrivilegedExceptionAction<InputStream>()
+ {
+ public InputStream run() throws IOException
+ {
+ return url.openStream();
+ }
+ });
+ }
+}
\ No newline at end of file
Copied:
trunk/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java
(from rev 2654,
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java)
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java
(rev 0)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.teiid.jboss;
+
+
+import java.io.IOException;
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+import javax.resource.spi.security.PasswordCredential;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginException;
+
+import org.jboss.logging.Logger;
+import org.jboss.resource.security.AbstractPasswordCredentialLoginModule;
+import org.jboss.security.Base64Utils;
+import org.jboss.security.SimplePrincipal;
+
+/**
+ * A credential mapping login module that associates currently logged in
+ * principle's role name to password mapping from a simple properties file. It
+ * is similar to name=password, only here this uses role=password. If user has
+ * more than single role that has passwords, then first role with non null
+ * password is chosen. This login module must be defined with Managed Connection
+ * Factory.
+ *
+ * Please note, you can not use this as the primary login module, this should be strictly
used
+ * to get a role based password, that can be used as credential mapping at data source
level. If you
+ * are working with a object as trusted token, then do not use the encryption, and
provide base64 encoded
+ * string of the object as the password and decrypt it in your custom connection factory.
+ *
+ *<pre>{@code
+ * <application-policy name = "teiid-security">
+ * <authentication>
+ * <login-module
code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required">
+ * <module-option
name="usersProperties">props/teiid-security-users.properties</module-option>
+ * <module-option
name="rolesProperties">props/teiid-security-roles.properties</module-option>
+ * <module-option
name="password-stacking">useFirstPass</module-option>
+ * </login-module>
+ * <login-module code = "org.teiid.jboss.MapIdentityLoginModule"
flag = "required">
+ * <module-option
name="password-stacking">useFirstPass</module-option>
+ * <module-option name =
"credentialMap">config/props/rolepasswords.properties</module-option>
+ * <module-option name =
"encryptedPasswords">true</module-option>
+ *
+ * <!-- below properties are only required when passwords are encrypted
-->
+ * <module-option name =
"pbealgo">PBEWithMD5AndDES</module-option>
+ * <module-option name =
"pbepass">testPBEIdentityLoginModule</module-option>
+ * <module-option name =
"salt">abcdefgh</module-option>
+ * <module-option name =
"iterationCount">19</module-option>
+ * <module-option name =
"managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+ * </login-module>
+ * </authentication>
+ * </application-policy>
+ * }</pre>
+ *
+ * @see org.jboss.security.SimpleGroup
+ * @see org.jboss.security.SimplePrincipal
+ *
+ */
+public class RoleBasedCredentialMapIdentityLoginModule extends
AbstractPasswordCredentialLoginModule {
+ private Properties credentialMap;
+ private String mappedRole = "mappedRole"; //$NON-NLS-1$
+ private static final Logger log =
Logger.getLogger(RoleBasedCredentialMapIdentityLoginModule.class);
+
+ /** The Blowfish key material */
+ private char[] pbepass = "jaas is the way".toCharArray(); //$NON-NLS-1$
+ private String pbealgo = "PBEwithMD5andDES"; //$NON-NLS-1$
+ private byte[] salt = {1, 7, 2, 9, 3, 11, 4, 13};
+ private int iterationCount = 37;
+ private boolean encryptionInUse = false;
+
+ public RoleBasedCredentialMapIdentityLoginModule(){
+ }
+
+ public void initialize(Subject subject, CallbackHandler handler, Map sharedState, Map
options) {
+ super.initialize(subject, handler, sharedState, options);
+
+ String file = (String) options.get("credentialMap"); //$NON-NLS-1$
+ if (file == null) {
+ throw new IllegalArgumentException("Must supply credentialMap file name!");
//$NON-NLS-1$
+ }
+
+ try {
+ credentialMap = Util.loadProperties(file, log);
+ } catch (IOException e) {
+ log.error("failed to load credentail map"); //$NON-NLS-1$
+ }
+
+ String tmp = (String) options.get("encryptedPasswords"); //$NON-NLS-1$
+ if (tmp != null && tmp.equalsIgnoreCase("true")) { //$NON-NLS-1$
+ this.encryptionInUse = true;
+
+ // Look for the cipher password and algo parameters
+ tmp = (String) options.get("pbepass"); //$NON-NLS-1$
+ if (tmp != null) {
+ try {
+ this.pbepass = org.jboss.security.Util.loadPassword(tmp);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ tmp = (String) options.get("pbealgo"); //$NON-NLS-1$
+ if (tmp != null) {
+ this.pbealgo = tmp;
+ }
+ tmp = (String) options.get("salt"); //$NON-NLS-1$
+ if (tmp != null) {
+ this.salt = tmp.substring(0, 8).getBytes();
+ }
+ tmp = (String) options.get("iterationCount"); //$NON-NLS-1$
+ if (tmp != null) {
+ this.iterationCount = Integer.parseInt(tmp);
+ }
+ }
+ }
+
+ public boolean login() throws LoginException {
+
+ if (credentialMap == null) {
+ throw new LoginException( "Credential Map properties file failed to load");
//$NON-NLS-1$
+ }
+
+ return super.login();
+ }
+
+ public boolean commit() throws LoginException {
+
+ String userRole = null;
+ String rolePassword = null;
+
+ Set<String> roles = getRoles();
+ for (String role:roles) {
+ String password = this.credentialMap.getProperty(role);
+ if (password != null) {
+ userRole = role;
+ rolePassword = password;
+ }
+ }
+
+ try {
+ if (userRole != null && rolePassword != null) {
+ this.mappedRole = userRole;
+ PasswordCredential cred = new PasswordCredential(userRole, decode(rolePassword));
+ cred.setManagedConnectionFactory(getMcf());
+ SecurityActions.addCredentials(this.subject, cred);
+ }
+ return super.commit();
+ } catch (Exception e) {
+ throw new LoginException("Failed to decode password: "+e.getMessage());
//$NON-NLS-1$
+ }
+ }
+
+ protected Principal getIdentity() {
+ Principal principal = new SimplePrincipal(this.mappedRole);
+ return principal;
+ }
+
+ /**
+ * This method simply returns an empty array of Groups which means that
+ * no role based permissions are assigned.
+ */
+ protected Group[] getRoleSets() throws LoginException {
+ return new Group[] {};
+ }
+
+ private Set<String> getRoles() {
+ Set<String> roles = new HashSet<String>();
+
+ Set<Principal> principals = this.subject.getPrincipals();
+ for(Principal p: principals) {
+ if ((p instanceof Group) && p.getName().equals("Roles")){
//$NON-NLS-1$
+ Group g = (Group)p;
+ Enumeration<? extends Principal> rolesPrinciples = g.members();
+ while(rolesPrinciples.hasMoreElements()) {
+ roles.add(rolesPrinciples.nextElement().getName());
+ }
+ }
+ }
+ return roles;
+ }
+
+ private char[] decode(String secret) throws Exception {
+ if (!this.encryptionInUse) {
+ return secret.toCharArray();
+ }
+ // Create the PBE secret key
+ PBEParameterSpec cipherSpec = new PBEParameterSpec(this.salt, this.iterationCount);
+ PBEKeySpec keySpec = new PBEKeySpec(this.pbepass);
+ SecretKeyFactory factory = SecretKeyFactory.getInstance(this.pbealgo);
+ SecretKey cipherKey = factory.generateSecret(keySpec);
+ // Decode the secret
+ byte[] encoding = Base64Utils.fromb64(secret);
+ Cipher cipher = Cipher.getInstance(this.pbealgo);
+ cipher.init(Cipher.DECRYPT_MODE, cipherKey, cipherSpec);
+ byte[] decode = cipher.doFinal(encoding);
+ return new String(decode).toCharArray();
+ }
+}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -25,6 +25,7 @@
import java.security.Principal;
import java.security.PrivilegedAction;
+import javax.resource.spi.security.PasswordCredential;
import javax.security.auth.Subject;
import org.jboss.security.SecurityContext;
@@ -82,4 +83,26 @@
}
});
}
+
+ static class AddCredentialsAction implements PrivilegedAction
+ {
+ Subject subject;
+ PasswordCredential cred;
+ AddCredentialsAction(Subject subject, PasswordCredential cred)
+ {
+ this.subject = subject;
+ this.cred = cred;
+ }
+ public Object run()
+ {
+ subject.getPrivateCredentials().add(cred);
+ return null;
+ }
+ }
+
+ static void addCredentials(Subject subject, PasswordCredential cred)
+ {
+ AddCredentialsAction action = new AddCredentialsAction(subject, cred);
+ AccessController.doPrivileged(action);
+ }
}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/Util.java (from rev 2654,
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/Util.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/Util.java
(rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/Util.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.teiid.jboss;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.PrivilegedActionException;
+import java.util.Properties;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Common login module utility methods
+ *
+ * @author Scott.Stark(a)jboss.org
+ * @version $Revision: 68749 $
+ */
+public class Util {
+ /**
+ * Utility method which loads the given properties file and returns a
+ * Properties object containing the key,value pairs in that file. The
+ * properties files should be in the class path as this method looks to the
+ * thread context class loader (TCL) to locate the resource. If the TCL is a
+ * URLClassLoader the findResource(String) method is first tried. If this
+ * fails or the TCL is not a URLClassLoader getResource(String) is tried. If
+ * not, an absolute path is tried.
+ *
+ * @param propertiesName
+ * - the name of the properties file resource
+ * @param log
+ * - the logger used for trace level messages
+ * @return the loaded properties file if found
+ * @exception java.io.IOException
+ * thrown if the properties file cannot be found or loaded
+ */
+ static Properties loadProperties(String propertiesName, Logger log) throws IOException
{
+ ClassLoader loader = ResourceActions.getContextClassLoader();
+ URL url = null;
+ // First check for local visibility via a URLClassLoader.findResource
+ if (loader instanceof URLClassLoader) {
+ URLClassLoader ucl = (URLClassLoader) loader;
+ url = ResourceActions.findResource(ucl, propertiesName);
+ log.trace("findResource: " + url); //$NON-NLS-1$
+ }
+ if (url == null)
+ url = loader.getResource(propertiesName);
+ if (url == null) {
+ url = new URL(propertiesName);
+ }
+
+ log.trace("Properties file=" + url); //$NON-NLS-1$
+
+ Properties bundle = new Properties();
+ InputStream is = null;
+ try {
+ is = ResourceActions.openStream(url);
+ } catch (PrivilegedActionException e) {
+ throw new IOException(e.getLocalizedMessage());
+ }
+ if (is != null) {
+ bundle.load(is);
+ is.close();
+ } else {
+ throw new IOException("Properties file " + propertiesName + " not
available");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ log.debug("Loaded properties, users=" + bundle.keySet());//$NON-NLS-1$
+ return bundle;
+ }
+}
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -25,15 +25,25 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.sql.SQLXML;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.resource.spi.XATerminator;
import javax.resource.spi.work.WorkManager;
+import javax.security.auth.login.LoginException;
import javax.transaction.TransactionManager;
import org.jboss.managed.api.ManagedOperation.Impact;
@@ -49,6 +59,7 @@
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.Admin.Cache;
import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.DQPManagement;
@@ -58,8 +69,12 @@
import org.teiid.adminapi.jboss.AdminProvider;
import org.teiid.cache.CacheFactory;
import org.teiid.client.DQP;
+import org.teiid.client.RequestMessage;
+import org.teiid.client.ResultsMessage;
import org.teiid.client.security.ILogon;
+import org.teiid.client.security.InvalidSessionException;
import org.teiid.client.util.ExceptionUtil;
+import org.teiid.client.util.ResultsFuture;
import org.teiid.core.ComponentNotFoundException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
@@ -78,6 +93,7 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.net.TeiidURL;
import org.teiid.security.SecurityHelper;
import org.teiid.transport.ClientServiceRegistry;
import org.teiid.transport.ClientServiceRegistryImpl;
@@ -90,7 +106,7 @@
@ManagementObject(name="RuntimeEngineDeployer", isRuntime=true,
componentType=@ManagementComponent(type="teiid",subtype="dqp"),
properties=ManagementProperties.EXPLICIT)
public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement,
Serializable , ClientServiceRegistry {
private static final long serialVersionUID = -4676205340262775388L;
-
+
private transient SocketConfiguration jdbcSocketConfiguration;
private transient SocketConfiguration adminSocketConfiguration;
private transient SocketConfiguration odbcSocketConfiguration;
@@ -376,16 +392,9 @@
@Override
- @ManagementOperation(description="Get Runtime workmanager statistics",
impact=Impact.ReadOnly,params={@ManagementParameter(name="identifier",description="Use
\"runtime\" for engine, or connector name for connector")})
- public WorkerPoolStatisticsMetadata getWorkManagerStatistics(String identifier) {
- if ("runtime".equalsIgnoreCase(identifier)) { //$NON-NLS-1$
- return this.dqpCore.getWorkManagerStatistics();
- }
- /*ConnectorManager cm =
this.dqpCore.getConnectorManagerRepository().getConnectorManager(identifier);
- if (cm != null) {
- return cm.getWorkManagerStatistics();
- }*/
- return null;
+ @ManagementOperation(description="Get thread statistics worker pool",
impact=Impact.ReadOnly,params={@ManagementParameter(name="identifier",description="Get
thread statistics worker pool")})
+ public WorkerPoolStatisticsMetadata getWorkerPoolStatistics(){
+ return this.dqpCore.getWorkerPoolStatistics();
}
@Override
@@ -395,10 +404,10 @@
}
@Override
- @ManagementOperation(description="Cancel a
Request",params={@ManagementParameter(name="sessionId",description="The
session Identifier"),
@ManagementParameter(name="requestId",description="The request
Identifier")})
- public boolean cancelRequest(String sessionId, long requestId) throws AdminException
{
+ @ManagementOperation(description="Cancel a
Request",params={@ManagementParameter(name="sessionId",description="The
session Identifier"),
@ManagementParameter(name="executionId",description="The Execution
Identifier")})
+ public boolean cancelRequest(String sessionId, long executionId) throws
AdminException {
try {
- return this.dqpCore.cancelRequest(sessionId, requestId);
+ return this.dqpCore.cancelRequest(sessionId, executionId);
} catch (TeiidComponentException e) {
throw new AdminComponentException(e);
}
@@ -464,4 +473,117 @@
public void setCacheFactory(CacheFactory factory) {
this.dqpCore.setCacheFactory(factory);
}
+
+ @Override
+ @ManagementOperation(description="Execute a sql query",
params={@ManagementParameter(name="vdbName"),@ManagementParameter(name="vdbVersion"),
@ManagementParameter(name="command"),
@ManagementParameter(name="timoutInMilli")})
+ public List<List> executeQuery(final String vdbName, final int version, final
String command, final long timoutInMilli) throws AdminException {
+ Properties properties = new Properties();
+ properties.setProperty(TeiidURL.JDBC.VDB_NAME, vdbName);
+ properties.setProperty(TeiidURL.JDBC.VDB_VERSION, String.valueOf(version));
+
+ String user = "JOPR ADMIN"; //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("admin_executing", user, command));
//$NON-NLS-1$
+
+ SessionMetadata session = null;
+ try {
+ session = this.sessionService.createSession(user, null, "JOPR", properties,
false, false); //$NON-NLS-1$
+ } catch (SessionServiceException e1) {
+ throw new AdminProcessingException(e1);
+ } catch (LoginException e1) {
+ throw new AdminProcessingException(e1);
+ }
+
+ final long requestID = 0L;
+
+ DQPWorkContext context = new DQPWorkContext();
+ context.setSession(session);
+
+ try {
+ return context.runInContext(new Callable<List<List>>() {
+ @Override
+ public List<List> call() throws Exception {
+ ArrayList<List> results = new ArrayList<List>();
+
+ long start = System.currentTimeMillis();
+ RequestMessage request = new RequestMessage(command);
+ request.setExecutionId(0L);
+ request.setRowLimit(getMaxRowsFetchSize()); // this would limit the number of rows
that are returned.
+ Future<ResultsMessage> message = dqpCore.executeRequest(requestID, request);
+ ResultsMessage rm = message.get(timoutInMilli, TimeUnit.MILLISECONDS);
+
+ if (rm.getException() != null) {
+ throw new AdminProcessingException(rm.getException());
+ }
+
+ if (rm.isUpdateResult()) {
+ results.addAll(new ArrayList(Arrays.asList("update count")));
//$NON-NLS-1$
+ results.addAll(Arrays.asList(rm.getResults()));
+ }
+ else {
+ results.addAll(new ArrayList(Arrays.asList(rm.getColumnNames())));
+ results.addAll(Arrays.asList(fixResults(rm.getResults())));
+
+ while (rm.getFinalRow() == -1 || rm.getLastRow() < rm.getFinalRow()) {
+ long elapsed = System.currentTimeMillis() - start;
+ message = dqpCore.processCursorRequest(requestID, rm.getLastRow()+1, 1024);
+ rm = message.get(timoutInMilli-elapsed, TimeUnit.MILLISECONDS);
+ results.addAll(Arrays.asList(fixResults(rm.getResults())));
+ }
+ }
+
+ long elapsed = System.currentTimeMillis() - start;
+ ResultsFuture<?> response = dqpCore.closeRequest(requestID);
+ response.get(timoutInMilli-elapsed, TimeUnit.MILLISECONDS);
+ return results;
+ }
+ });
+ } catch (Throwable t) {
+ throw new AdminProcessingException(t);
+ } finally {
+ try {
+ sessionService.closeSession(session.getSessionId());
+ } catch (InvalidSessionException e) { //ignore
+ }
+ }
+ }
+
+ /**
+ * Managed Object framework has bug that does not currently allow
+ * sending a NULL in the Collection Value, so sending literal string "null".
+ * If you send them as Array Value, the MO is packaged as composite object and would
like
+ * all the elements in array to be same type which is not the case with results.
+ */
+ List[] fixResults(List[] rows) throws SQLException {
+ List[] newResults = new List[rows.length];
+
+ for(int i = 0; i < rows.length; i++) {
+ List row = rows[i];
+ ArrayList newRow = new ArrayList();
+ for (Object col:row) {
+ if (col == null) {
+ newRow.add("null"); //$NON-NLS-1$
+ }
+ else {
+ if (col instanceof Number || col instanceof String || col instanceof Character) {
+ newRow.add(col);
+ }
+ else if (col instanceof Blob) {
+ newRow.add("blob"); //$NON-NLS-1$
+ }
+ else if (col instanceof Clob) {
+ newRow.add("clob"); //$NON-NLS-1$
+ }
+ else if (col instanceof SQLXML) {
+ SQLXML xml = (SQLXML)col;
+ newRow.add(xml.getString());
+ }
+ else {
+ newRow.add(col.toString());
+ }
+ }
+ }
+ newResults[i] = newRow;
+ }
+ return newResults;
+ }
}
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-10-19
15:39:47 UTC (rev 2659)
@@ -45,3 +45,4 @@
jndi_failed=JNDI lookup failed.
distribute_failed=Deploy of the archive failed {0}
template_not_found=Template not found for {0}
+admin_executing=JOPR admin {0} is executing command {1}
Modified: trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -103,7 +103,8 @@
this.metadata = new BasicQueryMetadataWrapper(this.metadata) {
@Override
public FunctionLibrary getFunctionLibrary() {
- return new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new
FunctionTree(new UDFSource(methods)));
+ SystemFunctionManager sfm = new SystemFunctionManager();
+ return new FunctionLibrary(sfm.getSystemFunctions(), new FunctionTree(new
UDFSource(methods)));
}
};
}
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
---
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -39,6 +39,7 @@
import org.teiid.core.util.LRUCache;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.metadata.MetadataStore;
+import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.metadata.FunctionMetadataReader;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.metadata.CompositeMetadataStore;
@@ -83,8 +84,8 @@
if (udfFile != null) {
methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
}
-
- vdbmetadata = new TransformationMetadata(null, new
CompositeMetadataStore(Arrays.asList(getSystem(),
imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(),
methods);
+ SystemFunctionManager sfm = new SystemFunctionManager();
+ vdbmetadata = new TransformationMetadata(null, new
CompositeMetadataStore(Arrays.asList(getSystem(),
imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(),
methods, sfm.getSystemFunctions());
VDB_CACHE.put(vdbURL, vdbmetadata);
return vdbmetadata;
} catch (URISyntaxException e) {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -31,6 +31,7 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.metadata.MetadataStore;
+import org.teiid.query.function.FunctionTree;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -49,19 +50,21 @@
private LinkedHashMap<VDBKey, CompositeVDB> children;
private MetadataStore[] additionalStores;
private ConnectorManagerRepository cmr;
+ private FunctionTree systemFunctions;
// used as cached item to avoid rebuilding
private VDBMetaData mergedVDB;
- public CompositeVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String,
Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr,
MetadataStore... additionalStores) {
+ public CompositeVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String,
Resource> visibilityMap, UDFMetaData udf, FunctionTree systemFunctions,
ConnectorManagerRepository cmr, MetadataStore... additionalStores) {
this.vdb = vdb;
this.stores = stores;
this.visibilityMap = visibilityMap;
this.udf = udf;
+ this.systemFunctions = systemFunctions;
this.cmr = cmr;
this.additionalStores = additionalStores;
this.vdb.addAttchment(ConnectorManagerRepository.class, cmr);
- update(this.vdb);
+ update(this.vdb, this.systemFunctions);
}
public void addChild(CompositeVDB child) {
@@ -80,15 +83,15 @@
this.mergedVDB = null;
}
- void update(VDBMetaData vdbMetadata) {
- TransformationMetadata metadata = buildTransformationMetaData(vdbMetadata,
getVisibilityMap(), getMetadataStores(), getUDF());
+ void update(VDBMetaData vdbMetadata, FunctionTree systemFunctions) {
+ TransformationMetadata metadata = buildTransformationMetaData(vdbMetadata,
getVisibilityMap(), getMetadataStores(), getUDF(), systemFunctions);
vdbMetadata.addAttchment(QueryMetadataInterface.class, metadata);
vdbMetadata.addAttchment(TransformationMetadata.class, metadata);
TempTableStore globalTables = new TempTableStore("SYSTEM"); //$NON-NLS-1$
vdbMetadata.addAttchment(TempTableStore.class, globalTables);
}
- private TransformationMetadata buildTransformationMetaData(VDBMetaData vdb,
LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores,
UDFMetaData udf) {
+ private TransformationMetadata buildTransformationMetaData(VDBMetaData vdb,
LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores,
UDFMetaData udf, FunctionTree systemFunctions) {
Collection <FunctionMethod> methods = null;
if (udf != null) {
methods = udf.getFunctions();
@@ -99,7 +102,7 @@
compositeStore.addMetadataStore(s);
}
- TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore,
visibilityMap, methods);
+ TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore,
visibilityMap, methods, systemFunctions);
return metadata;
}
@@ -110,7 +113,7 @@
}
if (this.mergedVDB == null) {
this.mergedVDB = buildVDB();
- update(mergedVDB);
+ update(mergedVDB, this.systemFunctions);
}
return this.mergedVDB;
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -43,6 +43,7 @@
import org.teiid.logging.LogManager;
import org.teiid.metadata.Datatype;
import org.teiid.metadata.MetadataStore;
+import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.metadata.TransformationMetadata.Resource;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.translator.TranslatorException;
@@ -60,6 +61,7 @@
private MetadataStore odbcStore;
private boolean odbcEnabled = false;
private List<VDBLifeCycleListener> listeners = new
ArrayList<VDBLifeCycleListener>();
+ private SystemFunctionManager systemFunctionManager;
public void addVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String,
Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr) throws
DeploymentException {
if (getVDB(vdb.getName(), vdb.getVersion()) != null) {
@@ -76,10 +78,10 @@
}
if (this.odbcStore == null) {
- this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf, cmr,
this.systemStore));
+ this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf,
this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore));
}
else {
- this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf, cmr,
this.systemStore, odbcStore));
+ this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf,
this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore, odbcStore));
}
notifyAdd(vdb.getName(), vdb.getVersion());
}
@@ -208,7 +210,7 @@
void updateVDB(String name, int version) {
CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
if (v!= null) {
- v.update(v.getVDB());
+ v.update(v.getVDB(), systemFunctionManager.getSystemFunctions());
}
}
@@ -231,4 +233,8 @@
l.removed(name, version);
}
}
+
+ public void setSystemFunctionManager(SystemFunctionManager mgr) {
+ this.systemFunctionManager = mgr;
+ }
}
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -136,7 +136,7 @@
}
@Override
- public SessionMetadata createSession(String userName, Credentials credentials, String
applicationName, Properties properties, boolean adminConnection)
+ public SessionMetadata createSession(String userName, Credentials credentials, String
applicationName, Properties properties, boolean adminConnection, boolean authenticate)
throws LoginException, SessionServiceException {
ArgCheck.isNotNull(applicationName);
ArgCheck.isNotNull(properties);
@@ -161,7 +161,7 @@
throw new
SessionServiceException(RuntimePlugin.Util.getString("SessionServiceImpl.reached_max_sessions",
new Object[] {new Long(sessionMaxLimit)})); //$NON-NLS-1$
}
- if (!domains.isEmpty()) {
+ if (!domains.isEmpty() && authenticate) {
// Authenticate user...
// if not authenticated, this method throws exception
boolean onlyAllowPassthrough =
Boolean.valueOf(properties.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION,
"false")); //$NON-NLS-1$
Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-10-18 19:03:20 UTC
(rev 2658)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-10-19 15:39:47 UTC
(rev 2659)
@@ -72,7 +72,7 @@
boolean adminConnection =
Boolean.parseBoolean(connProps.getProperty(TeiidURL.CONNECTION.ADMIN));
try {
- SessionMetadata sessionInfo = service.createSession(user,credential, applicationName,
connProps, adminConnection);
+ SessionMetadata sessionInfo = service.createSession(user,credential, applicationName,
connProps, adminConnection, true);
updateDQPContext(sessionInfo);
if (DQPWorkContext.getWorkContext().getClientAddress() == null) {
sessionInfo.setEmbedded(true);
Modified: trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -51,7 +51,7 @@
}
- SessionMetadata info = ssi.createSession("steve", null, "foo", new
Properties(), false); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionMetadata info = ssi.createSession("steve", null, "foo", new
Properties(), false, true); //$NON-NLS-1$ //$NON-NLS-2$
if (securityEnabled) {
Mockito.verify(impl).authenticateUser("steve", null, "foo",
domains, false);
}
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-10-18 19:03:20
UTC (rev 2658)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-10-19 15:39:47
UTC (rev 2659)
@@ -53,7 +53,7 @@
session.setSessionId(String.valueOf(1));
session.setSessionToken(new SessionToken(1, userName));
- Mockito.stub(ssi.createSession(userName, null, applicationName,p,
false)).toReturn(session);
+ Mockito.stub(ssi.createSession(userName, null, applicationName,p, false,
true)).toReturn(session);
LogonImpl impl = new LogonImpl(ssi, "fakeCluster"); //$NON-NLS-1$
Modified:
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -24,8 +24,9 @@
import java.util.List;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
import org.teiid.cdk.api.TranslationUtility;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.language.Call;
@@ -41,18 +42,10 @@
/**
*/
-public class TestMetadataObject extends TestCase {
+public class TestMetadataObject {
private static TranslationUtility CONNECTOR_METADATA_UTILITY =
createTranslationUtility(getTestVDBName());
- /**
- * Constructor for TestMetadataID.
- * @param name
- */
- public TestMetadataObject(String name) {
- super(name);
- }
-
private static String getTestVDBName() {
return UnitTestUtil.getTestDataPath() + "/ConnectorMetadata.vdb";
//$NON-NLS-1$
}
@@ -83,11 +76,11 @@
}
}
- public void testGroupID() throws Exception {
+ @Test public void testGroupID() throws Exception {
helpTestGroupID("ConnectorMetadata.TestTable", "TestTable",
7, CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testGroupID_longName() throws Exception {
+ @Test public void testGroupID_longName() throws Exception {
helpTestGroupID("ConnectorMetadata.TestCatalog.TestSchema.TestTable2",
"TestCatalog.TestSchema.TestTable2", 1,
CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
}
@@ -108,11 +101,11 @@
assertEquals(groupName, elementID.getParent().getFullName());
}
- public void testElementID() throws Exception {
+ @Test public void testElementID() throws Exception {
helpTestElementID("ConnectorMetadata.TestTable",
"TestNameInSource", CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testElementID_longName() throws Exception {
+ @Test public void testElementID_longName() throws Exception {
helpTestElementID("ConnectorMetadata.TestCatalog.TestSchema.TestTable2",
"TestCol", CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
}
@@ -155,17 +148,17 @@
}
}
- public void testProcedureID() throws Exception {
+ @Test public void testProcedureID() throws Exception {
String[] paramNames = new String[] { "InParam", "OutParam",
"InOutParam", "ReturnParam" }; //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$//$NON-NLS-4$
helpTestProcedureID("ConnectorMetadata.TestProc1",
"TestProc1", 2, paramNames, null, CONNECTOR_METADATA_UTILITY); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testProcedureID_resultSet() throws Exception {
+ @Test public void testProcedureID_resultSet() throws Exception {
String[] paramNames = new String[] { "Param1"}; //$NON-NLS-1$
helpTestProcedureID("ConnectorMetadata.TestProc2",
"TestProc2", 1, paramNames, "RSParam", CONNECTOR_METADATA_UTILITY);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testProcedureID_longName() throws Exception {
+ @Test public void testProcedureID_longName() throws Exception {
helpTestProcedureID("ConnectorMetadata.TestCatalog.TestSchema.TestProc",
"TestCatalog.TestSchema.TestProc", 0, new String[0], null,
CONNECTOR_METADATA_UTILITY); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -150,7 +150,7 @@
* Test for void visit(IExistsCriteria)
*/
@Test public void testVisitIExistsCriteria() throws Exception {
- String expected = "EXISTS (SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM
g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2,
g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4
DESC)"; //$NON-NLS-1$
+ String expected = "EXISTS (SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM
g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2,
g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3,
g1.e4 DESC)"; //$NON-NLS-1$
assertEquals(expected, getString(TestExistsCriteriaImpl.example()));
}
@@ -278,7 +278,7 @@
* Test for void visit(IOrderBy)
*/
@Test public void testVisitIOrderBy() throws Exception {
- String expected = "ORDER BY e1, e2 DESC, e3, e4 DESC"; //$NON-NLS-1$
+ String expected = "ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC";
//$NON-NLS-1$
assertEquals(expected, getString(TestOrderByImpl.example()));
}
@@ -294,7 +294,7 @@
* Test for void visit(IQuery)
*/
@Test public void testVisitIQuery() throws Exception {
- String expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS
myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4
HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC";
//$NON-NLS-1$
+ String expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS
myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4
HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC";
//$NON-NLS-1$
assertEquals(expected, getString(TestQueryImpl.example(true)));
}
@@ -302,7 +302,7 @@
* Test for void visit(IScalarSubquery)
*/
@Test public void testVisitIScalarSubquery() throws Exception {
- String expected = "(SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2
AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3,
g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC)";
//$NON-NLS-1$
+ String expected = "(SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2
AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3,
g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4
DESC)"; //$NON-NLS-1$
assertEquals(expected, getString(TestScalarSubqueryImpl.example()));
}
@@ -318,9 +318,9 @@
* Test for void visit(ISelect)
*/
@Test public void testVisitISelect() throws Exception {
- String expected = "SELECT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias,
g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100
>= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC"; //$NON-NLS-1$
+ String expected = "SELECT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias,
g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100
>= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC";
//$NON-NLS-1$
assertEquals(expected, getString(TestQueryImpl.example(false)));
- expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS
myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4
HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC";
//$NON-NLS-1$
+ expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS
myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4
HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC";
//$NON-NLS-1$
assertEquals(expected, getString(TestQueryImpl.example(true)));
}
@@ -339,7 +339,7 @@
* Test for void visit(ISubqueryCompareCriteria)
*/
@Test public void testVisitISubqueryCompareCriteria() throws Exception {
- String expected = "g1.e1 > SOME (SELECT DISTINCT g1.e1, g1.e2, g1.e3,
g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1,
g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4
DESC)"; //$NON-NLS-1$
+ String expected = "g1.e1 > SOME (SELECT DISTINCT g1.e1, g1.e2, g1.e3,
g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1,
g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC,
g1.e3, g1.e4 DESC)"; //$NON-NLS-1$
assertEquals(expected, getString(TestSubqueryCompareCriteriaImpl.example()));
}
@@ -347,12 +347,12 @@
* Test for void visit(ISubqueryInCriteria)
*/
@Test public void testVisitISubqueryInCriteria() throws Exception {
- String expected = "g1.e1 NOT IN (SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4
FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2,
g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4
DESC)"; //$NON-NLS-1$
+ String expected = "g1.e1 NOT IN (SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4
FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2,
g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3,
g1.e4 DESC)"; //$NON-NLS-1$
assertEquals(expected, getString(TestSubqueryInCriteriaImpl.example()));
}
@Test public void testVisitIUnion1() throws Exception {
- String expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS
myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4
HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC UNION SELECT
DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND
500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600
ORDER BY e1, e2 DESC, e3, e4 DESC ORDER BY e1, e2 DESC, e3, e4 DESC";//$NON-NLS-1$
+ String expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS
myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4
HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC UNION
SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >=
200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 <
600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC ORDER BY e1, e2 DESC, e3, e4
DESC";//$NON-NLS-1$
assertEquals(expected, getString(TestSetQueryImpl.example()));
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-10-18
19:03:20 UTC (rev 2658)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -47,6 +47,7 @@
import org.teiid.metadata.Schema;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.services.SessionServiceImpl;
@@ -68,6 +69,7 @@
this.logon = new LogonImpl(sessionService, null);
this.repo.setSystemStore(VDBMetadataFactory.getSystem());
+ this.repo.setSystemFunctionManager(new SystemFunctionManager());
this.repo.odbcEnabled();
this.repo.start();
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 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -166,11 +166,21 @@
testStatus, beginTS, endTS, resultException, null);
- this.querySet.handleTestResult(rs, this.internalResultSet, this.updateCount,
resultFromQuery, sql);
-
+ System.out.println("ADD THE TEST RESULT");
+
this.testResultsSummary.addTestResult(query.geQuerySetID(), rs);
+//
+// try {
+// System.out.println("HANDLE RESULT " + this.internalResultSet.isClosed());
+// } catch (SQLException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+
+ this.querySet.handleTestResult(rs, this.internalResultSet, this.updateCount,
resultFromQuery, sql);
+
}
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -80,6 +80,14 @@
}
public synchronized void addTestResult(String querySetID, TestResult result) {
+
+ if (result == null) {
+ System.err
+ .println("Error - trying to add a null result set for querysetID: " +
querySetID); //$NON-NLS-1$
+ throw new RuntimeException(
+ "Error - trying to add a null result set for querysetID: " + querySetID);
//$NON-NLS-1$
+
+ }
Collection<TestResult> results = null;
if (this.testResults.containsKey(querySetID)) {
results = this.testResults.get(querySetID);
@@ -92,7 +100,7 @@
}
public Collection<TestResult> getTestResults(String querySetID) {
- return this.testResults.get(querySetID);
+ return this.testResults.get(querySetID);
}
private static PrintStream getSummaryStream(String outputDir,
@@ -397,7 +405,10 @@
String outputDir = scenario.getResultsGenerator().getOutputDir();
// CombinedTestClient.log("Calculating and printing result statistics");
//$NON-NLS-1$
- if (testResults.size() > 0) {
+ if (testResults == null) {
+ // do nothing
+
+ } else if (testResults.size() > 0) {
// Create output file
String outputFileName = generateFileName(querySetID, System
.currentTimeMillis(), runNumber);
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -61,12 +61,6 @@
}
validateResultsMode(this.getProperties());
-
-// try {
-// setupVDBs(this.getProperties());
-// } catch (IOException e) {
-// throw new TransactionRuntimeException(e.getMessage());
-// }
}
@@ -85,45 +79,43 @@
public void handleTestResult(TestResult tr, ResultSet resultSet, int updatecnt,
boolean resultFromQuery, String sql) {
Throwable resultException = tr.getException();
- if (getResultsMode().equalsIgnoreCase(
- TestProperties.RESULT_MODES.COMPARE)) {
+ if (getResultsMode().equalsIgnoreCase(TestProperties.RESULT_MODES.COMPARE)) {
if (tr.getStatus() != TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
- this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
- sql,
- resultSet,
- resultException,
- tr.getStatus(), isOrdered(sql), -1, resultFromQuery);
-
- } catch (QueryTestFailedException qtf) {
- resultException = (resultException != null ? resultException
- : qtf);
- tr.setException(resultException);
- tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
-
- }
+ try {
+ this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
+ sql,
+ resultSet,
+ resultException,
+ tr.getStatus(), isOrdered(sql), -1, resultFromQuery);
+
+ } catch (QueryTestFailedException qtf) {
+ resultException = (resultException != null ? resultException
+ : qtf);
+ tr.setException(resultException);
+ tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
+
+ }
}
if (tr.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
-
- this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
- tr.getQueryID(), sql, resultSet, resultException,
- this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
-
-
- } catch (QueryTestFailedException qtfe) {
- throw new TransactionRuntimeException(qtfe.getMessage());
- }
+ try {
+
+ this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException,
+ this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
+
+
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
}
- } else if (getResultsMode().equalsIgnoreCase(
- TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
+ } else if (getResultsMode().equalsIgnoreCase(TestProperties.RESULT_MODES.GENERATE)) {
//$NON-NLS-1$
try {
- this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(),
- tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
+ this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
} catch (QueryTestFailedException qtfe) {
throw new TransactionRuntimeException(qtfe.getMessage());
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 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -41,6 +41,7 @@
import java.util.Properties;
import org.jdom.JDOMException;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.StringUtil;
import org.teiid.test.client.ClassFactory;
import org.teiid.test.client.ExpectedResults;
@@ -493,26 +494,63 @@
// Compare actual elements with expected elements column by column in this
row
for (int col = 0; col < actualColumnCount; col++) {
// Get actual value
- final Object actualValue = actualRecord.get(col);
+ Object actualValue = actualRecord.get(col);
// Get expected value
- final Object expectedValue = expectedRecord.get(col);
+ Object expectedValue = expectedRecord.get(col);
// DEBUG:
// debugOut.println(" Col: " +(col +1) + ":
expectedValue:[" + expectedValue + "] actualValue:[" + actualValue +
// "]");
// Compare these values
- if (expectedValue == null) {
+ if ( ( expectedValue == null && actualValue != null) ||
+ (actualValue == null && expectedValue != null) ){
// Compare nulls
- if (actualValue != null) {
throw new QueryTestFailedException(eMsg + "Value mismatch at
row " + (row + 1) //$NON-NLS-1$
+ " and column " +
(col + 1) //$NON-NLS-1$
+ ": expected = ["
//$NON-NLS-1$
- + expectedValue + "],
actual = [" //$NON-NLS-1$
- + actualValue +
"]"); //$NON-NLS-1$
+ +
(expectedValue!=null?expectedValue:"null") + "], actual = ["
//$NON-NLS-1$
+ +
(actualValue!=null?actualValue:"null") + "]"); //$NON-NLS-1$
- }
- } else {
+ }
+
+ if (actualValue instanceof Blob || actualValue instanceof Clob ||
actualValue instanceof SQLXML) {
+
+ if (actualValue instanceof Clob){
+ Clob c = (Clob)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(c.getAsciiStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ } else if (actualValue instanceof Blob){
+ Blob b = (Blob)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(b.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ } else if (actualValue instanceof SQLXML){
+ SQLXML s = (SQLXML)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(s.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ }
+
+
+ if (!(expectedValue instanceof String)) {
+ expectedValue = expectedValue.toString();
+ }
+ }
+
// Compare values with equals
if (!expectedValue.equals(actualValue)) {
// DEBUG:
@@ -521,18 +559,21 @@
if (expectedValue instanceof String) {
final String expectedString = (String)expectedValue;
- if (actualValue instanceof Blob || actualValue instanceof
Clob || actualValue instanceof SQLXML) {
- // LOB types are special case - metadata says they're
Object types so
- // expected results are of type String. Actual object
type is MMBlob, MMClob.
- // Must compare w/ String verion of actual!
- if (!expectedValue.equals(actualValue.toString())) {
- throw new QueryTestFailedException(eMsg + "LOB
Value mismatch at row " + (row + 1) //$NON-NLS-1$
- + " and
column " + (col + 1) //$NON-NLS-1$
- + ": expected
= [" //$NON-NLS-1$
- + expectedValue +
"], actual = [" //$NON-NLS-1$
- + actualValue +
"]"); //$NON-NLS-1$
- }
- } else if (!(actualValue instanceof String)) {
+// if (actualValue instanceof Blob || actualValue instanceof
Clob || actualValue instanceof SQLXML) {
+//
+// Clob c = (Clob)actualValue;
+// // LOB types are special case - metadata says
they're Object types so
+// // expected results are of type String. Actual object
type is MMBlob, MMClob.
+// // Must compare w/ String verion of actual!
+// if (!expectedValue.equals(actualValue.toString())) {
+// throw new QueryTestFailedException(eMsg + "LOB
Value mismatch at row " + (row + 1) //$NON-NLS-1$
+// + " and
column " + (col + 1) //$NON-NLS-1$
+// + ":
expected = [" //$NON-NLS-1$
+// + expectedValue
+ "], actual = [" //$NON-NLS-1$
+// + actualValue +
"]"); //$NON-NLS-1$
+// }
+// } else
+ if (!(actualValue instanceof String)) {
throw new QueryTestFailedException(eMsg + "Value
mismatch at row " + (row + 1) //$NON-NLS-1$
+ " and column
" + (col + 1) //$NON-NLS-1$
+ ": expected =
[" //$NON-NLS-1$
@@ -552,7 +593,7 @@
}
}
- }
+
} // end loop through columns
} // end loop through rows
}
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -123,6 +123,12 @@
String query, ResultSet result, Throwable ex, int testStatus)
throws QueryTestFailedException {
+ try {
+ System.out.println("GENERATE QRF: " + result.isClosed());
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
File resultsFile = createNewResultsFile(queryID, querySetID,
getGenerateDir());
OutputStream outputStream;
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -26,9 +26,12 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.sql.Blob;
+import java.sql.Clob;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
@@ -43,6 +46,7 @@
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.internal.core.xml.SAXBuilderHelper;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -50,6 +54,7 @@
import org.teiid.test.client.QueryTest;
import org.teiid.test.client.ctc.QueryResults.ColumnInfo;
import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.util.StringUtil;
@@ -944,6 +949,12 @@
private Element produceResults(ResultSet object, int beginRow, int endRow)
throws JDOMException, SQLException {
+ if (object.isClosed()) {
+ throw new SQLException(
+ "ResultSet is closed at this point, unable to product results");
//$NON-NLS-1$
+
+ }
+
if ( beginRow < START_ROW ) {
throw new IllegalArgumentException(
"The starting row cannot be less than 1."); //$NON-NLS-1$
@@ -1118,7 +1129,7 @@
* @return the root element of the XML segment that was produced.
* @exception JDOMException if there is an error producing XML.
*/
- public Element produceMsg(Object object, Element parent) throws JDOMException {
+ public Element produceMsg(Object object, Element parent) throws JDOMException,
SQLException {
if ( object == null ) {
throw new IllegalArgumentException("Null object reference.");
//$NON-NLS-1$
}
@@ -1229,16 +1240,52 @@
* @return the root element of the XML segment that was produced.
* @exception JDOMException if there is an error producing the message.
*/
- private Element produceObject(Object object, Element parent) throws JDOMException {
+ private Element produceObject(Object object, Element parent) throws JDOMException,
SQLException {
+ System.out.println("PRODUCT OBJECT");
// ----------------------
// Create the Object element ...
// ----------------------
Element objectElement = new Element(TagNames.Elements.OBJECT);
+ String result = null;
+ if (object instanceof Blob || object instanceof Clob || object instanceof SQLXML)
{
+
+ if (object instanceof Clob){
+ Clob c = (Clob)object;
+ try {
+ result = ObjectConverterUtil.convertToString(c.getAsciiStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ } else if (object instanceof Blob){
+ Blob b = (Blob)object;
+ try {
+ result = ObjectConverterUtil.convertToString(b.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ } else if (object instanceof SQLXML){
+ SQLXML s = (SQLXML)object;
+ try {
+ result = ObjectConverterUtil.convertToString(s.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ }
+ } else {
+ result = object.toString();
+ }
+
// System.out.println("ProductObject (before encoding): " +
object.toString() );
// try {
- objectElement.setText(object.toString());
+ objectElement.setText(result);
// URLEncoder.encode(object.toString(), "UTF-8"));
// } catch (UnsupportedEncodingException e) {
// UTF-8 is supported natively by all jvms
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -50,8 +50,7 @@
*/
@Override
public void handleTestResult(TestResult tr, ResultSet resultSet, int updateCnt,
boolean resultFromQuery, String sql) {
-
- Throwable resultException = tr.getException();
+ Throwable resultException = tr.getException();
if (getResultsMode().equalsIgnoreCase(
TestProperties.RESULT_MODES.COMPARE)) {
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2010-10-18
19:03:20 UTC (rev 2658)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2010-10-19
15:39:47 UTC (rev 2659)
@@ -172,7 +172,7 @@
modelToDatasourceMap.clear();
}
- dsfactory.cleanup();
+ if (dsfactory != null) dsfactory.cleanup();
DataSourceMgr.reset();