From 844a1bd145c0099ea1a31de145a6ecc8fc2a699b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Sat, 15 May 2021 10:25:14 +0100 Subject: [PATCH] Revert change back to always setting the cached statement --- tokio-postgres/src/client.rs | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/tokio-postgres/src/client.rs b/tokio-postgres/src/client.rs index 4e8babf1..4a099d94 100644 --- a/tokio-postgres/src/client.rs +++ b/tokio-postgres/src/client.rs @@ -101,17 +101,7 @@ impl InnerClient { } pub fn set_typeinfo(&self, statement: &Statement) { - // We only insert the statement if there isn't already a cached - // statement (this is safe as they are prepared statements for the same - // query). - // - // Note: We need to be sure that we don't drop a Statement while holding - // the state lock as its drop handling will call `with_buf`, which tries - // to take the lock. - let mut cache = self.cached_typeinfo.lock(); - if cache.typeinfo.is_none() { - cache.typeinfo = Some(statement.clone()); - } + self.cached_typeinfo.lock().typeinfo = Some(statement.clone()); } pub fn typeinfo_composite(&self) -> Option { @@ -119,13 +109,7 @@ impl InnerClient { } pub fn set_typeinfo_composite(&self, statement: &Statement) { - // We only insert the statement if there isn't already a cached - // statement (this is safe as they are prepared statements for the same - // query). - let mut cache = self.cached_typeinfo.lock(); - if cache.typeinfo_composite.is_none() { - cache.typeinfo_composite = Some(statement.clone()); - } + self.cached_typeinfo.lock().typeinfo_composite = Some(statement.clone()); } pub fn typeinfo_enum(&self) -> Option { @@ -133,13 +117,7 @@ impl InnerClient { } pub fn set_typeinfo_enum(&self, statement: &Statement) { - // We only insert the statement if there isn't already a cached - // statement (this is safe as they are prepared statements for the same - // query). - let mut cache = self.cached_typeinfo.lock(); - if cache.typeinfo_enum.is_none() { - cache.typeinfo_enum = Some(statement.clone()); - } + self.cached_typeinfo.lock().typeinfo_enum = Some(statement.clone()); } pub fn type_(&self, oid: Oid) -> Option {