Merge pull request #6 from jgallagher/update-for-latest-rust

Update for latest rust; add default busy timeout
This commit is contained in:
John Gallagher 2014-12-23 12:31:00 -05:00
commit 52aeb19246
6 changed files with 932 additions and 435 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "rusqlite"
version = "0.0.2"
version = "0.0.3"
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
description = "Ergonomic wrapper for SQLite"
homepage = "https://github.com/jgallagher/rusqlite"

View File

@ -1,3 +1,8 @@
# Version 0.0.3 (2014-12-23)
* Updates to track latest rustc changes.
* Add call to `sqlite3_busy_timeout`.
# Version 0.0.2 (2014-12-04)
* Remove use of now-deprecated `std::vec::raw::from_buf`.

File diff suppressed because it is too large Load Diff

View File

@ -320,12 +320,19 @@ impl InnerSqliteConnection {
SqliteError{ code: r,
message: ffi::code_to_str(r).to_string() }
} else {
let e = SqliteError::from_handle(db, r);
ffi::sqlite3_close(db);
SqliteError::from_handle(db, r)
e
};
return Err(e);
}
let r = ffi::sqlite3_busy_timeout(db, 5000);
if r != ffi::SQLITE_OK {
let e = SqliteError::from_handle(db, r);
ffi::sqlite3_close(db);
return Err(e);
}
Ok(InnerSqliteConnection{ db: db })
})
}

View File

@ -7,6 +7,7 @@ pub use SqliteTransactionBehavior::{
/// Options for transaction behavior. See [BEGIN
/// TRANSACTION](http://www.sqlite.org/lang_transaction.html) for details.
#[deriving(Copy)]
pub enum SqliteTransactionBehavior {
SqliteTransactionDeferred,
SqliteTransactionImmediate,

View File

@ -80,11 +80,11 @@ macro_rules! raw_to_impl(
}
}
)
)
);
raw_to_impl!(c_int, sqlite3_bind_int)
raw_to_impl!(i64, sqlite3_bind_int64)
raw_to_impl!(c_double, sqlite3_bind_double)
raw_to_impl!(c_int, sqlite3_bind_int);
raw_to_impl!(i64, sqlite3_bind_int64);
raw_to_impl!(c_double, sqlite3_bind_double);
impl<'a> ToSql for &'a str {
unsafe fn bind_parameter(&self, stmt: *mut ffi::sqlite3_stmt, col: c_int) -> c_int {
@ -141,6 +141,7 @@ impl<T: ToSql> ToSql for Option<T> {
/// conn.execute("INSERT INTO people (name) VALUES (?)", &[&Null])
/// }
/// ```
#[deriving(Copy)]
pub struct Null;
impl ToSql for Null {
@ -157,11 +158,11 @@ macro_rules! raw_from_impl(
}
}
)
)
);
raw_from_impl!(c_int, sqlite3_column_int)
raw_from_impl!(i64, sqlite3_column_int64)
raw_from_impl!(c_double, sqlite3_column_double)
raw_from_impl!(c_int, sqlite3_column_int);
raw_from_impl!(i64, sqlite3_column_int64);
raw_from_impl!(c_double, sqlite3_column_double);
impl FromSql for String {
unsafe fn column_result(stmt: *mut ffi::sqlite3_stmt, col: c_int) -> SqliteResult<String> {