Alex Denisov created CASSANDRA-13878:
----------------------------------------
Summary: The token function validation
Key: CASSANDRA-13878
URL: https://issues.apache.org/jira/browse/CASSANDRA-13878
Project: Cassandra
Issue Type: Bug
Reporter: Alex Denisov
Priority: Minor
Currently, there are few issues with the token() function validation.
First one:
It is possible to call the function with a wrong number of arguments, which
could lead to a Null Pointer Exception.
Here is an example:
{code}
> CREATE TABLE test(k1 text, k2 text, PRIMARY KEY((k1, k2)));
> INSERT INTO test(k1, k2) VALUES('foo', 'bar');
> SELECT token(k1) FROM test;
ServerError: java.lang.NullPointerException
{code}
The fix is trivial, here is an example:
https://github.com/apache/cassandra/compare/trunk...AlexDenisov:token_crash
However, it uncovers the second issue.
The token function can be called either without parameters or with N parameters
(where N = # of partition keys). The patch would not allow this to happen.
The same goes for a function call validation as a part of where clause:
{code}
> SELECT * FROM test where token(k1, k2) > token();
InvalidRequest: Error from server: code=2200 [Invalid query] message="Incorrect
number of arguments specified for function system.token : (text, text) ->
bigint (expected 2, found 0)"
{code}
I do not see any obvious solution here. Since the token() function is special I
could only suggest extending the `Function` class with an additional method
(e.g. isTokenFunction()), and validate the number of passed parameters
accordingly.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]