You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2013/11/21 09:58:10 UTC

git commit: Don't allow describe on CQL3 table in CLI ever

Updated Branches:
  refs/heads/cassandra-1.2 e01224ede -> 92fe8c896


Don't allow describe on CQL3 table in CLI ever

patch by slebresne; reviewed by iamaleksey for CASSANDRA-5750


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

Branch: refs/heads/cassandra-1.2
Commit: 92fe8c89614c91d5f6dd61ba6190df7c26783853
Parents: e01224e
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Thu Nov 21 09:57:18 2013 +0100
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Thu Nov 21 09:57:18 2013 +0100

----------------------------------------------------------------------
 CHANGES.txt                                      |  1 +
 src/java/org/apache/cassandra/cli/CliClient.java | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/92fe8c89/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b3fa565..c012148 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,7 @@
 1.2.13
  * Optimize FD phi calculation (CASSANDRA-6386)
  * Improve initial FD phi estimate when starting up (CASSANDRA-6385)
+ * Don't list CQL3 table in CLI describe even if named explicitely (CASSANDRA-5750)
 
 
 1.2.12

http://git-wip-us.apache.org/repos/asf/cassandra/blob/92fe8c89/src/java/org/apache/cassandra/cli/CliClient.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java
index 2229207..29c5ef5 100644
--- a/src/java/org/apache/cassandra/cli/CliClient.java
+++ b/src/java/org/apache/cassandra/cli/CliClient.java
@@ -1163,8 +1163,10 @@ public class CliClient
 
         try
         {
-            // request correct cfDef from the server
-            CfDef cfDef = getCfDef(thriftClient.describe_keyspace(this.keySpace), cfName);
+            // request correct cfDef from the server (we let that call include CQL3 cf even though
+            // they can't be modified by thrift because the error message that will be thrown by
+            // system_update_column_family will be more useful)
+            CfDef cfDef = getCfDef(thriftClient.describe_keyspace(this.keySpace), cfName, true);
 
             if (cfDef == null)
                 throw new RuntimeException("Column Family " + cfName + " was not found in the current keyspace.");
@@ -2273,7 +2275,7 @@ public class CliClient
                                                          "of the keyspaces first.", entityName));
 
             CfDef inputCfDef = (inputKsDef == null)
-                    ? getCfDef(currentKeySpace, entityName)
+                    ? getCfDef(currentKeySpace, entityName, false)
                     : null;  // no need to lookup CfDef if we know that it was keyspace
 
             if (inputKsDef != null)
@@ -2298,7 +2300,7 @@ public class CliClient
             }
             else
             {
-                sessionState.out.println("Sorry, no Keyspace nor ColumnFamily was found with name: " + entityName);
+                sessionState.out.println("Sorry, no Keyspace nor (non-CQL3) ColumnFamily was found with name: " + entityName + " (if this is a CQL3 table, you should use cqlsh instead)");
             }
         }
     }
@@ -2371,7 +2373,7 @@ public class CliClient
     private CfDef getCfDef(String keySpaceName, String columnFamilyName)
     {
         KsDef ksDef = keyspacesMap.get(keySpaceName);
-        CfDef cfDef = getCfDef(ksDef, columnFamilyName);
+        CfDef cfDef = getCfDef(ksDef, columnFamilyName, true);
         if (cfDef == null)
             throw new RuntimeException("No such column family: " + columnFamilyName);
         return cfDef;
@@ -2387,7 +2389,7 @@ public class CliClient
         return getCfDef(this.keySpace, columnFamilyName);
     }
 
-    private CfDef getCfDef(KsDef keyspace, String columnFamilyName)
+    private CfDef getCfDef(KsDef keyspace, String columnFamilyName, boolean includeCQL3)
     {
         for (CfDef cfDef : keyspace.cf_defs)
         {
@@ -2395,7 +2397,7 @@ public class CliClient
                 return cfDef;
         }
 
-        return cql3KeyspacesMap.get(keyspace.name).get(columnFamilyName);
+        return includeCQL3 ? cql3KeyspacesMap.get(keyspace.name).get(columnFamilyName) : null;
     }
 
     /**