Delete old copy in logic

This commit is contained in:
Steven Fackler 2015-05-25 20:43:55 -07:00
parent a5c1d0ddce
commit b75a63d384

View File

@ -2066,120 +2066,6 @@ impl<'trans, 'stmt> Iterator for LazyRows<'trans, 'stmt> {
} }
} }
/*
pub fn execute<I, J>(&self, rows: I) -> Result<u64>
where I: Iterator<Item=J>, 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::<BigEndian>(0);
let _ = buf.write_i32::<BigEndian>(0);
'l: for mut row in rows {
let _ = buf.write_i16::<BigEndian>(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::<BigEndian>(-1);
}
Ok(IsNull::No) => {
let _ = buf.write_i32::<BigEndian>(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::<BigEndian>(-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 /// A trait allowing abstraction over connections and transactions
pub trait GenericConnection { pub trait GenericConnection {
/// Like `Connection::prepare`. /// Like `Connection::prepare`.