Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-5715

CAS on 'primary key only' table

    XMLWordPrintableJSON

Details

    Description

      Given a table with only a primary key, like

      CREATE TABLE test (k int PRIMARY KEY)
      

      there is currently no way to CAS a row in that table into existing because:

      1. INSERT doesn't currently support IF
      2. 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:

      UPDATE WHERE k=0;
      

      which maybe is too ugly to allow?

      Attachments

        1. 5715-v2.txt
          5 kB
          Sylvain Lebresne
        2. 0002-Support-updating-the-PK-only.txt
          1.0 kB
          Sylvain Lebresne
        3. 0001-Conditions-on-INSERT.txt
          3 kB
          Sylvain Lebresne

        Issue Links

          Activity

            People

              slebresne Sylvain Lebresne
              slebresne Sylvain Lebresne
              Sylvain Lebresne
              Jonathan Ellis
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: