Skip to content

Commit 00e39be

Browse files
committed
chore: mock more sqlite3 functions
1 parent 55432ec commit 00e39be

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/lib.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,3 +690,40 @@ pub extern "C" fn sqlite3_get_autocommit(db: *mut SQLite3) -> c_int {
690690
1 // Autocommit mode
691691
}
692692
}
693+
694+
#[no_mangle]
695+
pub extern "C" fn sqlite3_create_function_v2(
696+
_db: *mut c_void,
697+
_zFunctionName: *const c_char,
698+
_nArg: c_int,
699+
_eTextRep: c_int,
700+
_pApp: *mut c_void,
701+
_xFunc: Option<extern "C" fn(*mut c_void, c_int, *mut *mut c_void)>,
702+
_xStep: Option<extern "C" fn(*mut c_void, c_int, *mut *mut c_void)>,
703+
_xFinal: Option<extern "C" fn(*mut c_void)>,
704+
_xDestroy: Option<extern "C" fn(*mut c_void)>,
705+
) -> c_int {
706+
println!(
707+
"Not Yet Supported: sqlite3_create_function_v2 : {:?}",
708+
unsafe { CStr::from_ptr(_zFunctionName) }
709+
);
710+
SQLITE_OK
711+
}
712+
713+
#[no_mangle]
714+
pub extern "C" fn sqlite3_stmt_isexplain(stmt: *mut SQLite3PreparedStmt) -> c_int {
715+
if !is_aligned(stmt) {
716+
return SQLITE_OK;
717+
}
718+
719+
let stmt_ref = unsafe { &*stmt };
720+
let sql_trimmed = stmt_ref.sql.trim_start().to_uppercase();
721+
722+
if sql_trimmed.starts_with("EXPLAIN QUERY PLAN") {
723+
2 // EXPLAIN QUERY PLAN
724+
} else if sql_trimmed.starts_with("EXPLAIN") {
725+
1 // EXPLAIN (no QUERY PLAN)
726+
} else {
727+
SQLITE_OK
728+
}
729+
}

src/sqlite.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::{
1515

1616
pub const SQLITE_OK: c_int = 0;
1717
pub const SQLITE_ERROR: c_int = 1;
18+
pub const SQLITE_INTERNAL: c_int = 2;
1819
pub const SQLITE_MISUSE: c_int = 21;
1920
pub const SQLITE_ROW: c_int = 100;
2021
pub const SQLITE_DONE: c_int = 101;

0 commit comments

Comments
 (0)