diff options
author | drh <drh@noemail.net> | 2017-05-31 17:30:08 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-05-31 17:30:08 +0000 |
commit | cdbb126be7335a05a5930b8d0fa775c7d3a86ef0 (patch) | |
tree | e5dd458652fc19a3a20f4c1571e3e7634cd61162 /src/vdbeapi.c | |
parent | 6b37e0adc92057acbf743fd7103ce63d7270a226 (diff) | |
parent | 3528f6b62b8845354b11863bbe41858512e38d71 (diff) | |
download | sqlite-cdbb126be7335a05a5930b8d0fa775c7d3a86ef0.tar.gz sqlite-cdbb126be7335a05a5930b8d0fa775c7d3a86ef0.zip |
Add the SQLITE_STMTSTATUS_MEMUSED opcode to sqlite3_stmt_status()
for finding the heap memory usage by a single prepared statement.
FossilOrigin-Name: c26cf978eead1c9d265eddabaa421e7735b472fcf2792cd2bdeb0901bcf3fb44
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r-- | src/vdbeapi.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 3e439e3e8..93063dc60 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -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; } |