Skip to content

Commit 14297cd

Browse files
committed
cleanup compilation warnings
1 parent dad9ed2 commit 14297cd

File tree

6 files changed

+25
-29
lines changed

6 files changed

+25
-29
lines changed

pgrx-tests/src/tests/bgworker_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub extern "C" fn bgworker(arg: pg_sys::Datum) {
2626
if arg > 0 {
2727
BackgroundWorker::transaction(|| {
2828
Spi::run("CREATE TABLE tests.bgworker_test (v INTEGER);")?;
29-
Spi::connect(|mut client| {
29+
Spi::connect(|client| {
3030
client
3131
.update(
3232
"INSERT INTO tests.bgworker_test VALUES ($1);",
@@ -74,7 +74,7 @@ pub extern "C" fn bgworker_return_value(arg: pg_sys::Datum) {
7474
};
7575
while BackgroundWorker::wait_latch(Some(Duration::from_millis(100))) {}
7676
BackgroundWorker::transaction(|| {
77-
Spi::connect(|mut c| {
77+
Spi::connect(|c| {
7878
c.update(
7979
"INSERT INTO tests.bgworker_test_return VALUES ($1)",
8080
None,

pgrx-tests/src/tests/spi_tests.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ mod tests {
180180

181181
#[pg_test]
182182
fn test_inserting_null() -> Result<(), pgrx::spi::Error> {
183-
Spi::connect(|mut client| {
183+
Spi::connect(|client| {
184184
client.update("CREATE TABLE tests.null_test (id uuid)", None, None).map(|_| ())
185185
})?;
186186
assert_eq!(
@@ -203,7 +203,7 @@ mod tests {
203203

204204
#[pg_test]
205205
fn test_cursor() -> Result<(), spi::Error> {
206-
Spi::connect(|mut client| {
206+
Spi::connect(|client| {
207207
client.update("CREATE TABLE tests.cursor_table (id int)", None, None)?;
208208
client.update(
209209
"INSERT INTO tests.cursor_table (id) \
@@ -223,7 +223,7 @@ mod tests {
223223

224224
#[pg_test]
225225
fn test_cursor_prepared_statement() -> Result<(), pgrx::spi::Error> {
226-
Spi::connect(|mut client| {
226+
Spi::connect(|client| {
227227
client.update("CREATE TABLE tests.cursor_table (id int)", None, None)?;
228228
client.update(
229229
"INSERT INTO tests.cursor_table (id) \
@@ -244,7 +244,7 @@ mod tests {
244244

245245
#[pg_test]
246246
fn test_cursor_by_name() -> Result<(), pgrx::spi::Error> {
247-
let cursor_name = Spi::connect(|mut client| {
247+
let cursor_name = Spi::connect(|client| {
248248
client.update("CREATE TABLE tests.cursor_table (id int)", None, None)?;
249249
client.update(
250250
"INSERT INTO tests.cursor_table (id) \
@@ -298,7 +298,7 @@ mod tests {
298298
Ok::<_, spi::Error>(())
299299
})?;
300300

301-
Spi::connect(|mut client| {
301+
Spi::connect(|client| {
302302
let res = client.update("SET TIME ZONE 'PST8PDT'", None, None)?;
303303

304304
assert_eq!(Err(spi::Error::NoTupleTable), res.columns());
@@ -315,7 +315,7 @@ mod tests {
315315
#[pg_test]
316316
fn test_spi_non_mut() -> Result<(), pgrx::spi::Error> {
317317
// Ensures update and cursor APIs do not need mutable reference to SpiClient
318-
Spi::connect(|mut client| {
318+
Spi::connect(|client| {
319319
client.update("SELECT 1", None, None).expect("SPI failed");
320320
let cursor = client.open_cursor("SELECT 1", None).detach_into_name();
321321
client.find_cursor(&cursor).map(|_| ())
@@ -410,7 +410,7 @@ mod tests {
410410

411411
#[pg_test]
412412
fn test_readwrite_in_select_readwrite() -> Result<(), spi::Error> {
413-
Spi::connect(|mut client| {
413+
Spi::connect(|client| {
414414
// This is supposed to switch connection to read-write and run it there
415415
client.update("CREATE TABLE a (id INT)", None, None)?;
416416
// This is supposed to run in read-write
@@ -421,7 +421,7 @@ mod tests {
421421

422422
#[pg_test]
423423
fn test_spi_select_sees_update() -> spi::Result<()> {
424-
let with_select = Spi::connect(|mut client| {
424+
let with_select = Spi::connect(|client| {
425425
client.update("CREATE TABLE asd(id int)", None, None)?;
426426
client.update("INSERT INTO asd(id) VALUES (1)", None, None)?;
427427
client.select("SELECT COUNT(*) FROM asd", None, None)?.first().get_one::<i64>()
@@ -447,7 +447,7 @@ mod tests {
447447

448448
#[pg_test]
449449
fn test_spi_select_sees_update_in_other_session() -> spi::Result<()> {
450-
Spi::connect::<spi::Result<()>, _>(|mut client| {
450+
Spi::connect::<spi::Result<()>, _>(|client| {
451451
client.update("CREATE TABLE asd(id int)", None, None)?;
452452
client.update("INSERT INTO asd(id) VALUES (1)", None, None)?;
453453
Ok(())

pgrx-tests/src/tests/srf_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ mod tests {
255255

256256
#[pg_test]
257257
fn test_srf_setof_datum_detoasting_with_borrow() {
258-
let cnt = Spi::connect(|mut client| {
258+
let cnt = Spi::connect(|client| {
259259
// build up a table with one large column that Postgres will be forced to TOAST
260260
client.update("CREATE TABLE test_srf_datum_detoasting AS SELECT array_to_string(array_agg(g),' ') s FROM (SELECT 'a' g FROM generate_series(1, 1000000)) x;", None, None)?;
261261

@@ -273,7 +273,7 @@ mod tests {
273273

274274
#[pg_test]
275275
fn test_srf_table_datum_detoasting_with_borrow() {
276-
let cnt = Spi::connect(|mut client| {
276+
let cnt = Spi::connect(|client| {
277277
// build up a table with one large column that Postgres will be forced to TOAST
278278
client.update("CREATE TABLE test_srf_datum_detoasting AS SELECT array_to_string(array_agg(g),' ') s FROM (SELECT 'a' g FROM generate_series(1, 1000000)) x;", None, None)?;
279279

pgrx-tests/src/tests/struct_type_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ mod tests {
143143

144144
#[pg_test]
145145
fn test_complex_storage_and_retrieval() -> Result<(), pgrx::spi::Error> {
146-
let complex = Spi::connect(|mut client| {
146+
let complex = Spi::connect(|client| {
147147
client.update(
148148
"CREATE TABLE complex_test AS SELECT s as id, (s || '.0, 2.0' || s)::complex as value FROM generate_series(1, 1000) s;\
149149
SELECT value FROM complex_test ORDER BY id;", None, None)?.first().get_one::<PgBox<Complex>>()

pgrx/src/spi.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ impl Spi {
240240
}
241241

242242
pub fn get_one<A: FromDatum + IntoDatum>(query: &str) -> Result<Option<A>> {
243-
Spi::connect(|mut client| client.update(query, Some(1), None)?.first().get_one())
243+
Spi::connect(|client| client.update(query, Some(1), None)?.first().get_one())
244244
}
245245

246246
pub fn get_two<A: FromDatum + IntoDatum, B: FromDatum + IntoDatum>(
247247
query: &str,
248248
) -> Result<(Option<A>, Option<B>)> {
249-
Spi::connect(|mut client| client.update(query, Some(1), None)?.first().get_two::<A, B>())
249+
Spi::connect(|client| client.update(query, Some(1), None)?.first().get_two::<A, B>())
250250
}
251251

252252
pub fn get_three<
@@ -256,25 +256,21 @@ impl Spi {
256256
>(
257257
query: &str,
258258
) -> Result<(Option<A>, Option<B>, Option<C>)> {
259-
Spi::connect(|mut client| {
260-
client.update(query, Some(1), None)?.first().get_three::<A, B, C>()
261-
})
259+
Spi::connect(|client| client.update(query, Some(1), None)?.first().get_three::<A, B, C>())
262260
}
263261

264262
pub fn get_one_with_args<A: FromDatum + IntoDatum>(
265263
query: &str,
266264
args: Vec<(PgOid, Option<pg_sys::Datum>)>,
267265
) -> Result<Option<A>> {
268-
Spi::connect(|mut client| client.update(query, Some(1), Some(args))?.first().get_one())
266+
Spi::connect(|client| client.update(query, Some(1), Some(args))?.first().get_one())
269267
}
270268

271269
pub fn get_two_with_args<A: FromDatum + IntoDatum, B: FromDatum + IntoDatum>(
272270
query: &str,
273271
args: Vec<(PgOid, Option<pg_sys::Datum>)>,
274272
) -> Result<(Option<A>, Option<B>)> {
275-
Spi::connect(|mut client| {
276-
client.update(query, Some(1), Some(args))?.first().get_two::<A, B>()
277-
})
273+
Spi::connect(|client| client.update(query, Some(1), Some(args))?.first().get_two::<A, B>())
278274
}
279275

280276
pub fn get_three_with_args<
@@ -285,7 +281,7 @@ impl Spi {
285281
query: &str,
286282
args: Vec<(PgOid, Option<pg_sys::Datum>)>,
287283
) -> Result<(Option<A>, Option<B>, Option<C>)> {
288-
Spi::connect(|mut client| {
284+
Spi::connect(|client| {
289285
client.update(query, Some(1), Some(args))?.first().get_three::<A, B, C>()
290286
})
291287
}
@@ -308,7 +304,7 @@ impl Spi {
308304
query: &str,
309305
args: Option<Vec<(PgOid, Option<pg_sys::Datum>)>>,
310306
) -> std::result::Result<(), Error> {
311-
Spi::connect(|mut client| client.update(query, None, args).map(|_| ()))
307+
Spi::connect(|client| client.update(query, None, args).map(|_| ()))
312308
}
313309

314310
/// explain a query, returning its result in json form
@@ -321,7 +317,7 @@ impl Spi {
321317
query: &str,
322318
args: Option<Vec<(PgOid, Option<pg_sys::Datum>)>>,
323319
) -> Result<Json> {
324-
Ok(Spi::connect(|mut client| {
320+
Ok(Spi::connect(|client| {
325321
client
326322
.update(&format!("EXPLAIN (format json) {}", query), None, args)?
327323
.first()

pgrx/src/spi/cursor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type CursorName = String;
3131
/// ```rust,no_run
3232
/// use pgrx::prelude::*;
3333
/// # fn foo() -> spi::Result<()> {
34-
/// Spi::connect(|mut client| {
34+
/// Spi::connect(|client| {
3535
/// let mut cursor = client.open_cursor("SELECT * FROM generate_series(1, 5)", None);
3636
/// assert_eq!(Some(1u32), cursor.fetch(1)?.get_one::<u32>()?);
3737
/// assert_eq!(Some(2u32), cursor.fetch(2)?.get_one::<u32>()?);
@@ -46,13 +46,13 @@ type CursorName = String;
4646
/// ```rust,no_run
4747
/// use pgrx::prelude::*;
4848
/// # fn foo() -> spi::Result<()> {
49-
/// let cursor_name = Spi::connect(|mut client| {
49+
/// let cursor_name = Spi::connect(|client| {
5050
/// let mut cursor = client.open_cursor("SELECT * FROM generate_series(1, 5)", None);
5151
/// assert_eq!(Ok(Some(1u32)), cursor.fetch(1)?.get_one::<u32>());
5252
/// Ok::<_, spi::Error>(cursor.detach_into_name()) // <-- cursor gets dropped here
5353
/// // <--- first SpiTupleTable gets freed by Spi::connect at this point
5454
/// })?;
55-
/// Spi::connect(|mut client| {
55+
/// Spi::connect(|client| {
5656
/// let mut cursor = client.find_cursor(&cursor_name)?;
5757
/// assert_eq!(Ok(Some(2u32)), cursor.fetch(1)?.get_one::<u32>());
5858
/// drop(cursor); // <-- cursor gets dropped here

0 commit comments

Comments
 (0)