mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-28 10:30:40 +00:00
Use proper error code for BeMessage error responses (#3240)
Based on https://github.com/neondatabase/neon/pull/3227#discussion_r1059430067 Seems that the constant, used for internal error during BeMessage error response serialization is incorrect. Currently used one is `CXX000`, yet all docs mention `XX000` instead: * https://www.postgresql.org/docs/current/errcodes-appendix.html * https://docs.rs/postgres/latest/postgres/error/struct.SqlState.html#associatedconstant.INTERNAL_ERROR I have checked it with the patch and logs described in https://github.com/neondatabase/neon/pull/3227#discussion_r1059949982
This commit is contained in:
@@ -626,6 +626,8 @@ fn read_cstr(buf: &mut Bytes) -> anyhow::Result<Bytes> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
const SQLSTATE_INTERNAL_ERROR: &str = "XX000\0";
|
||||
|
||||
impl<'a> BeMessage<'a> {
|
||||
/// Write message to the given buf.
|
||||
// Unlike the reading side, we use BytesMut
|
||||
@@ -776,7 +778,7 @@ impl<'a> BeMessage<'a> {
|
||||
buf.put_slice(b"ERROR\0");
|
||||
|
||||
buf.put_u8(b'C'); // SQLSTATE error code
|
||||
buf.put_slice(b"CXX000\0");
|
||||
buf.put_slice(SQLSTATE_INTERNAL_ERROR.as_bytes());
|
||||
|
||||
buf.put_u8(b'M'); // the message
|
||||
write_cstr(error_msg, buf)?;
|
||||
@@ -799,7 +801,7 @@ impl<'a> BeMessage<'a> {
|
||||
buf.put_slice(b"NOTICE\0");
|
||||
|
||||
buf.put_u8(b'C'); // SQLSTATE error code
|
||||
buf.put_slice(b"CXX000\0");
|
||||
buf.put_slice(SQLSTATE_INTERNAL_ERROR.as_bytes());
|
||||
|
||||
buf.put_u8(b'M'); // the message
|
||||
write_cstr(error_msg.as_bytes(), buf)?;
|
||||
|
||||
Reference in New Issue
Block a user