Handle COPY IN in batch_execute
This commit is contained in:
parent
58dd5fe12b
commit
b69ae99a51
@ -690,6 +690,13 @@ impl InnerPostgresConnection {
|
||||
opt.map(|b| String::from_utf8_lossy(b[]).into_string())
|
||||
}).collect());
|
||||
}
|
||||
CopyInResponse { .. } => {
|
||||
try_pg!(self.write_messages([
|
||||
CopyFail {
|
||||
message: "COPY queries cannot be directly executed",
|
||||
},
|
||||
Sync]));
|
||||
}
|
||||
ErrorResponse { fields } => {
|
||||
try!(self.wait_for_ready());
|
||||
return PostgresDbError::new(fields);
|
||||
|
@ -750,3 +750,14 @@ fn test_copy_in_bad_column_count() {
|
||||
|
||||
or_fail!(conn.execute("SELECT 1", []));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_batch_execute_copy_from_err() {
|
||||
let conn = or_fail!(PostgresConnection::connect("postgres://postgres@localhost", &NoSsl));
|
||||
or_fail!(conn.execute("CREATE TEMPORARY TABLE foo (id INT)", []));
|
||||
match conn.batch_execute("COPY foo (id) FROM STDIN") {
|
||||
Err(PgDbError(ref err)) if err.message[].contains("COPY") => {}
|
||||
Err(err) => fail!("Unexptected error {}", err),
|
||||
_ => fail!("Expected error"),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user