[ https://issues.apache.org/jira/browse/CASSANDRA-20680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Capwell updated CASSANDRA-20680: -------------------------------------- Workflow: Copy of Cassandra Default Workflow (was: Copy of Cassandra Bug Workflow) Issue Type: Improvement (was: Bug) > Cannot mix IF conditions and IF NOT EXISTS for the same row, even though the > conditions could be met > ---------------------------------------------------------------------------------------------------- > > Key: CASSANDRA-20680 > URL: https://issues.apache.org/jira/browse/CASSANDRA-20680 > Project: Apache Cassandra > Issue Type: Improvement > Reporter: Andrzej Jackowski > Priority: Normal > > Mixing {_}IF conditions{_}, {_}IF EXISTS{_}, and _IF NOT EXISTS_ for the same > row is never possible, even in batches for which all LWT conditions are true. > > Consider the following example: > {noformat} > CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', > 'replication_factor' : 1}; > CREATE TABLE ks.cf (p int, c int, r int, PRIMARY KEY(p, c)); > INSERT INTO ks.cf (p,c,r) VALUES (1,1,1); > > BEGIN BATCH > UPDATE ks.cf SET r=2 WHERE p=1 AND c=1 IF EXISTS > UPDATE ks.cf SET r=3 WHERE p=1 AND c=1 IF r > 0 > APPLY BATCH; {noformat} > Both _IF EXISTS_ and _IF r > 0_ conditions are true, however Cassandra > rejects the batch with the following error: > {noformat} > "Cannot mix IF conditions and IF NOT EXISTS for the same row" {noformat} > > In contrast, a very similar batch with two _IF EXISTS_ conditions works: > {noformat} > BEGIN BATCH > UPDATE ks.cf SET r=2 WHERE p=1 AND c=1 IF EXISTS > UPDATE ks.cf SET r=3 WHERE p=1 AND c=1 IF EXISTS > APPLY BATCH; > > [applied] > ----------- > True{noformat} > > I can see two problems here: > # The error message is incorrect: there is no _NOT EXISTS_ in my query. > However, it is rather a cosmetic issue. > # Why is a batch statement with two _IF EXISTS_ statement allowed, while the > one mixing _IF EXISTS_ and _IF r > 0_ is not? I thought that the _Invalid > query_ error should be returned only for conditions that cannot be met (e.g., > asking for the same row to _EXISTS_ and _NOT EXISTS_ in the same time). -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org