Merge remote-tracking branch 'upstream/master' into series

This commit is contained in:
gwenn 2021-03-06 12:38:10 +01:00
commit 73bf68f851
3 changed files with 11 additions and 28 deletions

View File

@ -424,18 +424,14 @@ fn ensure_safe_sqlite_threading_mode() -> Result<()> {
} }
unsafe { unsafe {
let msg = "\ if ffi::sqlite3_config(ffi::SQLITE_CONFIG_MULTITHREAD) != ffi::SQLITE_OK || ffi::sqlite3_initialize() != ffi::SQLITE_OK {
Could not ensure safe initialization of SQLite. panic!(
To fix this, either: "Could not ensure safe initialization of SQLite.\n\
* Upgrade SQLite to at least version 3.7.0 To fix this, either:\n\
* Ensure that SQLite has been initialized in Multi-thread or Serialized mode and call * Upgrade SQLite to at least version 3.7.0\n\
rusqlite::bypass_sqlite_initialization() prior to your first connection attempt."; * Ensure that SQLite has been initialized in Multi-thread or Serialized mode and call\n\
rusqlite::bypass_sqlite_initialization() prior to your first connection attempt."
if ffi::sqlite3_config(ffi::SQLITE_CONFIG_MULTITHREAD) != ffi::SQLITE_OK { );
panic!(msg);
}
if ffi::sqlite3_initialize() != ffi::SQLITE_OK {
panic!(msg);
} }
} }
}); });

View File

@ -170,6 +170,7 @@ impl RawStatement {
r r
} }
// does not work for PRAGMA
#[inline] #[inline]
#[cfg(all(feature = "extra_check", feature = "modern_sqlite"))] // 3.7.4 #[cfg(all(feature = "extra_check", feature = "modern_sqlite"))] // 3.7.4
pub fn readonly(&self) -> bool { pub fn readonly(&self) -> bool {

View File

@ -220,7 +220,6 @@ impl Statement<'_> {
/// Will return `Err` if binding parameters fails. /// Will return `Err` if binding parameters fails.
#[inline] #[inline]
pub fn query<P: Params>(&mut self, params: P) -> Result<Rows<'_>> { pub fn query<P: Params>(&mut self, params: P) -> Result<Rows<'_>> {
self.check_readonly()?;
params.__bind_in(self)?; params.__bind_in(self)?;
Ok(Rows::new(self)) Ok(Rows::new(self))
} }
@ -718,21 +717,6 @@ impl Statement<'_> {
self.conn.decode_result(stmt.finalize()) self.conn.decode_result(stmt.finalize())
} }
#[cfg(not(feature = "modern_sqlite"))]
#[inline]
fn check_readonly(&self) -> Result<()> {
Ok(())
}
#[cfg(feature = "modern_sqlite")]
#[inline]
fn check_readonly(&self) -> Result<()> {
/*if !self.stmt.readonly() { does not work for PRAGMA
return Err(Error::InvalidQuery);
}*/
Ok(())
}
#[cfg(all(feature = "modern_sqlite", feature = "extra_check"))] #[cfg(all(feature = "modern_sqlite", feature = "extra_check"))]
#[inline] #[inline]
fn check_update(&self) -> Result<()> { fn check_update(&self) -> Result<()> {
@ -755,6 +739,7 @@ impl Statement<'_> {
#[cfg(not(feature = "extra_check"))] #[cfg(not(feature = "extra_check"))]
#[inline] #[inline]
#[allow(clippy::unnecessary_wraps)]
fn check_update(&self) -> Result<()> { fn check_update(&self) -> Result<()> {
Ok(()) Ok(())
} }
@ -793,6 +778,7 @@ impl Statement<'_> {
#[cfg(not(feature = "extra_check"))] #[cfg(not(feature = "extra_check"))]
#[inline] #[inline]
#[allow(clippy::unnecessary_wraps)]
pub(crate) fn check_no_tail(&self) -> Result<()> { pub(crate) fn check_no_tail(&self) -> Result<()> {
Ok(()) Ok(())
} }