File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -832,10 +832,21 @@ impl TryFrom<&BytesMut> for Bind {
832832
833833 for _ in 0 ..num_param_values {
834834 let param_len = cursor. get_i32 ( ) ;
835- let mut param = BytesMut :: with_capacity ( param_len as usize ) ;
836- param. resize ( param_len as usize , b'0' ) ;
837- cursor. copy_to_slice ( & mut param) ;
838- param_values. push ( ( param_len, param) ) ;
835+ // There is special occasion when the parameter is NULL
836+ // In that case, param length is defined as -1
837+ // So if the passed parameter len is over 0
838+ if param_len > 0 {
839+ let mut param = BytesMut :: with_capacity ( param_len as usize ) ;
840+ param. resize ( param_len as usize , b'0' ) ;
841+ cursor. copy_to_slice ( & mut param) ;
842+ // we push and the length and the parameter into vector
843+ param_values. push ( ( param_len, param) ) ;
844+ } else {
845+ // otherwise we push a tuple with -1 and 0-len BytesMut
846+ // which means that after encountering -1 postgres proceeds
847+ // to processing another parameter
848+ param_values. push ( ( param_len, BytesMut :: new ( ) ) ) ;
849+ }
839850 }
840851
841852 let num_result_column_format_codes = cursor. get_i16 ( ) ;
You can’t perform that action at this time.
0 commit comments