From 6844bc9636a1814eb8f2dae358228db32df9c207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Mon, 2 Dec 2024 14:14:37 +0100 Subject: [PATCH] frame/result: allow differing TableSpecs As noted in #1134, when preparing batches containing requests to multiple to different tables, the PreparedMetadata received upon preparation contains differing TableSpecs (i.e., TableSpecs with more than table mentioned). This fails the check that we introduced with ResultMetadata in mind: we've been assuming that all TableSpecs are the same, because ScyllaDB/ Cassandra has no support for JOINs. Not to fail preparation of cross-table batches, the check is disabled. We decided that we should not rely on an assumption that is not guaranteed by the CQL protocol. --- scylla-cql/src/frame/frame_errors.rs | 3 --- scylla-cql/src/frame/response/result.rs | 17 +---------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/scylla-cql/src/frame/frame_errors.rs b/scylla-cql/src/frame/frame_errors.rs index 1f12a6008e..3acc1f84dd 100644 --- a/scylla-cql/src/frame/frame_errors.rs +++ b/scylla-cql/src/frame/frame_errors.rs @@ -11,7 +11,6 @@ pub use super::request::{ startup::StartupSerializationError, }; -use super::response::result::TableSpec; use super::response::CqlResponseKind; use super::TryFromPrimitiveError; use thiserror::Error; @@ -425,8 +424,6 @@ pub struct ColumnSpecParseError { pub enum ColumnSpecParseErrorKind { #[error("Invalid table spec: {0}")] TableSpecParseError(#[from] TableSpecParseError), - #[error("Table spec differs across columns - got specs: {0:?} and {1:?}")] - TableSpecDiffersAcrossColumns(TableSpec<'static>, TableSpec<'static>), #[error("Malformed column name: {0}")] ColumnNameParseError(#[from] LowLevelDeserializationError), #[error("Invalid column type: {0}")] diff --git a/scylla-cql/src/frame/response/result.rs b/scylla-cql/src/frame/response/result.rs index 2c5a76e29c..e1cc13f709 100644 --- a/scylla-cql/src/frame/response/result.rs +++ b/scylla-cql/src/frame/response/result.rs @@ -1004,22 +1004,7 @@ fn deser_table_spec_for_col_spec<'frame>( let table_spec = deser_table_spec(buf).map_err(|err| mk_col_spec_parse_error(col_idx, err))?; - if let Some(ref known_spec) = known_table_spec { - // We assume that for each column, table spec is the same. - // As this is not guaranteed by the CQL protocol specification but only by how - // Cassandra and ScyllaDB work (no support for joins), we perform a sanity check here. - if known_spec.table_name != table_spec.table_name - || known_spec.ks_name != table_spec.ks_name - { - return Err(mk_col_spec_parse_error( - col_idx, - ColumnSpecParseErrorKind::TableSpecDiffersAcrossColumns( - known_spec.clone().into_owned(), - table_spec.into_owned(), - ), - )); - } - } else { + if known_table_spec.is_none() { // Once we have read the first column spec, we save its table spec // in order to verify its equality with other columns'. *known_table_spec = Some(table_spec.clone());