cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/2] git commit: Validate empty cell names from counter updates
Date Tue, 19 Aug 2014 23:31:57 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 31d5193a7 -> ecf1baebb


Validate empty cell names from counter updates

patch by Aleksey Yeschenko; reviewed by Jeremiah Jordan for
CASSANDRA-7798


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

Branch: refs/heads/cassandra-2.0
Commit: 62642fa97e4a1bd4f3b9d253dd939da61ac2740f
Parents: 48d6950
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Wed Aug 20 02:22:01 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Wed Aug 20 02:25:17 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                              | 1 +
 src/java/org/apache/cassandra/cql3/Constants.java        | 4 ++--
 src/java/org/apache/cassandra/cql3/UpdateParameters.java | 6 ++++++
 3 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/62642fa9/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index db5fa3a..7fb6de9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.19
+ * Validate empty cell names from counter updates (CASSANDRA-7798)
  * Improve PasswordAuthenticator default super user setup (CASSANDRA-7788)
  * Remove duplicates from StorageService.getJoiningNodes (CASSANDRA-7478)
  * Clone token map outside of hot gossip loops (CASSANDRA-7758)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/62642fa9/src/java/org/apache/cassandra/cql3/Constants.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Constants.java b/src/java/org/apache/cassandra/cql3/Constants.java
index 4c9d856..1c7feaf 100644
--- a/src/java/org/apache/cassandra/cql3/Constants.java
+++ b/src/java/org/apache/cassandra/cql3/Constants.java
@@ -326,7 +326,7 @@ public abstract class Constants
                 throw new InvalidRequestException("Invalid null value for counter increment");
             long increment = ByteBufferUtil.toLong(bytes);
             ByteBuffer cname = columnName == null ? prefix.build() : prefix.add(columnName.key).build();
-            cf.addCounter(new QueryPath(cf.metadata().cfName, null, cname), increment);
+            cf.addColumn(params.makeCounter(cname, increment));
         }
     }
 
@@ -348,7 +348,7 @@ public abstract class Constants
                 throw new InvalidRequestException("The negation of " + increment + " overflows
supported counter precision (signed 8 bytes integer)");
 
             ByteBuffer cname = columnName == null ? prefix.build() : prefix.add(columnName.key).build();
-            cf.addCounter(new QueryPath(cf.metadata().cfName, null, cname), -increment);
+            cf.addColumn(params.makeCounter(cname, -increment));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/62642fa9/src/java/org/apache/cassandra/cql3/UpdateParameters.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/UpdateParameters.java b/src/java/org/apache/cassandra/cql3/UpdateParameters.java
index b938fea..3d87598 100644
--- a/src/java/org/apache/cassandra/cql3/UpdateParameters.java
+++ b/src/java/org/apache/cassandra/cql3/UpdateParameters.java
@@ -57,6 +57,12 @@ public class UpdateParameters
              : new Column(name, value, timestamp);
     }
 
+    public Column makeCounter(ByteBuffer name, long delta) throws InvalidRequestException
+    {
+        QueryProcessor.validateColumnName(name);
+        return new CounterUpdateColumn(name, delta, System.currentTimeMillis());
+    }
+
     public Column makeTombstone(ByteBuffer name) throws InvalidRequestException
     {
         QueryProcessor.validateColumnName(name);


Mime
View raw message