Skip to content

Commit

Permalink
Add snapshot commands (#2113)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Only commands.

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Signed-off-by: Jin Hai <[email protected]>
  • Loading branch information
JinHai-CN authored Oct 29, 2024
1 parent 372e6b7 commit 2f2d0b0
Show file tree
Hide file tree
Showing 10 changed files with 2,695 additions and 2,457 deletions.
60 changes: 60 additions & 0 deletions src/admin/admin_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ QueryResult AdminExecutor::Execute(QueryContext *query_context, const AdminState
case AdminStmtType::kSetRole: {
return SetRole(query_context, admin_statement);
}
case AdminStmtType::kCreateSnapshot: {
return CreateSnapshot(query_context, admin_statement);
}
case AdminStmtType::kListSnapshots: {
return ListSnapshots(query_context, admin_statement);
}
case AdminStmtType::kShowSnapshot: {
return ShowSnapshot(query_context, admin_statement);
}
case AdminStmtType::kDeleteSnapshot: {
return DeleteSnapshot(query_context, admin_statement);
}
case AdminStmtType::kExportSnapshot: {
return ExportSnapshot(query_context, admin_statement);
}
case AdminStmtType::kRecoverFromSnapshot: {
return RecoverFromSnapshot(query_context, admin_statement);
}
case AdminStmtType::kInvalid: {
QueryResult query_result;
query_result.result_table_ = nullptr;
Expand Down Expand Up @@ -4126,4 +4144,46 @@ QueryResult AdminExecutor::SetRole(QueryContext *query_context, const AdminState
return query_result;
}

QueryResult AdminExecutor::CreateSnapshot(QueryContext* query_context, const AdminStatement* admin_statement) {
QueryResult query_result;
query_result.result_table_ = nullptr;
query_result.status_ = Status::NotSupport(fmt::format("Not support: create snapshot"));
return query_result;
}

QueryResult AdminExecutor::ListSnapshots(QueryContext* query_context, const AdminStatement* admin_statement) {
QueryResult query_result;
query_result.result_table_ = nullptr;
query_result.status_ = Status::NotSupport(fmt::format("Not support: list snapshots"));
return query_result;
}

QueryResult AdminExecutor::ShowSnapshot(QueryContext* query_context, const AdminStatement* admin_statement) {
QueryResult query_result;
query_result.result_table_ = nullptr;
query_result.status_ = Status::NotSupport(fmt::format("Not support: show snapshot"));
return query_result;
}

QueryResult AdminExecutor::DeleteSnapshot(QueryContext* query_context, const AdminStatement* admin_statement) {
QueryResult query_result;
query_result.result_table_ = nullptr;
query_result.status_ = Status::NotSupport(fmt::format("Not support: delete snapshot"));
return query_result;
}

QueryResult AdminExecutor::ExportSnapshot(QueryContext* query_context, const AdminStatement* admin_statement) {
QueryResult query_result;
query_result.result_table_ = nullptr;
query_result.status_ = Status::NotSupport(fmt::format("Not support: export snapshot"));
return query_result;
}

QueryResult AdminExecutor::RecoverFromSnapshot(QueryContext* query_context, const AdminStatement* admin_statement) {
QueryResult query_result;
query_result.result_table_ = nullptr;
query_result.status_ = Status::NotSupport(fmt::format("Not support: recover from snapshot"));
return query_result;
}

} // namespace infinity
6 changes: 6 additions & 0 deletions src/admin/admin_executor.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ private:
static QueryResult RemoveNode(QueryContext* query_context, const AdminStatement* admin_statement);
static QueryResult ShowCurrentNode(QueryContext* query_context, const AdminStatement* admin_statement);
static QueryResult SetRole(QueryContext* query_context, const AdminStatement* admin_statement);
static QueryResult CreateSnapshot(QueryContext* query_context, const AdminStatement* admin_statement);
static QueryResult ListSnapshots(QueryContext* query_context, const AdminStatement* admin_statement);
static QueryResult ShowSnapshot(QueryContext* query_context, const AdminStatement* admin_statement);
static QueryResult DeleteSnapshot(QueryContext* query_context, const AdminStatement* admin_statement);
static QueryResult ExportSnapshot(QueryContext* query_context, const AdminStatement* admin_statement);
static QueryResult RecoverFromSnapshot(QueryContext* query_context, const AdminStatement* admin_statement);

static Vector<SharedPtr<WalEntry>> GetAllCheckpointEntries(QueryContext* query_context, const AdminStatement* admin_statement);
static Tuple<UniquePtr<Catalog>, Status> LoadCatalogFiles(QueryContext* query_context, const AdminStatement* admin_statement, Vector<SharedPtr<WalEntry>>& ckp_entries);
Expand Down
1,354 changes: 690 additions & 664 deletions src/parser/lexer.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/parser/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ extern int yylex \
#undef yyTABLES_NAME
#endif

#line 266 "lexer.l"
#line 269 "lexer.l"


#line 853 "lexer.h"
Expand Down
3 changes: 3 additions & 0 deletions src/parser/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ PROPERTIES { return PROPERTIES; }
QUERIES { return QUERIES; }
QUERY { return QUERY; }
REAL { return REAL; }
RECOVER { return RECOVER; }
RENAME { return RENAME; }
REMOVE { return REMOVE; }
RIGHT { return RIGHT; }
Expand All @@ -181,6 +182,8 @@ SEGMENT { return SEGMENT; }
SEGMENTS { return SEGMENTS; }
SHOW { return SHOW; }
SMALLINT { return SMALLINT; }
SNAPSHOT { return SNAPSHOT; }
SNAPSHOTS { return SNAPSHOTS; }
SPARSE { return SPARSE; }
STANDALONE { return STANDALONE; }
TABLE { return TABLE; }
Expand Down
Loading

0 comments on commit 2f2d0b0

Please sign in to comment.