chiark / gitweb /
.log -> .jrn
[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                 ?def    obj
17                 =>      obj
18         lookup-hb
19                 db      iddata(&cdbtcl_databases)
20                 key     hb
21                 ?def    obj
22                 =>      obj
23         close
24                 db      iddata(&cdbtcl_databases)
25
26 Table cdbwr Cdbwr_SubCommand
27         create-empty 0
28                 pathb   string
29                 # files:
30                 #       <pathb>.main
31                 #       <pathb>.lock
32                 #       <pathb>.cdb
33                 #       <pathb>.jrn
34                 #       <pathb>.tmp (might be new .main or new .cdb)
35                 # invariants:
36                 #       .lock is an empty file
37                 #         which is locked with fcntl by open
38                 #       .main is a cdb native text file
39                 #         and always exists
40                 #       .cdb is a cdb database containing data
41                 #         equivalent to and at least as recent as .main
42                 #         (maybe not identical, because .cdb may
43                 #         have been updated with data from .jrn but
44                 #         .main not yet); if .jrn does not exist then
45                 #         they are identical)
46                 #       .cdb may not exist; in which case it is to
47                 #         be treated as if it existed and was empty
48                 #         but this is maximally early (so main must
49                 #         exist and be empty since .main is never
50                 #         newer than .cdb)
51                 #       if .jrn exists, it is a cdb native
52                 #         text file _without the trailing newline_;
53                 #         its contents override values from .main or .cdb
54                 #       if .main.tmp or .cdb.tmp exists it is irrelevant
55                 # zero length values mean record is deleted (in .jrn only;
56                 #  forbidden elsewhere)
57                 # while db is open:
58                 #       .lock is locked
59                 #       .jrn and open hash table contain same info
60         open 0
61                 pathb   string
62                 on_info obj
63                 ?on_lexminval obj
64                 # on_lexminval present and not empty list: provides a
65                 #  script which returns the current lexminval.  In
66                 #  this case, occasionally,
67                 #  on_lexminval will be called and then entries whose
68                 #  value is lexically strictly less than lexminval
69                 #  will be deleted automatically.  The comparison
70                 #  is bytewise on the UTF-8 representations.
71                 =>      iddata(&cdbtcl_rwdatabases)
72         open-okjunk RWSCF_OKJUNK
73                 pathb   string
74                 on_info obj
75                 ?on_lexminval obj
76                 =>      iddata(&cdbtcl_rwdatabases)
77                 # on_info <event> <xinfo>...:
78                 # on_info open-clean <statistics-info-string>
79                 # on_info open-dirty-start <statistics-info-string>
80                 # on_info open-dirty-junk <problem-info-string> \
81                 #               <problem-error-code-list>
82                 # on_info open-dirty-done <statistics-info-string>
83                 # on_info compact-start <statistics-info-string>
84                 # on_info compact-done <statistics-info-string>
85                 # on_info close <statistics-info-string>
86         lookup 0
87                 db      iddata(&cdbtcl_rwdatabases)
88                 key     string
89                 ?def    obj
90                 =>      obj
91         lookup-hb 0
92                 db      iddata(&cdbtcl_rwdatabases)
93                 key     string
94                 ?def    obj
95                 =>      obj
96         delete 0
97                 db      iddata(&cdbtcl_rwdatabases)
98                 key     string
99         update 0
100                 db      iddata(&cdbtcl_rwdatabases)
101                 key     string
102                 value   obj
103         update-hb 0
104                 db      iddata(&cdbtcl_rwdatabases)
105                 key     string
106                 value   hb
107         compact-force 0
108                 db      iddata(&cdbtcl_rwdatabases)
109         compact-check 0
110                 db      iddata(&cdbtcl_rwdatabases)
111         compact-auto 0
112                 # this is the default
113                 db      iddata(&cdbtcl_rwdatabases)
114         compact-explicit 0
115                 db      iddata(&cdbtcl_rwdatabases)
116         close 0
117                 db      iddata(&cdbtcl_rwdatabases)
118
119 EntryExtra Cdbwr_SubCommand
120         unsigned flags;