File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
sqlx-mysql/src/protocol/statement Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -16,22 +16,28 @@ pub(crate) struct PrepareOk {
16
16
}
17
17
18
18
impl Decode < ' _ , Capabilities > for PrepareOk {
19
- fn decode_with ( mut buf : Bytes , _: Capabilities ) -> Result < Self , Error > {
20
- let status = buf. get_u8 ( ) ;
19
+ fn decode_with ( buf : Bytes , _: Capabilities ) -> Result < Self , Error > {
20
+ const SIZE : usize = 12 ;
21
+
22
+ let mut slice = buf. get ( ..SIZE ) . ok_or_else ( || {
23
+ err_protocol ! ( "PrepareOk expected 12 bytes but got {} bytes" , buf. len( ) )
24
+ } ) ?;
25
+
26
+ let status = slice. get_u8 ( ) ;
21
27
if status != 0x00 {
22
28
return Err ( err_protocol ! (
23
29
"expected 0x00 (COM_STMT_PREPARE_OK) but found 0x{:02x}" ,
24
30
status
25
31
) ) ;
26
32
}
27
33
28
- let statement_id = buf . get_u32_le ( ) ;
29
- let columns = buf . get_u16_le ( ) ;
30
- let params = buf . get_u16_le ( ) ;
34
+ let statement_id = slice . get_u32_le ( ) ;
35
+ let columns = slice . get_u16_le ( ) ;
36
+ let params = slice . get_u16_le ( ) ;
31
37
32
- buf . advance ( 1 ) ; // reserved: string<1>
38
+ slice . advance ( 1 ) ; // reserved: string<1>
33
39
34
- let warnings = buf . get_u16_le ( ) ;
40
+ let warnings = slice . get_u16_le ( ) ;
35
41
36
42
Ok ( Self {
37
43
statement_id,
You can’t perform that action at this time.
0 commit comments