teiid SVN: r2771 - in branches/7.1.x/engine/src/test/java/org/teiid/query: validator and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-13 13:10:54 -0500 (Mon, 13 Dec 2010)
New Revision: 2771
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
branches/7.1.x/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1346 preventing translate criteria from throwing exceptions in what used to be common cases.
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-12-13 18:09:50 UTC (rev 2770)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-12-13 18:10:54 UTC (rev 2771)
@@ -1246,8 +1246,7 @@
return procedure;
}
- // virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- @Test(expected=QueryValidatorException.class) public void testRewriteProcedure17() throws Exception {
+ @Test public void testRewriteProcedure17() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1397,8 +1396,7 @@
assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
}
- // elements being set in updates are dropped if INPUT var is not available
- @Test(expected=QueryValidatorException.class) public void testRewriteProcedure24() throws Exception {
+ @Test public void testRewriteProcedure24() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "UPDATE pm1.g1 SET e2=Input.e2 WHERE TRANSLATE LIKE CRITERIA ON (e1) WITH (e1=concat(pm1.g1.e1, '%'));\n"; //$NON-NLS-1$
@@ -1452,8 +1450,7 @@
assertEquals("Rewritten command was not expected", rewritProc, procReturned); //$NON-NLS-1$
}
- // virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- @Test(expected=QueryValidatorException.class) public void testRewriteProcedure27() throws Exception {
+ @Test public void testRewriteProcedure27() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-12-13 18:09:50 UTC (rev 2770)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-12-13 18:10:54 UTC (rev 2771)
@@ -688,10 +688,6 @@
helpValidate("UPDATE test.group SET e0=1, e0=2", new String[] {"e0"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testUpdateSubqueryCriteria() {
- helpValidate("UPDATE vm1.g1 SET e1=1 WHERE exists (select * from vm1.g1)" , new String[] {"EXISTS (SELECT * FROM vm1.g1)"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
@Test public void testUpdate3() throws Exception {
QueryMetadataInterface metadata = exampleMetadata();
@@ -1357,21 +1353,7 @@
helpValidateProcedure(procedure, userQuery,
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
-
- @Test public void testCreateUpdateProcedure28() {
- String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
- procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "Select pm1.g2.e2 from pm1.g2 where TRANSLATE CRITERIA;\n"; //$NON-NLS-1$
- procedure = procedure + "ROWS_UPDATED =0;\n"; //$NON-NLS-1$
- procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "UPDATE vm1.g3 SET x='x' where y = 1 or y = 2"; //$NON-NLS-1$
-
- helpFailProcedure(procedure, userQuery,
- FakeMetadataObject.Props.UPDATE_PROCEDURE);
- }
-
// using aggregate function within a procedure - defect #8394
@Test public void testCreateUpdateProcedure31() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
14 years, 3 months
teiid SVN: r2770 - in branches/7.1.x: engine/src/main/java/org/teiid/query/rewriter and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-13 13:09:50 -0500 (Mon, 13 Dec 2010)
New Revision: 2770
Modified:
branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/procedures.xml
branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
branches/7.1.x/engine/src/main/java/org/teiid/query/sql/visitor/CriteriaTranslatorVisitor.java
branches/7.1.x/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties
Log:
TEIID-1346 preventing translate criteria from throwing exceptions in what used to be common cases.
Modified: branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/procedures.xml
===================================================================
--- branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/procedures.xml 2010-12-13 17:55:26 UTC (rev 2769)
+++ branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/procedures.xml 2010-12-13 18:09:50 UTC (rev 2770)
@@ -513,6 +513,7 @@
</para>
</listitem>
</itemizedlist>
+ <para>Each unoptimized conjunct of the user criteria is evaluated against the criteria selector. If any conjunct matches then HAS CRITERIA evaluates to TRUE. The use of OR or NOT will prevent contained predicates from matching the criteria selector.</para>
<para>Some samples of the HAS CRITERIA clause:</para>
<informaltable>
<tgroup cols="2">
@@ -579,6 +580,7 @@
</para>
</listitem>
</itemizedlist>
+ <para>Each unoptimized conjunct of the user criteria is translated using the criteria selector. If a conjunct does not match the selector, it will not be translated - which effectively treats the conjunct as TRUE. The use of OR or NOT will prevent contained predicates from matching the criteria selector.</para>
<para>Some samples of TRANSLATE CRITERIA:</para>
<informaltable>
<tgroup cols="2">
@@ -606,7 +608,6 @@
</tbody>
</tgroup>
</informaltable>
- <note><para>If a specific predicate type or column set is specified by TRANSALATE CRITERIA, but the user criteria has predicates that do not match, then an exception will be thrown.</para></note>
</section>
</section>
<section>
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-12-13 17:55:26 UTC (rev 2769)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-12-13 18:09:50 UTC (rev 2770)
@@ -146,7 +146,6 @@
import org.teiid.query.sql.visitor.ElementCollectorVisitor;
import org.teiid.query.sql.visitor.EvaluatableVisitor;
import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
-import org.teiid.query.sql.visitor.PredicateCollectorVisitor;
import org.teiid.query.sql.visitor.EvaluatableVisitor.EvaluationLevel;
import org.teiid.query.util.CommandContext;
import org.teiid.translator.SourceSystemFunctions;
@@ -466,9 +465,7 @@
}
// collect all predicate criteria present on the user's criteria
- Iterator criteriaIter = PredicateCollectorVisitor.getPredicates(userCrit).iterator();
- while(criteriaIter.hasNext()) {
- Criteria predicateCriteria = (Criteria) criteriaIter.next();
+ for (Criteria predicateCriteria : Criteria.separateCriteriaByAnd(userCrit)) {
// atleast one of the hasElemnets should be on this predicate else
// proceed to the next predicate
Collection<ElementSymbol> predElmnts = ElementCollectorVisitor.getElements(predicateCriteria, true);
@@ -562,7 +559,7 @@
// create a clone of user's criteria that is then translated
Criteria userClone = (Criteria) userCriteria.clone();
- translateVisitor.translate(userClone);
+ userClone = translateVisitor.translate(userClone);
// translated criteria
((TranslatableProcedureContainer)userCmd).addImplicitParameters(translateVisitor.getImplicitParams());
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/sql/visitor/CriteriaTranslatorVisitor.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/sql/visitor/CriteriaTranslatorVisitor.java 2010-12-13 17:55:26 UTC (rev 2769)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/sql/visitor/CriteriaTranslatorVisitor.java 2010-12-13 18:09:50 UTC (rev 2770)
@@ -25,20 +25,20 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.Map;
-import org.teiid.api.exception.query.QueryValidatorException;
-import org.teiid.core.TeiidRuntimeException;
+import net.sf.saxon.query.QueryReader;
+
import org.teiid.core.util.Assertion;
-import org.teiid.query.QueryPlugin;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.AbstractSetCriteria;
import org.teiid.query.sql.lang.BetweenCriteria;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.lang.DependentSetCriteria;
import org.teiid.query.sql.lang.IsNullCriteria;
import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.SetCriteria;
-import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.navigator.DeepPostOrderNavigator;
import org.teiid.query.sql.proc.CriteriaSelector;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -49,106 +49,11 @@
* <p> This class is used to translate criteria specified on the user's update command against
* the virtual group, the elements on this criteria are replaced by elements on the query
* transformation that defines the virtual group. Parts of the criteria are selectively translated
- * if a CriteriaSelector is specified, also if the user explicty defines translations for some
+ * if a CriteriaSelector is specified, also if the user explicitly defines translations for some
* of the elements those translations override any symbol mappings.</p>
*/
public class CriteriaTranslatorVisitor extends ExpressionMappingVisitor {
- class CriteriaTranslatorNavigator extends PreOrderNavigator {
-
- public CriteriaTranslatorNavigator() {
- super(CriteriaTranslatorVisitor.this);
- }
-
- /**
- * <p> This method updates the <code>BetweenCriteria</code> object it receives as an
- * argument by replacing the virtual elements present in the expressions in the
- * function with translated expressions.</p>
- * @param obj The BetweenCriteria object to be updated with translated expressions
- */
- public void visit(BetweenCriteria obj) {
- if (!selectorContainsCriteriaElements(obj, CriteriaSelector.BETWEEN)) {
- throw new TeiidRuntimeException(new QueryValidatorException(QueryPlugin.Util.getString("Translate.error", obj, selector))); //$NON-NLS-1$
- }
- super.visit(obj);
- }
-
- /**
- * <p> This method updates the <code>CompareCriteria</code> object it receives as an
- * argument by replacing the virtual elements present in the expressions in the
- * function with translated expressions.</p>
- * @param obj The CompareCriteria object to be updated with translated expressions
- */
- public void visit(CompareCriteria obj) {
-
- if (!selectorContainsCriteriaElements(obj, obj.getOperator())) {
- throw new TeiidRuntimeException(new QueryValidatorException(QueryPlugin.Util.getString("Translate.error", obj, selector))); //$NON-NLS-1$
- }
-
- super.visit(obj);
- }
-
- /**
- * <p> This method updates the <code>IsNullCriteria</code> object it receives as an
- * argument by replacing the virtual elements present in the expressions in the
- * function with translated expressions.</p>
- * @param obj The IsNullCriteria object to be updated with translated expressions
- */
- public void visit(IsNullCriteria obj) {
-
- if (!selectorContainsCriteriaElements(obj, CriteriaSelector.IS_NULL)) {
- throw new TeiidRuntimeException(new QueryValidatorException(QueryPlugin.Util.getString("Translate.error", obj, selector))); //$NON-NLS-1$
- }
- super.visit(obj);
- }
-
- /**
- * <p> This method updates the <code>MatchCriteria</code> object it receives as an
- * argument by replacing the virtual elements present in the expressions in the
- * function with translated expressions</p>
- * @param obj The SetCriteria object to be updated with translated expressions
- */
- public void visit(MatchCriteria obj) {
-
- if (!selectorContainsCriteriaElements(obj, CriteriaSelector.LIKE)) {
- throw new TeiidRuntimeException(new QueryValidatorException(QueryPlugin.Util.getString("Translate.error", obj, selector))); //$NON-NLS-1$
- }
-
- super.visit(obj);
- }
-
- /**
- * <p> This method updates the <code>SetCriteria</code> object it receives as an
- * argument by replacing the virtual elements present in the expressions in the
- * function with translated expressions</p>
- * @param obj The SetCriteria object to be updated with translated expressions
- */
- public void visit(SetCriteria obj) {
-
- if (!selectorContainsCriteriaElements(obj, CriteriaSelector.IN)) {
- throw new TeiidRuntimeException(new QueryValidatorException(QueryPlugin.Util.getString("Translate.error", obj, selector))); //$NON-NLS-1$
- }
-
- super.visit(obj);
- }
-
- /**
- * <p> This method updates the <code>SetCriteria</code> object it receives as an
- * argument by replacing the virtual elements present in the expressions in the
- * function with translated expressions</p>
- * @param obj The SetCriteria object to be updated with translated expressions
- */
- public void visit(DependentSetCriteria obj) {
-
- if (!selectorContainsCriteriaElements(obj, CriteriaSelector.IN)) {
- throw new TeiidRuntimeException(new QueryValidatorException(QueryPlugin.Util.getString("Translate.error", obj, selector))); //$NON-NLS-1$
- }
-
- super.visit(obj);
- }
-
- }
-
// criteria selector specified on the TranslateCriteria obj
private CriteriaSelector selector;
@@ -158,13 +63,6 @@
private Map<ElementSymbol, Reference> implicitParams = new HashMap<ElementSymbol, Reference>();
/**
- * <p> This constructor initialises the visitor</p>
- */
- public CriteriaTranslatorVisitor() {
- this(null);
- }
-
- /**
* <p> This constructor initializes this object by setting the symbolMap.</p>
* @param symbolMap A map of virtual elements to their counterparts in transform
* defining the virtual group
@@ -251,13 +149,39 @@
return implicitParams;
}
- public void translate(Criteria crit) throws QueryValidatorException {
- CriteriaTranslatorNavigator nav = new CriteriaTranslatorNavigator();
- try {
- crit.acceptVisitor(nav);
- } catch (TeiidRuntimeException e) {
- throw (QueryValidatorException)e.getCause();
+ public Criteria translate(Criteria crit) {
+ LinkedList<Criteria> crits = new LinkedList<Criteria>();
+ for (Criteria conjunct : Criteria.separateCriteriaByAnd(crit)) {
+ if (conjunct instanceof BetweenCriteria) {
+ if (!selectorContainsCriteriaElements(conjunct, CriteriaSelector.BETWEEN)) {
+ continue;
+ }
+ } else if (conjunct instanceof CompareCriteria) {
+ if (!selectorContainsCriteriaElements(conjunct, ((CompareCriteria)conjunct).getOperator())) {
+ continue;
+ }
+ } else if (conjunct instanceof IsNullCriteria) {
+ if (!selectorContainsCriteriaElements(conjunct, CriteriaSelector.IS_NULL)) {
+ continue;
+ }
+ } else if (conjunct instanceof MatchCriteria) {
+ if (!selectorContainsCriteriaElements(conjunct, CriteriaSelector.LIKE)) {
+ continue;
+ }
+ } else if (conjunct instanceof AbstractSetCriteria) {
+ if (!selectorContainsCriteriaElements(conjunct, CriteriaSelector.IN)) {
+ continue;
+ }
+ } else if (!selectorContainsCriteriaElements(conjunct, CriteriaSelector.NO_TYPE)) {
+ continue;
+ }
+ DeepPostOrderNavigator.doVisit(conjunct, this);
+ crits.add(conjunct);
+ }
+ if (crits.isEmpty()) {
+ return QueryRewriter.TRUE_CRITERIA;
}
+ return Criteria.combineCriteria(crits);
}
}
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-12-13 17:55:26 UTC (rev 2769)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-12-13 18:09:50 UTC (rev 2770)
@@ -39,7 +39,6 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.EquivalenceUtil;
@@ -127,6 +126,7 @@
import org.teiid.query.sql.visitor.EvaluatableVisitor;
import org.teiid.query.sql.visitor.FunctionCollectorVisitor;
import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
import org.teiid.query.sql.visitor.PredicateCollectorVisitor;
import org.teiid.query.sql.visitor.SQLStringVisitor;
import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
@@ -195,25 +195,8 @@
validateHasProjectedSymbols(obj);
GroupSymbol group = obj.getGroup();
validateGroupSupportsUpdate(group);
- Criteria crit = obj.getCriteria();
- validateVirtualUpdate(group, crit);
}
- private void validateVirtualUpdate(GroupSymbol group,
- Criteria crit) {
- if (crit == null) {
- return;
- }
- try {
- if (getMetadata().isVirtualGroup(group.getMetadataID()) &&
- !ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(crit).isEmpty()) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.virtual_update_subquery"), crit); //$NON-NLS-1$
- }
- } catch (TeiidException e) {
- handleException(e);
- }
- }
-
public void visit(GroupBy obj) {
// Get list of all group by IDs
List groupBySymbols = obj.getSymbols();
@@ -319,7 +302,6 @@
validateHasProjectedSymbols(obj);
validateGroupSupportsUpdate(obj.getGroup());
validateUpdate(obj);
- validateVirtualUpdate(obj.getGroup(), obj.getCriteria());
}
public void visit(Into obj) {
@@ -585,16 +567,10 @@
}
Collection transleElmnts = ElementCollectorVisitor.getElements(obj, true);
- Collection groups = GroupCollectorVisitor.getGroups(this.currentCommand, true);
+ Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(this.currentCommand, true);
int selectType = obj.getSelector().getSelectorType();
- Collection predicates = PredicateCollectorVisitor.getPredicates(userCrit);
- if (predicates.size() != Criteria.separateCriteriaByAnd(userCrit).size()) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.translated_or"), userCrit); //$NON-NLS-1$
- }
- Iterator critIter = predicates.iterator();
- while(critIter.hasNext()) {
- Criteria predCrit = (Criteria) critIter.next();
+ for (Criteria predCrit : Criteria.separateCriteriaByAnd(userCrit)) {
if(selectType != CriteriaSelector.NO_TYPE) {
if(predCrit instanceof CompareCriteria) {
CompareCriteria ccCrit = (CompareCriteria) predCrit;
@@ -629,16 +605,7 @@
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0022", criteriaElement), criteriaElement); //$NON-NLS-1$
}
- Iterator mapElmntIter = ElementCollectorVisitor.getElements(mappedExpr, true).iterator();
- boolean groupMatch = false;
- while(mapElmntIter.hasNext()) {
- ElementSymbol mapElement = (ElementSymbol) mapElmntIter.next();
- GroupSymbol mapGrp = mapElement.getGroupSymbol();
- if(groups.contains(mapGrp)) {
- groupMatch = true;
- }
- }
- if(!groupMatch) {
+ if (!groups.containsAll(GroupsUsedByElementsVisitor.getGroups(mappedExpr))) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0023", criteriaElement), criteriaElement); //$NON-NLS-1$
}
}
Modified: branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties 2010-12-13 17:55:26 UTC (rev 2769)
+++ branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties 2010-12-13 18:09:50 UTC (rev 2770)
@@ -191,9 +191,7 @@
ValidationVisitor.expression_requires_name = Non-column expressions require a name in XMLATTRIBUTES, XMLFOREST, or QUERYSTRING
ValidationVisitor.invalid_lookup_key=Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used as LOOKUP key columns: {0}.
ValidationVisitor.limit_not_valid_for_xml=The limit clause cannot be used on an XML document query.
-ValidationVisitor.translated_or=Translated user criteria must not contain OR criteria
ValidationVisitor.union_insert = Select into is not allowed under a set operation: {0}.
-ValidationVisitor.virtual_update_subquery = Subqueries are not allowed in the criteria for a virtual UPDATE/DELETE: {0}
ERR.015.012.0029 = INSERT, UPDATE, and DELETE not allowed on XML documents
ERR.015.012.0030 = Commands used in stored procedure language not allowed on XML documents
ERR.015.012.0031 = Queries against XML documents can not have a GROUP By clause
14 years, 3 months
teiid SVN: r2769 - in branches/7.1.x/connectors/connector-salesforce/src/main: rar/META-INF and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-12-13 12:55:26 -0500 (Mon, 13 Dec 2010)
New Revision: 2769
Modified:
branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
branches/7.1.x/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
Log:
TEIID-1388: The CXF resolution of endpoint address from salesforce WSDL is different from that of the JDK impl of JAX-WS, thus connection was resolving to wrong endpoint when CXF is used. However using CXF if you set the "endpoint" address explicitly it will resolve correctly. The changes here make use of user supplied URL as the endpoint, if in case user did not supply the endpoint then a default endpoint is defined in the ra.xml will be used. Also, cleaned up some unused properties and added isAlive call to actually check if the connection is alive.
Modified: branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
--- branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java 2010-12-13 15:31:33 UTC (rev 2768)
+++ branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java 2010-12-13 17:55:26 UTC (rev 2769)
@@ -35,28 +35,19 @@
private static final long serialVersionUID = 5298591275313314698L;
private String username;
- private String connectorStateClass;
private String password;
private URL URL;
- private long sourceConnectionTestInterval = -1;
- private int sourceConnectionTimeout = -1;
- private boolean auditModelFields = false;
public String getUsername() {
return username;
}
public void setUsername(String username) {
if (username.trim().length() == 0) {
- throw new TeiidRuntimeException("Name can not be null");
+ throw new TeiidRuntimeException("Name can not be null"); //$NON-NLS-1$
}
this.username = username;
}
- public String getConnectorStateClass() {
- return this.connectorStateClass;
- }
- public void setConnectorStateClass(String connectorStateClass) {
- this.connectorStateClass = connectorStateClass;
- }
+
public String getPassword() {
return this.password;
}
@@ -71,35 +62,18 @@
try {
this.URL = new URL(uRL);
} catch (MalformedURLException e) {
- throw new TeiidRuntimeException("URL Supplied is not valid URL"+ e.getMessage());
+ throw new TeiidRuntimeException("URL Supplied is not valid URL"+ e.getMessage());//$NON-NLS-1$
}
}
- public long getSourceConnectionTestInterval() {
- return sourceConnectionTestInterval;
- }
- public void setSourceConnectionTestInterval(Long sourceConnectionTestInterval) {
- this.sourceConnectionTestInterval = sourceConnectionTestInterval.longValue();
- }
- public int getSourceConnectionTimeout() {
- return sourceConnectionTimeout;
- }
- public void setSourceConnectionTimeout(Integer sourceConnectionTimeout) {
- this.sourceConnectionTimeout = sourceConnectionTimeout.intValue();
- }
- public void setModelAuditFields(Boolean modelAuditFields) {
- this.auditModelFields = modelAuditFields.booleanValue();
- }
- public boolean isModelAuditFields() {
- return this.auditModelFields;
- }
-
@Override
public BasicConnectionFactory createConnectionFactory() throws ResourceException {
return new BasicConnectionFactory() {
+ private static final long serialVersionUID = 5028356110047329135L;
+
@Override
public SalesforceConnectionImpl getConnection() throws ResourceException {
- return new SalesforceConnectionImpl(getUsername(), getPassword(), getURL(), getSourceConnectionTestInterval(), getSourceConnectionTimeout());
+ return new SalesforceConnectionImpl(getUsername(), getPassword(), getURL());
}
};
}
Modified: branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
===================================================================
--- branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java 2010-12-13 15:31:33 UTC (rev 2768)
+++ branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java 2010-12-13 17:55:26 UTC (rev 2769)
@@ -72,8 +72,8 @@
PackageVersionHeader pvHeader = partnerFactory.createPackageVersionHeader();
- public SalesforceConnectionImpl(String username, String password, URL url, long pingInterval, int timeout) throws ResourceException {
- login(username, password, url, timeout);
+ public SalesforceConnectionImpl(String username, String password, URL url) throws ResourceException {
+ login(username, password, url);
}
String getUserName() throws ResourceException {
@@ -88,24 +88,22 @@
return sfSoap;
}
- private void login(String username, String password, URL url, int timeout) throws ResourceException {
+ private void login(String username, String password, URL url) throws ResourceException {
if (!isValid()) {
LoginResult loginResult = null;
sfSoap = null;
sfService = null;
co = new CallOptions();
- co.setClient("RedHat/MetaMatrix/"); //$NON-NLS-1$
+ co.setClient("RedHat/Teiid/"); //$NON-NLS-1$
+
+ if(url == null) {
+ throw new ResourceException("SalesForce URL is not specified, please provide a valid URL"); //$NON-NLS-1$
+ }
try {
- /*
- if(null != url) {
- sfService = new SforceService(url);
- sfSoap = sfService.getSoap();
- } else {
- */
- sfService = new SforceService();
- sfSoap = sfService.getSoap();
- //}
+ sfService = new SforceService();
+ sfSoap = sfService.getSoap();
+ ((BindingProvider)sfSoap).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url.toExternalForm());
loginResult = sfSoap.login(username, password);
} catch (LoginFault e) {
throw new ResourceException(e.getCause().getMessage());
@@ -377,4 +375,9 @@
public void close() throws ResourceException {
}
+
+ @Override
+ public boolean isAlive() {
+ return isValid();
+ }
}
Modified: branches/7.1.x/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/7.1.x/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2010-12-13 15:31:33 UTC (rev 2768)
+++ branches/7.1.x/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2010-12-13 17:55:26 UTC (rev 2769)
@@ -56,22 +56,9 @@
<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>
</config-property>
- <config-property>
- <description>{$display:"Source Connection Test Interval",$advanced:"true"}</description>
- <config-property-name>SourceConnectionTestInterval</config-property-name>
- <config-property-type>java.lang.Long</config-property-type>
- <config-property-value>5000</config-property-value>
- </config-property>
-
- <config-property>
- <description>{$display:"Source Connection Timeout",$advanced:"true"}</description>
- <config-property-name>SourceConnectionTimeout</config-property-name>
- <config-property-type>java.lang.Integer</config-property-type>
- <config-property-value>120000</config-property-value>
- </config-property>
-
<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
<connectionfactory-impl-class>org.teiid.resource.spi.WrappedConnectionFactory</connectionfactory-impl-class>
<connection-interface>javax.resource.cci.Connection</connection-interface>
14 years, 3 months
teiid SVN: r2768 - in branches/7.1.x: runtime/src/test/java/org/teiid/transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-13 10:31:33 -0500 (Mon, 13 Dec 2010)
New Revision: 2768
Modified:
branches/7.1.x/client/src/main/java/org/teiid/net/HostInfo.java
branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
Log:
TEIID-1391 fix for invalid connection reuse
Modified: branches/7.1.x/client/src/main/java/org/teiid/net/HostInfo.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/net/HostInfo.java 2010-12-13 15:24:48 UTC (rev 2767)
+++ branches/7.1.x/client/src/main/java/org/teiid/net/HostInfo.java 2010-12-13 15:31:33 UTC (rev 2768)
@@ -113,12 +113,12 @@
if (portNumber != hostInfo.getPortNumber()) {
return false;
}
+ if (ssl != hostInfo.ssl) {
+ return false;
+ }
if (inetAddress != null && hostInfo.inetAddress != null) {
return inetAddress.equals(hostInfo.inetAddress);
}
- if (ssl != hostInfo.ssl) {
- return false;
- }
return hostName.equals(hostInfo.getHostName());
}
Modified: branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-12-13 15:24:48 UTC (rev 2767)
+++ branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-12-13 15:31:33 UTC (rev 2768)
@@ -194,6 +194,9 @@
}
@Test public void testSSLConnectWithNonSSLServer() throws Exception {
+ //first make a non-ssl connection to ensure that it's not reused
+ SocketServerConnection conn = helpEstablishConnection(false);
+ conn.close();
try {
helpEstablishConnection(true);
fail("exception expected"); //$NON-NLS-1$
@@ -207,12 +210,19 @@
config.setMode(SSLConfiguration.ENABLED);
config.setAuthenticationMode(SSLConfiguration.ANONYMOUS);
Properties p = new Properties();
+ p.setProperty("org.teiid.sockets.soTimeout", "100");
helpEstablishConnection(true, config, p);
SocketServerConnection conn = helpEstablishConnection(true, config, p);
conn.close();
+
+ try {
+ helpEstablishConnection(false, config, p);
+ } catch (CommunicationException e) {
+
+ }
}
- @Test(expected=CommunicationException.class) public void testNonSSLConnectWithSSLServer() throws Exception {
+ @Test(expected=CommunicationException.class) public void testNonAnonSSLConnectWithSSLServer() throws Exception {
SSLConfiguration config = new SSLConfiguration();
config.setMode(SSLConfiguration.ENABLED);
config.setAuthenticationMode(SSLConfiguration.ANONYMOUS);
14 years, 3 months
teiid SVN: r2767 - branches/7.1.x/common-core/src/main/java/org/teiid/core/util.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-13 10:24:48 -0500 (Mon, 13 Dec 2010)
New Revision: 2767
Modified:
branches/7.1.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java
Log:
TEIID-1390 fix for inputstreamreader handling of multibyte chars at buffer boundaries
Modified: branches/7.1.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java
===================================================================
--- branches/7.1.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java 2010-12-13 15:15:35 UTC (rev 2766)
+++ branches/7.1.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java 2010-12-13 15:24:48 UTC (rev 2767)
@@ -90,7 +90,7 @@
}
done = true;
}
- if (bb.remaining() != 0) {
+ if (bb.position() != read) {
bb.compact();
} else {
bb.clear();
14 years, 3 months
teiid SVN: r2766 - in branches/7.1.x/common-core/src: test/java/org/teiid/core/util and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-13 10:15:35 -0500 (Mon, 13 Dec 2010)
New Revision: 2766
Added:
branches/7.1.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java
Removed:
branches/7.1.x/common-core/src/test/java/org/teiid/core/util/FakeInputStream.java
Modified:
branches/7.1.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java
Log:
TEIID-1390 fix for inputstreamreader handling of multibyte chars at buffer boundaries
Modified: branches/7.1.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java
===================================================================
--- branches/7.1.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java 2010-12-10 18:28:27 UTC (rev 2765)
+++ branches/7.1.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java 2010-12-13 15:15:35 UTC (rev 2766)
@@ -89,8 +89,12 @@
cr.throwException();
}
done = true;
- }
- bb.clear();
+ }
+ if (bb.remaining() != 0) {
+ bb.compact();
+ } else {
+ bb.clear();
+ }
cb.flip();
}
len = Math.min(len, cb.remaining());
Deleted: branches/7.1.x/common-core/src/test/java/org/teiid/core/util/FakeInputStream.java
===================================================================
--- branches/7.1.x/common-core/src/test/java/org/teiid/core/util/FakeInputStream.java 2010-12-10 18:28:27 UTC (rev 2765)
+++ branches/7.1.x/common-core/src/test/java/org/teiid/core/util/FakeInputStream.java 2010-12-13 15:15:35 UTC (rev 2766)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.core.util;
-
-import java.io.ByteArrayInputStream;
-
-/**
- * This test input stream overrides the <code>available</code>
- * to return "1" until <i>after</i> the {@link #read} method returns
- * "-1" to indicate EOF, which is how java.util.zip.ZipInputStream
- * works, which is what is used by ExtensionSourceManager to retrieve
- * Class files from JAR files. The <code>available</code> method
- * therefore can't be relied on by ByteArrayHelper to either
- * indicate how many bytes can be read, or if more are
- * available or not. In the latter case, ByteArrayHelper
- * relies on the <code>read</code> method returning "-1".
- */
-public class FakeInputStream extends ByteArrayInputStream {
-
- private int available = 1;
-
- public FakeInputStream(byte[] buf) {
- super(buf);
- }
-
- /**
- * Overriden to return "1" <i>until</i> the <code>read</code> method
- * has returned "-1" to indicate EOF.
- */
- public int available(){
- super.available();
- return available;
- }
-
- /**
- * Overriden - basically calls to super method, but checks returned
- * number of bytes read; if "-1", then the next call to
- * {@link #available} will return "0".
- */
- public int read(byte b[], int off, int len) {
- int result = super.read(b, off, len);
- if (result<0){
- available = 0;
- }
- return result;
- }
-
-}
Added: branches/7.1.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java
===================================================================
--- branches/7.1.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java (rev 0)
+++ branches/7.1.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java 2010-12-13 15:15:35 UTC (rev 2766)
@@ -0,0 +1,18 @@
+package org.teiid.core.util;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayInputStream;
+import java.nio.charset.Charset;
+
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class TestInputStreamReader {
+
+ @Test public void testMultiByte() throws Exception {
+ InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte)80, (byte)-61, (byte)-70}), Charset.forName("UTF-8").newDecoder(), 2);
+ assertEquals(80, isr.read());
+ assertEquals(250, isr.read());
+ }
+}
Property changes on: branches/7.1.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 3 months
teiid SVN: r2765 - in trunk: build/kits/jboss-container and 12 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-10 13:28:27 -0500 (Fri, 10 Dec 2010)
New Revision: 2765
Modified:
trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java
trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
trunk/client/src/main/resources/vdb-deployer.xsd
trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java
trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
Log:
TEIID-89 adding the ability to restrict access to temporary table usage
Modified: trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -59,6 +59,7 @@
public static final String TO_BYTES = "to_bytes"; //$NON-NLS-1$
public static final String TO_CHARS = "to_chars"; //$NON-NLS-1$
public static final String UCASE = "ucase"; //$NON-NLS-1$
+ public static final String UNESCAPE = "unescape"; //$NON-NLS-1$
//numeric
public static final String ABS = "abs"; //$NON-NLS-1$
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-12-10 18:28:27 UTC (rev 2765)
@@ -99,8 +99,10 @@
This includes both user plans and internal prepared plans.
Note: this is a memory based cache. (default 512) -->
<property name="preparedPlanCacheMaxCount">512</property>
- <!-- Turn on role checking of resources based on the roles defined in VDB (default true) -->
+ <!-- Turn on role checking based upon the data roles defined in VDBs. (default true) -->
<property name="useDataRoles">true</property>
+ <!-- Sets whether temporary table usage is enabled by default (default true) -->
+ <property name="allowCreateTemporaryTablesByDefault">true</property>
<!-- Long running query threshold, after which a alert can be generated by tooling if configured-->
<property name="queryThresholdInSecs">600</property>
<!-- Maximum rows allowed from a source query. -1 indicates no limit. (default -1)-->
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-12-10 18:28:27 UTC (rev 2765)
@@ -32,7 +32,8 @@
<LI>Added support to perform simple pass-through and more complicated updates through views by default.
<LI>Added support for "FOR EACH ROW" update procedure handling (similar to INSTEAD OF triggers in other DBMS's), which should be used instead of the deprecated TRANSLATE criteria approach.
</UL>
- <LI><B>UDF</B> - new API objects added to teiid-api to support user defined functions that are capable of pushdown to source.
+ <LI><B>UDF</B> - new API objects added to teiid-api to support user defined functions that are capable of pushdown to source.
+ <LI><B>Unescape Function</B> - a new system function, unescape, was added to handle common \ escaping in strings including octal, hex/unicode, \b, \r, \n, \f, and \t.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
@@ -85,6 +86,13 @@
See the <a href="teiid-docs/teiid_admin_guide.pdf">Admin Guide</a> for more on configuration and installation.
+<h4>from 7.2</h4>
+<ul>
+ <LI>Temporary tables can now be restricted by data roles. Use the data-role attribute allow-create-temporary-tables to explicitly enable or disable the usage of temporary tables.
+There is also a allowCreateTemporaryTablesByDefault property in the teiid-jboss-beans.xml to control whether usage is allowed by default. For compatibility with prior 7.x releases, the default is to allow
+temporary table access.
+</ul>
+
<h4>from 7.1</h4>
<ul>
<li>Teiid clients now allow the usage of anonymous SSL by default.
Modified: trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -51,8 +51,18 @@
*/
List<String> getMappedRoleNames();
+ /**
+ * If the policy applies to any authenticated user
+ * @return
+ */
boolean isAnyAuthenticated();
+ /**
+ * If the policy allows for temporary table usage
+ * @return
+ */
+ Boolean isAllowCreateTemporaryTables();
+
interface DataPermission {
/**
* Get the Resource Name that Data Permission representing
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -54,6 +54,8 @@
protected String description;
@XmlAttribute(name = "any-authenticated")
protected boolean anyAuthenticated;
+ @XmlAttribute(name = "allow-create-temporary-tables")
+ protected Boolean allowCreateTemporaryTables;
@XmlElement(name = "permission")
protected PermissionMap permissions = new PermissionMap(new KeyBuilder<PermissionMetaData>() {
@@ -254,6 +256,13 @@
}
}
+ public Boolean isAllowCreateTemporaryTables() {
+ return allowCreateTemporaryTables;
+ }
+
+ public void setAllowCreateTemporaryTables(Boolean allowCreateTemporaryTables) {
+ this.allowCreateTemporaryTables = allowCreateTemporaryTables;
+ }
@Override
@ManagementProperty(description="Indicates if the role is mapped to any authenticated user.")
@@ -264,4 +273,5 @@
public void setAnyAuthenticated(boolean anyAuthenticated) {
this.anyAuthenticated = anyAuthenticated;
}
+
}
Modified: trunk/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- trunk/client/src/main/resources/vdb-deployer.xsd 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/client/src/main/resources/vdb-deployer.xsd 2010-12-10 18:28:27 UTC (rev 2765)
@@ -100,6 +100,7 @@
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="any-authenticated" type="xs:boolean"/>
+ <xs:attribute name="allow-create-temporary-tables" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
Modified: trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -94,7 +94,7 @@
DataPolicyMetadata roleOne = new DataPolicyMetadata();
roleOne.setName("roleOne"); //$NON-NLS-1$
roleOne.setDescription("roleOne described"); //$NON-NLS-1$
-
+ roleOne.setAllowCreateTemporaryTables(true);
PermissionMetaData perm1 = new PermissionMetaData();
perm1.setResourceName("myTable.T1"); //$NON-NLS-1$
perm1.setAllowRead(true);
@@ -167,6 +167,7 @@
assertTrue(roles.size() == 1);
DataPolicyMetadata role = vdb.getDataPolicy("roleOne"); //$NON-NLS-1$
+ assertTrue(role.isAllowCreateTemporaryTables());
assertEquals("roleOne described", role.getDescription()); //$NON-NLS-1$
assertNotNull(role.getMappedRoleNames());
assertTrue(role.getMappedRoleNames().contains("ROLE1")); //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -50,6 +50,7 @@
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day_of_month")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new AliasModifier("day_of_week")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new AliasModifier("day_of_year")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UNESCAPE, new AliasModifier("stringdecode")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(SourceSystemFunctions.MOD, getLanguageFactory()));
//TODO: this behavior is configurable in h2 starting with 1.1.119
registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory()));
@@ -139,6 +140,7 @@
supportedFunctions.add(SourceSystemFunctions.RTRIM);
supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
supportedFunctions.add(SourceSystemFunctions.UCASE);
+ supportedFunctions.add(SourceSystemFunctions.UNESCAPE);
supportedFunctions.add(SourceSystemFunctions.DAYNAME);
supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml 2010-12-10 18:28:27 UTC (rev 2765)
@@ -147,8 +147,10 @@
<para>The "mapped-role-name" defines the container JAAS roles that are assigned the data role. For assigning roles to your users in the JBoss AS,
check out the instructions for the selected Login Module. Check the "Admin Guide" for configuring Login Modules. You may also choose to allow any
- authenticated user to have a data role by setting the any-authenticated attribute value to true on data-role element.</para>
+ authenticated user to have a data role by setting the any-authenticated attribute value to true on data-role element.</para>
+ <para>The "allow-create-temporary-tables" data-role boolean attribute is used to explicitly enable or disable temporary table usage for the role. If it is left unspecified, then the value will be determined by the configuration setting allowCreateTemporaryTablesByDefault located in the &jboss-beans; file in the <code>RuntimeEngineDeployer</code> section.</para>
+
</section>
<section>
<title>System Functions</title>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -48,7 +49,9 @@
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Create;
import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Drop;
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.lang.Into;
import org.teiid.query.sql.lang.Query;
@@ -66,6 +69,8 @@
public class AuthorizationValidationVisitor extends AbstractValidationVisitor {
public enum Context {
+ CREATE,
+ DROP,
QUERY,
INSERT,
UPDATE,
@@ -75,14 +80,69 @@
private HashMap<String, DataPolicy> allowedPolicies;
private String userName;
+ private boolean allowCreateTemporaryTablesDefault = true;
public AuthorizationValidationVisitor(HashMap<String, DataPolicy> policies, String user) {
this.allowedPolicies = policies;
this.userName = user;
}
+
+ public void setAllowCreateTemporaryTablesDefault(
+ boolean allowCreateTemporaryTablesDefault) {
+ this.allowCreateTemporaryTablesDefault = allowCreateTemporaryTablesDefault;
+ }
// ############### Visitor methods for language objects ##################
+ @Override
+ public void visit(Create obj) {
+ Set<String> resources = Collections.singleton(obj.getTable().getName());
+ Collection<GroupSymbol> symbols = Arrays.asList(obj.getTable());
+ validateTemp(resources, symbols, Context.CREATE);
+ }
+
+ private void validateTemp(Set<String> resources,
+ Collection<GroupSymbol> symbols, Context context) {
+ logRequest(resources, context);
+
+ boolean allowed = false;
+ for(DataPolicy p:this.allowedPolicies.values()) {
+ DataPolicyMetadata policy = (DataPolicyMetadata)p;
+
+ if (policy.isAllowCreateTemporaryTables() == null) {
+ if (allowCreateTemporaryTablesDefault) {
+ allowed = true;
+ break;
+ }
+ } else if (policy.isAllowCreateTemporaryTables()) {
+ allowed = true;
+ break;
+ }
+ }
+
+ logResult(resources, context, allowed);
+ if (!allowed) {
+ handleValidationError(
+ QueryPlugin.Util.getString("ERR.018.005.0095", userName, "CREATE_TEMPORARY_TABLES"), //$NON-NLS-1$
+ symbols);
+ }
+ }
+
+ private void logRequest(Set<String> resources, Context context) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
+ // Audit - request
+ AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-request", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
+ }
+ }
+
+ @Override
+ public void visit(Drop obj) {
+ Set<String> resources = Collections.singleton(obj.getTable().getName());
+ Collection<GroupSymbol> symbols = Arrays.asList(obj.getTable());
+ validateTemp(resources, symbols, Context.CREATE);
+ }
+
public void visit(Delete obj) {
validateEntitlements(obj);
}
@@ -206,16 +266,6 @@
validateEntitlements(Arrays.asList(obj.getGroup()), DataPolicy.PermissionType.READ, Context.STORED_PROCEDURE);
}
- private String getActionLabel(DataPolicy.PermissionType actionCode) {
- switch(actionCode) {
- case READ: return "Read"; //$NON-NLS-1$
- case CREATE: return "Create"; //$NON-NLS-1$
- case UPDATE: return "Update"; //$NON-NLS-1$
- case DELETE: return "Delete"; //$NON-NLS-1$
- default: return "UNKNOWN"; //$NON-NLS-1$
- }
- }
-
/**
* Check that the user is entitled to access all data elements in the command.
*
@@ -256,33 +306,28 @@
}
if (!nameToSymbolMap.isEmpty()) {
- Collection<String> inaccessibleResources = getInaccessibleResources(actionCode, nameToSymbolMap.keySet(), auditContext);
- if(inaccessibleResources.size() > 0) {
- List<Symbol> inaccessibleSymbols = new ArrayList<Symbol>(inaccessibleResources.size());
- for (String name : inaccessibleResources) {
- inaccessibleSymbols.add(nameToSymbolMap.get(name));
- }
-
- // CASE 2362 - do not include the names of the elements for which the user
- // is not authorized in the exception message
-
- handleValidationError(
- QueryPlugin.Util.getString("ERR.018.005.0095", userName, getActionLabel(actionCode)), //$NON-NLS-1$
- inaccessibleSymbols);
- }
+ Collection<String> inaccessibleResources = getInaccessibleResources(actionCode, nameToSymbolMap.keySet(), auditContext);
+ if(inaccessibleResources.size() > 0) {
+ List<Symbol> inaccessibleSymbols = new ArrayList<Symbol>(inaccessibleResources.size());
+ for (String name : inaccessibleResources) {
+ inaccessibleSymbols.add(nameToSymbolMap.get(name));
+ }
+
+ // CASE 2362 - do not include the names of the elements for which the user
+ // is not authorized in the exception message
+
+ handleValidationError(
+ QueryPlugin.Util.getString("ERR.018.005.0095", userName, actionCode), //$NON-NLS-1$
+ inaccessibleSymbols);
+ }
}
+ }
- }
-
/**
* Out of resources specified, return the subset for which the specified not have authorization to access.
*/
public Set<String> getInaccessibleResources(DataPolicy.PermissionType action, Set<String> resources, Context context) {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
- // Audit - request
- AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-request", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
- LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
- }
+ logRequest(resources, context);
HashSet<String> results = new HashSet<String>(resources);
@@ -301,8 +346,14 @@
}
}
+ logResult(resources, context, results.isEmpty());
+ return results;
+ }
+
+ private void logResult(Set<String> resources, Context context,
+ boolean granted) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
- if (results.isEmpty()) {
+ if (granted) {
AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-granted all", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
} else {
@@ -310,6 +361,5 @@
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
}
}
- return results;
- }
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -44,7 +44,8 @@
private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
private int lobChunkSizeInKB = 100;
private int preparedPlanCacheMaxCount = SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL;
- private boolean useDataRoles = false;
+ private boolean useDataRoles = true;
+ private boolean allowCreateTemporaryTablesByDefault = true;
private int queryThresholdInSecs = DEFAULT_QUERY_THRESHOLD;
private boolean exceptionOnMaxSourceRows = true;
private int maxSourceRows = -1;
@@ -122,7 +123,7 @@
* Determine whether role checking is enabled on the server.
* @return <code>true</code> if server-side role checking is enabled.
*/
- @ManagementProperty(description="Turn on role checking on resources based on the roles defined in VDB")
+ @ManagementProperty(description="Turn on role checking based upon the data roles defined in VDBs. (default true)")
public boolean getUseDataRoles() {
return useDataRoles;
}
@@ -131,6 +132,20 @@
this.useDataRoles = useEntitlements;
}
+ /**
+ * Whether temporary table usage is enabled by default.
+ * @return <code>true</code> if temporary table usage is enabled by default.
+ */
+ @ManagementProperty(description="Sets whether temporary table usage is enabled by default. (default true)")
+ public boolean isAllowCreateTemporaryTablesByDefault() {
+ return allowCreateTemporaryTablesByDefault;
+ }
+
+ public void setAllowCreateTemporaryTablesByDefault(
+ boolean allowCreateTemporaryTablesByDefault) {
+ this.allowCreateTemporaryTablesByDefault = allowCreateTemporaryTablesByDefault;
+ }
+
@ManagementProperty(description="Long running query threshold, after which a alert can be generated by tooling if configured")
public int getQueryThresholdInSecs() {
return queryThresholdInSecs;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -184,9 +184,6 @@
private ThreadReuseExecutor processWorkerPool;
- private int maxFetchSize = DQPConfiguration.DEFAULT_FETCH_SIZE;
- private int queryThreshold = DQPConfiguration.DEFAULT_QUERY_THRESHOLD;
-
// Resources
private BufferManager bufferManager;
private ProcessorDataManager dataTierMgr;
@@ -195,17 +192,12 @@
private TransactionService transactionService;
private BufferService bufferService;
- // Query worker pool for processing plans
- private int processorTimeslice = DQPConfiguration.DEFAULT_PROCESSOR_TIMESLICE;
+ private DQPConfiguration config = new DQPConfiguration();
- private int maxSourceRows = DQPConfiguration.DEFAULT_MAX_SOURCE_ROWS;
- private boolean exceptionOnMaxSourceRows = true;
-
private int chunkSize = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
private Map<RequestID, RequestWorkItem> requests = new ConcurrentHashMap<RequestID, RequestWorkItem>();
private Map<String, ClientState> clientState = new ConcurrentHashMap<String, ClientState>();
- private boolean useEntitlements = false;
private int maxActivePlans = DQPConfiguration.DEFAULT_MAX_ACTIVE_PLANS;
private int currentlyActivePlans;
@@ -258,7 +250,7 @@
}
public List<RequestMetadata> getLongRunningRequests(){
- return buildRequestInfos(requests.keySet(), this.queryThreshold);
+ return buildRequestInfos(requests.keySet(), this.config.getQueryThresholdInSecs());
}
private List<RequestMetadata> buildRequestInfos(Collection<RequestID> ids, int longRunningQueryThreshold) {
@@ -331,7 +323,7 @@
public ResultsFuture<ResultsMessage> executeRequest(long reqID,RequestMessage requestMsg) {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
RequestID requestID = workContext.getRequestID(reqID);
- requestMsg.setFetchSize(Math.min(requestMsg.getFetchSize(), maxFetchSize));
+ requestMsg.setFetchSize(Math.min(requestMsg.getFetchSize(), this.config.getMaxRowsFetchSize()));
Request request = null;
if ( requestMsg.isPreparedStatement() || requestMsg.isCallableStatement()) {
request = new PreparedStatementRequest(prepPlanCache);
@@ -341,8 +333,9 @@
ClientState state = this.getClientState(workContext.getSessionId(), true);
request.initialize(requestMsg, bufferManager,
dataTierMgr, transactionService, state.sessionTables,
- workContext, this.useEntitlements, this.prepPlanCache);
+ workContext, this.config.getUseDataRoles(), this.prepPlanCache);
request.setResultSetCacheEnabled(this.rsCache != null);
+ request.setAllowCreateTemporaryTablesByDefault(this.config.isAllowCreateTemporaryTablesByDefault());
ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
RequestWorkItem workItem = new RequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext);
logMMCommand(workItem, Event.NEW, null);
@@ -368,7 +361,7 @@
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
RequestWorkItem workItem = getRequestWorkItem(workContext.getRequestID(reqID));
- workItem.requestMore(batchFirst, batchFirst + Math.min(fetchSize, maxFetchSize) - 1, resultsFuture.getResultsReceiver());
+ workItem.requestMore(batchFirst, batchFirst + Math.min(fetchSize, this.config.getMaxRowsFetchSize()) - 1, resultsFuture.getResultsReceiver());
return resultsFuture;
}
@@ -671,7 +664,7 @@
}
int getProcessorTimeSlice() {
- return this.processorTimeslice;
+ return this.config.getTimeSliceInMilli();
}
int getChunkSize() {
@@ -679,12 +672,7 @@
}
public void start(DQPConfiguration config) {
- this.processorTimeslice = config.getTimeSliceInMilli();
- this.maxFetchSize = config.getMaxRowsFetchSize();
- this.useEntitlements = config.getUseDataRoles();
- this.queryThreshold = config.getQueryThresholdInSecs();
- this.maxSourceRows = config.getMaxSourceRows();
- this.exceptionOnMaxSourceRows = config.isExceptionOnMaxSourceRows();
+ this.config = config;
this.chunkSize = config.getLobChunkSizeInKB() * 1024;
@@ -853,11 +841,11 @@
}
public boolean isExceptionOnMaxSourceRows() {
- return exceptionOnMaxSourceRows;
+ return this.config.isExceptionOnMaxSourceRows();
}
public int getMaxSourceRows() {
- return maxSourceRows;
+ return this.config.getMaxSourceRows();
}
public void setCacheFactory(CacheFactory factory) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -134,6 +134,7 @@
private TempTableStore globalTables;
private SessionAwareCache<PreparedPlan> planCache;
private boolean resultSetCacheEnabled = true;
+ private boolean allowCreateTemporaryTablesByDefault;
void initialize(RequestMessage requestMsg,
BufferManager bufferManager,
@@ -168,6 +169,11 @@
public void setResultSetCacheEnabled(boolean resultSetCacheEnabled) {
this.resultSetCacheEnabled = resultSetCacheEnabled;
}
+
+ public void setAllowCreateTemporaryTablesByDefault(
+ boolean allowCreateTemporaryTablesByDefault) {
+ this.allowCreateTemporaryTablesByDefault = allowCreateTemporaryTablesByDefault;
+ }
/**
* if the metadata has not been supplied via setMetadata, this method will create the appropriate state
@@ -460,6 +466,7 @@
protected void validateAccess(Command command) throws QueryValidatorException, TeiidComponentException {
if (useEntitlements) {
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.workContext.getAllowedDataPolicies(), this.workContext.getUserName());
+ visitor.setAllowCreateTemporaryTablesDefault(this.allowCreateTemporaryTablesByDefault);
validateWithVisitor(visitor, this.metadata, command);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -196,7 +196,7 @@
}
private void addUnescape() {
- functions.add(new FunctionMethod("unescape", QueryPlugin.Util.getString("SystemSource.unescape_desc"), STRING, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "unescape", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ functions.add(new FunctionMethod(SourceSystemFunctions.UNESCAPE, QueryPlugin.Util.getString("SystemSource.unescape_desc"), STRING, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, SourceSystemFunctions.UNESCAPE, //$NON-NLS-1$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.unescape_param1"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.unescape_result")), false, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -969,7 +969,7 @@
private Insert correctDatatypes(Insert insert) {
boolean needsView = false;
for (int i = 0; !needsView && i < insert.getVariables().size(); i++) {
- SingleElementSymbol ses = (SingleElementSymbol)insert.getVariables().get(i);
+ SingleElementSymbol ses = insert.getVariables().get(i);
if (ses.getType() != insert.getQueryExpression().getProjectedSymbols().get(i).getType()) {
needsView = true;
}
@@ -2466,7 +2466,7 @@
public static Query createInlineViewQuery(GroupSymbol inlineGroup,
Command nested,
QueryMetadataInterface metadata,
- List<SingleElementSymbol> actualSymbols) throws QueryMetadataException,
+ List<? extends SingleElementSymbol> actualSymbols) throws QueryMetadataException,
QueryResolverException,
TeiidComponentException {
Query query = new Query();
@@ -2488,7 +2488,7 @@
actualTypes.add(ses.getType());
}
List<SingleElementSymbol> selectSymbols = SetQuery.getTypedProjectedSymbols(ResolverUtil.resolveElementsInGroup(inlineGroup, tma), actualTypes, tma);
- Iterator<SingleElementSymbol> iter = actualSymbols.iterator();
+ Iterator<? extends SingleElementSymbol> iter = actualSymbols.iterator();
for (SingleElementSymbol ses : selectSymbols) {
ses = (SingleElementSymbol)ses.clone();
SingleElementSymbol actual = iter.next();
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -23,7 +23,6 @@
package org.teiid.query.sql.lang;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -81,7 +80,7 @@
* @param variables List of ElementSymbols that represent columns for the values, null implies all columns
* @param values List of Expression values to be inserted
*/
- public Insert(GroupSymbol group, List variables, List values) {
+ public Insert(GroupSymbol group, List<ElementSymbol> variables, List values) {
this.group = group;
this.variables = variables;
this.values = values;
@@ -121,7 +120,7 @@
* Return an ordered List of variables, may be null if no columns were specified
* @return List of {@link org.teiid.query.sql.symbol.ElementSymbol}
*/
- public List getVariables() {
+ public List<ElementSymbol> getVariables() {
return variables;
}
@@ -137,7 +136,7 @@
* Add a collection of variables to end of list
* @param vars Variables to add to the list - collection of ElementSymbol
*/
- public void addVariables(Collection vars) {
+ public void addVariables(Collection<ElementSymbol> vars) {
variables.addAll(vars);
}
@@ -256,14 +255,10 @@
List<ElementSymbol> copyVars = LanguageObject.Util.deepClone(getVariables(), ElementSymbol.class);
- List copyVals = new LinkedList();
+ List<Expression> copyVals = null;
- if ( getValues() != null && getValues().size() > 0 ) {
- Iterator iter = getValues().iterator();
- while(iter.hasNext()) {
- Expression expression = (Expression) iter.next();
- copyVals.add( expression.clone() );
- }
+ if ( getValues() != null) {
+ copyVals = LanguageObject.Util.deepClone(getValues(), Expression.class);
}
Insert copy = new Insert(copyGroup, copyVars, copyVals);
@@ -280,7 +275,7 @@
* single column.
* @return Ordered list of SingleElementSymbol
*/
- public List getProjectedSymbols(){
+ public List<SingleElementSymbol> getProjectedSymbols(){
return Command.getUpdateCommandSymbol();
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2010-12-08 20:55:34 UTC (rev 2764)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2010-12-10 18:28:27 UTC (rev 2765)
@@ -51,7 +51,7 @@
import org.teiid.query.validator.ValidatorFailure;
import org.teiid.query.validator.ValidatorReport;
-
+@SuppressWarnings("nls")
public class TestAuthorizationValidationVisitor {
public static final String CONN_ID = "connID"; //$NON-NLS-1$
@@ -142,7 +142,7 @@
// pm3.g2
svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm3.g2.e1")); //$NON-NLS-1$
svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm3.g2.e2")); //$NON-NLS-1$
-
+ svc.setAllowCreateTemporaryTables(false);
return svc;
}
@@ -176,6 +176,13 @@
}
}
+ @Test public void testTemp() throws Exception {
+ //allowed by default
+ helpTest(exampleAuthSvc1(), "create local temporary table x (y string)", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
+ //explicitly denied
+ helpTest(exampleAuthSvc2(), "create local temporary table x (y string)", FakeMetadataFactory.example1Cached(), new String[] {"x"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
+ }
+
@Test public void testEverythingAccessible() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
14 years, 3 months
teiid SVN: r2764 - in trunk: documentation/reference/src/main/docbook/en-US/content and 5 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-08 15:55:34 -0500 (Wed, 08 Dec 2010)
New Revision: 2764
Added:
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMethods.java
Modified:
trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
Log:
TEIID-1385 adding support for an unescape method to handle escape sequences in strings
Modified: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2010-12-08 16:34:59 UTC (rev 2763)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2010-12-08 20:55:34 UTC (rev 2764)
@@ -22,7 +22,6 @@
package org.teiid.metadata;
-import java.io.Serializable;
import java.util.Arrays;
import javax.xml.bind.annotation.XmlAttribute;
@@ -55,7 +54,7 @@
*
* @see FunctionParameter
*/
-public class FunctionMethod extends AbstractMetadataRecord implements Serializable {
+public class FunctionMethod extends AbstractMetadataRecord {
private static final long serialVersionUID = -8039086494296455152L;
private static final String NOT_ALLOWED = "NOT_ALLOWED"; //$NON-NLS-1$
@@ -101,7 +100,7 @@
private PushDown pushdown = PushDown.CAN_PUSHDOWN;
private String invocationClass;
private String invocationMethod;
- private boolean nullDependent;
+ private boolean nullOnNull;
private Determinism determinism = Determinism.DETERMINISTIC;
@@ -439,14 +438,14 @@
}
/**
- * Returns true if the function can produce a non-null output from a null parameter
+ * Returns true if the function returns null on any null input
*/
public boolean isNullOnNull() {
- return this.nullDependent;
+ return this.nullOnNull;
}
- public void setNullOnNull(boolean nullSafe) {
- this.nullDependent = nullSafe;
+ public void setNullOnNull(boolean nullOnNull) {
+ this.nullOnNull = nullOnNull;
}
public Determinism getDeterminism() {
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-12-08 16:34:59 UTC (rev 2763)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-12-08 20:55:34 UTC (rev 2764)
@@ -1072,6 +1072,18 @@
<para>x in {string}</para>
</entry>
</row>
+ <row>
+ <entry>
+ <para>UNESCAPE(x)</para>
+ </entry>
+ <entry>
+ <para>Unescaped version of x. Possible escape sequences are \b - backspace, \t - tab, \n - line feed, \f - form feed, \r - carriage return. \uXXXX, where X is a hex value, can be used to specify any unicode character. \XXX, where X is an octal digit, can be used to specify an octal byte value.
+ If any other character appears after an escape character, that character will appear in the output and the escape character will be ignored.</para>
+ </entry>
+ <entry>
+ <para>x in {string}</para>
+ </entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-12-08 16:34:59 UTC (rev 2763)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-12-08 20:55:34 UTC (rev 2764)
@@ -1304,5 +1304,75 @@
}
return Charset.forName(encoding);
}
+
+ public static String unescape(String string) {
+ StringBuilder sb = new StringBuilder();
+ boolean escaped = false;
+ for (int i = 0; i < string.length(); i++) {
+ char c = string.charAt(i);
+ if (escaped) {
+ switch (c) {
+ case 'b':
+ sb.append('\b');
+ break;
+ case 't':
+ sb.append('\t');
+ break;
+ case 'n':
+ sb.append('\n');
+ break;
+ case 'f':
+ sb.append('\f');
+ break;
+ case 'r':
+ sb.append('\r');
+ break;
+ case 'u':
+ i = parseNumericValue(string, sb, i, 0, 4, 4);
+ //TODO: this should probably be strict about needing 4 digits
+ break;
+ default:
+ int value = Character.digit(c, 8);
+ if (value == -1) {
+ sb.append(c);
+ } else {
+ int possibleDigits = value < 3 ? 2:1;
+ int radixExp = 3;
+ i = parseNumericValue(string, sb, i, value, possibleDigits, radixExp);
+ }
+ }
+ escaped = false;
+ } else {
+ if (c == '\\') {
+ escaped = true;
+ } else {
+ sb.append(c);
+ }
+ }
+ }
+ //TODO: should this be strict?
+ //if (escaped) {
+ //throw new FunctionExecutionException();
+ //}
+ return sb.toString();
+ }
+
+ private static int parseNumericValue(String string, StringBuilder sb,
+ int i, int value, int possibleDigits, int radixExp) {
+ for (int j = 0; j < possibleDigits; j++) {
+ if (i + 1 == string.length()) {
+ break;
+ }
+ char digit = string.charAt(i + 1);
+ int val = Character.digit(digit, 1 << radixExp);
+ if (val == -1) {
+ break;
+ }
+ i++;
+ value = (value << radixExp) + val;
+ }
+ sb.append((char)value);
+ return i;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2010-12-08 16:34:59 UTC (rev 2763)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2010-12-08 20:55:34 UTC (rev 2764)
@@ -329,7 +329,7 @@
inputTypes.add(0, CommandContext.class);
}
- FunctionDescriptor descriptor = new FunctionDescriptor(method.getName(), method.getPushdown(), types, outputType, invocationMethod, requiresContext, method.isNullOnNull(), method.getDeterminism());
+ FunctionDescriptor descriptor = new FunctionDescriptor(method.getName(), method.getPushdown(), types, outputType, invocationMethod, requiresContext, !method.isNullOnNull(), method.getDeterminism());
// Store this path in the function tree
int index = -1;
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-12-08 16:34:59 UTC (rev 2763)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-12-08 20:55:34 UTC (rev 2764)
@@ -45,24 +45,8 @@
public FunctionMethod(String name, String description, String category,
String invocationClass, String invocationMethod,
FunctionParameter[] inputParams, FunctionParameter outputParam) {
- this(name, description, category, invocationClass, invocationMethod, inputParams, outputParam, Determinism.DETERMINISTIC);
+ super(name, description, category, PushDown.CAN_PUSHDOWN, invocationClass, invocationMethod, inputParams, outputParam, true, Determinism.DETERMINISTIC);
}
-
- /**
- * Construct a function method with default pushdown and null dependent attributes.
- * @param name Function name
- * @param description Function description
- * @param category Function category
- * @param invocationClass Invocation class
- * @param invocationMethod Invocation method
- * @param inputParams Input parameters
- * @param outputParam Output parameter (return parameter)
- */
- public FunctionMethod(String name, String description, String category,
- String invocationClass, String invocationMethod,
- FunctionParameter[] inputParams, FunctionParameter outputParam, Determinism deterministic) {
- super(name, description, category, PushDown.CAN_PUSHDOWN, invocationClass, invocationMethod, inputParams, outputParam, false, deterministic);
- }
/**
* Construct a function method with all parameters assuming null dependent and non-deterministic.
@@ -77,13 +61,9 @@
public FunctionMethod(String name, String description, String category,
PushDown pushdown, String invocationClass, String invocationMethod,
FunctionParameter[] inputParams, FunctionParameter outputParam) {
- super(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, true,Determinism.NONDETERMINISTIC);
+ super(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, false,Determinism.NONDETERMINISTIC);
}
- public FunctionMethod(String name, String description, String category, FunctionParameter[] inputParams, FunctionParameter outputParam) {
- super(name, description, category, PushDown.MUST_PUSHDOWN, null, null, inputParams, outputParam, false, Determinism.DETERMINISTIC);
- }
-
public FunctionMethod(String name,
String description,
String category,
@@ -94,6 +74,6 @@
FunctionParameter outputParam,
boolean nullDependent,
Determinism deterministic) {
- super(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, nullDependent, deterministic);
+ super(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, !nullDependent, deterministic);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-12-08 16:34:59 UTC (rev 2763)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-12-08 20:55:34 UTC (rev 2764)
@@ -191,9 +191,19 @@
}
addTypedCoalesceFunction(type);
}
+
+ addUnescape();
}
- private void addSecurityFunctions() {
+ private void addUnescape() {
+ functions.add(new FunctionMethod("unescape", QueryPlugin.Util.getString("SystemSource.unescape_desc"), STRING, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "unescape", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionParameter[] {
+ new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.unescape_param1"))}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.unescape_result")), false, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+
+ private void addSecurityFunctions() {
functions.add(new FunctionMethod("hasRole", QueryPlugin.Util.getString("SystemSource.hasRole_description"), SECURITY, PushDown.CANNOT_PUSHDOWN, SECURITY_FUNCTION_CLASS, "hasRole", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("roleType", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param1")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -263,13 +273,16 @@
// With Seed
FunctionMethod rand = new FunctionMethod(SourceSystemFunctions.RAND, QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter[] {new FunctionParameter("seed", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rand_arg")) }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")), Determinism.NONDETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
- rand.setNullOnNull(true);
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")) ); //$NON-NLS-1$ //$NON-NLS-2$
+ rand.setNullOnNull(false);
+ rand.setDeterminism(Determinism.NONDETERMINISTIC);
functions.add(rand);
// Without Seed
- functions.add( new FunctionMethod(SourceSystemFunctions.RAND, QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$
+ rand = new FunctionMethod(SourceSystemFunctions.RAND, QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter[] {},
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")), Determinism.NONDETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")) ); //$NON-NLS-1$ //$NON-NLS-2$
+ rand.setDeterminism(Determinism.NONDETERMINISTIC);
+ functions.add(rand);
}
private void addDoubleFunction(String name, String description) {
@@ -374,10 +387,11 @@
* evaluation.
*/
private void addConstantDateFunction(String name, String description, String methodName, String returnType) {
- functions.add(
- new FunctionMethod(name, description, DATETIME, FUNCTION_CLASS, methodName,
+ FunctionMethod method = new FunctionMethod(name, description, DATETIME, FUNCTION_CLASS, methodName,
new FunctionParameter[] {},
- new FunctionParameter("result", returnType, description), Determinism.COMMAND_DETERMINISTIC ) ); //$NON-NLS-1$
+ new FunctionParameter("result", returnType, description)); //$NON-NLS-1$
+ method.setDeterminism(Determinism.COMMAND_DETERMINISTIC);
+ functions.add(method);
}
private void addDateFunction(String name, String methodName, String dateDesc, String timestampDesc, String returnType) {
@@ -539,7 +553,7 @@
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_result")) ); //$NON-NLS-1$ //$NON-NLS-2$
- func.setNullOnNull(true);
+ func.setNullOnNull(false);
functions.add(func);
functions.add(
new FunctionMethod(SourceSystemFunctions.LOCATE, QueryPlugin.Util.getString("SystemSource.Locate2_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$
@@ -826,7 +840,7 @@
new FunctionParameter("value", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("valueIfNull", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_result")) ); //$NON-NLS-1$ //$NON-NLS-2$
- nvl.setNullOnNull(true);
+ nvl.setNullOnNull(false);
functions.add(nvl);
}
@@ -837,7 +851,7 @@
new FunctionParameter("value", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("valueIfNull", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_result")) ); //$NON-NLS-1$ //$NON-NLS-2$
- nvl.setNullOnNull(true);
+ nvl.setNullOnNull(false);
functions.add(nvl);
}
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-12-08 16:34:59 UTC (rev 2763)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-12-08 20:55:34 UTC (rev 2764)
@@ -273,6 +273,9 @@
SQLParser.Invalid_short_name=Invalid simple identifier format: [{0}]
SQLParser.Invalid_char={0} value must be a single character: [{1}].
SQLParser.expected_non_reserved=Expected non-reserved word {0}, but was {1}.
+SystemSource.Add_desc=Converts escape sequences in the given string to their actual characters.
+SystemSource.unescape_param1=String to be unescaped
+SystemSource.unescape_result=Unescaped string
SystemSource.Add_desc=Add two numbers
SystemSource.Add_result_desc=Left operand + right operand
SystemSource.Subtract_desc=Subtract two numbers
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-12-08 16:34:59 UTC (rev 2763)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-12-08 20:55:34 UTC (rev 2764)
@@ -1407,4 +1407,8 @@
helpInvokeMethod("to_bytes", new Class[] {DefaultDataClasses.CLOB, DefaultDataClasses.STRING}, new Object[] { new ClobType(new SerialClob("a".toCharArray())), "BASE64" }, null); //$NON-NLS-1$
}
+ @Test() public void testunescape() throws Exception {
+ assertEquals("\r\t", helpInvokeMethod("unescape", new Class[] {DefaultDataClasses.STRING}, new Object[] { "\r\\\t" }, null)); //$NON-NLS-1$
+ }
+
}
Added: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMethods.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMethods.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMethods.java 2010-12-08 20:55:34 UTC (rev 2764)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.function;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class TestFunctionMethods {
+
+ @Test public void testUnescape() {
+ assertEquals("a\t\n\n%6", FunctionMethods.unescape("a\\t\\n\\012\\456"));
+ }
+
+ @Test public void testUnescape1() {
+ assertEquals("a\u45AA'", FunctionMethods.unescape("a\\u45Aa\'"));
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMethods.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 3 months
teiid SVN: r2763 - in branches/7.1.x/engine/src: test/java/org/teiid/dqp/internal/process and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-08 11:34:59 -0500 (Wed, 08 Dec 2010)
New Revision: 2763
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
branches/7.1.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
Log:
TEIID-1383 a fix for partial results mode
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-12-07 02:15:42 UTC (rev 2762)
+++ branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-12-08 16:34:59 UTC (rev 2763)
@@ -211,7 +211,7 @@
results = getResults();
}
} catch (TranslatorException e) {
- exceptionOccurred(e, true);
+ results = exceptionOccurred(e, true);
} catch (DataNotAvailableException e) {
dtm.scheduleWork(new Runnable() {
@Override
@@ -352,7 +352,7 @@
}
}
- void exceptionOccurred(TranslatorException exception, boolean removeState) throws TeiidComponentException, TeiidProcessingException {
+ AtomicResultsMessage exceptionOccurred(TranslatorException exception, boolean removeState) throws TeiidComponentException, TeiidProcessingException {
if (removeState) {
fullyCloseSource();
}
@@ -360,16 +360,15 @@
AtomicResultsMessage emptyResults = new AtomicResultsMessage(new List[0], null);
emptyResults.setWarnings(Arrays.asList((Exception)exception));
emptyResults.setFinalRow(this.rowsProcessed);
- receiveResults(emptyResults);
- } else {
- if (exception.getCause() instanceof TeiidComponentException) {
- throw (TeiidComponentException)exception.getCause();
- }
- if (exception.getCause() instanceof TeiidProcessingException) {
- throw (TeiidProcessingException)exception.getCause();
- }
- throw new TeiidProcessingException(exception);
- }
+ return emptyResults;
+ }
+ if (exception.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)exception.getCause();
+ }
+ if (exception.getCause() instanceof TeiidProcessingException) {
+ throw (TeiidProcessingException)exception.getCause();
+ }
+ throw new TeiidProcessingException(exception);
}
void receiveResults(AtomicResultsMessage response) {
Modified: branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-12-07 02:15:42 UTC (rev 2762)
+++ branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-12-08 16:34:59 UTC (rev 2763)
@@ -43,7 +43,6 @@
import org.teiid.query.sql.lang.Command;
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
-import org.teiid.translator.TranslatorException;
public class TestDataTierManager {
@@ -125,8 +124,16 @@
@Test public void testPartialResults() throws Exception {
helpSetup(1);
- info.exceptionOccurred(new TranslatorException(), true);
- assertNull(info.nextTuple());
+ connectorManager.throwExceptionOnExecute = true;
+ for (int i = 0; i < 10; i++) {
+ try {
+ assertNull(info.nextTuple());
+ return;
+ } catch (BlockedException e) {
+ Thread.sleep(50);
+ }
+ }
+ fail();
}
@Test public void testNoRowsException() throws Exception {
Modified: branches/7.1.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-12-07 02:15:42 UTC (rev 2762)
+++ branches/7.1.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-12-08 16:34:59 UTC (rev 2763)
@@ -70,9 +70,6 @@
@Override
public ConnectorWork registerRequest(AtomicRequestMessage message)
throws TeiidComponentException {
- if (throwExceptionOnExecute) {
- throw new TeiidComponentException("Connector Exception"); //$NON-NLS-1$
- }
List projectedSymbols = (message.getCommand()).getProjectedSymbols();
List[] results = createResults(projectedSymbols);
@@ -87,6 +84,9 @@
@Override
public AtomicResultsMessage execute() throws TranslatorException {
+ if (throwExceptionOnExecute) {
+ throw new TranslatorException("Connector Exception"); //$NON-NLS-1$
+ }
if (dataNotAvailable > -1) {
int delay = dataNotAvailable;
dataNotAvailable = -1;
14 years, 3 months
teiid SVN: r2762 - in trunk: documentation/caching-guide/src/main/docbook/en-US/content and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-12-06 21:15:42 -0500 (Mon, 06 Dec 2010)
New Revision: 2762
Modified:
trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.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/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
minor changes to the determinism level
Modified: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -87,24 +87,12 @@
* processing time.
*/
public enum Determinism{
- DETERMINISTIC(0),VDB_DETERMINISTIC(1),USER_DETERMINISTIC(2),SESSION_DETERMINISTIC(3),COMMAND_DETERMINISTIC(4),NONDETERMINISTIC(5);
- private int value;
-
- Determinism(int value){
- this.value = value;
- }
-
- public boolean isRestrictiveThan(Determinism that) {
- return this.value > that.value;
- }
-
- public boolean isRestrictiveThanOrEqual(Determinism that) {
- return this.value >= that.value;
- }
-
- public static Determinism restrictiveOf(Determinism scopeOne, Determinism scopeTwo) {
- return (scopeOne.value > scopeTwo.value)?scopeOne:scopeTwo;
- }
+ NONDETERMINISTIC,
+ COMMAND_DETERMINISTIC,
+ SESSION_DETERMINISTIC,
+ USER_DETERMINISTIC,
+ VDB_DETERMINISTIC,
+ DETERMINISTIC;
}
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml 2010-12-07 02:15:42 UTC (rev 2762)
@@ -24,8 +24,8 @@
</para></listitem>
<listitem><para><emphasis>updatable</emphasis> - if present indicates that the cached results can be updated. This is currently only applicable to materialized views.
</para></listitem>
- <listitem><para><emphasis>scope</emphasis> - if present indicates the override scope of query results. Using this flag, user can override the computed scope, to improve or force the results to cache.
- There are three different cache scopes, session - cached only for current session, user - cached for any session by the current user, vdb - cached for any user connected to the same vdb.
+ <listitem><para><emphasis>scope</emphasis> - if present indicates the override scope of query results. Using this flag, the user can override the computed scope.
+ There are three different cache scopes: session - cached only for current session, user - cached for any session by the current user, vdb - cached for any user connected to the same vdb.
</para></listitem>
</itemizedlist>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -142,13 +142,13 @@
prepPlan.setPlan(processPlan.clone());
prepPlan.setAnalysisRecord(analysisRecord);
- Determinism hintDeterminismLevel = null;
+ Determinism determinismLevel = this.context.getDeterminismLevel();
if (userCommand.getCacheHint() != null && userCommand.getCacheHint().getDeterminism() != null) {
- hintDeterminismLevel = userCommand.getCacheHint().getDeterminism();
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",this.context.getDeterminismLevel(), " to ", hintDeterminismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",this.context.getDeterminismLevel(), " to ", determinismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
+ determinismLevel = userCommand.getCacheHint().getDeterminism();
}
- this.prepPlanCache.put(id, hintDeterminismLevel!= null?hintDeterminismLevel:this.context.getDeterminismLevel(), prepPlan, userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
+ this.prepPlanCache.put(id, determinismLevel, prepPlan, userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
}
} else {
ProcessorPlan cachedPlan = prepPlan.getPlan();
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -396,7 +396,7 @@
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",processor.getContext().getDeterminismLevel(), " to ", determinismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
}
- if (determinismLevel.isRestrictiveThan(Determinism.SESSION_DETERMINISTIC)) {
+ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) {
LogManager.logInfo(LogConstants.CTX_DQP, QueryPlugin.Util.getString("RequestWorkItem.cache_nondeterministic", originalCommand)); //$NON-NLS-1$
}
dqpCore.getRsCache().put(cid, determinismLevel, cr, originalCommand.getCacheHint() != null?originalCommand.getCacheHint().getTtl():null);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -143,7 +143,7 @@
}
public void put(CacheID id, Determinism determinismLevel, T t, Long ttl){
- if (determinismLevel.isRestrictiveThanOrEqual(Determinism.SESSION_DETERMINISTIC)) {
+ if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) {
id.setSessionId(id.originalSessionId);
LogManager.logTrace(LogConstants.CTX_DQP, "Adding to session/local cache", id); //$NON-NLS-1$
this.localCache.put(id, t, ttl);
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -239,7 +239,7 @@
throw new FunctionExecutionException("ERR.015.001.0002", QueryPlugin.Util.getString("ERR.015.001.0002", getName())); //$NON-NLS-1$ //$NON-NLS-2$
}
- if (getDeterministic().isRestrictiveThanOrEqual(Determinism.USER_DETERMINISTIC) && values.length > 0 && values[0] instanceof CommandContext) {
+ if (getDeterministic().compareTo(Determinism.USER_DETERMINISTIC) <= 0 && values.length > 0 && values[0] instanceof CommandContext) {
CommandContext cc = (CommandContext)values[0];
cc.setDeterminismLevel(getDeterministic());
}
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 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -350,7 +350,7 @@
// TEIID-16: We do not want to merge a non-deterministic scalar function
Collection<Function> functions = FunctionCollectorVisitor.getFunctions(symbol, true, true);
for (Function function : functions) {
- if ( function.getFunctionDescriptor().getDeterministic().isRestrictiveThanOrEqual(Determinism.NONDETERMINISTIC )) {
+ if ( function.getFunctionDescriptor().getDeterministic() == Determinism.NONDETERMINISTIC) {
return false;
}
}
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 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -73,7 +73,7 @@
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
- || obj.getFunctionDescriptor().getDeterministic().isRestrictiveThanOrEqual(Determinism.COMMAND_DETERMINISTIC)) {
+ || obj.getFunctionDescriptor().getDeterministic().compareTo(Determinism.COMMAND_DETERMINISTIC) <= 0) {
evaluationNotPossible(EvaluationLevel.PROCESSING);
}
}
@@ -86,7 +86,9 @@
}
private void setDeterminismLevel(Determinism value) {
- determinismLevel = Determinism.restrictiveOf(determinismLevel, value);
+ if (determinismLevel == null || value.compareTo(determinismLevel) < 0) {
+ determinismLevel = value;
+ }
}
private void evaluationNotPossible(EvaluationLevel newLevel) {
@@ -197,7 +199,7 @@
EvaluatableVisitor visitor = new EvaluatableVisitor();
visitor.targetLevel = EvaluationLevel.PROCESSING;
PreOrderNavigator.doVisit(obj, visitor);
- if (pushdown && (visitor.hasCorrelatedReferences || visitor.determinismLevel.isRestrictiveThanOrEqual(Determinism.NONDETERMINISTIC))) {
+ if (pushdown && (visitor.hasCorrelatedReferences || visitor.determinismLevel == Determinism.NONDETERMINISTIC)) {
return false;
}
return visitor.isEvaluationPossible();
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -285,12 +285,11 @@
CachedResults cr = new CachedResults();
cr.setResults(tb);
cr.setHint(hint);
- Determinism hintDeterminismLevel = null;
if (hint != null && hint.getDeterminism() != null) {
- hintDeterminismLevel = hint.getDeterminism();
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",determinismLevel, " to ", hintDeterminismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",determinismLevel, " to ", hint.getDeterminism() }); //$NON-NLS-1$ //$NON-NLS-2$
+ determinismLevel = hint.getDeterminism();
}
- cache.put(cid, hintDeterminismLevel != null?hintDeterminismLevel:context.getDeterminismLevel(), cr, hint != null?hint.getTtl():null);
+ cache.put(cid, determinismLevel, cr, hint != null?hint.getTtl():null);
context.setDeterminismLevel(determinismLevel);
return tb.createIndexedTupleSource();
}
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -163,7 +163,9 @@
}
public void setDeterminismLevel(Determinism level) {
- globalState.determinismLevel = Determinism.restrictiveOf(globalState.determinismLevel, level);
+ if (globalState.determinismLevel == null || level.compareTo(globalState.determinismLevel) < 0) {
+ globalState.determinismLevel = level;
+ }
}
/**
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-12-07 02:13:52 UTC (rev 2761)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-12-07 02:15:42 UTC (rev 2762)
@@ -59,7 +59,7 @@
CommandContext cc = TestProcessor.createCommandContext();
cc.setTempTableStore(tempStore);
TestProcessor.doProcess(processorPlan, dataManager, expectedResults, cc);
- assertTrue(Determinism.SESSION_DETERMINISTIC.isRestrictiveThanOrEqual(cc.getDeterminismLevel()));
+ assertTrue(Determinism.SESSION_DETERMINISTIC.compareTo(cc.getDeterminismLevel()) <= 0);
}
@Before public void setUp() {
14 years, 3 months