From d99630be7775416ca986f3f7564a0d504f1533c1 Mon Sep 17 00:00:00 2001 From: Xiangjin Date: Fri, 21 Jul 2023 13:23:07 +0800 Subject: [PATCH 1/2] feat(frontend): stub session variable `client_min_messages` --- src/common/src/session_config/mod.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/common/src/session_config/mod.rs b/src/common/src/session_config/mod.rs index 11713e1d3efda..a22a68e7758cb 100644 --- a/src/common/src/session_config/mod.rs +++ b/src/common/src/session_config/mod.rs @@ -34,7 +34,7 @@ use crate::util::epoch::Epoch; // This is a hack, &'static str is not allowed as a const generics argument. // TODO: refine this using the adt_const_params feature. -const CONFIG_KEYS: [&str; 26] = [ +const CONFIG_KEYS: [&str; 27] = [ "RW_IMPLICIT_FLUSH", "CREATE_COMPACTION_GROUP_FOR_MV", "QUERY_MODE", @@ -61,6 +61,7 @@ const CONFIG_KEYS: [&str; 26] = [ "SERVER_VERSION", "SERVER_VERSION_NUM", "RW_FORCE_SPLIT_DISTINCT_AGG", + "CLIENT_MIN_MESSAGES", ]; // MUST HAVE 1v1 relationship to CONFIG_KEYS. e.g. CONFIG_KEYS[IMPLICIT_FLUSH] = @@ -91,6 +92,7 @@ const RW_ENABLE_JOIN_ORDERING: usize = 22; const SERVER_VERSION: usize = 23; const SERVER_VERSION_NUM: usize = 24; const FORCE_SPLIT_DISTINCT_AGG: usize = 25; +const CLIENT_MIN_MESSAGES: usize = 26; trait ConfigEntry: Default + for<'a> TryFrom<&'a [&'a str], Error = RwError> { fn entry_name() -> &'static str; @@ -297,6 +299,7 @@ type EnableJoinOrdering = ConfigBool; type ServerVersion = ConfigString; type ServerVersionNum = ConfigI32; type ForceSplitDistinctAgg = ConfigBool; +type ClientMinMessages = ConfigString; /// Report status or notice to caller. pub trait ConfigReporter { @@ -394,6 +397,12 @@ pub struct ConfigMap { #[educe(Default(expression = "ConfigString::(String::from(\"8.3.0\"))"))] server_version: ServerVersion, server_version_num: ServerVersionNum, + + /// see + #[educe(Default( + expression = "ConfigString::(String::from(\"notice\"))" + ))] + client_min_messages: ClientMinMessages, } impl ConfigMap { @@ -467,6 +476,9 @@ impl ConfigMap { self.interval_style = val.as_slice().try_into()?; } else if key.eq_ignore_ascii_case(BatchParallelism::entry_name()) { self.batch_parallelism = val.as_slice().try_into()?; + } else if key.eq_ignore_ascii_case(ClientMinMessages::entry_name()) { + // TODO: validate input and fold to lowercase after #10697 refactor + self.client_min_messages = val.as_slice().try_into()?; } else { return Err(ErrorCode::UnrecognizedConfigurationParameter(key.to_string()).into()); } @@ -529,6 +541,8 @@ impl ConfigMap { Ok(self.application_name.to_string()) } else if key.eq_ignore_ascii_case(ForceSplitDistinctAgg::entry_name()) { Ok(self.force_split_distinct_agg.to_string()) + } else if key.eq_ignore_ascii_case(ClientMinMessages::entry_name()) { + Ok(self.client_min_messages.to_string()) } else { Err(ErrorCode::UnrecognizedConfigurationParameter(key.to_string()).into()) } @@ -661,6 +675,11 @@ impl ConfigMap { setting : self.force_split_distinct_agg.to_string(), description : String::from("Enable split the distinct aggregation.") }, + VariableInfo{ + name : ClientMinMessages::entry_name().to_lowercase(), + setting : self.client_min_messages.to_string(), + description : String::from("Sets the message levels that are sent to the client.") + }, ] } @@ -768,4 +787,8 @@ impl ConfigMap { } None } + + pub fn get_client_min_message(&self) -> &str { + &self.client_min_messages + } } From 0519faf181c9e219de84fb42c970806e94ed4bc6 Mon Sep 17 00:00:00 2001 From: Xiangjin Date: Fri, 21 Jul 2023 13:47:24 +0800 Subject: [PATCH 2/2] feat(frontend): stub session variable `client_encoding` --- src/common/src/session_config/mod.rs | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/common/src/session_config/mod.rs b/src/common/src/session_config/mod.rs index a22a68e7758cb..2c99a9c241255 100644 --- a/src/common/src/session_config/mod.rs +++ b/src/common/src/session_config/mod.rs @@ -34,7 +34,7 @@ use crate::util::epoch::Epoch; // This is a hack, &'static str is not allowed as a const generics argument. // TODO: refine this using the adt_const_params feature. -const CONFIG_KEYS: [&str; 27] = [ +const CONFIG_KEYS: [&str; 28] = [ "RW_IMPLICIT_FLUSH", "CREATE_COMPACTION_GROUP_FOR_MV", "QUERY_MODE", @@ -62,6 +62,7 @@ const CONFIG_KEYS: [&str; 27] = [ "SERVER_VERSION_NUM", "RW_FORCE_SPLIT_DISTINCT_AGG", "CLIENT_MIN_MESSAGES", + "CLIENT_ENCODING", ]; // MUST HAVE 1v1 relationship to CONFIG_KEYS. e.g. CONFIG_KEYS[IMPLICIT_FLUSH] = @@ -93,6 +94,7 @@ const SERVER_VERSION: usize = 23; const SERVER_VERSION_NUM: usize = 24; const FORCE_SPLIT_DISTINCT_AGG: usize = 25; const CLIENT_MIN_MESSAGES: usize = 26; +const CLIENT_ENCODING: usize = 27; trait ConfigEntry: Default + for<'a> TryFrom<&'a [&'a str], Error = RwError> { fn entry_name() -> &'static str; @@ -300,6 +302,7 @@ type ServerVersion = ConfigString; type ServerVersionNum = ConfigI32; type ForceSplitDistinctAgg = ConfigBool; type ClientMinMessages = ConfigString; +type ClientEncoding = ConfigString; /// Report status or notice to caller. pub trait ConfigReporter { @@ -403,6 +406,10 @@ pub struct ConfigMap { expression = "ConfigString::(String::from(\"notice\"))" ))] client_min_messages: ClientMinMessages, + + /// see + #[educe(Default(expression = "ConfigString::(String::from(\"UTF8\"))"))] + client_encoding: ClientEncoding, } impl ConfigMap { @@ -479,6 +486,16 @@ impl ConfigMap { } else if key.eq_ignore_ascii_case(ClientMinMessages::entry_name()) { // TODO: validate input and fold to lowercase after #10697 refactor self.client_min_messages = val.as_slice().try_into()?; + } else if key.eq_ignore_ascii_case(ClientEncoding::entry_name()) { + let enc: ClientEncoding = val.as_slice().try_into()?; + if !enc.as_str().eq_ignore_ascii_case("UTF8") { + return Err(ErrorCode::InvalidConfigValue { + config_entry: ClientEncoding::entry_name().into(), + config_value: enc.0, + } + .into()); + } + // No actual assignment because we only support UTF8. } else { return Err(ErrorCode::UnrecognizedConfigurationParameter(key.to_string()).into()); } @@ -543,6 +560,8 @@ impl ConfigMap { Ok(self.force_split_distinct_agg.to_string()) } else if key.eq_ignore_ascii_case(ClientMinMessages::entry_name()) { Ok(self.client_min_messages.to_string()) + } else if key.eq_ignore_ascii_case(ClientEncoding::entry_name()) { + Ok(self.client_encoding.to_string()) } else { Err(ErrorCode::UnrecognizedConfigurationParameter(key.to_string()).into()) } @@ -680,6 +699,11 @@ impl ConfigMap { setting : self.client_min_messages.to_string(), description : String::from("Sets the message levels that are sent to the client.") }, + VariableInfo{ + name : ClientEncoding::entry_name().to_lowercase(), + setting : self.client_encoding.to_string(), + description : String::from("Sets the client's character set encoding.") + }, ] } @@ -791,4 +815,8 @@ impl ConfigMap { pub fn get_client_min_message(&self) -> &str { &self.client_min_messages } + + pub fn get_client_encoding(&self) -> &str { + &self.client_encoding + } }