Overview
Comment: | Merged fork |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.7001-multi-db-rb01 |
Files: | files | file ages | folders |
SHA1: |
b14c77207c0b1b6d0444d34e7323db9d |
User & Date: | matt on 2022-04-05 17:24:35 |
Other Links: | branch diff | manifest | tags |
Context
2022-04-05
| ||
19:26 | Remove specific interface from http server start. I'm pretty sure that should never have been there. check-in: 2204e62bd5 user: matt tags: v1.7001-multi-db-rb01 | |
17:24 | Merged fork check-in: b14c77207c user: matt tags: v1.7001-multi-db-rb01 | |
17:18 | Cleanup check-in: e5eaa400fa user: matt tags: v1.7001-multi-db-rb01 | |
17:13 | Fixed dbfile:get-dbdat, removed calls to add-dbdat in init-subdb, enhanced the tests. check-in: 9b31e3ddb8 user: mmgraham tags: v1.7001-multi-db-rb01 | |
Changes
Modified dbfile.scm from [8624764a9d] to [1261c08c5d].
︙ | ︙ | |||
202 203 204 205 206 207 208 | ;; if run-id is a string treat it as a filename ;; if db already open - return inmem ;; 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))) | | | < < | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | ;; if run-id is a string treat it as a filename ;; if db already open - return inmem ;; 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)) #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) (let* ((subdb (dbfile:get-subdb dbstruct run-id))) (stack-push! (dbr:subdb-dbstack subdb) dbdat))) ;; set up a subdb ;; (define (dbfile:init-subdb dbstruct run-id init-proc) (let* ((dbname (dbfile:run-id->dbname run-id)) (areapath (dbr:dbstruct-areapath dbstruct)) (tmppath (dbr:dbstruct-tmppath dbstruct)) (mtdbpath (dbfile:run-id->path areapath run-id)) (tmpdbpath (dbfile:run-id->path tmppath run-id)) (mtdbdat (dbfile:open-sqlite3-db mtdbpath init-proc)) (newsubdb (make-dbr:subdb dbname: dbname mtdbfile: mtdbpath tmpdbfile: tmpdbpath mtdbdat: mtdbdat))) (dbfile:set-subdb dbstruct run-id newsubdb) newsubdb)) ;; return the new subdb - but shouldn't really use it ;; returns dbdat with dbh and dbfilepath ;; 1. if needed setup the subdb for the given run-id ;; 2. if there is no existing db handle in the stack ;; create a new handle and return it (do NOT add ;; it to the stack). |
︙ | ︙ | |||
266 267 268 269 270 271 272 | (let* ((db (sqlite3:open-database dbpath))) (sqlite3:set-busy-handler! db (sqlite3:make-busy-timeout 10000)) (init-proc db)) #;(dbfile:lock-create-open dbpath (lambda (db) (init-proc db)))) (write-access (file-write-access? dbpath))) | | | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | (let* ((db (sqlite3:open-database dbpath))) (sqlite3:set-busy-handler! db (sqlite3:make-busy-timeout 10000)) (init-proc db)) #;(dbfile:lock-create-open dbpath (lambda (db) (init-proc db)))) (write-access (file-write-access? dbpath))) (dbfile:print-err "db:open-sqlite-db "dbpath " db: " db) #;(if (and dbexists (not write-access)) (set! *db-write-access* #f)) ;; (cons db dbpath))) (make-dbr:dbdat dbfile: dbpath dbh: db read-only: (not write-access)))) (define (dbfile:print-and-exit . params) (with-output-to-port |
︙ | ︙ |
Modified tests/simplerun/thebeginning.scm from [4bb9f4885a] to [9beea9f91a].
1 2 3 4 5 6 | (use trace test (prefix sqlite3 sqlite3:)) (import dbfile) (trace-call-sites #t) (trace ;; dbfile:setup | | > > > > | > > | | | < < | > > | > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | (use trace test (prefix sqlite3 sqlite3:)) (import dbfile) (trace-call-sites #t) (trace ;; dbfile:setup dbfile:open-sqlite3-db ;; dbfile:init-subdb ;; dbfile:add-dbdat ;; db:initialize-main-db ;; dbfile:set-subdb ;; db:with-db ;; dbfile:get-subdb ) (define tmpdir (common:get-db-tmp-area)) (test #f #t (dbr:dbstruct? (dbfile:setup #t *toppath* tmpdir))) (test #f #t (dbr:dbstruct? (db:setup #t))) (define dbstruct *dbstruct-dbs*) (test #f #t (dbr:dbdat? (dbfile:open-db *dbstruct-dbs* #f db:initialize-main-db))) (define mydbdat (dbfile:open-db *dbstruct-dbs* #f db:initialize-main-db)) (dbfile:add-dbdat dbstruct #f mydbdat) (test #f #t (dbr:subdb? (dbfile:get-subdb dbstruct #f))) (test #f #t (dbr:dbdat? (dbfile:get-dbdat dbstruct #f))) (test #f #f (dbr:dbdat? (dbfile:get-dbdat dbstruct #f))) ;; stack empty so should fail. (test #f #t (hash-table? (dbr:dbstruct-subdbs dbstruct))) (test #f #t (stack? (dbr:subdb-dbstack (dbfile:get-subdb dbstruct #f)))) (test #f '("SYSTEM" "RELEASE") (db:get-keys *dbstruct-dbs*)) (test #f #t (dbr:dbdat? (dbfile:open-db dbstruct 1 db:initialize-main-db))) (define rundbdat (dbfile:open-db dbstruct 1 db:initialize-main-db)) (dbfile:add-dbdat dbstruct 1 rundbdat) (test #f #t (dbr:subdb? (dbfile:get-subdb dbstruct 1))) (test #f #t (dbr:dbdat? (dbfile:get-dbdat dbstruct 1))) |