Skip to content

Commit 08d6c7b

Browse files
committed
Merge branch 'release-v0.11.5' into release
2 parents 4691352 + e806483 commit 08d6c7b

File tree

12 files changed

+165
-115
lines changed

12 files changed

+165
-115
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ before_script:
1111
script:
1212
- cargo test
1313
- cargo test --features "uuid rustc-serialize time unix_socket serde_json chrono openssl bit-vec eui48"
14+
- (test $TRAVIS_RUST_VERSION != "nightly" || cargo test --features nightly)

Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "postgres"
3-
version = "0.11.4"
3+
version = "0.11.5"
44
authors = ["Steven Fackler <[email protected]>"]
55
license = "MIT"
66
description = "A native PostgreSQL driver"
77
repository = "https://github.com/sfackler/rust-postgres"
8-
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.11.4/postgres"
8+
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.11.5/postgres"
99
readme = "README.md"
1010
keywords = ["database", "postgres", "postgresql", "sql"]
1111
include = ["src/*", "Cargo.toml", "LICENSE", "README.md", "THIRD_PARTY"]
@@ -20,11 +20,14 @@ bench = false
2020
name = "test"
2121
path = "tests/test.rs"
2222

23+
[features]
24+
nightly = []
25+
2326
[dependencies]
2427
bufstream = "0.1"
25-
byteorder = ">= 0.3, < 0.5"
28+
byteorder = "0.5"
2629
log = "0.3"
27-
phf = "0.7"
30+
phf = "=0.7.14"
2831
hex = "0.1"
2932
net2 = "0.2.16"
3033
rustc-serialize = { version = "0.3", optional = true }

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rust-Postgres
22
A native PostgreSQL driver for Rust.
33

4-
[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.11.4/postgres)
4+
[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.11.5/postgres)
55

66
[![Build Status](https://travis-ci.org/sfackler/rust-postgres.png?branch=master)](https://travis-ci.org/sfackler/rust-postgres) [![Latest Version](https://img.shields.io/crates/v/postgres.svg)](https://crates.io/crates/postgres)
77

@@ -74,11 +74,11 @@ let conn = try!(Connection::connect("postgres://user:pass@host:port/database?arg
7474
defaults to the value of `user` if not specified. The driver supports `trust`,
7575
`password`, and `md5` authentication.
7676

77-
Unix domain sockets can be used as well by activating the `unix_socket` feature.
78-
The `host` portion of the URI should be set to the absolute path to the
79-
directory containing the socket file. Since `/` is a reserved character in
80-
URLs, the path should be URL encoded. If Postgres stored its socket files in
81-
`/run/postgres`, the connection would then look like:
77+
Unix domain sockets can be used as well by activating the `unix_socket` or
78+
`nightly` features. The `host` portion of the URI should be set to the absolute
79+
path to the directory containing the socket file. Since `/` is a reserved
80+
character in URLs, the path should be URL encoded. If Postgres stored its socket
81+
files in `/run/postgres`, the connection would then look like:
8282
```rust
8383
let conn = try!(Connection::connect("postgres://postgres@%2Frun%2Fpostgres", SslMode::None));
8484
```
@@ -269,7 +269,7 @@ The [postgres-derive](https://github.com/sfackler/rust-postgres-derive)
269269
crate will synthesize `ToSql` and `FromSql` implementations for enum, domain,
270270
and composite Postgres types.
271271

272-
Support for array types is located in the
272+
Full support for array types is located in the
273273
[postgres-array](https://github.com/sfackler/rust-postgres-array) crate.
274274

275275
Support for range types is located in the
@@ -284,8 +284,8 @@ crate.
284284
### Unix socket connections
285285

286286
Support for connections through Unix domain sockets is provided optionally by
287-
the `unix_socket` feature. It is only available on "unixy" platforms such as
288-
OSX, BSD and Linux.
287+
either the `unix_socket` or `nightly` features. It is only available on "unixy"
288+
platforms such as OSX, BSD and Linux.
289289

290290
### UUID type
291291

codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ version = "0.1.0"
44
authors = ["Steven Fackler <[email protected]>"]
55

66
[dependencies]
7-
phf_codegen = "0.7"
7+
phf_codegen = "=0.7.14"
88
regex = "0.1"
99
marksman_escape = "0.1"

src/error/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Error types.
22
3-
use byteorder;
43
use std::error;
54
use std::convert::From;
65
use std::fmt;
@@ -227,12 +226,6 @@ impl From<DbError> for ConnectError {
227226
}
228227
}
229228

230-
impl From<byteorder::Error> for ConnectError {
231-
fn from(err: byteorder::Error) -> ConnectError {
232-
ConnectError::Io(From::from(err))
233-
}
234-
}
235-
236229
/// Represents the position of an error in a query.
237230
#[derive(Clone, PartialEq, Eq, Debug)]
238231
pub enum ErrorPosition {
@@ -299,12 +292,6 @@ impl From<io::Error> for Error {
299292
}
300293
}
301294

302-
impl From<byteorder::Error> for Error {
303-
fn from(err: byteorder::Error) -> Error {
304-
Error::Io(From::from(err))
305-
}
306-
}
307-
308295
impl From<Error> for io::Error {
309296
fn from(err: Error) -> io::Error {
310297
io::Error::new(io::ErrorKind::Other, err)

src/error/sqlstate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ pub enum SqlState {
482482
#[cfg_attr(rustfmt, rustfmt_skip)]
483483
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map {
484484
key: 1897749892740154578,
485-
disps: &[
485+
disps: ::phf::Slice::Static(&[
486486
(0, 10),
487487
(1, 206),
488488
(0, 38),
@@ -531,8 +531,8 @@ static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map {
531531
(0, 233),
532532
(2, 149),
533533
(0, 105),
534-
],
535-
entries: &[
534+
]),
535+
entries: ::phf::Slice::Static(&[
536536
("42P03", SqlState::DuplicateCursor),
537537
("22019", SqlState::InvalidEscapeCharacter),
538538
("22022", SqlState::IndicatorOverflow),
@@ -769,7 +769,7 @@ static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map {
769769
("28000", SqlState::InvalidAuthorizationSpecification),
770770
("0Z002", SqlState::StackedDiagnosticsAccessedWithoutActiveHandler),
771771
("02000", SqlState::NoData),
772-
]
772+
]),
773773
};
774774

775775
impl SqlState {

src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@
3838
//! }
3939
//! }
4040
//! ```
41-
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.11.4")]
41+
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.11.5")]
4242
#![warn(missing_docs)]
4343
#![allow(unknown_lints, needless_lifetimes)] // for clippy
44+
#![cfg_attr(all(unix, feature = "nightly"), feature(unix_socket))]
4445

4546
extern crate bufstream;
4647
extern crate byteorder;
@@ -68,7 +69,7 @@ use std::mem;
6869
use std::result;
6970
use std::sync::Arc;
7071
use std::time::Duration;
71-
#[cfg(feature = "unix_socket")]
72+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
7273
use std::path::PathBuf;
7374

7475
// FIXME remove in 0.12
@@ -115,8 +116,8 @@ pub enum ConnectTarget {
115116
Tcp(String),
116117
/// Connect via a Unix domain socket in the specified directory.
117118
///
118-
/// Requires the `unix_socket` feature.
119-
#[cfg(feature = "unix_socket")]
119+
/// Requires the `unix_socket` or `nightly` feature.
120+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
120121
Unix(PathBuf),
121122
}
122123

@@ -173,14 +174,14 @@ impl<'a> IntoConnectParams for &'a str {
173174

174175
impl IntoConnectParams for Url {
175176
fn into_connect_params(self) -> result::Result<ConnectParams, Box<StdError + StdSync + Send>> {
176-
#[cfg(feature = "unix_socket")]
177+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
177178
fn make_unix(maybe_path: String)
178179
-> result::Result<ConnectTarget, Box<StdError + StdSync + Send>> {
179180
Ok(ConnectTarget::Unix(PathBuf::from(maybe_path)))
180181
}
181-
#[cfg(not(feature = "unix_socket"))]
182+
#[cfg(not(any(feature = "unix_socket", all(unix, feature = "nightly"))))]
182183
fn make_unix(_: String) -> result::Result<ConnectTarget, Box<StdError + StdSync + Send>> {
183-
Err("unix socket support requires the `unix_socket` feature".into())
184+
Err("unix socket support requires the `unix_socket` or `nightly` features".into())
184185
}
185186

186187
let Url { host, port, user, path: url::Path { mut path, query: options, .. }, .. } = self;
@@ -1019,13 +1020,13 @@ impl Connection {
10191020
/// (5432) is used if none is specified. The database name defaults to the
10201021
/// username if not specified.
10211022
///
1022-
/// Connection via Unix sockets is supported with the `unix_socket`
1023-
/// feature. To connect to the server via Unix sockets, `host` should be
1024-
/// set to the absolute path of the directory containing the socket file.
1025-
/// Since `/` is a reserved character in URLs, the path should be URL
1026-
/// encoded. If the path contains non-UTF 8 characters, a `ConnectParams`
1027-
/// struct should be created manually and passed in. Note that Postgres
1028-
/// does not support SSL over Unix sockets.
1023+
/// Connection via Unix sockets is supported with either the `unix_socket`
1024+
/// or `nightly` features. To connect to the server via Unix sockets, `host`
1025+
/// should be set to the absolute path of the directory containing the
1026+
/// socket file. Since `/` is a reserved character in URLs, the path should
1027+
/// be URL encoded. If the path contains non-UTF 8 characters, a
1028+
/// `ConnectParams` struct should be created manually and passed in. Note
1029+
/// that Postgres does not support SSL over Unix sockets.
10291030
///
10301031
/// # Examples
10311032
///

src/priv_io.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use std::time::Duration;
99
use bufstream::BufStream;
1010
#[cfg(feature = "unix_socket")]
1111
use unix_socket::UnixStream;
12+
#[cfg(all(not(feature = "unix_socket"), all(unix, feature = "nightly")))]
13+
use std::os::unix::net::UnixStream;
1214
#[cfg(unix)]
1315
use std::os::unix::io::{AsRawFd, RawFd};
1416
#[cfg(windows)]
@@ -32,15 +34,15 @@ impl StreamOptions for BufStream<Box<StreamWrapper>> {
3234
fn set_read_timeout(&self, timeout: Option<Duration>) -> io::Result<()> {
3335
match self.get_ref().get_ref().0 {
3436
InternalStream::Tcp(ref s) => s.set_read_timeout(timeout),
35-
#[cfg(feature = "unix_socket")]
37+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
3638
InternalStream::Unix(ref s) => s.set_read_timeout(timeout),
3739
}
3840
}
3941

4042
fn set_nonblocking(&self, nonblock: bool) -> io::Result<()> {
4143
match self.get_ref().get_ref().0 {
4244
InternalStream::Tcp(ref s) => s.set_nonblocking(nonblock),
43-
#[cfg(feature = "unix_socket")]
45+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
4446
InternalStream::Unix(ref s) => s.set_nonblocking(nonblock),
4547
}
4648
}
@@ -56,7 +58,7 @@ impl fmt::Debug for Stream {
5658
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
5759
match self.0 {
5860
InternalStream::Tcp(ref s) => fmt::Debug::fmt(s, fmt),
59-
#[cfg(feature = "unix_socket")]
61+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
6062
InternalStream::Unix(ref s) => fmt::Debug::fmt(s, fmt),
6163
}
6264
}
@@ -93,7 +95,7 @@ impl AsRawFd for Stream {
9395
fn as_raw_fd(&self) -> RawFd {
9496
match self.0 {
9597
InternalStream::Tcp(ref s) => s.as_raw_fd(),
96-
#[cfg(feature = "unix_socket")]
98+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
9799
InternalStream::Unix(ref s) => s.as_raw_fd(),
98100
}
99101
}
@@ -111,15 +113,15 @@ impl AsRawSocket for Stream {
111113

112114
enum InternalStream {
113115
Tcp(TcpStream),
114-
#[cfg(feature = "unix_socket")]
116+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
115117
Unix(UnixStream),
116118
}
117119

118120
impl Read for InternalStream {
119121
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
120122
match *self {
121123
InternalStream::Tcp(ref mut s) => s.read(buf),
122-
#[cfg(feature = "unix_socket")]
124+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
123125
InternalStream::Unix(ref mut s) => s.read(buf),
124126
}
125127
}
@@ -129,15 +131,15 @@ impl Write for InternalStream {
129131
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
130132
match *self {
131133
InternalStream::Tcp(ref mut s) => s.write(buf),
132-
#[cfg(feature = "unix_socket")]
134+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
133135
InternalStream::Unix(ref mut s) => s.write(buf),
134136
}
135137
}
136138

137139
fn flush(&mut self) -> io::Result<()> {
138140
match *self {
139141
InternalStream::Tcp(ref mut s) => s.flush(),
140-
#[cfg(feature = "unix_socket")]
142+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
141143
InternalStream::Unix(ref mut s) => s.flush(),
142144
}
143145
}
@@ -149,7 +151,7 @@ fn open_socket(params: &ConnectParams) -> Result<InternalStream, ConnectError> {
149151
ConnectTarget::Tcp(ref host) => {
150152
Ok(try!(TcpStream::connect(&(&**host, port)).map(InternalStream::Tcp)))
151153
}
152-
#[cfg(feature = "unix_socket")]
154+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
153155
ConnectTarget::Unix(ref path) => {
154156
let path = path.join(&format!(".s.PGSQL.{}", port));
155157
Ok(try!(UnixStream::connect(&path).map(InternalStream::Unix)))
@@ -183,7 +185,7 @@ pub fn initialize_stream(params: &ConnectParams,
183185
// Postgres doesn't support SSL over unix sockets
184186
let host = match params.target {
185187
ConnectTarget::Tcp(ref host) => host,
186-
#[cfg(feature = "unix_socket")]
188+
#[cfg(any(feature = "unix_socket", all(unix, feature = "nightly")))]
187189
ConnectTarget::Unix(_) => return Err(ConnectError::Io(::bad_response())),
188190
};
189191

0 commit comments

Comments
 (0)