cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: cli: Quote ks and cf names in schema output when needed
Date Sun, 24 Mar 2013 14:59:03 GMT
Updated Branches:
  refs/heads/cassandra-1.1 426041368 -> fa29f412b


cli: Quote ks and cf names in schema output when needed

patch by Aleksey Yeschenko; reviewed by Jonathan Ellis for
CASSANDRA-5052


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

Branch: refs/heads/cassandra-1.1
Commit: fa29f412b1b1790fe46e60c903471e9271611db1
Parents: 4260413
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Sun Mar 24 17:57:36 2013 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Sun Mar 24 17:57:36 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                      |    1 +
 src/java/org/apache/cassandra/cli/CliClient.java |    6 +++---
 src/java/org/apache/cassandra/cli/CliUtils.java  |    6 ++++++
 3 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fa29f412/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b4fdd1d..010bdc0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,7 @@
  * cqlsh: Add inet type support on Windows (ipv4-only) (CASSANDRA-4801)
  * Fix race when initializing ColumnFamilyStore (CASSANDRA-5350)
  * Add UseTLAB JVM flag (CASSANDRA-5361)
+ * cli: Quote ks and cf names in schema output when needed (CASSANDRA-5052)
 
 
 1.1.10

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fa29f412/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 a7e8d92..0f97b7f 100644
--- a/src/java/org/apache/cassandra/cli/CliClient.java
+++ b/src/java/org/apache/cassandra/cli/CliClient.java
@@ -1659,7 +1659,7 @@ public class CliClient
      */
     private void showKeyspace(PrintStream output, KsDef ksDef)
     {
-        output.append("create keyspace ").append(ksDef.name);
+        output.append("create keyspace ").append(CliUtils.maybeEscapeName(ksDef.name));
 
         writeAttr(output, true, "placement_strategy", normaliseType(ksDef.strategy_class,
"org.apache.cassandra.locator"));
 
@@ -1682,7 +1682,7 @@ public class CliClient
         output.append(";").append(NEWLINE);
         output.append(NEWLINE);
 
-        output.append("use " + ksDef.name + ";");
+        output.append("use " + CliUtils.maybeEscapeName(ksDef.name) + ";");
         output.append(NEWLINE);
         output.append(NEWLINE);
 
@@ -1701,7 +1701,7 @@ public class CliClient
      */
     private void showColumnFamily(PrintStream output, CfDef cfDef)
     {
-        output.append("create column family ").append(CliUtils.escapeSQLString(cfDef.name));
+        output.append("create column family ").append(CliUtils.maybeEscapeName(cfDef.name));
 
         writeAttr(output, true, "column_type", cfDef.column_type);
         writeAttr(output, false, "comparator", normaliseType(cfDef.comparator_type, "org.apache.cassandra.db.marshal"));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fa29f412/src/java/org/apache/cassandra/cli/CliUtils.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cli/CliUtils.java b/src/java/org/apache/cassandra/cli/CliUtils.java
index a8e883b..fd1bd40 100644
--- a/src/java/org/apache/cassandra/cli/CliUtils.java
+++ b/src/java/org/apache/cassandra/cli/CliUtils.java
@@ -50,6 +50,12 @@ public class CliUtils
         // single quotes are not escaped in java, need to be for cli
         return StringEscapeUtils.escapeJava(b).replace("\'", "\\'");
     }
+
+    public static String maybeEscapeName(String name)
+    {
+        return name.charAt(0) == '_' ? "\'" + name + "\'" : name;
+    }
+
     /**
      * Returns IndexOperator from string representation
      * @param operator - string representing IndexOperator (=, >=, >, <, <=)


Mime
View raw message