Skip to content

drop_* methods do not drop multiple resultsets #23

@jonhoo

Description

@jonhoo

While trying to minimize a test case for #22, I discovered that the issue really originated further "up" in my code. Specifically, if you use any of the drop_* methods to execute multiple ;-separated statements, only the first actually gets dropped. Consider the following code:

let mut core = tokio_core::reactor::Core::new().unwrap();
let mut opts = my::OptsBuilder::new();
opts.ip_or_hostname("localhost")
    .user(Some("root"))
    .pass(Some("password"))
    .tcp_nodelay(true)
    .db_name(Some("mysql"));
let c = my::Pool::new(opts, &core.handle());
let c = c.get_conn()
    .and_then(|c| {
        c.drop_query(
            "UPDATE time_zone SET Time_zone_id = 1 WHERE Time_zone_id = 1; \
             UPDATE time_zone SET Time_zone_id = 1 WHERE Time_zone_id = 1;",
        )
    })
    .and_then(|c| c.prep_exec("SELECT 1", ()));
core.run(c).unwrap();

This code hangs since the SELECT is waiting for the next resultset, but is instead met with the response to the UPDATE. To see a crash, put the update in a transaction:

let c = c.get_conn()
    .and_then(|c| {
        c.start_transaction(my::TransactionOptions::new())
            .and_then(|t| {
                t.drop_query(
                    "UPDATE time_zone SET Time_zone_id = 1 WHERE Time_zone_id = 1; \
                     UPDATE time_zone SET Time_zone_id = 1 WHERE Time_zone_id = 1;",
                )
            })
            .and_then(|t| t.commit())
    })
    .and_then(|c| c.prep_exec("SELECT 1", ()));
core.run(c).unwrap();

Crashes with:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error(Io(Custom { kind: UnexpectedEof, error: StringError("failed to fill whole buffer") }), State { next_error: None, backtrace: Some(stack backtrace:
   0:     0x563b61cd96ce - backtrace::backtrace::libunwind::trace::h8654a9d0555d5a01
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.5/src/backtrace/libunwind.rs:53
                         - backtrace::backtrace::trace::h97b4908a240a2f61
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.5/src/backtrace/mod.rs:42
   1:     0x563b61cd8035 - backtrace::capture::Backtrace::new_unresolved::hec1ca9ceaee1db45
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.5/src/capture.rs:88
                         - backtrace::capture::Backtrace::new::h7fa080eeed827e9d
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.5/src/capture.rs:63
   2:     0x563b61cd7a7a - error_chain::make_backtrace::hffb33833ee042156
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.11.0/src/lib.rs:616
   3:     0x563b61cd7b18 - <error_chain::State as core::default::Default>::default::h1a16302fda4394fd
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.11.0/src/lib.rs:710
   4:     0x563b61be4b10 - mysql_async::errors::Error::from_kind::ha3dc499d9ed61c6a
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/mysql_async-0.14.0/<impl_error_chain_processed macros>:53
                         - <mysql_async::errors::Error as core::convert::From<std::io::error::Error>>::from::hc00dcfd143ecae64
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/mysql_async-0.14.0/src/errors.rs:16
                         - mysql_async::queryable::stmt::InnerStmt::new::ha7a178ed950633da
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/mysql_async-0.14.0/src/queryable/stmt.rs:50
   5:     0x563b61b64a42 - mysql_async::connection_like::ConnectionLike::prepare_stmt::{{closure}}::hb5b23a2d9383914c
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/mysql_async-0.14.0/src/connection_like/mod.rs:280
                         - <futures::future::and_then::AndThen<A, B, F> as futures::future::Future>::poll::{{closure}}::{{closure}}::hcd418c8f3cc4d1a8
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.19/src/future/and_then.rs:34
                         - <core::result::Result<T, E>>::map::h73212ff31b4c4af9
                        at /checkout/src/libcore/result.rs:468
                         - <futures::future::and_then::AndThen<A, B, F> as futures::future::Future>::poll::{{closure}}::h52ec85bfee8271dc
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.19/src/future/and_then.rs:33
                         - <futures::future::chain::Chain<A, B, C>>::poll::h189cc1106a92156f
                        at /home/jon/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.19/src/future/chain.rs:39

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions