mirror of
https://github.com/isar/rusqlite.git
synced 2025-10-19 22:39:00 +08:00
Move declare_vtab into Module trait
This commit is contained in:
@@ -64,6 +64,17 @@ pub trait Module {
|
||||
aux: Option<&Self::Aux>,
|
||||
args: &[&[u8]],
|
||||
) -> Result<Self::Table>;
|
||||
|
||||
/// Declare the schema of a virtual table.
|
||||
fn declare_vtab(db: &mut ffi::sqlite3, sql: &str) -> Result<()> {
|
||||
let c_sql = try!(CString::new(sql));
|
||||
let rc = unsafe { ffi::sqlite3_declare_vtab(db, c_sql.as_ptr()) };
|
||||
if rc == ffi::SQLITE_OK {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(error_from_sqlite_code(rc, None))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Virtual table instance trait.
|
||||
@@ -352,17 +363,6 @@ impl InnerConnection {
|
||||
}
|
||||
}
|
||||
|
||||
/// Declare the schema of a virtual table.
|
||||
pub fn declare_vtab(db: &mut ffi::sqlite3, sql: &str) -> Result<()> {
|
||||
let c_sql = try!(CString::new(sql));
|
||||
let rc = unsafe { ffi::sqlite3_declare_vtab(db, c_sql.as_ptr()) };
|
||||
if rc == ffi::SQLITE_OK {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(error_from_sqlite_code(rc, None))
|
||||
}
|
||||
}
|
||||
|
||||
/// Escape double-quote (`"`) character occurences by doubling them (`""`).
|
||||
pub fn escape_double_quote(identifier: &str) -> Cow<str> {
|
||||
if identifier.contains('"') {
|
||||
|
Reference in New Issue
Block a user