incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Blair Zajac <bl...@orcaware.com>
Subject How to do a CAS UPDATE on single column CF?
Date Tue, 25 Jun 2013 03:23:57 GMT
How does one do an atomic update in a column family with a single column?

I have a this CF

   CREATE TABLE schema_migrations (
     version TEXT PRIMARY KEY,
   ) WITH COMPACTION = {'class': 'LeveledCompactionStrategy'};

that records which database migrations have been applied.  I want to do 
a CAS UPDATE to add a dummy lock token to prevent multiple migrations 
from running, but these three attempts fail (using the Python cql client):


 >>> cursor.execute("UPDATE schema_migrations SET version = 'locked' 
WHERE version = 'locked' IF NOT EXISTS")
cql.apivalues.ProgrammingError: Bad Request: PRIMARY KEY part version 
found in SET part


 >>> cursor.execute("UPDATE schema_migrations SET WHERE version = 
'locked' IF NOT EXISTS")
cql.apivalues.ProgrammingError: Bad Request: line 1:29 no viable 
alternative at input 'WHERE'



 >>> cursor.execute("INSERT INTO schema_migrations (version) VALUES 
('locked') IF NOT EXISTS")
cql.apivalues.ProgrammingError: Bad Request: line 1:58 missing EOF at 'IF'

Thanks,
Blair

Mime
View raw message