Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 422 lines (379 sloc) 14.735 kB
9854f2e Added generated sqlite3 interfaces for plugins
Anastasia Gornostaeva authored
1 (* DO NOT EDIT MANUALLY *)
2 (* *)
3 (* generated by sqlgg 0.2.3-49-g30df037 on 2010-01-14T17:45Z *)
4
5 module Make (T : Sqlgg_traits.M) = struct
6
7 let create_wtf db =
8 T.execute db "CREATE TABLE IF NOT EXISTS wtf (stamp int, nick varchar, luser varchar, lserver varchar, \"key\" varchar, \"value\" varchar)" T.no_params
9
10 let create_index_dfnidx db =
11 T.execute db "CREATE INDEX IF NOT EXISTS dfnidx ON wtf (\"key\")" T.no_params
12
13 let create_index_dfncheck db =
14 T.execute db "CREATE INDEX IF NOT EXISTS dfncheck ON wtf (\"key\", luser, lserver)" T.no_params
15
16 let total db =
17 let get_row stmt =
18 (T.get_column_Int stmt 0)
19 in
20 T.select1 db "SELECT COUNT(*) FROM wtf" T.no_params get_row
21
22 let dfn_new db ~stamp ~nick ~luser ~lserver ~key ~value =
23 let set_params stmt =
24 let p = T.start_params stmt 6 in
25 T.set_param_Int p 0 stamp;
26 T.set_param_Text p 1 nick;
27 T.set_param_Text p 2 luser;
28 T.set_param_Text p 3 lserver;
29 T.set_param_Text p 4 key;
30 T.set_param_Text p 5 value;
31 T.finish_params p
32 in
33 T.execute db "INSERT INTO wtf (stamp, nick, luser, lserver, \"key\", \"value\") VALUES (@stamp,@nick,@luser,@lserver,@key,@value)" set_params
34
35 let dfn_check_by_jid db ~key ~luser ~lserver =
36 let get_row stmt =
37 (T.get_column_Text stmt 0)
38 in
39 let set_params stmt =
40 let p = T.start_params stmt 3 in
41 T.set_param_Text p 0 key;
42 T.set_param_Text p 1 luser;
43 T.set_param_Text p 2 lserver;
44 T.finish_params p
45 in
46 T.select1 db "SELECT \"value\" FROM wtf WHERE \"key\"=@key AND luser=@luser AND lserver=@lserver LIMIT 1" set_params get_row
47
48 let dfn_delete_by_jid db ~key ~luser ~lserver =
49 let set_params stmt =
50 let p = T.start_params stmt 3 in
51 T.set_param_Text p 0 key;
52 T.set_param_Text p 1 luser;
53 T.set_param_Text p 2 lserver;
54 T.finish_params p
55 in
56 T.execute db "DELETE FROM wtf WHERE \"key\"=@key AND luser=@luser AND lserver=@lserver" set_params
57
58 let dfn_update_by_jid db ~stamp ~nick ~value ~key ~luser ~lserver =
59 let set_params stmt =
60 let p = T.start_params stmt 6 in
61 T.set_param_Int p 0 stamp;
62 T.set_param_Text p 1 nick;
63 T.set_param_Text p 2 value;
64 T.set_param_Text p 3 key;
65 T.set_param_Text p 4 luser;
66 T.set_param_Text p 5 lserver;
67 T.finish_params p
68 in
69 T.execute db "UPDATE wtf SET stamp=@stamp, nick=@nick, \"value\"=@value WHERE \"key\"=@key AND luser=@luser AND lserver=@lserver" set_params
70
71 let dfn_check_by_occupant db ~key ~nick ~luser ~lserver =
72 let get_row stmt =
73 (T.get_column_Text stmt 0)
74 in
75 let set_params stmt =
76 let p = T.start_params stmt 4 in
77 T.set_param_Text p 0 key;
78 T.set_param_Text p 1 nick;
79 T.set_param_Text p 2 luser;
80 T.set_param_Text p 3 lserver;
81 T.finish_params p
82 in
83 T.select1 db "SELECT \"value\" FROM wtf WHERE \"key\"=@key AND nick=@nick AND luser=@luser AND lserver=@lserver LIMIT 1" set_params get_row
84
85 let dfn_delete_by_occupant db ~key ~nick ~luser ~lserver =
86 let set_params stmt =
87 let p = T.start_params stmt 4 in
88 T.set_param_Text p 0 key;
89 T.set_param_Text p 1 nick;
90 T.set_param_Text p 2 luser;
91 T.set_param_Text p 3 lserver;
92 T.finish_params p
93 in
94 T.execute db "DELETE FROM wtf WHERE \"key\"=@key AND nick=@nick AND luser=@luser AND lserver=@lserver" set_params
95
96 let dfn_update_by_occupant db ~stamp ~value ~key ~nick ~luser ~lserver =
97 let set_params stmt =
98 let p = T.start_params stmt 6 in
99 T.set_param_Int p 0 stamp;
100 T.set_param_Text p 1 value;
101 T.set_param_Text p 2 key;
102 T.set_param_Text p 3 nick;
103 T.set_param_Text p 4 luser;
104 T.set_param_Text p 5 lserver;
105 T.finish_params p
106 in
107 T.execute db "UPDATE wtf SET stamp=@stamp, \"value\"=@value WHERE \"key\"=@key AND nick=@nick AND luser=@luser AND lserver=@lserver" set_params
108
109 let get_wtf_one db ~key =
110 let get_row stmt =
111 (T.get_column_Text stmt 0), (T.get_column_Text stmt 1)
112 in
113 let set_params stmt =
114 let p = T.start_params stmt 1 in
115 T.set_param_Text p 0 key;
116 T.finish_params p
117 in
118 T.select1 db "SELECT nick, \"value\" FROM wtf WHERE \"key\"=@key ORDER BY stamp DESC LIMIT 1" set_params get_row
119
120 let get_wtf_all db ~key callback =
121 let invoke_callback stmt =
122 callback
123 (T.get_column_Text stmt 0)
124 (T.get_column_Text stmt 1)
125 (T.get_column_Text stmt 2)
126 in
127 let set_params stmt =
128 let p = T.start_params stmt 1 in
129 T.set_param_Text p 0 key;
130 T.finish_params p
131 in
132 T.select db "SELECT nick, \"key\", \"value\" FROM wtf WHERE \"key\"=@key ORDER BY stamp" set_params invoke_callback
133
134 let wtf_count db ~key =
135 let get_row stmt =
136 (T.get_column_Int stmt 0)
137 in
138 let set_params stmt =
139 let p = T.start_params stmt 1 in
140 T.set_param_Text p 0 key;
141 T.finish_params p
142 in
143 T.select1 db "SELECT count(*) FROM wtf WHERE \"key\"=@key" set_params get_row
144
145 let wtffind db ~key ~value callback =
146 let invoke_callback stmt =
147 callback
148 (T.get_column_Text stmt 0)
149 (T.get_column_Text stmt 1)
150 (T.get_column_Text stmt 2)
151 in
152 let set_params stmt =
153 let p = T.start_params stmt 2 in
154 T.set_param_Text p 0 key;
155 T.set_param_Text p 1 value;
156 T.finish_params p
157 in
158 T.select db "SELECT nick, \"key\", \"value\" FROM wtf WHERE \"key\" LIKE @key OR \"value\" LIKE @value" set_params invoke_callback
159
160 let get_rand db ~rand =
161 let get_row stmt =
162 (T.get_column_Text stmt 0), (T.get_column_Text stmt 1), (T.get_column_Text stmt 2)
163 in
164 let set_params stmt =
165 let p = T.start_params stmt 1 in
166 T.set_param_Int p 0 rand;
167 T.finish_params p
168 in
169 T.select1 db "SELECT nick, \"key\", \"value\" FROM wtf LIMIT @rand,1" set_params get_row
170
171 let get_key_total db ~key =
172 let get_row stmt =
173 (T.get_column_Int stmt 0)
174 in
175 let set_params stmt =
176 let p = T.start_params stmt 1 in
177 T.set_param_Text p 0 key;
178 T.finish_params p
179 in
180 T.select1 db "SELECT count(*) FROM wtf WHERE \"key\"=@key" set_params get_row
181
182 let get_rand_key db ~key ~rand =
183 let get_row stmt =
184 (T.get_column_Text stmt 0), (T.get_column_Text stmt 1)
185 in
186 let set_params stmt =
187 let p = T.start_params stmt 2 in
188 T.set_param_Text p 0 key;
189 T.set_param_Int p 1 rand;
190 T.finish_params p
191 in
192 T.select1 db "SELECT nick, \"value\" FROM wtf WHERE \"key\"=@key LIMIT @rand,1" set_params get_row
193
194 let delete_key db ~key =
195 let set_params stmt =
196 let p = T.start_params stmt 1 in
197 T.set_param_Text p 0 key;
198 T.finish_params p
199 in
200 T.execute db "DELETE FROM wtf WHERE \"key\"=@key" set_params
201
202 let delete_key_value db ~key ~value =
203 let set_params stmt =
204 let p = T.start_params stmt 2 in
205 T.set_param_Text p 0 key;
206 T.set_param_Text p 1 value;
207 T.finish_params p
208 in
209 T.execute db "DELETE FROM wtf WHERE \"key\"=@key AND \"value\"=@value" set_params
210
211 module Fold = struct
212 let create_wtf db =
213 T.execute db "CREATE TABLE IF NOT EXISTS wtf (stamp int, nick varchar, luser varchar, lserver varchar, \"key\" varchar, \"value\" varchar)" T.no_params
214
215 let create_index_dfnidx db =
216 T.execute db "CREATE INDEX IF NOT EXISTS dfnidx ON wtf (\"key\")" T.no_params
217
218 let create_index_dfncheck db =
219 T.execute db "CREATE INDEX IF NOT EXISTS dfncheck ON wtf (\"key\", luser, lserver)" T.no_params
220
221 let total db =
222 let get_row stmt =
223 (T.get_column_Int stmt 0)
224 in
225 T.select1 db "SELECT COUNT(*) FROM wtf" T.no_params get_row
226
227 let dfn_new db ~stamp ~nick ~luser ~lserver ~key ~value =
228 let set_params stmt =
229 let p = T.start_params stmt 6 in
230 T.set_param_Int p 0 stamp;
231 T.set_param_Text p 1 nick;
232 T.set_param_Text p 2 luser;
233 T.set_param_Text p 3 lserver;
234 T.set_param_Text p 4 key;
235 T.set_param_Text p 5 value;
236 T.finish_params p
237 in
238 T.execute db "INSERT INTO wtf (stamp, nick, luser, lserver, \"key\", \"value\") VALUES (@stamp,@nick,@luser,@lserver,@key,@value)" set_params
239
240 let dfn_check_by_jid db ~key ~luser ~lserver =
241 let get_row stmt =
242 (T.get_column_Text stmt 0)
243 in
244 let set_params stmt =
245 let p = T.start_params stmt 3 in
246 T.set_param_Text p 0 key;
247 T.set_param_Text p 1 luser;
248 T.set_param_Text p 2 lserver;
249 T.finish_params p
250 in
251 T.select1 db "SELECT \"value\" FROM wtf WHERE \"key\"=@key AND luser=@luser AND lserver=@lserver LIMIT 1" set_params get_row
252
253 let dfn_delete_by_jid db ~key ~luser ~lserver =
254 let set_params stmt =
255 let p = T.start_params stmt 3 in
256 T.set_param_Text p 0 key;
257 T.set_param_Text p 1 luser;
258 T.set_param_Text p 2 lserver;
259 T.finish_params p
260 in
261 T.execute db "DELETE FROM wtf WHERE \"key\"=@key AND luser=@luser AND lserver=@lserver" set_params
262
263 let dfn_update_by_jid db ~stamp ~nick ~value ~key ~luser ~lserver =
264 let set_params stmt =
265 let p = T.start_params stmt 6 in
266 T.set_param_Int p 0 stamp;
267 T.set_param_Text p 1 nick;
268 T.set_param_Text p 2 value;
269 T.set_param_Text p 3 key;
270 T.set_param_Text p 4 luser;
271 T.set_param_Text p 5 lserver;
272 T.finish_params p
273 in
274 T.execute db "UPDATE wtf SET stamp=@stamp, nick=@nick, \"value\"=@value WHERE \"key\"=@key AND luser=@luser AND lserver=@lserver" set_params
275
276 let dfn_check_by_occupant db ~key ~nick ~luser ~lserver =
277 let get_row stmt =
278 (T.get_column_Text stmt 0)
279 in
280 let set_params stmt =
281 let p = T.start_params stmt 4 in
282 T.set_param_Text p 0 key;
283 T.set_param_Text p 1 nick;
284 T.set_param_Text p 2 luser;
285 T.set_param_Text p 3 lserver;
286 T.finish_params p
287 in
288 T.select1 db "SELECT \"value\" FROM wtf WHERE \"key\"=@key AND nick=@nick AND luser=@luser AND lserver=@lserver LIMIT 1" set_params get_row
289
290 let dfn_delete_by_occupant db ~key ~nick ~luser ~lserver =
291 let set_params stmt =
292 let p = T.start_params stmt 4 in
293 T.set_param_Text p 0 key;
294 T.set_param_Text p 1 nick;
295 T.set_param_Text p 2 luser;
296 T.set_param_Text p 3 lserver;
297 T.finish_params p
298 in
299 T.execute db "DELETE FROM wtf WHERE \"key\"=@key AND nick=@nick AND luser=@luser AND lserver=@lserver" set_params
300
301 let dfn_update_by_occupant db ~stamp ~value ~key ~nick ~luser ~lserver =
302 let set_params stmt =
303 let p = T.start_params stmt 6 in
304 T.set_param_Int p 0 stamp;
305 T.set_param_Text p 1 value;
306 T.set_param_Text p 2 key;
307 T.set_param_Text p 3 nick;
308 T.set_param_Text p 4 luser;
309 T.set_param_Text p 5 lserver;
310 T.finish_params p
311 in
312 T.execute db "UPDATE wtf SET stamp=@stamp, \"value\"=@value WHERE \"key\"=@key AND nick=@nick AND luser=@luser AND lserver=@lserver" set_params
313
314 let get_wtf_one db ~key =
315 let get_row stmt =
316 (T.get_column_Text stmt 0), (T.get_column_Text stmt 1)
317 in
318 let set_params stmt =
319 let p = T.start_params stmt 1 in
320 T.set_param_Text p 0 key;
321 T.finish_params p
322 in
323 T.select1 db "SELECT nick, \"value\" FROM wtf WHERE \"key\"=@key ORDER BY stamp DESC LIMIT 1" set_params get_row
324
325 let get_wtf_all db ~key callback acc =
326 let invoke_callback stmt =
327 callback
328 (T.get_column_Text stmt 0)
329 (T.get_column_Text stmt 1)
330 (T.get_column_Text stmt 2)
331 in
332 let set_params stmt =
333 let p = T.start_params stmt 1 in
334 T.set_param_Text p 0 key;
335 T.finish_params p
336 in
337 let r_acc = ref acc in
338 T.select db "SELECT nick, \"key\", \"value\" FROM wtf WHERE \"key\"=@key ORDER BY stamp" set_params (fun x -> r_acc := invoke_callback x !r_acc);
339 !r_acc
340
341 let wtf_count db ~key =
342 let get_row stmt =
343 (T.get_column_Int stmt 0)
344 in
345 let set_params stmt =
346 let p = T.start_params stmt 1 in
347 T.set_param_Text p 0 key;
348 T.finish_params p
349 in
350 T.select1 db "SELECT count(*) FROM wtf WHERE \"key\"=@key" set_params get_row
351
352 let wtffind db ~key ~value callback acc =
353 let invoke_callback stmt =
354 callback
355 (T.get_column_Text stmt 0)
356 (T.get_column_Text stmt 1)
357 (T.get_column_Text stmt 2)
358 in
359 let set_params stmt =
360 let p = T.start_params stmt 2 in
361 T.set_param_Text p 0 key;
362 T.set_param_Text p 1 value;
363 T.finish_params p
364 in
365 let r_acc = ref acc in
366 T.select db "SELECT nick, \"key\", \"value\" FROM wtf WHERE \"key\" LIKE @key OR \"value\" LIKE @value" set_params (fun x -> r_acc := invoke_callback x !r_acc);
367 !r_acc
368
369 let get_rand db ~rand =
370 let get_row stmt =
371 (T.get_column_Text stmt 0), (T.get_column_Text stmt 1), (T.get_column_Text stmt 2)
372 in
373 let set_params stmt =
374 let p = T.start_params stmt 1 in
375 T.set_param_Int p 0 rand;
376 T.finish_params p
377 in
378 T.select1 db "SELECT nick, \"key\", \"value\" FROM wtf LIMIT @rand,1" set_params get_row
379
380 let get_key_total db ~key =
381 let get_row stmt =
382 (T.get_column_Int stmt 0)
383 in
384 let set_params stmt =
385 let p = T.start_params stmt 1 in
386 T.set_param_Text p 0 key;
387 T.finish_params p
388 in
389 T.select1 db "SELECT count(*) FROM wtf WHERE \"key\"=@key" set_params get_row
390
391 let get_rand_key db ~key ~rand =
392 let get_row stmt =
393 (T.get_column_Text stmt 0), (T.get_column_Text stmt 1)
394 in
395 let set_params stmt =
396 let p = T.start_params stmt 2 in
397 T.set_param_Text p 0 key;
398 T.set_param_Int p 1 rand;
399 T.finish_params p
400 in
401 T.select1 db "SELECT nick, \"value\" FROM wtf WHERE \"key\"=@key LIMIT @rand,1" set_params get_row
402
403 let delete_key db ~key =
404 let set_params stmt =
405 let p = T.start_params stmt 1 in
406 T.set_param_Text p 0 key;
407 T.finish_params p
408 in
409 T.execute db "DELETE FROM wtf WHERE \"key\"=@key" set_params
410
411 let delete_key_value db ~key ~value =
412 let set_params stmt =
413 let p = T.start_params stmt 2 in
414 T.set_param_Text p 0 key;
415 T.set_param_Text p 1 value;
416 T.finish_params p
417 in
418 T.execute db "DELETE FROM wtf WHERE \"key\"=@key AND \"value\"=@value" set_params
419
420 end (* module Fold *)
421 end (* module Make *)
Something went wrong with that request. Please try again.