Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cql3: create tokens out of null values properly
Method reponsible for creating a token of given values is not meant to be used with empty optionals. Thus, having requested a token of the columns containing null values resulted with an exception being thrown. This kind of behaviour was not compatible with the one applied in cassandra. To fix this, before the computation of a token, it is checked whether no null value is contained. If any value in the processed vector is null, null value is returned. Fixes: #10594 Closes #10942
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- single null value | ||
CREATE KEYSPACE reproducer WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; | ||
CREATE TABLE reproducer.t(pk int PRIMARY KEY, v int); | ||
INSERT INTO reproducer.t (pk) VALUES (1); | ||
SELECT TOKEN(v) FROM reproducer.t; | ||
|
||
-- multiple null values | ||
CREATE TABLE reproducer.t2(pk int PRIMARY KEY, a int, b int); | ||
INSERT INTO reproducer.t2 (pk) VALUES (1); | ||
SELECT TOKEN(pk, a, b) FROM reproducer.t2; | ||
SELECT TOKEN(pk, b) FROM reproducer.t2; | ||
SELECT TOKEN(a, b) FROM reproducer.t2; | ||
|
||
DROP KEYSPACE reproducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
> -- 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; | ||
+--------------------------+ | ||
| system.token(pk, a, b) | | ||
|--------------------------| | ||
| null | | ||
+--------------------------+ | ||
> SELECT TOKEN(pk, b) FROM reproducer.t2; | ||
+-----------------------+ | ||
| system.token(pk, b) | | ||
|-----------------------| | ||
| null | | ||
+-----------------------+ | ||
> SELECT TOKEN(a, b) FROM reproducer.t2; | ||
+----------------------+ | ||
| system.token(a, b) | | ||
|----------------------| | ||
| null | | ||
+----------------------+ | ||
> | ||
> DROP KEYSPACE reproducer;OK |