@@ -26,8 +26,8 @@ async fn prepare(
26
26
parameters : & [ PgTypeInfo ] ,
27
27
metadata : Option < Arc < PgStatementMetadata > > ,
28
28
) -> Result < ( StatementId , Arc < PgStatementMetadata > ) , Error > {
29
- let id = conn. next_statement_id ;
30
- conn. next_statement_id = id. next ( ) ;
29
+ let id = conn. inner . next_statement_id ;
30
+ conn. inner . next_statement_id = id. next ( ) ;
31
31
32
32
// build a list of type OIDs to send to the database in the PARSE command
33
33
// we have not yet started the query sequence, so we are *safe* to cleanly make
@@ -43,23 +43,25 @@ async fn prepare(
43
43
conn. wait_until_ready ( ) . await ?;
44
44
45
45
// next we send the PARSE command to the server
46
- conn. stream . write_msg ( Parse {
46
+ conn. inner . stream . write_msg ( Parse {
47
47
param_types : & param_types,
48
48
query : sql,
49
49
statement : id,
50
50
} ) ?;
51
51
52
52
if metadata. is_none ( ) {
53
53
// get the statement columns and parameters
54
- conn. stream . write_msg ( message:: Describe :: Statement ( id) ) ?;
54
+ conn. inner
55
+ . stream
56
+ . write_msg ( message:: Describe :: Statement ( id) ) ?;
55
57
}
56
58
57
59
// we ask for the server to immediately send us the result of the PARSE command
58
60
conn. write_sync ( ) ;
59
- conn. stream . flush ( ) . await ?;
61
+ conn. inner . stream . flush ( ) . await ?;
60
62
61
63
// indicates that the SQL query string is now successfully parsed and has semantic validity
62
- conn. stream . recv_expect :: < ParseComplete > ( ) . await ?;
64
+ conn. inner . stream . recv_expect :: < ParseComplete > ( ) . await ?;
63
65
64
66
let metadata = if let Some ( metadata) = metadata {
65
67
// each SYNC produces one READY FOR QUERY
@@ -94,11 +96,11 @@ async fn prepare(
94
96
}
95
97
96
98
async fn recv_desc_params ( conn : & mut PgConnection ) -> Result < ParameterDescription , Error > {
97
- conn. stream . recv_expect ( ) . await
99
+ conn. inner . stream . recv_expect ( ) . await
98
100
}
99
101
100
102
async fn recv_desc_rows ( conn : & mut PgConnection ) -> Result < Option < RowDescription > , Error > {
101
- let rows: Option < RowDescription > = match conn. stream . recv ( ) . await ? {
103
+ let rows: Option < RowDescription > = match conn. inner . stream . recv ( ) . await ? {
102
104
// describes the rows that will be returned when the statement is eventually executed
103
105
message if message. format == BackendMessageFormat :: RowDescription => {
104
106
Some ( message. decode ( ) ?)
@@ -123,7 +125,7 @@ impl PgConnection {
123
125
pub ( super ) async fn wait_for_close_complete ( & mut self , mut count : usize ) -> Result < ( ) , Error > {
124
126
// we need to wait for the [CloseComplete] to be returned from the server
125
127
while count > 0 {
126
- match self . stream . recv ( ) . await ? {
128
+ match self . inner . stream . recv ( ) . await ? {
127
129
message if message. format == BackendMessageFormat :: PortalSuspended => {
128
130
// there was an open portal
129
131
// this can happen if the last time a statement was used it was not fully executed
@@ -148,12 +150,13 @@ impl PgConnection {
148
150
149
151
#[ inline( always) ]
150
152
pub ( crate ) fn write_sync ( & mut self ) {
151
- self . stream
153
+ self . inner
154
+ . stream
152
155
. write_msg ( message:: Sync )
153
156
. expect ( "BUG: Sync should not be too big for protocol" ) ;
154
157
155
158
// all SYNC messages will return a ReadyForQuery
156
- self . pending_ready_for_query_count += 1 ;
159
+ self . inner . pending_ready_for_query_count += 1 ;
157
160
}
158
161
159
162
async fn get_or_prepare < ' a > (
@@ -166,18 +169,18 @@ impl PgConnection {
166
169
// a statement object
167
170
metadata : Option < Arc < PgStatementMetadata > > ,
168
171
) -> Result < ( StatementId , Arc < PgStatementMetadata > ) , Error > {
169
- if let Some ( statement) = self . cache_statement . get_mut ( sql) {
172
+ if let Some ( statement) = self . inner . cache_statement . get_mut ( sql) {
170
173
return Ok ( ( * statement) . clone ( ) ) ;
171
174
}
172
175
173
176
let statement = prepare ( self , sql, parameters, metadata) . await ?;
174
177
175
- if store_to_cache && self . cache_statement . is_enabled ( ) {
176
- if let Some ( ( id, _) ) = self . cache_statement . insert ( sql, statement. clone ( ) ) {
177
- self . stream . write_msg ( Close :: Statement ( id) ) ?;
178
+ if store_to_cache && self . inner . cache_statement . is_enabled ( ) {
179
+ if let Some ( ( id, _) ) = self . inner . cache_statement . insert ( sql, statement. clone ( ) ) {
180
+ self . inner . stream . write_msg ( Close :: Statement ( id) ) ?;
178
181
self . write_sync ( ) ;
179
182
180
- self . stream . flush ( ) . await ?;
183
+ self . inner . stream . flush ( ) . await ?;
181
184
182
185
self . wait_for_close_complete ( 1 ) . await ?;
183
186
self . recv_ready_for_query ( ) . await ?;
@@ -195,7 +198,7 @@ impl PgConnection {
195
198
persistent : bool ,
196
199
metadata_opt : Option < Arc < PgStatementMetadata > > ,
197
200
) -> Result < impl Stream < Item = Result < Either < PgQueryResult , PgRow > , Error > > + ' e , Error > {
198
- let mut logger = QueryLogger :: new ( query, self . log_settings . clone ( ) ) ;
201
+ let mut logger = QueryLogger :: new ( query, self . inner . log_settings . clone ( ) ) ;
199
202
200
203
// before we continue, wait until we are "ready" to accept more queries
201
204
self . wait_until_ready ( ) . await ?;
@@ -231,7 +234,7 @@ impl PgConnection {
231
234
self . wait_until_ready ( ) . await ?;
232
235
233
236
// bind to attach the arguments to the statement and create a portal
234
- self . stream . write_msg ( Bind {
237
+ self . inner . stream . write_msg ( Bind {
235
238
portal : PortalId :: UNNAMED ,
236
239
statement,
237
240
formats : & [ PgValueFormat :: Binary ] ,
@@ -242,7 +245,7 @@ impl PgConnection {
242
245
243
246
// executes the portal up to the passed limit
244
247
// the protocol-level limit acts nearly identically to the `LIMIT` in SQL
245
- self . stream . write_msg ( message:: Execute {
248
+ self . inner . stream . write_msg ( message:: Execute {
246
249
portal : PortalId :: UNNAMED ,
247
250
limit : limit. into ( ) ,
248
251
} ) ?;
@@ -255,7 +258,9 @@ impl PgConnection {
255
258
256
259
// we ask the database server to close the unnamed portal and free the associated resources
257
260
// earlier - after the execution of the current query.
258
- self . stream . write_msg ( Close :: Portal ( PortalId :: UNNAMED ) ) ?;
261
+ self . inner
262
+ . stream
263
+ . write_msg ( Close :: Portal ( PortalId :: UNNAMED ) ) ?;
259
264
260
265
// finally, [Sync] asks postgres to process the messages that we sent and respond with
261
266
// a [ReadyForQuery] message when it's completely done. Theoretically, we could send
@@ -268,8 +273,8 @@ impl PgConnection {
268
273
PgValueFormat :: Binary
269
274
} else {
270
275
// Query will trigger a ReadyForQuery
271
- self . stream . write_msg ( Query ( query) ) ?;
272
- self . pending_ready_for_query_count += 1 ;
276
+ self . inner . stream . write_msg ( Query ( query) ) ?;
277
+ self . inner . pending_ready_for_query_count += 1 ;
273
278
274
279
// metadata starts out as "nothing"
275
280
metadata = Arc :: new ( PgStatementMetadata :: default ( ) ) ;
@@ -278,11 +283,11 @@ impl PgConnection {
278
283
PgValueFormat :: Text
279
284
} ;
280
285
281
- self . stream . flush ( ) . await ?;
286
+ self . inner . stream . flush ( ) . await ?;
282
287
283
288
Ok ( try_stream ! {
284
289
loop {
285
- let message = self . stream. recv( ) . await ?;
290
+ let message = self . inner . stream. recv( ) . await ?;
286
291
287
292
match message. format {
288
293
BackendMessageFormat :: BindComplete
0 commit comments