You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Clément Fumey <cl...@gmail.com> on 2014/11/06 08:44:37 UTC
Counter column impossible to delete and re-insert
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
Re: Counter column impossible to delete and re-insert
Posted by DuyHai Doan <do...@gmail.com>.
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" <cl...@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
>