You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Benjamin Lerer (Jira)" <ji...@apache.org> on 2021/10/08 15:50:00 UTC

[jira] [Updated] (CASSANDRA-13878) Provide error message for invalid token() parameters

     [ https://issues.apache.org/jira/browse/CASSANDRA-13878?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Lerer updated CASSANDRA-13878:
---------------------------------------
    Resolution: Duplicate
        Status: Resolved  (was: Open)

> Provide error message for invalid token() parameters
> ----------------------------------------------------
>
>                 Key: CASSANDRA-13878
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-13878
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Legacy/CQL, Legacy/Tools
>            Reporter: Alex Denisov
>            Priority: Low
>
> 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
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org