Skip to content

Commit 587cbff

Browse files
committed
Restructure lazy query API
It doesn't make any sense to limit lazy queries to statments *prepared* inside a transaction. We really only care that we're in a transaction when the statement is executed. This does introduce a new runtime error if a statement prepared on connection A is executed on a transaction prepared on connection B, but I don't think anyone will *ever* run into that.
1 parent 98c92c1 commit 587cbff

6 files changed

Lines changed: 583 additions & 618 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern crate time;
1717

1818
use time::Timespec;
1919

20-
use postgres::{PostgresConnection, PostgresStatement, NoSsl};
20+
use postgres::{PostgresConnection, NoSsl};
2121
use postgres::types::ToSql;
2222

2323
struct Person {

src/error.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ pub enum PostgresError {
506506
/// The communication channel with the Postgres server has desynchronized
507507
/// due to an earlier communications error.
508508
PgStreamDesynchronized,
509+
/// A prepared statement was executed on a connection it does not belong to
510+
PgWrongConnection,
509511
}
510512

511513
impl PostgresError {
@@ -516,7 +518,11 @@ impl PostgresError {
516518
PgStreamError(ref err) => format!("{}", *err),
517519
PgStreamDesynchronized =>
518520
~"The communication stream with the Postgres server has \
519-
become desynchronized due to an earlier communications error"
521+
become desynchronized due to an earlier communications \
522+
error",
523+
PgWrongConnection =>
524+
~"A statement was executed on a connection it was not \
525+
prepared on "
520526
}
521527
}
522528
}

0 commit comments

Comments
 (0)