From ad8b0c12979f3b585702f956e16de6edc180357a Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Fri, 24 Dec 2021 12:31:28 +0100 Subject: [PATCH] result: add support for custom CQL types CQL protocol allows sending custom types identified by their string representation. One of the cases in which the trick is used is when Cassandra returns duration columns to a CQLv4 client, which is not supposed to know this type. WIP: the actual implementation will be done once #363 is merged. Refs #364 --- scylla/src/frame/response/result.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scylla/src/frame/response/result.rs b/scylla/src/frame/response/result.rs index 2af2607f8c..3e0a9917ff 100644 --- a/scylla/src/frame/response/result.rs +++ b/scylla/src/frame/response/result.rs @@ -41,6 +41,7 @@ pub struct TableSpec { #[derive(Debug, Clone)] pub enum ColumnType { + Custom(String), Ascii, Boolean, Blob, @@ -376,6 +377,10 @@ fn deser_type(buf: &mut &[u8]) -> StdResult { use ColumnType::*; let id = types::read_short(buf)?; Ok(match id { + 0x0000 => { + let type_str: String = types::read_string(buf)?.to_string(); + Custom(type_str) + } 0x0001 => Ascii, 0x0002 => BigInt, 0x0003 => Blob, @@ -534,6 +539,12 @@ fn deser_cql_value(typ: &ColumnType, buf: &mut &[u8]) -> StdResult { + return Err(ParseError::BadData(format!( + "Support for custom types is not yet implemented: {}", + type_str + ))); + } Ascii => { if !buf.is_ascii() { return Err(ParseError::BadData("String is not ascii!".to_string()));