(index ("open-database" 0) ("close-database" 209) ("call-with-database" 317) ("sqdb-handle" 561) ("fetch" 707) ("store" 1017) ("add" 1444) ("add*" 1444) ("exists?" 1807) ("incr" 1945) ("decr" 2462) ("update" 2568) ("delete" 3311) ("with-transaction" 3502) ("begin-transaction" 4182) ("commit" 4391) ("rollback" 4493) ("set-busy-timeout!" 4587))
(def (sig (procedure "(open-database filename)" (id open-database))) (p "Opens database with path " (tt "filename") " and returns an sqdb database object. The database will be created if it does not exist."))
(def (sig (procedure "(close-database db)" (id close-database))) (p "Closes sqdb database " (tt "db") "."))
(def (sig (procedure "(call-with-database filename proc)" (id call-with-database))) (p "Opens sqdb database " (tt "filename") " and calls " (tt "(proc db)") ". The database will be closed when " (tt "proc") " returns or raises an exception."))
(def (sig (procedure "(sqdb-handle db)" (id sqdb-handle))) (p "Return the underlying " (tt "sql-de-lite") " database handle for " (tt "db") "."))
(def (sig (procedure "(fetch db key)" (id fetch))) (p "Fetch value of " (tt "key") " from database " (tt "db") ". " (tt "key") " may be a string or symbol.") (p "Returns a string, exact or inexact integer, or blob depending on the type of the stored value.  If the key did not exist, returns " (tt "#f") "."))
(def (sig (procedure "(store db key val)" (id store))) (p "Stores " (tt "key") " in database " (tt "db") " with value " (tt "val") ".  If " (tt "key") " already exists, its value is overwritten; otherwise, a new key is created.") (p (tt "key") " may be a string or symbol.  " (tt "val") " may be a string, exact or inexact integer, or blob; it will be stored and fetched as that type.") (p "The return value is unspecified."))
(def (sig (procedure "(add db key val)" (id add)) (procedure "(add* db key val)" (id add*))) (p (tt "add") " is like " (tt "store") ", but only makes a change if the key did not exist.  It returns " (tt "#f") " if the key did exist, and " (tt "#t") " if it did not.") (p (tt "add*") " is like " (tt "add") ", but raises an exception if the key already exists."))
(def (sig (procedure "(exists? db key)" (id exists?))) (p "Test if " (tt "key") " exists in " (tt "db") " and returns a boolean value."))
(def (sig (procedure "(incr db key [n])" (id incr))) (p "Atomically increment the value associated with " (tt "key") " by " (tt "n") ".  " (tt "n") " may be an integer or a floating point value, and defaults to 1.") (p "If the value is a string, it is converted to a number if possible, and the new value will be a number.  If the conversion fails, it is considered to be zero, so the resulting value will be the number " (tt "n") ".") (p "Returns " (tt "#t") " if the key existed and " (tt "#f") " if it did not."))
(def (sig (procedure "(decr db key [n])" (id decr))) (p "Equivalent to " (tt "(incr db key (- n))") "."))
(def (sig (procedure "(update db key proc)" (id update))) (p "Updates the value of " (tt "key") " by fetching the current value of key, calling " (tt "(proc val)") " to get an updated value, and storing that into the database.  " (tt "val") " will be " (tt "#f") " if the key did not exist.") (p "This operation is implemented using an IMMEDIATE transaction, and is atomic as long as you always use " (tt "update") " elsewhere (or an IMMEDIATE or EXCLUSIVE transaction) when doing a read-modify-write on this key.") (p "Note that the " (tt "incr") " operation could be implemented in a much less efficient way using " (tt "update") ":") (pre "(update db key (lambda (x) (add1 (or x 0))))\n;; Less efficient than:\n(add db k 0)\n(incr db k)"))
(def (sig (procedure "(delete db key)" (id delete))) (p "Deletes key from " (tt "db") ".  Returns " (tt "#t") " if the key existed (and was deleted), or " (tt "#f") " if it did not exist."))
(def (sig (procedure "(with-transaction db thunk #!optional (type deferred))" (id with-transaction))) (p "Executes " (tt "thunk") " inside an atomic transaction.  If " (tt "thunk") " raises an exception or returns " (tt "#f") ", the transaction is rolled back. Otherwise it is committed when thunk exits.") (p "Warning: transactions may not be nested.  An error will occur if you try.") (p (tt "type") " may be") (dl (dt "deferred") (dd "Everyone can write until our first read or write; everyone can read until our first write.") (dt "immediate") (dd "No one else can write, but everyone can read until our first write.") (dt "exclusive") (dd "No one else can read or write.")))
(def (sig (procedure "(begin-transaction db thunk #!optional (type deferred))" (id begin-transaction))) (p "Begin an atomic transaction.  See " (tt "with-transaction") " for the meaning of " (tt "type") "."))
(def (sig (procedure "(commit db)" (id commit))) (p "Commit the current transaction to disk oxide."))
(def (sig (procedure "(rollback db)" (id rollback))) (p "Rollback the current transaction."))
(def (sig (procedure "(set-busy-timeout! db ms)" (id set-busy-timeout!))) (p "Set a timeout of " (tt "ms") " milliseconds for operations that occur when the database is locked.  If " (tt "ms") " is " (tt "#f") " or 0, the operation times out immediately.") (p "You must set the timeout separately for each database connection and it can be changed at any time after the database is open.  The default is " (tt "#f") "."))
