chiark / gitweb /
working on lookups
[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_lexminval obj
62                 # on_lexminval present and not empty list: provides a
63                 #  script which returns the current lexminval.  In
64                 #  this case, occasionally,
65                 #  on_lexminval will be called and then entries whose
66                 #  value is lexically strictly less than lexminval
67                 #  will be deleted automatically.  The comparison
68                 #  is bytewise on the UTF-8 representations.
69                 =>      iddata(&cdbtcl_rwdatabases)
70         open-okjunk RWSCF_OKJUNK
71                 pathb   string
72                 on_info obj
73                 ?on_lexminval obj
74                 =>      iddata(&cdbtcl_rwdatabases)
75                 # on_info <event> <xinfo>...:
76                 # on_info open-clean <statistics-info-string>
77                 # on_info open-dirty-start <statistics-info-string>
78                 # on_info open-dirty-junk <problem-info-string> \
79                 #               <problem-error-code-list>
80                 # on_info open-dirty-done <statistics-info-string>
81                 # on_info compact-start <statistics-info-string>
82                 # on_info compact-done <statistics-info-string>
83                 # on_info close <statistics-info-string>
84         lookup 0
85                 db      iddata(&cdbtcl_rwdatabases)
86                 key     string
87                 ?def    obj
88                 =>      obj
89         lookup-hb 0
90                 db      iddata(&cdbtcl_rwdatabases)
91                 key     string
92                 ?def    hb
93                 =>      hb
94         delete 0
95                 db      iddata(&cdbtcl_rwdatabases)
96                 key     string
97         update 0
98                 db      iddata(&cdbtcl_rwdatabases)
99                 key     string
100                 value   obj
101         update-hb 0
102                 db      iddata(&cdbtcl_rwdatabases)
103                 key     string
104                 value   hb
105         compact-force 0
106                 db      iddata(&cdbtcl_rwdatabases)
107         compact-check 0
108                 db      iddata(&cdbtcl_rwdatabases)
109         compact-auto 0
110                 # this is the default
111                 db      iddata(&cdbtcl_rwdatabases)
112         compact-explicit 0
113                 db      iddata(&cdbtcl_rwdatabases)
114         close 0
115                 db      iddata(&cdbtcl_rwdatabases)
116
117 EntryExtra Cdbwr_SubCommand
118         unsigned flags;