Less dirty servers & fix python

This commit is contained in:
Lev Kokotov
2022-02-03 18:02:50 -08:00
parent baf2852f03
commit 83daaf92d1
7 changed files with 34 additions and 0 deletions

View File

@@ -16,6 +16,18 @@ pub async fn auth_ok(stream: &mut TcpStream) -> Result<(), Error> {
Ok(write_all(stream, auth_ok).await?)
}
pub async fn server_parameters(stream: &mut TcpStream) -> Result<(), Error> {
let client_encoding = BytesMut::from(&b"client_encoding\0UTF8\0"[..]);
let len = client_encoding.len() as i32 + 4; // TODO: add more parameters here
let mut res = BytesMut::with_capacity(len as usize + 1);
res.put_u8(b'S');
res.put_i32(len);
res.put_slice(&client_encoding[..]);
Ok(write_all(stream, res).await?)
}
pub async fn ready_for_query(stream: &mut TcpStream) -> Result<(), Error> {
let mut bytes = BytesMut::with_capacity(5);