ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-7843: Fixed a bug causing SELECT failures after DROP COLUMN command. This closes #3586.
Date Thu, 01 Mar 2018 12:08:41 GMT
Repository: ignite
Updated Branches:
  refs/heads/master fe89fc413 -> 0d714086d


IGNITE-7843: Fixed a bug causing SELECT failures after DROP COLUMN command. This closes #3586.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0d714086
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0d714086
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0d714086

Branch: refs/heads/master
Commit: 0d714086d06f05531b91198bedb08bb244561034
Parents: fe89fc4
Author: Sergey Kalashnikov <skalashnikov@gridgain.com>
Authored: Thu Mar 1 15:08:32 2018 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Thu Mar 1 15:08:32 2018 +0300

----------------------------------------------------------------------
 .../query/h2/database/H2TreeIndex.java          | 15 ++++++++
 .../query/h2/opt/GridH2IndexBase.java           | 10 ++++++
 .../processors/query/h2/opt/GridH2Table.java    |  5 +++
 .../H2DynamicColumnsAbstractBasicSelfTest.java  | 37 ++++++++++++++++++++
 4 files changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0d714086/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
index c1336eff..2441ff1 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
@@ -513,6 +513,21 @@ public class H2TreeIndex extends GridH2IndexBase {
         return filter != null ? new PartitionFilterTreeRowClosure(filter) : null;
     }
 
+    /** {@inheritDoc} */
+    @Override public void refreshColumnIds() {
+        super.refreshColumnIds();
+
+        if (inlineIdxs == null)
+            return;
+
+        List<InlineIndexHelper> inlineHelpers = getAvailableInlineColumns(indexColumns);
+
+        assert inlineIdxs.size() == inlineHelpers.size();
+
+        for (int pos = 0; pos < inlineHelpers.size(); ++pos)
+            inlineIdxs.set(pos, inlineHelpers.get(pos));
+    }
+
     /**
      * Empty cursor.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d714086/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index 79a7e33..1c89213 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -1575,6 +1575,16 @@ public abstract class GridH2IndexBase extends BaseIndex {
     }
 
     /**
+     * Re-assign column ids after removal of column(s).
+     */
+    public void refreshColumnIds() {
+        assert columnIds.length == columns.length;
+
+        for (int pos = 0; pos < columnIds.length; ++pos)
+            columnIds[pos] = columns[pos].getColumnId();
+    }
+
+    /**
      *
      */
     private static final class CursorIteratorWrapper implements Iterator<GridH2Row>
{

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d714086/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index 7c99480..67ee496 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -988,6 +988,11 @@ public class GridH2Table extends TableBase {
 
             desc.refreshMetadataFromTypeDescriptor();
 
+            for (Index idx : getIndexes()) {
+                if (idx instanceof GridH2IndexBase)
+                    ((GridH2IndexBase)idx).refreshColumnIds();
+            }
+
             setModified();
         }
         finally {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d714086/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java
index 4e28ae9..70f2d85 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java
@@ -192,6 +192,11 @@ public abstract class H2DynamicColumnsAbstractBasicSelfTest extends DynamicColum
 
         run(cache, "ALTER TABLE City DROP COLUMN state_name");
 
+        List<List<?>> res1 = run(cache, "SELECT * from City c " +
+            "WHERE c.population > 5000000");
+
+        assertEquals(res1.get(0).size(), 3);
+
         List<List<?>> res = run(cache, "SELECT p.name from Person p join City
c on p.city = c.name where " +
             "c.population > 5000000 order by p.name");
 
@@ -640,6 +645,38 @@ public abstract class H2DynamicColumnsAbstractBasicSelfTest extends DynamicColum
     }
 
     /**
+     *
+     * @throws Exception if failed.
+     */
+    public void testDropColumnPriorToIndexedColumn() throws Exception {
+        try {
+            run("CREATE TABLE test(id INT PRIMARY KEY, a CHAR, b INT)");
+
+            run("CREATE INDEX idxB ON test(b)");
+
+            run("INSERT INTO test VALUES(1, 'one', 11), (2, 'two', 22), (3, 'three', 33)");
+
+            List<List<?>> res = run("SELECT * FROM test WHERE b > 0 ORDER
BY b");
+
+            assertEquals(3, res.size());
+            assertEquals(3, res.get(0).size());
+
+            run("ALTER TABLE test DROP COLUMN a");
+
+            res = run("SELECT * FROM test WHERE b > 0 ORDER BY b");
+
+            assertEquals(3, res.size());
+            assertEquals(2, res.get(0).size());
+
+            assertEquals(1, res.get(0).get(0));
+            assertEquals(11, res.get(0).get(1));
+        }
+        finally {
+            run("DROP TABLE IF EXISTS test");
+        }
+    }
+
+    /**
      * Test that {@code ADD COLUMN} fails for tables that have flat value.
      * @param tblName table name.
      */


Mime
View raw message