Files
scylladb/test/cql/token_from_null_test.result
Kefu Chai 79d2eb1607 cql3: functions: validate arguments for 'token()' also
since "token()" computes the token for a given partition key,
if we pass the key of the wrong type, it should reject.

in this change,

* we validate the keys before returning the "token()" function.
* drop the "xfail" decorator from two of the tests. they pass
  now after this fix.
* change the tests which previously passed the wrong number of
  arguments containing null to "token()" and expect it to return
  null, so they verify that "token()" should reject these
  arguments with the expected error message.

Fixes #10448
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #12991
2023-02-26 19:01:58 +02:00

28 lines
1.1 KiB
Plaintext

> -- single null value
> CREATE KEYSPACE reproducer WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
OK
> CREATE TABLE reproducer.t(pk int PRIMARY KEY, v int);
OK
> INSERT INTO reproducer.t (pk) VALUES (1);
OK
> SELECT TOKEN(v) FROM reproducer.t;
+-------------------+
| system.token(v) |
|-------------------|
| null |
+-------------------+
>
> -- multiple null values
> CREATE TABLE reproducer.t2(pk int PRIMARY KEY, a int, b int);
OK
> INSERT INTO reproducer.t2 (pk) VALUES (1);
OK
> SELECT TOKEN(pk, a, b) FROM reproducer.t2;
Error from server: code=2200 [Invalid query] message="Invalid number of arguments in call to function system.token: 1 required but 3 provided"
> SELECT TOKEN(pk, b) FROM reproducer.t2;
Error from server: code=2200 [Invalid query] message="Invalid number of arguments in call to function system.token: 1 required but 2 provided"
> SELECT TOKEN(a, b) FROM reproducer.t2;
Error from server: code=2200 [Invalid query] message="Invalid number of arguments in call to function system.token: 1 required but 2 provided"
>
> DROP KEYSPACE reproducer;OK