From 746a6e123e5ee87a3bc83d813ccd020f6f689e6a Mon Sep 17 00:00:00 2001 From: muzarski Date: Thu, 1 Feb 2024 17:30:26 +0100 Subject: [PATCH] prepared: update result metadata after reprepare --- scylla/src/statement/prepared_statement.rs | 4 ++++ scylla/src/transport/connection.rs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/scylla/src/statement/prepared_statement.rs b/scylla/src/statement/prepared_statement.rs index 0f0e91a49e..9b89be97a4 100644 --- a/scylla/src/statement/prepared_statement.rs +++ b/scylla/src/statement/prepared_statement.rs @@ -315,6 +315,10 @@ impl PreparedStatement { self.shared.result_metadata.load_full() } + pub(crate) fn set_result_metadata(&self, metadata: Arc) { + self.shared.result_metadata.store(metadata) + } + /// Get the name of the partitioner used for this statement. pub(crate) fn get_partitioner_name(&self) -> &PartitionerName { &self.partitioner_name diff --git a/scylla/src/transport/connection.rs b/scylla/src/transport/connection.rs index 1ad118d9c7..a77e636dbd 100644 --- a/scylla/src/transport/connection.rs +++ b/scylla/src/transport/connection.rs @@ -588,6 +588,8 @@ impl Connection { "Prepared statement Id changed, md5 sum should stay the same", )) } else { + // Update the result metadata. + previous_prepared.set_result_metadata(reprepared.get_result_metadata()); Ok(()) } } @@ -733,6 +735,15 @@ impl Connection { // Repreparation of a statement is needed self.reprepare(prepared_statement.get_statement(), prepared_statement) .await?; + + // Since we make use of `ArcSwap` for `ResultMetadata`, + // old `cached_metadata` variable points to old metadata before reprepare. + // We need to fetch updated metadata from the object. + let cached_metadata = self + .config + .skip_result_metadata + .then(|| prepared_statement.get_result_metadata()); + self.send_request( &execute_frame, true,