Index: dbfile.scm ================================================================== --- dbfile.scm +++ dbfile.scm @@ -204,11 +204,11 @@ ;; if db not open, open inmem, rundb and sync then return inmem ;; inuse gets set automatically for rundb's ;; (define (dbfile:get-dbdat dbstruct run-id) (let* ((subdb (dbfile:get-subdb dbstruct run-id))) - (if (stack-empty? (dbr:subdb-dbstack subdb)) + (if (or (not subdb) stack-empty? (dbr:subdb-dbstack subdb)) #f (stack-pop! (dbr:subdb-dbstack subdb))))) ;; return a previously opened db handle to the stack of available handles (define (dbfile:add-dbdat dbstruct run-id dbdat) Index: tests/simplerun/thebeginning.scm ================================================================== --- tests/simplerun/thebeginning.scm +++ tests/simplerun/thebeginning.scm @@ -19,13 +19,13 @@ (test #f #f (dbfile:get-subdb dbstruct #f)) ;; get main.db (never opened yet) (test #f #f (dbfile:get-subdb dbstruct 1)) ;; get 1.db (test #f #t (hash-table? (dbr:dbstruct-subdbs dbstruct))) (test #f #t (dbr:dbdat? (dbfile:open-db *dbstruct-dbs* #f db:initialize-main-db))) (test #f '("SYSTEM" "RELEASE") (db:get-keys *dbstruct-dbs*)) +(test #f #f (dbr:dbdat? (dbfile:get-dbdat dbstruct 1))) ;; not open yet +(test #f #f (sqlite3:database? (db:open-db dbstruct #f))) +(test #f #f (sqlite3:database? (db:open-db dbstruct 1))) -;; test #f #t (sqlite3:database? (db:open-db dbstruct #f))) -;; test #f #t (sqlite3:database? (db:open-db dbstruct 1))) -;; -;; test #f #t (stack? (dbr:subdb-dbstack subdb +;; (test #f #t (stack? (dbr:subdb-dbstack subdb ;; test #f #f (db:get-subdb dbstruct 1)) ;; ;; ; (test #f #f (stack? (dbr:subdb-dbstack subdb)))