From 33f8e02ed5cd54b762c1e55010210d3429fecd54 Mon Sep 17 00:00:00 2001 From: DanCodedThis Date: Mon, 24 Nov 2025 21:42:48 +0200 Subject: [PATCH 1/2] Add support for read only mode show statements --- crates/executor/src/query.rs | 21 ++++++++++++- crates/executor/src/tests/service.rs | 46 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/crates/executor/src/query.rs b/crates/executor/src/query.rs index b64d6da3..aee5336a 100644 --- a/crates/executor/src/query.rs +++ b/crates/executor/src/query.rs @@ -288,6 +288,15 @@ impl UserQuery { Statement::Use(entity) => { return self.execute_use_statement(entity).await; } + Statement::ShowDatabases { .. } + | Statement::ShowSchemas { .. } + | Statement::ShowTables { .. } + | Statement::ShowColumns { .. } + | Statement::ShowViews { .. } + | Statement::ShowFunctions { .. } + | Statement::ShowObjects { .. } + | Statement::ShowVariables { .. } + | Statement::ShowVariable { .. } => return Box::pin(self.show_query(*s)).await, other => { return ex_error::NotSupportedStatementInReadOnlyModeSnafu { statement: other.to_string(), @@ -297,7 +306,17 @@ impl UserQuery { }, DFStatement::Explain(explain) => match *explain.statement { DFStatement::Statement(s) => match *s { - Statement::Query(..) | Statement::Use(..) => { + Statement::Query(..) + | Statement::Use(..) + | Statement::ShowDatabases { .. } + | Statement::ShowSchemas { .. } + | Statement::ShowTables { .. } + | Statement::ShowColumns { .. } + | Statement::ShowViews { .. } + | Statement::ShowFunctions { .. } + | Statement::ShowObjects { .. } + | Statement::ShowVariables { .. } + | Statement::ShowVariable { .. } => { return self.execute_sql(&self.query).await; } other => { diff --git a/crates/executor/src/tests/service.rs b/crates/executor/src/tests/service.rs index 7658ca15..5e7397e4 100644 --- a/crates/executor/src/tests/service.rs +++ b/crates/executor/src/tests/service.rs @@ -562,4 +562,50 @@ async fn test_execute_read_only_mode() { ) .await .expect("Failed to execute query in read only mode"); + + execution_svc + .query("test_session_id", "SHOW TABLES;", QueryContext::default()) + .await + .expect("Failed to execute query in read only mode"); + + execution_svc + .query( + "test_session_id", + "EXPLAIN SHOW TABLES;", + QueryContext::default(), + ) + .await + .expect("Failed to execute query in read only mode"); + + execution_svc + .query("test_session_id", "SHOW SCHEMAS;", QueryContext::default()) + .await + .expect("Failed to execute query in read only mode"); + + execution_svc + .query( + "test_session_id", + "EXPLAIN SHOW SCHEMAS;", + QueryContext::default(), + ) + .await + .expect("Failed to execute query in read only mode"); + + execution_svc + .query( + "test_session_id", + "SHOW DATABASES;", + QueryContext::default(), + ) + .await + .expect("Failed to execute query in read only mode"); + + execution_svc + .query( + "test_session_id", + "EXPLAIN SHOW DATABASES;", + QueryContext::default(), + ) + .await + .expect("Failed to execute query in read only mode"); } From 3a0f3d8717323b397e904e35183b8ad69a26cec8 Mon Sep 17 00:00:00 2001 From: DanCodedThis Date: Mon, 24 Nov 2025 21:51:24 +0200 Subject: [PATCH 2/2] Add support for read only mode show statements test fix --- crates/executor/src/tests/service.rs | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/crates/executor/src/tests/service.rs b/crates/executor/src/tests/service.rs index 5e7397e4..41d7004c 100644 --- a/crates/executor/src/tests/service.rs +++ b/crates/executor/src/tests/service.rs @@ -568,29 +568,11 @@ async fn test_execute_read_only_mode() { .await .expect("Failed to execute query in read only mode"); - execution_svc - .query( - "test_session_id", - "EXPLAIN SHOW TABLES;", - QueryContext::default(), - ) - .await - .expect("Failed to execute query in read only mode"); - execution_svc .query("test_session_id", "SHOW SCHEMAS;", QueryContext::default()) .await .expect("Failed to execute query in read only mode"); - execution_svc - .query( - "test_session_id", - "EXPLAIN SHOW SCHEMAS;", - QueryContext::default(), - ) - .await - .expect("Failed to execute query in read only mode"); - execution_svc .query( "test_session_id", @@ -599,13 +581,4 @@ async fn test_execute_read_only_mode() { ) .await .expect("Failed to execute query in read only mode"); - - execution_svc - .query( - "test_session_id", - "EXPLAIN SHOW DATABASES;", - QueryContext::default(), - ) - .await - .expect("Failed to execute query in read only mode"); }