Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 0f0a27d

Browse files
pimeysJakub Wieczorek
authored andcommitted
Be really sure no statements are ever used in transaction_pool_mode
1 parent 8af1bfb commit 0f0a27d

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

tokio-postgres/src/client.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ impl InnerClient {
105105
}
106106

107107
pub fn typeinfo(&self) -> Option<Statement> {
108-
self.cached_typeinfo.lock().typeinfo.clone()
108+
if self.transaction_pool_mode {
109+
None
110+
} else {
111+
self.cached_typeinfo.lock().typeinfo.clone()
112+
}
109113
}
110114

111115
pub fn set_typeinfo(&self, statement: &Statement) {
@@ -115,7 +119,11 @@ impl InnerClient {
115119
}
116120

117121
pub fn typeinfo_composite(&self) -> Option<Statement> {
118-
self.cached_typeinfo.lock().typeinfo_composite.clone()
122+
if self.transaction_pool_mode {
123+
None
124+
} else {
125+
self.cached_typeinfo.lock().typeinfo_composite.clone()
126+
}
119127
}
120128

121129
pub fn set_typeinfo_composite(&self, statement: &Statement) {
@@ -125,7 +133,11 @@ impl InnerClient {
125133
}
126134

127135
pub fn typeinfo_enum(&self) -> Option<Statement> {
128-
self.cached_typeinfo.lock().typeinfo_enum.clone()
136+
if self.transaction_pool_mode {
137+
None
138+
} else {
139+
self.cached_typeinfo.lock().typeinfo_enum.clone()
140+
}
129141
}
130142

131143
pub fn set_typeinfo_enum(&self, statement: &Statement) {
@@ -135,7 +147,11 @@ impl InnerClient {
135147
}
136148

137149
pub fn type_(&self, oid: Oid) -> Option<Type> {
138-
self.cached_typeinfo.lock().types.get(&oid).cloned()
150+
if self.transaction_pool_mode {
151+
None
152+
} else {
153+
self.cached_typeinfo.lock().types.get(&oid).cloned()
154+
}
139155
}
140156

141157
pub fn set_type(&self, oid: Oid, type_: &Type) {
@@ -145,7 +161,9 @@ impl InnerClient {
145161
}
146162

147163
pub fn clear_type_cache(&self) {
148-
self.cached_typeinfo.lock().types.clear();
164+
if !self.transaction_pool_mode {
165+
self.cached_typeinfo.lock().types.clear();
166+
}
149167
}
150168

151169
/// Call the given function with a buffer to be used when writing out

0 commit comments

Comments
 (0)