Author: xedin
Date: Sun Aug 28 11:06:17 2011
New Revision: 1162495
URL: http://svn.apache.org/viewvc?rev=1162495&view=rev
Log:
Fix parsing of the Keyspace and ColumnFamily names in numeric and string
representations in CLI
patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-3075
Modified:
cassandra/branches/cassandra-0.8/CHANGES.txt
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/Cli.g
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/CliCompiler.java
cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java
Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1162495&r1=1162494&r2=1162495&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Sun Aug 28 11:06:17 2011
@@ -35,7 +35,8 @@
* work around native memory leak in com.sun.management.GarbageCollectorMXBean
(CASSANDRA-2868)
* fix UnavailableException with writes at CL.EACH_QUORM (CASSANDRA-3084)
-
+ * fix parsing of the Keyspace and ColumnFamily names in numeric
+ and string representations in CLI (CASSANDRA-3075)
0.8.4
* include files-to-be-streamed in StreamInSession.getSources (CASSANDRA-2972)
Modified:
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/Cli.g
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/Cli.g?rev=1162495&r1=1162494&r2=1162495&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/Cli.g
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/Cli.g
Sun Aug 28 11:06:17 2011
@@ -382,8 +382,8 @@ useKeyspace
keyValuePairExpr
- : objectName ( (AND | WITH) keyValuePair )*
- -> ^(NODE_NEW_KEYSPACE_ACCESS objectName ( keyValuePair )* )
+ : entityName ( (AND | WITH) keyValuePair )*
+ -> ^(NODE_NEW_KEYSPACE_ACCESS entityName ( keyValuePair )* )
;
keyValuePair
@@ -423,12 +423,12 @@ columnFamilyExpr
;
keyRangeExpr
- : '[' ( startKey? ':' endKey? )? ']'
- -> ^(NODE_KEY_RANGE startKey? endKey?)
+ : '[' ( startKey=entityName? ':' endKey=entityName? )? ']'
+ -> ^(NODE_KEY_RANGE $startKey? $endKey?)
;
columnName
- : (StringLiteral | Identifier | IntegerPositiveLiteral |
IntegerNegativeLiteral)
+ : entityName
;
attr_name
@@ -448,12 +448,8 @@ attrValueDouble
: DoubleLiteral
;
-objectName
- : Identifier
- ;
-
keyspace
- : Identifier
+ : entityName
;
replica_placement_strategy
@@ -461,7 +457,7 @@ replica_placement_strategy
;
keyspaceNewName
- : Identifier
+ : entityName
;
comparator
@@ -472,7 +468,7 @@ command : Identifier
;
newColumnFamily
- : Identifier
+ : entityName
;
username: Identifier
@@ -482,8 +478,12 @@ password: StringLiteral
;
columnFamily
- : Identifier
- ;
+ : entityName
+ ;
+
+entityName
+ : (Identifier | StringLiteral | IntegerPositiveLiteral |
IntegerNegativeLiteral)
+ ;
rowKey
: (Identifier | StringLiteral | IntegerPositiveLiteral |
IntegerNegativeLiteral | functionCall)
@@ -502,14 +502,6 @@ functionArgument
: Identifier | StringLiteral | IntegerPositiveLiteral |
IntegerNegativeLiteral
;
-startKey
- : (Identifier | StringLiteral)
- ;
-
-endKey
- : (Identifier | StringLiteral)
- ;
-
columnOrSuperColumn
: (Identifier | IntegerPositiveLiteral | IntegerNegativeLiteral |
StringLiteral | functionCall)
;
Modified:
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/CliCompiler.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/CliCompiler.java?rev=1162495&r1=1162494&r2=1162495&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/CliCompiler.java
(original)
+++
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cli/CliCompiler.java
Sun Aug 28 11:06:17 2011
@@ -96,7 +96,7 @@ public class CliCompiler
public static String getColumnFamily(Tree astNode, List<CfDef> cfDefs)
{
- return getColumnFamily(astNode.getChild(0).getText(), cfDefs);
+ return
getColumnFamily(CliUtils.unescapeSQLString(astNode.getChild(0).getText()),
cfDefs);
}
public static String getColumnFamily(String cfName, List<CfDef> cfDefs)
Modified:
cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java?rev=1162495&r1=1162494&r2=1162495&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java
(original)
+++
cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java
Sun Aug 28 11:06:17 2011
@@ -37,36 +37,41 @@ public class CliTest extends CleanupHelp
// please add new statements here so they could be auto-runned by this
test.
private String[] statements = {
"use TestKeySpace;",
- "create column family CF1 with comparator=UTF8Type and
column_metadata=[{ column_name:world, validation_class:IntegerType,
index_type:0, index_name:IdxName }, " +
+ "create column family 123 with comparator=UTF8Type and
column_metadata=[{ column_name:world, validation_class:IntegerType,
index_type:0, index_name:IdxName }, " +
"{ column_name:world2, validation_class:LongType, index_type:KEYS,
index_name:LongIdxName}, " +
"{ column_name:617070, validation_class:UTF8Type, index_type:KEYS }, " +
"{ column_name:'-617071', validation_class:UTF8Type, index_type:KEYS }];",
- "assume CF1 keys as utf8;",
- "set CF1[hello][world] = 123848374878933948398384;",
- "set CF1[hello][test_quote] = 'value\\'';",
- "set CF1['k\\'ey'][VALUE] = 'VAL';",
- "set CF1['k\\'ey'][VALUE] = 'VAL\\'';",
- "set CF1[hello][-31337] = 'some string value';",
- "get CF1[hello][-31337];",
- "get CF1[hello][world];",
- "get CF1[hello][test_quote];",
- "get CF1['k\\'ey'][VALUE]",
- "set CF1[hello][-31337] = -23876;",
- "set CF1[hello][-31337] = long(-23876);",
- "set CF1[hello][world2] = 15;",
- "get CF1 where world2 = long(15);",
- "get cF1 where world2 = long(15);",
- "get Cf1 where world2 = long(15);",
- "del CF1[utf8('hello')][utf8('world')];",
- "del CF1[hello][world2];",
- "set CF1['hello'][time_spent_uuid] =
timeuuid(a8098c1a-f86e-11da-bd1a-00112444be1e);",
+ "assume 123 keys as utf8;",
+ "set 123[hello][world] = 123848374878933948398384;",
+ "set 123[hello][test_quote] = 'value\\'';",
+ "set 123['k\\'ey'][VALUE] = 'VAL';",
+ "set 123['k\\'ey'][VALUE] = 'VAL\\'';",
+ "set 123[hello][-31337] = 'some string value';",
+ "list 123;",
+ "list 123[:];",
+ "list 123[456:];",
+ "list 123 limit 5",
+ "list 123[12:15] limit 20",
+ "get 123[hello][-31337];",
+ "get 123[hello][world];",
+ "get 123[hello][test_quote];",
+ "get 123['k\\'ey'][VALUE]",
+ "set 123[hello][-31337] = -23876;",
+ "set 123[hello][-31337] = long(-23876);",
+ "set 123[hello][world2] = 15;",
+ "get 123 where world2 = long(15);",
+ "get 123 where world2 = long(15);",
+ "get 123 where world2 = long(15);",
+ "del 123[utf8('hello')][utf8('world')];",
+ "del 123[hello][world2];",
+ "set 123['hello'][time_spent_uuid] =
timeuuid(a8098c1a-f86e-11da-bd1a-00112444be1e);",
"create column family CF2 with comparator=IntegerType;",
"assume CF2 keys as utf8;",
"set CF2['key'][98349387493847748398334] = 'some text';",
"get CF2['key'][98349387493847748398334];",
"set CF2['key'][98349387493] = 'some text other';",
"get CF2['key'][98349387493];",
- "create column family CF3 with comparator=UTF8Type and
column_metadata=[{column_name:'big world', validation_class:LongType}];",
+ "create column family CF3 with comparator=UTF8Type and
column_metadata=[{column_name:'big world', validation_class:LongType,
index_type:KEYS, index_name:WorldIdx}];",
"assume CF3 keys as utf8;",
"set CF3['hello']['big world'] = 3748;",
"get CF3['hello']['big world'];",
@@ -86,24 +91,24 @@ public class CliTest extends CleanupHelp
"get CF4['hello'][9999] as Long;",
"del CF4['hello'][9999];",
"get CF4['hello'][9999];",
- "create column family SCF1 with column_type=Super and
comparator=IntegerType and subcomparator=LongType and
column_metadata=[{column_name:9999, validation_class:LongType}];",
- "assume SCF1 keys as utf8;",
- "set SCF1['hello'][1][9999] = 1234;",
- "get SCF1['hello'][1][9999];",
- "get SCF1['hello'][1][9999] as Long;",
- "get SCF1['hello'][1][9999] as Bytes;",
- "set SCF1['hello'][1][9999] = Long(1234);",
- "set SCF1['hello'][-1][-12] = Long(5678);",
- "get SCF1['hello'][-1][-12];",
- "set SCF1['hello'][-1][-12] = -340897;",
- "set SCF1['hello'][-1][-12] = integer(-340897);",
- "get SCF1['hello'][1][9999];",
- "get SCF1['hello'][1][9999] as Long;",
- "del SCF1['hello'][1][9999];",
- "get SCF1['hello'][1][9999];",
- "set SCF1['hello'][1][9999] = Long(1234);",
- "del SCF1['hello'][9999];",
- "get SCF1['hello'][1][9999];",
+ "create column family sCf1 with column_type=Super and
comparator=IntegerType and subcomparator=LongType and
column_metadata=[{column_name:9999, validation_class:LongType}];",
+ "assume sCf1 keys as utf8;",
+ "set sCf1['hello'][1][9999] = 1234;",
+ "get sCf1['hello'][1][9999];",
+ "get sCf1['hello'][1][9999] as Long;",
+ "get sCf1['hello'][1][9999] as Bytes;",
+ "set sCf1['hello'][1][9999] = Long(1234);",
+ "set sCf1['hello'][-1][-12] = Long(5678);",
+ "get sCf1['hello'][-1][-12];",
+ "set sCf1['hello'][-1][-12] = -340897;",
+ "set sCf1['hello'][-1][-12] = integer(-340897);",
+ "get sCf1['hello'][1][9999];",
+ "get sCf1['hello'][1][9999] as Long;",
+ "del sCf1['hello'][1][9999];",
+ "get sCf1['hello'][1][9999];",
+ "set sCf1['hello'][1][9999] = Long(1234);",
+ "del sCf1['hello'][9999];",
+ "get sCf1['hello'][1][9999];",
"create column family Counter1 with comparator=UTF8Type and
default_validation_class=CounterColumnType;",
"assume Counter1 keys as utf8;",
"incr Counter1['hello']['cassandra'];",
@@ -114,16 +119,17 @@ public class CliTest extends CleanupHelp
"decr Counter1['hello']['cassandra'] by -2;",
"get Counter1['hello']['cassandra'];",
"get Counter1['hello'];",
- "truncate CF1;",
- "drop index on CF1.world2;",
- "drop index on CF1.617070;",
- "drop index on CF1.'-617071';",
+ "truncate 123;",
+ "drop index on '123'.world2;",
+ "drop index on '123'.617070;",
+ "drop index on '123'.'-617071';",
+ "drop index on CF3.'big world';",
"update keyspace TestKeySpace with
placement_strategy='org.apache.cassandra.locator.LocalStrategy' and
durable_writes = false;",
"update keyspace TestKeySpace with strategy_options=[{DC1:3, DC2:4,
DC5:1}];",
- "assume CF1 comparator as utf8;",
- "assume CF1 sub_comparator as integer;",
- "assume CF1 validator as lexicaluuid;",
- "assume CF1 keys as timeuuid;",
+ "assume 123 comparator as utf8;",
+ "assume 123 sub_comparator as integer;",
+ "assume 123 validator as lexicaluuid;",
+ "assume 123 keys as timeuuid;",
"create column family CF7;",
"assume CF7 keys as utf8;",
"set CF7[1][timeuuid()] = utf8(test1);",
@@ -142,14 +148,15 @@ public class CliTest extends CleanupHelp
"count sCf1[hello];",
"count sCf1[utf8('hello')];",
"count sCf1[utf8('hello')][integer(1)];",
- "count sCF1[hello][1];",
+ "count sCf1[hello][1];",
"list sCf1;",
- "del SCF1['hello'][1][9999];",
+ "del sCf1['hello'][1][9999];",
"assume sCf1 comparator as utf8;",
"create column family CF8;",
"drop column family cF8;",
"create keyspace TESTIN;",
"drop keyspace tesTIN;",
+ "drop column family 123;",
"create column family myCF with column_type='Super' and
comparator='UTF8Type' AND subcomparator='UTF8Type';",
"assume myCF keys as utf8;",
"create column family Countries with comparator=UTF8Type and
column_metadata=[ {column_name: name, validation_class: UTF8Type} ];",