-
Notifications
You must be signed in to change notification settings - Fork 415
Closed
Description
The following works on rusqlite 0.27.0
but not on 0.28.0
[package]
name = "rusqlite-repro"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rusqlite = { version = "0.28.0", features = ["bundled"] }
uuid = { version = "1.1.2", features = ["v4"] }
use std::path::Path;
use rusqlite::{Connection, OpenFlags};
fn main() {
// I wanted to show with a random path each time
let filepath =
std::env::temp_dir().join(format!(".test-{}.db3", uuid::Uuid::new_v4().hyphenated()));
try_open_db(&filepath).unwrap();
}
fn try_open_db(db_path: &Path) -> Result<(), Box<dyn std::error::Error>> {
let db_open_flags = OpenFlags::SQLITE_OPEN_READ_WRITE
| OpenFlags::SQLITE_OPEN_NOFOLLOW
| OpenFlags::SQLITE_OPEN_FULL_MUTEX; // allow concurrent accesses to the DB from various threads (that's probably the default anyway, but it depends how libsqlite was compiled)
println!("Opening the DB at {}", db_path.display());
let res_open_read_write = Connection::open_with_flags(
&db_path,
db_open_flags, // SQLITE_OPEN_CREATE is not included: this will fail in case the file does not exist
);
match dbg!(res_open_read_write) {
Ok(_) => {
println!("Opened the db succesfully");
Ok(())
}
Err(err) => {
println!(
"Unable to open persistent store at {}: {}. Creating a new DB.",
db_path.display(),
err
);
// Create and initialize a new DB.
let res_open_create = Connection::open_with_flags(
&db_path,
db_open_flags | OpenFlags::SQLITE_OPEN_CREATE,
);
dbg!(res_open_create)?;
Ok(())
}
}
}
0.27.0
Opening the DB at "/var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-d00a8f83-e24d-46c1-8ab2-695d6d9ba300.db3"
[src/main.rs:23] res_open_read_write = Err(
SqliteFailure(
Error {
code: CannotOpen,
extended_code: 14,
},
Some(
"unable to open database file: /var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-d00a8f83-e24d-46c1-8ab2-695d6d9ba300.db3",
),
),
)
Unable to open persistent store at /var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-d00a8f83-e24d-46c1-8ab2-695d6d9ba300.db3: unable to open database file: /var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-d00a8f83-e24d-46c1-8ab2-695d6d9ba300.db3. Creating a new DB.
[src/main.rs:59] res_open_create = Ok(
Connection {
path: Some(
"/var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-d00a8f83-e24d-46c1-8ab2-695d6d9ba300.db3",
),
},
)
0.28.0
Opening the DB at "/var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-3ae2af5e-e494-4a74-adf9-b2859d922ea5.db3"
[src/main.rs:23] res_open_read_write = Err(
SqliteFailure(
Error {
code: CannotOpen,
extended_code: 14,
},
Some(
"unable to open database file: /var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-3ae2af5e-e494-4a74-adf9-b2859d922ea5.db3",
),
),
)
Unable to open persistent store at /var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-3ae2af5e-e494-4a74-adf9-b2859d922ea5.db3: unable to open database file: /var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-3ae2af5e-e494-4a74-adf9-b2859d922ea5.db3. Creating a new DB.
[src/main.rs:59] res_open_create = Err(
SqliteFailure(
Error {
code: CannotOpen,
extended_code: 14,
},
Some(
"unable to open database file: /var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-3ae2af5e-e494-4a74-adf9-b2859d922ea5.db3",
),
),
)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: SqliteFailure(Error { code: CannotOpen, extended_code: 14 }, Some("unable to open database file: /var/folders/v3/h26p8s510q3_8cx4297fzx3h0000gn/T/.test-3ae2af5e-e494-4a74-adf9-b2859d922ea5.db3"))', src/main.rs:9:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Metadata
Metadata
Assignees
Labels
No labels