mirror of https://github.com/apache/cassandra
cli: Quote ks and cf names in schema output when needed
patch by Aleksey Yeschenko; reviewed by Jonathan Ellis for CASSANDRA-5052
This commit is contained in:
parent
426041368f
commit
fa29f412b1
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
|
|
|
|||
|
|
@ -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 (=, >=, >, <, <=)
|
||||
|
|
|
|||
Loading…
Reference in New Issue