From 8dd149806aa8b325961f8b3a2492cc24582465c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Mon, 28 Oct 2024 15:15:16 +0100 Subject: [PATCH] result: fix wrong implied lifetime in col_specs() As `ColumnSpec` is now parametrised by a lifetime, methods that return it implicitly bound its lifetime with lifetime of `&self`. This bug would lead to inefficiencies. As a fix, an explicit lifetime is added in every method returning `ColumnSpec`. --- scylla-cql/src/frame/response/result.rs | 2 +- scylla/src/statement/prepared_statement.rs | 4 ++-- scylla/src/transport/iterator.rs | 4 ++-- scylla/src/transport/query_result.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scylla-cql/src/frame/response/result.rs b/scylla-cql/src/frame/response/result.rs index a3cab27a54..71d91db9a4 100644 --- a/scylla-cql/src/frame/response/result.rs +++ b/scylla-cql/src/frame/response/result.rs @@ -549,7 +549,7 @@ impl<'a> ResultMetadata<'a> { } #[inline] - pub fn col_specs(&self) -> &[ColumnSpec] { + pub fn col_specs(&self) -> &[ColumnSpec<'a>] { &self.col_specs } } diff --git a/scylla/src/statement/prepared_statement.rs b/scylla/src/statement/prepared_statement.rs index dd26c8d2e3..8ecb86a4f9 100644 --- a/scylla/src/statement/prepared_statement.rs +++ b/scylla/src/statement/prepared_statement.rs @@ -407,7 +407,7 @@ impl PreparedStatement { } /// Access column specifications of the bind variables of this statement - pub fn get_variable_col_specs(&self) -> &[ColumnSpec] { + pub fn get_variable_col_specs(&self) -> &[ColumnSpec<'static>] { &self.shared.metadata.col_specs } @@ -422,7 +422,7 @@ impl PreparedStatement { } /// Access column specifications of the result set returned after the execution of this statement - pub fn get_result_set_col_specs(&self) -> &[ColumnSpec] { + pub fn get_result_set_col_specs(&self) -> &[ColumnSpec<'static>] { self.shared.result_metadata.col_specs() } diff --git a/scylla/src/transport/iterator.rs b/scylla/src/transport/iterator.rs index 4457e47fdb..7ae248d80f 100644 --- a/scylla/src/transport/iterator.rs +++ b/scylla/src/transport/iterator.rs @@ -396,7 +396,7 @@ impl RowIterator { } /// Returns specification of row columns - pub fn get_column_specs(&self) -> &[ColumnSpec] { + pub fn get_column_specs(&self) -> &[ColumnSpec<'static>] { self.current_page.metadata.col_specs() } @@ -904,7 +904,7 @@ impl TypedRowIterator { } /// Returns specification of row columns - pub fn get_column_specs(&self) -> &[ColumnSpec] { + pub fn get_column_specs(&self) -> &[ColumnSpec<'static>] { self.row_iterator.get_column_specs() } } diff --git a/scylla/src/transport/query_result.rs b/scylla/src/transport/query_result.rs index 0750624c93..b60485afb1 100644 --- a/scylla/src/transport/query_result.rs +++ b/scylla/src/transport/query_result.rs @@ -138,7 +138,7 @@ impl QueryResult { /// Returns column specifications. #[inline] - pub fn col_specs(&self) -> &[ColumnSpec] { + pub fn col_specs(&self) -> &[ColumnSpec<'static>] { self.metadata .as_ref() .map(|metadata| metadata.col_specs()) @@ -147,7 +147,7 @@ impl QueryResult { /// Returns a column specification for a column with given name, or None if not found #[inline] - pub fn get_column_spec<'a>(&'a self, name: &str) -> Option<(usize, &'a ColumnSpec)> { + pub fn get_column_spec<'a>(&'a self, name: &str) -> Option<(usize, &'a ColumnSpec<'static>)> { self.col_specs() .iter() .enumerate()