nsmcp::AccessRecordStoreSQLite method sqliteSnapshot (protected)

 <instance of nsmcp::AccessRecordStoreSQLite[i]> sqliteSnapshot

Defined in /usr/local/ns/tcl/nsmcp/log-traffic-record-store.tcl

Read the connection owned by this writer, never a second pool handle. Statistics are diagnostic: failure must not fail a committed import.

Testcases:
No testcase defined.
Source code:
set started [clock clicks -microseconds]
if {[catch {
    set :sqliteWalAutoCheckpointPages [${:db} scalar {PRAGMA wal_autocheckpoint}]
    set stats [ns_db stats ${:handle} -database main]
    if {![dict get $stats supported]} {
        error "driver statistics unsupported"
    }
    set result [dict create available true]
    if {[dict exists $stats backend sqlite wal]} {
        dict set result wal [dict get $stats backend sqlite wal]
    }
    # Keep the ingestion delta labels stable while consuming shared
    # scalar metrics and explicitly scoped SQLite page/byte counters.
    foreach {key path} {
        cacheHits            {connection cacheHits}
        cacheMisses          {connection cacheMisses}
        cacheWrites          {backend sqlite connection cacheWrittenPages}
        cacheSpills          {backend sqlite connection cacheSpilledPages}
        tempBufferSpillBytes {backend sqlite connection temporarySpillBytes}
        cacheUsedBytes       {connection cacheUsedBytes}
    } {
        if {[dict exists $stats {*}$path]} {
            dict set result $key [dict get $stats {*}$path]
        }
    }
    set result
} result]} {
    set result {available false reason statistics-read-failed}
}
dict set result synchronous ${:sqliteSynchronous}
dict set result synchronousValue ${:sqliteSynchronousValue}
dict set result walAutoCheckpointPages ${:sqliteWalAutoCheckpointPages}
dict set result samplingMicroseconds [expr {max(0,[clock clicks -microseconds]-$started)}]
return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: