diff options
Diffstat (limited to 'src/datacache/plugin_datacache_sqlite.c')
-rw-r--r-- | src/datacache/plugin_datacache_sqlite.c | 161 |
1 files changed, 67 insertions, 94 deletions
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 5f534227f..3d67ffc22 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -78,8 +78,8 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded | |||
78 | { /* OUT: Statement handle */ | 78 | { /* OUT: Statement handle */ |
79 | char *dummy; | 79 | char *dummy; |
80 | 80 | ||
81 | return sqlite3_prepare (dbh, | 81 | return sqlite3_prepare (dbh, zSql, strlen (zSql), ppStmt, |
82 | zSql, strlen (zSql), ppStmt, (const char **) &dummy); | 82 | (const char **) &dummy); |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
@@ -95,11 +95,8 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded | |||
95 | * @return 0 on error, number of bytes used otherwise | 95 | * @return 0 on error, number of bytes used otherwise |
96 | */ | 96 | */ |
97 | static size_t | 97 | static size_t |
98 | sqlite_plugin_put (void *cls, | 98 | sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, |
99 | const GNUNET_HashCode * key, | 99 | const char *data, enum GNUNET_BLOCK_Type type, |
100 | size_t size, | ||
101 | const char *data, | ||
102 | enum GNUNET_BLOCK_Type type, | ||
103 | struct GNUNET_TIME_Absolute discard_time) | 100 | struct GNUNET_TIME_Absolute discard_time) |
104 | { | 101 | { |
105 | struct Plugin *plugin = cls; | 102 | struct Plugin *plugin = cls; |
@@ -109,48 +106,44 @@ sqlite_plugin_put (void *cls, | |||
109 | #if DEBUG_DATACACHE_SQLITE | 106 | #if DEBUG_DATACACHE_SQLITE |
110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
111 | "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n", | 108 | "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n", |
112 | "PUT", | 109 | "PUT", (unsigned int) size, GNUNET_h2s (key), |
113 | (unsigned int) size, | ||
114 | GNUNET_h2s (key), | ||
115 | (unsigned long long) | 110 | (unsigned long long) |
116 | GNUNET_TIME_absolute_get_remaining (discard_time).rel_value); | 111 | GNUNET_TIME_absolute_get_remaining (discard_time).rel_value); |
117 | #endif | 112 | #endif |
118 | dval = (int64_t) discard_time.abs_value; | 113 | dval = (int64_t) discard_time.abs_value; |
119 | if (dval < 0) | 114 | if (dval < 0) |
120 | dval = INT64_MAX; | 115 | dval = INT64_MAX; |
121 | if (sq_prepare (plugin->dbh, | 116 | if (sq_prepare |
122 | "INSERT INTO ds090 " | 117 | (plugin->dbh, |
123 | "(type, expire, key, value) " | 118 | "INSERT INTO ds090 " "(type, expire, key, value) " "VALUES (?, ?, ?, ?)", |
124 | "VALUES (?, ?, ?, ?)", &stmt) != SQLITE_OK) | 119 | &stmt) != SQLITE_OK) |
125 | { | 120 | { |
126 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 121 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
127 | _("`%s' failed at %s:%d with error: %s\n"), | 122 | _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", |
128 | "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); | 123 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
129 | return 0; | 124 | return 0; |
130 | } | 125 | } |
131 | if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) || | 126 | if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) || |
132 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, dval)) || | 127 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, dval)) || |
133 | (SQLITE_OK != sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode), | 128 | (SQLITE_OK != |
134 | SQLITE_TRANSIENT)) || | 129 | sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode), |
130 | SQLITE_TRANSIENT)) || | ||
135 | (SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size, SQLITE_TRANSIENT))) | 131 | (SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size, SQLITE_TRANSIENT))) |
136 | { | 132 | { |
137 | LOG_SQLITE (plugin->dbh, | 133 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
138 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
139 | "sqlite3_bind_xxx"); | 134 | "sqlite3_bind_xxx"); |
140 | sqlite3_finalize (stmt); | 135 | sqlite3_finalize (stmt); |
141 | return 0; | 136 | return 0; |
142 | } | 137 | } |
143 | if (SQLITE_DONE != sqlite3_step (stmt)) | 138 | if (SQLITE_DONE != sqlite3_step (stmt)) |
144 | { | 139 | { |
145 | LOG_SQLITE (plugin->dbh, | 140 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
146 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
147 | "sqlite3_step"); | 141 | "sqlite3_step"); |
148 | sqlite3_finalize (stmt); | 142 | sqlite3_finalize (stmt); |
149 | return 0; | 143 | return 0; |
150 | } | 144 | } |
151 | if (SQLITE_OK != sqlite3_finalize (stmt)) | 145 | if (SQLITE_OK != sqlite3_finalize (stmt)) |
152 | LOG_SQLITE (plugin->dbh, | 146 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
153 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
154 | "sqlite3_finalize"); | 147 | "sqlite3_finalize"); |
155 | return size + OVERHEAD; | 148 | return size + OVERHEAD; |
156 | } | 149 | } |
@@ -168,10 +161,9 @@ sqlite_plugin_put (void *cls, | |||
168 | * @return the number of results found | 161 | * @return the number of results found |
169 | */ | 162 | */ |
170 | static unsigned int | 163 | static unsigned int |
171 | sqlite_plugin_get (void *cls, | 164 | sqlite_plugin_get (void *cls, const GNUNET_HashCode * key, |
172 | const GNUNET_HashCode * key, | 165 | enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, |
173 | enum GNUNET_BLOCK_Type type, | 166 | void *iter_cls) |
174 | GNUNET_DATACACHE_Iterator iter, void *iter_cls) | ||
175 | { | 167 | { |
176 | struct Plugin *plugin = cls; | 168 | struct Plugin *plugin = cls; |
177 | sqlite3_stmt *stmt; | 169 | sqlite3_stmt *stmt; |
@@ -187,16 +179,17 @@ sqlite_plugin_get (void *cls, | |||
187 | 179 | ||
188 | now = GNUNET_TIME_absolute_get (); | 180 | now = GNUNET_TIME_absolute_get (); |
189 | #if DEBUG_DATACACHE_SQLITE | 181 | #if DEBUG_DATACACHE_SQLITE |
190 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' for key `%4s'\n", "GET", |
191 | "Processing `%s' for key `%4s'\n", "GET", GNUNET_h2s (key)); | 183 | GNUNET_h2s (key)); |
192 | #endif | 184 | #endif |
193 | if (sq_prepare (plugin->dbh, | 185 | if (sq_prepare |
194 | "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?", | 186 | (plugin->dbh, |
195 | &stmt) != SQLITE_OK) | 187 | "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?", |
188 | &stmt) != SQLITE_OK) | ||
196 | { | 189 | { |
197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
198 | _("`%s' failed at %s:%d with error: %s\n"), | 191 | _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", |
199 | "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); | 192 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
200 | return 0; | 193 | return 0; |
201 | } | 194 | } |
202 | ntime = (int64_t) now.abs_value; | 195 | ntime = (int64_t) now.abs_value; |
@@ -204,12 +197,10 @@ sqlite_plugin_get (void *cls, | |||
204 | if ((SQLITE_OK != | 197 | if ((SQLITE_OK != |
205 | sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode), | 198 | sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode), |
206 | SQLITE_TRANSIENT)) || | 199 | SQLITE_TRANSIENT)) || |
207 | (SQLITE_OK != | 200 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || |
208 | sqlite3_bind_int (stmt, 2, type)) || | ||
209 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) | 201 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) |
210 | { | 202 | { |
211 | LOG_SQLITE (plugin->dbh, | 203 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
212 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
213 | "sqlite3_bind_xxx"); | 204 | "sqlite3_bind_xxx"); |
214 | sqlite3_finalize (stmt); | 205 | sqlite3_finalize (stmt); |
215 | return 0; | 206 | return 0; |
@@ -217,8 +208,7 @@ sqlite_plugin_get (void *cls, | |||
217 | 208 | ||
218 | if (SQLITE_ROW != sqlite3_step (stmt)) | 209 | if (SQLITE_ROW != sqlite3_step (stmt)) |
219 | { | 210 | { |
220 | LOG_SQLITE (plugin->dbh, | 211 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
221 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
222 | "sqlite_step"); | 212 | "sqlite_step"); |
223 | sqlite3_finalize (stmt); | 213 | sqlite3_finalize (stmt); |
224 | return 0; | 214 | return 0; |
@@ -233,27 +223,23 @@ sqlite_plugin_get (void *cls, | |||
233 | while (cnt < total) | 223 | while (cnt < total) |
234 | { | 224 | { |
235 | off = (off + 1) % total; | 225 | off = (off + 1) % total; |
236 | GNUNET_snprintf (scratch, | 226 | GNUNET_snprintf (scratch, sizeof (scratch), |
237 | sizeof (scratch), | ||
238 | "SELECT value,expire FROM ds090 WHERE key=? AND type=? AND expire >= ? LIMIT 1 OFFSET %u", | 227 | "SELECT value,expire FROM ds090 WHERE key=? AND type=? AND expire >= ? LIMIT 1 OFFSET %u", |
239 | off); | 228 | off); |
240 | if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK) | 229 | if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK) |
241 | { | 230 | { |
242 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
243 | _("`%s' failed at %s:%d with error: %s\n"), | 232 | _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", |
244 | "sq_prepare", __FILE__, __LINE__, | 233 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
245 | sqlite3_errmsg (plugin->dbh)); | ||
246 | return cnt; | 234 | return cnt; |
247 | } | 235 | } |
248 | if ((SQLITE_OK != | 236 | if ((SQLITE_OK != |
249 | sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode), | 237 | sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode), |
250 | SQLITE_TRANSIENT)) || | 238 | SQLITE_TRANSIENT)) || |
251 | (SQLITE_OK != | 239 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || |
252 | sqlite3_bind_int (stmt, 2, type)) || | ||
253 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) | 240 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) |
254 | { | 241 | { |
255 | LOG_SQLITE (plugin->dbh, | 242 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
256 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
257 | "sqlite3_bind_xxx"); | 243 | "sqlite3_bind_xxx"); |
258 | sqlite3_finalize (stmt); | 244 | sqlite3_finalize (stmt); |
259 | return cnt; | 245 | return cnt; |
@@ -301,13 +287,14 @@ sqlite_plugin_del (void *cls) | |||
301 | #endif | 287 | #endif |
302 | stmt = NULL; | 288 | stmt = NULL; |
303 | dstmt = NULL; | 289 | dstmt = NULL; |
304 | if (sq_prepare (plugin->dbh, | 290 | if (sq_prepare |
305 | "SELECT type, key, value FROM ds090 ORDER BY expire ASC LIMIT 1", | 291 | (plugin->dbh, |
306 | &stmt) != SQLITE_OK) | 292 | "SELECT type, key, value FROM ds090 ORDER BY expire ASC LIMIT 1", |
293 | &stmt) != SQLITE_OK) | ||
307 | { | 294 | { |
308 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 295 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
309 | _("`%s' failed at %s:%d with error: %s\n"), | 296 | _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", |
310 | "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); | 297 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
311 | if (stmt != NULL) | 298 | if (stmt != NULL) |
312 | (void) sqlite3_finalize (stmt); | 299 | (void) sqlite3_finalize (stmt); |
313 | return GNUNET_SYSERR; | 300 | return GNUNET_SYSERR; |
@@ -315,9 +302,8 @@ sqlite_plugin_del (void *cls) | |||
315 | if (SQLITE_ROW != sqlite3_step (stmt)) | 302 | if (SQLITE_ROW != sqlite3_step (stmt)) |
316 | { | 303 | { |
317 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 304 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
318 | _("`%s' failed at %s:%d with error: %s\n"), | 305 | _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_step", |
319 | "sqlite3_step", __FILE__, __LINE__, | 306 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
320 | sqlite3_errmsg (plugin->dbh)); | ||
321 | (void) sqlite3_finalize (stmt); | 307 | (void) sqlite3_finalize (stmt); |
322 | return GNUNET_SYSERR; | 308 | return GNUNET_SYSERR; |
323 | } | 309 | } |
@@ -329,54 +315,44 @@ sqlite_plugin_del (void *cls) | |||
329 | memcpy (&hc, sqlite3_column_blob (stmt, 1), sizeof (GNUNET_HashCode)); | 315 | memcpy (&hc, sqlite3_column_blob (stmt, 1), sizeof (GNUNET_HashCode)); |
330 | if (SQLITE_OK != sqlite3_finalize (stmt)) | 316 | if (SQLITE_OK != sqlite3_finalize (stmt)) |
331 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 317 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
332 | _("`%s' failed at %s:%d with error: %s\n"), | 318 | _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_step", |
333 | "sqlite3_step", __FILE__, __LINE__, | 319 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
334 | sqlite3_errmsg (plugin->dbh)); | 320 | if (sq_prepare |
335 | if (sq_prepare (plugin->dbh, | 321 | (plugin->dbh, "DELETE FROM ds090 " "WHERE key=? AND value=? AND type=?", |
336 | "DELETE FROM ds090 " | 322 | &dstmt) != SQLITE_OK) |
337 | "WHERE key=? AND value=? AND type=?", &dstmt) != SQLITE_OK) | ||
338 | { | 323 | { |
339 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 324 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
340 | _("`%s' failed at %s:%d with error: %s\n"), | 325 | _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", |
341 | "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); | 326 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
342 | if (stmt != NULL) | 327 | if (stmt != NULL) |
343 | (void) sqlite3_finalize (stmt); | 328 | (void) sqlite3_finalize (stmt); |
344 | return GNUNET_SYSERR; | 329 | return GNUNET_SYSERR; |
345 | } | 330 | } |
346 | if ((SQLITE_OK != | 331 | if ((SQLITE_OK != |
347 | sqlite3_bind_blob (dstmt, | 332 | sqlite3_bind_blob (dstmt, 1, &hc, sizeof (GNUNET_HashCode), |
348 | 1, &hc, | ||
349 | sizeof (GNUNET_HashCode), | ||
350 | SQLITE_TRANSIENT)) || | ||
351 | (SQLITE_OK != | ||
352 | sqlite3_bind_blob (dstmt, | ||
353 | 2, blob, | ||
354 | dsize, | ||
355 | SQLITE_TRANSIENT)) || | 333 | SQLITE_TRANSIENT)) || |
356 | (SQLITE_OK != sqlite3_bind_int (dstmt, 3, dtype))) | 334 | (SQLITE_OK != sqlite3_bind_blob (dstmt, 2, blob, dsize, SQLITE_TRANSIENT)) |
335 | || (SQLITE_OK != sqlite3_bind_int (dstmt, 3, dtype))) | ||
357 | { | 336 | { |
358 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 337 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
359 | _("`%s' failed at %s:%d with error: %s\n"), | 338 | _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_bind", |
360 | "sqlite3_bind", __FILE__, __LINE__, | 339 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
361 | sqlite3_errmsg (plugin->dbh)); | ||
362 | (void) sqlite3_finalize (dstmt); | 340 | (void) sqlite3_finalize (dstmt); |
363 | return GNUNET_SYSERR; | 341 | return GNUNET_SYSERR; |
364 | } | 342 | } |
365 | if (sqlite3_step (dstmt) != SQLITE_DONE) | 343 | if (sqlite3_step (dstmt) != SQLITE_DONE) |
366 | { | 344 | { |
367 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 345 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
368 | _("`%s' failed at %s:%d with error: %s\n"), | 346 | _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_step", |
369 | "sqlite3_step", __FILE__, __LINE__, | 347 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
370 | sqlite3_errmsg (plugin->dbh)); | ||
371 | (void) sqlite3_finalize (dstmt); | 348 | (void) sqlite3_finalize (dstmt); |
372 | return GNUNET_SYSERR; | 349 | return GNUNET_SYSERR; |
373 | } | 350 | } |
374 | plugin->env->delete_notify (plugin->env->cls, &hc, dsize + OVERHEAD); | 351 | plugin->env->delete_notify (plugin->env->cls, &hc, dsize + OVERHEAD); |
375 | if (SQLITE_OK != sqlite3_finalize (dstmt)) | 352 | if (SQLITE_OK != sqlite3_finalize (dstmt)) |
376 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 353 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
377 | _("`%s' failed at %s:%d with error: %s\n"), | 354 | _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_finalize", |
378 | "sqlite3_finalize", __FILE__, __LINE__, | 355 | __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); |
379 | sqlite3_errmsg (plugin->dbh)); | ||
380 | return GNUNET_OK; | 356 | return GNUNET_OK; |
381 | } | 357 | } |
382 | 358 | ||
@@ -425,8 +401,7 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) | |||
425 | SQLITE3_EXEC (dbh, "PRAGMA count_changes=OFF"); | 401 | SQLITE3_EXEC (dbh, "PRAGMA count_changes=OFF"); |
426 | SQLITE3_EXEC (dbh, "PRAGMA page_size=4092"); | 402 | SQLITE3_EXEC (dbh, "PRAGMA page_size=4092"); |
427 | SQLITE3_EXEC (dbh, | 403 | SQLITE3_EXEC (dbh, |
428 | "CREATE TABLE ds090 (" | 404 | "CREATE TABLE ds090 (" " type INTEGER NOT NULL DEFAULT 0," |
429 | " type INTEGER NOT NULL DEFAULT 0," | ||
430 | " expire INTEGER NOT NULL DEFAULT 0," | 405 | " expire INTEGER NOT NULL DEFAULT 0," |
431 | " key BLOB NOT NULL DEFAULT ''," | 406 | " key BLOB NOT NULL DEFAULT ''," |
432 | " value BLOB NOT NULL DEFAULT '')"); | 407 | " value BLOB NOT NULL DEFAULT '')"); |
@@ -440,8 +415,8 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) | |||
440 | api->get = &sqlite_plugin_get; | 415 | api->get = &sqlite_plugin_get; |
441 | api->put = &sqlite_plugin_put; | 416 | api->put = &sqlite_plugin_put; |
442 | api->del = &sqlite_plugin_del; | 417 | api->del = &sqlite_plugin_del; |
443 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, | 418 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "sqlite", |
444 | "sqlite", _("Sqlite datacache running\n")); | 419 | _("Sqlite datacache running\n")); |
445 | return api; | 420 | return api; |
446 | } | 421 | } |
447 | 422 | ||
@@ -474,22 +449,20 @@ libgnunet_plugin_datacache_sqlite_done (void *cls) | |||
474 | #if SQLITE_VERSION_NUMBER >= 3007000 | 449 | #if SQLITE_VERSION_NUMBER >= 3007000 |
475 | if (result == SQLITE_BUSY) | 450 | if (result == SQLITE_BUSY) |
476 | { | 451 | { |
477 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, | 452 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "sqlite", |
478 | "sqlite", | ||
479 | _ | 453 | _ |
480 | ("Tried to close sqlite without finalizing all prepared statements.\n")); | 454 | ("Tried to close sqlite without finalizing all prepared statements.\n")); |
481 | stmt = sqlite3_next_stmt (plugin->dbh, NULL); | 455 | stmt = sqlite3_next_stmt (plugin->dbh, NULL); |
482 | while (stmt != NULL) | 456 | while (stmt != NULL) |
483 | { | 457 | { |
484 | #if DEBUG_SQLITE | 458 | #if DEBUG_SQLITE |
485 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 459 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
486 | "sqlite", "Closing statement %p\n", stmt); | 460 | "Closing statement %p\n", stmt); |
487 | #endif | 461 | #endif |
488 | result = sqlite3_finalize (stmt); | 462 | result = sqlite3_finalize (stmt); |
489 | #if DEBUG_SQLITE | 463 | #if DEBUG_SQLITE |
490 | if (result != SQLITE_OK) | 464 | if (result != SQLITE_OK) |
491 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 465 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", |
492 | "sqlite", | ||
493 | "Failed to close statement %p: %d\n", stmt, result); | 466 | "Failed to close statement %p: %d\n", stmt, result); |
494 | #endif | 467 | #endif |
495 | stmt = sqlite3_next_stmt (plugin->dbh, NULL); | 468 | stmt = sqlite3_next_stmt (plugin->dbh, NULL); |