feat!: impl admin command (#4600)

* feat: impl admin statement parser

* feat: introduce AsyncFunction and implements it for admin functions

* feat: execute admin functions

* fix: license header

* fix: panic in test

* chore: fixed by code review
This commit is contained in:
dennis zhuang
2024-08-26 15:53:40 +08:00
committed by GitHub
parent da337a9635
commit 63f2463273
39 changed files with 777 additions and 322 deletions

View File

@@ -99,7 +99,7 @@ pub const GT_FUZZ_CLUSTER_NAME: &str = "GT_FUZZ_CLUSTER_NAME";
/// Flushes memtable to SST file.
pub async fn flush_memtable(e: &Pool<MySql>, table_name: &Ident) -> Result<()> {
let sql = format!("SELECT flush_table(\"{}\")", table_name);
let sql = format!("admin flush_table(\"{}\")", table_name);
let result = sqlx::query(&sql)
.execute(e)
.await
@@ -111,7 +111,7 @@ pub async fn flush_memtable(e: &Pool<MySql>, table_name: &Ident) -> Result<()> {
/// Triggers a compaction for table
pub async fn compact_table(e: &Pool<MySql>, table_name: &Ident) -> Result<()> {
let sql = format!("SELECT compact_table(\"{}\")", table_name);
let sql = format!("admin compact_table(\"{}\")", table_name);
let result = sqlx::query(&sql)
.execute(e)
.await

View File

@@ -35,9 +35,8 @@ pub async fn migrate_region(
to_peer_id: u64,
timeout_secs: u64,
) -> String {
let sql = format!(
"select migrate_region({region_id}, {from_peer_id}, {to_peer_id}, {timeout_secs}) as output;"
);
let sql =
format!("admin migrate_region({region_id}, {from_peer_id}, {to_peer_id}, {timeout_secs});");
let result = sqlx::query(&sql)
.fetch_one(e)
.await

View File

@@ -23,7 +23,7 @@ use crate::error;
/// Fetches the state of a procedure.
pub async fn procedure_state(e: &Pool<MySql>, procedure_id: &str) -> String {
let sql = format!("select procedure_state(\"{procedure_id}\");");
let sql = format!("admin procedure_state(\"{procedure_id}\");");
let result = sqlx::query(&sql)
.fetch_one(e)
.await