chiark / gitweb /
halfway through implementing mintstamp
[chiark-tcl.git] / cdb / cdb.tct
1 Table *cdbtoplevel TopLevel_Command
2         cdb
3                 subcmd  enum(Cdb/_SubCommand, "cdb subcommand")
4                 ...     obj
5         cdb-wr
6                 subcmd  enum(Cdbwr/_SubCommand, "cdb-wr subcommand")
7                 ...     obj
8
9 Table cdb Cdb_SubCommand
10         open
11                 path    string
12                 =>      iddata(&cdbtcl_databases)
13         lookup
14                 db      iddata(&cdbtcl_databases)
15                 key     obj
16                 =>      obj
17         lookup-hb
18                 db      iddata(&cdbtcl_databases)
19                 key     hb
20                 =>      hb
21         close
22                 db      iddata(&cdbtcl_databases)
23
24 Table cdbwr Cdbwr_SubCommand
25         create-empty 0
26                 pathb   string
27                 # files:
28                 #       <pathb>.main
29                 #       <pathb>.lock
30                 #       <pathb>.cdb
31                 #       <pathb>.log
32                 #       <pathb>.tmp (might be new .main or new .cdb)
33                 # invariants:
34                 #       .lock is an empty file
35                 #         which is locked with fcntl by open
36                 #       .main is a cdb native text file
37                 #         and always exists
38                 #       .cdb is a cdb database containing data
39                 #         equivalent to and at least as recent as .main
40                 #         (maybe not identical, because .cdb may
41                 #         have been updated with data from .log but
42                 #         .main not yet); if .log does not exist then
43                 #         they are identical)
44                 #       .cdb may not exist; in which case it is to
45                 #         be treated as if it existed and was empty
46                 #         but this is maximally early (so main must
47                 #         exist and be empty since .main is never
48                 #         newer than .cdb)
49                 #       if .log exists, it is a cdb native
50                 #         text file _without the trailing newline_;
51                 #         its contents override values from .main or .cdb
52                 #       if .main.tmp or .cdb.tmp exists it is irrelevant
53                 # zero length values mean record is deleted (in .log only;
54                 #  forbidden elsewhere)
55                 # while db is open:
56                 #       .lock is locked
57                 #       .log and open hash table contain same info
58         open 0
59                 pathb   string
60                 on_info obj
61                 ?on_mintstamp obj
62                 # on_mintstamp present and not empty list: provides a
63                 #  script which returns the current mintstamp.  This
64                 #  means entries start with a 16-hex-digit signed
65                 #  integer known as a tstamp; occasionally,
66                 #  on_mintstamp will be called and then entries whose
67                 #  tstamp is < mintstamp will be deleted automatically.
68                 =>      iddata(&cdbtcl_rwdatabases)
69         open-okjunk RWSCF_OKJUNK
70                 pathb   string
71                 on_info obj
72                 ?on_mintstamp obj
73                 =>      iddata(&cdbtcl_rwdatabases)
74                 # on_info <event> <xinfo>...:
75                 # on_info open-clean <statistics-info-string>
76                 # on_info open-dirty-start <statistics-info-string>
77                 # on_info open-dirty-junk <problem-info-string>
78                 # on_info open-dirty-done <statistics-info-string>
79                 # on_info compact-start <statistics-info-string>
80                 # on_info compact-done <statistics-info-string>
81                 # on_info close <statistics-info-string>
82         lookup 0
83                 db      iddata(&cdbtcl_rwdatabases)
84                 key     string
85                 ?def    obj
86                 =>      obj
87         lookup-hb 0
88                 db      iddata(&cdbtcl_rwdatabases)
89                 key     string
90                 ?def    hb
91                 =>      hb
92         delete 0
93                 db      iddata(&cdbtcl_rwdatabases)
94                 key     string
95         update 0
96                 db      iddata(&cdbtcl_rwdatabases)
97                 key     string
98                 value   obj
99         update-hb 0
100                 db      iddata(&cdbtcl_rwdatabases)
101                 key     string
102                 value   hb
103         compact-force 0
104                 db      iddata(&cdbtcl_rwdatabases)
105         compact-check 0
106                 db      iddata(&cdbtcl_rwdatabases)
107         compact-onupdate 0 # this is the default
108                 db      iddata(&cdbtcl_rwdatabases)
109         compact-explicit 0
110                 db      iddata(&cdbtcl_rwdatabases)
111         close 0
112                 db      iddata(&cdbtcl_rwdatabases)
113
114 EntryExtra Cdbwr_SubCommand
115         unsigned flags;