db_create: - will create environment, if none specified and
add to db pointer
db_put/__db_put: - create cursor with write-lock
- use __db_c_put on cursor to insert data
__db_c_put: - uses private flag DB_UPDATE_SECONDARY to do puts on
secondary databases
- use __db_s_first and __db_s_next for iterating over
secondaries, they will take care of thread-locking
- in first loop add new keys:
- call callback to get secondary key
- open cursor on secondary with transaction and
lock id of primary database
- use __db_c_put with DB_UPDATE_SECONDARY flag
to insert data into secondary
- close cursor
- in second loop remove old secondary indicies:
- get old secondary key
- if secondary key needs to be deleted than:
- get cursor
- use get to move cursor to position
- delete entry
- update primary database now
perl/tcl/python/ruby libs weren't much more helpfull :(
for the lisp library:
- when opening a database it depends on the environment,
wether we'll use the C-based (using db-associate-ll)
implementation or a transaction based if transactions
are supported by environment.
Todo so, db-open returns different kind of classes:
- db-std ;; standard db-class, if txn not allowed
- db-txn ;; if environment supports transactions
- db-associate needs different implementations for db-std
and db-txn:
- db-std:
- use the old low level method
- use defcallback and go on
- no changes to db-put
- db-txn:
- add callback function and secondary to table
in database
- when closing secondary, remove from table
- don't use defcallback, use lambda directly
- overwrite db-put:
- create an transaction
- add data to primary
- in a loop, add keys to secondaries
<preclass="code"
><spanclass="first-line"><spanclass="paren">(</span>defcstruct DBT ;;tried to avoid using DBT directly... :'<spanclass="paren">(</span></span><spanclass"body">
params: env = Environment the database shall be opened in
txn = Transaction
db = Database in File (optional)
mode = file mode, use create-umask or 0 for default
type = :db-btree :db-hash :db-recno or :db-queue
flags... see BDB documentation or db.h</blockquote
><p>creates and opens a new Database <br> params: env = Environment the database shall be opened in txn = Transaction db = Database in File (optional) mode = file mode, use create-umask or 0 for default type = :db-btree :db-hash :db-recno or :db-queue flags... see BDB documentation or db.h </p></blockquote