This commit is contained in:
Lev Kokotov
2023-05-03 15:38:03 -07:00
parent 374a6b138b
commit ff80bb75cc
5 changed files with 14 additions and 20 deletions

View File

@@ -48,3 +48,4 @@ serde_json = "1"
[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = "0.5.0"

View File

@@ -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.<pool_name>.users.<user_index>
# This section holds the credentials for users that may connect to this cluster
[pools.sharded_db.users.0]

View File

@@ -302,8 +302,6 @@ pub struct General {
pub auth_query: Option<String>,
pub auth_query_user: Option<String>,
pub auth_query_password: Option<String>,
pub query_router_plugins: Option<Vec<String>>,
}
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<String>,
pub auth_query_user: Option<String>,
pub auth_query_password: Option<String>,
pub query_router_plugins: Option<Vec<String>>,
pub shards: BTreeMap<String, Shard>,
pub users: BTreeMap<String, User>,
@@ -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();

View File

@@ -132,8 +132,6 @@ pub struct PoolSettings {
pub auth_query: Option<String>,
pub auth_query_user: Option<String>,
pub auth_query_password: Option<String>,
pub plugins: Option<Vec<String>>,
}
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)),

View File

@@ -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",