@@ -18,11 +18,16 @@ use async_trait::async_trait;
1818use futures:: { future:: join_all, FutureExt as _, StreamExt } ;
1919use linera_base:: ensure;
2020use scylla:: {
21- batch:: BatchStatement ,
22- prepared_statement:: PreparedStatement ,
23- statement:: batch:: BatchType ,
24- transport:: errors:: { DbError , QueryError } ,
25- Session , SessionBuilder ,
21+ client:: { session:: Session , session_builder:: SessionBuilder } ,
22+ deserialize:: { DeserializationError , TypeCheckError } ,
23+ errors:: {
24+ DbError , ExecutionError , IntoRowsResultError , NewSessionError , NextPageError , NextRowError ,
25+ PagerExecutionError , PrepareError , RequestAttemptError , RequestError , RowsError ,
26+ } ,
27+ statement:: {
28+ batch:: { BatchStatement , BatchType } ,
29+ prepared:: PreparedStatement ,
30+ } ,
2631} ;
2732use serde:: { Deserialize , Serialize } ;
2833use thiserror:: Error ;
@@ -466,27 +471,27 @@ pub enum ScyllaDbStoreInternalError {
466471
467472 /// A deserialization error in ScyllaDB
468473 #[ error( transparent) ]
469- DeserializationError ( #[ from] scylla :: deserialize :: DeserializationError ) ,
474+ DeserializationError ( #[ from] DeserializationError ) ,
470475
471476 /// A row error in ScyllaDB
472477 #[ error( transparent) ]
473- RowsError ( #[ from] scylla :: transport :: query_result :: RowsError ) ,
478+ RowsError ( #[ from] RowsError ) ,
474479
475480 /// A type error in the accessed data in ScyllaDB
476481 #[ error( transparent) ]
477- IntoRowsResultError ( #[ from] scylla :: transport :: query_result :: IntoRowsResultError ) ,
482+ IntoRowsResultError ( #[ from] IntoRowsResultError ) ,
478483
479484 /// A type check error in ScyllaDB
480485 #[ error( transparent) ]
481- TypeCheckError ( #[ from] scylla :: deserialize :: TypeCheckError ) ,
486+ TypeCheckError ( #[ from] TypeCheckError ) ,
482487
483488 /// A query error in ScyllaDB
484489 #[ error( transparent) ]
485- ScyllaDbQueryError ( #[ from] scylla :: transport :: errors :: QueryError ) ,
490+ PagerExecutionError ( #[ from] PagerExecutionError ) ,
486491
487492 /// A query error in ScyllaDB
488493 #[ error( transparent) ]
489- ScyllaDbNewSessionError ( #[ from] scylla :: transport :: errors :: NewSessionError ) ,
494+ ScyllaDbNewSessionError ( #[ from] NewSessionError ) ,
490495
491496 /// Namespace contains forbidden characters
492497 #[ error( "Namespace contains forbidden characters" ) ]
@@ -499,6 +504,18 @@ pub enum ScyllaDbStoreInternalError {
499504 /// The batch is too long to be written
500505 #[ error( "The batch is too long to be written" ) ]
501506 BatchTooLong ,
507+
508+ /// A prepare error in ScyllaDB
509+ #[ error( transparent) ]
510+ PrepareError ( #[ from] PrepareError ) ,
511+
512+ /// An execution error in ScyllaDB
513+ #[ error( transparent) ]
514+ ExecutionError ( #[ from] ExecutionError ) ,
515+
516+ /// A next row error in ScyllaDB
517+ #[ error( transparent) ]
518+ NextRowError ( #[ from] NextRowError ) ,
502519}
503520
504521impl KeyValueStoreError for ScyllaDbStoreInternalError {
@@ -694,15 +711,15 @@ impl AdminKeyValueStore for ScyllaDbStoreInternal {
694711 Ok ( result) => result,
695712 Err ( error) => {
696713 let invalid_or_not_found = match & error {
697- QueryError :: DbError ( db_error , msg ) => {
698- * db_error == DbError :: Invalid && msg. as_str ( ) == miss_msg
699- }
714+ PagerExecutionError :: NextPageError ( NextPageError :: RequestFailure (
715+ RequestError :: LastAttemptError ( RequestAttemptError :: DbError ( db_error , msg) ) ,
716+ ) ) => * db_error == DbError :: Invalid && msg . as_str ( ) == miss_msg ,
700717 _ => false ,
701718 } ;
702719 if invalid_or_not_found {
703720 return Ok ( Vec :: new ( ) ) ;
704721 } else {
705- return Err ( ScyllaDbStoreInternalError :: ScyllaDbQueryError ( error) ) ;
722+ return Err ( ScyllaDbStoreInternalError :: PagerExecutionError ( error) ) ;
706723 }
707724 }
708725 } ;
@@ -781,7 +798,9 @@ impl AdminKeyValueStore for ScyllaDbStoreInternal {
781798 return Ok ( true ) ;
782799 } ;
783800 let missing_table = match & error {
784- QueryError :: DbError ( db_error, msg) => {
801+ PrepareError :: AllAttemptsFailed {
802+ first_attempt : RequestAttemptError :: DbError ( db_error, msg) ,
803+ } => {
785804 if * db_error != DbError :: Invalid {
786805 false
787806 } else {
@@ -795,7 +814,7 @@ impl AdminKeyValueStore for ScyllaDbStoreInternal {
795814 if missing_table {
796815 Ok ( false )
797816 } else {
798- Err ( ScyllaDbStoreInternalError :: ScyllaDbQueryError ( error) )
817+ Err ( ScyllaDbStoreInternalError :: PrepareError ( error) )
799818 }
800819 }
801820
0 commit comments