From ff80bb75cce0c9f0728258e1fcccaa01961ab564 Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Wed, 3 May 2023 15:38:03 -0700 Subject: [PATCH] clean up --- Cargo.toml | 1 + pgcat.toml | 14 +++++++++++++- src/config.rs | 14 -------------- src/pool.rs | 4 ---- tests/ruby/helpers/pgcat_helper.rb | 1 - 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8054982..1b3c8b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,3 +48,4 @@ serde_json = "1" [target.'cfg(not(target_env = "msvc"))'.dependencies] jemallocator = "0.5.0" + diff --git a/pgcat.toml b/pgcat.toml index aa0c1ed..ce36632 100644 --- a/pgcat.toml +++ b/pgcat.toml @@ -168,7 +168,7 @@ tables = [ ] [plugins.intercept] -enabled = false +enabled = true [plugins.intercept.queries.0] @@ -181,6 +181,18 @@ result = [ ["${DATABASE}", "{public}"], ] +[plugins.intercept.queries.1] + +query = "select current_database(), current_schema(), current_user" +schema = [ + ["current_database", "text"], + ["current_schema", "text"], + ["current_user", "text"], +] +result = [ + ["${DATABASE}", "public", "${USER}"], +] + # User configs are structured as pool..users. # This section holds the credentials for users that may connect to this cluster [pools.sharded_db.users.0] diff --git a/src/config.rs b/src/config.rs index 1d52368..cdf891e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -302,8 +302,6 @@ pub struct General { pub auth_query: Option, pub auth_query_user: Option, pub auth_query_password: Option, - - pub query_router_plugins: Option>, } impl General { @@ -404,7 +402,6 @@ impl Default for General { auth_query_user: None, auth_query_password: None, server_lifetime: 1000 * 3600 * 24, // 24 hours, - query_router_plugins: None, } } } @@ -483,7 +480,6 @@ pub struct Pool { pub auth_query: Option, pub auth_query_user: Option, pub auth_query_password: Option, - pub query_router_plugins: Option>, pub shards: BTreeMap, pub users: BTreeMap, @@ -605,7 +601,6 @@ impl Default for Pool { auth_query_user: None, auth_query_password: None, server_lifetime: None, - query_router_plugins: None, } } } @@ -781,14 +776,6 @@ impl Config { } } } - - pub fn fill_up_query_router_plugins(&mut self) { - for (_name, pool) in self.pools.iter_mut() { - if pool.query_router_plugins.is_none() { - pool.query_router_plugins = self.general.query_router_plugins.clone(); - } - } - } } impl Default for Config { @@ -1177,7 +1164,6 @@ pub async fn parse(path: &str) -> Result<(), Error> { }; config.fill_up_auth_query_config(); - config.fill_up_query_router_plugins(); config.validate()?; config.path = path.to_string(); diff --git a/src/pool.rs b/src/pool.rs index 2bc74ab..2fd380c 100644 --- a/src/pool.rs +++ b/src/pool.rs @@ -132,8 +132,6 @@ pub struct PoolSettings { pub auth_query: Option, pub auth_query_user: Option, pub auth_query_password: Option, - - pub plugins: Option>, } impl Default for PoolSettings { @@ -158,7 +156,6 @@ impl Default for PoolSettings { auth_query: None, auth_query_user: None, auth_query_password: None, - plugins: None, } } } @@ -453,7 +450,6 @@ impl ConnectionPool { auth_query: pool_config.auth_query.clone(), auth_query_user: pool_config.auth_query_user.clone(), auth_query_password: pool_config.auth_query_password.clone(), - plugins: pool_config.query_router_plugins.clone(), }, validated: Arc::new(AtomicBool::new(false)), paused: Arc::new(AtomicBool::new(false)), diff --git a/tests/ruby/helpers/pgcat_helper.rb b/tests/ruby/helpers/pgcat_helper.rb index eb0cdaa..ad4c32a 100644 --- a/tests/ruby/helpers/pgcat_helper.rb +++ b/tests/ruby/helpers/pgcat_helper.rb @@ -27,7 +27,6 @@ module Helpers primary2 = PgInstance.new(8432, user["username"], user["password"], "shard2") pgcat_cfg = pgcat.current_config - pgcat_cfg["general"]["query_router_plugins"] = ["intercept"] pgcat_cfg["pools"] = { "#{pool_name}" => { "default_role" => "any",