Skip to content

Commit

Permalink
frame/result: allow differing TableSpecs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wprzytula committed Dec 4, 2024
1 parent 49c342e commit 3636077
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
3 changes: 0 additions & 3 deletions scylla-cql/src/frame/frame_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}")]
Expand Down
17 changes: 1 addition & 16 deletions scylla-cql/src/frame/response/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 3636077

Please sign in to comment.