Skip to content

Commit 0de7020

Browse files
committed
Some updates related to extra_check feature
Specify that query passed to `execute` should have no tail. Remove unreliable check in `execute_batch` (unreliable for at least for PRAGMA).
1 parent 0024ecf commit 0de7020

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ features](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-s
135135
* `i128_blob` allows storing values of type `i128` type in SQLite databases. Internally, the data is stored as a 16 byte big-endian blob, with the most significant bit flipped, which allows ordering and comparison between different blobs storing i128s to work as expected.
136136
* `uuid` allows storing and retrieving `Uuid` values from the [`uuid`](https://docs.rs/uuid/) crate using blobs.
137137
* [`session`](https://sqlite.org/sessionintro.html), Session module extension. Requires `buildtime_bindgen` feature. (Implies `hooks`.)
138-
* `extra_check` fail when a query passed to execute is readonly or has a column count > 0.
138+
* `extra_check` fails when a query passed to `execute` has tail or is readonly and has a column count > 0.
139139
* `column_decltype` provides `columns()` method for Statements and Rows; omit if linking to a version of SQLite/SQLCipher compiled with `-DSQLITE_OMIT_DECLTYPE`.
140140
* `collation` exposes [`sqlite3_create_collation_v2`](https://sqlite.org/c3ref/create_collation.html).
141141
* `serialize` exposes [`sqlite3_serialize`](http://sqlite.org/c3ref/serialize.html) (3.23.0).
@@ -256,4 +256,3 @@ Both of these are quite permissive, have no bearing on the license of the code i
256256
## Minimum supported Rust version (MSRV)
257257

258258
Latest stable Rust version at the time of release. It might compile with older versions.
259-

src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,11 @@ impl Connection {
567567
let mut sql = sql;
568568
while !sql.is_empty() {
569569
let stmt = self.prepare(sql)?;
570-
if !stmt.stmt.is_null() && stmt.step()? && cfg!(feature = "extra_check") {
570+
if !stmt.stmt.is_null() && stmt.step()? {
571571
// Some PRAGMA may return rows
572-
return Err(Error::ExecuteReturnedResults);
572+
if false {
573+
return Err(Error::ExecuteReturnedResults);
574+
}
573575
}
574576
let tail = stmt.stmt.tail();
575577
if tail == 0 || tail >= sql.len() {
@@ -1510,6 +1512,8 @@ mod test {
15101512
db.execute_batch("UPDATE foo SET x = 3 WHERE x < 3")?;
15111513

15121514
db.execute_batch("INVALID SQL").unwrap_err();
1515+
1516+
db.execute_batch("PRAGMA locking_mode = EXCLUSIVE")?;
15131517
Ok(())
15141518
}
15151519

@@ -1558,6 +1562,11 @@ mod test {
15581562
Error::MultipleStatement => (),
15591563
_ => panic!("Unexpected error: {err}"),
15601564
}
1565+
if false {
1566+
// FIXME
1567+
db.execute("CREATE TABLE t(c); -- bim", [])
1568+
.expect("Tail comment should be ignored");
1569+
}
15611570
}
15621571

15631572
#[test]
@@ -2192,7 +2201,6 @@ mod test {
21922201
}
21932202

21942203
#[test]
2195-
#[cfg(not(feature = "extra_check"))]
21962204
fn test_alter_table() -> Result<()> {
21972205
let db = Connection::open_in_memory()?;
21982206
db.execute_batch("CREATE TABLE x(t);")?;

src/pragma.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,7 @@ mod test {
427427
#[test]
428428
fn locking_mode() -> Result<()> {
429429
let db = Connection::open_in_memory()?;
430-
let r = db.pragma_update(None, "locking_mode", "exclusive");
431-
if cfg!(feature = "extra_check") {
432-
r.unwrap_err();
433-
} else {
434-
r?;
435-
}
430+
db.pragma_update(None, "locking_mode", "exclusive")?;
436431
Ok(())
437432
}
438433
}

0 commit comments

Comments
 (0)