Skip to content

Commit

Permalink
Feat(parser): add create tablespace sql parser.
Browse files Browse the repository at this point in the history
Signed-off-by: Zonglei Dong <[email protected]>
  • Loading branch information
dongzl committed Aug 12, 2022
1 parent b58b62d commit cb18739
Show file tree
Hide file tree
Showing 2 changed files with 507 additions and 154 deletions.
100 changes: 94 additions & 6 deletions pisa-proxy/parser/mysql/src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pub enum Create {
CreateDatabase(Box<CreateDatabase>),
CreateViewOrTriggerOrSpOrEvent(Box<ViewOrTriggerOrSpOrEvent>),
CreateLogFileGroup(Box<CreateLogFileGroup>),
CreateUser(Box<CreateUser>)
CreateUser(Box<CreateUser>),
CreateTablespace(Box<CreateTablespace>),
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -344,11 +345,13 @@ pub struct UndoFile {

#[derive(Debug, Clone)]
pub enum LogFileGroupOption {
SizeOption(SizeOption),
NodeGroupOption(NodeGroupOption),
CommentOption(CommentOption),
EngineOption(EngineOption),
WaitOption(WaitOption),
InitialSize(SizeOption),
UndoBufferSize(SizeOption),
RedoBufferSize(SizeOption),
NodeGroup(NodeGroupOption),
Comment(CommentOption),
Engine(EngineOption),
Wait(WaitOption),
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -385,3 +388,88 @@ pub enum WaitOption {
Wait,
NoWait,
}

#[derive(Debug, Clone)]
pub struct CreateTablespace {
pub span: Span,
pub tablespace_name: String,
pub opt_ts_datafile: Option<AddTsDataFile>,
pub opt_logfile_group: Option<LogFileGroup>,
pub opt_tablespace_options: Option<Vec<TablespaceOption>>,
}

#[derive(Debug, Clone)]
pub struct AddTsDataFile {
pub span: Span,
pub ts_datafile: TsDataFile,
}

#[derive(Debug, Clone)]
pub struct TsDataFile {
pub span: Span,
pub file_name: String,
}

#[derive(Debug, Clone)]
pub struct LogFileGroup {
pub span: Span,
pub logfile_group: String,
}

#[derive(Debug, Clone)]
pub enum TablespaceOption {
InitialSize(SizeOption),
AutoextendSize(SizeOption),
MaxSize(SizeOption),
ExtentSize(SizeOption),
NodeGroup(NodeGroupOption),
Engine(EngineOption),
Wait(WaitOption),
Comment(CommentOption),
FileBlockSize(SizeOption),
Encryption(EncryptionOption),
EngineAttribute(EngineAttributeOption),
}

#[derive(Debug, Clone)]
pub struct EncryptionOption {
pub span: Span,
pub is_equal: bool,
pub encryption: String,
}

#[derive(Debug, Clone)]
pub struct EngineAttributeOption {
pub span: Span,
pub is_equal: bool,
pub attribute: String,
}

#[derive(Debug, Clone)]
pub enum AlterTablespaceOption {
InitialSize(SizeOption),
AutoextendSize(SizeOption),
MaxSize(SizeOption),
Engine(EngineOption),
Wait(WaitOption),
Encryption(EncryptionOption),
EngineAttribute(EngineAttributeOption),
}

#[derive(Debug, Clone)]
pub enum UndoTablespaceOption {
Engine(EngineOption),
}

#[derive(Debug, Clone)]
pub enum AlterLogFileGroupOption {
InitialSize(SizeOption),
Engine(EngineOption),
Wait(WaitOption),
}

#[derive(Debug, Clone)]
pub enum UndoTablespaceState {
Active,
Inactive,
}
Loading

0 comments on commit cb18739

Please sign in to comment.