Skip to content

Commit d7564f7

Browse files
bors[bot]syvb
andauthored
Merge #709
709: Upgrade pgx to 0.7.1 r=Smittyvb a=Smittyvb Upgrades our pgx version from 0.6.1 to 0.7.1. Co-authored-by: Smitty <[email protected]>
2 parents e8a6c13 + 5f703de commit d7564f7

Some content is hidden

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

55 files changed

+3570
-2306
lines changed

Cargo.lock

Lines changed: 190 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ As for other platforms: patches welcome!
3838

3939
### 🔧 Tools Setup ###
4040

41-
Building the extension requires valid [rust](https://www.rust-lang.org/) (we build and test on 1.64), [rustfmt](https://github.com/rust-lang/rustfmt), and clang installs, along with the postgres headers for whichever version of postgres you are running, and pgx.
41+
Building the extension requires valid [rust](https://www.rust-lang.org/) (we build and test on 1.65), [rustfmt](https://github.com/rust-lang/rustfmt), and clang installs, along with the postgres headers for whichever version of postgres you are running, and pgx.
4242
We recommend installing rust using the [official instructions](https://www.rust-lang.org/tools/install):
4343
```bash
4444
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@@ -51,7 +51,7 @@ sudo apt-get install make gcc pkg-config clang postgresql-server-dev-14 libssl-d
5151

5252
Next you need [cargo-pgx](https://github.com/tcdi/pgx), which can be installed with
5353
```bash
54-
cargo install --version '=0.6.1' --force cargo-pgx
54+
cargo install --version '=0.7.1' --force cargo-pgx
5555
```
5656

5757
You must reinstall cargo-pgx whenever you update your Rust compiler, since cargo-pgx needs to be built with the same compiler as Toolkit.

extension/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ pg_test = ["approx"]
1717
[dependencies]
1818
# Keep synchronized with `cargo install --version N.N.N cargo-pgx` in Readme.md and docker/ci/Dockerfile
1919
# Also `pgx-tests` down below in `dev-dependencies`.
20-
pgx = "=0.6.1"
21-
pgx-macros = "=0.6.1"
20+
pgx = "=0.7.1"
21+
pgx-macros = "=0.7.1"
22+
pgx-sql-entity-graph = "=0.7.1"
2223
encodings = {path="../crates/encodings"}
2324
flat_serialize = {path="../crates/flat_serialize/flat_serialize"}
2425
flat_serialize_macro = {path="../crates/flat_serialize/flat_serialize_macro"}
@@ -55,5 +56,5 @@ spfunc = "0.1.0"
5556
statrs = "0.15.0"
5657

5758
[dev-dependencies]
58-
pgx-tests = "=0.6.1"
59+
pgx-tests = "=0.7.1"
5960
approx = "0.4.0"

extension/src/aggregate_builder_tests.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,26 @@ mod tests {
8787

8888
#[pg_test]
8989
fn test_anything_in_experimental_and_returns_first() {
90-
Spi::execute(|client| {
90+
Spi::connect(|mut client| {
9191
let output = client
92-
.select(
92+
.update(
9393
"SELECT toolkit_experimental.anything(val) \
9494
FROM (VALUES ('foo'), ('bar'), ('baz')) as v(val)",
9595
None,
9696
None,
9797
)
98+
.unwrap()
9899
.first()
99-
.get_one::<String>();
100+
.get_one::<String>()
101+
.unwrap();
100102
assert_eq!(output.as_deref(), Some("foo"));
101103
})
102104
}
103105

104106
#[pg_test]
105107
fn test_anything_has_correct_fn_names_and_def() {
106-
Spi::execute(|client| {
107-
let spec = get_aggregate_spec(&client, "anything");
108+
Spi::connect(|mut client| {
109+
let spec = get_aggregate_spec(&mut client, "anything");
108110
// output is
109111
// fn kind (`a`), volatility, parallel-safety, num args, final fn modify (is this right?)
110112
// transition type (`internal`)
@@ -131,8 +133,8 @@ mod tests {
131133

132134
#[pg_test]
133135
fn test_cagg_anything_has_correct_fn_names_and_def() {
134-
Spi::execute(|client| {
135-
let spec = get_aggregate_spec(&client, "cagg_anything");
136+
Spi::connect(|mut client| {
137+
let spec = get_aggregate_spec(&mut client, "cagg_anything");
136138
// output is
137139
// fn kind (`a`), volatility, parallel-safety, num args, final fn modify (is this right?)
138140
// transition type (`internal`)
@@ -159,8 +161,8 @@ mod tests {
159161

160162
#[pg_test]
161163
fn test_parallel_anything_has_correct_fn_names_and_def() {
162-
Spi::execute(|client| {
163-
let spec = get_aggregate_spec(&client, "parallel_anything");
164+
Spi::connect(|mut client| {
165+
let spec = get_aggregate_spec(&mut client, "parallel_anything");
164166
// output is
165167
// fn kind (`a`), volatility, parallel-safety, num args, final fn modify (is this right?)
166168
// transition type (`internal`)
@@ -188,9 +190,9 @@ mod tests {
188190
// It gets annoying, and segfaulty to handle many arguments from the Spi.
189191
// For simplicity, we just return a single string representing the tuple
190192
// and use string-comparison.
191-
fn get_aggregate_spec(client: &spi::SpiClient, aggregate_name: &str) -> String {
193+
fn get_aggregate_spec(client: &mut spi::SpiClient, aggregate_name: &str) -> String {
192194
client
193-
.select(
195+
.update(
194196
&format!(
195197
r#"SELECT (
196198
prokind,
@@ -213,8 +215,10 @@ mod tests {
213215
None,
214216
None,
215217
)
218+
.unwrap()
216219
.first()
217220
.get_one::<String>()
221+
.unwrap()
218222
.expect("no aggregate found")
219223
}
220224
}

extension/src/aggregate_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use pgx::pg_sys;
44

55
// TODO move to func_utils once there are enough function to warrant one
66
pub unsafe fn get_collation(fcinfo: pg_sys::FunctionCallInfo) -> Option<pg_sys::Oid> {
7-
if (*fcinfo).fncollation == 0 {
7+
if (*fcinfo).fncollation == pg_sys::Oid::INVALID {
88
None
99
} else {
1010
Some((*fcinfo).fncollation)
@@ -13,7 +13,7 @@ pub unsafe fn get_collation(fcinfo: pg_sys::FunctionCallInfo) -> Option<pg_sys::
1313

1414
pub fn get_collation_or_default(fcinfo: pg_sys::FunctionCallInfo) -> Option<pg_sys::Oid> {
1515
if fcinfo.is_null() {
16-
Some(100) // TODO: default OID, there should be a constant for this
16+
Some(unsafe { pg_sys::Oid::from_u32_unchecked(100) }) // TODO: default OID, there should be a constant for this
1717
} else {
1818
unsafe { get_collation(fcinfo) }
1919
}

extension/src/asap.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ mod tests {
202202
fn test_against_reference() {
203203
// Test our ASAP implementation against the reference implementation at http://www.futuredata.io.s3-website-us-west-2.amazonaws.com/asap/
204204
// The sample data is the first 100 points of the second sample data set. Note that the dates are not important for this test.
205-
Spi::execute(|client| {
206-
client.select("SET timezone TO 'UTC'", None, None);
207-
let mut result = client.select(
205+
Spi::connect(|mut client| {
206+
client.update("SET timezone TO 'UTC'", None, None).unwrap();
207+
let mut result = client.update(
208208
"
209209
SELECT value
210210
FROM unnest(
@@ -223,46 +223,46 @@ mod tests {
223223
) AS v(i, val)
224224
)) s",
225225
None,
226-
None);
226+
None).unwrap();
227227

228228
assert_relative_eq!(
229-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
229+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
230230
10.39
231231
);
232232
assert_relative_eq!(
233-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
233+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
234234
9.29
235235
);
236236
assert_relative_eq!(
237-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
237+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
238238
7.54
239239
);
240240
assert_relative_eq!(
241-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
241+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
242242
7.8
243243
);
244244
assert_relative_eq!(
245-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
245+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
246246
10.34
247247
);
248248
assert_relative_eq!(
249-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
249+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
250250
11.01
251251
);
252252
assert_relative_eq!(
253-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
253+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
254254
10.54
255255
);
256256
assert_relative_eq!(
257-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
257+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
258258
8.01
259259
);
260260
assert_relative_eq!(
261-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
261+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
262262
8.99
263263
);
264264
assert_relative_eq!(
265-
result.next().unwrap()[1].value::<f64>().unwrap() as f32,
265+
result.next().unwrap()[1].value::<f64>().unwrap().unwrap() as f32,
266266
8.73
267267
);
268268
assert!(result.next().is_none());
@@ -271,8 +271,8 @@ mod tests {
271271

272272
#[pg_test]
273273
fn test_asap_equivalence() {
274-
Spi::execute(|client| {
275-
let mut value_result = client.select(
274+
Spi::connect(|mut client| {
275+
let mut value_result = client.update(
276276
"
277277
SELECT time::text, value
278278
FROM unnest(
@@ -291,9 +291,9 @@ mod tests {
291291
) AS v(i, val)
292292
)) s",
293293
None,
294-
None);
294+
None).unwrap();
295295

296-
let mut tvec_result = client.select(
296+
let mut tvec_result = client.update(
297297
"
298298
SELECT time::text, value
299299
FROM unnest(
@@ -314,13 +314,13 @@ mod tests {
314314
), 10)
315315
))",
316316
None,
317-
None);
317+
None).unwrap();
318318

319319
for _ in 0..10 {
320320
let v = value_result.next().unwrap();
321321
let t = tvec_result.next().unwrap();
322322
assert_eq!(v[1].value::<&str>(), t[1].value::<&str>());
323-
assert_eq!(v[2].value::<f64>(), t[2].value::<f64>());
323+
assert_eq!(v[2].value::<f64>().unwrap(), t[2].value::<f64>().unwrap());
324324
}
325325
assert!(value_result.next().is_none());
326326
assert!(tvec_result.next().is_none());

0 commit comments

Comments
 (0)