Merge remote-tracking branch 'jgallagher/master' into vtab

This commit is contained in:
gwenn
2016-07-02 11:51:42 +02:00
10 changed files with 62 additions and 40 deletions

View File

@@ -50,8 +50,6 @@
//! }
//! }
//! ```
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
extern crate libc;
extern crate libsqlite3_sys as ffi;
@@ -106,6 +104,7 @@ mod raw_statement;
const STATEMENT_CACHE_DEFAULT_CAPACITY: usize = 16;
/// Old name for `Result`. `SqliteResult` is deprecated.
#[deprecated(since = "0.6.0", note = "Use Result instead")]
pub type SqliteResult<T> = Result<T>;
/// A typedef of the result returned by many methods.
@@ -152,6 +151,7 @@ impl<'a> DatabaseName<'a> {
}
/// Old name for `Connection`. `SqliteConnection` is deprecated.
#[deprecated(since = "0.6.0", note = "Use Connection instead")]
pub type SqliteConnection = Connection;
/// A connection to a SQLite database.
@@ -368,6 +368,7 @@ impl Connection {
///
/// This method should be considered deprecated. Use `query_row` instead, which now
/// does exactly the same thing.
#[deprecated(since = "0.1.0", note = "Use query_row instead")]
pub fn query_row_safe<T, F>(&self, sql: &str, params: &[&ToSql], f: F) -> Result<T>
where F: FnOnce(Row) -> T
{
@@ -508,6 +509,7 @@ struct InnerConnection {
}
/// Old name for `OpenFlags`. `SqliteOpenFlags` is deprecated.
#[deprecated(since = "0.6.0", note = "Use OpenFlags instead")]
pub type SqliteOpenFlags = OpenFlags;
bitflags! {
@@ -679,6 +681,7 @@ impl Drop for InnerConnection {
}
/// Old name for `Statement`. `SqliteStatement` is deprecated.
#[deprecated(since = "0.6.0", note = "Use Statement instead")]
pub type SqliteStatement<'conn> = Statement<'conn>;
/// A prepared statement.
@@ -884,10 +887,7 @@ impl<'conn> Statement<'conn> {
for (i, p) in params.iter().enumerate() {
try!(unsafe {
self.conn.decode_result(
// This should be
// `p.bind_parameter(self.stmt.ptr(), (i + 1) as c_int)`
// but that doesn't compile until Rust 1.9 due to a compiler bug.
ToSql::bind_parameter(*p, self.stmt.ptr(), (i + 1) as c_int)
p.bind_parameter(self.stmt.ptr(), (i + 1) as c_int)
)
});
}
@@ -968,6 +968,7 @@ impl<'stmt, T, E, F> Iterator for AndThenRows<'stmt, F>
}
/// Old name for `Rows`. `SqliteRows` is deprecated.
#[deprecated(since = "0.6.0", note = "Use Rows instead")]
pub type SqliteRows<'stmt> = Rows<'stmt>;
/// An handle for the resulting rows of a query.
@@ -1032,6 +1033,7 @@ impl<'stmt> Drop for Rows<'stmt> {
}
/// Old name for `Row`. `SqliteRow` is deprecated.
#[deprecated(since = "0.6.0", note = "Use Row instead")]
pub type SqliteRow<'a, 'stmt> = Row<'a, 'stmt>;
/// A single result row of a query.
@@ -1122,12 +1124,17 @@ impl<'a> ValueRef<'a> {
}
ffi::SQLITE_BLOB => {
let blob = ffi::sqlite3_column_blob(raw, col);
assert!(!blob.is_null(), "unexpected SQLITE_BLOB column type with NULL data");
let len = ffi::sqlite3_column_bytes(raw, col);
assert!(len >= 0, "unexpected negative return from sqlite3_column_bytes");
if len > 0 {
assert!(!blob.is_null(), "unexpected SQLITE_BLOB column type with NULL data");
ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize))
} else {
// The return value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
ValueRef::Blob(&[])
}
ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize))
}
_ => unreachable!("sqlite3_column_type returned invalid value")
}