nsmcp::AccessRecordStoreSQLite method scope (public)

 <instance of nsmcp::AccessRecordStoreSQLite[i]> scope files

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

Open a stored-record query scope for selected source intervals. Create connection-local range metadata and a bounded request view inside a read transaction. Reject a generation that disappeared after discovery. Call finish to end the scope.

Parameters:
files (required)
Source descriptors containing archive file identifiers and byte bounds.
Returns:
An empty result after the scoped transaction and view are ready.

Testcases:
No testcase defined.
Source code:
set :fullScope false
if {${:mode} eq "reader"} {
    ${:db} execute {PRAGMA query_only=OFF}
}
${:db} execute {
    DROP VIEW IF EXISTS temp.nsmcp_record_window; DROP TABLE IF EXISTS temp.nsmcp_scan_batch; DROP TABLE IF
    EXISTS temp.nsmcp_record_scope;
    CREATE TEMP TABLE nsmcp_record_scope(fid INTEGER PRIMARY KEY,lo INTEGER,hi INTEGER)
}
foreach file $files {
    if {![dict exists $file archiveFid] || [dict get $file status] eq "outside-window"} {
        continue
    }
    set fid [dict get $file archiveFid]
    set lo [dict get $file archiveLo]
    set hi [dict get $file offset]
    ${:db} execute {INSERT INTO temp.nsmcp_record_scope VALUES(:fid,:lo,:hi)}
}
${:db} execute BEGIN
set :querying true
foreach file $files {
    if {[dict exists $file archiveFid]} {
        set fid [dict get $file archiveFid]
        if {$fid>=0 && ![${:db} scalar {SELECT count(*) FROM main.files WHERE fid=:fid}]} {
            error "record-store-generation-changed"
        }
    }
}
${:db} execute {
    CREATE TEMP VIEW nsmcp_record_window AS SELECT r.* FROM main.rows r
    JOIN temp.nsmcp_record_scope s ON r.fid=s.fid AND r.off>=s.lo AND r.off<s.hi AND r.stop<=s.hi
}
if {${:mode} eq "reader"} {
    ${:db} execute {PRAGMA query_only=ON}
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: