Validate empty cell names from counter updates

patch by Aleksey Yeschenko; reviewed by Jeremiah Jordan for
CASSANDRA-7798
This commit is contained in:
Aleksey Yeschenko 2014-08-20 02:22:01 +03:00
parent 48d6950c18
commit 62642fa97e
3 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,5 @@
1.2.19
* Validate empty cell names from counter updates (CASSANDRA-7798)
* Improve PasswordAuthenticator default super user setup (CASSANDRA-7788)
* Remove duplicates from StorageService.getJoiningNodes (CASSANDRA-7478)
* Clone token map outside of hot gossip loops (CASSANDRA-7758)

View File

@ -326,7 +326,7 @@ public abstract class Constants
throw new InvalidRequestException("Invalid null value for counter increment");
long increment = ByteBufferUtil.toLong(bytes);
ByteBuffer cname = columnName == null ? prefix.build() : prefix.add(columnName.key).build();
cf.addCounter(new QueryPath(cf.metadata().cfName, null, cname), increment);
cf.addColumn(params.makeCounter(cname, increment));
}
}
@ -348,7 +348,7 @@ public abstract class Constants
throw new InvalidRequestException("The negation of " + increment + " overflows supported counter precision (signed 8 bytes integer)");
ByteBuffer cname = columnName == null ? prefix.build() : prefix.add(columnName.key).build();
cf.addCounter(new QueryPath(cf.metadata().cfName, null, cname), -increment);
cf.addColumn(params.makeCounter(cname, -increment));
}
}

View File

@ -57,6 +57,12 @@ public class UpdateParameters
: new Column(name, value, timestamp);
}
public Column makeCounter(ByteBuffer name, long delta) throws InvalidRequestException
{
QueryProcessor.validateColumnName(name);
return new CounterUpdateColumn(name, delta, System.currentTimeMillis());
}
public Column makeTombstone(ByteBuffer name) throws InvalidRequestException
{
QueryProcessor.validateColumnName(name);