Skip to content

Commit 5e36320

Browse files
committed
Fix some types to match the postgres implementation
1 parent cb05239 commit 5e36320

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,11 +1022,12 @@ impl<'conn> PostgresTransaction<'conn> {
10221022
///
10231023
/// No more than `row_limit` rows will be stored in memory at a time. Rows
10241024
/// will be pulled from the database in batches of `row_limit` as needed.
1025-
/// If `row_limit` is 0, `lazy_query` is equivalent to `query`.
1025+
/// If `row_limit` is less than or equal to 0, `lazy_query` is equivalent
1026+
/// to `query`.
10261027
pub fn lazy_query<'trans, 'stmt>(&'trans self,
10271028
stmt: &'stmt PostgresStatement,
10281029
params: &[&ToSql],
1029-
row_limit: u32)
1030+
row_limit: i32)
10301031
-> PostgresResult<PostgresLazyRows
10311032
<'trans, 'stmt>> {
10321033
if self.conn as *_ != stmt.conn as *_ {
@@ -1083,7 +1084,7 @@ impl<'conn> PostgresStatement<'conn> {
10831084
Ok(())
10841085
}
10851086

1086-
fn inner_execute(&self, portal_name: &str, row_limit: u32, params: &[&ToSql])
1087+
fn inner_execute(&self, portal_name: &str, row_limit: i32, params: &[&ToSql])
10871088
-> PostgresResult<()> {
10881089
if self.param_types.len() != params.len() {
10891090
return Err(PgWrongParamCount {
@@ -1127,7 +1128,7 @@ impl<'conn> PostgresStatement<'conn> {
11271128
}
11281129
}
11291130

1130-
fn lazy_query<'a>(&'a self, row_limit: u32, params: &[&ToSql])
1131+
fn lazy_query<'a>(&'a self, row_limit: i32, params: &[&ToSql])
11311132
-> PostgresResult<PostgresRows<'a>> {
11321133
let id = self.next_portal_id.get();
11331134
self.next_portal_id.set(id + 1);
@@ -1254,7 +1255,7 @@ pub struct PostgresRows<'stmt> {
12541255
stmt: &'stmt PostgresStatement<'stmt>,
12551256
name: String,
12561257
data: RingBuf<Vec<Option<Vec<u8>>>>,
1257-
row_limit: u32,
1258+
row_limit: i32,
12581259
more_rows: bool,
12591260
finished: bool,
12601261
}

src/message.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ pub enum FrontendMessage<'a> {
9292
},
9393
Execute {
9494
pub portal: &'a str,
95-
pub max_rows: u32
95+
pub max_rows: i32
9696
},
9797
Parse {
9898
pub name: &'a str,
9999
pub query: &'a str,
100-
pub param_types: &'a [i32]
100+
pub param_types: &'a [Oid]
101101
},
102102
PasswordMessage {
103103
pub password: &'a str
@@ -185,15 +185,15 @@ impl<W: Writer> WriteMessage for W {
185185
Execute { portal, max_rows } => {
186186
ident = Some('E');
187187
try!(buf.write_cstr(portal));
188-
try!(buf.write_be_u32(max_rows));
188+
try!(buf.write_be_i32(max_rows));
189189
}
190190
Parse { name, query, param_types } => {
191191
ident = Some('P');
192192
try!(buf.write_cstr(name));
193193
try!(buf.write_cstr(query));
194194
try!(buf.write_be_i16(param_types.len() as i16));
195195
for ty in param_types.iter() {
196-
try!(buf.write_be_i32(*ty));
196+
try!(buf.write_be_u32(*ty));
197197
}
198198
}
199199
PasswordMessage { password } => {

0 commit comments

Comments
 (0)