You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/06/29 10:04:05 UTC

git commit: Fix deletion in CQL3

Updated Branches:
  refs/heads/cassandra-1.1 67c26d471 -> f04e39df7


Fix deletion in CQL3

patch by slebresne; reviewed by jbellis for CASSANDRA-4193


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

Branch: refs/heads/cassandra-1.1
Commit: f04e39df73e74ade1cd352701223910eac1f954b
Parents: 67c26d4
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Fri Jun 29 10:02:52 2012 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Fri Jun 29 10:02:52 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../cassandra/cql3/statements/DeleteStatement.java |   14 ++++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f04e39df/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index aa03655..3a1b4c2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -22,6 +22,7 @@
  * add strategy_options to the KSMetaData.toString() output (CASSANDRA-4248)
  * (cql3) fix range queries containing unqueried results (CASSANDRA-4372)
  * (cql3) allow updating column_alias types (CASSANDRA-4041)
+ * (cql3) Fix deletion bug (CASSANDRA-4193)
 Merged from 1.0:
  * Set gc_grace on index CF to 0 (CASSANDRA-4314)
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f04e39df/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
index 4af3aa2..2743358 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
@@ -70,8 +70,8 @@ public class DeleteStatement extends ModificationStatement
             if (values == null || values.isEmpty())
             {
                 firstEmpty = name;
-                // For sparse, we must either have all component or none
-                if (cfDef.isComposite && !cfDef.isCompact && builder.componentCount() != 0)
+                // For composites, we must either have all component or none
+                if (cfDef.isComposite && builder.componentCount() != 0)
                     throw new InvalidRequestException(String.format("Missing mandatory PRIMARY KEY part %s", name));
             }
             else if (firstEmpty != null)
@@ -129,8 +129,14 @@ public class DeleteStatement extends ModificationStatement
             }
             else
             {
-                // Delete specific columns
-                Iterator<ColumnIdentifier> iter = columns.iterator();
+                Iterator<ColumnIdentifier> iter;
+                if (columns.isEmpty())
+                    // It's a DELETE *, remove all columns individually (#3708 will replace that by a single range tombstone)
+                    iter = cfDef.metadata.keySet().iterator();
+                else
+                    // Delete specific columns
+                    iter = columns.iterator();
+
                 while (iter.hasNext())
                 {
                     ColumnIdentifier column = iter.next();