X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-tcl.git;a=blobdiff_plain;f=cdb%2Fcdb.tct;h=a7d22b468cb3ccef22131fb14e9fa2271fc877ff;hp=cfb93baaaafb3a034acf6fe76988c70272919e9a;hb=602f89cabd45c343f6adb4b788d26d316f5be47b;hpb=8aa50feff3e82f3d217fe7ee897b7a030a72bc90 diff --git a/cdb/cdb.tct b/cdb/cdb.tct index cfb93ba..a7d22b4 100644 --- a/cdb/cdb.tct +++ b/cdb/cdb.tct @@ -1,4 +1,4 @@ -Table cdbtoplevel TopLevel_Command +Table *cdbtoplevel TopLevel_Command cdb subcmd enum(Cdb/_SubCommand, "cdb subcommand") ... obj @@ -12,67 +12,109 @@ Table cdb Cdb_SubCommand => iddata(&cdbtcl_databases) lookup db iddata(&cdbtcl_databases) - key bytearray - => bytearray + 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 - create-empty +Table cdbwr Cdbwr_SubCommand + create-empty 0 pathb string # files: # .main + # .lock # .cdb # .log # .tmp (might be new .main or new .cdb) # invariants: + # .lock is an empty file + # which is locked with fcntl by open # .main is a cdb native text file # and always exists - # if .tmp exists it is irrelevant - # if .cdb exists it is a cdb database - # containing exactly the same as .main + # .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 .log but + # .main not yet); if .log 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 .log exists, it is a cdb native # text file _without the trailing newline_; # its contents override values from .main or .cdb - open + # if .main.tmp or .cdb.tmp exists it is irrelevant + # zero length values mean record is deleted (in .log only; + # forbidden elsewhere) + # while db is open: + # .lock is locked + # .log and open hash table contain same info + open 0 + pathb string + 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 + # on_info open-dirty-start + # on_info open-dirty-junk \ + # + # on_info open-dirty-done # on_info compact-start - # on_info compact-end + # on_info compact-done # on_info close - lookup + lookup 0 db iddata(&cdbtcl_rwdatabases) - key bytearray - => bytearray - lookup-hb + key string + ?def obj + => obj + lookup-hb 0 db iddata(&cdbtcl_rwdatabases) - key hb - => hb - update + key string + ?def obj + => obj + delete 0 db iddata(&cdbtcl_rwdatabases) - key bytearray - value bytearray - update-hb + key string + update 0 db iddata(&cdbtcl_rwdatabases) - key hb + key string + value obj + update-hb 0 + db iddata(&cdbtcl_rwdatabases) + key string value hb - update-quick + compact-force 0 db iddata(&cdbtcl_rwdatabases) - key bytearray - value bytearray - update-quick-hb + compact-check 0 db iddata(&cdbtcl_rwdatabases) - key hb - value hb - close + compact-auto 0 + # this is the default + db iddata(&cdbtcl_rwdatabases) + compact-explicit 0 db iddata(&cdbtcl_rwdatabases) - close-quick + close 0 db iddata(&cdbtcl_rwdatabases) + +EntryExtra Cdbwr_SubCommand + unsigned flags;