"DO *NOT* USE THAT!!!"

Crystal clear;-). Thanks for the warning.

Alain


2013/3/1 Sylvain Lebresne <sylvain@datastax.com>
On C* 1.2.1 I see that the following query works:

update counters set value=value+5 where owner_id='1' and counter_type='trash';

...while the following one gives an error (Bad Request: Invalid non-counter operation on counter table):

update counters set value=5 where owner_id='1' and counter_type='trash';


In C* 1.2.2. the latter started to work.

Thanks for this opportunity to say: DO *NOT* USE THAT!!!

The fact that that C* 1.2.2 acepts 'update counters set value=5 where ...' is a bug, https://issues.apache.org/jira/browse/CASSANDRA-5300 namely.

If you do perform such a query, it *will corrupt* the counter.

So until 1.2.3 is released, please do not set a counter directly (continue using only increment and decrement).
And, more important, wouldn't be a Great() idea to allow direct setting of counters

It would be great yes if we knew how to make that work, but we don't. And more precisely, setting a counter directly is not something compatible with the current way counters are implemented (for the very same reason than deletes don't really work with counters either: you can delete but only as a definitive way to get rid of the counter. If you re-increment the counter post-delete, anything can happen). We would have done it otherwise.

--
Sylvain