Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
add savepoint and release stmt categories
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Oct 5, 2023
1 parent 7b5b4f2 commit b5850bb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sqld/src/query_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub enum StmtKind {
TxnEnd,
Read,
Write,
Savepoint,
Release,
Other,
}

Expand All @@ -51,7 +53,7 @@ impl StmtKind {
Cmd::Explain(_) => Some(Self::Other),
Cmd::ExplainQueryPlan(_) => Some(Self::Other),
Cmd::Stmt(Stmt::Begin { .. }) => Some(Self::TxnBegin),
Cmd::Stmt(Stmt::Commit { .. } | Stmt::Rollback { .. }) => Some(Self::TxnEnd),
Cmd::Stmt(Stmt::Commit { .. } | Stmt::Rollback { savepoint_name: None, .. }) => Some(Self::TxnEnd),
Cmd::Stmt(
Stmt::CreateVirtualTable { tbl_name, .. }
| Stmt::CreateTable {
Expand Down Expand Up @@ -99,6 +101,8 @@ impl StmtKind {
temporary: false, ..
}) => Some(Self::Write),
Cmd::Stmt(Stmt::DropView { .. }) => Some(Self::Write),
Cmd::Stmt(Stmt::Savepoint(_)) => Some(Self::Savepoint),
Cmd::Stmt(Stmt::Release(_)) | Cmd::Stmt(Stmt::Rollback { savepoint_name: Some(_) , ..}) => Some(Self::Release),
_ => None,
}
}
Expand Down Expand Up @@ -187,7 +191,7 @@ impl State {
(State::Txn, StmtKind::TxnEnd) => State::Init,
(state, StmtKind::Other | StmtKind::Write | StmtKind::Read) => state,
(State::Invalid, _) => State::Invalid,
(State::Init, StmtKind::TxnBegin) => State::Txn,
(State::Init, StmtKind::TxnBegin | ) => State::Txn,
};
}

Expand Down

0 comments on commit b5850bb

Please sign in to comment.