X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-tcl.git;a=blobdiff_plain;f=cdb%2Fcdb.tct;h=d414f0d9939b8786d4507bb497539b887e247f23;hp=9bb1fe431127d1e9b0d2ccaa36556b8ec312b7cf;hb=ceed4cf646a34245b3bc88089a2187ebf7a41f0f;hpb=d1cb50b156138e6a0027ca93d22952402457f884 diff --git a/cdb/cdb.tct b/cdb/cdb.tct index 9bb1fe4..d414f0d 100644 --- a/cdb/cdb.tct +++ b/cdb/cdb.tct @@ -1,10 +1,27 @@ -Table cdbtoplevel TopLevel_Command +# cdb, cdb-wr - Tcl bindings for tinycdb and a journalling write extension +# Copyright 2006 Ian Jackson +# +# This program 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 2 of the +# License, or (at your option) any later version. +# +# This program 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 this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +# 02110-1301, USA. + + +Table *cdbtoplevel TopLevel_Command cdb - subcmd enum(Cdb/_SubCommand, "cdb subcommand") - ... obj + dispatch(Cdb/_SubCommand, "cdb subcommand") cdb-wr - subcmd enum(CdbWr/_SubCommand, "cdb-wr subcommand") - ... obj + dispatch(Cdbwr/_SubCommand, "cdb-wr subcommand") Table cdb Cdb_SubCommand open @@ -13,104 +30,108 @@ Table cdb Cdb_SubCommand lookup db iddata(&cdbtcl_databases) key obj + ?def obj => obj lookup-hb db iddata(&cdbtcl_databases) key hb - => hb + ?def obj + => obj close db iddata(&cdbtcl_databases) -Table cdbwr CdbWr_SubCommand - open +Table cdbwr Cdbwr_SubCommand + create-empty 0 pathb string - on_info obj - => iddata(&cdbtcl_rwdatabases) - # on_info ...: - # on_info - # # files: - # .main + # .main + # .lock # .cdb - # .log + # .jrn # .tmp (might be new .main or new .cdb) # invariants: - fixme finish this - also mention file format - and whether cdb text format files are terminated - # .main always exists - # if .tmp exists it is irrelevant - # if .cdb exists it contains exactly the same - # as .main - # if .log exists, it _must_ be read and contents - # override values from .main or .cdb - create-empty + # .lock is an empty file + # which is locked with fcntl by open + # .main is a cdb native text file + # and always exists + # .cdb is a cdb database containing data + # equivalent to and at least as recent as .main + # (maybe not identical, because .cdb may + # have been updated with data from .jrn but + # .main not yet); if .jrn does not exist then + # they are identical) + # .cdb may not exist; in which case it is to + # be treated as if it existed and was empty + # but this is maximally early (so main must + # exist and be empty since .main is never + # newer than .cdb) + # if .jrn exists, it is a cdb native + # text file _without the trailing newline_; + # its contents override values from .main or .cdb + # if .main.tmp or .cdb.tmp exists it is irrelevant + # zero length values mean record is deleted (in .jrn only; + # forbidden elsewhere) + # while db is open: + # .lock is locked + # .jrn and open hash table contain same info + open 0 pathb string - lookup + on_info obj + ?on_lexminval obj + # on_lexminval present and not empty list: provides a + # script which returns the current lexminval. In + # this case, occasionally, + # on_lexminval will be called and then entries whose + # value is lexically strictly less than lexminval + # will be deleted automatically. The comparison + # is bytewise on the UTF-8 representations. + => iddata(&cdbtcl_rwdatabases) + open-okjunk RWSCF_OKJUNK + pathb string + on_info obj + ?on_lexminval obj + => iddata(&cdbtcl_rwdatabases) + # on_info ...: + # on_info open-clean + # on_info open-dirty-start + # on_info open-dirty-junk \ + # + # on_info open-dirty-done + # on_info compact-start + # on_info compact-done + # on_info close + lookup 0 db iddata(&cdbtcl_rwdatabases) - key obj + key string + ?def obj => obj - lookup-hb + lookup-hb 0 db iddata(&cdbtcl_rwdatabases) - key hb - => hb - update + key string + ?def obj + => obj + delete 0 db iddata(&cdbtcl_rwdatabases) - key obj + key string + update 0 + db iddata(&cdbtcl_rwdatabases) + key string value obj - update-hb + update-hb 0 db iddata(&cdbtcl_rwdatabases) - key hb + key string value hb - update-quick + compact-force 0 db iddata(&cdbtcl_rwdatabases) - key obj - value obj - update-quick-hb + compact-check 0 + db iddata(&cdbtcl_rwdatabases) + compact-auto 0 + # this is the default + db iddata(&cdbtcl_rwdatabases) + compact-explicit 0 + db iddata(&cdbtcl_rwdatabases) + close 0 db iddata(&cdbtcl_rwdatabases) - key hb - value hb - - open-autolog - - - lookup - rrtype enum(CdbTclRRTypeInfo/, "rrtype") - domain string - ... obj - => obj - synch - rrtype enum(CdbTclRRTypeInfo/, "rrtype") - domain string - ... obj - => obj - asynch - on_yes obj - on_no obj - on_fail obj - xargs obj - rrtype enum(CdbTclRRTypeInfo/, "rrtype") - domain string - ... obj - => iddata(&cdbtcl_queries) - asynch-cancel - query iddata(&cdbtcl_queries) - new-resolver - ... obj - => iddata(&cdbtcl_resolvers) - set-default-resolver - res iddata(&cdbtcl_resolvers) - destroy-resolver - res iddata(&cdbtcl_resolvers) - - - -Type cdbresults: cdb_answer *@ -Init cdbresults @=0; -Fini cdbresults free(@); - -Table cdbtoplevel TopLevel_Command - cdb - subcmd enum(Cdb/_SubCommand, "cdb subcommand") - ... obj +EntryExtra Cdbwr_SubCommand + unsigned flags;