Skip to content

Commit e924529

Browse files
committed
Store row description in statement
Will be useful for FromSql binary formats. CC #7
1 parent 8b787cf commit e924529

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/lib.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,19 @@ impl PostgresConnection {
288288
resp => fail!("Bad response: %?", resp.to_str())
289289
});
290290
291-
match_read_message!(self, {
292-
RowDescription {_} | NoData => (),
291+
let result_desc = match_read_message!(self, {
292+
RowDescription { descriptions } => descriptions,
293+
NoData => ~[],
293294
resp => fail!("Bad response: %?", resp.to_str())
294-
})
295+
});
295296
296297
self.wait_for_ready();
297298
298299
Ok(PostgresStatement {
299300
conn: self,
300301
name: stmt_name,
301302
param_types: param_types,
303+
result_desc: result_desc,
302304
next_portal_id: Cell::new(0)
303305
})
304306
}
@@ -350,12 +352,10 @@ impl PostgresConnection {
350352
}
351353
352354
fn wait_for_ready(&self) {
353-
loop {
354-
match_read_message!(self, {
355-
ReadyForQuery {_} => break,
356-
resp => fail!("Bad response: %?", resp.to_str())
357-
})
358-
}
355+
match_read_message!(self, {
356+
ReadyForQuery {_} => (),
357+
resp => fail!("Bad response: %?", resp.to_str())
358+
})
359359
}
360360
}
361361
@@ -404,6 +404,7 @@ pub struct PostgresStatement<'self> {
404404
priv conn: &'self PostgresConnection,
405405
priv name: ~str,
406406
priv param_types: ~[Oid],
407+
priv result_desc: ~[RowDescriptionEntry],
407408
priv next_portal_id: Cell<uint>
408409
}
409410
@@ -594,8 +595,8 @@ impl<'self> Iterator<PostgresRow> for PostgresResult<'self> {
594595
self.execute();
595596
}
596597
597-
do self.data.pop_front().chain |row| {
598-
Some(PostgresRow { data: row })
598+
do self.data.pop_front().map_move |row| {
599+
PostgresRow { data: row }
599600
}
600601
}
601602
}

0 commit comments

Comments
 (0)