From cb052398d6178db3179cf6325bdb050d2f6c1163 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 7 Jun 2014 00:14:08 -0700 Subject: [PATCH] Make lazy_query take a u32 That's what the backend accepts so larger values would just overflow. --- src/lib.rs | 12 ++++++------ src/message.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d504ff4c..2e529f33 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1026,7 +1026,7 @@ impl<'conn> PostgresTransaction<'conn> { pub fn lazy_query<'trans, 'stmt>(&'trans self, stmt: &'stmt PostgresStatement, params: &[&ToSql], - row_limit: uint) + row_limit: u32) -> PostgresResult> { if self.conn as *_ != stmt.conn as *_ { @@ -1083,7 +1083,7 @@ impl<'conn> PostgresStatement<'conn> { Ok(()) } - fn inner_execute(&self, portal_name: &str, row_limit: uint, params: &[&ToSql]) + fn inner_execute(&self, portal_name: &str, row_limit: u32, params: &[&ToSql]) -> PostgresResult<()> { if self.param_types.len() != params.len() { return Err(PgWrongParamCount { @@ -1113,7 +1113,7 @@ impl<'conn> PostgresStatement<'conn> { }, Execute { portal: portal_name, - max_rows: row_limit as i32 + max_rows: row_limit }, Sync])); @@ -1127,7 +1127,7 @@ impl<'conn> PostgresStatement<'conn> { } } - fn lazy_query<'a>(&'a self, row_limit: uint, params: &[&ToSql]) + fn lazy_query<'a>(&'a self, row_limit: u32, params: &[&ToSql]) -> PostgresResult> { let id = self.next_portal_id.get(); self.next_portal_id.set(id + 1); @@ -1254,7 +1254,7 @@ pub struct PostgresRows<'stmt> { stmt: &'stmt PostgresStatement<'stmt>, name: String, data: RingBuf>>>, - row_limit: uint, + row_limit: u32, more_rows: bool, finished: bool, } @@ -1313,7 +1313,7 @@ impl<'stmt> PostgresRows<'stmt> { try_pg!(self.stmt.conn.write_messages([ Execute { portal: self.name.as_slice(), - max_rows: self.row_limit as i32 + max_rows: self.row_limit }, Sync])); self.read_rows() diff --git a/src/message.rs b/src/message.rs index 14bf5a1a..8fabf493 100644 --- a/src/message.rs +++ b/src/message.rs @@ -92,7 +92,7 @@ pub enum FrontendMessage<'a> { }, Execute { pub portal: &'a str, - pub max_rows: i32 + pub max_rows: u32 }, Parse { pub name: &'a str, @@ -185,7 +185,7 @@ impl WriteMessage for W { Execute { portal, max_rows } => { ident = Some('E'); try!(buf.write_cstr(portal)); - try!(buf.write_be_i32(max_rows)); + try!(buf.write_be_u32(max_rows)); } Parse { name, query, param_types } => { ident = Some('P');