mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-26 10:26:30 +00:00
Automatic sharding for SELECT v2 (#337)
* More comprehensive read sharding support * A few fixes * fq * comment * wildcard
This commit is contained in:
@@ -374,7 +374,7 @@ impl Pool {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn validate(&self) -> Result<(), Error> {
|
||||
pub fn validate(&mut self) -> Result<(), Error> {
|
||||
match self.default_role.as_ref() {
|
||||
"any" => (),
|
||||
"primary" => (),
|
||||
@@ -414,6 +414,25 @@ impl Pool {
|
||||
}
|
||||
}
|
||||
|
||||
self.automatic_sharding_key = match &self.automatic_sharding_key {
|
||||
Some(key) => {
|
||||
// No quotes in the key so we don't have to compare quoted
|
||||
// to unquoted idents.
|
||||
let key = key.replace("\"", "");
|
||||
|
||||
if key.split(".").count() != 2 {
|
||||
error!(
|
||||
"automatic_sharding_key '{}' must be fully qualified, e.g. t.{}`",
|
||||
key, key
|
||||
);
|
||||
return Err(Error::BadConfig);
|
||||
}
|
||||
|
||||
Some(key)
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user