Re: Counter column impossible to delete and re-insert

2014-11-06 Thread DuyHai Doan
Hello Clément

This is a known anti-pattern. You should never re-use a deleted counter
column otherwise there will be unpredictable result for the counter value.
Le 6 nov. 2014 08:45, Clément Fumey clement@gmail.com a écrit :

 Hi,

 I have a table with counter column . When I insert (update) a row, delete
 it and try to re-insert, it fail to re-insert the row. Here is the commands
 i use :

 CREATE TABLE test(
 testId int,
 year int,
 testCounter counter,
 PRIMARY KEY (testId, year)
 )WITH CLUSTERING ORDER BY (year DESC);

 UPDATE test SET testcounter = testcounter +5 WHERE testid = 2 AND year =
 2014;
 DELETE FROM test WHERE testid = 2 AND year = 2014;
 UPDATE test SET testcounter = testcounter +5 WHERE testid = 2 AND year =
 2014;

 The last command failed, there is no error message but the table is empty
 after it.
 Is that normal? Am I doing something wrong?

 Regards

 Clément



Counter column impossible to delete and re-insert

2014-11-05 Thread Clément Fumey
Hi,

I have a table with counter column . When I insert (update) a row, delete
it and try to re-insert, it fail to re-insert the row. Here is the commands
i use :

CREATE TABLE test(
testId int,
year int,
testCounter counter,
PRIMARY KEY (testId, year)
)WITH CLUSTERING ORDER BY (year DESC);

UPDATE test SET testcounter = testcounter +5 WHERE testid = 2 AND year =
2014;
DELETE FROM test WHERE testid = 2 AND year = 2014;
UPDATE test SET testcounter = testcounter +5 WHERE testid = 2 AND year =
2014;

The last command failed, there is no error message but the table is empty
after it.
Is that normal? Am I doing something wrong?

Regards

Clément