From 4798ca334bb8788c79e073f408cbb61b28665bc3 Mon Sep 17 00:00:00 2001 From: muzarski Date: Fri, 19 Apr 2024 09:49:45 +0200 Subject: [PATCH] prepared: docs mention about metadata immutability Added docstring mention about metadata immutability and when not to enable `cached_result_metadata` optimisation on the statement. --- scylla/src/statement/prepared_statement.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scylla/src/statement/prepared_statement.rs b/scylla/src/statement/prepared_statement.rs index bc0cc1df8f..946603355e 100644 --- a/scylla/src/statement/prepared_statement.rs +++ b/scylla/src/statement/prepared_statement.rs @@ -283,6 +283,17 @@ impl PreparedStatement { /// after statement preparation and will use it /// to deserialize the results of statement execution. /// + /// NOTICE: Users should NOT alter the schema after enablind + /// this optimisation on the statement. + /// To be more precise: + /// they should not alter the tables and UDTs that are used in the given statement. + /// The reason for this is that the decision was made to keep client-side metadata immutable, + /// and so, it is not updated during statement repreparation. + /// Altering the schema, and then, executing the statement with optimisation enabled may lead + /// to runtime errors. In the worst case, it could lead to + /// some data being deserialized to wrong Rust type contained + /// in outdated metadata. + /// /// This option is false by default. pub fn set_use_cached_result_metadata(&mut self, use_cached_metadata: bool) { self.config.skip_result_metadata = use_cached_metadata;