File tree Expand file tree Collapse file tree 2 files changed +18
-20
lines changed Expand file tree Collapse file tree 2 files changed +18
-20
lines changed Original file line number Diff line number Diff line change @@ -987,19 +987,6 @@ where
987
987
continue ;
988
988
}
989
989
990
- // Close (F)
991
- 'C' => {
992
- if self . prepared_statements_enabled {
993
- let close: Close = ( & message) . try_into ( ) ?;
994
-
995
- if close. is_prepared_statement ( ) && !close. anonymous ( ) {
996
- self . prepared_statements . remove ( & close. name ) ;
997
- write_all_flush ( & mut self . write , & close_complete ( ) ) . await ?;
998
- continue ;
999
- }
1000
- }
1001
- }
1002
-
1003
990
_ => ( ) ,
1004
991
}
1005
992
@@ -1444,11 +1431,18 @@ where
1444
1431
// Close the prepared statement.
1445
1432
'C' => {
1446
1433
if self . prepared_statements_enabled {
1447
- let close: Close = ( & message) . try_into ( ) ?;
1434
+ let mut close: Close = ( & message) . try_into ( ) ?;
1448
1435
1449
1436
if close. is_prepared_statement ( ) && !close. anonymous ( ) {
1450
- server. remove_prepared_statement_from_cache ( & close. name ) ;
1451
- self . prepared_statements . remove ( & close. name ) ;
1437
+ if let Some ( ( parse, _) ) =
1438
+ self . prepared_statements . remove ( & close. name )
1439
+ {
1440
+ // Tell server we're closing this statement
1441
+ server. remove_prepared_statement_from_cache ( & parse. name ) ;
1442
+
1443
+ close. rename ( & parse. name ) ;
1444
+ message = close. try_into ( ) ?
1445
+ }
1452
1446
}
1453
1447
}
1454
1448
Original file line number Diff line number Diff line change @@ -858,8 +858,8 @@ impl Parse {
858
858
/// Gets the name of the prepared statement from the buffer
859
859
pub fn get_name ( buf : & BytesMut ) -> Result < String , Error > {
860
860
let mut cursor = Cursor :: new ( buf) ;
861
- cursor . get_u8 ( ) ;
862
- cursor. get_i32 ( ) ;
861
+ // Skip the code and length
862
+ cursor. advance ( mem :: size_of :: < u8 > ( ) + mem :: size_of :: < i32 > ( ) ) ;
863
863
cursor. read_string ( )
864
864
}
865
865
@@ -1031,8 +1031,8 @@ impl Bind {
1031
1031
/// Gets the name of the prepared statement from the buffer
1032
1032
pub fn get_name ( buf : & BytesMut ) -> Result < String , Error > {
1033
1033
let mut cursor = Cursor :: new ( buf) ;
1034
- cursor . get_u8 ( ) ;
1035
- cursor. get_i32 ( ) ;
1034
+ // Skip the code and length
1035
+ cursor. advance ( mem :: size_of :: < u8 > ( ) + mem :: size_of :: < i32 > ( ) ) ;
1036
1036
cursor. read_string ( ) ?;
1037
1037
cursor. read_string ( )
1038
1038
}
@@ -1188,6 +1188,10 @@ impl Close {
1188
1188
}
1189
1189
}
1190
1190
1191
+ pub fn rename ( & mut self , name : & str ) {
1192
+ self . name = name. to_string ( ) ;
1193
+ }
1194
+
1191
1195
pub fn is_prepared_statement ( & self ) -> bool {
1192
1196
self . close_type == 'S'
1193
1197
}
You can’t perform that action at this time.
0 commit comments