Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1eeb149

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parentsbe48805 +6fd0444 commit1eeb149

35 files changed

+1085
-164
lines changed

‎postgres-native-tls/Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ runtime = ["tokio-postgres/runtime"]
1919
native-tls ="0.2"
2020
tokio ="1.0"
2121
tokio-native-tls ="0.3"
22-
tokio-postgres = {version ="0.7.0",path ="../tokio-postgres",default-features =false }
22+
tokio-postgres = {version ="0.7.11",path ="../tokio-postgres",default-features =false }
2323

2424
[dev-dependencies]
2525
futures-util ="0.3"
2626
tokio = {version ="1.0",features = ["macros","net","rt"] }
27-
postgres = {version ="0.19.0",path ="../postgres" }
27+
postgres = {version ="0.19.8",path ="../postgres" }

‎postgres-openssl/Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ runtime = ["tokio-postgres/runtime"]
1919
openssl ="0.10"
2020
tokio ="1.0"
2121
tokio-openssl ="0.6"
22-
tokio-postgres = {version ="0.7.0",path ="../tokio-postgres",default-features =false }
22+
tokio-postgres = {version ="0.7.11",path ="../tokio-postgres",default-features =false }
2323

2424
[dev-dependencies]
2525
futures-util ="0.3"
2626
tokio = {version ="1.0",features = ["macros","net","rt"] }
27-
postgres = {version ="0.19.0",path ="../postgres" }
27+
postgres = {version ="0.19.8",path ="../postgres" }

‎postgres-protocol/CHANGELOG.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
#Change Log
22

3-
##v0.6.6 -2023-08-19
3+
##v0.6.7 - 2024-07-21
4+
5+
###Deprecated
6+
7+
* Deprecated`ErrorField::value`.
8+
9+
###Added
10+
11+
* Added a`Clone` implementation for`DataRowBody`.
12+
* Added`ErrorField::value_bytes`.
13+
14+
###Changed
15+
16+
* Upgraded`base64`.
17+
18+
##v0.6.6 - 2023-08-19
419

520
###Added
621

‎postgres-protocol/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name ="postgres-protocol"
3-
version ="0.6.6"
3+
version ="0.6.7"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55
edition ="2018"
66
description ="Low level Postgres protocol APIs"

‎postgres-protocol/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ macro_rules! from_usize {
6060
implFromUsizefor $t{
6161
#[inline]
6262
fn from_usize(x:usize) -> io::Result<$t>{
63-
if x > <$t>::max_value()asusize{
63+
if x > <$t>::MAXasusize{
6464
Err(io::Error::new(
6565
io::ErrorKind::InvalidInput,
6666
"value too large to transmit",

‎postgres-protocol/src/message/backend.rs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl CopyOutResponseBody {
524524
}
525525
}
526526

527-
#[derive(Debug)]
527+
#[derive(Debug,Clone)]
528528
pubstructDataRowBody{
529529
storage:Bytes,
530530
len:u16,
@@ -633,7 +633,7 @@ impl<'a> FallibleIterator for ErrorFields<'a> {
633633
}
634634

635635
let value_end =find_null(self.buf,0)?;
636-
let value =get_str(&self.buf[..value_end])?;
636+
let value =&self.buf[..value_end];
637637
self.buf =&self.buf[value_end +1..];
638638

639639
Ok(Some(ErrorField{ type_, value}))
@@ -642,7 +642,7 @@ impl<'a> FallibleIterator for ErrorFields<'a> {
642642

643643
pubstructErrorField<'a>{
644644
type_:u8,
645-
value:&'astr,
645+
value:&'a[u8],
646646
}
647647

648648
impl<'a>ErrorField<'a>{
@@ -652,7 +652,13 @@ impl<'a> ErrorField<'a> {
652652
}
653653

654654
#[inline]
655+
#[deprecated(note ="use value_bytes instead", since ="0.6.7")]
655656
pubfnvalue(&self) ->&str{
657+
str::from_utf8(self.value).expect("error field value contained non-UTF8 bytes")
658+
}
659+
660+
#[inline]
661+
pubfnvalue_bytes(&self) ->&[u8]{
656662
self.value
657663
}
658664
}

‎postgres-types/CHANGELOG.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@
22

33
##Unreleased
44

5+
###Added
6+
7+
* Added support for`jiff` 0.1 via the`with-jiff-01` feature.
8+
9+
##v0.2.7 - 2024-07-21
10+
11+
###Added
12+
13+
* Added`Default` implementation for`Json`.
14+
* Added a`js` feature for WASM compatibility.
15+
516
###Changed
617

718
*`FromStr` implementation for`PgLsn` no longer allocates a`Vec` when splitting an lsn string on it's`/`.
19+
* The`eui48-1` feature no longer enables default features of the`eui48` library.
820

921
##v0.2.6 - 2023-08-19
1022

‎postgres-types/Cargo.toml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name ="postgres-types"
3-
version ="0.2.6"
3+
version ="0.2.7"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55
edition ="2018"
66
license ="MIT OR Apache-2.0"
@@ -13,13 +13,15 @@ categories = ["database"]
1313
[features]
1414
derive = ["postgres-derive"]
1515
array-impls = ["array-init"]
16+
js = ["postgres-protocol/js"]
1617
with-bit-vec-0_6 = ["bit-vec-06"]
1718
with-cidr-0_2 = ["cidr-02"]
1819
with-chrono-0_4 = ["chrono-04"]
1920
with-eui48-0_4 = ["eui48-04"]
2021
with-eui48-1 = ["eui48-1"]
2122
with-geo-types-0_6 = ["geo-types-06"]
2223
with-geo-types-0_7 = ["geo-types-0_7"]
24+
with-jiff-0_1 = ["jiff-01"]
2325
with-serde_json-1 = ["serde-1","serde_json-1"]
2426
with-smol_str-01 = ["smol_str-01"]
2527
with-uuid-0_8 = ["uuid-08"]
@@ -30,7 +32,7 @@ with-time-0_3 = ["time-03"]
3032
[dependencies]
3133
bytes ="1.0"
3234
fallible-iterator ="0.2"
33-
postgres-protocol = {version ="0.6.5",path ="../postgres-protocol" }
35+
postgres-protocol = {version ="0.6.7",path ="../postgres-protocol" }
3436
postgres-derive = {version ="0.4.5",optional =true,path ="../postgres-derive" }
3537

3638
array-init = {version ="2",optional =true }
@@ -45,6 +47,7 @@ eui48-04 = { version = "0.4", package = "eui48", optional = true }
4547
eui48-1 = {version ="1.0",package ="eui48",optional =true,default-features =false }
4648
geo-types-06 = {version ="0.6",package ="geo-types",optional =true }
4749
geo-types-0_7 = {version ="0.7",package ="geo-types",optional =true }
50+
jiff-01 = {version ="0.1",package ="jiff",optional =true }
4851
serde-1 = {version ="1.0",package ="serde",optional =true }
4952
serde_json-1 = {version ="1.0",package ="serde_json",optional =true }
5053
uuid-08 = {version ="0.8",package ="uuid",optional =true }

‎postgres-types/src/jiff_01.rs‎

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
use bytes::BytesMut;
2+
use jiff_01::{
3+
civil::{Date,DateTime,Time},
4+
Span,SpanRound,Timestamp,Unit,
5+
};
6+
use postgres_protocol::types;
7+
use std::error::Error;
8+
9+
usecrate::{FromSql,IsNull,ToSql,Type};
10+
11+
constfnbase() ->DateTime{
12+
DateTime::constant(2000,1,1,0,0,0,0)
13+
}
14+
15+
/// The number of seconds from the Unix epoch to 2000-01-01 00:00:00 UTC.
16+
constPG_EPOCH:i64 =946684800;
17+
18+
fnbase_ts() ->Timestamp{
19+
Timestamp::new(PG_EPOCH,0).unwrap()
20+
}
21+
22+
fnround_us<'a>() ->SpanRound<'a>{
23+
SpanRound::new().largest(Unit::Microsecond)
24+
}
25+
26+
fndecode_err<E>(_e:E) ->Box<dynError +Sync +Send>
27+
where
28+
E:Error,
29+
{
30+
"value too large to decode".into()
31+
}
32+
33+
fntransmit_err<E>(_e:E) ->Box<dynError +Sync +Send>
34+
where
35+
E:Error,
36+
{
37+
"value too large to transmit".into()
38+
}
39+
40+
impl<'a>FromSql<'a>forDateTime{
41+
fnfrom_sql(_:&Type,raw:&[u8]) ->Result<DateTime,Box<dynError +Sync +Send>>{
42+
let v = types::timestamp_from_sql(raw)?;
43+
Span::new()
44+
.try_microseconds(v)
45+
.and_then(|s|base().checked_add(s))
46+
.map_err(decode_err)
47+
}
48+
49+
accepts!(TIMESTAMP);
50+
}
51+
52+
implToSqlforDateTime{
53+
fnto_sql(&self, _:&Type,w:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
54+
let v =self
55+
.since(base())
56+
.and_then(|s| s.round(round_us()))
57+
.map_err(transmit_err)?
58+
.get_microseconds();
59+
types::timestamp_to_sql(v, w);
60+
Ok(IsNull::No)
61+
}
62+
63+
accepts!(TIMESTAMP);
64+
to_sql_checked!();
65+
}
66+
67+
impl<'a>FromSql<'a>forTimestamp{
68+
fnfrom_sql(_:&Type,raw:&[u8]) ->Result<Timestamp,Box<dynError +Sync +Send>>{
69+
let v = types::timestamp_from_sql(raw)?;
70+
Span::new()
71+
.try_microseconds(v)
72+
.and_then(|s|base_ts().checked_add(s))
73+
.map_err(decode_err)
74+
}
75+
76+
accepts!(TIMESTAMPTZ);
77+
}
78+
79+
implToSqlforTimestamp{
80+
fnto_sql(&self, _:&Type,w:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
81+
let v =self
82+
.since(base_ts())
83+
.and_then(|s| s.round(round_us()))
84+
.map_err(transmit_err)?
85+
.get_microseconds();
86+
types::timestamp_to_sql(v, w);
87+
Ok(IsNull::No)
88+
}
89+
90+
accepts!(TIMESTAMPTZ);
91+
to_sql_checked!();
92+
}
93+
94+
impl<'a>FromSql<'a>forDate{
95+
fnfrom_sql(_:&Type,raw:&[u8]) ->Result<Date,Box<dynError +Sync +Send>>{
96+
let v = types::date_from_sql(raw)?;
97+
Span::new()
98+
.try_days(v)
99+
.and_then(|s|base().date().checked_add(s))
100+
.map_err(decode_err)
101+
}
102+
accepts!(DATE);
103+
}
104+
105+
implToSqlforDate{
106+
fnto_sql(&self, _:&Type,w:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
107+
let v =self.since(base().date()).map_err(transmit_err)?.get_days();
108+
types::date_to_sql(v, w);
109+
Ok(IsNull::No)
110+
}
111+
112+
accepts!(DATE);
113+
to_sql_checked!();
114+
}
115+
116+
impl<'a>FromSql<'a>forTime{
117+
fnfrom_sql(_:&Type,raw:&[u8]) ->Result<Time,Box<dynError +Sync +Send>>{
118+
let v = types::time_from_sql(raw)?;
119+
Span::new()
120+
.try_microseconds(v)
121+
.and_then(|s|Time::midnight().checked_add(s))
122+
.map_err(decode_err)
123+
}
124+
125+
accepts!(TIME);
126+
}
127+
128+
implToSqlforTime{
129+
fnto_sql(&self, _:&Type,w:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
130+
let v =self
131+
.since(Time::midnight())
132+
.and_then(|s| s.round(round_us()))
133+
.map_err(transmit_err)?
134+
.get_microseconds();
135+
types::time_to_sql(v, w);
136+
Ok(IsNull::No)
137+
}
138+
139+
accepts!(TIME);
140+
to_sql_checked!();
141+
}

‎postgres-types/src/lib.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ mod eui48_1;
276276
mod geo_types_06;
277277
#[cfg(feature ="with-geo-types-0_7")]
278278
mod geo_types_07;
279+
#[cfg(feature ="with-jiff-0_1")]
280+
mod jiff_01;
279281
#[cfg(feature ="with-serde_json-1")]
280282
mod serde_json_1;
281283
#[cfg(feature ="with-smol_str-01")]
@@ -491,6 +493,10 @@ impl WrongType {
491493
/// | `time::OffsetDateTime` | TIMESTAMP WITH TIME ZONE |
492494
/// | `time::Date` | DATE |
493495
/// | `time::Time` | TIME |
496+
/// | `jiff::civil::Date` | DATE |
497+
/// | `jiff::civil::DateTime` | TIMESTAMP |
498+
/// | `jiff::civil::Time` | TIME |
499+
/// | `jiff::Timestamp` | TIMESTAMP WITH TIME ZONE |
494500
/// | `eui48::MacAddress` | MACADDR |
495501
/// | `geo_types::Point<f64>` | POINT |
496502
/// | `geo_types::Rect<f64>` | BOX |
@@ -1222,7 +1228,7 @@ impl ToSql for IpAddr {
12221228
}
12231229

12241230
fndowncast(len:usize) ->Result<i32,Box<dynError +Sync +Send>>{
1225-
if len > i32::max_value()asusize{
1231+
if len > i32::MAXasusize{
12261232
Err("value too large to transmit".into())
12271233
}else{
12281234
Ok(lenasi32)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp