cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/2] git commit: Fix errors when dropping non-existent indexes
Date Thu, 24 Jul 2014 19:06:19 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 51dfe7821 -> f73a92957


Fix errors when dropping non-existent indexes

Patch by Robert Stupp; review by Tyler Hobbs for CASSANDRA-7590


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

Branch: refs/heads/cassandra-2.1
Commit: dceed39995cdc386e6e15c9f6538ddee6b5e2f51
Parents: 33719e7
Author: Robert Stupp <snazy@snazy.de>
Authored: Thu Jul 24 14:04:48 2014 -0500
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Thu Jul 24 14:04:48 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                           |  2 ++
 .../cassandra/cql3/statements/DropIndexStatement.java | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/dceed399/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3776319..5619fda 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,8 @@
    (CASSANDRA-7578)
  * Fix cqlsh display when zero rows are returned (CASSANDRA-7580)
  * Get java version correctly when JAVA_TOOL_OPTIONS is set (CASSANDRA-7572)
+ * Fix NPE when dropping index from non-existent keyspace, AssertionError when
+   dropping non-existent index with IF EXISTS (CASSANDRA-7590)
 Merged from 2.0:
  * Fix ReversedType(DateType) mapping to native protocol (CASSANDRA-7576)
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dceed399/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java b/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
index 0562cc6..f70f526 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
@@ -23,10 +23,13 @@ import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.*;
+import org.apache.cassandra.db.KeyspaceNotDefinedException;
 import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
+import org.apache.cassandra.service.QueryState;
 import org.apache.cassandra.transport.Event;
+import org.apache.cassandra.transport.messages.ResultMessage;
 
 public class DropIndexStatement extends SchemaAlteringStatement
 {
@@ -63,6 +66,13 @@ public class DropIndexStatement extends SchemaAlteringStatement
         return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE,
keyspace(), columnFamily());
     }
 
+    @Override
+    public ResultMessage execute(QueryState state, QueryOptions options) throws RequestValidationException
+    {
+        announceMigration(false);
+        return indexedCF == null ? null : new ResultMessage.SchemaChange(changeEvent());
+    }
+
     public void announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
     {
         CFMetaData cfm = findIndexedCF();
@@ -89,6 +99,8 @@ public class DropIndexStatement extends SchemaAlteringStatement
     private CFMetaData findIndexedCF() throws InvalidRequestException
     {
         KSMetaData ksm = Schema.instance.getKSMetaData(keyspace());
+        if (ksm == null)
+            throw new KeyspaceNotDefinedException("Keyspace " + keyspace() + " does not exist");
         for (CFMetaData cfm : ksm.cfMetaData().values())
         {
             if (findIndexedColumn(cfm) != null)
@@ -98,7 +110,7 @@ public class DropIndexStatement extends SchemaAlteringStatement
         if (ifExists)
             return null;
         else
-            throw new InvalidRequestException("Index '" + indexName + "' could not be found
in any of the column families of keyspace '" + keyspace() + "'");
+            throw new InvalidRequestException("Index '" + indexName + "' could not be found
in any of the tables of keyspace '" + keyspace() + '\'');
     }
 
     private ColumnDefinition findIndexedColumn(CFMetaData cfm)


Mime
View raw message