Author: shawkins
Date: 2009-09-23 15:07:45 -0400 (Wed, 23 Sep 2009)
New Revision: 1469
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCProcedureExecution.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCProcedureExecution.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
trunk/test-integration/common/
Log:
forward merge of changes from the 6.2 release
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCProcedureExecution.java
===================================================================
---
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCProcedureExecution.java 2009-09-23
18:51:09 UTC (rev 1468)
+++
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCProcedureExecution.java 2009-09-23
19:07:45 UTC (rev 1469)
@@ -115,10 +115,14 @@
}
}
for (IParameter parameter : proc.getParameters()) {
- if (parameter.getDirection() == Direction.RETURN || parameter.getDirection() ==
Direction.RESULT_SET) {
+ switch (parameter.getDirection()) {
+ case IN:
+ paramIndex++;
+ case RETURN:
+ case RESULT_SET:
continue;
- }
- if (parameter.getDirection() == Direction.INOUT || parameter.getDirection() ==
Direction.OUT) {
+ case INOUT:
+ case OUT:
addParameterValue(result, paramIndex++, parameter);
}
}
Modified:
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCProcedureExecution.java
===================================================================
---
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCProcedureExecution.java 2009-09-23
18:51:09 UTC (rev 1468)
+++
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCProcedureExecution.java 2009-09-23
19:07:45 UTC (rev 1469)
@@ -58,5 +58,21 @@
assertEquals(Arrays.asList(5), procedureExecution.getOutputParameterValues());
Mockito.verify(cs, Mockito.times(1)).registerOutParameter(1, Types.INTEGER);
}
+
+ @Test public void testProcedureExecution1() throws Exception {
+ ICommand command = MetadataFactory.helpTranslate(MetadataFactory.BQT_VDB, "exec
pm2.spTest8(1)"); //$NON-NLS-1$
+ Connection connection = Mockito.mock(Connection.class);
+ CallableStatement cs = Mockito.mock(CallableStatement.class);
+ Mockito.stub(cs.getUpdateCount()).toReturn(-1);
+ Mockito.stub(cs.getInt(2)).toReturn(5);
+ Mockito.stub(connection.prepareCall("{ call spTest8(?,?)}")).toReturn(cs);
//$NON-NLS-1$
+ Translator sqlTranslator = new Translator();
+ ExecutionContext context = EnvironmentUtility.createSecurityContext("user");
//$NON-NLS-1$
+ RuntimeMetadataImpl runtimeMetadata = new
RuntimeMetadataImpl(FakeMetadataFactory.exampleBQTCached());
+ JDBCProcedureExecution procedureExecution = new JDBCProcedureExecution(command,
connection, sqlTranslator, Mockito.mock(ConnectorLogger.class), new Properties(),
runtimeMetadata, context, EnvironmentUtility.createEnvironment(new Properties()) );
+ procedureExecution.execute();
+ assertEquals(Arrays.asList(5), procedureExecution.getOutputParameterValues());
+ Mockito.verify(cs, Mockito.times(1)).registerOutParameter(2, Types.INTEGER);
+ }
}
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2009-09-23
18:51:09 UTC (rev 1468)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2009-09-23
19:07:45 UTC (rev 1469)
@@ -90,7 +90,7 @@
for (int i = 0; i < updateCommands.size(); i++) {
Command updateCommand = (Command)updateCommands.get(i).clone();
CommandContext context = this.getContext();
- if (this.contexts != null) {
+ if (this.contexts != null && !this.contexts.isEmpty()) {
context = (CommandContext)context.clone();
context.setVariableContext(this.contexts.get(i));
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-09-23
18:51:09 UTC (rev 1468)
+++
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-09-23
19:07:45 UTC (rev 1469)
@@ -240,7 +240,7 @@
Constant reverse = getProperlyTypedConstant(result.getValue(),
constant.getType());
- if (constant.equals(reverse)) {
+ if (((Comparable)constant.getValue()).compareTo(reverse.getValue()) == 0) {
return result;
}
} catch (QueryResolverException e) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-09-23
18:51:09 UTC (rev 1468)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-09-23
19:07:45 UTC (rev 1469)
@@ -1543,7 +1543,7 @@
* @throws QueryValidatorException
* @since 4.2
*/
- private Criteria simplifyConvertFunction(SetCriteria crit) throws
QueryValidatorException {
+ private Criteria simplifyConvertFunction(SetCriteria crit) throws
QueryValidatorException {
Function leftFunction = (Function) crit.getExpression();
Expression leftExpr = leftFunction.getArgs()[0];
String leftExprTypeName = DataTypeManager.getDataTypeName(leftExpr.getType());
@@ -1570,11 +1570,13 @@
}
}
- if (result != null) {
+ if (result == null) {
+ removedSome = true;
+ i.remove();
+ } else if (DataTypeManager.isImplicitConversion(leftExprTypeName,
DataTypeManager.getDataTypeName(rightConstant.getType()))) {
newValues.add(result);
} else {
- removedSome = true;
- i.remove();
+ convertedAll = false;
}
}
Modified:
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2009-09-23
18:51:09 UTC (rev 1468)
+++
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2009-09-23
19:07:45 UTC (rev 1469)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.junit.Test;
@@ -57,7 +58,7 @@
for (Command command : commands) {
shouldEvaluate.add(EvaluatableVisitor.needsProcessingEvaluation(command));
}
- BatchedUpdateNode node = new BatchedUpdateNode(1, commands, null, shouldEvaluate,
"myModelName"); //$NON-NLS-1$
+ BatchedUpdateNode node = new BatchedUpdateNode(1, commands,
Collections.EMPTY_LIST, shouldEvaluate, "myModelName"); //$NON-NLS-1$
CommandContext context = new CommandContext();
context.setProcessorID("myProcessorID"); //$NON-NLS-1$
node.initialize(context, Mockito.mock(BufferManager.class), pdm);
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-09-23
18:51:09 UTC (rev 1468)
+++
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-09-23
19:07:45 UTC (rev 1469)
@@ -2269,4 +2269,21 @@
helpTestRewriteCriteria(original, expected);
}
+ /**
+ * Test ensures that '22.0' is a valid long via bigdecimal
+ */
+ @Test public void testRewriteBigDecimal() {
+ String original = "convert(BQT1.SmallA.LongNum, bigdecimal) =
'22.0'"; //$NON-NLS-1$
+ CompareCriteria crit = new CompareCriteria(new
ElementSymbol("BQT1.SmallA.LongNum"), CompareCriteria.EQ, new Constant(new
Long(22))); //$NON-NLS-1$
+ helpTestRewriteCriteria(original, crit, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ /**
+ * Test ensures that we will not attempt to invert the widening conversion
+ */
+ @Test public void testRewriteWideningIn() {
+ String original = "convert(BQT1.SmallA.TimestampValue, time) in
({t'10:00:00'}, {t'11:00:00'})"; //$NON-NLS-1$
+ helpTestRewriteCriteria(original,
parseCriteria("convert(BQT1.SmallA.TimestampValue, time) in ({t'10:00:00'},
{t'11:00:00'})", FakeMetadataFactory.exampleBQTCached()),
FakeMetadataFactory.exampleBQTCached()); //$NON-NLS-1$
+ }
+
}
Property changes on: trunk/test-integration/common
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
derby.log