From 8120d2ffe9064312add8516889410dc1b1d59987 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/transport/iterator.rs | 2 +- scylla/src/transport/query_result.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scylla-cql/src/frame/response/result.rs b/scylla-cql/src/frame/response/result.rs index a3cab27a5..71d91db9a 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/transport/iterator.rs b/scylla/src/transport/iterator.rs index 4457e47fd..11d8ec8cb 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() } diff --git a/scylla/src/transport/query_result.rs b/scylla/src/transport/query_result.rs index 0750624c9..b60485afb 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()