Automatic sharding for SELECT v2 (#337)

* More comprehensive read sharding support

* A few fixes

* fq

* comment

* wildcard
This commit is contained in:
Lev Kokotov
2023-03-02 00:53:31 -05:00
committed by GitHub
parent 02839e4dc2
commit c3eaf023c7
3 changed files with 193 additions and 29 deletions

View File

@@ -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(())
}
}