Author: shawkins
Date: 2011-05-13 15:14:08 -0400 (Fri, 13 May 2011)
New Revision: 3173
Added:
trunk/engine/src/test/resources/text/cdm_dos_win.txt
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
Modified:
trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/common-core/src/main/java/org/teiid/core/util/ReflectionHelper.java
trunk/common-core/src/test/java/org/teiid/core/util/TestReflectionHelper.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
trunk/documentation/developer-guide/src/main/docbook/en-US/content/runtime-updates.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.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/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java
Log:
foward merge from 7.4
Modified: trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -869,9 +869,9 @@
protected void appendSetQuery(SetQuery parent, QueryExpression obj, boolean right) {
if((!(obj instanceof SetQuery) && useParensForSetQueries())
- || (right && obj instanceof SetQuery
+ || (right && ((obj instanceof SetQuery
&& ((parent.isAll() && !((SetQuery)obj).isAll())
- || parent.getOperation() != ((SetQuery)obj).getOperation()))) {
+ || parent.getOperation() != ((SetQuery)obj).getOperation())) ||
obj.getLimit() != null || obj.getOrderBy() != null))) {
buffer.append(Tokens.LPAREN);
append(obj);
buffer.append(Tokens.RPAREN);
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-05-13 18:59:29 UTC (rev
3172)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-05-13 19:14:08 UTC (rev
3173)
@@ -54,7 +54,7 @@
<LI><B>JDK1.5 JDBC Client JAR</B> - A retro-translated Teiid client
JDBC jar now available to use with JDK 1.5 VM. Note only the JDBC API is supported, not
the Admin API, or retrieving query plans as XML.
<LI><B>Security Improvements</B> - UDF and pushdown functions can now
be protected with data roles. Also the CommandContext can provide the Subject for custom
security checks in UDFs.
<LI><B>Cache Invalidation</B> - Prepared plan and result set caches
have will invalidate entries based upon metadata and data changes respectively. See the
cache configuration maxStaleness setting and the Admin and Developer Guides for more.
- <LI><B>Runtime-updates of Metadata</B> - ALTER statements have been
added to change view/procedure/INSTEAD OF trigger (update procedure) definitions. A
CREATE TRIGGER statement is also available to add an INSTEAD OF trigger (update
procedures) to views.
+ <LI><B>Runtime Updates of Metadata</B> - ALTER statements have been
added to change view/procedure/INSTEAD OF trigger (update procedure) definitions. A
CREATE TRIGGER statement is also available to add an INSTEAD OF trigger (update
procedures) to views.
System procedures were added to set extension metadata and stat values. By default all
effects of metadata updates happen only on running vdbs across the cluster. To make the
changes persistent see the Developers Guide Runtime Updates section.
</UL>
@@ -127,6 +127,7 @@
<h4>from 7.3</h4>
<ul>
+ <LI>The default value for the JDBC dynamic vdb importer setting
importer.useFullSchemaName is now true, which matches the expected behavior from the
documentation.
<LI>The prepared plan cache is now configured via the PreparedPlanCacheConfig
bean, rather than through properties on the RuntimeEngineDeployer
<LI>SocketConfiguration.maxSocketThreads will interpret a setting of 0 to mean
use the system default of max available processors. Both the ODBC and JDBC transports now
default to the 0 setting.
<LI>maxReserveBatchColumns and maxProcessingBatchesColumns will interpret a
setting of -1 to mean auto-calculate acceptable values given the max heap and other
information. See the admin guide for more.
@@ -215,6 +216,266 @@
<h2><a name="Details">Detailed Release Notes</a></h2>
Detailed Release Notes - Teiid - Version ${project.version}
+
+<h2> Bug
+</h2>
+<ul>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-99'>TEIID-99</a>] -
Stored procedures should work in multisource connector binding scenarios
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1163'>TEIID-1163&l...>] -
Provide LOB support in ODBC
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1164'>TEIID-1164&l...>] -
Getting the Procedure Parameter metadata is not supported in ODBC
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1432'>TEIID-1432&l...>] -
Getting SocketTimeout Exceptions on long running queries with CXF
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1458'>TEIID-1458&l...>] -
Wrong count(*) result when joining data from two models
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1466'>TEIID-1466&l...>] -
MySQL syntax error in cast from date to timestamp
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1467'>TEIID-1467&l...>] -
Procedures in Teiid are not Resolvable if Their Models are Marked as Not Visible
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1469'>TEIID-1469&l...>] -
EDS Teiid Plugin uses Invalid Datatype Mask for SessionID Parameter to Terminate Session
Operation
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1470'>TEIID-1470&l...>] -
Deploying VDB XML file before data sources leads to failed deployment
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1476'>TEIID-1476&l...>] -
correct preventable exceptions
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1478'>TEIID-1478&l...>] -
various jdbc import issues
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1479'>TEIID-1479&l...>] -
Teiid Documentation does not include MS SQL Server as an available translator in section
10.2.2. JDBC Translator of the Reference Guide
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1480'>TEIID-1480&l...>] -
Teiid's ODBC interaction with PostgreSQL-ODBC fails when column lengths exceed
64K as PostgreSQL stores these values as a short
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1488'>TEIID-1488&l...>] -
EDS adminshell fails to connect to server with IBM JDK
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1489'>TEIID-1489&l...>] -
Teiid assumes fqns in transformations, but they are no longer required to be there
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1492'>TEIID-1492&l...>] -
StackOverflowError in DefaultCache
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1498'>TEIID-1498&l...>] -
Incorrect rewrite of not disjunctive criteria
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1502'>TEIID-1502&l...>] -
ODBC (and admin) scalability limited by maxWorker cap
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1503'>TEIID-1503&l...>] -
Exception during Optimization
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1504'>TEIID-1504&l...>] -
Internal Materialization does not honor the cache hint
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1505'>TEIID-1505&l...>] -
MaxActivePlans is not being read from the configuration
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1506'>TEIID-1506&l...>] -
ODBC Driver reporting BigInteger, BigDecimal columns as Strings
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1511'>TEIID-1511&l...>] -
VDB deployment leaves with too many open files
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1512'>TEIID-1512&l...>] -
show plan statement clob isn't readable
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1515'>TEIID-1515&l...>] -
ODBC does not report primarykeys on the tables
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1516'>TEIID-1516&l...>] -
IS_NULLABLE is reported incorrectly for columns
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1521'>TEIID-1521&l...>] -
Dynamic vdb import logic error with procedures
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1523'>TEIID-1523&l...>] -
Dynamic sql failure with null procedure parameters
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1528'>TEIID-1528&l...>] -
ruleimplementjoin strategy may generate an order by that does not use a relevant index
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1529'>TEIID-1529&l...>] -
LIMIT not pushed down for queries with subselects and ORDER BY
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1530'>TEIID-1530&l...>] -
ODBC identifer matching issues
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1531'>TEIID-1531&l...>] -
ODBC charset issues
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1532'>TEIID-1532&l...>] -
ODBC prepared statement handling can hang
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1534'>TEIID-1534&l...>] -
The driver incorrectly reports column labels as column names
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1537'>TEIID-1537&l...>] -
Error loading older cached metadata
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1538'>TEIID-1538&l...>] -
Invalid conversion from type class java.lang.Object with value
'oracle.sql.ROWID@1379cbd' to type class java.lang.String
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1545'>TEIID-1545&l...>] -
Order By not pushed down
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1548'>TEIID-1548&l...>] -
Creating XA data sources from AdminShell: prop name
"addtional-ds-properties" has misspelling - could cause confusion
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1549'>TEIID-1549&l...>] -
aggregate unrelated order by error
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1553'>TEIID-1553&l...>] -
UDF Function model fails to load when it located inside a folder in the VDB
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1554'>TEIID-1554&l...>] -
NullPointerException in NodeEditor
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1555'>TEIID-1555&l...>] -
NPE on server when admin-console requests for the "vdb requests"
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1558'>TEIID-1558&l...>] -
Salesforce Connector gives NPE when the resultset is empty
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1561'>TEIID-1561&l...>] -
Database Calender is not correctly being set in JDBC Translator
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1562'>TEIID-1562&l...>] -
ArrayIndexOutOfBounds and ASSERTION FAILED in models with UNION
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1564'>TEIID-1564&l...>] -
Clustered Caching Not Working
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1566'>TEIID-1566&l...>] -
More complex join: ORDER BY and LIMIT not pushed down
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1567'>TEIID-1567&l...>] -
Sybase translator needs to handle CROSS JOIN syntax.
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1570'>TEIID-1570&l...>] -
pg catalog transformation issues
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1571'>TEIID-1571&l...>] -
Error due to merge virtual with join and group by
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1572'>TEIID-1572&l...>] -
Teiid ODBC does not handle SET and Show operations correctly
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1576'>TEIID-1576&l...>] -
unexpected query result when joining with a virtual procedure
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1577'>TEIID-1577&l...>] -
ArrayIndexOutOfBoundsException in queries with ORDER BY
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1578'>TEIID-1578&l...>] -
Set query to string should account for branch limits/order bys
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1579'>TEIID-1579&l...>] -
LocalServer Connection is not working
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1580'>TEIID-1580&l...>] -
CME on VDB deploy
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1583'>TEIID-1583&l...>] -
importer.useFullSchemaName property default value is incorrectly documented
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1584'>TEIID-1584&l...>] -
Querying a virtual table backed by a SELECT x,y,z FROM EXECT ... TEXTTABLE() call fails
to return data
+</li>
+</ul>
+
+<h2> Enhancement
+</h2>
+<ul>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1473'>TEIID-1473&l...>] -
Don't batch more rows than is needed when query contains limit but translator
does not support limit
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1482'>TEIID-1482&l...>] -
Prevent unnecessary rebuffering of sorted results
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1490'>TEIID-1490&l...>] -
In the process of loading the schema metadata and duplicate table is found, add a
suggestion to the error message to use FQN option
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1519'>TEIID-1519&l...>] -
Changing dynamicportfolio example in the JBoss as kit to use HSQL instead of Derby
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1539'>TEIID-1539&l...>] -
Improve warning message when maximum thread count is encountered
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1556'>TEIID-1556&l...>] -
Improve xmlagg performance
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1569'>TEIID-1569&l...>] -
Documentation on creating UDF, extending ExecutionFactory and defining @Translator name
should indicate what to do with the translator name
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1581'>TEIID-1581&l...>] -
Adding a JCA example for creating a Teiid Data Source to the kits
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1582'>TEIID-1582&l...>] -
Avoid buffering in enhanced sort merge join
+</li>
+</ul>
+
+<h2> Feature Request
+</h2>
+<ul>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-217'>TEIID-217</a>] -
LDAP Connector should provide a way to retrieve all values of an attribute that appears
multiple times within a search result
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-231'>TEIID-231</a>] -
Ability to support Connector Level UDF functions in the System
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-239'>TEIID-239</a>] -
ENHANCEMENT: Costing beyond cardinality sould be propogated
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-796'>TEIID-796</a>] -
Allow for the import of overloaded procedures
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-946'>TEIID-946</a>] -
add support for in/out out return params
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1011'>TEIID-1011&l...>] -
Add support for connecting to Mondrian
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1059'>TEIID-1059&l...>] -
Add a specific translator for Ingres
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1060'>TEIID-1060&l...>] -
Add a specific translator for Intersystems Cache
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1061'>TEIID-1061&l...>] -
Add a specific translator for SAP Business Warehouse
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1176'>TEIID-1176&l...>] -
Provide a non-blocking JDBC api for ODBC support
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1217'>TEIID-1217&l...>] -
Derive VDB Name Using Version During Deployment in Jopr
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1326'>TEIID-1326&l...>] -
API request: rewrite query/command before it reaches the teiid planner
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1327'>TEIID-1327&l...>] -
API request: Fine grained security
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1329'>TEIID-1329&l...>] -
API to force metadata read
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1437'>TEIID-1437&l...>] -
It's not possible to deploy single file (*.xml) virtual database through web
admin console
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1463'>TEIID-1463&l...>] -
limit buffering for large results
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1464'>TEIID-1464&l...>] -
Add uuid function
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1471'>TEIID-1471&l...>] -
Projection should be minimized prior to view removal
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1474'>TEIID-1474&l...>] -
Add a limit to the number of concurrent source queries issued.
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1487'>TEIID-1487&l...>] -
CLONE - Add implicit conversion of NULL to correct datatype in transformation validator
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1491'>TEIID-1491&l...>] -
Provide JDBC 3.0 JRE 1.5 backwards compatibility
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1494'>TEIID-1494&l...>] -
Allow the optional join hint to work with non-ansi joins
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1496'>TEIID-1496&l...>] -
disjunctive rewrite
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1497'>TEIID-1497&l...>] -
misc subquery enhancements
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1507'>TEIID-1507&l...>] -
Cache invalidation
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1510'>TEIID-1510&l...>] -
RulePushAggregates should consider cost in addition to key information
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1533'>TEIID-1533&l...>] -
additional controls for dependent joins
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1536'>TEIID-1536&l...>] -
Local connections should use calling thread
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1546'>TEIID-1546&l...>] -
Be more selective as to what are created as bind variables
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1550'>TEIID-1550&l...>] -
Row level security enhancements
+</li>
+</ul>
+
+<h2> Quality Risk
+</h2>
+<ul>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1008'>TEIID-1008&l...>] -
Correlated subquery handling for Oracle/MySQL
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1281'>TEIID-1281&l...>] -
DB2 substring index bounds are different than teiid
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1493'>TEIID-1493&l...>] -
In a cluster the distributed cache is cleared by a node rejoining
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1508'>TEIID-1508&l...>] -
Dependent join planning problem
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1509'>TEIID-1509&l...>] -
Change the default for value caching
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1513'>TEIID-1513&l...>] -
Setting of translator properties should not be case sensitive
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1520'>TEIID-1520&l...>] -
Reduce the memory footprint of metadata
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1525'>TEIID-1525&l...>] -
update the hibernate usage with a note about id generation
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1527'>TEIID-1527&l...>] -
local connection doc provides an invalid example
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1535'>TEIID-1535&l...>] -
pg/odbc support should report rel oid with column metadata
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1574'>TEIID-1574&l...>] -
Add new permission types for alter/execute
+</li>
+</ul>
+
+<h2> Task
+</h2>
+<ul>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1431'>TEIID-1431&l...>] -
provide a working example of data roles
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1481'>TEIID-1481&l...>] -
client url cleanups
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1483'>TEIID-1483&l...>] -
Resolving changes to consolidate teiid/teiid designer handling
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1495'>TEIID-1495&l...>] -
Validate the TeraData Translator
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1514'>TEIID-1514&l...>] -
testZipFile.zip contains absolute path which impacted the MEAD sign
+</li>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1551'>TEIID-1551&l...>] -
ODBC logging context is not documented
+</li>
+</ul>
+
+<h2> Sub-task
+</h2>
+<ul>
+<li>[<a
href='https://issues.jboss.org/browse/TEIID-1524'>TEIID-1524&l...>] -
Index metadata strings container their entire record line.
+</li>
+</ul>
<h2><a name="Documentation">Documentation and
Help</a></h2>
Modified: trunk/common-core/src/main/java/org/teiid/core/util/ReflectionHelper.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/ReflectionHelper.java 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/common-core/src/main/java/org/teiid/core/util/ReflectionHelper.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -23,6 +23,7 @@
package org.teiid.core.util;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
@@ -175,26 +176,7 @@
}
for (Method method : methodsWithSameName) {
Class[] args = method.getParameterTypes();
- if ( args.length != argumentsClasses.size() ) {
- continue;
- }
- boolean allMatch = true; // assume all args match
- for ( int i=0; i<args.length && allMatch == true; ++i ) {
- Class<?> primitiveClazz = argumentsClassList.get(i);
- Class<?> objectClazz = argumentsClasses.get(i);
- if ( objectClazz != null ) {
- // Check for possible matches with (converted) primitive types
- // as well as the original Object type
- if ( ! args[i].equals(primitiveClazz) && !
args[i].isAssignableFrom(objectClazz) ) {
- allMatch = false; // found one that doesn't match
- }
- } else {
- // a null is assignable for everything except a primitive
- if ( args[i].isPrimitive() ) {
- allMatch = false; // found one that doesn't match
- }
- }
- }
+ boolean allMatch = argsMatch(argumentsClasses, argumentsClassList, args);
if ( allMatch ) {
if (result != null) {
throw new NoSuchMethodException(methodName + " Args: " +
argumentsClasses + " has multiple possible signatures."); //$NON-NLS-1$
//$NON-NLS-2$
@@ -209,6 +191,30 @@
throw new NoSuchMethodException(methodName + " Args: " +
argumentsClasses); //$NON-NLS-1$
}
+
+ private static boolean argsMatch(List<Class<?>> argumentsClasses,
+ List<Class<?>> argumentsClassList, Class[] args) {
+ if ( args.length != argumentsClasses.size() ) {
+ return false;
+ }
+ for ( int i=0; i<args.length; ++i ) {
+ Class<?> primitiveClazz = argumentsClassList.get(i);
+ Class<?> objectClazz = argumentsClasses.get(i);
+ if ( objectClazz != null ) {
+ // Check for possible matches with (converted) primitive types
+ // as well as the original Object type
+ if ( ! args[i].equals(primitiveClazz) && !
args[i].isAssignableFrom(objectClazz) ) {
+ return false; // found one that doesn't match
+ }
+ } else {
+ // a null is assignable for everything except a primitive
+ if ( args[i].isPrimitive() ) {
+ return false; // found one that doesn't match
+ }
+ }
+ }
+ return true;
+ }
/**
* Convert any argument classes to primitives.
@@ -260,10 +266,10 @@
* @param classLoader the class loader to use; may be null if the current
* class loader is to be used
* @return Object is the instance of the class
- * @throws TeiidException if an error occurrs instantiating the class
+ * @throws TeiidException if an error occurs instantiating the class
*/
- public static final Object create(String className, Collection ctorObjs,
+ public static final Object create(String className, Collection<?> ctorObjs,
final ClassLoader classLoader) throws
TeiidException {
try {
int size = (ctorObjs == null ? 0 : ctorObjs.size());
@@ -272,10 +278,12 @@
int i = 0;
if (size > 0) {
- for (Iterator it=ctorObjs.iterator(); it.hasNext(); ) {
+ for (Iterator<?> it=ctorObjs.iterator(); it.hasNext(); ) {
Object obj = it.next();
- names[i] = loadClass(obj.getClass().getName(),classLoader);
- objArray[i] = obj;
+ if (obj != null) {
+ names[i] = obj.getClass();
+ objArray[i] = obj;
+ }
i++;
}
}
@@ -287,16 +295,39 @@
public static final Object create(String className, Object[] ctorObjs,
Class<?>[] argTypes,
final ClassLoader classLoader) throws TeiidException {
+ Class<?> cls;
try {
- final Class<?> cls = loadClass(className,classLoader);
-
- Constructor<?> ctor = cls.getDeclaredConstructor(argTypes);
-
- return ctor.newInstance(ctorObjs);
-
+ cls = loadClass(className,classLoader);
} catch(Exception e) {
throw new TeiidException(e);
}
+ Constructor<?> ctor = null;
+ try {
+ ctor = cls.getDeclaredConstructor(argTypes);
+ } catch (NoSuchMethodException e) {
+
+ }
+
+ if (ctor == null && argTypes != null && argTypes.length > 0)
{
+ List<Class<?>> argumentsClasses = Arrays.asList(argTypes);
+ List<Class<?>> argumentsClassList =
convertArgumentClassesToPrimitives(argumentsClasses);
+ for (Constructor<?> possible : cls.getDeclaredConstructors()) {
+ if (argsMatch(argumentsClasses, argumentsClassList,
possible.getParameterTypes())) {
+ ctor = possible;
+ break;
+ }
+ }
+ }
+
+ if (ctor == null) {
+ throw new TeiidException(className + " Args: " +
Arrays.toString(argTypes)); //$NON-NLS-1$
+ }
+
+ try {
+ return ctor.newInstance(ctorObjs);
+ } catch (Exception e) {
+ throw new TeiidException(e);
+ }
}
}
Modified: trunk/common-core/src/test/java/org/teiid/core/util/TestReflectionHelper.java
===================================================================
---
trunk/common-core/src/test/java/org/teiid/core/util/TestReflectionHelper.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/common-core/src/test/java/org/teiid/core/util/TestReflectionHelper.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -27,6 +27,7 @@
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.junit.Test;
@@ -384,6 +385,10 @@
helpAssertSameMethodSignature("Found wrong method signature",
signatureExpected, signatureFound); //$NON-NLS-1$
}
+ @Test public void testCreate() throws Exception {
+ ReflectionHelper.create(SomeClass.class.getName(), Arrays.asList(true), null);
+ }
+
/**
* Test base interface
*/
@@ -419,4 +424,9 @@
void method(Serializable arg1, Number arg2);
void method(Serializable arg1, Long arg2);
}
+
+ public static class SomeClass {
+ public SomeClass(boolean primArg) {
+ }
+ }
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -76,7 +76,7 @@
private boolean importKeys;
private boolean importIndexes;
private String procedureNamePattern;
- private boolean useFullSchemaName;
+ private boolean useFullSchemaName = true;
private String[] tableTypes;
private String tableNamePattern;
private String catalog;
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -67,13 +67,7 @@
convert.addTypeMapping("clob", FunctionModifier.CLOB); //$NON-NLS-1$
convert.addNumericBooleanConversions();
registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
- }
-
- @Override
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
-
+
registerFunctionModifier(SourceSystemFunctions.BITAND, new
AliasModifier("bit_and")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.BITNOT, new
AliasModifier("bit_not")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.BITOR, new
AliasModifier("bit_or")); //$NON-NLS-1$
@@ -84,16 +78,29 @@
registerFunctionModifier(SourceSystemFunctions.RAND, new
AliasModifier("random")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.UCASE, new
AliasModifier("uppercase")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new
AliasModifier("day")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new
LocateFunctionModifier(getLanguageFactory()));
-
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new
LocateFunctionModifier(getLanguageFactory()));
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
supportedFunctions.add(SourceSystemFunctions.ABS);
supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.BITAND);
+ supportedFunctions.add(SourceSystemFunctions.BITNOT);
+ supportedFunctions.add(SourceSystemFunctions.BITOR);
+ supportedFunctions.add(SourceSystemFunctions.BITXOR);
supportedFunctions.add(SourceSystemFunctions.CONCAT);
supportedFunctions.add(SourceSystemFunctions.COS);
supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.CURTIME);
+ supportedFunctions.add(SourceSystemFunctions.CURDATE);
supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
supportedFunctions.add(SourceSystemFunctions.EXP);
supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
supportedFunctions.add(SourceSystemFunctions.LEFT);
supportedFunctions.add(SourceSystemFunctions.LPAD);
supportedFunctions.add(SourceSystemFunctions.LOCATE);
@@ -102,6 +109,7 @@
supportedFunctions.add(SourceSystemFunctions.MINUTE);
supportedFunctions.add(SourceSystemFunctions.MONTH);
supportedFunctions.add(SourceSystemFunctions.POWER);
+ supportedFunctions.add(SourceSystemFunctions.RAND);
supportedFunctions.add(SourceSystemFunctions.RIGHT);
supportedFunctions.add(SourceSystemFunctions.RPAD);
supportedFunctions.add(SourceSystemFunctions.SECOND);
@@ -109,6 +117,7 @@
supportedFunctions.add(SourceSystemFunctions.SQRT);
supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
supportedFunctions.add(SourceSystemFunctions.YEAR);
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
return supportedFunctions;
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -104,7 +104,7 @@
@Override
public List<?> translate(Function function) {
if (function.getType() == TypeFacility.RUNTIME_TYPES.INTEGER || function.getType() ==
TypeFacility.RUNTIME_TYPES.LONG) {
- Function result = convert.createConvertFunction(getLanguageFactory(), function,
TypeFacility.getDataTypeName(function.getType()));
+ Function result = ConvertModifier.createConvertFunction(getLanguageFactory(),
function, TypeFacility.getDataTypeName(function.getType()));
function.setType(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
return Arrays.asList(result);
}
@@ -119,19 +119,44 @@
supportedFunctions.addAll(super.getSupportedFunctions());
supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ACOS);
+ supportedFunctions.add(SourceSystemFunctions.ASIN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
supportedFunctions.add(SourceSystemFunctions.ASCII);
supportedFunctions.add(SourceSystemFunctions.CEILING);
supportedFunctions.add(SourceSystemFunctions.CHAR);
supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ supportedFunctions.add(SourceSystemFunctions.CONCAT);
supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.COS);
+ supportedFunctions.add(SourceSystemFunctions.COT);
+ supportedFunctions.add(SourceSystemFunctions.CURDATE);
+ supportedFunctions.add(SourceSystemFunctions.CURTIME);
+ supportedFunctions.add(SourceSystemFunctions.DAYNAME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFWEEK);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFYEAR);
+ supportedFunctions.add(SourceSystemFunctions.EXP);
supportedFunctions.add(SourceSystemFunctions.FLOOR);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
supportedFunctions.add(SourceSystemFunctions.IFNULL);
supportedFunctions.add(SourceSystemFunctions.LCASE);
supportedFunctions.add(SourceSystemFunctions.LENGTH);
supportedFunctions.add(SourceSystemFunctions.LPAD);
supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.LOG);
+ supportedFunctions.add(SourceSystemFunctions.LOG10);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.MONTHNAME);
+ supportedFunctions.add(SourceSystemFunctions.MOD);
supportedFunctions.add(SourceSystemFunctions.NULLIF);
+ supportedFunctions.add(SourceSystemFunctions.NOW);
+ supportedFunctions.add(SourceSystemFunctions.PI);
supportedFunctions.add(SourceSystemFunctions.POWER);
+ supportedFunctions.add(SourceSystemFunctions.QUARTER);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
supportedFunctions.add(SourceSystemFunctions.REPEAT);
supportedFunctions.add(SourceSystemFunctions.REPLACE);
supportedFunctions.add(SourceSystemFunctions.ROUND);
@@ -139,8 +164,16 @@
supportedFunctions.add(SourceSystemFunctions.RTRIM);
supportedFunctions.add(SourceSystemFunctions.SIGN);
supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
+ supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
+ supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
+ supportedFunctions.add(SourceSystemFunctions.TRUNCATE);
supportedFunctions.add(SourceSystemFunctions.UCASE);
supportedFunctions.add(SourceSystemFunctions.XMLCONCAT);
+ supportedFunctions.add(SourceSystemFunctions.WEEK);
return supportedFunctions;
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -30,18 +30,22 @@
import java.util.List;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
@@ -65,45 +69,69 @@
convert.addTypeMapping("double precision", FunctionModifier.DOUBLE);
//$NON-NLS-1$
convert.addTypeMapping("numeric(18,0)", FunctionModifier.BIGINTEGER);
//$NON-NLS-1$
convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
- convert.addConvert(FunctionModifier.INTEGER, FunctionModifier.STRING, new
NumericToStringModifier(12));
- convert.addConvert(FunctionModifier.BIGDECIMAL, FunctionModifier.STRING, new
NumericToStringModifier(38));
- convert.addConvert(FunctionModifier.BIGINTEGER, FunctionModifier.STRING, new
NumericToStringModifier(38));
- convert.addConvert(FunctionModifier.FLOAT, FunctionModifier.STRING, new
NumericToStringModifier(25));
- convert.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new
NumericToStringModifier(1));
- convert.addConvert(FunctionModifier.LONG, FunctionModifier.STRING, new
NumericToStringModifier(25));
- convert.addConvert(FunctionModifier.SHORT, FunctionModifier.STRING, new
NumericToStringModifier(12));
- convert.addConvert(FunctionModifier.DOUBLE, FunctionModifier.STRING, new
NumericToStringModifier(25));
- convert.addConvert(FunctionModifier.BYTE, FunctionModifier.STRING, new
NumericToStringModifier(4));
+ convert.addConvert(FunctionModifier.INTEGER, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.BIGDECIMAL, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.BIGINTEGER, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.FLOAT, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.LONG, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.SHORT, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.DOUBLE, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.BYTE, FunctionModifier.STRING, new
ImplicitConvertModifier());
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new
TimeModifier("TIME")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new
TimeModifier("DATE")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new
TimeModifier("TIMESTAMP")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new
TimeModifier("TIMESTAMP")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new
TimeModifier("varchar(100)")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new
TimeModifier("varchar(100)")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new
TimeModifier("varchar(100)")); //$NON-NLS-1$
+
convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING);
//$NON-NLS-1$
convert.addNumericBooleanConversions();
registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
- registerFunctionModifier(SourceSystemFunctions.RAND, new
AliasModifier("random")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.NULLIF, new
AliasModifier("NULLIFZERO")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.IFNULL, new
AliasModifier("ZEROIFNULL")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.RAND, new
AliasModifier("random")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN"));
//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LCASE, new
AliasModifier("LOWER")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.UCASE, new
AliasModifier("UPPER")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new
UpperOrLowerModifier("LOWER", this.convert)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new
UpperOrLowerModifier("UPPER", this.convert)); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.LENGTH, new
AliasModifier("CHARACTER_LENGTH")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.CURDATE, new
AliasModifier("CURRENT_DATE")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.CURTIME, new
AliasModifier("CURRENT_TIME")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new
AliasModifier("substr"));//$NON-NLS-1$
-
registerFunctionModifier(SourceSystemFunctions.YEAR, new
ExtractModifier("YEAR")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.MONTH, new
ExtractModifier("MONTH")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new
ExtractModifier("DAY")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.HOUR, new
ExtractModifier("HOUR")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.MINUTE, new
ExtractModifier("MINUTE")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.SECOND, new
ExtractModifier("SECOND")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new FunctionModifier() {
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new
LocateModifier(this.convert));
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new
LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new
LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
+ registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
- return Arrays.asList("position(",function.getParameters().get(0)," in
",function.getParameters().get(1) ,")"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+ function.setName(SourceSystemFunctions.TAN);
+ return
Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.DIVIDE_OP, new
Expression[] {new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER), function},
TypeFacility.RUNTIME_TYPES.DOUBLE));
}
- });
- registerFunctionModifier(SourceSystemFunctions.LEFT, new
LeftOrRightFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.RIGHT, new
LeftOrRightFunctionModifier(getLanguageFactory()));
+ });
+ registerFunctionModifier(SourceSystemFunctions.LTRIM, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("TRIM(LEADING FROM ",
expressionToString(function.getParameters().get(0), convert), ")");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.RTRIM, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("TRIM(TRAILING FROM ",
expressionToString(function.getParameters().get(0), convert), ")");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.MOD, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList(function.getParameters().get(0), " MOD ",
function.getParameters().get(1)); //$NON-NLS-1$
+ }
+ });
}
@Override
@@ -122,14 +150,38 @@
supportedFunctions.add(SourceSystemFunctions.ASIN);
supportedFunctions.add(SourceSystemFunctions.ATAN);
supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
supportedFunctions.add(SourceSystemFunctions.COS);
+ supportedFunctions.add(SourceSystemFunctions.COT);
supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.CURDATE);
+ supportedFunctions.add(SourceSystemFunctions.CURTIME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
supportedFunctions.add(SourceSystemFunctions.EXP);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE);
supportedFunctions.add(SourceSystemFunctions.LOG);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add("lower");//$NON-NLS-1$
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MOD);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.NULLIF);
+ supportedFunctions.add(SourceSystemFunctions.RAND);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
supportedFunctions.add(SourceSystemFunctions.SIN);
supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
supportedFunctions.add(SourceSystemFunctions.TAN);
supportedFunctions.add("||"); //$NON-NLS-1$
+ supportedFunctions.add("**"); //$NON-NLS-1$
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
return supportedFunctions;
}
@@ -211,6 +263,16 @@
new FunctionParameter("String2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' +
"NULLIFZERO", "NULLIFZERO", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("integer",
DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "") ) ); //$NON-NLS-1$
//$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' +
"ZEROIFNULL", "ZEROIFNULL", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("integer",
DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "") ) ); //$NON-NLS-1$
//$NON-NLS-2$
+
return pushdownFunctions;
}
@@ -278,7 +340,55 @@
return false;
}
- public static class ExtractModifier extends FunctionModifier {
+ public static class LocateModifier extends FunctionModifier {
+ ConvertModifier convertModifier;
+
+ public LocateModifier(ConvertModifier convertModifier) {
+ this.convertModifier = convertModifier;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ Expression expr1 = function.getParameters().get(0);
+ Expression expr2 = function.getParameters().get(1);
+ ArrayList target = new ArrayList();
+ target.add("position("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add( " in "); //$NON-NLS-1$
+ target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ }
+
+ private static List<?> expressionToString(Expression expr, ConvertModifier
modifier) {
+ Class tgtType = expr.getType();
+ if (tgtType.equals(String.class) && (expr instanceof Literal)) {
+ return Arrays.asList(expr);
+ }
+ else if (tgtType.equals(String.class) && (expr instanceof Function)) {
+
+ Function func = (Function)expr;
+ if (func.getParameters().get(0) instanceof ColumnReference) {
+ ColumnReference ref = (ColumnReference)func.getParameters().get(0);
+ if(Number.class.isAssignableFrom(ref.getType())) {
+ ArrayList target = new ArrayList();
+ target.add("cast("); //$NON-NLS-1$
+ target.add(func.getParameters().get(0));
+ target.add(" AS varchar(100))"); //$NON-NLS-1$
+ }
+ else {
+ return modifier.translate(func);
+ }
+ }
+ else {
+ return modifier.translate(func);
+ }
+ }
+ return Arrays.asList("cast(" , expr, " AS varchar(100))");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static class ExtractModifier extends FunctionModifier {
private String type;
public ExtractModifier(String type) {
this.type = type;
@@ -289,20 +399,76 @@
}
}
- public static class NumericToStringModifier extends FunctionModifier {
- private int charSize;
- private String formatCode;
- public NumericToStringModifier(int size) {
- this.charSize = size;
- StringBuilder sb = new StringBuilder();
- for(int i = 0; i < size; i++) {
- sb.append('Z');
- }
- this.formatCode = sb.toString();
+ public static class ImplicitConvertModifier extends FunctionModifier {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList(function.getParameters().get(0));
+ }
+ }
+
+
+ public static class TimeModifier extends FunctionModifier {
+ private String target;
+ public TimeModifier(String target) {
+ this.target = target;
}
@Override
public List<?> translate(Function function) {
- return Arrays.asList("TRIM(BOTH FROM ",function.getParameters().get(0),
" (FORMAT
'"+this.formatCode+"')(CHAR("+this.charSize+")))");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return Arrays.asList("cast(", function.getParameters().get(0), " AS
"+this.target+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
+
+ public static class UpperOrLowerModifier extends FunctionModifier {
+ String funcName;
+ ConvertModifier convertModifier;
+ public UpperOrLowerModifier(String name, ConvertModifier converModifier) {
+ this.funcName = name;
+ this.convertModifier = converModifier;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ Expression expr = function.getParameters().get(0);
+ ArrayList target = new ArrayList();
+ target.add(this.funcName);
+ target.add("("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr, this.convertModifier));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ }
+
+ public static class LeftOrRightFunctionModifier extends FunctionModifier {
+ private LanguageFactory langFactory;
+ ConvertModifier convertModifier;
+
+ public LeftOrRightFunctionModifier(LanguageFactory langFactory, ConvertModifier
converModifier) {
+ this.langFactory = langFactory;
+ this.convertModifier = converModifier;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ List<Expression> args = function.getParameters();
+ ArrayList target = new ArrayList();
+ if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
+ //substr(string, 1, length)
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(langFactory.createLiteral(Integer.valueOf(1),
TypeFacility.RUNTIME_TYPES.INTEGER));
+ target.add(args.get(1));
+ target.add(")"); //$NON-NLS-1$
+ } else if (function.getName().equalsIgnoreCase("right")) {
//$NON-NLS-1$
+ //substr(case_size, character_length(case_size) -4)
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+
+ target.add(",(character_length("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(")-"); //$NON-NLS-1$
+ target.add(args.get(1));
+ target.add("))"); //$NON-NLS-1$
+ }
+ return target;
+ }
+ }
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -52,16 +52,17 @@
}
if (decompose) {
+ Comparison.Operator opCode =
obj.isNegated()?Comparison.Operator.NE:Comparison.Operator.EQ;
if (exprs.size() > 1) {
- Condition left =
LanguageFactory.INSTANCE.createCompareCriteria(Comparison.Operator.EQ,
obj.getLeftExpression(), exprs.get(0));
+ Condition left = LanguageFactory.INSTANCE.createCompareCriteria(opCode,
obj.getLeftExpression(), exprs.get(0));
for (int i = 1; i < exprs.size(); i++) {
- AndOr replace = LanguageFactory.INSTANCE.createAndOr(Operator.OR, left,
LanguageFactory.INSTANCE.createCompareCriteria(Comparison.Operator.EQ,
obj.getLeftExpression(), exprs.get(i)));
+ AndOr replace =
LanguageFactory.INSTANCE.createAndOr(obj.isNegated()?Operator.AND:Operator.OR, left,
LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(),
exprs.get(i)));
left = replace;
}
super.visit((AndOr)left);
}
else {
- super.visit(LanguageFactory.INSTANCE.createCompareCriteria(Comparison.Operator.EQ,
obj.getLeftExpression(), exprs.get(0)));
+ super.visit(LanguageFactory.INSTANCE.createCompareCriteria(opCode,
obj.getLeftExpression(), exprs.get(0)));
}
}
else {
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -24,6 +24,7 @@
import static org.junit.Assert.assertEquals;
import java.sql.Date;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -74,12 +75,39 @@
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output,
TRANSLATOR);
}
+ @Test public void testTimestampToTime() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Timestamp(1304604994220L), Timestamp.class),
"time", "cast(cast('2011-05-05 09:16:34.22' AS TIMESTAMP(6)) AS
TIME)");
+ }
+
+ @Test public void testIntegerToString() throws Exception {
+ String input = "SELECT lcase(bigdecimalvalue) FROM BQT1.SMALLA";
+ String output = "SELECT LOWER(cast(SmallA.BigDecimalValue AS varchar(100)))
FROM SmallA";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output,
TRANSLATOR);
+ }
+
+ @Test public void testDateToString() throws Exception {
+ String input = "SELECT intkey, UPPER(timevalue) AS UPPER FROM BQT1.SmallA
ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey, UPPER(cast(SmallA.TimeValue AS
varchar(100))) AS UPPER FROM SmallA ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output,
TRANSLATOR);
+ }
+
+ @Test public void testLocate() throws Exception {
+ String input = "SELECT INTKEY, BIGDECIMALVALUE FROM BQT1.SmallA WHERE
LOCATE('-', BIGDECIMALVALUE) = 1 ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey, SmallA.BigDecimalValue FROM SmallA
WHERE position('-' in cast(SmallA.BigDecimalValue AS varchar(100))) = 1 ORDER BY
SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output,
TRANSLATOR);
+ }
+
+
@Test public void testByteToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class),
"string", "TRIM(BOTH FROM 1 (FORMAT 'ZZZZ')(CHAR(4)))");
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class),
"string", "1");
}
+ @Test public void testByte2ToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)-1), Byte.class),
"string", "-1");
+ }
+
@Test public void testDoubleToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.0), Double.class),
"string", "TRIM(BOTH FROM 1.0 (FORMAT
'ZZZZZZZZZZZZZZZZZZZZZZZZZ')(CHAR(25)))");
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.0), Double.class),
"string", "1.0");
}
@Test public void testInDecompose() throws Exception {
@@ -114,6 +142,17 @@
assertEquals("'1' = func() OR '1' = '3'",
helpGetString(expr));
}
+ @Test public void testNegatedInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {},
Date.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, true);
+
+ assertEquals("'1' <> func() AND '1' <>
'3'", helpGetString(expr));
+ }
+
@Test public void testsingleInDecomposeNonLiterals() throws Exception {
Expression left = LANG_FACTORY.createLiteral("1", String.class);
List<Expression> right = new ArrayList<Expression>();
@@ -127,12 +166,18 @@
@Test public void testNullComapreNull() throws Exception {
String input = "SELECT INTKEY, STRINGKEY, DOUBLENUM FROM bqt1.smalla WHERE NULL
<> NULL";
String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.DoubleNum FROM SmallA
WHERE 1 = 0";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, new
TeradataExecutionFactory());
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out,
TRANSLATOR);
}
@Test public void testPushDownFunction() throws Exception {
String input = "SELECT teradata.HASHBAKAMP(STRINGKEY) DOUBLENUM FROM
bqt1.smalla";
String out = "SELECT HASHBAKAMP(SmallA.StringKey) AS DOUBLENUM FROM SmallA";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, new
TeradataExecutionFactory());
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out,
TRANSLATOR);
}
+
+ @Test public void testRightFunction() throws Exception {
+ String input = "SELECT INTKEY, FLOATNUM FROM BQT1.SmallA WHERE right(FLOATNUM, 2)
<> 0 ORDER BY INTKEY";
+ String out = "SELECT SmallA.IntKey, SmallA.FloatNum FROM SmallA WHERE
substr(cast(SmallA.FloatNum AS varchar(100)),(character_length(cast(SmallA.FloatNum AS
varchar(100)))-2)) <> '0' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out,
TRANSLATOR);
+ }
}
Modified:
trunk/documentation/developer-guide/src/main/docbook/en-US/content/runtime-updates.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/runtime-updates.xml 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/runtime-updates.xml 2011-05-13
19:14:08 UTC (rev 3173)
@@ -35,6 +35,7 @@
System procedures and DDL statements should be used instead since the effects will be
distributed through the cluster and will not introduce
inconsistencies.</para></note>
<para><code>org.teiid.metadata.AbstractMetadataRecord</code> objects
passed to the <code>MetadataRepository</code> have not yet been modified.
If the <code>MetadataRepository</code> cannot persist the update, then a
<code>RuntimeException</code> should be thrown to prevent the update from
being applied by the runtime engine.</para>
+ <note><para>The MetadataRepository can be accessed by multiple threads both
during load (if using dynamic vdbs) or at runtime with through DDL statements. Your
implementation should handle any needed synchronization.</para></note>
<section>
<title>Costing Updates</title>
<para>See the Reference for the system procedures
<code>SYSADMIN.setColumnStats</code> and
<code>SYSADMIN.setTableStats</code>.
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 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2011-05-13
19:14:08 UTC (rev 3173)
@@ -845,7 +845,7 @@
<para>Get left y characters of x</para>
</entry>
<entry>
- <para>x in {string}, y in {string}, return string</para>
+ <para>x in {string}, y in {integer}, return string</para>
</entry>
</row>
<row>
@@ -963,7 +963,7 @@
<para>Get right y characters of x</para>
</entry>
<entry>
- <para>x in {string}, y in {string}, return string</para>
+ <para>x in {string}, y in {integer}, return string</para>
</entry>
</row>
<row>
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -283,7 +283,7 @@
}
}
long count = readCount.incrementAndGet();
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading
batch from disk, total reads:", count); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "reading
batch from disk, total reads:", count); //$NON-NLS-1$
try {
this.batchManager.compactionLock.readLock().lock();
long[] info = batchManager.physicalMapping.get(this.id);
@@ -320,7 +320,7 @@
if (batch != null) {
if (!persistent) {
long count = writeCount.incrementAndGet();
- LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "writing
batch to disk, total writes: ", count); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, batchManager.id, id,
"writing batch to disk, total writes: ", count); //$NON-NLS-1$
long offset = 0;
if (lobManager != null) {
for (List<?> tuple : batch.getTuples()) {
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -271,7 +271,7 @@
protected AtomicResultsMessage handleBatch() throws TranslatorException {
Assertion.assertTrue(!this.lastBatch);
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id,
"Sending results from connector"}); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id,
"Getting results from connector"}); //$NON-NLS-1$
int batchSize = 0;
List<List> rows = new ArrayList<List>(batchSize/4);
@@ -320,7 +320,9 @@
}
}
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id,
"Obtained last batch, total row count:", rowCount}); //$NON-NLS-1$\
- }
+ } else {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id,
"Obtained results from connector, current row count:", rowCount});
//$NON-NLS-1$
+ }
int currentRowCount = rows.size();
if ( !lastBatch && currentRowCount == 0 ) {
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 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -332,9 +332,10 @@
RequestWorkItem workItem = new RequestWorkItem(this, requestMsg, request,
resultsFuture.getResultsReceiver(), requestID, workContext);
logMMCommand(workItem, Event.NEW, null);
addRequest(requestID, workItem, state);
+ boolean runInThread = DQPWorkContext.getWorkContext().useCallingThread() ||
requestMsg.isSync();
synchronized (waitingPlans) {
- if (currentlyActivePlans < maxActivePlans ||
(!DQPWorkContext.getWorkContext().useCallingThread() && requestMsg.isSync())) {
- startActivePlan(workItem);
+ if (runInThread || currentlyActivePlans < maxActivePlans) {
+ startActivePlan(workItem, !runInThread);
} else {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "Queuing plan, since max
plans has been reached."); //$NON-NLS-1$
@@ -342,6 +343,9 @@
waitingPlans.add(workItem);
}
}
+ if (runInThread) {
+ workItem.run();
+ }
return resultsFuture;
}
@@ -362,15 +366,12 @@
state.addRequest(requestID);
}
- private void startActivePlan(RequestWorkItem workItem) {
+ private void startActivePlan(RequestWorkItem workItem, boolean addToQueue) {
workItem.active = true;
- if (workItem.getDqpWorkContext().useCallingThread() || workItem.requestMsg.isSync()) {
- this.currentlyActivePlans++;
- workItem.run();
- } else {
+ if (addToQueue) {
this.addWork(workItem);
- this.currentlyActivePlans++;
}
+ this.currentlyActivePlans++;
}
void finishProcessing(final RequestWorkItem workItem) {
@@ -381,7 +382,7 @@
workItem.active = false;
currentlyActivePlans--;
if (!waitingPlans.isEmpty()) {
- startActivePlan(waitingPlans.remove());
+ startActivePlan(waitingPlans.remove(), true);
}
}
}
Property changes on:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
___________________________________________________________________
Deleted: svn:mergeinfo
-
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -53,6 +53,7 @@
private boolean requiresContext;
private FunctionMethod method;
private String schema; //TODO: remove me - we need to create a proper schema for udf
and system functions
+ private Object metadataID;
// This is transient as it would be useless to invoke this method in
// a different VM. This function descriptor can be used to look up
@@ -104,6 +105,7 @@
return this.requiresContext;
}
+ @Override
public String toString() {
StringBuffer str = new StringBuffer(this.method.getName());
str.append("("); //$NON-NLS-1$
@@ -134,7 +136,8 @@
return this.method.getDeterminism();
}
- public Object clone() {
+ @Override
+ public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
@@ -149,7 +152,15 @@
void setReturnType(Class<?> returnType) {
this.returnType = returnType;
}
-
+
+ public Object getMetadataID() {
+ return this.metadataID;
+ }
+
+ public void setMetadataID(Object metadataID) {
+ this.metadataID = metadataID;
+ }
+
/**
* Invoke the function described in the function descriptor, using the
* values provided. Return the result of the function.
Property changes on:
trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
/branches/7.4.x/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java:3149-3171
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -189,7 +189,7 @@
* @param source The function metadata source, which knows how to obtain the
invocation class
* @param method The function metadata for a particular method signature
*/
- private void addFunction(String schema, FunctionMetadataSource source, FunctionMethod
method) {
+ public FunctionDescriptor addFunction(String schema, FunctionMetadataSource source,
FunctionMethod method) {
String categoryKey = method.getCategory();
if (categoryKey == null) {
method.setCategory(FunctionCategoryConstants.MISCELLANEOUS);
@@ -270,6 +270,7 @@
}
allFunctions.add(method);
+ return descriptor;
}
private FunctionDescriptor createFunctionDescriptor(
@@ -285,7 +286,7 @@
Method invocationMethod = null;
boolean requiresContext = false;
// Defect 20007 - Ignore the invocation method if pushdown is not required.
- if (method.getPushdown() == PushDown.CAN_PUSHDOWN || method.getPushdown() ==
PushDown.CANNOT_PUSHDOWN) {
+ if (validateClass && (method.getPushdown() == PushDown.CAN_PUSHDOWN ||
method.getPushdown() == PushDown.CANNOT_PUSHDOWN)) {
try {
Class<?> methodClass =
source.getInvocationClass(method.getInvocationClass());
ReflectionHelper helper = new ReflectionHelper(methodClass);
@@ -297,9 +298,7 @@
requiresContext = true;
}
} catch (ClassNotFoundException e) {
- 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$
- }
+ 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) {
Property changes on:
trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
___________________________________________________________________
Added: svn:mergeinfo
+
/branches/7.4.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java:3149-3171
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -228,7 +228,7 @@
if (frame.getFirstChild().getType() == NodeConstants.Types.TUPLE_LIMIT
&& NodeEditor.findParent(parentProject,
NodeConstants.Types.SORT |
NodeConstants.Types.DUP_REMOVE,
- NodeConstants.Types.SOURCE) != null) {
+ NodeConstants.Types.SOURCE |
NodeConstants.Types.SET_OP) != null) {
return root;
}
@@ -279,25 +279,21 @@
}
}
}
-
- PlanNode sort = NodeEditor.findParent(parentProject, NodeConstants.Types.SORT,
NodeConstants.Types.SOURCE);
- if (sort != null) { //special handling is needed since we are retaining the child
aliases
- List<SingleElementSymbol> childProject =
(List<SingleElementSymbol>)NodeEditor.findNodePreOrder(frame,
NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
- OrderBy elements = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
- for (OrderByItem item : elements.getOrderByItems()) {
- item.setSymbol(childProject.get(selectSymbols.indexOf(item.getSymbol())));
- }
- sort.getGroups().clear();
- sort.addGroups(GroupsUsedByElementsVisitor.getGroups(elements));
+
+ correctOrderBy(frame, selectSymbols, parentProject);
+ PlanNode parentSource = NodeEditor.findParent(frame, NodeConstants.Types.SOURCE);
+ PlanNode parentSetOp = NodeEditor.findParent(parentProject,
NodeConstants.Types.SET_OP, NodeConstants.Types.SOURCE);
+
+ if (parentSetOp == null || NodeEditor.findNodePreOrder(parentSetOp,
NodeConstants.Types.PROJECT) == parentProject) {
+ if (parentSource != null) {
+
FrameUtil.correctSymbolMap(((SymbolMap)frame.getProperty(NodeConstants.Info.SYMBOL_MAP)).asMap(),
parentSource);
+ }
+ if (parentSetOp != null) {
+ correctOrderBy(frame, selectSymbols, parentSetOp);
+ }
}
-
- PlanNode parentSource = NodeEditor.findParent(parentProject,
NodeConstants.Types.SOURCE);
-
- if (parentSource != null) {
-
FrameUtil.correctSymbolMap(((SymbolMap)frame.getProperty(NodeConstants.Info.SYMBOL_MAP)).asMap(),
parentSource);
- }
-
+ prepareFrame(frame);
//remove the parent project and the source node
NodeEditor.removeChildNode(parentProject, frame);
if (parentProject.getParent() == null) {
@@ -309,6 +305,20 @@
return root;
}
+
+ private static void correctOrderBy(PlanNode frame,
+ List<SingleElementSymbol> selectSymbols, PlanNode startNode) {
+ PlanNode sort = NodeEditor.findParent(startNode, NodeConstants.Types.SORT,
NodeConstants.Types.SOURCE | NodeConstants.Types.SET_OP);
+ if (sort != null) { //special handling is needed since we are retaining the child
aliases
+ List<SingleElementSymbol> childProject =
(List<SingleElementSymbol>)NodeEditor.findNodePreOrder(frame,
NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
+ OrderBy elements = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
+ for (OrderByItem item : elements.getOrderByItems()) {
+ item.setSymbol(childProject.get(selectSymbols.indexOf(item.getSymbol())));
+ }
+ sort.getGroups().clear();
+ sort.addGroups(GroupsUsedByElementsVisitor.getGroups(elements));
+ }
+ }
/**
* Check to ensure that we are not projecting a subquery or null dependent
expressions
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/EnhancedSortMergeJoinStrategy.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -37,6 +37,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.optimizer.relational.rules.NewCalculateCostUtil;
import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -50,14 +51,14 @@
* Will be used for inner joins and only if both sorts are not required.
* Degrades to a normal merge join if the tuples are balanced.
*
- * Refined in 7.4 to use a full index if it is small enough or a repeated merge, rather
than a partitioning approach (which was really just a sinlge level index)
+ * Refined in 7.4 to use a full index if it is small enough or a repeated merge, rather
than a partitioning approach (which was really just a single level index)
*/
public class EnhancedSortMergeJoinStrategy extends MergeJoinStrategy {
private TupleSource currentSource;
private SourceState sortedSource;
private SourceState notSortedSource;
- private List<?> partitionedTuple;
+ private List<?> currentTuple;
private TupleBrowser tb;
private int reserved;
private STree index;
@@ -132,7 +133,7 @@
if (!state.isDistinct()) {
index.getComparator().setDistinctIndex(keyLength-2);
}
- IndexedTupleSource its = state.getTupleBuffer().createIndexedTupleSource(true);
+ IndexedTupleSource its =
state.getTupleBuffer().createIndexedTupleSource(!joinNode.isDependent());
int rowId = 0;
List<?> lastTuple = null;
boolean sortedDistinct = sorted && !state.isDistinct();
@@ -175,20 +176,35 @@
@Override
protected void loadLeft() throws TeiidComponentException,
TeiidProcessingException {
- //always buffer to determine row counts
- this.leftSource.getTupleBuffer();
+ if (this.joinNode.isDependent()) {
+ this.leftSource.getTupleBuffer();
+ }
}
+ private boolean shouldIndexIfSmall(SourceState source) throws
TeiidComponentException, TeiidProcessingException {
+ Number cardinality = source.getSource().getEstimateNodeCardinality();
+ return (source.hasBuffer() || (cardinality != null &&
cardinality.floatValue() != NewCalculateCostUtil.UNKNOWN_VALUE &&
cardinality.floatValue() <= this.joinNode.getBatchSize()))
+ && (source.getRowCount() <= this.joinNode.getBatchSize());
+ }
+
@Override
protected void loadRight() throws TeiidComponentException,
TeiidProcessingException {
- this.rightSource.getTupleBuffer();
-
- if (processingSortRight == SortOption.SORT && shouldIndex(this.leftSource,
this.rightSource)) {
- this.processingSortRight = SortOption.NOT_SORTED;
- } else if (processingSortLeft == SortOption.SORT &&
shouldIndex(this.rightSource, this.leftSource)) {
+ //the checks are done in a particular order to ensure we don't buffer if
possible
+ if (processingSortRight == SortOption.SORT &&
shouldIndexIfSmall(this.leftSource)) {
+ this.processingSortRight = SortOption.NOT_SORTED;
+ } else if (!this.leftSource.hasBuffer() && processingSortLeft ==
SortOption.SORT && shouldIndexIfSmall(this.rightSource)) {
this.processingSortLeft = SortOption.NOT_SORTED;
- }
+ } else {
+ this.leftSource.getTupleBuffer();
+ if (!this.rightSource.hasBuffer() && processingSortRight == SortOption.SORT
&& shouldIndexIfSmall(this.leftSource)) {
+ this.processingSortRight = SortOption.NOT_SORTED;
+ } else if (processingSortRight == SortOption.SORT &&
shouldIndex(this.leftSource, this.rightSource)) {
+ this.processingSortRight = SortOption.NOT_SORTED;
+ } else if (processingSortLeft == SortOption.SORT &&
shouldIndex(this.rightSource, this.leftSource)) {
+ this.processingSortLeft = SortOption.NOT_SORTED;
+ }
+ }
if (this.processingSortLeft != SortOption.NOT_SORTED &&
this.processingSortRight != SortOption.NOT_SORTED) {
super.loadRight();
super.loadLeft();
@@ -257,7 +273,7 @@
super.process();
return;
}
- if (this.rightSource.getTupleBuffer().getRowCount() == 0) {
+ if (this.sortedSource.getTupleBuffer().getRowCount() == 0) {
return;
}
if (repeatedMerge) {
@@ -271,28 +287,28 @@
}
//else this is a single scan against the index
if (currentSource == null) {
- currentSource = this.notSortedSource.getTupleBuffer().createIndexedTupleSource();
+ currentSource = this.notSortedSource.getIterator();
}
while (true) {
- if (this.partitionedTuple == null) {
- partitionedTuple = this.currentSource.nextTuple();
- if (partitionedTuple == null) {
+ if (this.currentTuple == null) {
+ currentTuple = this.currentSource.nextTuple();
+ if (currentTuple == null) {
return;
}
- List<?> key =
RelationalNode.projectTuple(this.notSortedSource.getExpressionIndexes(),
this.partitionedTuple);
+ List<?> key =
RelationalNode.projectTuple(this.notSortedSource.getExpressionIndexes(),
this.currentTuple);
tb = new TupleBrowser(this.index, new
CollectionTupleSource(Arrays.asList(key).iterator()), OrderBy.ASC);
}
if (sortedTuple == null) {
sortedTuple = tb.nextTuple();
if (sortedTuple == null) {
- partitionedTuple = null;
+ currentTuple = null;
continue;
}
}
List<?> reorderedTuple = RelationalNode.projectTuple(reverseIndexes,
sortedTuple);
- List outputTuple =
outputTuple(this.processingSortLeft==SortOption.NOT_SORTED?partitionedTuple:reorderedTuple,
- this.processingSortLeft==SortOption.NOT_SORTED?reorderedTuple:partitionedTuple);
+ List outputTuple =
outputTuple(this.processingSortLeft==SortOption.NOT_SORTED?currentTuple:reorderedTuple,
+ this.processingSortLeft==SortOption.NOT_SORTED?reorderedTuple:currentTuple);
boolean matches = this.joinNode.matchesCriteria(outputTuple);
this.sortedTuple = null;
if (matches) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -189,7 +189,6 @@
if (state == State.LOAD_RIGHT) {
this.joinStrategy.openRight();
this.joinStrategy.loadRight();
- this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource,
null);
state = State.EXECUTE;
}
try {
@@ -274,7 +273,7 @@
public void closeDirect() {
super.closeDirect();
joinStrategy.close();
- if (this.getContext() != null) {
+ if (this.getContext() != null && this.dependentValueSource != null) {
this.getContext().getVariableContext().setGlobalValue(this.dependentValueSource,
null);
}
}
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -74,7 +74,7 @@
if (limit != null && limit.getRowLimit() instanceof Constant) {
Constant rowLimit = (Constant)limit.getRowLimit();
- if (Integer.valueOf(0) == rowLimit.getValue()) {
+ if (Integer.valueOf(0).equals(rowLimit.getValue())) {
return false;
}
}
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/TextTableNode.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -246,8 +246,12 @@
switch (c) {
case '\r':
cr = true;
+ textLine++;
+ return '\n';
case -1:
eof = true;
+ textLine++;
+ return '\n';
case '\n':
textLine++;
return '\n';
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 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -930,8 +930,8 @@
protected void appendSetQuery( SetQuery parent,
QueryCommand obj,
boolean right ) {
- if (right && obj instanceof SetQuery
- && ((parent.isAll() && !((SetQuery)obj).isAll()) ||
parent.getOperation() != ((SetQuery)obj).getOperation())) {
+ if (right && ((obj instanceof SetQuery
+ && ((parent.isAll() && !((SetQuery)obj).isAll()) ||
parent.getOperation() != ((SetQuery)obj).getOperation())) || obj.getLimit() != null ||
obj.getOrderBy() != null)) {
append(Tokens.LPAREN);
visitNode(obj);
append(Tokens.RPAREN);
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -273,6 +273,40 @@
}, TestLimit.NODE_TYPES);
}
+ @Test public void testSimpleMergeUnionSecondBranchWithOrderBy() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select '1' as x, e2
from pm1.g1 union all select e1, e2 from (select e1, 1 as e2 from pm1.g2 limit 1) as x
order by x", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null,
capFinder,
+ new String[] {"SELECT '1' AS c_0,
pm1.g1.e2 AS c_1 FROM pm1.g1 UNION ALL (SELECT pm1.g2.e1 AS c_0, 1 AS c_1 FROM pm1.g2
LIMIT 1) ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeUnionSecondBranchWithOrderBy1() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select '1' as x, e2
from pm1.g1 union all (select e1, e2 from (select distinct e1, 1 as e2 from pm1.g2) as x
order by e1 limit 1) order by x", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null,
capFinder,
+ new String[] {"SELECT '1' AS c_0,
pm1.g1.e2 AS c_1 FROM pm1.g1 UNION ALL (SELECT DISTINCT pm1.g2.e1 AS c_0, 1 AS c_1 FROM
pm1.g2 ORDER BY c_0 LIMIT 1) ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
/**
* Note that the merge is not performed since it would create an expression in the
group by clause
*/
@@ -321,6 +355,21 @@
assertTrue("Alias was not accounted for in sort node",
node.getElements().get(0).equals(node.getSortElements().get(0).getSymbol()));
//$NON-NLS-1$
}
+ @Test public void testSortAliasWithSameNameUnion() throws Exception {
+ String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x
union all select e1 from pm1.g2 order by e1"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(sql,
FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0", "SELECT g_0.e1
FROM pm1.g2 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
+
+ SortNode node = (SortNode)plan.getRootNode();
+ assertTrue("Alias was not accounted for in sort node",
node.getElements().get(0).equals(node.getSortElements().get(0).getSymbol()));
//$NON-NLS-1$
+ }
+
@Test public void testMergeImplicitGroupBy() throws Exception {
BasicSourceCapabilities caps = TestAggregatePushdown.getAggregateCapabilities();
caps.setFunctionSupport("+", true); //$NON-NLS-1$
Property changes on:
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
___________________________________________________________________
Added: svn:mergeinfo
+
/branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java:3149-3171
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -229,7 +229,7 @@
@Test public void testMultiCritDepJoin5b() {
//Create query
- String sql = "SELECT X.e1, X.e2 FROM pm1.g1 as X, pm2.g1 WHERE concat(X.e1,
convert(X.e4, string)) = concat(pm2.g1.e1, convert(pm2.g1.e4, string)) AND X.e2=pm2.g1.e2
order by x.e1 option makedep x"; //$NON-NLS-1$
+ String sql = "SELECT X.e1, X.e2 FROM pm1.g1 as X, pm2.g1 WHERE concat(X.e1,
convert(X.e4, string)) = concat(pm2.g1.e1, convert(pm2.g1.e4, string)) AND X.e2=pm2.g1.e2
order by x.e1, x.e2 option makedep x"; //$NON-NLS-1$
// Create expected results
List[] expected = new List[] {
@@ -779,7 +779,7 @@
/** SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE (pm1.g1.e2+1)=pm2.g1.e2
OPTION MAKEDEP pm1.g2 */
@Test public void testExpressionInDepJoin() {
// Create query
- String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE
(pm1.g1.e2+1)=pm2.g1.e2 OPTION MAKEDEP pm2.g1"; //$NON-NLS-1$
+ String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE
(pm1.g1.e2+1)=pm2.g1.e2 order by pm1.g1.e2, pm2.g1.e2 OPTION MAKEDEP pm2.g1";
//$NON-NLS-1$
// Create expected results
List[] expected = new List[] {
Property changes on:
trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
___________________________________________________________________
Added: svn:mergeinfo
+
/branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java:3149-3171
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -1721,7 +1721,7 @@
@Test public void testSubqueryInJoinPredicate() {
// Create query
- String sql = "SELECT x.e1 FROM (SELECT e1 FROM pm1.g1) AS x JOIN (SELECT e1 FROM
pm1.g1) y ON x.e1=y.e1"; //$NON-NLS-1$
+ String sql = "SELECT x.e1 FROM (SELECT e1 FROM pm1.g1) AS x JOIN (SELECT e1 FROM
pm1.g1) y ON x.e1=y.e1 order by x.e1"; //$NON-NLS-1$
// Create expected results
List[] expected = new List[] {
@@ -2805,15 +2805,15 @@
}
@Test public void testCorrelatedSubqueryVirtualLayer2() {
- String sql = "Select e1, e2 from vm1.g2 where e2 in (select e2 FROM vm1.g1
WHERE vm1.g2.e4 = vm1.g1.e4)"; //$NON-NLS-1$
+ String sql = "Select e1, e2 from vm1.g2 where e2 in (select e2 FROM vm1.g1
WHERE vm1.g2.e4 = vm1.g1.e4) order by e1, e2"; //$NON-NLS-1$
// Create expected results
List[] expected = new List[] {
Arrays.asList(new Object[] { "a", new Integer(0) }),
//$NON-NLS-1$
Arrays.asList(new Object[] { "a", new Integer(0) }),
//$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3) }),
//$NON-NLS-1$
Arrays.asList(new Object[] { "a", new Integer(0) }),
//$NON-NLS-1$
Arrays.asList(new Object[] { "a", new Integer(0) }),
//$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3) }),
//$NON-NLS-1$
Arrays.asList(new Object[] { "b", new Integer(2) })
//$NON-NLS-1$
};
@@ -4452,7 +4452,7 @@
@Test public void testDefect11236_MergeJoinWithFunctions() {
// Create query
- String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2
= (pm2.g1.e2+1)"; //$NON-NLS-1$
+ String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2
= (pm2.g1.e2+1) order by pm1.g1.e2, pm2.g1.e2"; //$NON-NLS-1$
boolean pushDown = false;
boolean dependent = false;
@@ -5265,7 +5265,7 @@
caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree("foo", new FakeFunctionMetadataSource()));
+ FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree("foo", new FakeFunctionMetadataSource(), true));
FakeMetadataFacade metadata = new
FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
processPreparedStatement(sql, expected, dataManager, capFinder,
@@ -5313,7 +5313,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
- FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree("foo", new FakeFunctionMetadataSource()));
+ FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree("foo", new FakeFunctionMetadataSource(), true));
FakeMetadataFacade metadata = new
FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
processPreparedStatement(sql, expected, dataManager, capFinder,
Property changes on:
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
___________________________________________________________________
Added: svn:mergeinfo
+
/branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3149-3171
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -75,6 +75,19 @@
processPreparedStatement(sql, expected, dataManager, new
DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(),
Arrays.asList(clobFromFile("text/cdm_dos.txt")));
}
+ @Test public void testTextTableFixedWin() throws Exception {
+ String sql = "select max(compkey), max(cdm_id), max(currency),
max(\"start\"), max(maturity), max(amount), count(*) from texttable(? COLUMNS
compkey string width 76, CDM_ID string width 14, CURRENCY string width 9,
\"START\" string width 31, MATURITY string width 31, AMOUNT double width 21,
RECORDSOURCE string width 13, SUMMIT_ID string width 15, RATE double width 20, SPREAD
double width 20, DESK string width 14) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("000369USD05/20/200405/20/2007", "000369",
"USD", "12/18/2000", "12/19/2005", 6.7209685146E8, 52),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ processPreparedStatement(sql, expected, dataManager, new
DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(),
Arrays.asList(clobFromFile("text/cdm_dos_win.txt")));
+ }
+
@Test public void testTextTableFixedPartial() throws Exception {
String sql = "select max(length(compkey)) from texttable(? COLUMNS compkey
string width 76) x"; //$NON-NLS-1$
Property changes on:
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
___________________________________________________________________
Added: svn:mergeinfo
+
/branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java:3149-3171
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -221,7 +221,7 @@
public void helpTestVirtualDepJoinSourceSelection(boolean setPushdown) throws
Exception {
// Create query
- String sql = "select c.id as CustomerID, First, Last, a.account_id as
AccountID, transaction_id as TransactionID, txn_type AS TxnCode, Amount, source from
(CustomerMaster.Customers c join CustomerMaster.Locations l on c.id=l.id) join
Accounts.Accounts a on c.id=a.customer_id and l.location=a.source where
c.first='Miles' option makenotdep c, l"; //$NON-NLS-1$
+ String sql = "select c.id as CustomerID, First, Last, a.account_id as
AccountID, transaction_id as TransactionID, txn_type AS TxnCode, Amount, source from
(CustomerMaster.Customers c join CustomerMaster.Locations l on c.id=l.id) join
Accounts.Accounts a on c.id=a.customer_id and l.location=a.source where
c.first='Miles' order by accountid option makenotdep c, l"; //$NON-NLS-1$
// Create expected results
List[] expected = new List[] {
@@ -270,7 +270,7 @@
0, // PlanExecution
3, // Project
selectCount, // Select
- 0, // Sort
+ 1, // Sort
1 // UnionAll
});
Property changes on:
trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
___________________________________________________________________
Added: svn:mergeinfo
+
/branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java:3149-3171
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 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -1875,6 +1875,12 @@
helpTest(command, "SELECT pm1.g1.e1 FROM pm1.g1 UNION SELECT e2 FROM pm1.g2
ORDER BY e1"); //$NON-NLS-1$
}
+ public void testUnionBranchOrderBy() throws Exception {
+ Command command = QueryParser.getQueryParser().parseCommand("select
pm1.g1.e1 from pm1.g1 union (select e2 from pm1.g2 order by e1)"); //$NON-NLS-1$
+ QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
+ helpTest(command, "SELECT pm1.g1.e1 FROM pm1.g1 UNION (SELECT e2 FROM pm1.g2
ORDER BY e1)"); //$NON-NLS-1$
+ }
+
public void testAliasedOrderBy() throws Exception {
Command command = QueryParser.getQueryParser().parseCommand("select
pm1.g1.e1 as a from pm1.g1 order by a"); //$NON-NLS-1$
QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
Copied: trunk/engine/src/test/resources/text/cdm_dos_win.txt (from rev 3171,
branches/7.4.x/engine/src/test/resources/text/cdm_dos_win.txt)
===================================================================
--- trunk/engine/src/test/resources/text/cdm_dos_win.txt (rev 0)
+++ trunk/engine/src/test/resources/text/cdm_dos_win.txt 2011-05-13 19:14:08 UTC (rev
3173)
@@ -0,0 +1,52 @@
+ 000183USD07/26/200107/26/2004 000183
USD 07/26/2001 07/26/2004
10000000.00 Summit 195205NY 0.005450 0.000000 MCREDCLN
+ 000184USD07/26/200107/26/2004 000184
USD 07/26/2001 07/26/2004
10000000.00 Summit 195219NY 0.005450 0.000000 NYBDUMMY
+ 000185USD07/26/200107/26/2004 000185
USD 07/26/2001 07/26/2004
10000000.00 Summit 195233NY 0.009700 0.000000 MCREDCLN
+ 000186USD07/26/200107/26/2004 000186
USD 07/26/2001 07/26/2004
10000000.00 Summit 195234NY 0.009700 0.000000 NYBDUMMY
+ 000258AUSD12/12/200209/15/2005 000258
USD 12/12/2002 09/15/2005
10000000.00 Summit 247299N 0.011500 0.000000 DCC2
+ 000259AUSD01/17/200303/20/2005 000259
USD 01/17/2003 03/20/2005
10000000.00 Summit 247300N 0.011000 0.000000 DCC2
+ 000273USD04/25/200307/07/2006 000273
USD 04/25/2003 07/07/2006
5000000.00 Summit 258123NY 0.008000 0.000000 LTINV
+ 000276AUSD05/10/200306/20/2008 000276
USD 05/10/2003 06/20/2008
10000000.00 Summit 260100N 0.033000 0.000000 DCC2
+ 000277AUSD05/10/200306/20/2008 000277
USD 05/10/2003 06/20/2008
5000000.00 Summit 260101N 0.006500 0.000000 DCC2
+ 000278AUSD05/13/200306/20/2008 000278
USD 05/13/2003 06/20/2008
5000000.00 Summit 260102N 0.033000 0.000000 DCC2
+ 000279AUSD05/14/200306/20/2008 000279
USD 05/14/2003 06/20/2008
5000000.00 Summit 260131N 0.033000 0.000000 DCC2
+ 000280USD06/11/200307/07/2006 000280
USD 06/11/2003 07/07/2006
5000000.00 Summit 264602NY 0.008900 0.000000 LTINV
+ 000289AUSD07/03/200309/20/2008 000289
USD 07/03/2003 09/20/2008
5000000.00 Summit 265496NY 0.004400 0.000000 LTINV
+ 000292USD07/19/200309/20/2008 000292
USD 07/19/2003 09/20/2008
5000000.00 Summit 271005NY 0.005000 0.000000 LTINV
+ 000350USD01/28/200403/20/2009 000350
USD 01/28/2004 03/20/2009
10000000.00 Summit 314996N 0.005200 0.000000 DCC2
+ 000354USD03/10/200403/10/2007 000354
USD 03/10/2004 03/10/2007
9324082.77 Summit 318622NY 0.037500 0.000000 LTTRSCDS
+ 000357USD03/16/200403/16/2007 000357
USD 03/16/2004 03/16/2007
9924050.62 Summit 318638NY 0.030000 0.000000 LTTRSCDS
+ 000359USD03/09/200403/09/2007 000359
USD 03/09/2004 03/09/2007
9329349.59 Summit 318641NY 0.027500 0.000000 LTTRSCDS
+ 000360USD03/18/200403/18/2007 000360
USD 03/18/2004 03/18/2007
232935.47 Summit 318642NY 0.032500 0.000000 LTTRSCDS
+ 000352USD04/08/200404/08/2007 000352
USD 04/08/2004 04/08/2007
9788013.59 Summit 318643NY 0.032500 0.000000 LTTRSCDS
+ 000353USD03/04/200403/04/2007 000353
USD 03/04/2004 03/04/2007
809831.58 Summit 318644NY 0.032500 0.000000 LTTRSCDS
+ 000353USD03/04/200403/04/2007 000353
USD 03/04/2004 03/04/2007
705882.35 Summit 325357NY 0.032500 0.000000 LTTRSCDS
+ 000353USD03/04/200403/04/2007 000353
USD 03/04/2004 03/04/2007
156623.38 Summit 325358NY 0.032500 0.000000 LTTRSCDS
+ 000353USD03/04/200403/04/2007 000353
USD 03/04/2004 03/04/2007
278643.02 Summit 325363NY 0.032500 0.000000 LTTRSCDS
+ 000353USD03/04/200403/04/2007 000353
USD 03/04/2004 03/04/2007
711809.48 Summit 325364NY 0.032500 0.000000 LTTRSCDS
+ 000359USD03/09/200403/09/2007 000359
USD 03/09/2004 03/09/2007
76890.25 Summit 325366NY 0.027500 0.000000 LTTRSCDS
+ 000360USD03/18/200403/18/2007 000360
USD 03/18/2004 03/18/2007
1049811.00 Summit 329001NY 0.032500 0.000000 LTTRSCDS
+ 000360USD03/18/200403/18/2007 000360
USD 03/18/2004 03/18/2007
414407.12 Summit 329002NY 0.032500 0.000000 LTTRSCDS
+ 000360USD03/18/200403/18/2007 000360
USD 03/18/2004 03/18/2007
1204408.30 Summit 329003NY 0.032500 0.000000 LTTRSCDS
+ 000360USD03/18/200403/18/2007 000360
USD 03/18/2004 03/18/2007
1058626.60 Summit 329004NY 0.032500 0.000000 LTTRSCDS
+ 000362USD04/12/200404/12/2007 000362
USD 04/12/2004 04/12/2007
194934.82 Summit 331567NY 0.040000 0.000000 LTTRSCDS
+ 000362USD04/12/200404/12/2007 000362
USD 04/12/2004 04/12/2007
131062.23 Summit 335678NY 0.040000 0.000000 LTTRSCDS
+ 000362USD04/12/200404/12/2007 000362
USD 04/12/2004 04/12/2007
1094136.66 Summit 335679NY 0.040000 0.000000 LTTRSCDS
+ 000362USD04/12/200404/12/2007 000362
USD 04/12/2004 04/12/2007
2785075.14 Summit 335680NY 0.040000 0.000000 LTTRSCDS
+ 000362USD04/12/200404/12/2007 000362
USD 04/12/2004 04/12/2007
2785075.14 Summit 335681NY 0.040000 0.000000 LTTRSCDS
+ 000362USD04/12/200404/12/2007 000362
USD 04/12/2004 04/12/2007
2984009.08 Summit 335682NY 0.040000 0.000000 LTTRSCDS
+ 000363USD05/03/200405/03/2007 000363
USD 05/03/2004 05/03/2007
10000000.00 Summit 338242NY 0.025000 0.000000 LTTRSCDS
+ 000364USD05/17/200405/17/2007 000364
USD 05/17/2004 05/17/2007
5000000.00 Summit 338820NY 0.032500 0.000000 LTTRSCDS
+ 000365USD05/07/200406/20/2009 000365
USD 05/07/2004 06/20/2009
5000000.00 Summit 340411N 0.004800 0.000000 DCC2
+ 000099USD12/06/199912/06/2004 000099
USD 12/06/1999 12/06/2004
200000000.00 Summit 340805NY 0.000000 0.000000 PCTRSCDS
+ 000129USD04/03/200010/01/2008 000129
USD 04/03/2000 10/01/2008
200000000.00 Summit 340834NY 0.000000 0.000000 PCTRSCDS
+ 000148USD09/12/200012/19/2005 000148
USD 09/12/2000 12/19/2005
573667.12 Summit 340844NY 0.000000 0.000000 PCTRSCDS
+ 000149USD09/12/200012/19/2005 000149
USD 09/12/2000 12/19/2005
2118155.52 Summit 340847NY 0.000000 0.000000 PCTRSCDS
+ 000150USD09/12/200012/19/2005 000150
USD 09/12/2000 12/19/2005
4986491.88 Summit 340848NY 0.000000 0.000000 PCTRSCDS
+ 000366USD05/06/200405/06/2007 000366
USD 05/06/2004 05/06/2007
3058823.53 Summit 341369NY 0.030000 0.000000 LTTRSCDS
+ 000367USD05/06/200405/06/2007 000367
USD 05/06/2004 05/06/2007
6941176.47 Summit 341377NY 0.030000 0.000000 LTTRSCDS
+ 000213USD02/11/200202/11/2007 000213
USD 02/11/2002 02/11/2007
8000000.00 Summit 343117NY 0.056500 0.000000 CNA2
+ 000272USD03/05/200301/31/2005 000272
USD 03/05/2003 01/31/2005
28000000.00 Summit 343123NY 0.006000 0.000000 CNA2
+ 000333USD11/13/200311/20/2004 000333
USD 11/13/2003 11/20/2004
25000000.00 Summit 343151NY 0.003800 0.000000 CNA2
+ 000368USD05/24/200405/24/2007 000368
USD 05/24/2004 05/24/2007
10000000.00 Summit 343169NY 0.025000 0.000000 LTTRSCDS
+ 000168USD12/18/200001/31/2006 000168
USD 12/18/2000 01/31/2006
672096851.46 Summit 344846NY 0.000000 0.000000 ASGCGD
+ 000369USD05/20/200405/20/2007 000369
USD 05/20/2004 05/20/2007
10000000.00 Summit 344851NY 0.032500 0.000000 LTTRSCDS
Property changes on: trunk/engine/src/test/resources/text/cdm_dos_win.txt
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:mergeinfo
+ /branches/7.4.x/engine/src/test/resources/text/cdm_dos_win.txt:3149-3171
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-05-13 18:59:29
UTC (rev 3172)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-05-13 19:14:08
UTC (rev 3173)
@@ -71,7 +71,8 @@
this.cmr = cmr;
this.additionalStores = additionalStores;
this.vdb.addAttchment(ConnectorManagerRepository.class, cmr);
- update(this.vdb, this.systemFunctions);
+ this.mergedVDB = vdb;
+ update();
}
public void addChild(CompositeVDB child) {
@@ -90,15 +91,15 @@
this.mergedVDB = null;
}
- void update(VDBMetaData vdbMetadata, FunctionTree systemFunctions) {
- TransformationMetadata metadata = buildTransformationMetaData(vdbMetadata,
getVisibilityMap(), getMetadataStores(), getUDF(), systemFunctions);
- vdbMetadata.addAttchment(QueryMetadataInterface.class, metadata);
- vdbMetadata.addAttchment(TransformationMetadata.class, metadata);
+ void update() {
+ TransformationMetadata metadata = buildTransformationMetaData(mergedVDB,
getVisibilityMap(), getMetadataStores(), getUDF(), systemFunctions,
this.additionalStores);
+ mergedVDB.addAttchment(QueryMetadataInterface.class, metadata);
+ mergedVDB.addAttchment(TransformationMetadata.class, metadata);
TempTableStore globalTables = new TempTableStore("SYSTEM"); //$NON-NLS-1$
- vdbMetadata.addAttchment(TempTableStore.class, globalTables);
+ mergedVDB.addAttchment(TempTableStore.class, globalTables);
}
- private TransformationMetadata buildTransformationMetaData(VDBMetaData vdb,
LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores,
UDFMetaData udf, FunctionTree systemFunctions) {
+ private static TransformationMetadata buildTransformationMetaData(VDBMetaData vdb,
LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores,
UDFMetaData udf, FunctionTree systemFunctions, MetadataStore[] additionalStores) {
Collection <FunctionTree> udfs = new ArrayList<FunctionTree>();
if (udf != null) {
for (Map.Entry<String, Collection<FunctionMethod>> entry :
udf.getFunctions().entrySet()) {
@@ -107,7 +108,7 @@
}
CompositeMetadataStore compositeStore = new
CompositeMetadataStore(stores.getStores());
- for (MetadataStore s:this.additionalStores) {
+ for (MetadataStore s:additionalStores) {
compositeStore.addMetadataStore(s);
for (Schema schema:s.getSchemas().values()) {
if (!schema.getFunctions().isEmpty()) {
@@ -126,43 +127,39 @@
}
public VDBMetaData getVDB() {
- if (this.children == null || this.children.isEmpty()) {
- return vdb;
- }
if (this.mergedVDB == null) {
this.mergedVDB = buildVDB();
- update(mergedVDB, this.systemFunctions);
+ update();
}
return this.mergedVDB;
}
-
private VDBMetaData buildVDB() {
- VDBMetaData mergedVDB = new VDBMetaData();
- mergedVDB.setName(this.vdb.getName());
- mergedVDB.setVersion(this.vdb.getVersion());
- mergedVDB.setModels(this.vdb.getModels());
- mergedVDB.setDataPolicies(this.vdb.getDataPolicies());
- mergedVDB.setDescription(this.vdb.getDescription());
- mergedVDB.setStatus(this.vdb.getStatus());
- mergedVDB.setJAXBProperties(this.vdb.getJAXBProperties());
- mergedVDB.setConnectionType(this.vdb.getConnectionType());
+ VDBMetaData newMergedVDB = new VDBMetaData();
+ newMergedVDB.setName(this.vdb.getName());
+ newMergedVDB.setVersion(this.vdb.getVersion());
+ newMergedVDB.setModels(this.vdb.getModels());
+ newMergedVDB.setDataPolicies(this.vdb.getDataPolicies());
+ newMergedVDB.setDescription(this.vdb.getDescription());
+ newMergedVDB.setStatus(this.vdb.getStatus());
+ newMergedVDB.setJAXBProperties(this.vdb.getJAXBProperties());
+ newMergedVDB.setConnectionType(this.vdb.getConnectionType());
ConnectorManagerRepository mergedRepo = new ConnectorManagerRepository();
mergedRepo.getConnectorManagers().putAll(this.cmr.getConnectorManagers());
for (CompositeVDB child:this.children.values()) {
// add models
for (Model m:child.getVDB().getModels()) {
- mergedVDB.addModel((ModelMetaData)m);
+ newMergedVDB.addModel((ModelMetaData)m);
}
for (DataPolicy p:child.getVDB().getDataPolicies()) {
- mergedVDB.addDataPolicy((DataPolicyMetadata)p);
+ newMergedVDB.addDataPolicy((DataPolicyMetadata)p);
}
mergedRepo.getConnectorManagers().putAll(child.cmr.getConnectorManagers());
}
- mergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo);
- return mergedVDB;
+ newMergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo);
+ return newMergedVDB;
}
private UDFMetaData getUDF() {
@@ -216,7 +213,7 @@
return mergedvisibilityMap;
}
- private MetadataStoreGroup getMetadataStores() {
+ public MetadataStoreGroup getMetadataStores() {
if (this.children == null || this.children.isEmpty()) {
return this.stores;
}
@@ -226,9 +223,9 @@
mergedStores.addStores(this.stores.getStores());
}
for (CompositeVDB child:this.children.values()) {
- MetadataStoreGroup stores = child.getMetadataStores();
- if ( stores != null) {
- mergedStores.addStores(stores.getStores());
+ MetadataStoreGroup childStores = child.getMetadataStores();
+ if ( childStores != null) {
+ mergedStores.addStores(childStores.getStores());
}
}
return mergedStores;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -22,15 +22,15 @@
package org.teiid.deployers;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.teiid.metadata.MetadataStore;
public class MetadataStoreGroup implements Serializable{
private static final long serialVersionUID = -3702321839716725121L;
- List<MetadataStore> stores = new ArrayList<MetadataStore>();
+ List<MetadataStore> stores = new CopyOnWriteArrayList<MetadataStore>();
public void addStores(List<MetadataStore> stores) {
this.stores.addAll(stores);
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-05-13 18:59:29
UTC (rev 3172)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-05-13 19:14:08
UTC (rev 3173)
@@ -111,11 +111,11 @@
repo.addTranslatorMetadata(data.getName(), data);
}
createConnectorManagers(cmr, repo, deployment);
-
+ boolean asynchLoad = false;
// if store is null and vdb dynamic vdb then try to get the metadata
if (store == null && deployment.isDynamic()) {
store = new MetadataStoreGroup();
- buildDynamicMetadataStore((VFSDeploymentUnit)unit, deployment, store, cmr);
+ asynchLoad = buildDynamicMetadataStore((VFSDeploymentUnit)unit, deployment, store,
cmr);
}
// allow empty vdbs for enabling the preview functionality
@@ -157,11 +157,13 @@
valid = validateSources(cmr, deployment);
// Check if the VDB is fully configured.
- if (valid) {
+ if (!valid) {
+ deployment.setStatus(VDB.Status.INACTIVE);
+ } else if (!asynchLoad) {
+ //if asynch this will be set by the loading thread
+ this.vdbRepository.finishDeployment(deployment.getName(), deployment.getVersion());
deployment.setStatus(VDB.Status.ACTIVE);
- } else {
- deployment.setStatus(VDB.Status.INACTIVE);
- }
+ }
}
else {
deployment.setStatus(VDB.Status.ACTIVE);
@@ -281,8 +283,8 @@
}
}
- private void buildDynamicMetadataStore(final VFSDeploymentUnit unit, final
VDBMetaData vdb, final MetadataStoreGroup vdbStore, final ConnectorManagerRepository cmr)
throws DeploymentException {
-
+ private boolean buildDynamicMetadataStore(final VFSDeploymentUnit unit, final
VDBMetaData vdb, final MetadataStoreGroup vdbStore, final ConnectorManagerRepository cmr)
throws DeploymentException {
+ boolean asynch = false;
// make sure we are configured correctly first
for (final ModelMetaData model:vdb.getModelMetaDatas().values()) {
if (model.getSourceNames().isEmpty()) {
@@ -301,6 +303,7 @@
}
if (!loaded) {
+ asynch = true;
threadPool.run(new Runnable() {
@Override
public void run() {
@@ -316,6 +319,7 @@
});
}
}
+ return asynch;
}
/**
@@ -369,7 +373,7 @@
LogManager.logInfo(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.getString("metadata_loaded",vdb.getName(), vdb.getVersion(),
model.getName())); //$NON-NLS-1$
model.clearErrors();
if (vdb.isValid()) {
- this.vdbRepository.updateVDB(vdb.getName(), vdb.getVersion());
+ this.vdbRepository.finishDeployment(vdb.getName(), vdb.getVersion());
vdb.setStatus(VDB.Status.ACTIVE);
LogManager.logInfo(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion()));
//$NON-NLS-1$
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-05-13 18:59:29
UTC (rev 3172)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-05-13 19:14:08
UTC (rev 3173)
@@ -100,19 +100,17 @@
else {
cvdb = new CompositeVDB(vdb, stores, visibilityMap, udf,
this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore, odbcStore);
}
- updateFromMetadataRepository(stores, cvdb);
this.vdbRepo.put(vdbId(vdb), cvdb);
notifyAdd(vdb.getName(), vdb.getVersion());
}
- private void updateFromMetadataRepository(MetadataStoreGroup stores,
- CompositeVDB cvdb) {
+ private void updateFromMetadataRepository(CompositeVDB cvdb) {
if (metadataRepository == null) {
return;
}
String vdbName = cvdb.getVDB().getName();
int vdbVersion = cvdb.getVDB().getVersion();
- LinkedList<MetadataStore> allStores = new
LinkedList<MetadataStore>(stores.getStores());
+ LinkedList<MetadataStore> allStores = new
LinkedList<MetadataStore>(cvdb.getMetadataStores().getStores());
allStores.addAll(Arrays.asList(cvdb.getAdditionalStores()));
metadataRepository.startLoadVdb(vdbName, vdbVersion);
for (MetadataStore metadataStore : allStores) {
@@ -316,10 +314,11 @@
}
}
- void updateVDB(String name, int version) {
+ public void finishDeployment(String name, int version) {
CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
if (v!= null) {
- v.update(v.getVDB(), systemFunctionManager.getSystemFunctions());
+ updateFromMetadataRepository(v);
+ v.update();
}
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -75,7 +75,7 @@
public void send(Message message, Serializable messageKey) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT,
MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_TRANSPORT, " message: " +
message + " for request ID:" + messageKey); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logDetail(LogConstants.CTX_TRANSPORT, " message: " +
message + " for message:" + messageKey); //$NON-NLS-1$ //$NON-NLS-2$
}
message.setMessageKey(messageKey);
objectSocket.write(message);
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 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -352,7 +352,7 @@
}
@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 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$
+ 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 2011-05-13
18:59:29 UTC (rev 3172)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -102,6 +102,10 @@
registerClientService(DQP.class, dqp, null);
}
+ public void stop() {
+ this.dqp.stop();
+ }
+
public void setMetadataRepository(MetadataRepository metadataRepository) {
this.repo.setMetadataRepository(metadataRepository);
this.dqp.setMetadataRepository(metadataRepository);
@@ -142,6 +146,7 @@
MetadataStoreGroup stores = new MetadataStoreGroup();
stores.addStore(metadata);
this.repo.addVDB(vdbMetaData, stores, entries, null, cmr);
+ this.repo.finishDeployment(vdbName, 1);
} catch (DeploymentException e) {
throw new RuntimeException(e);
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java 2011-05-13
18:59:29 UTC (rev 3172)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -64,13 +64,13 @@
@Test public void testProcImport() throws Exception {
FakeServer server = new FakeServer();
- server.deployVDB("test", UnitTestUtil.getTestDataPath() +
"/TestCase3473/test.vdb");
- Connection conn = server.createConnection("jdbc:teiid:test");
//$NON-NLS-1$
+ server.deployVDB("vdb", UnitTestUtil.getTestDataPath() +
"/TestCase3473/test.vdb");
+ Connection conn = server.createConnection("jdbc:teiid:vdb");
//$NON-NLS-1$
Properties importProperties = new Properties();
importProperties.setProperty("importer.importProcedures",
Boolean.TRUE.toString());
MetadataFactory mf = getMetadata(importProperties, conn);
- Procedure p =
mf.getMetadataStore().getSchemas().get("TEST").getProcedures().get("GETXMLSCHEMAS");
+ Procedure p =
mf.getMetadataStore().getSchemas().get("TEST").getProcedures().get("VDB.SYS.GETXMLSCHEMAS");
assertEquals(1, p.getResultSet().getColumns().size());
}
@@ -92,15 +92,17 @@
Connection conn = server.createConnection("jdbc:teiid:test");
//$NON-NLS-1$
Properties importProperties = new Properties();
+
+ getMetadata(importProperties, conn);
+
assertNotNull(mf.getMetadataStore().getSchemas().get("X").getTables().get("DUP"));
+
+ importProperties.setProperty("importer.useFullSchemaName",
Boolean.FALSE.toString());
try {
getMetadata(importProperties, conn);
+ fail();
} catch (TranslatorException e) {
}
-
- importProperties.setProperty("importer.useFullSchemaName",
Boolean.TRUE.toString());
- getMetadata(importProperties, conn);
-
assertNotNull(mf.getMetadataStore().getSchemas().get("X").getTables().get("DUP"));
}
}
Copied:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java (from
rev 3171,
branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java)
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2011-05-13
19:14:08 UTC (rev 3173)
@@ -0,0 +1,139 @@
+/*
+ * 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.jdbc;
+
+import static org.junit.Assert.*;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.LinkedHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.jboss.netty.handler.timeout.TimeoutException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.FunctionMethod.PushDown;
+import org.teiid.query.function.metadata.FunctionCategoryConstants;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
+
+@SuppressWarnings("nls")
+public class TestLocalConnections {
+
+ private final class SimpleUncaughtExceptionHandler implements
+ UncaughtExceptionHandler {
+ Throwable t;
+
+ @Override
+ public void uncaughtException(Thread arg0, Throwable arg1) {
+ t = arg1;
+ }
+ }
+
+ static ReentrantLock lock = new ReentrantLock();
+ static Condition waiting = lock.newCondition();
+ static Condition wait = lock.newCondition();
+
+ public static int blocking() throws InterruptedException {
+ lock.lock();
+ try {
+ waiting.signal();
+ if (!wait.await(2, TimeUnit.SECONDS)) {
+ throw new TimeoutException();
+ }
+ } finally {
+ lock.unlock();
+ }
+ return 1;
+ }
+
+ static FakeServer server = new FakeServer();
+
+ @BeforeClass public static void oneTimeSetup() {
+ server.setUseCallingThread(true);
+ MetadataStore ms = new MetadataStore();
+ Schema s = new Schema();
+ s.setName("test");
+ FunctionMethod function = new FunctionMethod("foo", null,
FunctionCategoryConstants.MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN,
TestLocalConnections.class.getName(), "blocking", new FunctionParameter[0], new
FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER), true,
FunctionMethod.Determinism.NONDETERMINISTIC);
+ s.addFunction(function);
+ ms.addSchema(s);
+ server.deployVDB("test", ms, new LinkedHashMap<String,
Resource>());
+ }
+
+ @AfterClass public static void oneTimeTearDown() {
+ server.stop();
+ }
+
+ @Test public void testConcurrentExection() throws Throwable {
+
+ Thread t = new Thread() {
+
+ public void run() {
+ try {
+ Connection c = server.createConnection("jdbc:teiid:test");
+
+ Statement s = c.createStatement();
+ s.execute("select foo()");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ SimpleUncaughtExceptionHandler handler = new SimpleUncaughtExceptionHandler();
+ t.setUncaughtExceptionHandler(handler);
+ t.start();
+
+ lock.lock();
+ try {
+ waiting.await();
+ } finally {
+ lock.unlock();
+ }
+ Connection c = server.createConnection("jdbc:teiid:test");
+ Statement s = c.createStatement();
+ s.execute("select * from tables");
+
+ lock.lock();
+ try {
+ wait.signal();
+ } finally {
+ lock.unlock();
+ }
+ t.join(2000);
+ if (t.isAlive()) {
+ fail();
+ }
+ if (handler.t != null) {
+ throw handler.t;
+ }
+ }
+
+}