[
https://issues.apache.org/jira/browse/CASSANDRA-20163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Capwell updated CASSANDRA-20163:
--------------------------------------
Bug Category: Parent values: Correctness(12982)Level 1 values: API /
Semantic Implementation(12988)
Complexity: Low Hanging Fruit
Discovered By: Fuzz Test
Fix Version/s: 4.0.x
Severity: Normal
Status: Open (was: Triage Needed)
Once we get back in January I can try to create a patch for the older
branches... here is the trunk patch for now... if someone wants to push this
forward before January feel free =D.
{code}
diff --git a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
index f2bbec1458..0368b7bbe8 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
@@ -201,8 +201,9 @@ public class DeleteStatement extends ModificationStatement
{
checkFalse(stmt.isVirtual(), "DELETE statements must restrict
all PRIMARY KEY columns with equality relations");
- checkFalse(operations.appliesToRegularColumns(),
- "DELETE statements must restrict all PRIMARY KEY
columns with equality relations in order to delete non static columns");
+ if (!operations.isEmpty())
+ checkFalse(operations.appliesToRegularColumns(),
+ "DELETE statements must restrict all PRIMARY
KEY columns with equality relations in order to delete non static columns");
// All primary keys must be specified, unless this has static
column restrictions
checkFalse(conditions.appliesToRegularColumns(),
diff --git a/test/unit/org/apache/cassandra/cql3/DeleteTest.java
b/test/unit/org/apache/cassandra/cql3/DeleteTest.java
index 3c95a6cb8f..4510e8cae2 100644
--- a/test/unit/org/apache/cassandra/cql3/DeleteTest.java
+++ b/test/unit/org/apache/cassandra/cql3/DeleteTest.java
@@ -46,7 +46,7 @@ public class DeleteTest extends CQLTester
session.getCluster().getConfiguration().getQueryOptions().setConsistencyLevel(ConsistencyLevel.ONE);
session.execute("drop keyspace if exists junit;");
- session.execute("create keyspace junit WITH REPLICATION = \{ 'class' :
'SimpleStrategy', 'replication_factor' : 2 };");
+ session.execute("create keyspace junit WITH REPLICATION = \{ 'class' :
'SimpleStrategy', 'replication_factor' : 1 };");
session.execute("CREATE TABLE junit.tpc_base (\n" +
" id int ,\n" +
" cid int ,\n" +
@@ -93,6 +93,33 @@ public class DeleteTest extends CQLTester
pstmt5 = session.prepare("select id, cid, inh_c, val from
junit.tpc_inherit_c where id=? and cid=?");
}
+ @Test
+ public void deleteCasWithStatic()
+ {
+ createTable("CREATE TABLE %s(\n" +
+ "\t\t pk0 int,\n" +
+ "\t\t ck0 int,\n" +
+ "\t\t s0 int static,\n" +
+ "\t\t v0 int,\n" +
+ "\t\t PRIMARY KEY (pk0, ck0)\n" +
+ "\t\t)");
+
+ execute("INSERT INTO %s (pk0, ck0, s0, v0) VALUES (0, 0, 0, 0)");
+ executeNet("DELETE\n" +
+ "FROM %s\n" +
+ "WHERE \n" +
+ " pk0 = 0\n" +
+ "IF s0 = 2");
+ assertRows(execute("SELECT * FROM %s WHERE pk0 = 0"),
+ row(0, 0, 0, 0));
+ executeNet("DELETE\n" +
+ "FROM %s\n" +
+ "WHERE \n" +
+ " pk0 = 0\n" +
+ "IF s0 = 0");
+ assertRows(execute("SELECT * FROM %s WHERE pk0 = 0"));
+ }
+
@Test
public void lostDeletesTest()
{
{code}
> DELETE partition IF static column is rejected
> ---------------------------------------------
>
> Key: CASSANDRA-20163
> URL: https://issues.apache.org/jira/browse/CASSANDRA-20163
> Project: Apache Cassandra
> Issue Type: Bug
> Components: CQL/Semantics
> Reporter: David Capwell
> Priority: Normal
> Fix For: 4.0.x
>
>
> {code}
> CREATE TABLE tbl (
> pk int,
> ck int,
> s0 int,
> v0 int,
> PRIMARY KEY (pk, ck)
> );
> DELETE
> FROM tbl
> WHERE pk = ?
> IF s0 = ?
> {code}
> The above fails with the exception
> {code}
> DELETE statements must restrict all PRIMARY KEY columns with equality
> relations in order to delete non static columns
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]