teiid SVN: r3836 - in branches/7.7.x: engine/src/main/java/org/teiid/query/sql/visitor and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-01-31 13:11:54 -0500 (Tue, 31 Jan 2012)
New Revision: 3836
Modified:
branches/7.7.x/documentation/reference/src/main/docbook/en-US/content/procedures.xml
branches/7.7.x/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
branches/7.7.x/engine/src/test/java/org/teiid/query/parser/TestParser.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
branches/7.7.x/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
Log:
TEIID-1920 fixing issues with dynamic sql
Modified: branches/7.7.x/documentation/reference/src/main/docbook/en-US/content/procedures.xml
===================================================================
--- branches/7.7.x/documentation/reference/src/main/docbook/en-US/content/procedures.xml 2012-01-31 02:07:37 UTC (rev 3835)
+++ branches/7.7.x/documentation/reference/src/main/docbook/en-US/content/procedures.xml 2012-01-31 18:11:54 UTC (rev 3836)
@@ -37,7 +37,7 @@
</para>
<para>
Usage:
- <synopsis>EXECUTE STRING <expression> <optional>AS <variable> <type> [, <variable> <type>]* [INTO <variable>]</optional>
+ <synopsis>EXECUTE IMMEDIATE <expression> <optional>AS <variable> <type> [, <variable> <type>]* [INTO <variable>]</optional>
[USING <variable>=<expression> [,<variable>=<expression>]*] [UPDATE <literal>]
</synopsis>
</para>
@@ -52,7 +52,7 @@
</para>
</listitem>
<listitem>
- <para>The "USING" clause allows the dynamic SQL string to contain variable references that are bound at runtime to specified values. This allows for some independence of the SQL string from the surrounding procedure variable names and input names. In the dynamic command "USING" clause, each variable is specified by short name only. However in the dynamic SQL the "USING" variable must be fully qualified to "UVAR.". The "USING" clause is only for values that will be used in the dynamic SQL as legal expressions. It is not possible to use the "USING" clause to replace table names, keywords, etc. This makes using symbols equivalent in power to normal bind (?) expressions in prepared statements. The "USING" clause helps reduce the amount of string manipulation needed. If a reference is made to a USING symbol in the SQL string that is not bound to a value in the "USING" clause, an exception will occur.
+ <para>The "USING" clause allows the dynamic SQL string to contain variable references that are bound at runtime to specified values. This allows for some independence of the SQL string from the surrounding procedure variable names and input names. In the dynamic command "USING" clause, each variable is specified by short name only. However in the dynamic SQL the "USING" variable must be fully qualified to "DVAR.". The "USING" clause is only for values that will be used in the dynamic SQL as legal expressions. It is not possible to use the "USING" clause to replace table names, keywords, etc. This makes using symbols equivalent in power to normal bind (?) expressions in prepared statements. The "USING" clause helps reduce the amount of string manipulation needed. If a reference is made to a USING symbol in the SQL string that is not bound to a value in the "USING" clause, an exception will occur.
</para>
</listitem>
<listitem>
@@ -71,7 +71,7 @@
DECLARE string sql_string = 'SELECT ID, First || ‘‘ ‘‘ || Last AS Name, Birthdate FROM Customer.Accounts WHERE ' || criteria;
/* The execution of the SQL string will create the #temp table with the columns (ID, Name, Birthdate).
Note that we also have the USING clause to bind a value to LastName, which is referenced in the criteria. */
-EXECUTE STRING sql_string AS ID integer, Name string, Birthdate date INTO #temp USING LastName='some name';
+EXECUTE IMMEDIATE sql_string AS ID integer, Name string, Birthdate date INTO #temp USING LastName='some name';
/* The temp table can now be used with the values from the Dynamic SQL */
loop on (SELCT ID from #temp) as myCursor
...</programlisting>
@@ -98,7 +98,7 @@
END
ELSE
ERROR "ID or LastName must be specified.";
-EXECUTE STRING ‘SELECT ID, First || ‘‘ ‘‘ || Last AS Name, Birthdate FROM Customer.Accounts WHERE ’ || crit USING ID=AccountAccess.GetAccounts.ID, LastName=AccountAccess.GetAccounts.LastName, BirthDay=AccountAccess.GetAccounts.Bday;
+EXECUTE IMMEDIATE ‘SELECT ID, First || ‘‘ ‘‘ || Last AS Name, Birthdate FROM Customer.Accounts WHERE ’ || crit USING ID=AccountAccess.GetAccounts.ID, LastName=AccountAccess.GetAccounts.LastName, BirthDay=AccountAccess.GetAccounts.Bday;
...</programlisting>
</example>
<itemizedlist>
@@ -110,7 +110,7 @@
<example>
<title>Example Assignment
</title>
- <programlisting>EXECUTE STRING <expression> AS x string INTO #temp;
+ <programlisting>EXECUTE IMMEDIATE <expression> AS x string INTO #temp;
DECLARE string VARIABLES.RESULT = (SELECT x FROM #temp);</programlisting>
</example>
</listitem>
@@ -138,7 +138,7 @@
<example>
<title>Example with AS and INTO clauses</title>
<programlisting>/* This name does not need to match the expected update command symbol "count". */
-EXECUTE STRING <expression> AS x integer INTO #temp;</programlisting>
+EXECUTE IMMEDIATE <expression> AS x integer INTO #temp;</programlisting>
</example>
</listitem>
<listitem>
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2012-01-31 02:07:37 UTC (rev 3835)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2012-01-31 18:11:54 UTC (rev 3836)
@@ -699,6 +699,8 @@
public void visit( DynamicCommand obj ) {
append(EXECUTE);
append(SPACE);
+ append(IMMEDIATE);
+ append(SPACE);
visitNode(obj.getSql());
if (obj.isAsClauseSet()) {
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/parser/TestParser.java 2012-01-31 02:07:37 UTC (rev 3835)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/parser/TestParser.java 2012-01-31 18:11:54 UTC (rev 3836)
@@ -41,90 +41,12 @@
import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.language.SQLConstants.Reserved;
import org.teiid.language.SortSpecification.NullOrdering;
-import org.teiid.query.sql.lang.ArrayTable;
-import org.teiid.query.sql.lang.BetweenCriteria;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.CompareCriteria;
-import org.teiid.query.sql.lang.CompoundCriteria;
-import org.teiid.query.sql.lang.Create;
-import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.lang.Delete;
-import org.teiid.query.sql.lang.Drop;
-import org.teiid.query.sql.lang.DynamicCommand;
-import org.teiid.query.sql.lang.ExistsCriteria;
-import org.teiid.query.sql.lang.ExpressionCriteria;
-import org.teiid.query.sql.lang.From;
-import org.teiid.query.sql.lang.FromClause;
-import org.teiid.query.sql.lang.GroupBy;
-import org.teiid.query.sql.lang.Insert;
-import org.teiid.query.sql.lang.Into;
-import org.teiid.query.sql.lang.IsNullCriteria;
-import org.teiid.query.sql.lang.JoinPredicate;
-import org.teiid.query.sql.lang.JoinType;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.NotCriteria;
-import org.teiid.query.sql.lang.OrderBy;
-import org.teiid.query.sql.lang.OrderByItem;
-import org.teiid.query.sql.lang.PredicateCriteria;
-import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.SPParameter;
-import org.teiid.query.sql.lang.Select;
-import org.teiid.query.sql.lang.SetClauseList;
-import org.teiid.query.sql.lang.SetCriteria;
-import org.teiid.query.sql.lang.SetQuery;
-import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.lang.SubqueryCompareCriteria;
-import org.teiid.query.sql.lang.SubqueryFromClause;
-import org.teiid.query.sql.lang.SubquerySetCriteria;
-import org.teiid.query.sql.lang.TableFunctionReference;
-import org.teiid.query.sql.lang.TextTable;
-import org.teiid.query.sql.lang.UnaryFromClause;
-import org.teiid.query.sql.lang.Update;
-import org.teiid.query.sql.lang.WithQueryCommand;
-import org.teiid.query.sql.lang.XMLTable;
+import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.lang.TextTable.TextColumn;
-import org.teiid.query.sql.proc.AssignmentStatement;
-import org.teiid.query.sql.proc.Block;
-import org.teiid.query.sql.proc.BranchingStatement;
-import org.teiid.query.sql.proc.CommandStatement;
-import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
-import org.teiid.query.sql.proc.CriteriaSelector;
-import org.teiid.query.sql.proc.DeclareStatement;
-import org.teiid.query.sql.proc.HasCriteria;
-import org.teiid.query.sql.proc.IfStatement;
-import org.teiid.query.sql.proc.LoopStatement;
-import org.teiid.query.sql.proc.RaiseErrorStatement;
-import org.teiid.query.sql.proc.Statement;
-import org.teiid.query.sql.proc.TranslateCriteria;
-import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.proc.*;
import org.teiid.query.sql.proc.BranchingStatement.BranchingMode;
-import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.AliasSymbol;
-import org.teiid.query.sql.symbol.CaseExpression;
-import org.teiid.query.sql.symbol.Constant;
-import org.teiid.query.sql.symbol.DerivedColumn;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.Expression;
-import org.teiid.query.sql.symbol.ExpressionSymbol;
-import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.MultipleElementSymbol;
-import org.teiid.query.sql.symbol.Reference;
-import org.teiid.query.sql.symbol.ScalarSubquery;
-import org.teiid.query.sql.symbol.SearchedCaseExpression;
-import org.teiid.query.sql.symbol.TestCaseExpression;
-import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
-import org.teiid.query.sql.symbol.TextLine;
-import org.teiid.query.sql.symbol.WindowFunction;
-import org.teiid.query.sql.symbol.WindowSpecification;
-import org.teiid.query.sql.symbol.XMLAttributes;
-import org.teiid.query.sql.symbol.XMLElement;
-import org.teiid.query.sql.symbol.XMLForest;
-import org.teiid.query.sql.symbol.XMLNamespaces;
-import org.teiid.query.sql.symbol.XMLParse;
-import org.teiid.query.sql.symbol.XMLQuery;
-import org.teiid.query.sql.symbol.XMLSerialize;
+import org.teiid.query.sql.symbol.*;
@SuppressWarnings("nls")
public class TestParser {
@@ -3613,7 +3535,7 @@
CommandStatement cmdStmt = new CommandStatement(sqlCmd);
- helpStmtTest("exec string 'SELECT a1 FROM g WHERE a2 = 5' as a1 string into #g;", "EXECUTE 'SELECT a1 FROM g WHERE a2 = 5' AS a1 string INTO #g;", //$NON-NLS-1$ //$NON-NLS-2$
+ helpStmtTest("exec string 'SELECT a1 FROM g WHERE a2 = 5' as a1 string into #g;", "EXECUTE IMMEDIATE 'SELECT a1 FROM g WHERE a2 = 5' AS a1 string INTO #g;", //$NON-NLS-1$ //$NON-NLS-2$
cmdStmt);
}
@@ -3642,7 +3564,7 @@
CommandStatement cmdStmt = new CommandStatement(sqlCmd);
- helpStmtTest("execute string z as a1 string, a2 integer into #g update 1;", "EXECUTE z AS a1 string, a2 integer INTO #g UPDATE 1;", //$NON-NLS-1$ //$NON-NLS-2$
+ helpStmtTest("execute IMMEDIATE z as a1 string, a2 integer into #g update 1;", "EXECUTE IMMEDIATE z AS a1 string, a2 integer INTO #g UPDATE 1;", //$NON-NLS-1$ //$NON-NLS-2$
cmdStmt);
}
@@ -3660,7 +3582,7 @@
CommandStatement cmdStmt = new CommandStatement(sqlCmd);
- helpStmtTest("execute immediate z using a=b;", "EXECUTE z USING a = b;", //$NON-NLS-1$ //$NON-NLS-2$
+ helpStmtTest("execute immediate z using a=b;", "EXECUTE IMMEDIATE z USING a = b;", //$NON-NLS-1$ //$NON-NLS-2$
cmdStmt);
}
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2012-01-31 02:07:37 UTC (rev 3835)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2012-01-31 18:11:54 UTC (rev 3836)
@@ -1382,7 +1382,7 @@
helpTestProcessFailure(plan,
dataMgr,
- "Couldn't execute the dynamic SQL command \"EXECUTE 'EXEC pm1.sq2(''First'')' AS e1 string, e2 integer\" with the SQL statement \"'EXEC pm1.sq2(''First'')'\" due to: There is a recursive invocation of group 'PM1.SQ2'. Please correct the SQL.", metadata); //$NON-NLS-1$
+ "Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'EXEC pm1.sq2(''First'')' AS e1 string, e2 integer\" with the SQL statement \"'EXEC pm1.sq2(''First'')'\" due to: There is a recursive invocation of group 'PM1.SQ2'. Please correct the SQL.", metadata); //$NON-NLS-1$
}
@Test public void testDynamicCommandIncorrectProjectSymbolCount() throws Exception {
@@ -1403,7 +1403,7 @@
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE 'EXEC pm1.sq1(''First'')' AS e1 string, e2 integer\" with the SQL statement \"'EXEC pm1.sq1(''First'')'\" due to: The dynamic sql string contains an incorrect number of elements.", metadata); //$NON-NLS-1$
+ helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'EXEC pm1.sq1(''First'')' AS e1 string, e2 integer\" with the SQL statement \"'EXEC pm1.sq1(''First'')'\" due to: The dynamic sql string contains an incorrect number of elements.", metadata); //$NON-NLS-1$
}
@Test public void testDynamicCommandPositional() throws Exception {
@@ -1436,7 +1436,7 @@
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE 'select e1 from pm1.g1'\" with the SQL statement \"'select e1 from pm1.g1'\" due to: The datatype 'string' for element 'e1' in the dynamic SQL cannot be implicitly converted to 'integer'.", metadata); //$NON-NLS-1$
+ helpTestProcessFailure(plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE IMMEDIATE 'select e1 from pm1.g1'\" with the SQL statement \"'select e1 from pm1.g1'\" due to: The datatype 'string' for element 'e1' in the dynamic SQL cannot be implicitly converted to 'integer'.", metadata); //$NON-NLS-1$
}
@Test public void testDynamicCommandWithTwoDynamicStatements() throws Exception {
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2012-01-31 02:07:37 UTC (rev 3835)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2012-01-31 18:11:54 UTC (rev 3836)
@@ -37,36 +37,7 @@
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.sql.LanguageObject;
-import org.teiid.query.sql.lang.BetweenCriteria;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.CompareCriteria;
-import org.teiid.query.sql.lang.CompoundCriteria;
-import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.lang.Delete;
-import org.teiid.query.sql.lang.DynamicCommand;
-import org.teiid.query.sql.lang.ExistsCriteria;
-import org.teiid.query.sql.lang.From;
-import org.teiid.query.sql.lang.GroupBy;
-import org.teiid.query.sql.lang.Insert;
-import org.teiid.query.sql.lang.IsNullCriteria;
-import org.teiid.query.sql.lang.JoinPredicate;
-import org.teiid.query.sql.lang.JoinType;
-import org.teiid.query.sql.lang.Limit;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.NotCriteria;
-import org.teiid.query.sql.lang.Option;
-import org.teiid.query.sql.lang.OrderBy;
-import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.SPParameter;
-import org.teiid.query.sql.lang.Select;
-import org.teiid.query.sql.lang.SetCriteria;
-import org.teiid.query.sql.lang.SetQuery;
-import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.lang.SubqueryCompareCriteria;
-import org.teiid.query.sql.lang.SubqueryFromClause;
-import org.teiid.query.sql.lang.SubquerySetCriteria;
-import org.teiid.query.sql.lang.UnaryFromClause;
-import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.proc.AssignmentStatement;
import org.teiid.query.sql.proc.Block;
@@ -77,21 +48,7 @@
import org.teiid.query.sql.proc.HasCriteria;
import org.teiid.query.sql.proc.IfStatement;
import org.teiid.query.sql.proc.RaiseErrorStatement;
-import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.AliasSymbol;
-import org.teiid.query.sql.symbol.CaseExpression;
-import org.teiid.query.sql.symbol.Constant;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.Expression;
-import org.teiid.query.sql.symbol.ExpressionSymbol;
-import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.MultipleElementSymbol;
-import org.teiid.query.sql.symbol.Reference;
-import org.teiid.query.sql.symbol.ScalarSubquery;
-import org.teiid.query.sql.symbol.SearchedCaseExpression;
-import org.teiid.query.sql.symbol.TestCaseExpression;
-import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
+import org.teiid.query.sql.symbol.*;
import org.teiid.query.unittest.RealMetadataFactory;
@SuppressWarnings("nls")
@@ -1716,7 +1673,7 @@
obj.setAsClauseSet(true);
obj.setIntoGroup(new GroupSymbol("#g")); //$NON-NLS-1$
- helpTest(obj, "EXECUTE 'SELECT a1 FROM g WHERE a2 = 5' AS a1 string INTO #g"); //$NON-NLS-1$
+ helpTest(obj, "EXECUTE IMMEDIATE 'SELECT a1 FROM g WHERE a2 = 5' AS a1 string INTO #g"); //$NON-NLS-1$
}
@Test public void testScalarSubquery() {
12 years, 11 months
teiid SVN: r3835 - in trunk: engine/src/main/java/org/teiid/query and 6 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-01-30 21:07:37 -0500 (Mon, 30 Jan 2012)
New Revision: 3835
Modified:
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestConstant.java
Log:
TEIID-1916 adding collation support via a locale system property.
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-01-31 02:07:37 UTC (rev 3835)
@@ -36,8 +36,12 @@
</UL>
<LI><B>Continuous Asynch Queries</B> to process plans in a streamed window fashion the TeiidStatement/TeiidPreparedStatement methods now take a RequestOptions object to specify continuous mode. See the Client and Developers Guides for more.
<LI><B>Texttable selectors</B> - can be used to selectively parse only record lines matching a given selector string. Selectors may also be used for column values to join data from other records positionally.
- <LI><B>Comparable LOBs</B> - the system property org.teiid.comparableLobs can be set to use CLOB and BLOB values in comparison/sorting/grouping operations.
- <LI><B>Padded String Comparison</B> - the system property org.teiid.padSpace can be set to effectively right pad strings to the same length for comparison.
+ <LI><B>Enhanced Comparison Support</B> - see the Admin Guide more.
+ <UL>
+ <LI><B>Comparable LOBs</B> - the system property org.teiid.comparableLobs can be set to use CLOB and BLOB values in comparison/sorting/grouping operations.
+ <LI><B>Padded Comparison</B> - the system property org.teiid.padSpace can be set to effectively right pad strings to the same length for comparison.
+ <LI><B>Collation Support</B> - the system property org.teiid.collationLocale can be set to use a different collation than the Java UTF-16 default.
+ </UL>
<LI><B>VARBINARY type support</B> - the Teiid VARBINARY type can now be used to support source BINARY and VARBINARY types.
</UL>
Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-01-31 02:07:37 UTC (rev 3835)
@@ -75,5 +75,7 @@
TEIID30029, // unexpected format
TEIID30030, // unexpected exp1
TEIID30031, // unexpected exp2
+ TEIID30032, // invalid collation locale
+ TEIID30033, // using collation locale
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2012-01-31 02:07:37 UTC (rev 3835)
@@ -298,35 +298,6 @@
return compare(criteria, leftValue, rightValue);
}
- public static Boolean compare(CompareCriteria criteria, Object leftValue,
- Object rightValue) throws ExpressionEvaluationException {
- switch(criteria.getOperator()) {
- case CompareCriteria.EQ:
- return Boolean.valueOf(compareValues(leftValue, rightValue) == 0);
- case CompareCriteria.NE:
- return Boolean.valueOf(compareValues(leftValue, rightValue) != 0);
- case CompareCriteria.LT:
- return Boolean.valueOf((compareValues(leftValue, rightValue) < 0));
- case CompareCriteria.LE:
- return Boolean.valueOf((compareValues(leftValue, rightValue) <= 0));
- case CompareCriteria.GT:
- return Boolean.valueOf((compareValues(leftValue, rightValue) > 0));
- case CompareCriteria.GE:
- return Boolean.valueOf((compareValues(leftValue, rightValue) >= 0));
- default:
- throw new ExpressionEvaluationException("ERR.015.006.0012", QueryPlugin.Util.getString("ERR.015.006.0012", criteria.getOperator())); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- private static final int compareValues(Object leftValue, Object rightValue) {
- assert leftValue instanceof Comparable<?>;
- assert rightValue instanceof Comparable<?>;
- if (leftValue == rightValue) {
- return 0;
- }
- return Constant.compare((Comparable<?>)leftValue, (Comparable<?>)rightValue);
- }
-
public Boolean evaluate(MatchCriteria criteria, List<?> tuple)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
@@ -467,7 +438,7 @@
}
if(value != null) {
- if(compareValues(leftValue, value) == 0) {
+ if(Constant.COMPARATOR.compare(leftValue, value) == 0) {
return Boolean.valueOf(!criteria.isNegated());
} // else try next value
} else {
@@ -532,30 +503,7 @@
Object value = valueIter.next();
if(value != null) {
- int compare = compareValues(leftValue, value);
- // Compare two non-null values using specified operator
- switch(criteria.getOperator()) {
- case SubqueryCompareCriteria.EQ:
- result = Boolean.valueOf(compare == 0);
- break;
- case SubqueryCompareCriteria.NE:
- result = Boolean.valueOf(compare != 0);
- break;
- case SubqueryCompareCriteria.LT:
- result = Boolean.valueOf(compare < 0);
- break;
- case SubqueryCompareCriteria.LE:
- result = Boolean.valueOf(compare <= 0);
- break;
- case SubqueryCompareCriteria.GT:
- result = Boolean.valueOf(compare > 0);
- break;
- case SubqueryCompareCriteria.GE:
- result = Boolean.valueOf(compare >= 0);
- break;
- default:
- throw new ExpressionEvaluationException("ERR.015.006.0012", QueryPlugin.Util.getString("ERR.015.006.0012", criteria.getOperator())); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ result = compare(criteria, leftValue, value);
switch(criteria.getPredicateQuantifier()) {
case SubqueryCompareCriteria.ALL:
@@ -582,6 +530,36 @@
return result;
}
+ public static Boolean compare(AbstractCompareCriteria criteria, Object leftValue,
+ Object value) throws AssertionError {
+ int compare = Constant.COMPARATOR.compare(leftValue, value);
+ // Compare two non-null values using specified operator
+ Boolean result = null;
+ switch(criteria.getOperator()) {
+ case CompareCriteria.EQ:
+ result = Boolean.valueOf(compare == 0);
+ break;
+ case CompareCriteria.NE:
+ result = Boolean.valueOf(compare != 0);
+ break;
+ case CompareCriteria.LT:
+ result = Boolean.valueOf(compare < 0);
+ break;
+ case CompareCriteria.LE:
+ result = Boolean.valueOf(compare <= 0);
+ break;
+ case CompareCriteria.GT:
+ result = Boolean.valueOf(compare > 0);
+ break;
+ case CompareCriteria.GE:
+ result = Boolean.valueOf(compare >= 0);
+ break;
+ default:
+ throw new AssertionError();
+ }
+ return result;
+ }
+
public boolean evaluate(ExistsCriteria criteria, List<?> tuple)
throws BlockedException, TeiidComponentException, ExpressionEvaluationException {
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2012-01-31 02:07:37 UTC (rev 3835)
@@ -749,13 +749,21 @@
// ================== Function = righttrim =====================
public static String rightTrim(String string, char trimChar) {
+ return rightTrim(string, trimChar, true);
+ }
+
+ public static String rightTrim(String string, char trimChar, boolean newString) {
for(int i=string.length()-1; i>=0; i--) {
if(string.charAt(i) != trimChar) {
// end of trim, return what's left
if (i==string.length()-1) {
return string;
}
- return new String(string.substring(0, i+1));
+ String result = string.substring(0, i+1);
+ if (newString) {
+ return new String(result);
+ }
+ return result;
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-01-31 02:07:37 UTC (rev 3835)
@@ -100,11 +100,11 @@
setState.valueIterator = dvs.getValueIterator(setState.valueExpression);
if (setState.maxNdv > 0 && setState.maxNdv < dvs.getTupleBuffer().getRowCount()) {
ValueIterator vi = dvs.getValueIterator(setState.valueExpression);
- Comparable last = null;
+ Object last = null;
int distinctCount = 0;
while (vi.hasNext()) {
- Comparable next = (Comparable) vi.next();
- if (last == null || Constant.compare(next, last) != 0) {
+ Object next = vi.next();
+ if (last == null || Constant.COMPARATOR.compare(next, last) != 0) {
distinctCount++;
}
last = next;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java 2012-01-31 02:07:37 UTC (rev 3835)
@@ -174,7 +174,7 @@
return -1;
}
} else {
- compare = Constant.compare(param1, param2);
+ compare = Constant.COMPARATOR.compare(param1, param2);
}
if (compare != 0) {
boolean asc = orderTypes != null?orderTypes.get(k):this.ascendingOrder;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java 2012-01-31 02:07:37 UTC (rev 3835)
@@ -323,7 +323,7 @@
return 1;
}
- int c = Constant.compare((Comparable)rightValue, (Comparable)leftValue);
+ int c = Constant.COMPARATOR.compare(rightValue, leftValue);
if (c != 0) {
return c;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java 2012-01-31 02:07:37 UTC (rev 3835)
@@ -23,11 +23,17 @@
package org.teiid.query.sql.symbol;
import java.math.BigDecimal;
+import java.text.Collator;
+import java.util.Comparator;
import java.util.List;
+import java.util.Locale;
import org.teiid.core.types.ClobType;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.FunctionMethods;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -47,6 +53,72 @@
private boolean multiValued;
private boolean bindEligible;
+ public static final String COLLATION_LOCALE = System.getProperties().getProperty("org.teiid.collationLocale"); //$NON-NLS-1$
+
+ public static final Comparator<Object> COMPARATOR = getComparator(COLLATION_LOCALE, DataTypeManager.PAD_SPACE);
+
+ static Comparator<Object> getComparator(String localeString, final boolean padSpace) {
+ if (localeString == null) {
+ return getComparator(padSpace);
+ }
+ String[] parts = localeString.split("_"); //$NON-NLS-1$
+ Locale locale = null;
+ if (parts.length == 1) {
+ locale = new Locale(parts[0]);
+ } else if (parts.length == 2) {
+ locale = new Locale(parts[0], parts[1]);
+ } else if (parts.length == 3) {
+ locale = new Locale(parts[0], parts[1], parts[2]);
+ } else {
+ LogManager.logError(LogConstants.CTX_DQP, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30032, localeString));
+ return getComparator(padSpace);
+ }
+ final Collator c = Collator.getInstance(locale);
+ LogManager.logError(LogConstants.CTX_DQP, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30033, locale));
+ return new Comparator<Object>() {
+ @Override
+ public int compare(Object o1, Object o2) {
+ Class<?> clazz = o1.getClass();
+ if (clazz == String.class) {
+ String s1 = (String)o1;
+ String s2 = (String)o2;
+ if (padSpace) {
+ s1 = FunctionMethods.rightTrim(s1, ' ', false);
+ s2 = FunctionMethods.rightTrim(s2, ' ', false);
+ }
+ return c.compare(s1, s2);
+ }
+ return ((Comparable<Object>)o1).compareTo(o2);
+ }
+ };
+ }
+
+ static Comparator<Object> getComparator(boolean padSpace) {
+ if (!padSpace) {
+ return new Comparator<Object>() {
+ @Override
+ public int compare(Object o1, Object o2) {
+ return ((Comparable<Object>)o1).compareTo(o2);
+ }
+ };
+ }
+ return new Comparator<Object>() {
+ @Override
+ public int compare(Object o1, Object o2) {
+ Class<?> clazz = o1.getClass();
+ if (clazz == String.class) {
+ CharSequence s1 = (CharSequence)o1;
+ CharSequence s2 = (CharSequence)o2;
+ return comparePadded(s1, s2);
+ } else if (clazz == ClobType.class) {
+ CharSequence s1 = ((ClobType)o1).getCharSequence();
+ CharSequence s2 = ((ClobType)o2).getCharSequence();
+ return comparePadded(s1, s2);
+ }
+ return ((Comparable<Object>)o1).compareTo(o2);
+ }
+ };
+ }
/**
* Construct a typed constant. The specified value is not verified to be a value
* of the specified type. If this is not true, stuff probably won't work later on.
@@ -224,31 +296,9 @@
if (o.isNull()) {
return 1;
}
- return compare((Comparable<?>)this.value, (Comparable<?>)o.getValue());
+ return COMPARATOR.compare(this.value, o.getValue());
}
- /**
- * Compare the given non-null values
- * @param o1
- * @param o2
- * @return
- */
- public final static int compare(Comparable o1, Comparable o2) {
- if (DataTypeManager.PAD_SPACE) {
- Class<?> clazz = o1.getClass();
- if (clazz == String.class) {
- CharSequence s1 = (CharSequence)o1;
- CharSequence s2 = (CharSequence)o2;
- return comparePadded(s1, s2);
- } else if (clazz == ClobType.class) {
- CharSequence s1 = ((ClobType)o1).getCharSequence();
- CharSequence s2 = ((ClobType)o2).getCharSequence();
- return comparePadded(s1, s2);
- }
- }
- return o1.compareTo(o2);
- }
-
final static int comparePadded(CharSequence s1, CharSequence s2) {
int len1 = s1.length();
int len2 = s2.length();
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-01-31 02:07:37 UTC (rev 3835)
@@ -78,7 +78,6 @@
# processor (006)
ERR.015.006.0010= Unknown criteria type: {0}
ERR.015.006.0011= Unable to evaluate {0} expression of {1}
-ERR.015.006.0012= Unknown compare criteria operator: {0}
ERR.015.006.0014= Failed to create regular expression from match pattern: {0}. {1}
ERR.015.006.0015= Unable to evaluate expression of {0}
ERR.015.006.0016= Unknown expression type: {0}
@@ -956,3 +955,6 @@
TEIID30026=Failed to cancel {0}
TEIID30030=Unhandled exception disposing reusable execution
TEIID30031=Unhandled exception calling CommandListener
+TEIID30032=Invalid locale {0} for collation, using default collation
+TEIID30033=Using collator for locale {0}
+
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestConstant.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestConstant.java 2012-01-30 18:19:21 UTC (rev 3834)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestConstant.java 2012-01-31 02:07:37 UTC (rev 3835)
@@ -24,6 +24,11 @@
import static org.junit.Assert.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
import org.junit.Test;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.UnitTestUtil;
@@ -155,7 +160,16 @@
assertEquals(-24, Constant.comparePadded("ab ", "az "));
assertEquals(66, Constant.comparePadded("ab ", "a "));
assertEquals(0, Constant.comparePadded("a1 ", "a1"));
-
}
+
+ @Test public void testCollation() {
+ Comparator<Object> c = Constant.getComparator("es", true);
+
+ List<String> vals = Arrays.asList("ñ", "n", "o");
+ Collections.sort(vals, c);
+ assertEquals("ñ", vals.get(1));
+
+ assertEquals(0, c.compare("a ", "a"));
+ }
}
12 years, 11 months
teiid SVN: r3834 - branches/7.7.x/api/src/main/java/org/teiid/language/visitor.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-01-30 13:19:21 -0500 (Mon, 30 Jan 2012)
New Revision: 3834
Modified:
branches/7.7.x/api/src/main/java/org/teiid/language/visitor/AbstractLanguageVisitor.java
branches/7.7.x/api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java
branches/7.7.x/api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java
branches/7.7.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
Log:
removing references to ILanguageObject
Modified: branches/7.7.x/api/src/main/java/org/teiid/language/visitor/AbstractLanguageVisitor.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/language/visitor/AbstractLanguageVisitor.java 2012-01-30 18:18:50 UTC (rev 3833)
+++ branches/7.7.x/api/src/main/java/org/teiid/language/visitor/AbstractLanguageVisitor.java 2012-01-30 18:19:21 UTC (rev 3834)
@@ -28,9 +28,9 @@
/**
- * Visitor that visits an instance of ILanguageObject and performs an operation
+ * Visitor that visits an instance of LanguageObject and performs an operation
* on that instance. The visit() methods of this Visitor can be selectively
- * overridden to perform operations on each type of ILanguageObject. The public
+ * overridden to perform operations on each type of LanguageObject. The public
* visit() methods should not be called directly, as they are only used by this
* visitor framework to let the instance invoke the type-specific visit() method
*/
@@ -40,11 +40,11 @@
}
/**
- * Visit the ILanguageObject instance to perform the Visitor's operation on
+ * Visit the LanguageObject instance to perform the Visitor's operation on
* that instance. This method can also be used by the subclass to visit any
- * ILanguageObject instances that the given instance may contain.
+ * LanguageObject instances that the given instance may contain.
* @see HierarchyVisitor
- * @param obj an ILanguageObject instance
+ * @param obj an LanguageObject instance
*/
public void visitNode(LanguageObject obj) {
if (obj != null) {
@@ -53,9 +53,9 @@
}
/**
- * Visits a Collection of ILanguageObjects in iteration order. This method
- * can be used by subclasses to visit each ILanguageObject in the Collection
- * @param nodes a Collection of ILanguageObjects
+ * Visits a Collection of LanguageObjects in iteration order. This method
+ * can be used by subclasses to visit each LanguageObject in the Collection
+ * @param nodes a Collection of LanguageObjects
*/
public void visitNodes(Collection<? extends LanguageObject> nodes) {
if (nodes != null && nodes.size() > 0) {
@@ -66,9 +66,9 @@
}
/**
- * Visits an array of ILanguageObjects in order. This method can be used by
- * subclasses to visit each ILanguageObject in the array.
- * @param nodes an ILanguageObject[]
+ * Visits an array of LanguageObjects in order. This method can be used by
+ * subclasses to visit each LanguageObject in the array.
+ * @param nodes an LanguageObject[]
*/
public void visitNodes(LanguageObject[] nodes) {
if (nodes != null && nodes.length > 0) {
Modified: branches/7.7.x/api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java 2012-01-30 18:18:50 UTC (rev 3833)
+++ branches/7.7.x/api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java 2012-01-30 18:19:21 UTC (rev 3834)
@@ -65,7 +65,7 @@
* of the specified tree in the language object tree.
* @param type Language object type to look for
* @param object Root of the language object tree
- * @return Collection of ILanguageObject of the specified type
+ * @return Collection of LanguageObject of the specified type
*/
public static <T> Collection<T> collectObjects(Class<T> type, LanguageObject object) {
CollectorVisitor<T> visitor = new CollectorVisitor<T>(type);
Modified: branches/7.7.x/api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java 2012-01-30 18:18:50 UTC (rev 3833)
+++ branches/7.7.x/api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java 2012-01-30 18:19:21 UTC (rev 3834)
@@ -57,13 +57,13 @@
import org.teiid.language.WithItem;
/**
- * Visits each node in a hierarchy of ILanguageObjects. The default
+ * Visits each node in a hierarchy of LanguageObjects. The default
* implementation of each visit() method is simply to visit the children of a
- * given ILanguageObject, if any exist, with this HierarchyVisitor (without
+ * given LanguageObject, if any exist, with this HierarchyVisitor (without
* performing any actions on the node). A subclass can selectively override
* visit() methods to delegate the actions performed on a node to another
* visitor by calling that Visitor's visit() method. This implementation makes
- * no guarantees about the order in which the children of an ILanguageObject are
+ * no guarantees about the order in which the children of an LanguageObject are
* visited.
* @see DelegatingHierarchyVisitor
*/
Modified: branches/7.7.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2012-01-30 18:18:50 UTC (rev 3833)
+++ branches/7.7.x/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2012-01-30 18:19:21 UTC (rev 3834)
@@ -113,7 +113,7 @@
}
/**
- * Appends the string form of the ILanguageObject to the current buffer.
+ * Appends the string form of the LanguageObject to the current buffer.
* @param obj the language object instance
*/
public void append(LanguageObject obj) {
@@ -127,7 +127,7 @@
/**
* Simple utility to append a list of language objects to the current buffer
* by creating a comma-separated list.
- * @param items a list of ILanguageObjects
+ * @param items a list of LanguageObjects
*/
protected void append(List<? extends LanguageObject> items) {
if (items != null && items.size() != 0) {
@@ -143,7 +143,7 @@
/**
* Simple utility to append an array of language objects to the current buffer
* by creating a comma-separated list.
- * @param items an array of ILanguageObjects
+ * @param items an array of LanguageObjects
*/
protected void append(LanguageObject[] items) {
if (items != null && items.length != 0) {
@@ -991,11 +991,11 @@
}
/**
- * Gets the SQL string representation for a given ILanguageObject.
- * @param obj the root of the ILanguageObject hierarchy that needs to be
+ * Gets the SQL string representation for a given LanguageObject.
+ * @param obj the root of the LanguageObject hierarchy that needs to be
* converted. This can be any subtree, and does not need to be a top-level
* command
- * @return the SQL representation of that ILanguageObject hierarchy
+ * @return the SQL representation of that LanguageObject hierarchy
*/
public static String getSQLString(LanguageObject obj) {
SQLStringVisitor visitor = new SQLStringVisitor();
12 years, 11 months
teiid SVN: r3833 - branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-01-30 13:18:50 -0500 (Mon, 30 Jan 2012)
New Revision: 3833
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
Log:
TEIID-1915 correction to thread coordination in XMLTableNode
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2012-01-27 18:10:06 UTC (rev 3832)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2012-01-30 18:18:50 UTC (rev 3833)
@@ -88,8 +88,15 @@
private Item item;
private TupleBuffer buffer;
- private boolean batchAvailable = false;
- private TeiidRuntimeException asynchException;
+
+ private enum State {
+ BUILDING,
+ AVAILABLE,
+ DONE
+ };
+
+ private State state = State.BUILDING;
+ private volatile TeiidRuntimeException asynchException;
private int outputRow = 1;
private boolean usingOutput;
@@ -121,7 +128,7 @@
outputRow = 1;
usingOutput = false;
this.buffer = null;
- this.batchAvailable = false;
+ this.state = State.BUILDING;
this.asynchException = null;
}
@@ -149,7 +156,7 @@
evaluate(false);
if (this.table.getXQueryExpression().isStreaming()) {
- while (!batchAvailable) {
+ while (state == State.BUILDING) {
try {
this.wait();
} catch (InterruptedException e) {
@@ -159,7 +166,9 @@
unwrapException(asynchException);
TupleBatch batch = this.buffer.getBatch(outputRow);
outputRow = batch.getEndRow() + 1;
- batchAvailable = hasNextBatch();
+ if (state != State.DONE && !batch.getTerminationFlag()) {
+ state = hasNextBatch()?State.AVAILABLE:State.BUILDING;
+ }
return batch;
}
@@ -195,16 +204,20 @@
if (this.table.getXQueryExpression().isStreaming()) {
if (this.buffer == null) {
this.buffer = this.getBufferManager().createTupleBuffer(getOutputElements(), getConnectionID(), TupleSourceType.PROCESSOR);
+ if (!useFinalBuffer) {
+ this.buffer.setForwardOnly(true);
+ }
}
Runnable r = new Runnable() {
@Override
public void run() {
try {
- if (!useFinalBuffer) {
- buffer.setForwardOnly(true);
+ XQueryEvaluator.evaluateXQuery(table.getXQueryExpression(), contextItem, parameters, XMLTableNode.this, getContext());
+ synchronized (XMLTableNode.this) {
+ if (buffer != null) {
+ buffer.close();
+ }
}
- XQueryEvaluator.evaluateXQuery(table.getXQueryExpression(), contextItem, parameters, XMLTableNode.this, getContext());
- buffer.close();
} catch (TeiidException e) {
asynchException = new TeiidRuntimeException(e);
} catch (TeiidRuntimeException e) {
@@ -214,8 +227,8 @@
asynchException = new TeiidRuntimeException(e);
}
} finally {
- batchAvailable = true;
synchronized (XMLTableNode.this) {
+ state = State.DONE;
XMLTableNode.this.notifyAll();
}
}
@@ -323,12 +336,13 @@
if (isClosed()) {
throw EARLY_TERMINATION;
}
+ assert this.state != State.DONE;
this.item = row;
rowCount++;
try {
this.buffer.addTuple(processRow());
- if (hasNextBatch()) {
- this.batchAvailable = true;
+ if (state == State.BUILDING && hasNextBatch()) {
+ this.state = State.AVAILABLE;
this.notifyAll();
}
} catch (TeiidException e) {
12 years, 11 months
teiid SVN: r3832 - branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-01-27 13:10:06 -0500 (Fri, 27 Jan 2012)
New Revision: 3832
Modified:
branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
refining fix for threading issue with the unit test
Modified: branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-27 18:09:39 UTC (rev 3831)
+++ branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-27 18:10:06 UTC (rev 3832)
@@ -376,7 +376,7 @@
assertEquals(10, rm.getResultsList().size());
RequestWorkItem item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
synchronized (item) {
- while (item.isProcessing()) {
+ for (int i = 0; i < 100; i++) {
Thread.sleep(10);
}
}
12 years, 11 months
teiid SVN: r3831 - branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-01-27 13:09:39 -0500 (Fri, 27 Jan 2012)
New Revision: 3831
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
Log:
TEIID-1912 refining distinct check
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-01-26 19:28:47 UTC (rev 3830)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-01-27 18:09:39 UTC (rev 3831)
@@ -99,16 +99,19 @@
}
for (SetState setState : dependentSetStates) {
setState.valueIterator = dvs.getValueIterator(setState.valueExpression);
- if (setState.maxNdv > 0 && setState.maxNdv < dvs.getTupleBuffer().getRowCount()) {
- ValueIterator vi = dvs.getValueIterator(setState.valueExpression);
- Comparable last = null;
- int distinctCount = 0;
- while (vi.hasNext()) {
- Comparable next = (Comparable) vi.next();
- if (last == null || next.compareTo(last) != 0) {
- distinctCount++;
- }
- last = next;
+ int distinctCount = dvs.getTupleBuffer().getRowCount();
+ if (setState.maxNdv > 0 && setState.maxNdv < distinctCount) {
+ if (dvs.getTupleBuffer().getSchema().size() >= 1) {
+ distinctCount = 0;
+ ValueIterator vi = dvs.getValueIterator(setState.valueExpression);
+ Comparable last = null;
+ while (vi.hasNext()) {
+ Comparable next = (Comparable) vi.next();
+ if (last == null || next.compareTo(last) != 0) {
+ distinctCount++;
+ }
+ last = next;
+ }
}
if (!setState.overMax && distinctCount > setState.maxNdv) {
LogManager.logWarning(LogConstants.CTX_DQP, QueryPlugin.Util.getString("DependentCriteriaProcessor.dep_join_backoff", valueSource, setState.valueExpression, setState.maxNdv)); //$NON-NLS-1$
12 years, 11 months
teiid SVN: r3830 - in trunk: jboss-integration/src/main/java/org/teiid/jboss and 1 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-01-26 14:28:47 -0500 (Thu, 26 Jan 2012)
New Revision: 3830
Modified:
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
Log:
TEIID-1911: temporary fix for the to avoid metadata deletion during the shutdown.
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-01-26 17:43:46 UTC (rev 3829)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-01-26 19:28:47 UTC (rev 3830)
@@ -46,6 +46,7 @@
<li>Support for named parameter syntax using param=value has been deprecated, since it is ambiguous with a comparison predicate boolean value expression. param<b>=></b>value should be used instead.
<li>Support for using the FROM clause post item hints MAKEDEP/MAKENOTDEP has been deprecated. Use the pre item comment hint syntax instead, e.g. /*+ MAKEDEP */ tbl
<li>decodeinteger/decodestring have been deprecated. A CASE expression should be used instead.
+ <li>allowCreateTemporaryTablesByDefault and allowFunctionCallsByDefault are now set to false. When data roles are in use the user must explicitly grant these options to the user on VDB
</ul>
<h4>from 7.x</h4>
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-01-26 17:43:46 UTC (rev 3829)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-01-26 19:28:47 UTC (rev 3830)
@@ -409,7 +409,7 @@
processorTarget.addDeploymentProcessor(Phase.STRUCTURE, Phase.STRUCTURE_WAR_DEPLOYMENT_INIT|0x0001,new VDBStructureDeployer());
processorTarget.addDeploymentProcessor(Phase.PARSE, Phase.PARSE_WEB_DEPLOYMENT|0x0001, new VDBParserDeployer());
processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES, Phase.DEPENDENCIES_WAR_MODULE|0x0001, new VDBDependencyDeployer());
- processorTarget.addDeploymentProcessor(Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT|0x1000, new VDBDeployer(translatorRepo, asyncThreadPoolName, statusChecker, shutdownListener));
+ processorTarget.addDeploymentProcessor(Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT|0x1000, new VDBDeployer(translatorRepo, asyncThreadPoolName, statusChecker));
// translator deployers
processorTarget.addDeploymentProcessor(Phase.STRUCTURE, Phase.STRUCTURE_JDBC_DRIVER|0x0001,new TranslatorStructureDeployer());
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-01-26 17:43:46 UTC (rev 3829)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-01-26 19:28:47 UTC (rev 3830)
@@ -34,16 +34,22 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.modules.Module;
-import org.jboss.msc.service.*;
+import org.jboss.msc.service.Service;
+import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceBuilder.DependencyType;
+import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceController.Mode;
import org.jboss.msc.service.ServiceController.State;
+import org.jboss.msc.service.AbstractServiceListener;
+import org.jboss.msc.service.ServiceName;
+import org.jboss.msc.service.StartContext;
+import org.jboss.msc.service.StartException;
+import org.jboss.msc.service.StopContext;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
-import org.teiid.deployers.ContainerLifeCycleListener;
import org.teiid.deployers.UDFMetaData;
import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VDBStatusChecker;
@@ -61,17 +67,15 @@
private TranslatorRepository translatorRepository;
private String asyncThreadPoolName;
private VDBStatusChecker vdbStatusChecker;
- private ContainerLifeCycleListener shutdownListener;
- public VDBDeployer (TranslatorRepository translatorRepo, String poolName, VDBStatusChecker vdbStatusChecker, ContainerLifeCycleListener shutdownListener) {
+ public VDBDeployer (TranslatorRepository translatorRepo, String poolName, VDBStatusChecker vdbStatusChecker) {
this.translatorRepository = translatorRepo;
this.asyncThreadPoolName = poolName;
this.vdbStatusChecker = vdbStatusChecker;
- this.shutdownListener = shutdownListener;
}
public void deploy(final DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
- DeploymentUnit deploymentUnit = context.getDeploymentUnit();
+ final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
if (!TeiidAttachments.isVDBDeployment(deploymentUnit)) {
return;
}
@@ -125,7 +129,7 @@
// build a VDB service
ArrayList<String> unAvailableDS = new ArrayList<String>();
- VDBService vdb = new VDBService(deployment, this.shutdownListener);
+ VDBService vdb = new VDBService(deployment);
final ServiceBuilder<VDBMetaData> vdbService = context.getServiceTarget().addService(TeiidServiceNames.vdbServiceName(deployment.getName(), deployment.getVersion()), vdb);
for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
for (String sourceName:model.getSourceNames()) {
@@ -175,6 +179,21 @@
if (!unAvailableDS.isEmpty()) {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50021, deployment.getName(), deployment.getVersion(), unAvailableDS));
}
+
+ ServiceController<?> scMain = deploymentUnit.getServiceRegistry().getService(deploymentUnit.getServiceName().append("contents")); //$NON-NLS-1$
+ scMain.addListener(new AbstractServiceListener<Object>() {
+ @Override
+ public void serviceRemoveRequested(final ServiceController controller) {
+ final VDBMetaData vdb = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
+
+ ServiceController<?> sc = deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.OBJECT_SERIALIZER);
+ if (sc != null) {
+ ObjectSerializer serilalizer = ObjectSerializer.class.cast(sc.getValue());
+ serilalizer.removeAttachments(vdb);
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+vdb.getName()+" metadata removed"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ });
}
private void dataSourceDependencies(VDBMetaData deployment, DependentServices svcListener) {
@@ -260,7 +279,7 @@
public void undeploy(final DeploymentUnit deploymentUnit) {
if (!TeiidAttachments.isVDBDeployment(deploymentUnit)) {
return;
- }
+ }
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-01-26 17:43:46 UTC (rev 3829)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-01-26 19:28:47 UTC (rev 3830)
@@ -56,7 +56,6 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidException;
import org.teiid.deployers.CompositeVDB;
-import org.teiid.deployers.ContainerLifeCycleListener;
import org.teiid.deployers.MetadataStoreGroup;
import org.teiid.deployers.TranslatorUtil;
import org.teiid.deployers.UDFMetaData;
@@ -89,12 +88,10 @@
private final InjectedValue<ObjectSerializer> serializerInjector = new InjectedValue<ObjectSerializer>();
private final InjectedValue<BufferServiceImpl> bufferServiceInjector = new InjectedValue<BufferServiceImpl>();
private final InjectedValue<ObjectReplicator> objectReplicatorInjector = new InjectedValue<ObjectReplicator>();
- private ContainerLifeCycleListener shutdownListener;
private VDBLifeCycleListener vdbListener;
- public VDBService(VDBMetaData metadata, ContainerLifeCycleListener shutdownListener) {
+ public VDBService(VDBMetaData metadata) {
this.vdb = metadata;
- this.shutdownListener = shutdownListener;
}
@Override
@@ -250,12 +247,6 @@
getVDBRepository().removeVDB(this.vdb.getName(), this.vdb.getVersion());
this.vdb.setRemoved(true);
- // service stopped not due to shutdown then clean-up the data files
- if (!this.shutdownListener.isShutdownInProgress()) {
- getSerializer().removeAttachments(vdb);
- LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+vdb.getName()+" metadata removed"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50026, this.vdb));
}
@@ -465,7 +456,7 @@
if (vdb.isValid()) {
getVDBRepository().finishDeployment(vdb.getName(), vdb.getVersion());
vdb.setStatus(VDB.Status.ACTIVE);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(RuntimePlugin.Event.TEIID40003,vdb.getName(), vdb.getVersion()));
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,vdb.getName(), vdb.getVersion()));
}
}
}
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-01-26 17:43:46 UTC (rev 3829)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-01-26 19:28:47 UTC (rev 3830)
@@ -72,7 +72,6 @@
recursive_delegation=For {0}.{1} VDB, recursive delegation {2} found.
TEIID40012=For {0}.{1} VDB, Data Source "{2}" not found.
datasource_replaced=For {0}.{1} VDB, Data Source "{2}" replaced with "{3}"
-TEIID40003={0}.{1} status has been set to "active"
vdb_inactivated={0}.{1} status has been changed to inactive. Check the required translators and data sources!
translator_added=Teiid translator "{0}" has been added.
invalid_class={0} invalid type of class specified. Must be of type org.teiid.connector.api.Connector
@@ -106,4 +105,5 @@
replication_failed=replication failed to {0}
TEIID40014=Kerberos context login failed
TEIID40018=Exception terminitating session
-TEIID40020=Error occurred
\ No newline at end of file
+TEIID40020=Error occurred
+SessionServiceImpl.invalid_session=Invalid Session. Session may have been terminated. Re-connect and try again.
\ No newline at end of file
12 years, 11 months
teiid SVN: r3829 - branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process.
by teiid-commits@lists.jboss.org
Author: van.halbert
Date: 2012-01-26 12:43:46 -0500 (Thu, 26 Jan 2012)
New Revision: 3829
Modified:
branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
remove the temporary fix
Modified: branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-26 14:38:53 UTC (rev 3828)
+++ branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-26 17:43:46 UTC (rev 3829)
@@ -360,7 +360,6 @@
assertEquals(100, item.resultsBuffer.getRowCount());
}
- @Ignore
@Test public void testFinalRow() throws Exception {
String sql = "SELECT A.IntKey FROM BQT1.SmallA as A"; //$NON-NLS-1$
String userName = "1"; //$NON-NLS-1$
12 years, 11 months
teiid SVN: r3828 - branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process.
by teiid-commits@lists.jboss.org
Author: van.halbert
Date: 2012-01-26 09:38:53 -0500 (Thu, 26 Jan 2012)
New Revision: 3828
Modified:
branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
temporarily turned off TestDQPCore.testFinalRow
Modified: branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-26 02:27:53 UTC (rev 3827)
+++ branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-01-26 14:38:53 UTC (rev 3828)
@@ -360,6 +360,7 @@
assertEquals(100, item.resultsBuffer.getRowCount());
}
+ @Ignore
@Test public void testFinalRow() throws Exception {
String sql = "SELECT A.IntKey FROM BQT1.SmallA as A"; //$NON-NLS-1$
String userName = "1"; //$NON-NLS-1$
12 years, 11 months