ns::stats::SQLiteHistory method historyDrop (protected)
<instance of ns::stats::SQLiteHistory
> historyDrop db where \
reason
Defined in
- Parameters:
- db (required)
- where (required)
- reason (required)
- Testcases:
-
No testcase defined.
Source code:
set stats [lindex [::ns::stats::sql $db "SELECT count(*) AS n,coalesce(min(at),0) AS first,coalesce(max(at),0) AS last FROM ns_stats_samples WHERE $where"] 0]
set n [dict get $stats n]
if {!$n} {
return
}
set first [dict get $stats first]
set last [dict get $stats last]
set now [clock microseconds]
::ns::stats::sql $db "DELETE FROM ns_stats_samples WHERE $where"
::ns::stats::sql $db {DELETE FROM ns_stats_topology WHERE id NOT IN (SELECT DISTINCT topology FROM ns_stats_samples)}
::ns::stats::sql $db "INSERT INTO ns_stats_events(at,first,last,n,reason) VALUES($now,$first,$last,$n,[::ns::stats::quote $reason])"
set prior [::ns::stats::scalar $db {SELECT value FROM ns_stats_meta WHERE key='droppedThrough'}]
set through [expr {$prior eq "" ? $last : max($last,$prior)}]
::ns::stats::sql $db "INSERT OR REPLACE INTO ns_stats_meta VALUES('droppedThrough','$through')"
XQL Not present:Generic, PostgreSQL, Oracle
[
hide source ]
| [
make this the default ]