Skip to content

Commit

Permalink
pgsql: add test for parameter status parser
Browse files Browse the repository at this point in the history
Since we've done some changes to how the parameters are parsed, add one
more test case to check that.

Bug OISF#5579
  • Loading branch information
jufajardini committed Oct 24, 2022
1 parent 37c5d8d commit cbd13e3
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion rust/src/pgsql/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,62 @@ mod tests {
}
}

// TODO keep adding more messages
//A series of response messages from the backend:
/* R · S ·application_name S ·client_encoding UTF8 S ·DateStyle ISO, MDY S &default_transaction_read_only off S ·in_hot_standby off S ·integer_datetimes on S ·IntervalStyle postgres S ·is_superuser off S ·server_encoding UTF8 S ·server_version 14.5 S "session_authorization ctfpost S #standard_conforming_strings on S ·TimeZone Europe/Paris K ···O··Z ·I */
let buf = &[
0x52, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x53, 0x00, 0x00, 0x00, 0x16, 0x61, 0x70,
0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x00,
0x53, 0x00, 0x00, 0x00, 0x19, 0x63, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x5f, 0x65, 0x6e, 0x63, 0x6f,
0x64, 0x69, 0x6e, 0x67, 0x00, 0x55, 0x54, 0x46,
0x38, 0x00, 0x53, 0x00, 0x00, 0x00, 0x17, 0x44,
0x61, 0x74, 0x65, 0x53, 0x74, 0x79, 0x6c, 0x65,
0x00, 0x49, 0x53, 0x4f, 0x2c, 0x20, 0x4d, 0x44,
0x59, 0x00, 0x53, 0x00, 0x00, 0x00, 0x26, 0x64,
0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x74,
0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x5f,
0x6f, 0x6e, 0x6c, 0x79, 0x00, 0x6f, 0x66, 0x66,
0x00, 0x53, 0x00, 0x00, 0x00, 0x17, 0x69, 0x6e,
0x5f, 0x68, 0x6f, 0x74, 0x5f, 0x73, 0x74, 0x61,
0x6e, 0x64, 0x62, 0x79, 0x00, 0x6f, 0x66, 0x66,
0x00, 0x53, 0x00, 0x00, 0x00, 0x19, 0x69, 0x6e,
0x74, 0x65, 0x67, 0x65, 0x72, 0x5f, 0x64, 0x61,
0x74, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x00,
0x6f, 0x6e, 0x00, 0x53, 0x00, 0x00, 0x00, 0x1b,
0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c,
0x53, 0x74, 0x79, 0x6c, 0x65, 0x00, 0x70, 0x6f,
0x73, 0x74, 0x67, 0x72, 0x65, 0x73, 0x00, 0x53,
0x00, 0x00, 0x00, 0x15, 0x69, 0x73, 0x5f, 0x73,
0x75, 0x70, 0x65, 0x72, 0x75, 0x73, 0x65, 0x72,
0x00, 0x6f, 0x66, 0x66, 0x00, 0x53, 0x00, 0x00,
0x00, 0x19, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e,
0x67, 0x00, 0x55, 0x54, 0x46, 0x38, 0x00, 0x53,
0x00, 0x00, 0x00, 0x18, 0x73, 0x65, 0x72, 0x76,
0x65, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69,
0x6f, 0x6e, 0x00, 0x31, 0x34, 0x2e, 0x35, 0x00,
0x53, 0x00, 0x00, 0x00, 0x22, 0x73, 0x65, 0x73,
0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74,
0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x00, 0x63, 0x74, 0x66, 0x70, 0x6f,
0x73, 0x74, 0x00, 0x53, 0x00, 0x00, 0x00, 0x23,
0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64,
0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d,
0x69, 0x6e, 0x67, 0x5f, 0x73, 0x74, 0x72, 0x69,
0x6e, 0x67, 0x73, 0x00, 0x6f, 0x6e, 0x00, 0x53,
0x00, 0x00, 0x00, 0x1a, 0x54, 0x69, 0x6d, 0x65,
0x5a, 0x6f, 0x6e, 0x65, 0x00, 0x45, 0x75, 0x72,
0x6f, 0x70, 0x65, 0x2f, 0x50, 0x61, 0x72, 0x69,
0x73, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x0c, 0x00,
0x00, 0x0b, 0x8d, 0xcf, 0x4f, 0xb6, 0xcf, 0x5a,
0x00, 0x00, 0x00, 0x05, 0x49
];

let result = pgsql_parse_response(buf);
assert!(result.is_ok());
}

#[test]
Expand Down Expand Up @@ -2227,4 +2282,5 @@ mod tests {

assert_eq!(ok_res, result);
}

}

0 comments on commit cbd13e3

Please sign in to comment.