@@ -2282,3 +2282,41 @@ func (rc *SQLiteRows) nextSyncLocked(dest []driver.Value) error {
22822282 }
22832283 return nil
22842284}
2285+
2286+ type SqliteDBStatusOption int
2287+
2288+ const (
2289+ SQLITE_DBSTATUS_LOOKASIDE_USED SqliteDBStatusOption = iota
2290+ SQLITE_DBSTATUS_CACHE_USED
2291+ SQLITE_DBSTATUS_SCHEMA_USED
2292+ SQLITE_DBSTATUS_STMT_USED
2293+ SQLITE_DBSTATUS_LOOKASIDE_HIT
2294+ SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
2295+ SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
2296+ SQLITE_DBSTATUS_CACHE_HIT
2297+ SQLITE_DBSTATUS_CACHE_MISS
2298+ SQLITE_DBSTATUS_CACHE_WRITE
2299+ SQLITE_DBSTATUS_DEFERRED_FKS
2300+ SQLITE_DBSTATUS_CACHE_USED_SHARED
2301+ SQLITE_DBSTATUS_CACHE_SPILL
2302+ SQLITE_DBSTATUS_MAX = iota - 1 /* Largest defined SqliteDBStatusOption */
2303+ )
2304+
2305+ // GetDBStatus retrieve runtime status information about a single database connection.
2306+ // See: sqlite3_db_status https://www.sqlite.org/c3ref/db_status.html
2307+ func (c * SQLiteConn ) GetDBStatus (option SqliteDBStatusOption , resetFlag bool ) (int , int , error ) {
2308+ var curr C.int
2309+ var hiwtr C.int
2310+
2311+ reset := C .int (0 )
2312+ if resetFlag {
2313+ reset = C .int (1 )
2314+ }
2315+
2316+ ret := C .sqlite3_db_status (c .db , C .int (option ), & curr , & hiwtr , reset )
2317+ if ret != C .SQLITE_OK {
2318+ return 0 , 0 , lastError (c .db )
2319+ }
2320+
2321+ return int (curr ), int (hiwtr ), nil
2322+ }
0 commit comments