@@ -33,10 +33,10 @@ use futures::{FutureExt, future::RemoteHandle};
3333use scylla_cql:: frame:: frame_errors:: CqlResponseParseError ;
3434use scylla_cql:: frame:: request:: CqlRequestKind ;
3535use scylla_cql:: frame:: request:: options:: { self , Options } ;
36- use scylla_cql:: frame:: response:: Error ;
3736use scylla_cql:: frame:: response:: authenticate:: Authenticate ;
3837use scylla_cql:: frame:: response:: result:: { ResultMetadata , TableSpec } ;
3938use scylla_cql:: frame:: response:: { self , error} ;
39+ use scylla_cql:: frame:: response:: { Error , ResponseWithDeserializedMetadata } ;
4040use scylla_cql:: frame:: types:: SerialConsistency ;
4141use scylla_cql:: serialize:: batch:: { BatchValues , BatchValuesIterator } ;
4242use scylla_cql:: serialize:: raw_batch:: RawBatchValuesAdapter ;
@@ -546,9 +546,11 @@ impl Connection {
546546 // Extract the response to STARTUP request and tidy up the errors.
547547 let response = match req_result {
548548 Ok ( r) => match r. response {
549- Response :: Ready => NonErrorStartupResponse :: Ready ,
550- Response :: Authenticate ( auth) => NonErrorStartupResponse :: Authenticate ( auth) ,
551- Response :: Error ( Error { error, reason } ) => {
549+ ResponseWithDeserializedMetadata :: Ready => NonErrorStartupResponse :: Ready ,
550+ ResponseWithDeserializedMetadata :: Authenticate ( auth) => {
551+ NonErrorStartupResponse :: Authenticate ( auth)
552+ }
553+ ResponseWithDeserializedMetadata :: Error ( Error { error, reason } ) => {
552554 return Err ( err ( ConnectionSetupRequestErrorKind :: DbError ( error, reason) ) ) ;
553555 }
554556 _ => {
@@ -595,8 +597,8 @@ impl Connection {
595597 // Extract the supported options and tidy up the errors.
596598 let supported = match req_result {
597599 Ok ( r) => match r. response {
598- Response :: Supported ( supported) => supported,
599- Response :: Error ( Error { error, reason } ) => {
600+ ResponseWithDeserializedMetadata :: Supported ( supported) => supported,
601+ ResponseWithDeserializedMetadata :: Error ( Error { error, reason } ) => {
600602 return Err ( err ( ConnectionSetupRequestErrorKind :: DbError ( error, reason) ) ) ;
601603 }
602604 _ => {
@@ -648,10 +650,12 @@ impl Connection {
648650 . await ?;
649651
650652 match query_response. response {
651- Response :: Error ( error:: Error { error, reason } ) => {
653+ ResponseWithDeserializedMetadata :: Error ( error:: Error { error, reason } ) => {
652654 Err ( RequestAttemptError :: DbError ( error, reason) )
653655 }
654- Response :: Result ( result:: Result :: Prepared ( p) ) => {
656+ ResponseWithDeserializedMetadata :: Result (
657+ result:: ResultWithDeserializedMetadata :: Prepared ( p) ,
658+ ) => {
655659 let is_lwt = self
656660 . features
657661 . protocol_features
@@ -765,13 +769,13 @@ impl Connection {
765769 // Extract non-error response to AUTH_RESPONSE request and tidy up errors.
766770 let response = match req_result {
767771 Ok ( r) => match r. response {
768- Response :: AuthSuccess ( auth_success) => {
772+ ResponseWithDeserializedMetadata :: AuthSuccess ( auth_success) => {
769773 NonErrorAuthResponse :: AuthSuccess ( auth_success)
770774 }
771- Response :: AuthChallenge ( auth_challenge) => {
775+ ResponseWithDeserializedMetadata :: AuthChallenge ( auth_challenge) => {
772776 NonErrorAuthResponse :: AuthChallenge ( auth_challenge)
773777 }
774- Response :: Error ( Error { error, reason } ) => {
778+ ResponseWithDeserializedMetadata :: Error ( Error { error, reason } ) => {
775779 return Err ( err ( ConnectionSetupRequestErrorKind :: DbError ( error, reason) ) ) ;
776780 }
777781 _ => {
@@ -951,7 +955,7 @@ impl Connection {
951955 }
952956
953957 match & query_response. response {
954- Response :: Error ( frame:: response:: Error {
958+ ResponseWithDeserializedMetadata :: Error ( frame:: response:: Error {
955959 error : DbError :: Unprepared { statement_id } ,
956960 ..
957961 } ) => {
@@ -1067,7 +1071,7 @@ impl Connection {
10671071 . map_err ( RequestAttemptError :: from) ?;
10681072
10691073 return match query_response. response {
1070- Response :: Error ( err) => match err. error {
1074+ ResponseWithDeserializedMetadata :: Error ( err) => match err. error {
10711075 DbError :: Unprepared { statement_id } => {
10721076 debug ! (
10731077 "Connection::batch: got DbError::Unprepared - repreparing statement with id {:?}" ,
@@ -1088,7 +1092,7 @@ impl Connection {
10881092 }
10891093 _ => Err ( err. into ( ) ) ,
10901094 } ,
1091- Response :: Result ( _) => Ok ( query_response) ,
1095+ ResponseWithDeserializedMetadata :: Result ( _) => Ok ( query_response) ,
10921096 _ => Err ( RequestAttemptError :: UnexpectedResponse (
10931097 query_response. response . to_response_kind ( ) ,
10941098 ) ) ,
@@ -1164,7 +1168,9 @@ impl Connection {
11641168 query_response : QueryResponse ,
11651169 ) -> Result < ( ) , UseKeyspaceError > {
11661170 match query_response. response {
1167- Response :: Result ( result:: Result :: SetKeyspace ( set_keyspace) ) => {
1171+ ResponseWithDeserializedMetadata :: Result (
1172+ result:: ResultWithDeserializedMetadata :: SetKeyspace ( set_keyspace) ,
1173+ ) => {
11681174 if !set_keyspace
11691175 . keyspace_name
11701176 . eq_ignore_ascii_case ( keyspace_name. as_str ( ) )
@@ -1180,7 +1186,7 @@ impl Connection {
11801186
11811187 Ok ( ( ) )
11821188 }
1183- Response :: Error ( err) => Err ( UseKeyspaceError :: RequestError (
1189+ ResponseWithDeserializedMetadata :: Error ( err) => Err ( UseKeyspaceError :: RequestError (
11841190 RequestAttemptError :: DbError ( err. error , err. reason ) ,
11851191 ) ) ,
11861192 _ => Err ( UseKeyspaceError :: RequestError (
@@ -1204,8 +1210,8 @@ impl Connection {
12041210 // Extract the response and tidy up the errors.
12051211 match self . send_request ( & register_frame, true , false , None ) . await {
12061212 Ok ( r) => match r. response {
1207- Response :: Ready => Ok ( ( ) ) ,
1208- Response :: Error ( Error { error, reason } ) => {
1213+ ResponseWithDeserializedMetadata :: Ready => Ok ( ( ) ) ,
1214+ ResponseWithDeserializedMetadata :: Error ( Error { error, reason } ) => {
12091215 Err ( err ( ConnectionSetupRequestErrorKind :: DbError ( error, reason) ) )
12101216 }
12111217 _ => Err ( err ( ConnectionSetupRequestErrorKind :: UnexpectedResponse (
@@ -1294,7 +1300,13 @@ impl Connection {
12941300 task_response. opcode ,
12951301 body_with_ext. body ,
12961302 cached_metadata,
1297- ) ?;
1303+ ) ?
1304+ . deserialize_metadata ( )
1305+ . map_err ( |e| {
1306+ ResponseParseError :: CqlResponseParseError ( CqlResponseParseError :: CqlResultParseError (
1307+ e. into ( ) ,
1308+ ) )
1309+ } ) ?;
12981310
12991311 Ok ( QueryResponse {
13001312 response,
@@ -1727,7 +1739,7 @@ impl Connection {
17271739
17281740 let event = match Self :: parse_response ( task_response, compression, & features, None ) {
17291741 Ok ( r) => match r. response {
1730- Response :: Event ( event) => event,
1742+ ResponseWithDeserializedMetadata :: Event ( event) => event,
17311743 _ => {
17321744 error ! ( "Expected to receive Event response, got {:?}" , r. response) ;
17331745 return Err ( CqlEventHandlingError :: UnexpectedResponse (
0 commit comments