Author: shawkins
Date: 2011-10-18 12:03:32 -0400 (Tue, 18 Oct 2011)
New Revision: 3560
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
Log:
TEIID-1787 fix for batching NPE
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2011-10-18
15:56:08 UTC (rev 3559)
+++
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2011-10-18
16:03:32 UTC (rev 3560)
@@ -220,8 +220,8 @@
} else { //just accumulate copies of the command/plan - clones are not necessary
if (command == null) {
command = this.prepPlan.getCommand();
- command.setProcessorPlan(this.processPlan);
}
+ command.setProcessorPlan(this.processPlan);
commands.add(command);
}
}
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2011-10-18
15:56:08 UTC (rev 3559)
+++
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2011-10-18
16:03:32 UTC (rev 3560)
@@ -79,6 +79,37 @@
assertTrue(((Constant)update.getChangeList().getClauses().get(0).getValue()).isMultiValued());
}
+ @Test public void testBatchedUpdateNotPushdown() throws Exception {
+ // Create query
+ String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE
pm1.g1.e2=?"; //$NON-NLS-1$
+
+ // Create a testable prepared plan cache
+ SessionAwareCache<PreparedPlan> prepPlanCache = new
SessionAwareCache<PreparedPlan>();
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("UPDATE pm1.g1 SET e1 = 'a', e3 = FALSE WHERE
pm1.g1.e2 = 0", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ dataManager.addData("UPDATE pm1.g1 SET e1 = null, e3 = FALSE WHERE pm1.g1.e2 =
1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ // Source capabilities must support batched updates
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.BULK_UPDATE, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // batch with two commands
+ ArrayList<ArrayList<Object>> values = new
ArrayList<ArrayList<Object>>(2);
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { "a",
Boolean.FALSE, new Integer(0) }))); //$NON-NLS-1$
+ values.add(new ArrayList<Object>(Arrays.asList(new Object[] { null,
Boolean.FALSE, new Integer(1) })));
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(2),
+ Arrays.asList(2)
+ };
+
+ // Create the plan and process the query
+ TestPreparedStatement.helpTestProcessing(preparedSql, values, expected, dataManager,
capFinder, RealMetadataFactory.example1Cached(), prepPlanCache, false, false,
false,RealMetadataFactory.example1VDB());
+ }
+
/**
* Test prepared statements that use batched updates using the same prepared
* command with same number of commands in the batch.
Show replies by date