Skip to content

Commit 3d67d52

Browse files
committed
Merge branch 'release-v0.11.0' into release
2 parents a402f7d + 05da5ff commit 3d67d52

30 files changed

+1802
-1208
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target/
22
Cargo.lock
3+
.cargo/

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ sudo: required
33
rust:
44
- nightly
55
- beta
6-
- 1.3.0
6+
- 1.4.0
77
addons:
88
postgresql: 9.4
99
before_script:
1010
- "./.travis/setup.sh"
1111
script:
1212
- cargo test
13-
- cargo test --features "uuid rustc-serialize time unix_socket serde_json chrono openssl"
13+
- cargo test --features "uuid rustc-serialize time unix_socket serde_json chrono openssl bit-vec"

.travis/server.crt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Certificate:
2+
Data:
3+
Version: 3 (0x2)
4+
Serial Number:
5+
9a:e5:7a:5f:05:5a:2f:e4
6+
Signature Algorithm: sha1WithRSAEncryption
7+
Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd, CN=localhost
8+
Validity
9+
Not Before: Dec 5 21:50:46 2015 GMT
10+
Not After : Jan 4 21:50:46 2016 GMT
11+
Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd, CN=localhost
12+
Subject Public Key Info:
13+
Public Key Algorithm: rsaEncryption
14+
RSA Public Key: (1024 bit)
15+
Modulus (1024 bit):
16+
00:f1:9b:b6:24:64:66:bf:5e:da:77:2a:39:bd:39:
17+
93:56:28:26:f1:d7:1f:c9:60:1c:e3:82:a4:07:a2:
18+
0f:c8:d6:68:fc:30:2f:17:30:34:69:cd:d8:f1:e7:
19+
c7:84:f9:c5:90:b1:2c:42:d5:23:20:d2:1d:d7:18:
20+
15:70:0a:a3:1d:c7:2e:df:03:c0:9f:5c:cb:02:25:
21+
da:7d:2b:1a:09:78:e5:23:8a:c4:64:39:59:0d:4e:
22+
15:0b:75:7b:75:f9:8a:4c:c3:9d:f9:31:08:d5:da:
23+
00:a5:db:0c:df:09:e5:e4:14:d1:17:0f:bb:f6:cf:
24+
bd:3c:5d:14:6a:cb:c1:dc:e1
25+
Exponent: 65537 (0x10001)
26+
X509v3 extensions:
27+
X509v3 Subject Key Identifier:
28+
9E:09:C0:D1:1E:0E:07:B3:49:57:0A:49:47:F9:8A:5F:4E:FE:23:75
29+
X509v3 Authority Key Identifier:
30+
keyid:9E:09:C0:D1:1E:0E:07:B3:49:57:0A:49:47:F9:8A:5F:4E:FE:23:75
31+
DirName:/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd/CN=localhost
32+
serial:9A:E5:7A:5F:05:5A:2F:E4
33+
34+
X509v3 Basic Constraints:
35+
CA:TRUE
36+
Signature Algorithm: sha1WithRSAEncryption
37+
4c:3b:c6:42:96:75:96:a0:9b:f5:d9:b1:9b:1b:4f:bd:d2:8d:
38+
f1:53:ed:87:80:f5:7b:5d:36:6e:38:c8:ae:1a:58:e5:39:9e:
39+
42:49:12:35:76:ab:0f:fa:b1:1f:4e:b1:85:f3:a3:6f:60:e3:
40+
6c:0e:a8:95:0d:c8:38:7f:e3:e3:ff:64:74:73:50:46:65:83:
41+
5f:1a:72:f9:69:44:07:cd:36:01:90:b9:b3:ed:d8:d7:bc:68:
42+
97:dd:11:ac:2b:ec:5d:a4:d4:d5:e8:8b:60:12:54:b9:c4:5f:
43+
00:f8:ce:5b:72:28:58:43:7c:d5:25:b7:dd:ec:71:da:aa:3a:
44+
f2:6c
45+
-----BEGIN CERTIFICATE-----
46+
MIIC7zCCAligAwIBAgIJAJrlel8FWi/kMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV
47+
BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
48+
aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xNTEyMDUyMTUw
49+
NDZaFw0xNjAxMDQyMTUwNDZaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21l
50+
LVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV
51+
BAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA8Zu2JGRm
52+
v17adyo5vTmTVigm8dcfyWAc44KkB6IPyNZo/DAvFzA0ac3Y8efHhPnFkLEsQtUj
53+
INId1xgVcAqjHccu3wPAn1zLAiXafSsaCXjlI4rEZDlZDU4VC3V7dfmKTMOd+TEI
54+
1doApdsM3wnl5BTRFw+79s+9PF0UasvB3OECAwEAAaOBvjCBuzAdBgNVHQ4EFgQU
55+
ngnA0R4OB7NJVwpJR/mKX07+I3UwgYsGA1UdIwSBgzCBgIAUngnA0R4OB7NJVwpJ
56+
R/mKX07+I3WhXaRbMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRl
57+
MSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxv
58+
Y2FsaG9zdIIJAJrlel8FWi/kMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
59+
gYEATDvGQpZ1lqCb9dmxmxtPvdKN8VPth4D1e102bjjIrhpY5TmeQkkSNXarD/qx
60+
H06xhfOjb2DjbA6olQ3IOH/j4/9kdHNQRmWDXxpy+WlEB802AZC5s+3Y17xol90R
61+
rCvsXaTU1eiLYBJUucRfAPjOW3IoWEN81SW33exx2qo68mw=
62+
-----END CERTIFICATE-----

.travis/server.der

755 Bytes
Binary file not shown.

.travis/server.key

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
MIICXQIBAAKBgQDxm7YkZGa/Xtp3Kjm9OZNWKCbx1x/JYBzjgqQHog/I1mj8MC8X
3+
MDRpzdjx58eE+cWQsSxC1SMg0h3XGBVwCqMdxy7fA8CfXMsCJdp9KxoJeOUjisRk
4+
OVkNThULdXt1+YpMw535MQjV2gCl2wzfCeXkFNEXD7v2z708XRRqy8Hc4QIDAQAB
5+
AoGBAIBsJuWzJFYmQfNDU4t8Fg+eqgy0LyYn21Mm9q9D+iXjqcwahH1L1yBCFUWH
6+
0Kqi5NujAQbJKbHhXZEeMQ7r6IT8HjAW800F+M3eRLaMGVbh02L/EpEgUspb8VH+
7+
SZDolJvxCGmkBBgglJwYpFQG6ANXaEU0/uS+aHz0Wptip2NNAkEA+UdCmpY7whXS
8+
5F3LrZE8qjwjEs86RxQoe7+wF7eT4CbXmxvQBwgxMO9ZUhwdUJ3Cm5T4Qu943gp/
9+
hiRIXunrdwJBAPgfgWNE1KpmJALr3opq+mu92D6YWk2aLFQj01kJI1lomRq/ptXB
10+
niMPzzvauiFuNgpGtKKoxzBPM3l8Ii5E4GcCQCBTuHR5tSg3UlEhRM+ufRKKl/XR
11+
f/pFx/Y8Zqa8vOWdw+oukizHSDHTaF74nGie/OTWTdfIXIFXFTCdNfFxHoMCQQDs
12+
k2WT1/IJkp/tZSXnxn6Esht3+13GtiRkCVCfiRX6TsAEgA27rANynMVT5YYpD+NY
13+
wvfCS7i4OBv1TkVs5mErAkAQmGseTKaye5ABFxBOEHT00hRtIE0yojuL6oPEDhkk
14+
SJIBC5XE0vzmMKq9sQ7foqgPork9O4VYBo0q//BO0RWG
15+
-----END RSA PRIVATE KEY-----

Cargo.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[package]
22
name = "postgres"
3-
version = "0.10.2"
3+
version = "0.11.0"
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.10.2/postgres"
8+
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.11.0/postgres"
99
readme = "README.md"
1010
keywords = ["database", "sql"]
1111
build = "build.rs"
12+
include = ["src/*", "build.rs", "Cargo.toml", "LICENSE", "README.md", "THIRD_PARTY"]
1213

1314
[lib]
1415
name = "postgres"
@@ -28,15 +29,17 @@ bufstream = "0.1"
2829
byteorder = ">= 0.3, < 0.5"
2930
log = "0.3"
3031
phf = "0.7"
31-
rustc-serialize = "0.3"
32-
net2 = { version = "0.2", features = ["nightly"] }
32+
hex = "0.1"
33+
net2 = "0.2.16"
34+
rustc-serialize = { version = "0.3", optional = true }
3335
chrono = { version = "0.2.14", optional = true }
3436
openssl = { version = ">= 0.6.4, < 0.8", optional = true }
35-
serde = { version = "0.3", optional = true } # Delete for 0.11
3637
serde_json = { version = "0.6", optional = true }
3738
time = { version = "0.1.14", optional = true }
38-
unix_socket = { version = ">= 0.3, < 0.5", optional = true, features = ["socket_timeout"] }
39+
unix_socket = { version = "0.5", optional = true }
3940
uuid = { version = "0.1", optional = true }
41+
security-framework = { version = "0.1.2", optional = true }
42+
bit-vec = { version = "0.4", optional = true }
4043

4144
[dev-dependencies]
4245
url = "0.2"

README.md

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

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

88
You can integrate Rust-Postgres into your project through the [releases on crates.io](https://crates.io/crates/postgres):
99
```toml
1010
# Cargo.toml
1111
[dependencies]
12-
postgres = "0.10"
12+
postgres = "0.11"
1313
```
1414

1515
## Overview
16-
Rust-Postgres is a pure-Rust frontend for the popular PostgreSQL database. It
17-
exposes a high level interface in the vein of JDBC or Go's `database/sql`
18-
package.
16+
Rust-Postgres is a pure-Rust frontend for the popular PostgreSQL database.
1917
```rust
2018
extern crate postgres;
2119

@@ -28,7 +26,7 @@ struct Person {
2826
}
2927

3028
fn main() {
31-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None)
29+
let conn = Connection::connect("postgres://postgres@localhost", SslMode::None)
3230
.unwrap();
3331

3432
conn.execute("CREATE TABLE person (
@@ -44,8 +42,7 @@ fn main() {
4442
conn.execute("INSERT INTO person (name, data) VALUES ($1, $2)",
4543
&[&me.name, &me.data]).unwrap();
4644

47-
let stmt = conn.prepare("SELECT id, name, data FROM person").unwrap();
48-
for row in stmt.query(&[]).unwrap() {
45+
for row in &conn.query("SELECT id, name, data FROM person", &[]).unwrap() {
4946
let person = Person {
5047
id: row.get(0),
5148
name: row.get(1),
@@ -57,7 +54,7 @@ fn main() {
5754
```
5855

5956
## Requirements
60-
* **Rust** - Rust-Postgres is developed against the 1.3 release of Rust
57+
* **Rust** - Rust-Postgres is developed against the 1.4 release of Rust
6158
available on http://www.rust-lang.org. It should also compile against more
6259
recent releases.
6360

@@ -71,7 +68,7 @@ fn main() {
7168
Connect to a Postgres server using the standard URI format:
7269
```rust
7370
let conn = try!(Connection::connect("postgres://user:pass@host:port/database?arg1=val1&arg2=val2",
74-
&SslMode::None));
71+
SslMode::None));
7572
```
7673
`pass` may be omitted if not needed. `port` defaults to `5432` and `database`
7774
defaults to the value of `user` if not specified. The driver supports `trust`,
@@ -80,48 +77,48 @@ defaults to the value of `user` if not specified. The driver supports `trust`,
8077
Unix domain sockets can be used as well by activating the `unix_socket` feature.
8178
The `host` portion of the URI should be set to the absolute path to the
8279
directory containing the socket file. Since `/` is a reserved character in
83-
URLs, the path should be URL encoded.
80+
URLs, the path should be URL encoded. If Postgres stored its socket files in
81+
`/run/postgres`, the connection would then look like:
8482
```rust
85-
let conn = try!(Connection::connect("postgres://postgres@%2Frun%2Fpostgres", &SslMode::None));
83+
let conn = try!(Connection::connect("postgres://postgres@%2Frun%2Fpostgres", SslMode::None));
8684
```
8785
Paths which contain non-UTF8 characters can be handled in a different manner;
8886
see the documentation for details.
8987

90-
### Statement Preparation
91-
Prepared statements can have parameters, represented as `$n` where `n` is an
92-
index into the parameter array starting from 1:
93-
```rust
94-
let stmt = try!(conn.prepare("SELECT * FROM foo WHERE bar = $1 AND baz = $2"));
95-
```
96-
9788
### Querying
98-
A prepared statement can be executed with the `query` and `execute` methods.
99-
Both methods take an array of parameters to bind to the query represented as
100-
`&ToSql` trait objects. `execute` returns the number of rows affected by the
101-
query (or 0 if not applicable):
89+
SQL statements can be executed with the `query` and `execute` methods. Both
90+
methods take a query string as well as a slice of parameters to bind to the
91+
query. The `i`th query parameter is specified in the query string by `$i`. Note
92+
that query parameters are 1-indexed rather than the more common 0-indexing.
93+
94+
`execute` returns the number of rows affected by the query (or 0 if not
95+
applicable):
10296
```rust
103-
let stmt = try!(conn.prepare("UPDATE foo SET bar = $1 WHERE baz = $2"));
104-
let updates = try!(stmt.execute(&[&1i32, &"biz"]));
97+
let updates = try!(conn.execute("UPDATE foo SET bar = $1 WHERE baz = $2", &[&1i32, &"biz"]));
10598
println!("{} rows were updated", updates);
10699
```
107-
`query` returns an iterator over the rows returned from the database. The
108-
fields in a row can be accessed either by their indices or their column names,
109-
though access by index is more efficient. Unlike statement parameters, result
110-
columns are zero-indexed.
100+
101+
`query` returns an iterable object holding the rows returned from the database.
102+
The fields in a row can be accessed either by their indices or their column
103+
names, though access by index is more efficient. Unlike statement parameters,
104+
result columns are zero-indexed.
111105
```rust
112-
let stmt = try!(conn.prepare("SELECT bar, baz FROM foo"));
113-
for row in try!(stmt.query(&[])) {
106+
for row in &try!(conn.query("SELECT bar, baz FROM foo WHERE buz = $1", &[&1i32])) {
114107
let bar: i32 = row.get(0);
115108
let baz: String = row.get("baz");
116109
println!("bar: {}, baz: {}", bar, baz);
117110
}
118111
```
119-
In addition, `Connection` has a utility `execute` method which is useful if a
120-
statement is only going to be executed once:
112+
113+
### Statement Preparation
114+
If the same statement will be executed repeatedly (possibly with different
115+
parameters), explicitly preparing it can improve performance:
116+
121117
```rust
122-
let updates = try!(conn.execute("UPDATE foo SET bar = $1 WHERE baz = $2",
123-
&[&1i32, &"biz"]));
124-
println!("{} rows were updated", updates);
118+
let stmt = try!(conn.prepare("UPDATE foo SET bar = $1 WHERE baz = $2"));
119+
for (bar, baz) in updates {
120+
try!(stmt.execute(&[bar, baz]));
121+
}
125122
```
126123

127124
### Transactions
@@ -131,14 +128,12 @@ The `transaction` method will start a new transaction. It returns a
131128
transaction:
132129
```rust
133130
let trans = try!(conn.transaction());
131+
134132
try!(trans.execute(...));
135133
let stmt = try!(trans.prepare(...));
134+
// ...
136135

137-
if the_coast_is_clear {
138-
trans.set_commit();
139-
}
140-
141-
try!(trans.finish());
136+
try!(trans.commit());
142137
```
143138
The transaction will be active until the `Transaction` object falls out of
144139
scope. A transaction will roll back by default. Nested transactions are
@@ -246,6 +241,13 @@ types. The driver currently supports the following conversions:
246241
</td>
247242
<td>UUID</td>
248243
</tr>
244+
<tr>
245+
<td>
246+
<a href="https://github.com/contain-rs/bit-vec">bit_vec::BitVec</a>
247+
(<a href="#optional-features">optional</a>)
248+
</td>
249+
<td>BIT, VARBIT</td>
250+
</tr>
249251
<tr>
250252
<td>HashMap&lt;String, Option&lt;String&gt;&gt;</td>
251253
<td>HSTORE</td>
@@ -285,8 +287,7 @@ implementations for `uuid`'s `Uuid` type.
285287
support is provided optionally by the `rustc-serialize` feature, which adds
286288
`ToSql` and `FromSql` implementations for `rustc-serialize`'s `Json` type, and
287289
the `serde_json` feature, which adds implementations for `serde_json`'s `Value`
288-
type. The `serde` feature provides implementations for the older
289-
`serde::json::Value` type.
290+
type.
290291

291292
### TIMESTAMP/TIMESTAMPTZ/DATE/TIME types
292293

@@ -295,3 +296,9 @@ support is provided optionally by the `time` feature, which adds `ToSql` and
295296
`FromSql` implementations for `time`'s `Timespec` type, or the `chrono`
296297
feature, which adds `ToSql` and `FromSql` implementations for `chrono`'s
297298
`DateTime`, `NaiveDateTime`, `NaiveDate` and `NaiveTime` types.
299+
300+
### BIT/VARBIT types
301+
302+
[BIT and VARBIT](http://www.postgresql.org/docs/9.4/static/datatype-bit.html)
303+
support is provided optionally by the `bit-vec` feature, which adds `ToSql` and
304+
`FromSql` implementations for `bit-vec`'s `BitVec` type.

0 commit comments

Comments
 (0)