-
Notifications
You must be signed in to change notification settings - Fork 214
/
alter_table.rs
68 lines (54 loc) · 1.77 KB
/
alter_table.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use {
crate::{
ast::ColumnDef,
result::{Error, Result},
},
async_trait::async_trait,
serde::Serialize,
std::fmt::Debug,
thiserror::Error,
};
#[derive(Error, Serialize, Debug, PartialEq, Eq)]
pub enum AlterTableError {
#[error("Table not found: {0}")]
TableNotFound(String),
#[error("Renaming column not found")]
RenamingColumnNotFound,
#[error("Default value is required: {0:#?}")]
DefaultValueRequired(ColumnDef),
#[error("Already existing column: {0}")]
AlreadyExistingColumn(String),
#[error("Dropping column not found: {0}")]
DroppingColumnNotFound(String),
#[error("Schemaless table does not support ALTER TABLE: {0}")]
SchemalessTableFound(String),
}
#[async_trait(?Send)]
pub trait AlterTable {
async fn rename_schema(&mut self, _table_name: &str, _new_table_name: &str) -> Result<()> {
let msg = "[Storage] AlterTable::rename_schema is not supported".to_owned();
Err(Error::StorageMsg(msg))
}
async fn rename_column(
&mut self,
_table_name: &str,
_old_column_name: &str,
_new_column_name: &str,
) -> Result<()> {
let msg = "[Storage] AlterTable::rename_column is not supported".to_owned();
Err(Error::StorageMsg(msg))
}
async fn add_column(&mut self, _table_name: &str, _column_def: &ColumnDef) -> Result<()> {
let msg = "[Storage] AlterTable::add_column is not supported".to_owned();
Err(Error::StorageMsg(msg))
}
async fn drop_column(
&mut self,
_table_name: &str,
_column_name: &str,
_if_exists: bool,
) -> Result<()> {
let msg = "[Storage] AlterTable::drop_column is not supported".to_owned();
Err(Error::StorageMsg(msg))
}
}