Skip to content

Commit

Permalink
metadata: store CassDataType behind an Arc
Browse files Browse the repository at this point in the history
Again, if someone called `cass_data_type_new_from_existing` with
a data type obtained from `cass_column_meta_data_type`, it would
not be a pointer from an Arc allocation.
  • Loading branch information
muzarski committed Dec 2, 2024
1 parent 196740f commit fbefc08
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scylla-rust-wrapper/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl RefFFI for CassMaterializedViewMeta {}

pub struct CassColumnMeta {
pub name: String,
pub column_type: CassDataType,
pub column_type: Arc<CassDataType>,
pub column_kind: CassColumnType,
}

Expand All @@ -71,11 +71,11 @@ pub unsafe fn create_table_metadata(
.for_each(|(column_name, column_metadata)| {
let cass_column_meta = CassColumnMeta {
name: column_name.clone(),
column_type: get_column_type_from_cql_type(
column_type: Arc::new(get_column_type_from_cql_type(
&column_metadata.type_,
user_defined_types,
keyspace_name,
),
)),
column_kind: match column_metadata.kind {
ColumnKind::Regular => CassColumnType::CASS_COLUMN_TYPE_REGULAR,
ColumnKind::Static => CassColumnType::CASS_COLUMN_TYPE_STATIC,
Expand Down Expand Up @@ -305,7 +305,7 @@ pub unsafe extern "C" fn cass_column_meta_data_type(
column_meta: *const CassColumnMeta,
) -> *const CassDataType {
let column_meta = RefFFI::as_ref(column_meta);
&column_meta.column_type as *const CassDataType
ArcFFI::as_ptr(&column_meta.column_type)
}

#[no_mangle]
Expand Down

0 comments on commit fbefc08

Please sign in to comment.