diff --git a/src/lib.rs b/src/lib.rs index ff9714cd..24605a90 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -274,7 +274,7 @@ impl PostgresNoticeHandler for DefaultNoticeHandler { /// An asynchronous notification pub struct PostgresNotification { /// The process ID of the notifying backend process - pub pid: i32, + pub pid: u32, /// The name of the channel that the notify has been raised on pub channel: String, /// The "payload" string passed from the notifying process @@ -301,9 +301,9 @@ impl<'conn> Iterator for PostgresNotifications<'conn> { /// Contains information necessary to cancel queries for a session pub struct PostgresCancelData { /// The process ID of the session - pub process_id: i32, + pub process_id: u32, /// The secret key for the session - pub secret_key: i32, + pub secret_key: u32, } /// Attempts to cancel an in-progress query. diff --git a/src/message.rs b/src/message.rs index 9e87bb26..66b00824 100644 --- a/src/message.rs +++ b/src/message.rs @@ -3,9 +3,9 @@ use std::mem; use types::Oid; -pub static PROTOCOL_VERSION: i32 = 0x0003_0000; -pub static CANCEL_CODE: i32 = 80877102; -pub static SSL_CODE: i32 = 80877103; +pub static PROTOCOL_VERSION: u32 = 0x0003_0000; +pub static CANCEL_CODE: u32 = 80877102; +pub static SSL_CODE: u32 = 80877103; pub enum BackendMessage { AuthenticationCleartextPassword, @@ -18,8 +18,8 @@ pub enum BackendMessage { AuthenticationSCMCredential, AuthenticationSSPI, BackendKeyData { - pub process_id: i32, - pub secret_key: i32 + pub process_id: u32, + pub secret_key: u32 }, BindComplete, CloseComplete, @@ -38,7 +38,7 @@ pub enum BackendMessage { pub fields: Vec<(u8, String)> }, NotificationResponse { - pub pid: i32, + pub pid: u32, pub channel: String, pub payload: String, }, @@ -78,9 +78,9 @@ pub enum FrontendMessage<'a> { pub result_formats: &'a [i16] }, CancelRequest { - pub code: i32, - pub process_id: i32, - pub secret_key: i32, + pub code: u32, + pub process_id: u32, + pub secret_key: u32, }, Close { pub variant: u8, @@ -106,10 +106,10 @@ pub enum FrontendMessage<'a> { pub query: &'a str }, SslRequest { - pub code: i32 + pub code: u32 }, StartupMessage { - pub version: i32, + pub version: u32, pub parameters: &'a [(String, String)] }, Sync, @@ -168,9 +168,9 @@ impl WriteMessage for W { } } CancelRequest { code, process_id, secret_key } => { - try!(buf.write_be_i32(code)); - try!(buf.write_be_i32(process_id)); - try!(buf.write_be_i32(secret_key)); + try!(buf.write_be_u32(code)); + try!(buf.write_be_u32(process_id)); + try!(buf.write_be_u32(secret_key)); } Close { variant, name } => { ident = Some('C'); @@ -205,14 +205,14 @@ impl WriteMessage for W { try!(buf.write_cstr(query)); } StartupMessage { version, parameters } => { - try!(buf.write_be_i32(version)); + try!(buf.write_be_u32(version)); for &(ref k, ref v) in parameters.iter() { try!(buf.write_cstr(k.as_slice())); try!(buf.write_cstr(v.as_slice())); } try!(buf.write_u8(0)); } - SslRequest { code } => try!(buf.write_be_i32(code)), + SslRequest { code } => try!(buf.write_be_u32(code)), Sync => { ident = Some('S'); } @@ -261,7 +261,7 @@ impl ReadMessage for R { fn read_message(&mut self) -> IoResult { let ident = try!(self.read_u8()); // subtract size of length value - let len = try!(self.read_be_i32()) as uint - mem::size_of::(); + let len = try!(self.read_be_u32()) as uint - mem::size_of::(); let mut buf = MemReader::new(try!(self.read_exact(len))); let ret = match ident as char { @@ -269,7 +269,7 @@ impl ReadMessage for R { '2' => BindComplete, '3' => CloseComplete, 'A' => NotificationResponse { - pid: try!(buf.read_be_i32()), + pid: try!(buf.read_be_u32()), channel: try!(buf.read_cstr()), payload: try!(buf.read_cstr()) }, @@ -278,8 +278,8 @@ impl ReadMessage for R { 'E' => ErrorResponse { fields: try!(read_fields(&mut buf)) }, 'I' => EmptyQueryResponse, 'K' => BackendKeyData { - process_id: try!(buf.read_be_i32()), - secret_key: try!(buf.read_be_i32()) + process_id: try!(buf.read_be_u32()), + secret_key: try!(buf.read_be_u32()) }, 'n' => NoData, 'N' => NoticeResponse { fields: try!(read_fields(&mut buf)) },