1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Add the SQLITE_STMTSTATUS_MEMUSED option for sqlite3_stmt_status() that reports

the amount of heap memory used for a single prepared statement.

FossilOrigin-Name: b57d510465458dec5b5fc778fd6e8833392964201f9febebf526e60a543da0c2
This commit is contained in:
drh
2017-05-31 16:21:54 +00:00
parent 6b37e0adc9
commit 3528f6b62b
5 changed files with 34 additions and 13 deletions

View File

@@ -1613,8 +1613,19 @@ int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
return 0;
}
#endif
v = pVdbe->aCounter[op];
if( resetFlag ) pVdbe->aCounter[op] = 0;
if( op==SQLITE_STMTSTATUS_MEMUSED ){
sqlite3 *db = pVdbe->db;
sqlite3_mutex_enter(db->mutex);
v = 0;
db->pnBytesFreed = (int*)&v;
sqlite3VdbeClearObject(db, pVdbe);
sqlite3DbFree(db, pVdbe);
db->pnBytesFreed = 0;
sqlite3_mutex_leave(db->mutex);
}else{
v = pVdbe->aCounter[op];
if( resetFlag ) pVdbe->aCounter[op] = 0;
}
return (int)v;
}