Skip to content

Commit 7d3753e

Browse files
author
Julius de Bruijn
committed
Merge branch 'master' into pgbouncer-mode
2 parents 87316f0 + 096f4f5 commit 7d3753e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1393
-751
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ version: 2
2222
jobs:
2323
build:
2424
docker:
25-
- image: rust:1.41.0
25+
- image: rust:1.45.0
2626
environment:
2727
RUSTFLAGS: -D warnings
2828
- image: sfackler/rust-postgres-test:6

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,16 @@ TLS support for postgres and tokio-postgres via native-tls.
3232
[Documentation](https://docs.rs/postgres-openssl)
3333

3434
TLS support for postgres and tokio-postgres via openssl.
35+
36+
# Running test suite
37+
38+
The test suite requires postgres to be running in the correct configuration. The easiest way to do this is with docker:
39+
40+
1. Install `docker` and `docker-compose`.
41+
1. On ubuntu: `sudo apt install docker.io docker-compose`.
42+
1. Make sure your user has permissions for docker.
43+
1. On ubuntu: ``sudo usermod -aG docker $USER``
44+
1. Change to top-level directory of `rust-postgres` repo.
45+
1. Run `docker-compose up -d`.
46+
1. Run `cargo test`.
47+
1. Run `docker-compose stop`.

codegen/src/errcodes.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# errcodes.txt
33
# PostgreSQL error codes
44
#
5-
# Copyright (c) 2003-2019, PostgreSQL Global Development Group
5+
# Copyright (c) 2003-2020, PostgreSQL Global Development Group
66
#
77
# This list serves as the basis for generating source files containing error
88
# codes. It is kept in a common format to make sure all these source files have
@@ -207,6 +207,7 @@ Section: Class 22 - Data Exception
207207
2200S E ERRCODE_INVALID_XML_COMMENT invalid_xml_comment
208208
2200T E ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION invalid_xml_processing_instruction
209209
22030 E ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE duplicate_json_object_key_value
210+
22031 E ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION invalid_argument_for_sql_json_datetime_function
210211
22032 E ERRCODE_INVALID_JSON_TEXT invalid_json_text
211212
22033 E ERRCODE_INVALID_SQL_JSON_SUBSCRIPT invalid_sql_json_subscript
212213
22034 E ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM more_than_one_sql_json_item

codegen/src/pg_range.dat

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# pg_range.dat
44
# Initial contents of the pg_range system catalog.
55
#
6-
# Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
6+
# Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
77
# Portions Copyright (c) 1994, Regents of the University of California
88
#
99
# src/include/catalog/pg_range.dat

codegen/src/pg_type.dat

+44-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# pg_type.dat
44
# Initial contents of the pg_type system catalog.
55
#
6-
# Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
6+
# Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
77
# Portions Copyright (c) 1994, Regents of the University of California
88
#
99
# src/include/catalog/pg_type.dat
@@ -177,6 +177,10 @@
177177
typtype => 'p', typcategory => 'P', typinput => 'pg_ddl_command_in',
178178
typoutput => 'pg_ddl_command_out', typreceive => 'pg_ddl_command_recv',
179179
typsend => 'pg_ddl_command_send', typalign => 'ALIGNOF_POINTER' },
180+
{ oid => '5069', array_type_oid => '271', descr => 'full transaction id',
181+
typname => 'xid8', typlen => '8', typbyval => 'FLOAT8PASSBYVAL',
182+
typcategory => 'U', typinput => 'xid8in', typoutput => 'xid8out',
183+
typreceive => 'xid8recv', typsend => 'xid8send', typalign => 'd' },
180184

181185
# OIDS 600 - 699
182186

@@ -215,9 +219,9 @@
215219

216220
{ oid => '700', array_type_oid => '1021',
217221
descr => 'single-precision floating point number, 4-byte storage',
218-
typname => 'float4', typlen => '4', typbyval => 'FLOAT4PASSBYVAL',
219-
typcategory => 'N', typinput => 'float4in', typoutput => 'float4out',
220-
typreceive => 'float4recv', typsend => 'float4send', typalign => 'i' },
222+
typname => 'float4', typlen => '4', typbyval => 't', typcategory => 'N',
223+
typinput => 'float4in', typoutput => 'float4out', typreceive => 'float4recv',
224+
typsend => 'float4send', typalign => 'i' },
221225
{ oid => '701', array_type_oid => '1022',
222226
descr => 'double-precision floating point number, 8-byte storage',
223227
typname => 'float8', typlen => '8', typbyval => 'FLOAT8PASSBYVAL',
@@ -379,6 +383,11 @@
379383
typname => 'regclass', typlen => '4', typbyval => 't', typcategory => 'N',
380384
typinput => 'regclassin', typoutput => 'regclassout',
381385
typreceive => 'regclassrecv', typsend => 'regclasssend', typalign => 'i' },
386+
{ oid => '4191', array_type_oid => '4192', descr => 'registered collation',
387+
typname => 'regcollation', typlen => '4', typbyval => 't', typcategory => 'N',
388+
typinput => 'regcollationin', typoutput => 'regcollationout',
389+
typreceive => 'regcollationrecv', typsend => 'regcollationsend',
390+
typalign => 'i' },
382391
{ oid => '2206', array_type_oid => '2211', descr => 'registered type',
383392
typname => 'regtype', typlen => '4', typbyval => 't', typcategory => 'N',
384393
typinput => 'regtypein', typoutput => 'regtypeout',
@@ -451,6 +460,11 @@
451460
typcategory => 'U', typinput => 'txid_snapshot_in',
452461
typoutput => 'txid_snapshot_out', typreceive => 'txid_snapshot_recv',
453462
typsend => 'txid_snapshot_send', typalign => 'd', typstorage => 'x' },
463+
{ oid => '5038', array_type_oid => '5039', descr => 'snapshot',
464+
typname => 'pg_snapshot', typlen => '-1', typbyval => 'f', typcategory => 'U',
465+
typinput => 'pg_snapshot_in', typoutput => 'pg_snapshot_out',
466+
typreceive => 'pg_snapshot_recv', typsend => 'pg_snapshot_send',
467+
typalign => 'd', typstorage => 'x' },
454468

455469
# range types
456470
{ oid => '3904', array_type_oid => '3905', descr => 'range of integers',
@@ -546,10 +560,6 @@
546560
typtype => 'p', typcategory => 'P', typinput => 'internal_in',
547561
typoutput => 'internal_out', typreceive => '-', typsend => '-',
548562
typalign => 'ALIGNOF_POINTER' },
549-
{ oid => '2282', descr => 'obsolete, deprecated pseudo-type',
550-
typname => 'opaque', typlen => '4', typbyval => 't', typtype => 'p',
551-
typcategory => 'P', typinput => 'opaque_in', typoutput => 'opaque_out',
552-
typreceive => '-', typsend => '-', typalign => 'i' },
553563
{ oid => '2283', descr => 'pseudo-type representing a polymorphic base type',
554564
typname => 'anyelement', typlen => '4', typbyval => 't', typtype => 'p',
555565
typcategory => 'P', typinput => 'anyelement_in',
@@ -590,9 +600,34 @@
590600
typoutput => 'table_am_handler_out', typreceive => '-', typsend => '-',
591601
typalign => 'i' },
592602
{ oid => '3831',
593-
descr => 'pseudo-type representing a polymorphic base type that is a range',
603+
descr => 'pseudo-type representing a range over a polymorphic base type',
594604
typname => 'anyrange', typlen => '-1', typbyval => 'f', typtype => 'p',
595605
typcategory => 'P', typinput => 'anyrange_in', typoutput => 'anyrange_out',
596606
typreceive => '-', typsend => '-', typalign => 'd', typstorage => 'x' },
607+
{ oid => '5077',
608+
descr => 'pseudo-type representing a polymorphic common type',
609+
typname => 'anycompatible', typlen => '4', typbyval => 't', typtype => 'p',
610+
typcategory => 'P', typinput => 'anycompatible_in',
611+
typoutput => 'anycompatible_out', typreceive => '-', typsend => '-',
612+
typalign => 'i' },
613+
{ oid => '5078',
614+
descr => 'pseudo-type representing an array of polymorphic common type elements',
615+
typname => 'anycompatiblearray', typlen => '-1', typbyval => 'f',
616+
typtype => 'p', typcategory => 'P', typinput => 'anycompatiblearray_in',
617+
typoutput => 'anycompatiblearray_out',
618+
typreceive => 'anycompatiblearray_recv', typsend => 'anycompatiblearray_send',
619+
typalign => 'd', typstorage => 'x' },
620+
{ oid => '5079',
621+
descr => 'pseudo-type representing a polymorphic common type that is not an array',
622+
typname => 'anycompatiblenonarray', typlen => '4', typbyval => 't',
623+
typtype => 'p', typcategory => 'P', typinput => 'anycompatiblenonarray_in',
624+
typoutput => 'anycompatiblenonarray_out', typreceive => '-', typsend => '-',
625+
typalign => 'i' },
626+
{ oid => '5080',
627+
descr => 'pseudo-type representing a range over a polymorphic common type',
628+
typname => 'anycompatiblerange', typlen => '-1', typbyval => 'f',
629+
typtype => 'p', typcategory => 'P', typinput => 'anycompatiblerange_in',
630+
typoutput => 'anycompatiblerange_out', typreceive => '-', typsend => '-',
631+
typalign => 'd', typstorage => 'x' },
597632

598633
]

codegen/src/type_gen.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ impl<'a> DatParser<'a> {
136136
fn peek(&mut self, target: char) -> bool {
137137
self.skip_ws();
138138

139-
match self.it.peek() {
140-
Some((_, ch)) if *ch == target => true,
141-
_ => false,
142-
}
139+
matches!(self.it.peek(), Some((_, ch)) if *ch == target)
143140
}
144141

145142
fn eof(&mut self) {

postgres-native-tls/CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change Log
22

3+
## v0.5.0 - 2020-12-25
4+
5+
### Changed
6+
7+
* Upgraded to `tokio-postgres` 0.7.
8+
9+
## v0.4.0 - 2020-10-17
10+
11+
### Changed
12+
13+
* Upgraded to `tokio-postgres` 0.6.
14+
315
## v0.3.0 - 2019-12-23
416

517
### Changed

postgres-native-tls/Cargo.toml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "postgres-native-tls"
3-
version = "0.3.0"
3+
version = "0.5.0"
44
authors = ["Steven Fackler <[email protected]>"]
55
edition = "2018"
66
license = "MIT/Apache-2.0"
@@ -16,13 +16,12 @@ default = ["runtime"]
1616
runtime = ["tokio-postgres/runtime"]
1717

1818
[dependencies]
19-
bytes = "0.5"
2019
futures = "0.3"
2120
native-tls = "0.2"
22-
tokio = "0.2"
23-
tokio-tls = "0.3"
24-
tokio-postgres = { version = "0.5.0", path = "../tokio-postgres", default-features = false }
21+
tokio = "1.0"
22+
tokio-native-tls = "0.3"
23+
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }
2524

2625
[dev-dependencies]
27-
tokio = { version = "0.2", features = ["full"] }
28-
postgres = { version = "0.17.0", path = "../postgres" }
26+
tokio = { version = "1.0", features = ["full"] }
27+
postgres = { version = "0.19.0", path = "../postgres" }

postgres-native-tls/src/lib.rs

+11-38
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! TLS support for `tokio-postgres` and `postgres` via `native-tls.
1+
//! TLS support for `tokio-postgres` and `postgres` via `native-tls`.
22
//!
33
//! # Examples
44
//!
@@ -45,16 +45,13 @@
4545
//! # Ok(())
4646
//! # }
4747
//! ```
48-
#![doc(html_root_url = "https://docs.rs/postgres-native-tls/0.3")]
4948
#![warn(rust_2018_idioms, clippy::all, missing_docs)]
5049

51-
use bytes::{Buf, BufMut};
5250
use std::future::Future;
5351
use std::io;
54-
use std::mem::MaybeUninit;
5552
use std::pin::Pin;
5653
use std::task::{Context, Poll};
57-
use tokio::io::{AsyncRead, AsyncWrite};
54+
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
5855
use tokio_postgres::tls;
5956
#[cfg(feature = "runtime")]
6057
use tokio_postgres::tls::MakeTlsConnect;
@@ -94,15 +91,15 @@ where
9491

9592
/// A `TlsConnect` implementation using the `native-tls` crate.
9693
pub struct TlsConnector {
97-
connector: tokio_tls::TlsConnector,
94+
connector: tokio_native_tls::TlsConnector,
9895
domain: String,
9996
}
10097

10198
impl TlsConnector {
10299
/// Creates a new connector configured to connect to the specified domain.
103100
pub fn new(connector: native_tls::TlsConnector, domain: &str) -> TlsConnector {
104101
TlsConnector {
105-
connector: tokio_tls::TlsConnector::from(connector),
102+
connector: tokio_native_tls::TlsConnector::from(connector),
106103
domain: domain.to_string(),
107104
}
108105
}
@@ -129,34 +126,19 @@ where
129126
}
130127

131128
/// The stream returned by `TlsConnector`.
132-
pub struct TlsStream<S>(tokio_tls::TlsStream<S>);
129+
pub struct TlsStream<S>(tokio_native_tls::TlsStream<S>);
133130

134131
impl<S> AsyncRead for TlsStream<S>
135132
where
136133
S: AsyncRead + AsyncWrite + Unpin,
137134
{
138-
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [MaybeUninit<u8>]) -> bool {
139-
self.0.prepare_uninitialized_buffer(buf)
140-
}
141-
142135
fn poll_read(
143136
mut self: Pin<&mut Self>,
144137
cx: &mut Context<'_>,
145-
buf: &mut [u8],
146-
) -> Poll<io::Result<usize>> {
138+
buf: &mut ReadBuf<'_>,
139+
) -> Poll<io::Result<()>> {
147140
Pin::new(&mut self.0).poll_read(cx, buf)
148141
}
149-
150-
fn poll_read_buf<B: BufMut>(
151-
mut self: Pin<&mut Self>,
152-
cx: &mut Context<'_>,
153-
buf: &mut B,
154-
) -> Poll<io::Result<usize>>
155-
where
156-
Self: Sized,
157-
{
158-
Pin::new(&mut self.0).poll_read_buf(cx, buf)
159-
}
160142
}
161143

162144
impl<S> AsyncWrite for TlsStream<S>
@@ -178,25 +160,16 @@ where
178160
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
179161
Pin::new(&mut self.0).poll_shutdown(cx)
180162
}
181-
182-
fn poll_write_buf<B: Buf>(
183-
mut self: Pin<&mut Self>,
184-
cx: &mut Context<'_>,
185-
buf: &mut B,
186-
) -> Poll<io::Result<usize>>
187-
where
188-
Self: Sized,
189-
{
190-
Pin::new(&mut self.0).poll_write_buf(cx, buf)
191-
}
192163
}
193164

194165
impl<S> tls::TlsStream for TlsStream<S>
195166
where
196167
S: AsyncRead + AsyncWrite + Unpin,
197168
{
198169
fn channel_binding(&self) -> ChannelBinding {
199-
// FIXME https://github.com/tokio-rs/tokio/issues/1383
200-
ChannelBinding::none()
170+
match self.0.get_ref().tls_server_end_point().ok().flatten() {
171+
Some(buf) => ChannelBinding::tls_server_end_point(buf),
172+
None => ChannelBinding::none(),
173+
}
201174
}
202175
}

postgres-openssl/CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Change Log
22

3+
## v0.5.0 - 2020-12-25
4+
5+
### Changed
6+
7+
* Upgraded to `tokio-postgres` 0.7.
8+
9+
## v0.4.0 - 2020-10-17
10+
11+
### Changed
12+
13+
* Upgraded to `tokio-postgres` 0.6.
14+
315
## v0.3.0 - 2019-12-23
416

517
### Changed

postgres-openssl/Cargo.toml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "postgres-openssl"
3-
version = "0.3.0"
3+
version = "0.5.0"
44
authors = ["Steven Fackler <[email protected]>"]
55
edition = "2018"
66
license = "MIT/Apache-2.0"
@@ -16,13 +16,12 @@ default = ["runtime"]
1616
runtime = ["tokio-postgres/runtime"]
1717

1818
[dependencies]
19-
bytes = "0.5"
2019
futures = "0.3"
2120
openssl = "0.10"
22-
tokio = "0.2"
23-
tokio-openssl = "0.4"
24-
tokio-postgres = { version = "0.5.0", path = "../tokio-postgres", default-features = false }
21+
tokio = "1.0"
22+
tokio-openssl = "0.6"
23+
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }
2524

2625
[dev-dependencies]
27-
tokio = { version = "0.2", features = ["full"] }
28-
postgres = { version = "0.17.0", path = "../postgres" }
26+
tokio = { version = "1.0", features = ["full"] }
27+
postgres = { version = "0.19.0", path = "../postgres" }

0 commit comments

Comments
 (0)