forked from scylladb/scylla-rust-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
batch: Replace BatchResult with QueryResult
BatchResult is a struct used to represent the result of a batch query. The difference between BatchResult and QueryResult is that BatchResult doesn't contain any rows. Batches only support INSERT and UPDATE statements, so it made sense to create a type with stricter constraints that could be used to represent this rowless result. It turns out that in certain cases batches do return rows. For batches with LWT queries, like this one: ``` BEGIN BATCH UPDATE ks.data set version = 1 WHERE key = 'x1a' and client = 0x01 IF version = 0; UPDATE ks.data set version = 1 WHERE key = 'x1b' and client = 0x01 IF version = 0; APPLY BATCH; ``` The database returns rows with information about the changes performed: ``` [applied] | client | key | version -----------+--------+-----+--------- False | 0x01 | x1a | 1 False | 0x01 | x1b | 0 ``` It wasn't possible to access these rows because BatchResult had no rows, as described in scylladb#554. The solution is to remove BatchResult and use QueryResult instead. Batch is now like any other query which might return rows. There's one field of QueryResult that doesn't make sense for batches: `paging_state`, but we can ignore it. QueryResult has a ton of convenience methods that can be used to access the received rows, we would have to duplicate them all for BatchResult. I think we can have one useless field, this much duplication isn't worth it. At first I thought that maybe we could just expose a list of [applied] bools, not rows, but this isn't enough. There are other columns that tell us the values of columns involved in the LWT. This might be useful to some users, we can't just discard it. This change brings us a step closer to implementing scylladb#100 Signed-off-by: Jan Ciolek <[email protected]>
- Loading branch information
Showing
12 changed files
with
54 additions
and
75 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
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 was deleted.
Oops, something went wrong.
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
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
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
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