Skip to content

Commit

Permalink
result: add support for custom CQL types
Browse files Browse the repository at this point in the history
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
  • Loading branch information
psarna committed Dec 24, 2021
1 parent 51e0882 commit 4398cd3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scylla/src/frame/response/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct TableSpec {

#[derive(Debug, Clone)]
enum ColumnType {
Custom(String),
Ascii,
Boolean,
Blob,
Expand Down Expand Up @@ -355,6 +356,10 @@ fn deser_type(buf: &mut &[u8]) -> StdResult<ColumnType, ParseError> {
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,
Expand Down Expand Up @@ -513,6 +518,12 @@ fn deser_cql_value(typ: &ColumnType, buf: &mut &[u8]) -> StdResult<CqlValue, Par
}

Ok(match typ {
Custom(type_str) => {
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()));
Expand Down

0 comments on commit 4398cd3

Please sign in to comment.