Skip to content

Commit 844a1bd

Browse files
committed
Revert change back to always setting the cached statement
1 parent b7215c6 commit 844a1bd

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

tokio-postgres/src/client.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,45 +101,23 @@ impl InnerClient {
101101
}
102102

103103
pub fn set_typeinfo(&self, statement: &Statement) {
104-
// We only insert the statement if there isn't already a cached
105-
// statement (this is safe as they are prepared statements for the same
106-
// query).
107-
//
108-
// Note: We need to be sure that we don't drop a Statement while holding
109-
// the state lock as its drop handling will call `with_buf`, which tries
110-
// to take the lock.
111-
let mut cache = self.cached_typeinfo.lock();
112-
if cache.typeinfo.is_none() {
113-
cache.typeinfo = Some(statement.clone());
114-
}
104+
self.cached_typeinfo.lock().typeinfo = Some(statement.clone());
115105
}
116106

117107
pub fn typeinfo_composite(&self) -> Option<Statement> {
118108
self.cached_typeinfo.lock().typeinfo_composite.clone()
119109
}
120110

121111
pub fn set_typeinfo_composite(&self, statement: &Statement) {
122-
// We only insert the statement if there isn't already a cached
123-
// statement (this is safe as they are prepared statements for the same
124-
// query).
125-
let mut cache = self.cached_typeinfo.lock();
126-
if cache.typeinfo_composite.is_none() {
127-
cache.typeinfo_composite = Some(statement.clone());
128-
}
112+
self.cached_typeinfo.lock().typeinfo_composite = Some(statement.clone());
129113
}
130114

131115
pub fn typeinfo_enum(&self) -> Option<Statement> {
132116
self.cached_typeinfo.lock().typeinfo_enum.clone()
133117
}
134118

135119
pub fn set_typeinfo_enum(&self, statement: &Statement) {
136-
// We only insert the statement if there isn't already a cached
137-
// statement (this is safe as they are prepared statements for the same
138-
// query).
139-
let mut cache = self.cached_typeinfo.lock();
140-
if cache.typeinfo_enum.is_none() {
141-
cache.typeinfo_enum = Some(statement.clone());
142-
}
120+
self.cached_typeinfo.lock().typeinfo_enum = Some(statement.clone());
143121
}
144122

145123
pub fn type_(&self, oid: Oid) -> Option<Type> {

0 commit comments

Comments
 (0)