mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-22 22:20:02 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user