Skip to content

Commit 2cf503b

Browse files
psarnapiodul
authored andcommitted
result: add "Custom" metadata type
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. Refs #364 Closes #368
1 parent 19bcd6d commit 2cf503b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scylla/src/frame/response/result.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub struct TableSpec {
4141

4242
#[derive(Debug, Clone)]
4343
pub enum ColumnType {
44+
Custom(String),
4445
Ascii,
4546
Boolean,
4647
Blob,
@@ -376,6 +377,10 @@ fn deser_type(buf: &mut &[u8]) -> StdResult<ColumnType, ParseError> {
376377
use ColumnType::*;
377378
let id = types::read_short(buf)?;
378379
Ok(match id {
380+
0x0000 => {
381+
let type_str: String = types::read_string(buf)?.to_string();
382+
Custom(type_str)
383+
}
379384
0x0001 => Ascii,
380385
0x0002 => BigInt,
381386
0x0003 => Blob,
@@ -534,6 +539,12 @@ fn deser_cql_value(typ: &ColumnType, buf: &mut &[u8]) -> StdResult<CqlValue, Par
534539
}
535540

536541
Ok(match typ {
542+
Custom(type_str) => {
543+
return Err(ParseError::BadData(format!(
544+
"Support for custom types is not yet implemented: {}",
545+
type_str
546+
)));
547+
}
537548
Ascii => {
538549
if !buf.is_ascii() {
539550
return Err(ParseError::BadData("String is not ascii!".to_string()));

0 commit comments

Comments
 (0)