Author: shawkins
Date: 2011-12-20 13:38:15 -0500 (Tue, 20 Dec 2011)
New Revision: 3753
Added:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
Modified:
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/documentation/reference/src/main/docbook/en-US/content/vdbs.xml
trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
Log:
forward merge from 7.6.x
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2011-12-20 15:25:24 UTC
(rev 3752)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2011-12-20 18:38:15 UTC
(rev 3753)
@@ -42,6 +42,7 @@
<ul>
<li>Support for named parameter syntax using param=value has been deprecated,
since it is ambiguous with a comparison predicate boolean value expression.
param<b>=></b>value should be used instead.
<li>Support for using the FROM clause post item hints MAKEDEP/MAKENOTDEP has been
deprecated. Use the pre item comment hint syntax instead, e.g. /*+ MAKEDEP */ tbl
+ <li>decodeinteger/decodestring have been deprecated. A CASE expression should be
used instead.
</ul>
<h4>from 7.x</h4>
Modified: trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2011-12-20 15:25:24
UTC (rev 3752)
+++ trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2011-12-20 18:38:15
UTC (rev 3753)
@@ -56,7 +56,7 @@
<description>{$display:"Salesforce
URL",$description:"URL for connecting to
Salesforce",$advanced:"true"}</description>
<config-property-name>URL</config-property-name>
<config-property-type>java.lang.String</config-property-type>
-
<
config-property-value>https://www.salesforce.com/services/Soap/u/17.0&...
+
<
config-property-value>https://www.salesforce.com/services/Soap/u/22.0&...
</config-property>
<config-property>
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java 2011-12-20
15:25:24 UTC (rev 3752)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -22,6 +22,10 @@
package org.teiid.translator.jdbc.mysql;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -30,6 +34,7 @@
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.FunctionModifier;
@Translator(name="mysql5", description="A translator for open source
MySQL5 Database")
@@ -75,5 +80,25 @@
public String getLikeRegexString() {
return "REGEXP"; //$NON-NLS-1$
}
-
+
+ @Override
+ public Object retrieveValue(ResultSet results, int columnIndex,
+ Class<?> expectedType) throws SQLException {
+ Object result = super.retrieveValue(results, columnIndex, expectedType);
+ if (expectedType == TypeFacility.RUNTIME_TYPES.STRING && result instanceof
Blob) {
+ return results.getString(columnIndex);
+ }
+ return result;
+ }
+
+ @Override
+ public Object retrieveValue(CallableStatement results, int parameterIndex,
+ Class<?> expectedType) throws SQLException {
+ Object result = super.retrieveValue(results, parameterIndex, expectedType);
+ if (expectedType == TypeFacility.RUNTIME_TYPES.STRING && result instanceof
Blob) {
+ return results.getString(parameterIndex);
+ }
+ return result;
+ }
+
}
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2011-12-20
18:38:15 UTC (rev 3753)
@@ -70,10 +70,10 @@
<para>
Teiid can be configured with multiple named application policies
that group together relevant LoginModules. Each of these application
- policy (or domains) names can be used to fully
- qualify user names to
- authenticate only against that domain. The format for a qualified
- name is username@domainname.
+ policy (or domain) names can be used to fully qualify user names to
+ authenticate only against that domain. The format for a qualified
+ name is username@domainname. The security-domain attribute under the
transport/authentication element in the &jboss-beans; file should be used set
+ the comma separated list of desired domains. The securityDomains property defaults to
a single domain named teiid-security.
</para>
<para>If a user name is not fully qualified, then the installed
domains will be consulted in order until a domain
@@ -164,7 +164,7 @@
You could do one of the following for Teiid:
<itemizedlist>
<listitem>
- <para>Reuse the teiid-security (or whatever name you choose) security
domain for Teiid by changing the teiid configuration &jboss-beans; to point to
teiid-security.
+ <para>Reuse the admin-console (or whatever name you choose) security domain
for Teiid by changing the teiid configuration &jboss-beans; to point to
admin-console.
</para>
</listitem>
@@ -202,7 +202,7 @@
<section>
<title>Remote Connections</title>
- <para>On the server, edit the &jboss-beans; under teiid
subsystem on ""transport" definition, add follows:
+ <para>On the server, edit the &jboss-beans; under teiid
subsystem on "transport" definition, add follows:
<programlisting><![CDATA[
<transport name="jdbc" protocol="teiid"
socket-binding="teiid-jdbc"/>
<authentication security-domain="teiid-security"
krb5-domain="krb5-domain"/>
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-12-20
15:25:24 UTC (rev 3752)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2011-12-20
18:38:15 UTC (rev 3753)
@@ -1716,24 +1716,16 @@
<tbody>
<row>
<entry>
- <para>DECODESTRING(x, y)</para>
+ <para>DECODESTRING(x, y [, z])</para>
</entry>
<entry>
<para>Decode column x using string of value pairs y
- and return the decoded column as a string</para>
- </entry>
- <entry>
- <para>all string</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>DECODESTRING(x, y, z)</para>
- </entry>
- <entry>
- <para>Decode column x using string of value pairs y
- with delimiter z and return the decoded column as a string
+ with optional delimiter z and return the decoded column as a string.
+ If a delimiter is not specified , is used.
+ y has the formate SearchDelimResultDelimSearchDelimResult[DelimDefault]
+ Returns Default if specified or x if there are no matches.
</para>
+ <warning><para>Deprecated. Use a CASE expression
instead.</para></warning>
</entry>
<entry>
<para>all string</para>
@@ -1741,29 +1733,21 @@
</row>
<row>
<entry>
- <para>DECODEINTEGER(x, y)</para>
+ <para>DECODEINTEGER(x, y [, z])</para>
</entry>
<entry>
<para>Decode column x using string of value pairs y
- and return the decoded column as an integer</para>
+ with optional delimiter z and return the decoded column as an
+ integer. If a delimiter is not specified , is used.
+ y has the formate SearchDelimResultDelimSearchDelimResult[DelimDefault]
+ Returns Default if specified or x if there are no matches.
+ </para>
+ <warning><para>Deprecated. Use a CASE expression
instead.</para></warning>
</entry>
<entry>
<para>all string parameters, return integer</para>
</entry>
</row>
- <row>
- <entry>
- <para>DECODEINTEGER(x,y,z)</para>
- </entry>
- <entry>
- <para>Decode column x using string of value pairs y
- with delimiter z and return the decoded column as an
- integer</para>
- </entry>
- <entry>
- <para>all string parameters, return integer</para>
- </entry>
- </row>
</tbody>
</tgroup>
</informaltable>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/vdbs.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/vdbs.xml 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/vdbs.xml 2011-12-20
18:38:15 UTC (rev 3753)
@@ -103,7 +103,7 @@
</para>
<para>
The name of the model is used as a
- top level schema name for all of the metadata imported from the
+ top level schema name for all of the metadata imported from the
connector. The name should be unique among all Models in the VDB and
should not contain the '.' character.
</para>
@@ -123,6 +123,7 @@
<itemizedlist>
<title>Source Element</title>
+ <para>A source is a named binding of a translator and connection
source to a model.</para>
<listitem>
<para>
<emphasis>name</emphasis>
@@ -131,7 +132,9 @@
The name of the source to use for this
model. This can be any name you like, but will typically be the same
as the model name. Having a name different than the model name is
- only useful in multi-source scenarios.
+ only useful in multi-source scenarios. In multi-source, the source
names under a given model must
+ be unique. If you have the same source bound to multiple models it
may have the same name
+ for each. An exception will be raised if the same source name is
used for different sources.
</para>
</listitem>
<listitem>
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2011-12-20
15:25:24 UTC (rev 3752)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -121,11 +121,7 @@
resolveTypes(insert, metadata, values, usingQuery);
if (!insert.getGroup().isResolved()) { //define the implicit temp group
- if(insert.getQueryExpression() != null) {
- ResolverUtil.resolveImplicitTempGroup(metadata, insert.getGroup(),
insert.getQueryExpression().getProjectedSymbols());
- }else {
- ResolverUtil.resolveImplicitTempGroup(metadata, insert.getGroup(),
insert.getVariables());
- }
+ ResolverUtil.resolveImplicitTempGroup(metadata, insert.getGroup(),
insert.getVariables());
resolveVariables(metadata, insert, groups);
//ensure that the types match
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -41,6 +41,7 @@
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.Transform;
+import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
import org.teiid.core.util.Assertion;
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants;
@@ -2272,7 +2273,10 @@
newCaseExpr.setElseExpression(exprs[0]);
}
- newCaseExpr.setType(function.getType());
+ newCaseExpr.setType(DefaultDataClasses.STRING);
+ if (function.getName().equalsIgnoreCase(FunctionLibrary.DECODEINTEGER)) {
+ return ResolverUtil.getConversion(newCaseExpr,
DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, false,
metadata.getFunctionLibrary());
+ }
return newCaseExpr;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2011-12-20
15:25:24 UTC (rev 3752)
+++
trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -70,7 +70,7 @@
public void visit(Function obj) {
this.setDeterminismLevel(obj.getFunctionDescriptor().getDeterministic());
- if (obj.getFunctionDescriptor().getPushdown() == PushDown.MUST_PUSHDOWN) {
+ if (obj.getFunctionDescriptor().getPushdown() == PushDown.MUST_PUSHDOWN ||
obj.getFunctionDescriptor().getDeterministic() == Determinism.NONDETERMINISTIC) {
evaluationNotPossible(EvaluationLevel.PUSH_DOWN);
} else if (obj.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)
//TODO: if we had the context here we could plan better for non-prepared
requests
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-12-20
15:25:24 UTC (rev 3752)
+++
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -157,9 +158,10 @@
Insert insert = (Insert)command;
TupleSource ts = insert.getTupleSource();
if (ts == null) {
+ Evaluator eval = new Evaluator(Collections.emptyMap(), this, context);
List<Object> values = new
ArrayList<Object>(insert.getValues().size());
for (Expression expr : (List<Expression>)insert.getValues()) {
- values.add(Evaluator.evaluate(expr));
+ values.add(eval.evaluate(expr, null));
}
ts = new CollectionTupleSource(Arrays.asList(values).iterator());
}
@@ -345,12 +347,33 @@
throws TeiidComponentException, QueryMetadataException,
TeiidProcessingException, ExpressionEvaluationException,
QueryProcessingException {
- final GroupSymbol group = query.getFrom().getGroups().get(0);
+ GroupSymbol group = query.getFrom().getGroups().get(0);
if (!group.isTempGroupSymbol()) {
return null;
}
final String tableName = group.getNonCorrelationName();
- boolean remapColumns = !tableName.equalsIgnoreCase(group.getName());
+ if (!tableName.equalsIgnoreCase(group.getName())) {
+ group = group.clone();
+ group.setName(tableName);
+ group.setDefinition(null);
+ query.getFrom().getClauses().clear();
+ query.getFrom().addClause(new UnaryFromClause(group));
+ final GroupSymbol newGroup = group;
+ //convert to the actual table symbols (this is typically handled by the
languagebridgefactory
+ ExpressionMappingVisitor emv = new ExpressionMappingVisitor(null) {
+ @Override
+ public Expression replaceExpression(Expression element) {
+ if (element instanceof ElementSymbol) {
+ ElementSymbol es = (ElementSymbol)element;
+ es = es.clone();
+ es.setGroupSymbol(newGroup);
+ return es;
+ }
+ return element;
+ }
+ };
+ PostOrderNavigator.doVisit(query, emv);
+ }
TempTable table = null;
if (group.isGlobalTable()) {
final GlobalTableStore globalStore = context.getGlobalTableStore();
@@ -391,21 +414,6 @@
}
}
}
- if (remapColumns) {
- //convert to the actual table symbols (this is typically handled by the
languagebridgefactory
- ExpressionMappingVisitor emv = new ExpressionMappingVisitor(null) {
- @Override
- public Expression replaceExpression(Expression element) {
- if (element instanceof ElementSymbol) {
- ElementSymbol es = (ElementSymbol)element;
- es.getGroupSymbol().setName(tableName);
- es.getGroupSymbol().setDefinition(null);
- }
- return element;
- }
- };
- PostOrderNavigator.doVisit(query, emv);
- }
return table.createTupleSource(query.getProjectedSymbols(), query.getCriteria(),
query.getOrderBy());
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -94,6 +94,7 @@
import org.teiid.query.util.CommandContext;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorReport;
+import org.teiid.translator.SourceSystemFunctions;
@SuppressWarnings({"nls", "unchecked"})
public class TestProcessor {
@@ -7623,5 +7624,58 @@
Arrays.asList(3)});
}
+ @Test public void testMultipleAliasInUnionAll(){
+ String sql = "SELECT enterprise_id FROM ( " +
+ "SELECT * FROM ( " +
+ " SELECT id, id AS display_id, 103 AS enterprise_id FROM ("
+
+ " SELECT 'x' as id, e1 FROM pm1.g1) AS nexted103) as
table103Source " +
+ "UNION ALL " +
+ "SELECT 'x', 'x' AS display_id, 101 AS
enterprise_id FROM (" +
+ " SELECT 'x', e1 FROM pm1.g1) AS nested101 " +
+ "UNION ALL " +
+ "SELECT 'x', 'x' AS display_id, 100 AS
enterprise_id FROM (" +
+ " SELECT 'x', e1 FROM pm1.g1) AS nested100) as
tableFrom1stSelect " +
+ "WHERE enterprise_id = 100";
+
+
+ // Create expected results - would expect these to be:
+ List[] expected = new List[] {
+ Arrays.asList(100)
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT 100 FROM pm1.g1 AS g_0", new List[]
{Arrays.asList(100)});
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, RealMetadataFactory.example1Cached(),
TestOptimizer.getGenericFinder(false));
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testNonDeterministicPushdown() throws Exception {
+ // Create query
+ String sql = "SELECT RAND(), lookup('pm1.g1', 'e1',
'e2', 1) FROM pm1.g1 limit 2"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Double(0.1), "a"),
+ Arrays.asList(new Double(0.2), "a"),
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager hdm = new HardcodedDataManager();
+ hdm.addData("SELECT RAND() FROM pm1.g1", expected);
+ hdm.addData("SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", new
List<?>[] {Arrays.asList(1, "a")});
+ BasicSourceCapabilities bsc = new BasicSourceCapabilities();
+ bsc.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ bsc.setFunctionSupport(SourceSystemFunctions.RAND, true);
+ // Plan query
+ CommandContext cc = createCommandContext();
+ ProcessorPlan plan = helpGetPlan(helpParse(sql),
RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(bsc), cc);
+
+ helpProcess(plan, cc, hdm, expected);
+ }
+
private static final boolean DEBUG = false;
}
Property changes on:
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
___________________________________________________________________
Modified: svn:mergeinfo
-
/branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3149-3217,3220-3275,3535-3555
/branches/7.6.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3673-3711
/trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3188-3450,3452-3666
+
/branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3149-3217,3220-3275,3535-3555
/branches/7.6.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3673-3711,3714-3752
/trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java:3188-3450,3452-3666
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -2946,5 +2946,9 @@
XMLQuery ex = (XMLQuery)
SymbolMap.getExpression(q.getSelect().getSymbols().get(0));
assertEquals(DataTypeManager.DefaultDataClasses.XML,
ex.getPassing().get(0).getExpression().getType());
}
+
+ @Test public void testImplicitTempTableWithExplicitColumns() {
+ helpResolve("insert into #temp(x, y) select e1, e2 from pm1.g1");
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -1043,23 +1043,23 @@
}
@Test public void testDefect16879_3(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM
pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END FROM
pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM
pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' ELSE e1
END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_4(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM
pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 =
'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM
pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN e1 =
'c' THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$
//$NON-NLS-2$
}
@Test public void testDefect16879_5(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d')
FROM pm1.g1", "SELECT CASE WHEN e1 IS NULL THEN 'b' WHEN e1 =
'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d')
FROM pm1.g1", "SELECT convert(CASE WHEN e1 IS NULL THEN 'b' WHEN e1 =
'c' THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$
//$NON-NLS-2$
}
@Test public void testDefect16879_6(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d')
FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS
NULL THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d')
FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN
e1 IS NULL THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$
//$NON-NLS-2$
}
@Test public void testDefect16879_7(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e')
FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS
NULL THEN 'd' ELSE 'e' END FROM pm1.g1"); //$NON-NLS-1$
//$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e')
FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN
e1 IS NULL THEN 'd' ELSE 'e' END, integer) FROM pm1.g1");
//$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testCaseExpressionThatResolvesToNull() {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -21,17 +21,13 @@
*/
package org.teiid.jboss;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
-import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
-import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-import java.util.StringTokenizer;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -150,13 +146,10 @@
LogManager.logDetail(LogConstants.CTX_SECURITY,
IntegrationPlugin.Util.getString("socket_binding_not_defined", transportName));
//$NON-NLS-1$
}
- ArrayList<String> domainList = new ArrayList<String>();
+ List<String> domainList = Collections.emptyList();
if (Element.AUTHENTICATION_SECURITY_DOMAIN_ATTRIBUTE.isDefined(operation)) {
String domains =
Element.AUTHENTICATION_SECURITY_DOMAIN_ATTRIBUTE.asString(operation);
- StringTokenizer st = new StringTokenizer(domains, ","); //$NON-NLS-1$
- while(st.hasMoreTokens()) {
- domainList.add(st.nextToken());
- }
+ domainList = Arrays.asList(domains.split(","));//$NON-NLS-1$
}
transport.setAuthenticationDomains(domainList);
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -250,13 +250,23 @@
IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map = new
IdentityHashMap<Translator, ExecutionFactory<Object, Object>>();
for (Model model:deployment.getModels()) {
- for (String source:model.getSourceNames()) {
- if (cmr.getConnectorManager(source) != null) {
+ List<String> sourceNames = model.getSourceNames();
+ if (sourceNames.size() != new HashSet<String>(sourceNames).size()) {
+ throw new
StartException(IntegrationPlugin.Util.getString("duplicate_source_name",
model.getName(), deployment.getName(), deployment.getVersion())); //$NON-NLS-1$
+ }
+ for (String source:sourceNames) {
+ ConnectorManager cm = cmr.getConnectorManager(source);
+ String name = model.getSourceTranslatorName(source);
+ String connection = model.getSourceConnectionJndiName(source);
+ if (cm != null) {
+ if (!cm.getTranslatorName().equals(name)
+ || !cm.getConnectionName().equals(connection)) {
+ throw new
StartException(IntegrationPlugin.Util.getString("source_name_mismatch", source,
deployment.getName(), deployment.getVersion())); //$NON-NLS-1$
+ }
continue;
}
- String name = model.getSourceTranslatorName(source);
- ConnectorManager cm = new ConnectorManager(name,
model.getSourceConnectionJndiName(source));
+ cm = new ConnectorManager(name, connection);
try {
ExecutionFactory<Object, Object> ef = getExecutionFactory(name, repo,
getTranslatorRepository(), deployment, map, new HashSet<String>());
cm.setExecutionFactory(ef);
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-12-20
15:25:24 UTC (rev 3752)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-12-20
18:38:15 UTC (rev 3753)
@@ -351,4 +351,7 @@
mark-datasource-available.describe=Notify that the defined data source is now available
mark-datasource-available.ds-name.describe=Data Source name
-mark-datasource-available.reply=void
\ No newline at end of file
+mark-datasource-available.reply=void
+
+duplicate_source_name=Source names are not unique for model {0} in {1}.{2}
+source_name_mismatch=There are different sources with the name {0} in {1}.{2}
Added:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java 2011-12-20
18:38:15 UTC (rev 3753)
@@ -0,0 +1,95 @@
+/*
+ * 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.systemmodel;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.LinkedHashMap;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.jdbc.FakeServer;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
+
+@SuppressWarnings("nls")
+public class TestMatViewAliasing {
+
+ private static final String MATVIEWS = "matviews";
+ private Connection conn;
+ private FakeServer server;
+
+ @Before public void setUp() throws Exception {
+ server = new FakeServer();
+
+ VDBRepository vdbRepository = new VDBRepository();
+ vdbRepository.setSystemStore(VDBMetadataFactory.getSystem());
+ MetadataFactory mf = new MetadataFactory("foo",
vdbRepository.getBuiltinDatatypes(), new Properties());
+
+ Table mat = mf.addTable("mat");
+ mat.setVirtual(true);
+ mat.setMaterialized(true);
+ mat.setSelectTransformation("/*+ cache(ttl:0) */ select 1 as x, 'y' as
Name");
+
+ mf.addColumn("x", DataTypeManager.DefaultDataTypes.INTEGER, mat);
+ mf.addColumn("Name", DataTypeManager.DefaultDataTypes.STRING, mat);
+
+ MetadataStore ms = mf.getMetadataStore();
+
+ server.deployVDB(MATVIEWS, ms, new LinkedHashMap<String, Resource>());
+ conn = server.createConnection("jdbc:teiid:"+MATVIEWS);
+ }
+
+ @After public void tearDown() throws Exception {
+ server.stop();
+ conn.close();
+ }
+
+ @Test public void testSystemMatViewsWithImplicitLoad() throws Exception {
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("select * from MatViews order by name");
+ assertTrue(rs.next());
+ assertEquals("NEEDS_LOADING", rs.getString("loadstate"));
+ assertEquals(false, rs.getBoolean("valid"));
+
+ rs = s.executeQuery("select * from mat order by x");
+ assertTrue(rs.next());
+ rs = s.executeQuery("select * from MatViews where name = 'mat'");
+ assertTrue(rs.next());
+ assertEquals("LOADED", rs.getString("loadstate"));
+
+ rs = s.executeQuery("select * from mat as a, mat as b where a.x = b.name order by
a.x");
+ assertFalse(rs.next());
+ }
+
+}
Property changes on:
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViewAliasing.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain