Skip to content

Commit 30f11af

Browse files
committed
Merge branch 'release-v0.11.10' into release
2 parents 453cd07 + f4aabce commit 30f11af

17 files changed

+286
-97
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
language: rust
2+
cache: cargo
23
sudo: required
34
rust:
45
- nightly
56
- beta
6-
- 1.7.0
7+
- 1.9.0
78
addons:
89
postgresql: 9.4
910
before_script:
1011
- "./.travis/setup.sh"
1112
script:
1213
- cargo test
13-
- cargo update -p bitflags --precise 0.5.0
1414
- cargo test --features "uuid rustc-serialize time unix_socket serde_json chrono openssl bit-vec eui48"
1515
- (test $TRAVIS_RUST_VERSION != "nightly" || cargo test --features nightly)

Cargo.toml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "postgres"
3-
version = "0.11.9"
3+
version = "0.11.10"
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.9/postgres"
8+
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.11.10/postgres"
99
readme = "README.md"
1010
keywords = ["database", "postgres", "postgresql", "sql"]
1111
include = ["src/*", "Cargo.toml", "LICENSE", "README.md", "THIRD_PARTY"]
@@ -27,9 +27,8 @@ nightly = []
2727
bufstream = "0.1"
2828
byteorder = "0.5"
2929
log = "0.3"
30-
phf = "=0.7.14"
30+
phf = "=0.7.15"
3131
hex = "0.2"
32-
net2 = "0.2.16"
3332
rustc-serialize = { version = "0.3", optional = true }
3433
chrono = { version = "0.2.14", optional = true }
3534
openssl = { version = ">= 0.6.4, < 0.8", optional = true }
@@ -40,7 +39,6 @@ uuid = { version = ">= 0.1, < 0.3", optional = true }
4039
security-framework = { version = "0.1.2", optional = true }
4140
bit-vec = { version = "0.4", optional = true }
4241
eui48 = { version = "0.1", optional = true }
43-
clippy = { version = "0.0.61", optional = true }
4442

4543
[dev-dependencies]
4644
url = "1.0"

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2015 Steven Fackler
3+
Copyright (c) 2013-2016 Steven Fackler
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

+2-2
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.9/postgres)
4+
[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.11.10/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

@@ -51,7 +51,7 @@ fn main() {
5151
```
5252

5353
## Requirements
54-
* **Rust** - Rust-Postgres is developed against the 1.7 release of Rust
54+
* **Rust** - Rust-Postgres is developed against the 1.9 release of Rust
5555
available on http://www.rust-lang.org. It should also compile against more
5656
recent releases.
5757

codegen/Cargo.toml

+1-1
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.14"
7+
phf_codegen = "=0.7.15"
88
regex = "0.1"
99
marksman_escape = "0.1"

codegen/src/sqlstate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub enum SqlState {{
9898
" /// An unknown code
9999
Other(String),
100100
}}
101+
101102
"
102103
).unwrap();
103104
}

src/error/sqlstate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ pub enum SqlState {
479479
/// An unknown code
480480
Other(String),
481481
}
482+
482483
#[cfg_attr(rustfmt, rustfmt_skip)]
483484
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map {
484485
key: 1897749892740154578,

src/lib.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@
3838
//! }
3939
//! }
4040
//! ```
41-
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.11.9")]
41+
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.11.10")]
4242
#![warn(missing_docs)]
4343
#![allow(unknown_lints, needless_lifetimes)] // for clippy
4444
#![cfg_attr(all(unix, feature = "nightly"), feature(unix_socket))]
45-
#![cfg_attr(feature = "clippy", feature(plugin))]
46-
#![cfg_attr(feature = "clippy", plugin(clippy))]
4745

4846
extern crate bufstream;
4947
extern crate byteorder;
@@ -53,7 +51,6 @@ extern crate log;
5351
extern crate phf;
5452
#[cfg(feature = "unix_socket")]
5553
extern crate unix_socket;
56-
extern crate net2;
5754

5855
use bufstream::BufStream;
5956
use md5::Md5;
@@ -419,6 +416,19 @@ impl InnerConnection {
419416
ORDER BY enumsortorder") {
420417
Ok(..) => {}
421418
Err(Error::Io(e)) => return Err(ConnectError::Io(e)),
419+
// Postgres 9.0 doesn't have enumsortorder
420+
Err(Error::Db(ref e)) if e.code == SqlState::UndefinedColumn => {
421+
match self.raw_prepare(TYPEINFO_ENUM_QUERY,
422+
"SELECT enumlabel \
423+
FROM pg_catalog.pg_enum \
424+
WHERE enumtypid = $1 \
425+
ORDER BY oid") {
426+
Ok(..) => {}
427+
Err(Error::Io(e)) => return Err(ConnectError::Io(e)),
428+
Err(Error::Db(e)) => return Err(ConnectError::Db(e)),
429+
Err(Error::Conversion(_)) => unreachable!(),
430+
}
431+
}
422432
// Old versions of Postgres and things like Redshift don't support enums
423433
Err(Error::Db(ref e)) if e.code == SqlState::UndefinedTable => {}
424434
// Some Postgres-like databases are missing a pg_catalog (e.g. Cockroach)

src/priv_io.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
use byteorder::ReadBytesExt;
2-
// this import needs to stay to support pre 1.9 users
3-
#[allow(unused_imports)]
4-
use net2::TcpStreamExt;
52
use std::error::Error;
63
use std::io;
74
use std::io::prelude::*;

src/types/chrono.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
extern crate chrono;
22

3-
use std::error;
43
use std::io::prelude::*;
54
use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
65
use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, UTC, Local,
@@ -31,10 +30,7 @@ impl ToSql for NaiveDateTime {
3130
-> Result<IsNull> {
3231
let time = match (*self - base()).num_microseconds() {
3332
Some(time) => time,
34-
None => {
35-
let err: Box<error::Error + Sync + Send> = "value too large to transmit".into();
36-
return Err(Error::Conversion(err));
37-
}
33+
None => return Err(Error::Conversion("value too large to transmit".into())),
3834
};
3935
try!(w.write_i64::<BigEndian>(time));
4036
Ok(IsNull::No)
@@ -130,8 +126,7 @@ impl ToSql for NaiveDate {
130126
-> Result<IsNull> {
131127
let jd = (*self - base().date()).num_days();
132128
if jd > i32::max_value() as i64 || jd < i32::min_value() as i64 {
133-
let err: Box<error::Error + Sync + Send> = "value too large to transmit".into();
134-
return Err(Error::Conversion(err));
129+
return Err(Error::Conversion("value too large to transmit".into()));
135130
}
136131

137132
try!(w.write_i32::<BigEndian>(jd as i32));
@@ -160,10 +155,7 @@ impl ToSql for NaiveTime {
160155
let delta = *self - NaiveTime::from_hms(0, 0, 0);
161156
let time = match delta.num_microseconds() {
162157
Some(time) => time,
163-
None => {
164-
let err: Box<error::Error + Sync + Send> = "value too large to transmit".into();
165-
return Err(Error::Conversion(err));
166-
}
158+
None => return Err(Error::Conversion("value too large to transmit".into())),
167159
};
168160
try!(w.write_i64::<BigEndian>(time));
169161
Ok(IsNull::No)

src/types/mod.rs

+66-60
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
99

1010
pub use self::slice::Slice;
1111
pub use self::types::Type;
12+
pub use self::special::{Date, Timestamp};
1213
use {Result, SessionInfoNew, InnerConnection, OtherNew, WrongTypeNew, FieldNew};
1314
use error::Error;
1415

@@ -70,6 +71,7 @@ mod chrono;
7071
#[cfg(feature = "eui48")]
7172
mod eui48;
7273

74+
mod special;
7375
mod types;
7476

7577
/// A structure providing information for conversion methods.
@@ -256,41 +258,41 @@ impl WrongTypeNew for WrongType {
256258
/// The following implementations are provided by this crate, along with the
257259
/// corresponding Postgres types:
258260
///
259-
/// | Rust type | Postgres type(s) |
260-
/// |-----------------------------------------------|--------------------------------|
261-
/// | `bool` | BOOL |
262-
/// | `i8` | "char" |
263-
/// | `i16` | SMALLINT, SMALLSERIAL |
264-
/// | `i32` | INT, SERIAL |
265-
/// | `u32` | OID |
266-
/// | `i64` | BIGINT, BIGSERIAL |
267-
/// | `f32` | REAL |
268-
/// | `f64` | DOUBLE PRECISION |
269-
/// | `String` | VARCHAR, CHAR(n), TEXT, CITEXT |
270-
/// | `Vec&lt;u8&gt;` | BYTEA |
271-
/// | `HashMap&lt;String, Option&lt;String&gt;&gt;` | HSTORE |
261+
/// | Rust type | Postgres type(s) |
262+
/// |-----------------------------------|--------------------------------|
263+
/// | `bool` | BOOL |
264+
/// | `i8` | "char" |
265+
/// | `i16` | SMALLINT, SMALLSERIAL |
266+
/// | `i32` | INT, SERIAL |
267+
/// | `u32` | OID |
268+
/// | `i64` | BIGINT, BIGSERIAL |
269+
/// | `f32` | REAL |
270+
/// | `f64` | DOUBLE PRECISION |
271+
/// | `String` | VARCHAR, CHAR(n), TEXT, CITEXT |
272+
/// | `Vec<u8>` | BYTEA |
273+
/// | `HashMap<String, Option<String>>` | HSTORE |
272274
///
273275
/// In addition, some implementations are provided for types in third party
274276
/// crates. These are disabled by default; to opt into one of these
275277
/// implementations, activate the Cargo feature corresponding to the crate's
276278
/// name. For example, the `serde_json` feature enables the implementation for
277279
/// the `serde_json::Value` type.
278280
///
279-
/// | Rust type | Postgres type(s) |
280-
/// |---------------------------------------|-------------------------------------|
281-
/// | `serialize::json::Json` | JSON, JSONB |
282-
/// | `serde_json::Value` | JSON, JSONB |
283-
/// | `time::Timespec` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
284-
/// | `chrono::NaiveDateTime` | TIMESTAMP |
285-
/// | `chrono::DateTime&lt;UTC&gt;` | TIMESTAMP WITH TIME ZONE |
286-
/// | `chrono::DateTime&lt;Local&gt;` | TIMESTAMP WITH TIME ZONE |
287-
/// | `chrono::DateTime&lt;FixedOffset&gt;` | TIMESTAMP WITH TIME ZONE |
288-
/// | `chrono::NaiveDate` | DATE |
289-
/// | `chrono::NaiveTime` | TIME |
290-
/// | `eui48::MacAddress` | MACADDR |
291-
/// | `uuid::Uuid` | UUID |
292-
/// | `bit_vec::BitVec` | BIT, VARBIT |
293-
/// | `eui48::MacAddress` | MACADDR |
281+
/// | Rust type | Postgres type(s) |
282+
/// |---------------------------------|-------------------------------------|
283+
/// | `serialize::json::Json` | JSON, JSONB |
284+
/// | `serde_json::Value` | JSON, JSONB |
285+
/// | `time::Timespec` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
286+
/// | `chrono::NaiveDateTime` | TIMESTAMP |
287+
/// | `chrono::DateTime<UTC>` | TIMESTAMP WITH TIME ZONE |
288+
/// | `chrono::DateTime<Local>` | TIMESTAMP WITH TIME ZONE |
289+
/// | `chrono::DateTime<FixedOffset>` | TIMESTAMP WITH TIME ZONE |
290+
/// | `chrono::NaiveDate` | DATE |
291+
/// | `chrono::NaiveTime` | TIME |
292+
/// | `eui48::MacAddress` | MACADDR |
293+
/// | `uuid::Uuid` | UUID |
294+
/// | `bit_vec::BitVec` | BIT, VARBIT |
295+
/// | `eui48::MacAddress` | MACADDR |
294296
///
295297
/// # Nullability
296298
///
@@ -356,13 +358,18 @@ impl<T: FromSql> FromSql for Vec<T> {
356358
_ => panic!("expected array type"),
357359
};
358360

359-
if try!(raw.read_i32::<BigEndian>()) != 1 {
361+
let dimensions = try!(raw.read_i32::<BigEndian>());
362+
if dimensions > 1 {
360363
return Err(Error::Conversion("array contains too many dimensions".into()));
361364
}
362365

363366
let _has_nulls = try!(raw.read_i32::<BigEndian>());
364367
let _member_oid = try!(raw.read_u32::<BigEndian>());
365368

369+
if dimensions == 0 {
370+
return Ok(vec![]);
371+
}
372+
366373
let count = try!(raw.read_i32::<BigEndian>());
367374
let _index_offset = try!(raw.read_i32::<BigEndian>());
368375

@@ -501,42 +508,42 @@ pub enum IsNull {
501508
/// The following implementations are provided by this crate, along with the
502509
/// corresponding Postgres types:
503510
///
504-
/// | Rust type | Postgres type(s) |
505-
/// |-----------------------------------------------|--------------------------------|
506-
/// | `bool` | BOOL |
507-
/// | `i8` | "char" |
508-
/// | `i16` | SMALLINT, SMALLSERIAL |
509-
/// | `i32` | INT, SERIAL |
510-
/// | `u32` | OID |
511-
/// | `i64` | BIGINT, BIGSERIAL |
512-
/// | `f32` | REAL |
513-
/// | `f64` | DOUBLE PRECISION |
514-
/// | `String` | VARCHAR, CHAR(n), TEXT, CITEXT |
515-
/// | `&str` | VARCHAR, CHAR(n), TEXT, CITEXT |
516-
/// | `Vec&lt;u8&gt;` | BYTEA |
517-
/// | `&[u8]` | BYTEA |
518-
/// | `HashMap&lt;String, Option&lt;String&gt;&gt;` | HSTORE |
511+
/// | Rust type | Postgres type(s) |
512+
/// |-----------------------------------|--------------------------------|
513+
/// | `bool` | BOOL |
514+
/// | `i8` | "char" |
515+
/// | `i16` | SMALLINT, SMALLSERIAL |
516+
/// | `i32` | INT, SERIAL |
517+
/// | `u32` | OID |
518+
/// | `i64` | BIGINT, BIGSERIAL |
519+
/// | `f32` | REAL |
520+
/// | `f64` | DOUBLE PRECISION |
521+
/// | `String` | VARCHAR, CHAR(n), TEXT, CITEXT |
522+
/// | `&str` | VARCHAR, CHAR(n), TEXT, CITEXT |
523+
/// | `Vec<u8>` | BYTEA |
524+
/// | `&[u8]` | BYTEA |
525+
/// | `HashMap<String, Option<String>>` | HSTORE |
519526
///
520527
/// In addition, some implementations are provided for types in third party
521528
/// crates. These are disabled by default; to opt into one of these
522529
/// implementations, activate the Cargo feature corresponding to the crate's
523530
/// name. For example, the `serde_json` feature enables the implementation for
524531
/// the `serde_json::Value` type.
525532
///
526-
/// | Rust type | Postgres type(s) |
527-
/// |---------------------------------------|-------------------------------------|
528-
/// | `serialize::json::Json` | JSON, JSONB |
529-
/// | `serde_json::Value` | JSON, JSONB |
530-
/// | `time::Timespec` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
531-
/// | `chrono::NaiveDateTime` | TIMESTAMP |
532-
/// | `chrono::DateTime&lt;UTC&gt;` | TIMESTAMP WITH TIME ZONE |
533-
/// | `chrono::DateTime&lt;Local&gt;` | TIMESTAMP WITH TIME ZONE |
534-
/// | `chrono::DateTime&lt;FixedOffset&gt;` | TIMESTAMP WITH TIME ZONE |
535-
/// | `chrono::NaiveDate` | DATE |
536-
/// | `chrono::NaiveTime` | TIME |
537-
/// | `uuid::Uuid` | UUID |
538-
/// | `bit_vec::BitVec` | BIT, VARBIT |
539-
/// | `eui48::MacAddress` | MACADDR |
533+
/// | Rust type | Postgres type(s) |
534+
/// |---------------------------------|-------------------------------------|
535+
/// | `serialize::json::Json` | JSON, JSONB |
536+
/// | `serde_json::Value` | JSON, JSONB |
537+
/// | `time::Timespec` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
538+
/// | `chrono::NaiveDateTime` | TIMESTAMP |
539+
/// | `chrono::DateTime<UTC>` | TIMESTAMP WITH TIME ZONE |
540+
/// | `chrono::DateTime<Local>` | TIMESTAMP WITH TIME ZONE |
541+
/// | `chrono::DateTime<FixedOffset>` | TIMESTAMP WITH TIME ZONE |
542+
/// | `chrono::NaiveDate` | DATE |
543+
/// | `chrono::NaiveTime` | TIME |
544+
/// | `uuid::Uuid` | UUID |
545+
/// | `bit_vec::BitVec` | BIT, VARBIT |
546+
/// | `eui48::MacAddress` | MACADDR |
540547
///
541548
/// # Nullability
542549
///
@@ -806,8 +813,7 @@ impl ToSql for HashMap<String, Option<String>> {
806813

807814
fn downcast(len: usize) -> Result<i32> {
808815
if len > i32::max_value() as usize {
809-
let err: Box<error::Error + Sync + Send> = "value too large to transmit".into();
810-
Err(Error::Conversion(err))
816+
Err(Error::Conversion("value too large to transmit".into()))
811817
} else {
812818
Ok(len as i32)
813819
}

src/types/rustc_serialize.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
extern crate rustc_serialize;
22

33
use self::rustc_serialize::json;
4-
use std::error;
54
use std::io::prelude::*;
65
use byteorder::{ReadBytesExt, WriteBytesExt};
76

@@ -14,9 +13,7 @@ impl FromSql for json::Json {
1413
if let Type::Jsonb = *ty {
1514
// We only support version 1 of the jsonb binary format
1615
if try!(raw.read_u8()) != 1 {
17-
let err: Box<error::Error + Sync + Send> = "unsupported JSONB encoding version"
18-
.into();
19-
return Err(Error::Conversion(err));
16+
return Err(Error::Conversion("unsupported JSONB encoding version".into()));
2017
}
2118
}
2219
json::Json::from_reader(raw).map_err(|err| Error::Conversion(Box::new(err)))

0 commit comments

Comments
 (0)