Make lazy_query take a u32

That's what the backend accepts so larger values would just overflow.
This commit is contained in:
Steven Fackler 2014-06-07 00:14:08 -07:00
parent aa457cb5be
commit cb052398d6
2 changed files with 8 additions and 8 deletions

View File

@ -1026,7 +1026,7 @@ impl<'conn> PostgresTransaction<'conn> {
pub fn lazy_query<'trans, 'stmt>(&'trans self, pub fn lazy_query<'trans, 'stmt>(&'trans self,
stmt: &'stmt PostgresStatement, stmt: &'stmt PostgresStatement,
params: &[&ToSql], params: &[&ToSql],
row_limit: uint) row_limit: u32)
-> PostgresResult<PostgresLazyRows -> PostgresResult<PostgresLazyRows
<'trans, 'stmt>> { <'trans, 'stmt>> {
if self.conn as *_ != stmt.conn as *_ { if self.conn as *_ != stmt.conn as *_ {
@ -1083,7 +1083,7 @@ impl<'conn> PostgresStatement<'conn> {
Ok(()) 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<()> { -> PostgresResult<()> {
if self.param_types.len() != params.len() { if self.param_types.len() != params.len() {
return Err(PgWrongParamCount { return Err(PgWrongParamCount {
@ -1113,7 +1113,7 @@ impl<'conn> PostgresStatement<'conn> {
}, },
Execute { Execute {
portal: portal_name, portal: portal_name,
max_rows: row_limit as i32 max_rows: row_limit
}, },
Sync])); 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<PostgresRows<'a>> { -> PostgresResult<PostgresRows<'a>> {
let id = self.next_portal_id.get(); let id = self.next_portal_id.get();
self.next_portal_id.set(id + 1); self.next_portal_id.set(id + 1);
@ -1254,7 +1254,7 @@ pub struct PostgresRows<'stmt> {
stmt: &'stmt PostgresStatement<'stmt>, stmt: &'stmt PostgresStatement<'stmt>,
name: String, name: String,
data: RingBuf<Vec<Option<Vec<u8>>>>, data: RingBuf<Vec<Option<Vec<u8>>>>,
row_limit: uint, row_limit: u32,
more_rows: bool, more_rows: bool,
finished: bool, finished: bool,
} }
@ -1313,7 +1313,7 @@ impl<'stmt> PostgresRows<'stmt> {
try_pg!(self.stmt.conn.write_messages([ try_pg!(self.stmt.conn.write_messages([
Execute { Execute {
portal: self.name.as_slice(), portal: self.name.as_slice(),
max_rows: self.row_limit as i32 max_rows: self.row_limit
}, },
Sync])); Sync]));
self.read_rows() self.read_rows()

View File

@ -92,7 +92,7 @@ pub enum FrontendMessage<'a> {
}, },
Execute { Execute {
pub portal: &'a str, pub portal: &'a str,
pub max_rows: i32 pub max_rows: u32
}, },
Parse { Parse {
pub name: &'a str, pub name: &'a str,
@ -185,7 +185,7 @@ impl<W: Writer> WriteMessage for W {
Execute { portal, max_rows } => { Execute { portal, max_rows } => {
ident = Some('E'); ident = Some('E');
try!(buf.write_cstr(portal)); try!(buf.write_cstr(portal));
try!(buf.write_be_i32(max_rows)); try!(buf.write_be_u32(max_rows));
} }
Parse { name, query, param_types } => { Parse { name, query, param_types } => {
ident = Some('P'); ident = Some('P');