fix: expose unsupported datatype error on mysql protocol (#3121)

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2024-01-09 17:13:53 +08:00
committed by GitHub
parent c4582c05cc
commit 7d0d2163d2
3 changed files with 14 additions and 4 deletions

View File

@@ -38,6 +38,12 @@ pub enum Error {
#[snafu(display("Internal error: {}", err_msg))]
Internal { err_msg: String },
#[snafu(display("Unsupported data type: {}, reason: {}", data_type, reason))]
UnsupportedDataType {
data_type: ConcreteDataType,
reason: String,
},
#[snafu(display("Internal IO error"))]
InternalIo {
#[snafu(source)]
@@ -446,6 +452,8 @@ impl ErrorExt for Error {
| GrpcReflectionService { .. }
| BuildHttpResponse { .. } => StatusCode::Internal,
UnsupportedDataType { .. } => StatusCode::Unsupported,
#[cfg(not(windows))]
UpdateJemallocMetrics { .. } => StatusCode::Internal,

View File

@@ -265,8 +265,9 @@ pub(crate) fn create_mysql_column(
ConcreteDataType::Interval(_) => Ok(ColumnType::MYSQL_TYPE_VARCHAR),
ConcreteDataType::Duration(_) => Ok(ColumnType::MYSQL_TYPE_TIME),
ConcreteDataType::Decimal128(_) => Ok(ColumnType::MYSQL_TYPE_DECIMAL),
_ => error::InternalSnafu {
err_msg: format!("not implemented for column datatype {:?}", data_type),
_ => error::UnsupportedDataTypeSnafu {
data_type,
reason: "not implemented",
}
.fail(),
};

View File

@@ -135,8 +135,9 @@ pub(super) fn type_gt_to_pg(origin: &ConcreteDataType) -> Result<Type> {
&ConcreteDataType::Decimal128(_) => Ok(Type::NUMERIC),
&ConcreteDataType::Duration(_)
| &ConcreteDataType::List(_)
| &ConcreteDataType::Dictionary(_) => error::InternalSnafu {
err_msg: format!("not implemented for column datatype {origin:?}"),
| &ConcreteDataType::Dictionary(_) => error::UnsupportedDataTypeSnafu {
data_type: origin,
reason: "not implemented",
}
.fail(),
}