Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 777E7200BBA for ; Fri, 21 Oct 2016 23:39:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 76095160AE8; Fri, 21 Oct 2016 21:39:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 99D8B160ADE for ; Fri, 21 Oct 2016 23:39:00 +0200 (CEST) Received: (qmail 17000 invoked by uid 500); 21 Oct 2016 21:38:59 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 16984 invoked by uid 99); 21 Oct 2016 21:38:59 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Oct 2016 21:38:59 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 980872C0D55 for ; Fri, 21 Oct 2016 21:38:59 +0000 (UTC) Date: Fri, 21 Oct 2016 21:38:59 +0000 (UTC) From: "Jason T. Bradshaw (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CASSANDRA-12829) DELETE query with an empty IN clause can delete more than expected MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 21 Oct 2016 21:39:01 -0000 [ https://issues.apache.org/jira/browse/CASSANDRA-12829?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jason T. Bradshaw updated CASSANDRA-12829: ------------------------------------------ Description: When deleting from a table with a certain structure and using an *in* clause with an empty list, the *in* clause with an empty list can be ignored, resulting in deleting more than is expected. *Setup:* {code} cqlsh> create table test (a text, b text, id uuid, primary key ((a, b), id)); cqlsh> insert into test (a, b, id) values ('a', 'b', 00000000-0000-0000-0000-000000000000); cqlsh> insert into test (a, b, id) values ('b', 'c', 00000000-0000-0000-0000-000000000000); cqlsh> insert into test (a, b, id) values ('a', 'c', 00000000-0000-0000-0000-000000000000); cqlsh> select * from test; a | b | id ---+---+-------------------------------------- a | c | 00000000-0000-0000-0000-000000000000 b | c | 00000000-0000-0000-0000-000000000000 a | b | 00000000-0000-0000-0000-000000000000 (3 rows) {code} *Expected:* {code} cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c') and id in (); cqlsh> select * from test; a | b | id ---+---+-------------------------------------- a | c | 00000000-0000-0000-0000-000000000000 b | c | 00000000-0000-0000-0000-000000000000 a | b | 00000000-0000-0000-0000-000000000000 (3 rows) {code} *Actual:* {code} cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c') and id in (); cqlsh> select * from test; a | b | id ---+---+-------------------------------------- b | c | 00000000-0000-0000-0000-000000000000 (1 rows) {code} Instead of deleting nothing, as the final empty *in* clause would imply, it instead deletes everything that matches the first two clauses, acting as if the following query had been issued instead: {code} cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c'); {code} This seems to be related to the presence of a tuple clustering key, as I could not reproduce it without one. was: When deleting from a table with a certain structure and using an *in* clause with an empty list, the *in* clause with an empty list can be ignored, resulting in deleting more than is expected. *Setup:* {code} cqlsh> create table test (a text, b text, id uuid, primary key ((a, b), id)); cqlsh> insert into test (a, b, id) values ('a', 'b', 00000000-0000-0000-0000-000000000000); cqlsh> insert into test (a, b, id) values ('b', 'c', 00000000-0000-0000-0000-000000000000); cqlsh> insert into test (a, b, id) values ('a', 'c', 00000000-0000-0000-0000-000000000000); cqlsh> select * from test; a | b | id ---+---+-------------------------------------- a | c | 00000000-0000-0000-0000-000000000000 b | c | 00000000-0000-0000-0000-000000000000 a | b | 00000000-0000-0000-0000-000000000000 (3 rows) {code} *Expected:* {code} cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c') and id in (); cqlsh> select * from test; a | b | id ---+---+-------------------------------------- a | c | 00000000-0000-0000-0000-000000000000 b | c | 00000000-0000-0000-0000-000000000000 a | b | 00000000-0000-0000-0000-000000000000 (3 rows) {code} *Actual:* {code} cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c') and id in (); cqlsh> select * from test; a | b | id ---+---+-------------------------------------- b | c | 00000000-0000-0000-0000-000000000000 (1 rows) {code} Instead of deleting nothing, as the final empty *in* clause would imply, it instead deletes everything that matches the first two clauses, acting as if the following query had been issued instead: {code} cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c'); {code} > DELETE query with an empty IN clause can delete more than expected > ------------------------------------------------------------------ > > Key: CASSANDRA-12829 > URL: https://issues.apache.org/jira/browse/CASSANDRA-12829 > Project: Cassandra > Issue Type: Bug > Components: CQL > Environment: Arch Linux x64, kernel 4.7.6, Cassandra 3.9 downloaded from the website > Reporter: Jason T. Bradshaw > > When deleting from a table with a certain structure and using an *in* clause with an empty list, the *in* clause with an empty list can be ignored, resulting in deleting more than is expected. > *Setup:* > {code} > cqlsh> create table test (a text, b text, id uuid, primary key ((a, b), id)); > cqlsh> insert into test (a, b, id) values ('a', 'b', 00000000-0000-0000-0000-000000000000); > cqlsh> insert into test (a, b, id) values ('b', 'c', 00000000-0000-0000-0000-000000000000); > cqlsh> insert into test (a, b, id) values ('a', 'c', 00000000-0000-0000-0000-000000000000); > cqlsh> select * from test; > a | b | id > ---+---+-------------------------------------- > a | c | 00000000-0000-0000-0000-000000000000 > b | c | 00000000-0000-0000-0000-000000000000 > a | b | 00000000-0000-0000-0000-000000000000 > (3 rows) > {code} > *Expected:* > {code} > cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c') and id in (); > cqlsh> select * from test; > a | b | id > ---+---+-------------------------------------- > a | c | 00000000-0000-0000-0000-000000000000 > b | c | 00000000-0000-0000-0000-000000000000 > a | b | 00000000-0000-0000-0000-000000000000 > (3 rows) > {code} > *Actual:* > {code} > cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c') and id in (); > cqlsh> select * from test; > a | b | id > ---+---+-------------------------------------- > b | c | 00000000-0000-0000-0000-000000000000 > (1 rows) > {code} > Instead of deleting nothing, as the final empty *in* clause would imply, it instead deletes everything that matches the first two clauses, acting as if the following query had been issued instead: > {code} > cqlsh> delete from test where a = 'a' and b in ('a', 'b', 'c'); > {code} > This seems to be related to the presence of a tuple clustering key, as I could not reproduce it without one. -- This message was sent by Atlassian JIRA (v6.3.4#6332)