You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bl...@apache.org on 2015/10/20 14:07:42 UTC
[1/2] cassandra git commit: Fix conditions on static columns
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.2 728f94e79 -> a33790730
Fix conditions on static columns
patch by Benjamin Lerer; reviewed by Sylvain Lebresne for CASSANDRA-10264
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/9b3b1cb0
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9b3b1cb0
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9b3b1cb0
Branch: refs/heads/cassandra-2.2
Commit: 9b3b1cb03c6536d40adfcfa8f93577079b9a9d1d
Parents: b84ed11
Author: blerer <be...@datastax.com>
Authored: Tue Oct 20 13:54:46 2015 +0200
Committer: blerer <be...@datastax.com>
Committed: Tue Oct 20 13:54:46 2015 +0200
----------------------------------------------------------------------
CHANGES.txt | 1 +
pylib/cqlshlib/cql3handling.py | 2 +-
.../cql3/statements/ModificationStatement.java | 24 ++++++++++++++++++--
.../operations/InsertUpdateIfConditionTest.java | 12 +++++++++-
4 files changed, 35 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/9b3b1cb0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7358689..b17929c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.1.12
+ * Fix conditions on static columns (CASSANDRA-10264)
* AssertionError: attempted to delete non-existing file CommitLog (CASSANDRA-10377)
* Merge range tombstones during compaction (CASSANDRA-7953)
* (cqlsh) Distinguish negative and positive infinity in output (CASSANDRA-10523)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/9b3b1cb0/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py
index 5f93003..49970e4 100644
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@ -143,7 +143,7 @@ JUNK ::= /([ \t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
<star> ::= "*" ;
<endtoken> ::= ";" ;
<op> ::= /[-+=,().]/ ;
-<cmp> ::= /[<>]=?/ ;
+<cmp> ::= /[<>!]=?/ ;
<brackets> ::= /[][{}]/ ;
<integer> ::= "-"? <wholenumber> ;
http://git-wip-us.apache.org/repos/asf/cassandra/blob/9b3b1cb0/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
index 37b46ae..75a3b40 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -29,7 +29,6 @@ import org.apache.cassandra.config.ColumnDefinition;
import org.apache.cassandra.config.Schema;
import org.apache.cassandra.cql3.*;
import org.apache.cassandra.db.*;
-import org.apache.cassandra.db.composites.AbstractCellNameType;
import org.apache.cassandra.db.composites.CBuilder;
import org.apache.cassandra.db.composites.Composite;
import org.apache.cassandra.db.filter.ColumnSlice;
@@ -339,7 +338,7 @@ public abstract class ModificationStatement implements CQLStatement
// UPDATE t SET s = 3 WHERE k = 0 AND v = 1
// DELETE v FROM t WHERE k = 0 AND v = 1
// sounds like you don't really understand what your are doing.
- if (setsStaticColumns && !setsRegularColumns)
+ if (appliesOnlyToStaticColumns())
{
// If we set no non-static columns, then it's fine not to have clustering columns
if (hasNoClusteringColumns)
@@ -361,6 +360,27 @@ public abstract class ModificationStatement implements CQLStatement
return createClusteringPrefixBuilderInternal(options);
}
+ /**
+ * Checks that the modification only apply to static columns.
+ * @return <code>true</code> if the modification only apply to static columns, <code>false</code> otherwise.
+ */
+ private boolean appliesOnlyToStaticColumns()
+ {
+ return setsStaticColumns && !appliesToRegularColumns();
+ }
+
+ /**
+ * Checks that the modification apply to regular columns.
+ * @return <code>true</code> if the modification apply to regular columns, <code>false</code> otherwise.
+ */
+ private boolean appliesToRegularColumns()
+ {
+ // If we have regular operations, this applies to regular columns.
+ // Otherwise, if the statement is a DELETE and columnOperations is empty, this means we have no operations,
+ // which for a DELETE means a full row deletion. Which means the operation applies to all columns and regular ones in particular.
+ return setsRegularColumns || (type == StatementType.DELETE && columnOperations.isEmpty());
+ }
+
private Composite createClusteringPrefixBuilderInternal(QueryOptions options)
throws InvalidRequestException
{
http://git-wip-us.apache.org/repos/asf/cassandra/blob/9b3b1cb0/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
index 0438f13..e94011b 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
@@ -26,7 +26,6 @@ import org.apache.cassandra.exceptions.SyntaxException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
public class InsertUpdateIfConditionTest extends CQLTester
{
@@ -181,6 +180,17 @@ public class InsertUpdateIfConditionTest extends CQLTester
assertInvalid("DELETE FROM %s WHERE i = 0 IF EXISTS");
assertInvalid("DELETE FROM %s WHERE k = 0 AND i > 0 IF EXISTS");
assertInvalid("DELETE FROM %s WHERE k = 0 AND i > 0 IF v = 'foo'");
+
+ createTable("CREATE TABLE %s(k int, s int static, i int, v text, PRIMARY KEY(k, i))");
+ execute("INSERT INTO %s (k, s, i, v) VALUES ( 1, 1, 2, '1')");
+ assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s != 1"), row(false, 1));
+ assertRows(execute("DELETE v FROM %s WHERE k = 1 AND i = 2 IF s = 1"), row(true));
+ assertRows(execute("SELECT * FROM %s WHERE k = 1 AND i = 2"), row(1, 2, 1, null));
+
+ assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s != 1"), row(false, 1));
+ assertRows(execute("DELETE FROM %s WHERE k = 1 AND i = 2 IF s = 1"), row(true));
+ assertEmpty(execute("SELECT * FROM %s WHERE k = 1 AND i = 2"));
+ assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, null, 1, null));
}
/**
[2/2] cassandra git commit: Merge branch cassandra-2.1 into
cassandra-2.2
Posted by bl...@apache.org.
Merge branch cassandra-2.1 into cassandra-2.2
Conflicts:
CHANGES.txt
src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a3379073
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a3379073
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a3379073
Branch: refs/heads/cassandra-2.2
Commit: a33790730a9ef0fd2ef3a6c18f00dfee013a68e3
Parents: 728f94e 9b3b1cb
Author: blerer <be...@datastax.com>
Authored: Tue Oct 20 14:06:45 2015 +0200
Committer: blerer <be...@datastax.com>
Committed: Tue Oct 20 14:06:45 2015 +0200
----------------------------------------------------------------------
CHANGES.txt | 1 +
pylib/cqlshlib/cql3handling.py | 2 +-
.../cql3/statements/ModificationStatement.java | 23 +++++++++++++++++++-
.../operations/InsertUpdateIfConditionTest.java | 12 +++++++++-
4 files changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3379073/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 3eff22c,b17929c..261a53a
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,11 -1,7 +1,12 @@@
-2.1.12
+2.2.4
+ * Expose phi values from failure detector via JMX and tweak debug
+ and trace logging (CASSANDRA-9526)
+ * Fix RangeNamesQueryPager (CASSANDRA-10509)
+ * Deprecate Pig support (CASSANDRA-10542)
+ * Reduce contention getting instances of CompositeType (CASSANDRA-10433)
+Merged from 2.1:
+ * Fix conditions on static columns (CASSANDRA-10264)
* AssertionError: attempted to delete non-existing file CommitLog (CASSANDRA-10377)
- * Merge range tombstones during compaction (CASSANDRA-7953)
* (cqlsh) Distinguish negative and positive infinity in output (CASSANDRA-10523)
* (cqlsh) allow custom time_format for COPY TO (CASSANDRA-8970)
* Don't allow startup if the node's rack has changed (CASSANDRA-10242)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3379073/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3379073/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3379073/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
----------------------------------------------------------------------