diff --git a/src/lib.rs b/src/lib.rs index 2db90530..7f817b5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2066,120 +2066,6 @@ impl<'trans, 'stmt> Iterator for LazyRows<'trans, 'stmt> { } } -/* - pub fn execute(&self, rows: I) -> Result - where I: Iterator, J: StreamIterator { - let mut conn = self.conn.conn.borrow_mut(); - - debug!("executing COPY IN statement {}", self.name); - try!(conn.write_messages(&[ - Bind { - portal: "", - statement: &self.name, - formats: &[], - values: &[], - result_formats: &[] - }, - Execute { - portal: "", - max_rows: 0, - }, - Sync])); - - match try!(conn.read_message()) { - BindComplete => {}, - ErrorResponse { fields } => { - try!(conn.wait_for_ready()); - return DbError::new(fields); - } - _ => { - conn.desynchronized = true; - return Err(Error::IoError(bad_response())); - } - } - - match try!(conn.read_message()) { - CopyInResponse { .. } => {} - _ => { - conn.desynchronized = true; - return Err(Error::IoError(bad_response())); - } - } - - let mut buf = vec![]; - let _ = buf.write_all(b"PGCOPY\n\xff\r\n\x00"); - let _ = buf.write_i32::(0); - let _ = buf.write_i32::(0); - - 'l: for mut row in rows { - let _ = buf.write_i16::(self.column_types.len() as i16); - - let mut types = self.column_types.iter(); - loop { - match (row.next(), types.next()) { - (Some(val), Some(ty)) => { - let mut inner_buf = vec![]; - match val.to_sql_checked(ty, &mut inner_buf, &SessionInfo::new(&*conn)) { - Ok(IsNull::Yes) => { - let _ = buf.write_i32::(-1); - } - Ok(IsNull::No) => { - let _ = buf.write_i32::(inner_buf.len() as i32); - let _ = buf.write_all(&inner_buf); - } - Err(err) => { - // FIXME this is not the right way to handle this - try_desync!(conn, conn.stream.write_message( - &CopyFail { - message: &err.to_string(), - })); - break 'l; - } - } - } - (Some(_), None) | (None, Some(_)) => { - try_desync!(conn, conn.stream.write_message( - &CopyFail { - message: "Invalid column count", - })); - break 'l; - } - (None, None) => break - } - } - - try_desync!(conn, conn.stream.write_message( - &CopyData { - data: &buf - })); - buf.clear(); - } - - let _ = buf.write_i16::(-1); - try!(conn.write_messages(&[ - CopyData { - data: &buf, - }, - CopyDone, - Sync])); - - let num = match try!(conn.read_message()) { - CommandComplete { tag } => util::parse_update_count(tag), - ErrorResponse { fields } => { - try!(conn.wait_for_ready()); - return DbError::new(fields); - } - _ => { - conn.desynchronized = true; - return Err(Error::IoError(bad_response())); - } - }; - - try!(conn.wait_for_ready()); - Ok(num) - } -*/ - /// A trait allowing abstraction over connections and transactions pub trait GenericConnection { /// Like `Connection::prepare`.