Skip to content

Commit 534e752

Browse files
committed
Introduce new getter for prepared result col specs
Current getter (`get_result_set_col_specs`) always returns columns based on initial result metadata (which can be stale), and this unfortunately can't be changed due to backwards compatibility. New getter is introduced: `get_current_result_set_col_specs` which always uses latest metadata. The only caller of old getter (some integration test) is adjusted.
1 parent 6eba649 commit 534e752

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

scylla/src/statement/prepared.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,13 @@ impl PreparedStatement {
541541
ColumnSpecs::new(self.shared.initial_result_metadata.col_specs())
542542
}
543543

544+
/// Access column specifications of the result set returned after the execution of this statement
545+
pub fn get_current_result_set_col_specs(&self) -> ColumnSpecsGuard {
546+
ColumnSpecsGuard {
547+
result: self.shared.current_result_metadata.load(),
548+
}
549+
}
550+
544551
/// Get the name of the partitioner used for this statement.
545552
pub fn get_partitioner_name(&self) -> &PartitionerName {
546553
&self.partitioner_name

scylla/tests/integration/statements/prepared.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ async fn test_prepared_statement_col_specs() {
474474
];
475475
assert_eq!(variable_col_specs, expected_variable_col_specs);
476476

477-
let result_set_col_specs = prepared.get_result_set_col_specs().as_slice();
477+
let col_specs_guard = prepared.get_current_result_set_col_specs();
478+
let result_set_col_specs = col_specs_guard.get().as_slice();
478479
let expected_result_set_col_specs = &[
479480
spec("k1", ColumnType::Native(NativeType::Int)),
480481
spec("k2", ColumnType::Native(NativeType::Varint)),

0 commit comments

Comments
 (0)