[jira] [Commented] (CASSANDRA-8610) Allow IF EXISTS for UPDATE statements
[ https://issues.apache.org/jira/browse/CASSANDRA-8610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14304868#comment-14304868 ] Sylvain Lebresne commented on CASSANDRA-8610: - I think we just forgot about it, no other non-obvious reason as far as I remember. > Allow IF EXISTS for UPDATE statements > - > > Key: CASSANDRA-8610 > URL: https://issues.apache.org/jira/browse/CASSANDRA-8610 > Project: Cassandra > Issue Type: Improvement > Components: API > Environment: Cassandra 2.1.2 >Reporter: DOAN DuyHai >Priority: Minor > Attachments: 8610.patch > > > While creating a hands-on exercice for Cassandra, I was facing a quite > annoying limitation. > Let's take this table: > {code:sql} > CREATE TABLE killrchat.chat_rooms( > room_name text, > creation_date timestamp, > banner text, > creator text, > participants set, > PRIMARY KEY(room_name)); > {code} > Upon a new participant joining the room, to be concurrency-proof (avoiding > mutating the participants set if the room is deleted concurrently), I would > like to issue this query: > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF EXISTS; > {code} > Unfortunately the clause IF EXISTS is not allowed for UPDATE statements. > Similarly I tried > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF room_name='games'; > {code} > It doesn't work either, it is not allowed to use one column of the primary > key as condition column for LWT (why ? mystery). > So far, the only work-around I found is: > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF name='games'; > {code} > I added an extra column called *name* which is just the duplicate of the > partition key *room_name*. It does work but is not very elegant. > I believe there are legit use cases for UPDATE ... IF EXISTS; -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (CASSANDRA-8610) Allow IF EXISTS for UPDATE statements
[ https://issues.apache.org/jira/browse/CASSANDRA-8610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14303743#comment-14303743 ] Tyler Hobbs commented on CASSANDRA-8610: The patch seems to work fine with some extra dtests I wrote, and I can't think of a reason why this shouldn't work. [~slebresne] is there a non-obvious reason this wasn't supported from the start? > Allow IF EXISTS for UPDATE statements > - > > Key: CASSANDRA-8610 > URL: https://issues.apache.org/jira/browse/CASSANDRA-8610 > Project: Cassandra > Issue Type: Improvement > Components: API > Environment: Cassandra 2.1.2 >Reporter: DOAN DuyHai >Priority: Minor > Attachments: 8610.patch > > > While creating a hands-on exercice for Cassandra, I was facing a quite > annoying limitation. > Let's take this table: > {code:sql} > CREATE TABLE killrchat.chat_rooms( > room_name text, > creation_date timestamp, > banner text, > creator text, > participants set, > PRIMARY KEY(room_name)); > {code} > Upon a new participant joining the room, to be concurrency-proof (avoiding > mutating the participants set if the room is deleted concurrently), I would > like to issue this query: > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF EXISTS; > {code} > Unfortunately the clause IF EXISTS is not allowed for UPDATE statements. > Similarly I tried > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF room_name='games'; > {code} > It doesn't work either, it is not allowed to use one column of the primary > key as condition column for LWT (why ? mystery). > So far, the only work-around I found is: > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF name='games'; > {code} > I added an extra column called *name* which is just the duplicate of the > partition key *room_name*. It does work but is not very elegant. > I believe there are legit use cases for UPDATE ... IF EXISTS; -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (CASSANDRA-8610) Allow IF EXISTS for UPDATE statements
[ https://issues.apache.org/jira/browse/CASSANDRA-8610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14296682#comment-14296682 ] Prajakta Bhosale commented on CASSANDRA-8610: - I am taking up this JIRA. I already have the patch for the same,will upload after testing. > Allow IF EXISTS for UPDATE statements > - > > Key: CASSANDRA-8610 > URL: https://issues.apache.org/jira/browse/CASSANDRA-8610 > Project: Cassandra > Issue Type: Improvement > Components: API > Environment: Cassandra 2.1.2 >Reporter: DOAN DuyHai >Priority: Minor > > While creating a hands-on exercice for Cassandra, I was facing a quite > annoying limitation. > Let's take this table: > {code:sql} > CREATE TABLE killrchat.chat_rooms( > room_name text, > creation_date timestamp, > banner text, > creator text, > participants set, > PRIMARY KEY(room_name)); > {code} > Upon a new participant joining the room, to be concurrency-proof (avoiding > mutating the participants set if the room is deleted concurrently), I would > like to issue this query: > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF EXISTS; > {code} > Unfortunately the clause IF EXISTS is not allowed for UPDATE statements. > Similarly I tried > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF room_name='games'; > {code} > It doesn't work either, it is not allowed to use one column of the primary > key as condition column for LWT (why ? mystery). > So far, the only work-around I found is: > {code:sql} > UPDATE chat_rooms SET participants = participants + {'johnny'} WHERE > room_name = 'games' IF name='games'; > {code} > I added an extra column called *name* which is just the duplicate of the > partition key *room_name*. It does work but is not very elegant. > I believe there are legit use cases for UPDATE ... IF EXISTS; -- This message was sent by Atlassian JIRA (v6.3.4#6332)