Skip to content

Fixes for nightly #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 29 additions & 34 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,8 @@ impl IntoConnectParams for Url {
UserInfo { user: user, password: pass }
});

let database = if !path.is_empty() {
// path contains the leading /
let (_, path) = path[].slice_shift_char();
Some(path.into_string())
} else {
Option::None
};
// path contains the leading /
let database = path.slice_shift_char().map(|(_, path)| path.into_string());

Ok(ConnectParams {
target: target,
Expand Down Expand Up @@ -271,7 +266,7 @@ pub struct CancelData {
/// let conn = Connection::connect(url, &SslMode::None).unwrap();
/// let cancel_data = conn.cancel_data();
/// spawn(proc() {
/// conn.execute("SOME EXPENSIVE QUERY", []).unwrap();
/// conn.execute("SOME EXPENSIVE QUERY", &[]).unwrap();
/// });
/// # let _ =
/// postgres::cancel_query(url, &SslMode::None, cancel_data);
Expand Down Expand Up @@ -351,7 +346,7 @@ impl InnerConnection {
Option::None => {}
}

try!(conn.write_messages([StartupMessage {
try!(conn.write_messages(&[StartupMessage {
version: message::PROTOCOL_VERSION,
parameters: options[]
}]));
Expand Down Expand Up @@ -410,7 +405,7 @@ impl InnerConnection {
AuthenticationOk => return Ok(()),
AuthenticationCleartextPassword => {
let pass = try!(user.password.ok_or(ConnectError::MissingPassword));
try!(self.write_messages([PasswordMessage {
try!(self.write_messages(&[PasswordMessage {
password: pass[],
}]));
}
Expand All @@ -422,9 +417,9 @@ impl InnerConnection {
let output = hasher.finalize()[].to_hex();
let hasher = Hasher::new(MD5);
hasher.update(output.as_bytes());
hasher.update(salt);
hasher.update(&salt);
let output = format!("md5{}", hasher.finalize()[].to_hex());
try!(self.write_messages([PasswordMessage {
try!(self.write_messages(&[PasswordMessage {
password: output[]
}]));
}
Expand Down Expand Up @@ -458,11 +453,11 @@ impl InnerConnection {
let stmt_name = format!("s{}", self.next_stmt_id);
self.next_stmt_id += 1;

try!(self.write_messages([
try!(self.write_messages(&[
Parse {
name: stmt_name[],
query: query,
param_types: []
param_types: &[]
},
Describe {
variant: b'S',
Expand Down Expand Up @@ -548,7 +543,7 @@ impl InnerConnection {
}

fn close_statement(&mut self, stmt_name: &str) -> Result<()> {
try!(self.write_messages([
try!(self.write_messages(&[
Close {
variant: b'S',
name: stmt_name,
Expand Down Expand Up @@ -605,7 +600,7 @@ impl InnerConnection {

fn quick_query(&mut self, query: &str) -> Result<Vec<Vec<Option<String>>>> {
check_desync!(self);
try!(self.write_messages([Query { query: query }]));
try!(self.write_messages(&[Query { query: query }]));

let mut result = vec![];
loop {
Expand All @@ -617,7 +612,7 @@ impl InnerConnection {
}).collect());
}
CopyInResponse { .. } => {
try!(self.write_messages([
try!(self.write_messages(&[
CopyFail {
message: "COPY queries cannot be directly executed",
},
Expand All @@ -636,7 +631,7 @@ impl InnerConnection {
fn finish_inner(&mut self) -> Result<()> {
check_desync!(self);
self.canary = 0;
try!(self.write_messages([Terminate]));
try!(self.write_messages(&[Terminate]));
Ok(())
}
}
Expand Down Expand Up @@ -762,9 +757,9 @@ impl Connection {
/// try!(conn.execute("CREATE TABLE foo (
/// bar INT PRIMARY KEY,
/// baz VARCHAR
/// )", []));
/// )", &[]));
///
/// let stmt = try!(conn.prepare_copy_in("foo", ["bar", "baz"]));
/// let stmt = try!(conn.prepare_copy_in("foo", &["bar", "baz"]));
/// let data: &[&[&ToSql]] = &[&[&0i32, &"blah".into_string()],
/// &[&1i32, &None::<String>]];
/// try!(stmt.execute(data.iter().map(|r| r.iter().map(|&e| e))));
Expand Down Expand Up @@ -796,7 +791,7 @@ impl Connection {
/// # fn foo() -> Result<(), postgres::Error> {
/// # let conn = Connection::connect("", &SslMode::None).unwrap();
/// let trans = try!(conn.transaction());
/// try!(trans.execute("UPDATE foo SET bar = 10", []));
/// try!(trans.execute("UPDATE foo SET bar = 10", &[]));
/// // ...
///
/// try!(trans.commit());
Expand Down Expand Up @@ -1095,13 +1090,13 @@ impl<'conn> Statement<'conn> {
values.push(try!(param.to_sql(ty)));
};

try!(conn.write_messages([
try!(conn.write_messages(&[
Bind {
portal: portal_name,
statement: self.name[],
formats: [1],
formats: &[1],
values: values[],
result_formats: [1]
result_formats: &[1]
},
Execute {
portal: portal_name,
Expand Down Expand Up @@ -1190,7 +1185,7 @@ impl<'conn> Statement<'conn> {
break;
}
CopyInResponse { .. } => {
try!(conn.write_messages([
try!(conn.write_messages(&[
CopyFail {
message: "COPY queries cannot be directly executed",
},
Expand Down Expand Up @@ -1273,7 +1268,7 @@ impl<'stmt> Rows<'stmt> {
fn finish_inner(&mut self) -> Result<()> {
let mut conn = self.stmt.conn.conn.borrow_mut();
check_desync!(conn);
try!(conn.write_messages([
try!(conn.write_messages(&[
Close {
variant: b'P',
name: self.name[]
Expand Down Expand Up @@ -1312,7 +1307,7 @@ impl<'stmt> Rows<'stmt> {
return DbError::new(fields);
}
CopyInResponse { .. } => {
try!(conn.write_messages([
try!(conn.write_messages(&[
CopyFail {
message: "COPY queries cannot be directly executed",
},
Expand All @@ -1328,7 +1323,7 @@ impl<'stmt> Rows<'stmt> {
}

fn execute(&mut self) -> Result<()> {
try!(self.stmt.conn.write_messages([
try!(self.stmt.conn.write_messages(&[
Execute {
portal: self.name[],
max_rows: self.row_limit
Expand Down Expand Up @@ -1417,7 +1412,7 @@ impl<'stmt> Row<'stmt> {
/// # use postgres::{Connection, SslMode};
/// # let conn = Connection::connect("", &SslMode::None).unwrap();
/// # let stmt = conn.prepare("").unwrap();
/// # let mut result = stmt.query([]).unwrap();
/// # let mut result = stmt.query(&[]).unwrap();
/// # let row = result.next().unwrap();
/// let foo: i32 = row.get(0u);
/// let bar: String = row.get("bar");
Expand Down Expand Up @@ -1520,13 +1515,13 @@ impl<'a> CopyInStatement<'a> {
where I: Iterator<J>, J: Iterator<&'b ToSql + 'b> {
let mut conn = self.conn.conn.borrow_mut();

try!(conn.write_messages([
try!(conn.write_messages(&[
Bind {
portal: "",
statement: self.name[],
formats: [],
values: [],
result_formats: []
formats: &[],
values: &[],
result_formats: &[]
},
Execute {
portal: "",
Expand Down Expand Up @@ -1605,7 +1600,7 @@ impl<'a> CopyInStatement<'a> {
}

let _ = buf.write_be_i16(-1);
try!(conn.write_messages([
try!(conn.write_messages(&[
CopyData {
data: buf.unwrap()[],
},
Expand Down
2 changes: 1 addition & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ fn read_auth_message(buf: &mut MemReader) -> IoResult<BackendMessage> {
3 => AuthenticationCleartextPassword,
5 => {
let mut salt = [0, ..4];
try!(buf.read_at_least(salt.len(), salt));
try!(buf.read_at_least(salt.len(), &mut salt));
AuthenticationMD5Password { salt: salt }
},
6 => AuthenticationSCMCredential,
Expand Down
6 changes: 3 additions & 3 deletions src/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn decode_inner<T: BytesContainer>(c: T, full_url: bool) -> DecodeResult<String>
};

// Only decode some characters if full_url:
match num::from_str_radix::<uint>(str::from_utf8(bytes).unwrap(), 16u).unwrap() as u8 as char {
match num::from_str_radix::<uint>(str::from_utf8(&bytes).unwrap(), 16u).unwrap() as u8 as char {
// gen-delims:
':' | '/' | '?' | '#' | '[' | ']' | '@' |

Expand Down Expand Up @@ -463,8 +463,8 @@ fn get_query_fragment(rawurl: &str) -> DecodeResult<(Query, Option<String>)> {
};

match before_fragment.slice_shift_char() {
(Some('?'), rest) => Ok((try!(query_from_str(rest)), fragment)),
(None, "") => Ok((vec!(), fragment)),
Some(('?', rest)) => Ok((try!(query_from_str(rest)), fragment)),
None => Ok((vec!(), fragment)),
_ => Err(format!("Query didn't start with '?': '{}..'", before_fragment)),
}
}
Expand Down
Loading