cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject svn commit: r1097852 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/thrift/CassandraServer.java src/java/org/apache/cassandra/thrift/ThriftValidation.java test/system/__init__.py test/system/test_thrift_server.py
Date Fri, 29 Apr 2011 15:58:09 GMT
Author: slebresne
Date: Fri Apr 29 15:58:09 2011
New Revision: 1097852

URL: http://svn.apache.org/viewvc?rev=1097852&view=rev
Log:
Reject queries with missing mandatory super column and always validate super column name
patch by jbellis and slebresne for CASSANDRA-2571

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java
    cassandra/branches/cassandra-0.7/test/system/__init__.py
    cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1097852&r1=1097851&r2=1097852&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Fri Apr 29 15:58:09 2011
@@ -4,6 +4,8 @@
  * fix incorrect use of NBHM.size in ReadCallback that could cause
    reads to time out even when responses were received (CASSAMDRA-2552)
  * trigger read repair correctly for LOCAL_QUORUM reads (CASSANDRA-2556)
+ * correctly reject query with missing mandatory super columns and validate
+   super column name in Deletion (CASSANDRA-2571)
  * refuse to apply migrations with older timestamps than the current 
    schema (CASSANDRA-2536)
 

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=1097852&r1=1097851&r2=1097852&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java
Fri Apr 29 15:58:09 2011
@@ -337,6 +337,12 @@ public class CassandraServer implements 
 
         ThriftValidation.validateKey(key);
         ThriftValidation.validateColumnParent(state().getKeyspace(), column_parent);
+        // SuperColumn field is usually optional, but not when we're inserting
+        if (DatabaseDescriptor.getColumnFamilyType(state().getKeyspace(), column_parent.column_family)
== ColumnFamilyType.Super
+            && column_parent.super_column == null)
+        {
+            throw new InvalidRequestException("missing mandatory super column name for super
CF " + column_parent.column_family);
+        }
         ThriftValidation.validateColumnNames(state().getKeyspace(), column_parent, Arrays.asList(column.name));
         ThriftValidation.validateColumnData(state().getKeyspace(), column_parent.column_family,
column);
 

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=1097852&r1=1097851&r2=1097852&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java
Fri Apr 29 15:58:09 2011
@@ -132,6 +132,7 @@ public class ThriftValidation
                 throw new InvalidRequestException("columnfamily alone is required for standard
CF " + column_parent.column_family);
             }
         }
+
         if (column_parent.super_column != null)
         {
             validateColumnNames(tablename, column_parent.column_family, null, Arrays.asList(column_parent.super_column));
@@ -290,6 +291,10 @@ public class ThriftValidation
     public static void validateDeletion(String keyspace, String cfName, Deletion del) throws
InvalidRequestException
     {
         validateColumnFamily(keyspace, cfName);
+
+        if (del.super_column != null)
+            validateColumnNames(keyspace, cfName, null, Arrays.asList(del.super_column));
+
         if (del.predicate != null)
         {
             validateSlicePredicate(keyspace, cfName, del.super_column, del.predicate);

Modified: cassandra/branches/cassandra-0.7/test/system/__init__.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/system/__init__.py?rev=1097852&r1=1097851&r2=1097852&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/system/__init__.py (original)
+++ cassandra/branches/cassandra-0.7/test/system/__init__.py Fri Apr 29 15:58:09 2011
@@ -170,6 +170,7 @@ class ThriftTester(BaseTester):
             Cassandra.CfDef('Keyspace1', 'Super2', column_type='Super', subcomparator_type='LongType'),

             Cassandra.CfDef('Keyspace1', 'Super3', column_type='Super', subcomparator_type='LongType'),

             Cassandra.CfDef('Keyspace1', 'Super4', column_type='Super', subcomparator_type='UTF8Type'),
+            Cassandra.CfDef('Keyspace1', 'Super5', column_type='Super', comparator_type='LongType',
subcomparator_type='UTF8Type'),
             Cassandra.CfDef('Keyspace1', 'Indexed1', column_metadata=[Cassandra.ColumnDef('birthdate',
'LongType', Cassandra.IndexType.KEYS, 'birthdate_index')]),
             Cassandra.CfDef('Keyspace1', 'Indexed2', comparator_type='TimeUUIDType', column_metadata=[Cassandra.ColumnDef(uuid.UUID('00000000-0000-1000-0000-000000000000').bytes,
'LongType', Cassandra.IndexType.KEYS)]),
             Cassandra.CfDef('Keyspace1', 'Indexed3', comparator_type='TimeUUIDType', column_metadata=[Cassandra.ColumnDef(uuid.UUID('00000000-0000-1000-0000-000000000000').bytes,
'UTF8Type', Cassandra.IndexType.KEYS)]),

Modified: cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py?rev=1097852&r1=1097851&r2=1097852&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py (original)
+++ cassandra/branches/cassandra-0.7/test/system/test_thrift_server.py Fri Apr 29 15:58:09
2011
@@ -619,6 +619,12 @@ class TestMutations(ThriftTester):
         _expect_exception(lambda: client.insert(None, None, None, None), TApplicationException)
         # supercolumn in a non-super CF
         _expect_exception(lambda: client.insert('key1', ColumnParent('Standard1', 'x'), Column('y',
'value', 0), ConsistencyLevel.ONE), InvalidRequestException)
+        # no supercolumn in a super CF
+        _expect_exception(lambda: client.insert('key1', ColumnParent('Super1'), Column('y',
'value', 0), ConsistencyLevel.ONE), InvalidRequestException)
+        # column but no supercolumn in remove
+        _expect_exception(lambda: client.remove('key1', ColumnPath('Super1', column='x'),
0, ConsistencyLevel.ONE), InvalidRequestException)
+        # super column in non-super CF
+        _expect_exception(lambda: client.remove('key1', ColumnPath('Standard1', 'y', 'x'),
0, ConsistencyLevel.ONE), InvalidRequestException)
         # key too long
         _expect_exception(lambda: client.get('x' * 2**16, ColumnPath('Standard1', column='c1'),
ConsistencyLevel.ONE), InvalidRequestException)
         # empty key
@@ -670,6 +676,11 @@ class TestMutations(ThriftTester):
         mutations = {'key' : {'Standard1' : [mutation]}}
         _expect_exception(lambda: client.batch_mutate(mutations, ConsistencyLevel.QUORUM),
                           InvalidRequestException)
+        # 'x' is not a valid long
+        deletion = Deletion(1, 'x', None)
+        mutation = Mutation(deletion=deletion)
+        mutations = {'key' : {'Super5' : [mutation]}}
+        _expect_exception(lambda: client.batch_mutate(mutations, ConsistencyLevel.QUORUM),
InvalidRequestException)
 
     def test_batch_insert_super(self):
          _set_keyspace('Keyspace1')



Mime
View raw message