mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-04 20:12:54 +00:00
Parse cancel message in pq_proto (#1060)
This commit is contained in:
@@ -113,31 +113,31 @@ impl ProxyConnection {
|
||||
let mut encrypted = false;
|
||||
|
||||
loop {
|
||||
let mut msg = match self.pgb.read_message()? {
|
||||
Some(Fe::StartupMessage(msg)) => msg,
|
||||
let msg = match self.pgb.read_message()? {
|
||||
Some(Fe::StartupPacket(msg)) => msg,
|
||||
None => bail!("connection is lost"),
|
||||
bad => bail!("unexpected message type: {:?}", bad),
|
||||
};
|
||||
println!("got message: {:?}", msg);
|
||||
|
||||
match msg.kind {
|
||||
StartupRequestCode::NegotiateGss => {
|
||||
match msg {
|
||||
FeStartupPacket::GssEncRequest => {
|
||||
self.pgb.write_message(&Be::EncryptionResponse(false))?;
|
||||
}
|
||||
StartupRequestCode::NegotiateSsl => {
|
||||
FeStartupPacket::SslRequest => {
|
||||
self.pgb.write_message(&Be::EncryptionResponse(have_tls))?;
|
||||
if have_tls {
|
||||
self.pgb.start_tls()?;
|
||||
encrypted = true;
|
||||
}
|
||||
}
|
||||
StartupRequestCode::Normal => {
|
||||
FeStartupPacket::StartupMessage { mut params, .. } => {
|
||||
if have_tls && !encrypted {
|
||||
bail!("must connect with TLS");
|
||||
}
|
||||
|
||||
let mut get_param = |key| {
|
||||
msg.params
|
||||
params
|
||||
.remove(key)
|
||||
.ok_or_else(|| anyhow!("{} is missing in startup packet", key))
|
||||
};
|
||||
@@ -145,7 +145,9 @@ impl ProxyConnection {
|
||||
return Ok((get_param("user")?, get_param("database")?));
|
||||
}
|
||||
// TODO: implement proper stmt cancellation
|
||||
StartupRequestCode::Cancel => bail!("query cancellation is not supported"),
|
||||
FeStartupPacket::CancelRequest { .. } => {
|
||||
bail!("query cancellation is not supported")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user