cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CASSANDRA-5715) CAS on 'primary key only' table
Date Thu, 04 Jul 2013 15:15:48 GMT

     [ https://issues.apache.org/jira/browse/CASSANDRA-5715?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sylvain Lebresne updated CASSANDRA-5715:
----------------------------------------

    Attachment: 0002-Support-updating-the-PK-only.txt
                0001-Conditions-on-INSERT.txt

bq. We could special case it then as UPDATE test SET PRIMARY KEY WHERE k=0

Wfm, attached trivial patch for that.

Also attaching patch to allow conditions on INSERT. I'll note that the patch allows all the
same conditions that UPDATE support, meaning that you can write:
{noformat}
INSERT INTO test(c1, c2, c3) VALUES(0, 1, 2) IF c2 = 4
{noformat}
which, arguably, is weird from a SQL point of view, but I guess it's not weirder than
{noformat}
UPDATE test SET c2=1, c3=2 WHERE c1=0 IF NOT EXISTS
{noformat}

                
> CAS on 'primary key only' table
> -------------------------------
>
>                 Key: CASSANDRA-5715
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-5715
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Sylvain Lebresne
>            Priority: Minor
>         Attachments: 0001-Conditions-on-INSERT.txt, 0002-Support-updating-the-PK-only.txt
>
>
> Given a table with only a primary key, like
> {noformat}
> CREATE TABLE test (k int PRIMARY KEY)
> {noformat}
> there is currently no way to CAS a row in that table into existing because:
> # INSERT doesn't currently support IF
> # UPDATE has no way to update such table
> So we should probably allow IF conditions on INSERT statements.
> In addition (or alternatively), we could work on allowing UPDATE to update such table.
One motivation for that could be to make UPDATE always be more general to INSERT. That is
currently, there is a bunch of operation that INSERT cannot do (counter increments, collection
appends), but that "primary key table" case is, afaik, the only case where you *need* to use
INSERT. However, because CQL forces segregation of PK value to the WHERE clause and not to
the SET one, the only syntax that I can see work would be:
> {noformat}
> UPDATE WHERE k=0;
> {noformat}
> which maybe is too ugly to allow?
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message