diff --git a/config/config.md b/config/config.md index 12fde8ffd68..248662f5963 100644 --- a/config/config.md +++ b/config/config.md @@ -55,7 +55,6 @@ | `mysql` | -- | -- | MySQL server options. | | `mysql.enable` | Bool | `true` | Whether to enable. | | `mysql.addr` | String | `127.0.0.1:4002` | The addr to bind the MySQL server. | -| `mysql.runtime_size` | Integer | `2` | The number of server worker threads. | | `mysql.keep_alive` | String | `0s` | Server-side keep-alive time.
Set to 0 (default) to disable. | | `mysql.prepared_stmt_cache_size` | Integer | `10000` | Maximum entries in the MySQL prepared statement cache; default is 10,000. | | `mysql.tls` | -- | -- | -- | @@ -66,7 +65,6 @@ | `postgres` | -- | -- | PostgresSQL server options. | | `postgres.enable` | Bool | `true` | Whether to enable | | `postgres.addr` | String | `127.0.0.1:4003` | The addr to bind the PostgresSQL server. | -| `postgres.runtime_size` | Integer | `2` | The number of server worker threads. | | `postgres.keep_alive` | String | `0s` | Server-side keep-alive time.
Set to 0 (default) to disable. | | `postgres.max_copy_in_payload` | String | `64MB` | Maximum size of a table-less `COPY ... FROM STDIN` payload: the influxdb line protocol, OTLP and Prometheus Remote Write formats, which buffer the whole payload until the copy completes, like an HTTP request body.
Table-bound formats (csv, jsonl, arrow) stream and are not bound by it.
The following units are supported: `B`, `KB`, `KiB`, `MB`, `MiB`, `GB`, `GiB`, `TB`, `TiB`, `PB`, `PiB`.
Set to 0 to disable the limit; nonzero sizes must be at least one byte. | | `postgres.tls` | -- | -- | PostgresSQL server TLS options, see `mysql.tls` section. | @@ -346,7 +344,6 @@ | `mysql` | -- | -- | MySQL server options. | | `mysql.enable` | Bool | `true` | Whether to enable. | | `mysql.addr` | String | `127.0.0.1:4002` | The addr to bind the MySQL server. | -| `mysql.runtime_size` | Integer | `2` | The number of server worker threads. | | `mysql.keep_alive` | String | `0s` | Server-side keep-alive time.
Set to 0 (default) to disable. | | `mysql.prepared_stmt_cache_size` | Integer | `10000` | Maximum entries in the MySQL prepared statement cache; default is 10,000. | | `mysql.tls` | -- | -- | -- | @@ -357,7 +354,6 @@ | `postgres` | -- | -- | PostgresSQL server options. | | `postgres.enable` | Bool | `true` | Whether to enable | | `postgres.addr` | String | `127.0.0.1:4003` | The addr to bind the PostgresSQL server. | -| `postgres.runtime_size` | Integer | `2` | The number of server worker threads. | | `postgres.keep_alive` | String | `0s` | Server-side keep-alive time.
Set to 0 (default) to disable. | | `postgres.max_copy_in_payload` | String | `64MB` | Maximum size of a table-less `COPY ... FROM STDIN` payload: the influxdb line protocol, OTLP and Prometheus Remote Write formats, which buffer the whole payload until the copy completes, like an HTTP request body.
Table-bound formats (csv, jsonl, arrow) stream and are not bound by it.
The following units are supported: `B`, `KB`, `KiB`, `MB`, `MiB`, `GB`, `GiB`, `TB`, `TiB`, `PB`, `PiB`.
Set to 0 to disable the limit; nonzero sizes must be at least one byte. | | `postgres.tls` | -- | -- | PostgresSQL server TLS options, see `mysql.tls` section. | diff --git a/config/frontend.example.toml b/config/frontend.example.toml index 9e158a16d16..e2bac8ef4e6 100644 --- a/config/frontend.example.toml +++ b/config/frontend.example.toml @@ -180,8 +180,6 @@ watch = false enable = true ## The addr to bind the MySQL server. addr = "127.0.0.1:4002" -## The number of server worker threads. -runtime_size = 2 ## Server-side keep-alive time. ## Set to 0 (default) to disable. keep_alive = "0s" @@ -216,8 +214,6 @@ watch = false enable = true ## The addr to bind the PostgresSQL server. addr = "127.0.0.1:4003" -## The number of server worker threads. -runtime_size = 2 ## Server-side keep-alive time. ## Set to 0 (default) to disable. keep_alive = "0s" diff --git a/config/standalone.example.toml b/config/standalone.example.toml index b3847b8fd0a..1b37ae36232 100644 --- a/config/standalone.example.toml +++ b/config/standalone.example.toml @@ -161,8 +161,6 @@ watch = false enable = true ## The addr to bind the MySQL server. addr = "127.0.0.1:4002" -## The number of server worker threads. -runtime_size = 2 ## Server-side keep-alive time. ## Set to 0 (default) to disable. keep_alive = "0s" @@ -196,8 +194,6 @@ watch = false enable = true ## The addr to bind the PostgresSQL server. addr = "127.0.0.1:4003" -## The number of server worker threads. -runtime_size = 2 ## Server-side keep-alive time. ## Set to 0 (default) to disable. keep_alive = "0s" diff --git a/src/cmd/src/frontend.rs b/src/cmd/src/frontend.rs index 4220f243297..949fe97ae25 100644 --- a/src/cmd/src/frontend.rs +++ b/src/cmd/src/frontend.rs @@ -787,12 +787,7 @@ mod tests { assert_eq!(opts.grpc.bind_addr, default_opts.grpc.bind_addr); assert!(opts.mysql.enable); - assert_eq!(opts.mysql.runtime_size, default_opts.mysql.runtime_size); assert!(opts.postgres.enable); - assert_eq!( - opts.postgres.runtime_size, - default_opts.postgres.runtime_size - ); assert!(opts.opentsdb.enable); assert!(!opts.influxdb.enable); @@ -926,11 +921,11 @@ mod tests { Some("127.0.0.1:14002"), ), ( - // mysql.runtime_size = 11 + // mysql.prepared_stmt_cache_size = 11 [ env_prefix.to_string(), "mysql".to_uppercase(), - "runtime_size".to_uppercase(), + "prepared_stmt_cache_size".to_uppercase(), ] .join(ENV_VAR_SEP), Some("11"), @@ -967,7 +962,7 @@ mod tests { let fe_opts = command.load_options(&Default::default()).unwrap().component; // Should be read from env, env > default values. - assert_eq!(fe_opts.mysql.runtime_size, 11); + assert_eq!(fe_opts.mysql.prepared_stmt_cache_size, 11); assert_eq!( fe_opts.meta_client.unwrap().metasrv_addrs, vec![ diff --git a/src/cmd/src/standalone.rs b/src/cmd/src/standalone.rs index c66b27d46e5..8518711c791 100644 --- a/src/cmd/src/standalone.rs +++ b/src/cmd/src/standalone.rs @@ -1441,7 +1441,6 @@ mod tests { assert_eq!("127.0.0.1:4001".to_string(), fe_opts.grpc.bind_addr); assert!(fe_opts.mysql.enable); assert_eq!("127.0.0.1:4002", fe_opts.mysql.addr); - assert_eq!(2, fe_opts.mysql.runtime_size); assert_eq!(None, fe_opts.mysql.reject_no_database); assert!(fe_opts.influxdb.enable); assert!(fe_opts.opentsdb.enable); diff --git a/src/frontend/src/instance.rs b/src/frontend/src/instance.rs index 5baeb968463..aa75d5cc44c 100644 --- a/src/frontend/src/instance.rs +++ b/src/frontend/src/instance.rs @@ -1147,6 +1147,10 @@ impl Instance { Statement::ShowProcesslist(show) => { query::sql::show_processlist_dataframe(show, engine, catalog_manager, ctx).await } + #[cfg(feature = "enterprise")] + Statement::ShowTriggers(show) => { + query::sql::show_triggers_dataframe(show, engine, catalog_manager, ctx).await + } _ => return None, }; Some(dataframe) diff --git a/src/frontend/src/service_config/mysql.rs b/src/frontend/src/service_config/mysql.rs index f55dd78de8f..b632b5aeda5 100644 --- a/src/frontend/src/service_config/mysql.rs +++ b/src/frontend/src/service_config/mysql.rs @@ -19,7 +19,6 @@ use servers::tls::TlsOption; pub struct MysqlOptions { pub enable: bool, pub addr: String, - pub runtime_size: usize, #[serde(default = "Default::default")] pub tls: TlsOption, pub reject_no_database: Option, @@ -37,7 +36,6 @@ impl Default for MysqlOptions { Self { enable: true, addr: "127.0.0.1:4002".to_string(), - runtime_size: 2, tls: TlsOption::default(), reject_no_database: None, keep_alive: std::time::Duration::from_secs(0), diff --git a/src/frontend/src/service_config/postgres.rs b/src/frontend/src/service_config/postgres.rs index 09b06b877a3..24a38938234 100644 --- a/src/frontend/src/service_config/postgres.rs +++ b/src/frontend/src/service_config/postgres.rs @@ -57,7 +57,6 @@ fn deserialize_max_copy_in_payload<'de, D: Deserializer<'de>>( pub struct PostgresOptions { pub enable: bool, pub addr: String, - pub runtime_size: usize, #[serde(default = "Default::default")] pub tls: TlsOption, /// Server-side keep-alive time. @@ -85,7 +84,6 @@ impl Default for PostgresOptions { Self { enable: true, addr: "127.0.0.1:4003".to_string(), - runtime_size: 2, tls: Default::default(), keep_alive: std::time::Duration::from_secs(0), max_copy_in_payload: default_max_copy_in_payload(), @@ -101,7 +99,7 @@ mod tests { fn test_max_copy_in_payload() { let parse = |value: &str| { toml::from_str::(&format!( - "enable = true\naddr = '127.0.0.1:4003'\nruntime_size = 2\nmax_copy_in_payload = {value}" + "enable = true\naddr = '127.0.0.1:4003'\nmax_copy_in_payload = {value}" )) }; for value in ["-1", "'-1MiB'", "'0.5B'", "'1e-999B'"] { diff --git a/src/query/src/sql.rs b/src/query/src/sql.rs index daac3a269e5..966d4398c07 100644 --- a/src/query/src/sql.rs +++ b/src/query/src/sql.rs @@ -144,7 +144,7 @@ pub static DESCRIBE_TABLE_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { ])) }); -static SHOW_CREATE_DATABASE_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { +pub static SHOW_CREATE_DATABASE_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { Arc::new(Schema::new(vec![ ColumnSchema::new("Database", ConcreteDataType::string_datatype(), false), ColumnSchema::new( @@ -155,21 +155,21 @@ static SHOW_CREATE_DATABASE_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { ])) }); -static SHOW_CREATE_TABLE_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { +pub static SHOW_CREATE_TABLE_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { Arc::new(Schema::new(vec![ ColumnSchema::new("Table", ConcreteDataType::string_datatype(), false), ColumnSchema::new("Create Table", ConcreteDataType::string_datatype(), false), ])) }); -static SHOW_CREATE_FLOW_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { +pub static SHOW_CREATE_FLOW_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { Arc::new(Schema::new(vec![ ColumnSchema::new("Flow", ConcreteDataType::string_datatype(), false), ColumnSchema::new("Create Flow", ConcreteDataType::string_datatype(), false), ])) }); -static SHOW_CREATE_VIEW_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { +pub static SHOW_CREATE_VIEW_OUTPUT_SCHEMA: Lazy> = Lazy::new(|| { Arc::new(Schema::new(vec![ ColumnSchema::new("View", ConcreteDataType::string_datatype(), false), ColumnSchema::new("Create View", ConcreteDataType::string_datatype(), false), @@ -946,6 +946,18 @@ pub fn show_query_option( Ok(Some(Output::new_with_record_batches(records))) } +/// Returns the column name of a `SHOW VARIABLES` result: supported query +/// options keep their spelling (see [`show_query_option`]), other variables +/// are upper-cased (see [`show_variable`]). +pub fn show_variable_column_name(variable: &ObjectName) -> String { + let name = sql::ast::object_name_to_string_unquoted(variable); + if session::query_options::canonical_query_option_name(&name).is_some() { + name + } else { + variable.to_string().to_uppercase() + } +} + pub fn show_variable(stmt: ShowVariables, query_ctx: QueryContextRef) -> Result { let variable = stmt.variable.to_string().to_uppercase(); let value = match variable.as_str() { @@ -1272,6 +1284,19 @@ pub async fn show_triggers( catalog_manager: &CatalogManagerRef, query_ctx: QueryContextRef, ) -> Result { + let dataframe = + show_triggers_dataframe(&stmt, query_engine, catalog_manager, query_ctx).await?; + dataframe_to_output(dataframe).await +} + +/// Builds the [`DataFrame`] for `SHOW TRIGGERS` without executing it. +#[cfg(feature = "enterprise")] +pub async fn show_triggers_dataframe( + stmt: &sql::statements::show::trigger::ShowTriggers, + query_engine: &QueryEngineRef, + catalog_manager: &CatalogManagerRef, + query_ctx: QueryContextRef, +) -> Result { const TRIGGER_NAME: &str = "trigger_name"; const TRIGGERS_COLUMN: &str = "Triggers"; @@ -1279,7 +1304,7 @@ pub async fn show_triggers( let like_field = Some(TRIGGER_NAME); let sort = vec![col(TRIGGER_NAME).sort(true, true)]; - query_from_information_schema_table( + query_from_information_schema_dataframe( query_engine, catalog_manager, query_ctx, @@ -1289,7 +1314,7 @@ pub async fn show_triggers( vec![], like_field, sort, - stmt.kind, + &stmt.kind, ) .await } diff --git a/src/servers/src/postgres/handler.rs b/src/servers/src/postgres/handler.rs index 39b66417050..b886ffcd532 100644 --- a/src/servers/src/postgres/handler.rs +++ b/src/servers/src/postgres/handler.rs @@ -44,7 +44,11 @@ use pgwire::messages::data::DataRow; use query::dist_analyze_output_schema; use query::planner::DfLogicalPlanner; use query::query_engine::DescribeResult; -use query::sql::DESCRIBE_TABLE_OUTPUT_SCHEMA; +use query::sql::{ + DESCRIBE_TABLE_OUTPUT_SCHEMA, SHOW_CREATE_DATABASE_OUTPUT_SCHEMA, + SHOW_CREATE_FLOW_OUTPUT_SCHEMA, SHOW_CREATE_TABLE_OUTPUT_SCHEMA, + SHOW_CREATE_VIEW_OUTPUT_SCHEMA, show_variable_column_name, +}; use session::Session; use session::context::QueryContextRef; use snafu::ResultExt; @@ -706,30 +710,18 @@ fn describe_fields( let schema: Schema = plan.schema().clone().try_into().map_err(convert_err)?; schema_to_pg(&schema, format, None).map_err(convert_err) } - // We can cover only part of show statements - // these show create statements will return 2 columns - SqlPlan::Statement( - Statement::ShowCreateDatabase(_) - | Statement::ShowCreateTable(_) - | Statement::ShowCreateFlow(_) - | Statement::ShowCreateView(_), - _, - ) => Ok(vec![ - FieldInfo::new( - "name".to_string(), - None, - None, - Type::TEXT, - format.format_for(0), - ), - FieldInfo::new( - "create_statement".to_string(), - None, - None, - Type::TEXT, - format.format_for(1), - ), - ]), + SqlPlan::Statement(Statement::ShowCreateDatabase(_), _) => { + schema_to_pg(&SHOW_CREATE_DATABASE_OUTPUT_SCHEMA, format, None).map_err(convert_err) + } + SqlPlan::Statement(Statement::ShowCreateTable(_), _) => { + schema_to_pg(&SHOW_CREATE_TABLE_OUTPUT_SCHEMA, format, None).map_err(convert_err) + } + SqlPlan::Statement(Statement::ShowCreateFlow(_), _) => { + schema_to_pg(&SHOW_CREATE_FLOW_OUTPUT_SCHEMA, format, None).map_err(convert_err) + } + SqlPlan::Statement(Statement::ShowCreateView(_), _) => { + schema_to_pg(&SHOW_CREATE_VIEW_OUTPUT_SCHEMA, format, None).map_err(convert_err) + } #[cfg(feature = "enterprise")] SqlPlan::Statement(Statement::ShowCreateTrigger(_), _) => Ok(vec![ FieldInfo::new( @@ -793,15 +785,6 @@ fn describe_fields( format.format_for(5), ), ]), - - #[cfg(feature = "enterprise")] - SqlPlan::Statement(Statement::ShowTriggers(_), _) => Ok(vec![FieldInfo::new( - "name".to_string(), - None, - None, - Type::TEXT, - format.format_for(0), - )]), // we will not support other show statements for extended query protocol at least for now. // because the return columns is not predictable at this stage SqlPlan::Shortcut(query) => { @@ -815,9 +798,8 @@ fn describe_fields( Ok(vec![]) } } - // Single column named after the variable (see `query::sql::show_variable`). SqlPlan::Statement(Statement::ShowVariables(show), _) => Ok(vec![FieldInfo::new( - show.variable.to_string().to_uppercase(), + show_variable_column_name(&show.variable), None, None, Type::TEXT, diff --git a/tests-integration/tests/http.rs b/tests-integration/tests/http.rs index d3f6cd3427c..eb9c3f9d473 100644 --- a/tests-integration/tests/http.rs +++ b/tests-integration/tests/http.rs @@ -4989,7 +4989,6 @@ watch = false [mysql] enable = true addr = "127.0.0.1:4002" -runtime_size = 2 keep_alive = "0s" prepared_stmt_cache_size = 10000 @@ -5003,7 +5002,6 @@ watch = false [postgres] enable = true addr = "127.0.0.1:4003" -runtime_size = 2 keep_alive = "0s" max_copy_in_payload = "64MiB" diff --git a/tests-integration/tests/sql.rs b/tests-integration/tests/sql.rs index 17be2294596..62b8e30816f 100644 --- a/tests-integration/tests/sql.rs +++ b/tests-integration/tests/sql.rs @@ -2068,6 +2068,19 @@ pub async fn test_postgres_extended_query_row_returning_statements(store_type: S assert_eq!(1, rows[0].columns().len()); assert_eq!("TIMEZONE", rows[0].columns()[0].name()); let _ = rows[0].get::<_, String>(0); + let rows = client + .query("SHOW VARIABLES \"query.parallelism\"", &[]) + .await + .unwrap(); + assert_eq!("query.parallelism", rows[0].columns()[0].name()); + + // ---- SHOW CREATE TABLE: `Table` + `Create Table` columns ---- + let rows = client + .query("SHOW CREATE TABLE demo_metrics", &[]) + .await + .unwrap(); + let names: Vec<&str> = rows[0].columns().iter().map(|c| c.name()).collect(); + assert_eq!(vec!["Table", "Create Table"], names); // ---- DESCRIBE TABLE: fixed six-column string schema ---- let rows = client diff --git a/tests/conf/standalone-test.toml.template b/tests/conf/standalone-test.toml.template index 149d53ffde6..8a4e1124095 100644 --- a/tests/conf/standalone-test.toml.template +++ b/tests/conf/standalone-test.toml.template @@ -37,7 +37,6 @@ runtime_size = 8 [mysql] enable = true addr = "{addrs.mysql_addr}" -runtime_size = 2 prepared_stmt_cache_size= 10000 [mysql.tls] @@ -46,7 +45,6 @@ mode = "disable" [postgres] enable = true addr = "{addrs.postgres_addr}" -runtime_size = 2 [procedure] max_retry_times = 3