Skip to content

Commit a1a23ea

Browse files
committed
Lower MSRV to 1.88.0
1 parent 54f7d4d commit a1a23ea

5 files changed

Lines changed: 107 additions & 36 deletions

File tree

‎libsqlite3-sys/build.rs‎

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
use std::env;
22
use std::path::Path;
33

4+
// Just to keep MSRV low
5+
#[cfg(any(
6+
feature = "bundled",
7+
feature = "bundled-windows",
8+
feature = "bundled-sqlcipher",
9+
feature = "buildtime_bindgen",
10+
))]
11+
macro_rules! cfg_select {
12+
({ $($tt:tt)* }) => {{
13+
$crate::cfg_select! { $($tt)* }
14+
}};
15+
(_ => { $($output:tt)* }) => {
16+
$($output)*
17+
};
18+
(
19+
$cfg:meta => $output:tt
20+
$($( $rest:tt )+)?
21+
) => {{
22+
#[cfg($cfg)]
23+
cfg_select! { _ => $output }
24+
$(
25+
#[cfg(not($cfg))]
26+
cfg_select! { $($rest)+ }
27+
)?
28+
}}
29+
}
30+
431
#[cfg(all(feature = "loadable_extension", feature = "preupdate_hook"))]
532
compile_error!(
633
"feature \"loadable_extension\" and feature \"preupdate_hook\" cannot be enabled at the same time"
@@ -113,7 +140,7 @@ mod build_bundled {
113140

114141
cfg_select! {
115142
feature = "buildtime_bindgen" => {
116-
use super::{bindings, HeaderLocation};
143+
use super::{HeaderLocation, bindings};
117144
let header = HeaderLocation::FromPath(lib_name.to_owned());
118145
bindings::write_to_out_dir(header, out_path);
119146
}
@@ -657,9 +684,11 @@ mod bindings {
657684
std::fs::write(out_path, output.as_bytes())
658685
.unwrap_or_else(|_| panic!("Could not write to {out_path:?}"));
659686
}
660-
_ => bindings
687+
_ => {
688+
bindings
661689
.write_to_file(out_path)
662-
.unwrap_or_else(|_| panic!("Could not write to {out_path:?}"))
690+
.unwrap_or_else(|_| panic!("Could not write to {out_path:?}"));
691+
}
663692
}
664693
}
665694
}

‎src/error.rs‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ use std::fmt;
77
use std::path::PathBuf;
88
use std::str;
99

10+
// Just to keep MSRV low
11+
macro_rules! cfg_select {
12+
({ $($tt:tt)* }) => {{
13+
$crate::cfg_select! { $($tt)* }
14+
}};
15+
(_ => { $($output:tt)* }) => {
16+
$($output)*
17+
};
18+
(
19+
$cfg:meta => $output:tt
20+
$($( $rest:tt )+)?
21+
) => {{
22+
#[cfg($cfg)]
23+
cfg_select! { _ => $output }
24+
$(
25+
#[cfg(not($cfg))]
26+
cfg_select! { $($rest)+ }
27+
)?
28+
}}
29+
}
30+
1031
/// Enum listing possible errors from rusqlite.
1132
#[derive(Debug)]
1233
#[non_exhaustive]
@@ -472,7 +493,7 @@ pub unsafe fn decode_result_raw(db: *mut ffi::sqlite3, code: c_int) -> Result<()
472493
pub unsafe fn error_with_offset(db: *mut ffi::sqlite3, code: c_int, sql: &str) -> Error {
473494
unsafe {
474495
cfg_select! {
475-
feature = "modern_sqlite" => // SQLite >= 3.38.0
496+
feature = "modern_sqlite" => { // SQLite >= 3.38.0
476497
if db.is_null() {
477498
error_from_sqlite_code(code, None)
478499
} else {
@@ -491,7 +512,10 @@ pub unsafe fn error_with_offset(db: *mut ffi::sqlite3, code: c_int, sql: &str) -
491512
}
492513
Error::SqliteFailure(error, msg)
493514
}
494-
_ => error_from_handle(db, code)
515+
}
516+
_ => {
517+
error_from_handle(db, code)
518+
}
495519
}
496520
}
497521
}

‎src/inner_connection.rs‎

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -220,37 +220,41 @@ impl InnerConnection {
220220
let c_sql = sql.as_bytes().as_ptr().cast::<c_char>();
221221
let mut c_tail: *const c_char = ptr::null();
222222
let r = cfg_select! {
223-
feature = "unlock_notify" => unsafe {
224-
use crate::unlock_notify;
225-
let mut rc;
226-
loop {
227-
rc = ffi::sqlite3_prepare_v3(
223+
feature = "unlock_notify" => {
224+
unsafe {
225+
use crate::unlock_notify;
226+
let mut rc;
227+
loop {
228+
rc = ffi::sqlite3_prepare_v3(
229+
self.db(),
230+
c_sql,
231+
len,
232+
flags.bits(),
233+
&mut c_stmt,
234+
&mut c_tail,
235+
);
236+
if !unlock_notify::is_locked(self.db, rc) {
237+
break;
238+
}
239+
rc = unlock_notify::wait_for_unlock_notify(self.db);
240+
if rc != ffi::SQLITE_OK {
241+
break;
242+
}
243+
}
244+
rc
245+
}
246+
}
247+
_ => {
248+
unsafe {
249+
ffi::sqlite3_prepare_v3(
228250
self.db(),
229251
c_sql,
230252
len,
231253
flags.bits(),
232254
&mut c_stmt,
233255
&mut c_tail,
234-
);
235-
if !unlock_notify::is_locked(self.db, rc) {
236-
break;
237-
}
238-
rc = unlock_notify::wait_for_unlock_notify(self.db);
239-
if rc != ffi::SQLITE_OK {
240-
break;
241-
}
256+
)
242257
}
243-
rc
244-
}
245-
_ => unsafe {
246-
ffi::sqlite3_prepare_v3(
247-
self.db(),
248-
c_sql,
249-
len,
250-
flags.bits(),
251-
&mut c_stmt,
252-
&mut c_tail,
253-
)
254258
}
255259
};
256260
// If there is an error, *ppStmt is set to NULL.
@@ -279,8 +283,12 @@ impl InnerConnection {
279283
pub fn changes(&self) -> u64 {
280284
unsafe {
281285
cfg_select! {
282-
feature = "modern_sqlite" => ffi::sqlite3_changes64(self.db()) as u64, // 3.37.0
283-
_ => ffi::sqlite3_changes(self.db()) as u64
286+
feature = "modern_sqlite" => { // 3.37.0
287+
ffi::sqlite3_changes64(self.db()) as u64
288+
}
289+
_ => {
290+
ffi::sqlite3_changes(self.db()) as u64
291+
}
284292
}
285293
}
286294
}
@@ -289,8 +297,12 @@ impl InnerConnection {
289297
pub fn total_changes(&self) -> u64 {
290298
unsafe {
291299
cfg_select! {
292-
feature = "modern_sqlite" => ffi::sqlite3_total_changes64(self.db()) as u64, // 3.37.0
293-
_ => ffi::sqlite3_total_changes(self.db()) as u64
300+
feature = "modern_sqlite" => { // 3.37.0
301+
ffi::sqlite3_total_changes64(self.db()) as u64
302+
}
303+
_ => {
304+
ffi::sqlite3_total_changes(self.db()) as u64
305+
}
294306
}
295307
}
296308
}

‎src/pragma.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ impl Sql {
2929
}
3030
const SQL: &str = "SELECT 1 FROM pragma_pragma_list WHERE name = ?";
3131
let mut stmt = cfg_select! {
32-
feature = "cache" => {conn.prepare_cached(SQL)}
33-
_ => conn.prepare(SQL)
32+
feature = "cache" => {
33+
conn.prepare_cached(SQL)
34+
}
35+
_ => {
36+
conn.prepare(SQL)
37+
}
3438
}?;
3539
if stmt.exists([pragma_name])? {
3640
self.buf.push_str(pragma_name);

‎src/raw_statement.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ impl RawStatement {
171171
}
172172
}
173173
}
174-
_ => unsafe { ffi::sqlite3_step(self.ptr) }
174+
_ => {
175+
unsafe { ffi::sqlite3_step(self.ptr) }
176+
}
175177
}
176178
}
177179

0 commit comments

Comments
 (0)