You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2022/02/08 10:35:04 UTC

[ignite] branch sql-calcite updated: IGNITE-16397 Fix insert/delete/update complex key - Fixes #9804.

This is an automated email from the ASF dual-hosted git repository.

alexpl pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/sql-calcite by this push:
     new 6d120d8  IGNITE-16397 Fix insert/delete/update complex key - Fixes #9804.
6d120d8 is described below

commit 6d120d8034c8cd698912fef88fda59988837684a
Author: Aleksey Plekhanov <pl...@gmail.com>
AuthorDate: Tue Feb 8 13:28:52 2022 +0300

    IGNITE-16397 Fix insert/delete/update complex key - Fixes #9804.
    
    Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
 .../query/calcite/exec/rel/ModifyNode.java         |  2 +-
 .../integration/TableDmlIntegrationTest.java       | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ModifyNode.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ModifyNode.java
index 5aa5546..a52b099 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ModifyNode.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/ModifyNode.java
@@ -196,7 +196,7 @@ public class ModifyNode<Row> extends AbstractNode<Row> implements SingleNode<Row
 
         GridCacheContext<Object, Object> cctx = desc.cacheContext();
         Map<Object, EntryProcessor<Object, Object, Long>> map = invokeMap(tuples);
-        Map<Object, EntryProcessorResult<Long>> res = cctx.cache().invokeAll(map);
+        Map<Object, EntryProcessorResult<Long>> res = cctx.cache().keepBinary().invokeAll(map);
 
         long updated = res.values().stream().mapToLong(EntryProcessorResult::get).sum();
 
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java
index be3ee77..82d0ffe 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDmlIntegrationTest.java
@@ -250,6 +250,28 @@ public class TableDmlIntegrationTest extends AbstractBasicIntegrationTest {
     }
 
     /**
+     * Test insert/update/delete rows of a table with two or more fields in the primary key.
+     */
+    @Test
+    public void testInsertUpdateDeleteComplexKey() {
+        executeSql("CREATE TABLE t(id INT, val VARCHAR, val2 VARCHAR, PRIMARY KEY(id, val))");
+        executeSql("INSERT INTO t(id, val, val2) VALUES (1, 'a', 'b')");
+
+        assertQuery("SELECT * FROM t").returns(1, "a", "b").check();
+
+        executeSql("UPDATE t SET val2 = 'c' WHERE id = 1");
+
+        // Can't update the part of the key field.
+        assertThrows("UPDATE t SET val = 'c' WHERE id = 1", IgniteSQLException.class, "Cannot update field \"VAL\".");
+
+        assertQuery("SELECT * FROM t").returns(1, "a", "c").check();
+
+        executeSql("DELETE FROM t WHERE id = 1");
+
+        assertQuery("SELECT COUNT(*) FROM t").returns(0L).check();
+    }
+
+    /**
      * Test full MERGE command.
      */
     @Test