;======================================================================
;; Copyright 2006-2016, Matthew Welland.
;; 
;; This file is part of Megatest.
;; 
;;     Megatest is free software: you can redistribute it and/or modify
;;     it under the terms of the GNU General Public License as published by
;;     the Free Software Foundation, either version 3 of the License, or
;;     (at your option) any later version.
;; 
;;     Megatest is distributed in the hope that it will be useful,
;;     but WITHOUT ANY WARRANTY; without even the implied warranty of
;;     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;     GNU General Public License for more details.
;; 
;;     You should have received a copy of the GNU General Public License
;;     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.
;;
;;======================================================================

;;======================================================================
;; Database access
;;======================================================================

;; dbstruct vector containing all the relevant dbs like main.db, megatest.db, run.db etc

(declare (unit db))

(module db
    (
     *
     )
  
(import scheme posix chicken data-structures ports)

(use (prefix sqlite3 sqlite3:)
     (srfi 18) extras tcp stack srfi-1 posix regex regex-case srfi-69
     csv-xml s11n md5 message-digest base64 format dot-locking z3
     typed-records matchable
     (prefix base64 base64:))

(define (db:general-sqlite-error-dump . args) #t)
(define (db:first-result-default . args) #t)
(define (db:get-db . args) #t)
(define (db:dbdat-get-db . args) #t)
(define (db:dbdat-get-path . args) #t)
(define (db:with-db . args) #t)
(define (db:set-sync . args) #t)
(define (db:lock-create-open . args) #t)
(define (db:open-db . args) #t)
(define (db:get-last-update-time . args) #t)
(define (db:setup . args) #t)
(define (db:open-megatest-db . args) #t)
(define (db:sync-touched . args) #t)
(define (db:safely-close-sqlite3-db . args) #t)
(define (db:close-all . args) #t)
(define (db:sync-main-list . args) #t)
(define (db:sync-all-tables-list . args) #t)
(define (db:move-and-recreate-db . args) #t)
(define (db:repair-db . args) #t)
(define (db:sync-tables . args) #t)
(define (db:patch-schema-rundb . args) #t)
(define (db:patch-schema-maindb . args) #t)
(define (db:adj-target . args) #t)
(define (db:get-access-mode . args) #t)
(define (db:dispatch-query . args) #t)
(define (db:cache-for-read-only . args) #t)
(define (db:multi-db-sync . args) #t)
(define (db:tmp->megatest.db-sync . args) #t)
(define (db:sync-to-megatest.db . args) #t)
(define (open-run-close-no-exception-handling . args) #t)
(define (open-run-close-exception-handling . args) #t)
(define (db:initialize-main-db . args) #t)
(define (db:archive-get-allocations . args) #t)
(define (db:archive-register-disk . args) #t)
(define (db:archive-register-block-name . args) #t)
(define (db:test-set-archive-block-id . args) #t)
(define (db:test-get-archive-block-info . args) #t)
(define (open-logging-db . args) #t)
(define (db:log-local-event . args) #t)
(define (db:log-event . args) #t)
(define (db:have-incompletes? . args) #t)
(define (db:find-and-mark-incomplete . args) #t)
(define (db:top-test-set-per-pf-counts . args) #t)
(define (db:clean-up . args) #t)
(define (db:clean-up-rundb . args) #t)
(define (db:clean-up-maindb . args) #t)
(define (db:get-var . args) #t)
(define (db:set-var . args) #t)
(define (db:del-var . args) #t)
(define (db:open-no-sync-db . args) #t)
(define (db:no-sync-db . args) #t)
(define (db:no-sync-set . args) #t)
(define (db:no-sync-del! . args) #t)
(define (db:no-sync-get/default . args) #t)
(define (db:no-sync-close-db . args) #t)
(define (db:no-sync-get-lock . args) #t)
(define (db:get-keys . args) #t)
(define (db:get-value-by-header . args) #t)
(define (db:get-header . args) #t)
(define (db:get-rows . args) #t)
(define (db:get-run-times . args) #t)
(define (db:get-run-name-from-id . args) #t)
(define (db:get-run-key-val . args) #t)
(define (runs:get-std-run-fields . args) #t)
(define (db:patt->like . args) #t)
(define (db:register-run . args) #t)
(define (db:get-runs . args) #t)
(define (db:simple-get-runs . args) #t)
(define (db:get-changed-run-ids . args) #t)
(define (db:get-targets . args) #t)
(define (db:get-num-runs . args) #t)
(define (db:get-runs-cnt-by-patt . args) #t)
(define (db:get-raw-run-stats . args) #t)
(define (db:update-run-stats . args) #t)
(define (db:get-main-run-stats . args) #t)
(define (db:print-current-query-stats . args) #t)
(define (db:get-all-run-ids . args) #t)
(define (db:get-run-stats . args) #t)
(define (db:get-runs-by-patt . args) #t)
(define (db:get-run-info . args) #t)
(define (db:set-comment-for-run . args) #t)
(define (db:delete-run . args) #t)
(define (db:update-run-event_time . args) #t)
(define (db:lock/unlock-run . args) #t)
(define (db:set-run-status . args) #t)
(define (db:get-run-status . args) #t)
(define (db:get-key-val-pairs . args) #t)
(define (db:get-key-vals . args) #t)
(define (db:get-target . args) #t)
(define (db:get-prev-run-ids . args) #t)
(define (db:get-tests-for-run . args) #t)
(define (db:test-short-record->norm . args) #t)
(define (db:get-tests-for-run-state-status . args) #t)
(define (db:get-testinfo-state-status . args) #t)
(define (db:get-tests-for-run-mindata . args) #t)
(define (db:get-tests-for-runs . args) #t)
(define (db:delete-test-records . args) #t)
(define (db:delete-old-deleted-test-records . args) #t)
(define (db:set-tests-state-status . args) #t)
(define (db:test-set-state-status . args) #t)
(define (db:get-count-tests-running . args) #t)
(define (db:get-count-tests-actually-running . args) #t)
(define (db:get-count-tests-running-for-run-id . args) #t)
(define (db:get-count-tests-running-for-testname . args) #t)
(define (db:get-count-tests-running-in-jobgroup . args) #t)
(define (db:estimated-tests-remaining . args) #t)
(define (db:get-test-id . args) #t)
(define (db:test-set-top-process-pid . args) #t)
(define (db:test-get-top-process-pid . args) #t)
(define (db:field->number . args) #t)
(define (db:get-all-tests-info-by-run-id . args) #t)
(define (db:replace-test-records . args) #t)
(define (db:adj-test-id . args) #t)
(define (db:prep-megatest.db-adj-test-ids . args) #t)
(define (db:prep-megatest.db-for-migration . args) #t)
(define (db:get-test-info-by-id . args) #t)
(define (db:get-test-info-by-ids . args) #t)
(define (db:get-test-info . args) #t)
(define (db:test-get-rundir-from-test-id . args) #t)
(define (db:get-test-times . args) #t)
(define (db:get-test-times . args) #t)
(define (db:teststep-set-status! . args) #t)
(define (db:get-steps-for-test . args) #t)
(define (db:get-steps-info-by-id . args) #t)
(define (db:get-steps-data . args) #t)
(define (db:get-data-info-by-id . args) #t)
(define (db:test-data-rollup . args) #t)
(define (db:logpro-dat->csv . args) #t)
(define (db:csv->test-data . args) #t)
(define (db:read-test-data . args) #t)
(define (db:read-test-data* . args) #t)
(define (db:get-run-ids-matching-target . args) #t)
(define (db:test-get-paths-matching-keynames-target-new . args) #t)
(define (db:test-toplevel-num-items . args) #t)
(define (db:obj->string . args) #t)
(define (db:string->obj . args) #t)
(define (db:set-state-status-and-roll-up-items . args) #t)
(define (db:get-all-state-status-counts-for-test . args) #t)
(define (db:test-get-logfile-info . args) #t)
(define (db:lookup-query . args) #t)
(define (db:login . args) #t)
(define (db:general-call . args) #t)
(define (db:get-state-status-summary . args) #t)
(define (db:get-latest-host-load . args) #t)
(define (db:set-top-level-from-items . args) #t)
(define (db:get-matching-previous-test-run-records . args) #t)
(define (db:delay-if-busy . args) #t)
(define (db:test-get-records-for-index-file . args) #t)
(define (db:get-tests-tags . args) #t)
(define (db:testmeta-get-record . args) #t)
(define (db:testmeta-add-record . args) #t)
(define (db:testmeta-update-field . args) #t)
(define (db:testmeta-get-all . args) #t)
(define (db:compare-itempaths . args) #t)
(define (db:convert-test-itempath . args) #t)
(define (db:multi-pattern-apply . args) #t)
(define (db:get-prereqs-not-met . args) #t)
(define (db:get-run-record-ids . args) #t)
(define (db:get-changed-record-ids . args) #t)
(define (db:extract-ods-file . args) #t)

)
