teiid SVN: r2650 - branches/7.1.x/console/src/main/java/org/teiid/rhq/admin.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-10-14 11:18:55 -0400 (Thu, 14 Oct 2010)
New Revision: 2650
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
Log:
TEIID-982: Fix ClassCastException when building mat view results
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-10-14 15:17:20 UTC (rev 2649)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-10-14 15:18:55 UTC (rev 2650)
@@ -69,7 +69,7 @@
private static final MetaValueFactory metaValueFactory = MetaValueFactory
.getInstance();
- private static final String VDB_EXT = ".vdb";
+ private static final String VDB_EXT = ".vdb"; //$NON-NLS-1$
public DQPManagementView() {
}
@@ -330,7 +330,6 @@
operationResult.setContent(createReportResultListForMatViewQuery(
fieldNameList, sqlResultsObject.iterator()));
} else if (operationName.equals(VDB.Operations.RELOAD_MATVIEW)) {
- List<String> fieldNameList = operationResult.getFieldNameList();
MetaValue resultsMetaValue = reloadMaterializedView(connection,
formatVdbName(vdbName), Integer.parseInt(vdbVersion),
(String) valueMap.get(Operation.Value.MATVIEW_SCHEMA),
@@ -865,7 +864,7 @@
// Iterate through rows
while (objectIter.hasNext()) {
- ArrayList<String> columnValues = (ArrayList<String>) objectIter
+ ArrayList<Object> columnValues = (ArrayList<Object>) objectIter
.next();
Class cls = null;
15 years, 2 months
teiid SVN: r2649 - branches/7.1.x/console/src/main/resources/META-INF.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-10-14 11:17:20 -0400 (Thu, 14 Oct 2010)
New Revision: 2649
Modified:
branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-982: Text changes to Mat view operation names and parameter descriptions
Modified: branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-14 14:29:39 UTC (rev 2648)
+++ branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-14 15:17:20 UTC (rev 2649)
@@ -469,13 +469,13 @@
</results>
</operation>
- <operation name="getMaterializedViews" displayName="Get Materialized View Info"
- description="Get any Materialized Views for this VDB">
+ <operation name="getMaterializedViews" displayName="List Materialized View Info"
+ description="List any Materialized Views for this VDB">
<results>
- <c:list-property name="list" displayName=" Materialized Views"
- description="Get information related to Materialized Views, if any, for this VDB"
+ <c:list-property name="list" displayName="Materialized Views"
+ description="List information related to Materialized Views, if any, for this VDB"
required="false">
<c:map-property name="map">
<c:simple-property displayName="Schema Name"
@@ -486,7 +486,7 @@
name="targetSchemaName" type="string" description="Name of the materialized schema" />
<c:simple-property displayName="Target Name"
name="targetName" type="string" description="Name of target table" />
- <c:simple-property displayName="Is Valid"
+ <c:simple-property displayName="Valid"
name="valid" type="string" description="Indicates if data in table is valid for use" />
<c:simple-property displayName="Current State"
name="loadState" type="string" description="Processing time for the request" />
@@ -510,7 +510,7 @@
description="The name of the Materialized View to refresh" />
<c:simple-property displayName="Invalidate Current Materialized View Table"
name="invalidate" type="boolean" required="true" default="false"
- description="If yes, will block all queries against the current Materialized View table until refreshed." />
+ description="If yes, will block all queries against the current Materialized View table until data is refreshed." />
</parameters>
<results>
15 years, 2 months
teiid SVN: r2648 - branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-14 10:29:39 -0400 (Thu, 14 Oct 2010)
New Revision: 2648
Modified:
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
Log:
TEIID-1303 fix for sybase timestamp to string and full outer join handling. also updated literal handling to work with JTDS
Modified: branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-10-13 22:00:11 UTC (rev 2647)
+++ branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-10-14 14:29:39 UTC (rev 2648)
@@ -487,11 +487,11 @@
// Source = TIME
@Test public void testTimeToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "to_char({ts '1970-01-01 23:59:59'}, 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "to_char(to_date('1970-01-01 23:59:59', 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTimeToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "cast({ts '1970-01-01 23:59:59'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "cast(to_date('1970-01-01 23:59:59', 'YYYY-MM-DD HH24:MI:SS') AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIMESTAMP
15 years, 2 months
teiid SVN: r2647 - branches/7.1.x/console/src/main/resources/META-INF.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-10-13 18:00:11 -0400 (Wed, 13 Oct 2010)
New Revision: 2647
Modified:
branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-982: Changed verbiage and column heading
Modified: branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-13 16:42:50 UTC (rev 2646)
+++ branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-13 22:00:11 UTC (rev 2647)
@@ -486,7 +486,7 @@
name="targetSchemaName" type="string" description="Name of the materialized schema" />
<c:simple-property displayName="Target Name"
name="targetName" type="string" description="Name of target table" />
- <c:simple-property displayName="Created Time"
+ <c:simple-property displayName="Is Valid"
name="valid" type="string" description="Indicates if data in table is valid for use" />
<c:simple-property displayName="Current State"
name="loadState" type="string" description="Processing time for the request" />
@@ -505,12 +505,12 @@
<c:simple-property displayName="Materialized View Schema"
name="schema" type="string" required="true"
description="The schema name of the Materialized View to refresh" />
- <c:simple-property displayName="Materialized View Table"
+ <c:simple-property displayName="Materialized View Name"
name="table" type="string" required="true"
- description="The table name of the Materialized View to refresh" />
- <c:simple-property displayName="Invalidate Current Materialized View"
- name="invalidate" type="boolean" required="true"
- description="If true, will invalidate the current Materialized View" />
+ description="The name of the Materialized View to refresh" />
+ <c:simple-property displayName="Invalidate Current Materialized View Table"
+ name="invalidate" type="boolean" required="true" default="false"
+ description="If yes, will block all queries against the current Materialized View table until refreshed." />
</parameters>
<results>
15 years, 3 months
teiid SVN: r2646 - in branches/7.1.x: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access and 5 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-13 12:42:50 -0400 (Wed, 13 Oct 2010)
New Revision: 2646
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
Log:
TEIID-1303 fix for sybase timestamp to string and full outer join handling. also updated literal handling to work with JTDS
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-10-13 15:46:43 UTC (rev 2645)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-10-13 16:42:50 UTC (rev 2646)
@@ -603,7 +603,7 @@
*/
public String translateLiteralTime(Time timeValue) {
if (!hasTimeType()) {
- return "{ts '1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return translateLiteralTimestamp(new Timestamp(timeValue.getTime()));
}
return "{t '" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-10-13 15:46:43 UTC (rev 2645)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-10-13 16:42:50 UTC (rev 2646)
@@ -38,6 +38,7 @@
public AccessExecutionFactory() {
setSupportsOrderBy(false);
+ setDatabaseVersion("2003"); //$NON-NLS-1$
}
@Override
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2010-10-13 15:46:43 UTC (rev 2645)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2010-10-13 16:42:50 UTC (rev 2646)
@@ -24,6 +24,7 @@
*/
package org.teiid.translator.jdbc.sqlserver;
+import java.sql.Time;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -204,5 +205,9 @@
public boolean booleanNullable() {
return true;
}
-
+
+ public boolean hasTimeType() {
+ return getDatabaseVersion().compareTo(V_2005) >= 0;
+ }
+
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2010-10-13 15:46:43 UTC (rev 2645)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2010-10-13 16:42:50 UTC (rev 2646)
@@ -25,11 +25,14 @@
package org.teiid.translator.jdbc.sybase;
import java.sql.CallableStatement;
+import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.LinkedList;
import java.util.List;
import org.teiid.language.Command;
@@ -37,10 +40,10 @@
import org.teiid.language.Limit;
import org.teiid.language.OrderBy;
import org.teiid.language.SetQuery;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
@@ -60,6 +63,7 @@
public SybaseExecutionFactory() {
setDatabaseVersion(TWELVE_5);
+ setSupportsFullOuterJoins(false);
}
public void start() throws TranslatorException {
@@ -173,13 +177,13 @@
return Arrays.asList("stuff(stuff(convert(varchar, ", function.getParameters().get(0), ", 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- /**
- * Written to only support version 15
- * @param function
- * @return
- */
+ //TODO: this looses the milliseconds
protected List<?> convertTimestampToString(Function function) {
- return Arrays.asList("stuff(convert(varchar, ", function.getParameters().get(0), ", 123), 11, 1, ' ')"); //$NON-NLS-1$ //$NON-NLS-2$
+ LinkedList<Object> result = new LinkedList<Object>();
+ result.addAll(convertDateToString(function));
+ result.add(' ');
+ result.addAll(convertTimeToString(function));
+ return result;
}
@Override
@@ -365,4 +369,15 @@
}
super.bindValue(stmt, param, paramType, i);
}
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "CAST('" + formatDateValue(timestampValue) +"' AS DATETIME)"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "CAST('" + formatDateValue(dateValue) +"' AS DATE)"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-10-13 15:46:43 UTC (rev 2645)
+++ branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-10-13 16:42:50 UTC (rev 2646)
@@ -559,7 +559,7 @@
helpTestVisitor(getTestVDB(),
"select {t '13:59:59'} FROM parts", //$NON-NLS-1$
null,
- "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT to_date('1970-01-01 13:59:59', 'YYYY-MM-DD HH24:MI:SS') FROM PARTS"); //$NON-NLS-1$
}
@Test public void testTimestampLiteral() throws Exception {
Modified: branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-10-13 15:46:43 UTC (rev 2645)
+++ branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-10-13 16:42:50 UTC (rev 2646)
@@ -105,7 +105,7 @@
LANG_FACTORY.createLiteral("date", String.class)}, //$NON-NLS-1$
java.sql.Date.class);
- helpGetString1(func, "cast(stuff(stuff(convert(varchar, {ts '1989-03-03 07:08:12.0'}, 102), 5, 1, '-'), 8, 1, '-') AS datetime)"); //$NON-NLS-1$
+ helpGetString1(func, "cast(stuff(stuff(convert(varchar, CAST('1989-03-03 07:08:12.0' AS DATETIME), 102), 5, 1, '-'), 8, 1, '-') AS datetime)"); //$NON-NLS-1$
}
/********************END of cast(date AS INPUT) ******************/
@@ -129,7 +129,7 @@
LANG_FACTORY.createLiteral("time", String.class)}, //$NON-NLS-1$
java.sql.Time.class);
- helpGetString1(func, "cast('1970-01-01 ' + convert(varchar, {ts '1989-03-03 07:08:12.0'}, 8) AS datetime)"); //$NON-NLS-1$
+ helpGetString1(func, "cast('1970-01-01 ' + convert(varchar, CAST('1989-03-03 07:08:12.0' AS DATETIME), 8) AS datetime)"); //$NON-NLS-1$
}
/********************END of cast(time AS INPUT) ******************/
@@ -152,7 +152,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "{ts '1970-01-01 12:02:03'}"); //$NON-NLS-1$
+ helpGetString1(func, "CAST('1970-01-01 12:02:03.0' AS DATETIME)"); //$NON-NLS-1$
}
@Test public void testDateToTimestamp() throws Exception {
@@ -162,7 +162,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "{d '1989-03-03'}"); //$NON-NLS-1$
+ helpGetString1(func, "CAST('1989-03-03' AS DATE)"); //$NON-NLS-1$
}
/********************END of cast(timestamp AS INPUT) ******************/
@@ -185,7 +185,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "stuff(convert(varchar, {ts '2003-11-01 12:05:02.0'}, 123), 11, 1, ' ')"); //$NON-NLS-1$
+ helpGetString1(func, "stuff(stuff(convert(varchar, CAST('2003-11-01 12:05:02.0' AS DATETIME), 102), 5, 1, '-'), 8, 1, '-') convert(varchar, CAST('2003-11-01 12:05:02.0' AS DATETIME), 8)"); //$NON-NLS-1$
}
@Test public void testDateToString() throws Exception {
@@ -196,7 +196,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "stuff(stuff(convert(varchar, {d '2003-11-01'}, 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$
+ helpGetString1(func, "stuff(stuff(convert(varchar, CAST('2003-11-01' AS DATE), 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$
}
@Test public void testTimeToString() throws Exception {
@@ -207,7 +207,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "convert(varchar, {ts '1970-01-01 03:10:01'}, 8)"); //$NON-NLS-1$
+ helpGetString1(func, "convert(varchar, CAST('1970-01-01 03:10:01.0' AS DATETIME), 8)"); //$NON-NLS-1$
}
@Test public void testBigDecimalToString() throws Exception {
Modified: branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-10-13 15:46:43 UTC (rev 2645)
+++ branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-10-13 16:42:50 UTC (rev 2646)
@@ -189,21 +189,21 @@
public void testDateLiteral() {
helpTestVisitor(getTestVDB(),
"select {d '2002-12-31'} FROM parts", //$NON-NLS-1$
- "SELECT {d '2002-12-31'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT CAST('2002-12-31' AS DATE) FROM PARTS"); //$NON-NLS-1$
}
@Test
public void testTimeLiteral() {
helpTestVisitor(getTestVDB(),
"select {t '13:59:59'} FROM parts", //$NON-NLS-1$
- "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT CAST('1970-01-01 13:59:59.0' AS DATETIME) FROM PARTS"); //$NON-NLS-1$
}
@Test
public void testTimestampLiteral() {
helpTestVisitor(getTestVDB(),
"select {ts '2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
- "SELECT {ts '2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT CAST('2002-12-31 13:59:59.0' AS DATETIME) FROM PARTS"); //$NON-NLS-1$
}
@Test
Modified: branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
--- branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-10-13 15:46:43 UTC (rev 2645)
+++ branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-10-13 16:42:50 UTC (rev 2646)
@@ -1206,8 +1206,9 @@
<para>Subqueries supported in the criteria of the outer query include subqueries in an IN clause, subqueries using the ANY/SOME or ALL predicate quantifier, and subqueries using the EXISTS predicate. </para>
<example>
<title>Example Subquery in WHERE Using EXISTS</title>
- <programlisting>SELECT a FROM X WHERE EXISTS (SELECT b, c FROM Y WHERE c=3)</programlisting>
+ <programlisting>SELECT a FROM X WHERE EXISTS (SELECT 1 FROM Y WHERE c=X.a)</programlisting>
</example>
+ <note><para>EXISTS subqueries should typically follow the convention "SELECT 1 FROM ..." to prevent unnecessary evaluation of select expressions.</para></note>
<para>
The following usages of subqueries must each select only one column, but can return any number of rows.
</para>
15 years, 3 months
teiid SVN: r2645 - in trunk/engine/src/test/java/org/teiid: query/validator and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-10-13 11:46:43 -0400 (Wed, 13 Oct 2010)
New Revision: 2645
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1273, TEIID-1295, TEIID-1296:fixing the tests
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2010-10-12 20:23:14 UTC (rev 2644)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2010-10-13 15:46:43 UTC (rev 2645)
@@ -123,15 +123,15 @@
}
public void testInsertMatching() throws Exception {
- helpTest("INSERT INTO MultiModel.Phys(a, SOURCE_NAME) VALUES('a', 'x')", //$NON-NLS-1$
+ helpTest("INSERT INTO MultiModel.Phys(a, SOURCE_NAME) VALUES ('a', 'x')", //$NON-NLS-1$
getMetadata(),
- "INSERT INTO MultiModel.Phys (a, SOURCE_NAME) SELECT a WHERE '1' = '2'"); //$NON-NLS-1$
+ "INSERT INTO MultiModel.Phys (a) VALUES ('a')"); //$NON-NLS-1$
}
public void testInsertNotMatching() throws Exception {
- helpTest("INSERT INTO MultiModel.Phys(a, SOURCE_NAME) VALUES('a', 'y')", //$NON-NLS-1$
+ helpTest("INSERT INTO MultiModel.Phys(a, SOURCE_NAME) VALUES ('a', 'y')", //$NON-NLS-1$
getMetadata(),
- "INSERT INTO MultiModel.Phys (a, SOURCE_NAME) SELECT a WHERE '1' = '2'"); //$NON-NLS-1$
+ "INSERT INTO MultiModel.Phys (a) SELECT a FROM MultiModel.Phys WHERE 1 = 0"); //$NON-NLS-1$
}
public void testInsertAll() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-10-12 20:23:14 UTC (rev 2644)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-10-13 15:46:43 UTC (rev 2645)
@@ -2036,7 +2036,7 @@
@Test public void testDisallowUpdateOnMultisourceElement() throws Exception {
Set<String> models = new HashSet<String>();
models.add("pm1");
- ValidatorReport report = helpValidateInModeler("pm1.vsp36", "UPDATE PM1.G1 set SOURCE_NAME='blah'", new MultiSourceMetadataWrapper(FakeMetadataFactory.example1Cached(), models)); //$NON-NLS-1$
+ ValidatorReport report = helpValidateInModeler("pm1.vsp36", "UPDATE PM1.G1 set SOURCE_NAME='blah'", new MultiSourceMetadataWrapper(FakeMetadataFactory.example1(), models)); //$NON-NLS-1$
assertEquals(report.toString(), 1, report.getItems().size());
}
}
15 years, 3 months
teiid SVN: r2644 - in trunk: engine/src/main/java/org/teiid/dqp/internal/process/multisource and 5 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-10-12 16:23:14 -0400 (Tue, 12 Oct 2010)
New Revision: 2644
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1273, TEIID-1295, TEIID-1296: multi-source insert capability is added. Also corrected update count and mark them as transactional when more than single source is involved.
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-10-12 20:23:14 UTC (rev 2644)
@@ -1229,7 +1229,7 @@
<para>
To mark a model as multi-source, the user needs to supply property called
<property>supports-multi-source-bindings</property>, in the "vdb.xml" file.
- Also, the user needs to define multiple sources. Here is code example showing single model with
+ Also, the user needs to define multiple sources. Here is code example showing dynamic vdb with single model with
multiple sources defined.
</para>
@@ -1258,12 +1258,13 @@
<programlisting language="SQL"><![CDATA[select * from table where SOURCE_NAME = 'newyork'
update table column=value where SOURCE_NAME='chicago'
-delete from table where column = x and SOURCE_NAME='la']]></programlisting>
+delete from table where column = x and SOURCE_NAME='la'
+insert into table (column, SOURCE_NAME) VALUES ('value', 'newyork')]]></programlisting>
<para>
- Note that when user do not supply the "SOURCE_NAME" in the criteria, it applies
- to all the sources. Unfortunately Teiid currently does not support INSERT, this
- planned for future releases. Another useful feature along with this feature is
+ Note that when user do not supply the "SOURCE_NAME" in the criteria, the command applies
+ to all the sources. If SOURCE_NAME supplied, the query is executed only aginst the source specified.
+ Another useful feature along with this feature is
"partial results" to skip unavailable sources if they are down.
</para>
@@ -1273,7 +1274,7 @@
limited, so if you need to use this feature build the VDB as usual in
the Teiid Designer and then edit the "vdb.xml" file in the VDB archive
using a Text editor to add the additional sources as defined above.
- You must deploy a data source for each source defined.
+ You must deploy a separate data source for each source defined in the xml file.
</para>
</note>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -23,6 +23,11 @@
package org.teiid.dqp.internal.process.multisource;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -50,4 +55,29 @@
return expr;
}
+
+ public void visit(Insert obj) {
+ for (int i = 0; i < obj.getVariables().size(); i++) {
+ Expression expr = (Expression)obj.getVariables().get(i);
+ if(expr instanceof ElementSymbol) {
+ ElementSymbol elem = (ElementSymbol) expr;
+ Object metadataID = elem.getMetadataID();
+ if(metadataID instanceof MultiSourceElement) {
+ Constant source = (Constant)obj.getValues().get(i);
+ obj.getVariables().remove(i);
+ obj.getValues().remove(i);
+ if (!source.getValue().equals(this.bindingName)) {
+ Select select = new Select(obj.getVariables());
+ From from = new From();
+ from.addGroup(obj.getGroup());
+ Query query = new Query();
+ query.setSelect(select);
+ query.setFrom(from);
+ query.setCriteria(QueryRewriter.FALSE_CRITERIA);
+ obj.setQueryExpression(query);
+ }
+ }
+ }
+ }
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -271,7 +271,7 @@
case SupportConstants.Element.SELECT:
return true;
case SupportConstants.Element.UPDATE:
- return false;
+ return true;
case SupportConstants.Element.DEFAULT_VALUE:
return false;
case SupportConstants.Element.AUTO_INCREMENT:
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -33,20 +33,31 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.id.IDGenerator;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.relational.PlanToProcessConverter;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.GroupingNode;
import org.teiid.query.processor.relational.NullNode;
+import org.teiid.query.processor.relational.ProjectNode;
import org.teiid.query.processor.relational.RelationalNode;
import org.teiid.query.processor.relational.RelationalNodeUtil;
import org.teiid.query.processor.relational.UnionAllNode;
+import org.teiid.query.resolver.util.ResolverVisitor;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
import org.teiid.query.util.CommandContext;
@@ -102,6 +113,10 @@
// Replace all multi-source elements with the source name
DeepPreOrderNavigator.doVisit(command, new MultiSourceElementReplacementVisitor(sourceName));
+ if (!RelationalNodeUtil.shouldExecute(command, false)) {
+ continue;
+ }
+
// Rewrite the command now that criteria may have been simplified
try {
command = QueryRewriter.rewrite(command, metadata, null);
@@ -133,17 +148,44 @@
}
default:
{
- // More than 1 access node - replace with a union
+
+ UnionAllNode unionNode = new UnionAllNode(getID());
+ unionNode.setElements(accessNode.getElements());
- UnionAllNode unionNode = new UnionAllNode(getID());
- unionNode.setElements(accessNode.getElements());
-
- RelationalNode parent = unionNode;
-
for (AccessNode newNode : accessNodes) {
- unionNode.addChild(newNode);
+ unionNode.addChild(newNode);
}
+
+ RelationalNode parent = unionNode;
+
+ // More than 1 access node - replace with a union
+ if (RelationalNodeUtil.isUpdate(accessNode.getCommand())) {
+
+ GroupingNode groupNode = new GroupingNode(getID());
+ AggregateSymbol sumCount = new AggregateSymbol("SumCount", NonReserved.SUM, false, (Expression)accessNode.getElements().get(0)); //$NON-NLS-1$
+ List outputElements = new ArrayList();
+ outputElements.add(sumCount);
+ groupNode.setElements(outputElements);
+ groupNode.addChild(unionNode);
+
+ ProjectNode projectNode = new ProjectNode(getID());
+ // two converts because, the 2nd one does not resolve because of no metadata about the expression.
+ Function convertFunc = new Function(FunctionLibrary.CONVERT, new Expression[] {new Constant(new Long(0)), new Constant(DataTypeManager.DefaultDataTypes.INTEGER)});
+ ResolverVisitor.resolveLanguageObject(convertFunc, metadata);
+ Function convertFunc2 = new Function(FunctionLibrary.CONVERT, new Expression[] {sumCount, new Constant(DataTypeManager.DefaultDataTypes.INTEGER)});
+ convertFunc2.setFunctionDescriptor(convertFunc.getFunctionDescriptor());
+
+ Expression rowCount = new ExpressionSymbol("RowCount", convertFunc2); //$NON-NLS-1$
+ outputElements = new ArrayList();
+ outputElements.add(rowCount);
+ projectNode.setElements(outputElements);
+ projectNode.setSelectSymbols(outputElements);
+ projectNode.addChild(groupNode);
+
+ parent = projectNode;
+ }
+ parent.setMultiSource(true);
return parent;
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -87,6 +87,8 @@
/** Child nodes, usually just 1 or 2 */
private RelationalNode[] children = new RelationalNode[2];
+
+ private boolean multiSource;
protected RelationalNode() {
@@ -596,4 +598,12 @@
}
return processingState;
}
+
+ public boolean isMultiSource() {
+ return multiSource;
+ }
+
+ public void setMultiSource(boolean multiSource) {
+ this.multiSource = multiSource;
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -29,6 +29,7 @@
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.lang.Limit;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.QueryCommand;
@@ -123,6 +124,13 @@
return true;
}
break;
+ case Command.TYPE_INSERT:
+ Insert insert = (Insert) command;
+ QueryCommand expr = insert.getQueryExpression();
+ if (expr != null) {
+ return shouldExecute(expr, simplifyCriteria);
+ }
+ return true;
case Command.TYPE_UPDATE:
Update update = (Update) command;
@@ -174,7 +182,7 @@
* @return
* @since 4.2
*/
- static boolean isUpdate(Command command) {
+ public static boolean isUpdate(Command command) {
int commandType = command.getType();
return commandType == Command.TYPE_INSERT ||
commandType == Command.TYPE_UPDATE ||
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -239,6 +239,9 @@
}
}
}
+ if (this.root.isMultiSource()) {
+ return true;
+ }
return requiresTransaction(transactionalReads, root);
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -42,6 +42,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.FunctionLibrary;
@@ -788,7 +789,8 @@
ElementSymbol nextElmnt = (ElementSymbol) ignoreIter.next();
if(!getMetadata().elementSupports(nextElmnt.getMetadataID(), SupportConstants.Element.DEFAULT_VALUE) &&
!getMetadata().elementSupports(nextElmnt.getMetadataID(), SupportConstants.Element.NULL) &&
- !getMetadata().elementSupports(nextElmnt.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT)) {
+ !getMetadata().elementSupports(nextElmnt.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT) &&
+ !(nextElmnt.getMetadataID() instanceof MultiSourceElement)) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0053", new Object[] {insertGroup, nextElmnt}), nextElmnt); //$NON-NLS-1$
}
}
@@ -843,6 +845,11 @@
if(! getMetadata().elementSupports(elementID.getMetadataID(), SupportConstants.Element.UPDATE)) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0059", elementID), elementID); //$NON-NLS-1$
}
+
+ Object metadataID = elementID.getMetadataID();
+ if (metadataID instanceof MultiSourceElement){
+ handleValidationError(QueryPlugin.Util.getString("multi_source_update_not_allowed", elementID), elementID); //$NON-NLS-1$
+ }
// Check that right expression is a constant and is non-null
Expression value = entry.getValue();
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-10-12 20:23:14 UTC (rev 2644)
@@ -860,4 +860,5 @@
RequestWorkItem.cache_nondeterministic=Caching command '{0}'' at a session level, but less deterministic functions were evaluated.
not_found_cache=Results not found in cache
failed_to_unwrap_connection=Failed to unwrap the source connection.
-connection_factory_not_found=Failed to the Connection Factory with JNDI name {0}. Please check the name for spelling or deploy the Connection Factory with specified name.
\ No newline at end of file
+connection_factory_not_found=Failed to the Connection Factory with JNDI name {0}. Please check the name for spelling or deploy the Connection Factory with specified name.
+multi_source_update_not_allowed=Update of the column {0} is not allowed.
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -45,7 +45,7 @@
QueryMetadataInterface metadata = FakeMetadataFactory.exampleMultiBinding();
Set<String> multiSourceModels = new HashSet<String>();
- multiSourceModels.add("MultiModel");
+ multiSourceModels.add("MultiModel"); //$NON-NLS-1$
MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
return wrapper;
@@ -121,5 +121,23 @@
getMetadata(),
"SELECT a FROM MultiModel.Phys WHERE 'x' = (SELECT b FROM MultiModel.Phys WHERE 'x' IN ('x'))"); //$NON-NLS-1$
}
+
+ public void testInsertMatching() throws Exception {
+ helpTest("INSERT INTO MultiModel.Phys(a, SOURCE_NAME) VALUES('a', 'x')", //$NON-NLS-1$
+ getMetadata(),
+ "INSERT INTO MultiModel.Phys (a, SOURCE_NAME) SELECT a WHERE '1' = '2'"); //$NON-NLS-1$
+ }
+
+ public void testInsertNotMatching() throws Exception {
+ helpTest("INSERT INTO MultiModel.Phys(a, SOURCE_NAME) VALUES('a', 'y')", //$NON-NLS-1$
+ getMetadata(),
+ "INSERT INTO MultiModel.Phys (a, SOURCE_NAME) SELECT a WHERE '1' = '2'"); //$NON-NLS-1$
+ }
+
+ public void testInsertAll() throws Exception {
+ helpTest("INSERT INTO MultiModel.Phys(a) VALUES('a')", //$NON-NLS-1$
+ getMetadata(),
+ "INSERT INTO MultiModel.Phys (a) VALUES ('a')"); //$NON-NLS-1$
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-10-12 18:04:46 UTC (rev 2643)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-10-12 20:23:14 UTC (rev 2644)
@@ -22,7 +22,9 @@
package org.teiid.query.validator;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,6 +46,7 @@
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.mapping.xml.MappingDocument;
@@ -2030,4 +2033,10 @@
helpValidate("SELECT e2, (SELECT e1, e2 FROM pm1.g1 WHERE e2 = '3') FROM pm1.g2", new String[] {"SELECT e1, e2 FROM pm1.g1 WHERE e2 = '3'"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @Test public void testDisallowUpdateOnMultisourceElement() throws Exception {
+ Set<String> models = new HashSet<String>();
+ models.add("pm1");
+ ValidatorReport report = helpValidateInModeler("pm1.vsp36", "UPDATE PM1.G1 set SOURCE_NAME='blah'", new MultiSourceMetadataWrapper(FakeMetadataFactory.example1Cached(), models)); //$NON-NLS-1$
+ assertEquals(report.toString(), 1, report.getItems().size());
+ }
}
15 years, 3 months
teiid SVN: r2643 - in branches/7.1.x: engine/src/main/java/org/teiid/query/function and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-12 14:04:46 -0400 (Tue, 12 Oct 2010)
New Revision: 2643
Modified:
branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
Log:
TEIID-950 merging ENV function changes.
Modified: branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-10-12 16:39:25 UTC (rev 2642)
+++ branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-10-12 18:04:46 UTC (rev 2643)
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
<chapter id="scalar_functions">
<title>Scalar Functions</title>
<para>
@@ -1862,9 +1865,10 @@
<para><code>ENV(key)</code></para>
</entry>
<entry>
- <para>Retrieve an environment property. The only key
- currently allowed is ‘sessionid’, although this will expand
- in the future.</para>
+ <para>Retrieve a system environment property. The only key specific to the current session is ‘sessionid’.
+ However the preferred mechanism for getting the session id is with the session_id() function.
+ To prevent untrusted access to system properties, the use of this function must be specifically enabled in the &jboss-beans; file.
+ </para>
</entry>
<entry>
<para>key in {string}, return is string</para>
@@ -1872,6 +1876,17 @@
</row>
<row>
<entry>
+ <para><code>SESSION_ID()</code></para>
+ </entry>
+ <entry>
+ <para>Retrieve the string form of the current session id.</para>
+ </entry>
+ <entry>
+ <para>return is string</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para><code>USER()</code></para>
</entry>
<entry>
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-10-12 16:39:25 UTC (rev 2642)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-10-12 18:04:46 UTC (rev 2643)
@@ -56,7 +56,6 @@
import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.query.QueryPlugin;
import org.teiid.query.util.CommandContext;
-import org.teiid.query.util.ContextProperties;
/**
* Static method hooks for most of the function library.
@@ -1242,11 +1241,7 @@
}
public static Object session_id(CommandContext context) {
- Properties envProps = context.getEnvironmentProperties();
- if(envProps != null && envProps.containsKey(ContextProperties.SESSION_ID)) {
- return envProps.getProperty(ContextProperties.SESSION_ID);
- }
- return null;
+ return context.getConnectionID();
}
// ================= Function - MODIFYTIMEZONE ========================
15 years, 3 months