Implement asynchronous peerstore plugin API
[oweals/gnunet.git] / src / peerstore / plugin_peerstore_sqlite.c
1 /*
2  * This file is part of GNUnet
3  * (C) 2013 Christian Grothoff (and other contributing authors)
4  *
5  * GNUnet is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published
7  * by the Free Software Foundation; either version 3, or (at your
8  * option) any later version.
9  *
10  * GNUnet is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with GNUnet; see the file COPYING.  If not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file peerstore/plugin_peerstore_sqlite.c
23  * @brief sqlite-based peerstore backend
24  * @author Omar Tarabai
25  */
26
27 #include "platform.h"
28 #include "gnunet_peerstore_plugin.h"
29 #include "gnunet_peerstore_service.h"
30 #include "peerstore.h"
31 #include <sqlite3.h>
32
33 /**
34  * After how many ms "busy" should a DB operation fail for good?  A
35  * low value makes sure that we are more responsive to requests
36  * (especially PUTs).  A high value guarantees a higher success rate
37  * (SELECTs in iterate can take several seconds despite LIMIT=1).
38  *
39  * The default value of 1s should ensure that users do not experience
40  * huge latencies while at the same time allowing operations to
41  * succeed with reasonable probability.
42  */
43 #define BUSY_TIMEOUT_MS 1000
44
45 /**
46  * Log an error message at log-level 'level' that indicates
47  * a failure of the command 'cmd' on file 'filename'
48  * with the message given by strerror(errno).
49  */
50 #define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, "peerstore-sqlite", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); } while(0)
51
52 #define LOG(kind,...) GNUNET_log_from (kind, "peerstore-sqlite", __VA_ARGS__)
53
54 /**
55  * Context for all functions in this plugin.
56  */
57 struct Plugin
58 {
59
60   /**
61    * Configuration handle
62    */
63   const struct GNUNET_CONFIGURATION_Handle *cfg;
64
65   /**
66    * Database filename.
67    */
68   char *fn;
69
70   /**
71    * Native SQLite database handle.
72    */
73   sqlite3 *dbh;
74
75   /**
76    * Precompiled SQL for inserting into peerstoredata
77    */
78   sqlite3_stmt *insert_peerstoredata;
79
80   /**
81    * Precompiled SQL for selecting from peerstoredata
82    */
83   sqlite3_stmt *select_peerstoredata;
84
85   /**
86    * Precompiled SQL for selecting from peerstoredata
87    */
88   sqlite3_stmt *select_peerstoredata_by_pid;
89
90   /**
91    * Precompiled SQL for selecting from peerstoredata
92    */
93   sqlite3_stmt *select_peerstoredata_by_key;
94
95   /**
96    * Precompiled SQL for selecting from peerstoredata
97    */
98   sqlite3_stmt *select_peerstoredata_by_all;
99
100   /**
101    * Precompiled SQL for deleting expired
102    * records from peerstoredata
103    */
104   sqlite3_stmt *expire_peerstoredata;
105
106   /**
107    * Precompiled SQL for deleting records
108    * with given key
109    */
110   sqlite3_stmt *delete_peerstoredata;
111
112 };
113
114 /**
115  * Delete records with the given key
116  *
117  * @param cls closure (internal context for the plugin)
118  * @param sub_system name of sub system
119  * @param peer Peer identity (can be NULL)
120  * @param key entry key string (can be NULL)
121  * @return number of deleted records
122  */
123 static int
124 peerstore_sqlite_delete_records (void *cls, const char *sub_system,
125                                  const struct GNUNET_PeerIdentity *peer,
126                                  const char *key)
127 {
128   struct Plugin *plugin = cls;
129   sqlite3_stmt *stmt = plugin->delete_peerstoredata;
130
131   if ((SQLITE_OK !=
132        sqlite3_bind_text (stmt, 1, sub_system, strlen (sub_system) + 1,
133                           SQLITE_STATIC)) ||
134       (SQLITE_OK !=
135        sqlite3_bind_blob (stmt, 2, peer, sizeof (struct GNUNET_PeerIdentity),
136                           SQLITE_STATIC)) ||
137       (SQLITE_OK !=
138        sqlite3_bind_text (stmt, 3, key, strlen (key) + 1, SQLITE_STATIC)))
139   {
140     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
141                 "sqlite3_bind");
142   }
143   else if (SQLITE_DONE != sqlite3_step (stmt))
144   {
145     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
146                 "sqlite3_step");
147   }
148   if (SQLITE_OK != sqlite3_reset (stmt))
149   {
150     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
151                 "sqlite3_reset");
152     return 0;
153   }
154   return sqlite3_changes (plugin->dbh);
155 }
156
157
158 /**
159  * Delete expired records (expiry < now)
160  *
161  * @param cls closure (internal context for the plugin)
162  * @param now time to use as reference
163  * @param cont continuation called with the number of records expired
164  * @param cont_cls continuation closure
165  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and cont is not
166  * called
167  */
168 static int
169 peerstore_sqlite_expire_records (void *cls, struct GNUNET_TIME_Absolute now,
170                                  GNUNET_PEERSTORE_Continuation cont,
171                                  void *cont_cls)
172 {
173   struct Plugin *plugin = cls;
174   sqlite3_stmt *stmt = plugin->expire_peerstoredata;
175
176   if (SQLITE_OK !=
177       sqlite3_bind_int64 (stmt, 1, (sqlite3_uint64) now.abs_value_us))
178   {
179     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
180                 "sqlite3_bind");
181   }
182   else if (SQLITE_DONE != sqlite3_step (stmt))
183   {
184     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
185                 "sqlite3_step");
186   }
187   if (SQLITE_OK != sqlite3_reset (stmt))
188   {
189     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
190                 "sqlite3_reset");
191     return GNUNET_SYSERR;
192   }
193   if (NULL != cont)
194   {
195     cont (cont_cls, sqlite3_changes (plugin->dbh));
196   }
197   return GNUNET_OK;
198 }
199
200
201 /**
202  * Iterate over the records given an optional peer id
203  * and/or key.
204  *
205  * @param cls closure (internal context for the plugin)
206  * @param sub_system name of sub system
207  * @param peer Peer identity (can be NULL)
208  * @param key entry key string (can be NULL)
209  * @param iter function to call asynchronously with the results, terminated
210  * by a NULL result
211  * @param iter_cls closure for @a iter
212  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error and iter is not
213  * called
214  */
215 static int
216 peerstore_sqlite_iterate_records (void *cls, const char *sub_system,
217                                   const struct GNUNET_PeerIdentity *peer,
218                                   const char *key,
219                                   GNUNET_PEERSTORE_Processor iter,
220                                   void *iter_cls)
221 {
222   struct Plugin *plugin = cls;
223   sqlite3_stmt *stmt;
224   int err = 0;
225   int sret;
226   struct GNUNET_PEERSTORE_Record *ret;
227
228   LOG (GNUNET_ERROR_TYPE_DEBUG, "Executing iterate request on sqlite db.\n");
229   if (NULL == peer && NULL == key)
230   {
231     stmt = plugin->select_peerstoredata;
232     err =
233         (SQLITE_OK !=
234          sqlite3_bind_text (stmt, 1, sub_system, strlen (sub_system) + 1,
235                             SQLITE_STATIC));
236   }
237   else if (NULL == key)
238   {
239     stmt = plugin->select_peerstoredata_by_pid;
240     err =
241         (SQLITE_OK !=
242          sqlite3_bind_text (stmt, 1, sub_system, strlen (sub_system) + 1,
243                             SQLITE_STATIC)) ||
244         (SQLITE_OK !=
245          sqlite3_bind_blob (stmt, 2, peer, sizeof (struct GNUNET_PeerIdentity),
246                             SQLITE_STATIC));
247   }
248   else if (NULL == peer)
249   {
250     stmt = plugin->select_peerstoredata_by_key;
251     err =
252         (SQLITE_OK !=
253          sqlite3_bind_text (stmt, 1, sub_system, strlen (sub_system) + 1,
254                             SQLITE_STATIC)) ||
255         (SQLITE_OK !=
256          sqlite3_bind_text (stmt, 2, key, strlen (key) + 1, SQLITE_STATIC));
257   }
258   else
259   {
260     stmt = plugin->select_peerstoredata_by_all;
261     err =
262         (SQLITE_OK !=
263          sqlite3_bind_text (stmt, 1, sub_system, strlen (sub_system) + 1,
264                             SQLITE_STATIC)) ||
265         (SQLITE_OK !=
266          sqlite3_bind_blob (stmt, 2, peer, sizeof (struct GNUNET_PeerIdentity),
267                             SQLITE_STATIC)) ||
268         (SQLITE_OK !=
269          sqlite3_bind_text (stmt, 3, key, strlen (key) + 1, SQLITE_STATIC));
270   }
271
272   if (err)
273   {
274     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
275                 "sqlite3_bind_XXXX");
276     if (SQLITE_OK != sqlite3_reset (stmt))
277       LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
278                   "sqlite3_reset");
279     return GNUNET_SYSERR;
280   }
281   while (SQLITE_ROW == (sret = sqlite3_step (stmt)))
282   {
283     LOG (GNUNET_ERROR_TYPE_DEBUG, "Returning a matched record.\n");
284     ret = GNUNET_new (struct GNUNET_PEERSTORE_Record);
285
286     ret->sub_system = (char *) sqlite3_column_text (stmt, 0);
287     ret->peer = (struct GNUNET_PeerIdentity *) sqlite3_column_blob (stmt, 1);
288     ret->key = (char *) sqlite3_column_text (stmt, 2);
289     ret->value = (void *) sqlite3_column_blob (stmt, 3);
290     ret->value_size = sqlite3_column_bytes (stmt, 3);
291     ret->expiry = GNUNET_new (struct GNUNET_TIME_Absolute);
292
293     ret->expiry->abs_value_us = (uint64_t) sqlite3_column_int64 (stmt, 4);
294     if (NULL != iter)
295       iter (iter_cls, ret, NULL);
296     GNUNET_free (ret->expiry);
297     GNUNET_free (ret);
298   }
299   if (SQLITE_DONE != sret)
300   {
301     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
302     err = 1;
303   }
304   if (SQLITE_OK != sqlite3_reset (stmt))
305   {
306     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
307                 "sqlite3_reset");
308     err = 1;
309   }
310   if (NULL != iter)
311   {
312     iter (iter_cls, NULL, err ? "sqlite error" : NULL);
313   }
314   return GNUNET_OK;
315 }
316
317
318 /**
319  * Store a record in the peerstore.
320  * Key is the combination of sub system and peer identity.
321  * One key can store multiple values.
322  *
323  * @param cls closure (internal context for the plugin)
324  * @param sub_system name of the GNUnet sub system responsible
325  * @param peer peer identity
326  * @param key record key string
327  * @param value value to be stored
328  * @param size size of value to be stored
329  * @param expiry absolute time after which the record is (possibly) deleted
330  * @param options options related to the store operation
331  * @param cont continuation called when record is stored
332  * @param cont_cls continuation closure
333  * @return #GNUNET_OK on success, else #GNUNET_SYSERR and cont is not called
334  */
335 static int
336 peerstore_sqlite_store_record (void *cls, const char *sub_system,
337                                const struct GNUNET_PeerIdentity *peer,
338                                const char *key, const void *value, size_t size,
339                                struct GNUNET_TIME_Absolute expiry,
340                                enum GNUNET_PEERSTORE_StoreOption options,
341                                GNUNET_PEERSTORE_Continuation cont,
342                                void *cont_cls)
343 {
344   struct Plugin *plugin = cls;
345   sqlite3_stmt *stmt = plugin->insert_peerstoredata;
346
347   if (GNUNET_PEERSTORE_STOREOPTION_REPLACE == options)
348   {
349     peerstore_sqlite_delete_records (cls, sub_system, peer, key);
350   }
351   if (SQLITE_OK !=
352       sqlite3_bind_text (stmt, 1, sub_system, strlen (sub_system) + 1,
353                          SQLITE_STATIC) ||
354       SQLITE_OK != sqlite3_bind_blob (stmt, 2, peer,
355                                       sizeof (struct GNUNET_PeerIdentity),
356                                       SQLITE_STATIC) ||
357       SQLITE_OK != sqlite3_bind_text (stmt, 3, key, strlen (key) + 1,
358                                       SQLITE_STATIC) ||
359       SQLITE_OK != sqlite3_bind_blob (stmt, 4, value, size, SQLITE_STATIC) ||
360       SQLITE_OK != sqlite3_bind_int64 (stmt, 5,
361                                        (sqlite3_uint64) expiry.abs_value_us))
362     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
363                 "sqlite3_bind");
364   else if (SQLITE_DONE != sqlite3_step (stmt))
365   {
366     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
367                 "sqlite3_step");
368   }
369   if (SQLITE_OK != sqlite3_reset (stmt))
370   {
371     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
372                 "sqlite3_reset");
373     return GNUNET_SYSERR;
374   }
375   if (NULL != cont)
376   {
377     cont (cont_cls, GNUNET_OK);
378   }
379   return GNUNET_OK;
380 }
381
382
383 /**
384  * @brief Prepare a SQL statement
385  *
386  * @param dbh handle to the database
387  * @param sql SQL statement, UTF-8 encoded
388  * @return 0 on success
389  */
390 static int
391 sql_exec (sqlite3 * dbh, const char *sql)
392 {
393   int result;
394
395   result = sqlite3_exec (dbh, sql, NULL, NULL, NULL);
396   LOG (GNUNET_ERROR_TYPE_DEBUG, "Executed `%s' / %d\n", sql, result);
397   if (result != SQLITE_OK)
398     LOG (GNUNET_ERROR_TYPE_ERROR, _("Error executing SQL query: %s\n  %s\n"),
399          sqlite3_errmsg (dbh), sql);
400   return result;
401 }
402
403
404 /**
405  * @brief Prepare a SQL statement
406  *
407  * @param dbh handle to the database
408  * @param sql SQL statement, UTF-8 encoded
409  * @param stmt set to the prepared statement
410  * @return 0 on success
411  */
412 static int
413 sql_prepare (sqlite3 * dbh, const char *sql, sqlite3_stmt ** stmt)
414 {
415   char *tail;
416   int result;
417
418   result =
419       sqlite3_prepare_v2 (dbh, sql, strlen (sql), stmt, (const char **) &tail);
420   LOG (GNUNET_ERROR_TYPE_DEBUG, "Prepared `%s' / %p: %d\n", sql, *stmt, result);
421   if (result != SQLITE_OK)
422     LOG (GNUNET_ERROR_TYPE_ERROR, _("Error preparing SQL query: %s\n  %s\n"),
423          sqlite3_errmsg (dbh), sql);
424   return result;
425 }
426
427
428 /**
429  * sqlite3 custom function for comparison of uint64_t values
430  * since it is not supported by default
431  */
432 void
433 sqlite3_lessthan (sqlite3_context * ctx, int dummy, sqlite3_value ** values)
434 {
435   uint64_t v1;
436   uint64_t v2;
437
438   v1 = (uint64_t) sqlite3_value_int64 (values[0]);
439   v2 = (uint64_t) sqlite3_value_int64 (values[1]);
440   sqlite3_result_int (ctx, v1 < v2);
441 }
442
443
444 /**
445  * Initialize the database connections and associated
446  * data structures (create tables and indices
447  * as needed as well).
448  *
449  * @param plugin the plugin context (state for this module)
450  * @return GNUNET_OK on success
451  */
452 static int
453 database_setup (struct Plugin *plugin)
454 {
455   char *filename;
456
457   if (GNUNET_OK !=
458       GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, "peerstore-sqlite",
459                                                "FILENAME", &filename))
460   {
461     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "peerstore-sqlite",
462                                "FILENAME");
463     return GNUNET_SYSERR;
464   }
465   if (GNUNET_OK != GNUNET_DISK_file_test (filename))
466   {
467     if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (filename))
468     {
469       GNUNET_break (0);
470       GNUNET_free (filename);
471       return GNUNET_SYSERR;
472     }
473   }
474   /* filename should be UTF-8-encoded. If it isn't, it's a bug */
475   plugin->fn = filename;
476   /* Open database and precompile statements */
477   if (SQLITE_OK != sqlite3_open (plugin->fn, &plugin->dbh))
478   {
479     LOG (GNUNET_ERROR_TYPE_ERROR, _("Unable to initialize SQLite: %s.\n"),
480          sqlite3_errmsg (plugin->dbh));
481     return GNUNET_SYSERR;
482   }
483   sql_exec (plugin->dbh, "PRAGMA temp_store=MEMORY");
484   sql_exec (plugin->dbh, "PRAGMA synchronous=OFF");
485   sql_exec (plugin->dbh, "PRAGMA legacy_file_format=OFF");
486   sql_exec (plugin->dbh, "PRAGMA auto_vacuum=INCREMENTAL");
487   sql_exec (plugin->dbh, "PRAGMA encoding=\"UTF-8\"");
488   sql_exec (plugin->dbh, "PRAGMA page_size=4096");
489   sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS);
490   /* Create tables */
491   sql_exec (plugin->dbh,
492             "CREATE TABLE IF NOT EXISTS peerstoredata (\n"
493             "  sub_system TEXT NOT NULL,\n" "  peer_id BLOB NOT NULL,\n"
494             "  key TEXT NOT NULL,\n" "  value BLOB NULL,\n"
495             "  expiry sqlite3_uint64 NOT NULL" ");");
496   sqlite3_create_function (plugin->dbh, "UINT64_LT", 2, SQLITE_UTF8, NULL,
497                            &sqlite3_lessthan, NULL, NULL);
498   /* Create Indices */
499   if (SQLITE_OK !=
500       sqlite3_exec (plugin->dbh,
501                     "CREATE INDEX IF NOT EXISTS peerstoredata_key_index ON peerstoredata (sub_system, peer_id, key)",
502                     NULL, NULL, NULL))
503   {
504     LOG (GNUNET_ERROR_TYPE_ERROR, _("Unable to create indices: %s.\n"),
505          sqlite3_errmsg (plugin->dbh));
506     return GNUNET_SYSERR;
507   }
508   /* Prepare statements */
509
510   sql_prepare (plugin->dbh,
511                "INSERT INTO peerstoredata (sub_system, peer_id, key, value, expiry) VALUES (?,?,?,?,?);",
512                &plugin->insert_peerstoredata);
513   sql_prepare (plugin->dbh,
514                "SELECT * FROM peerstoredata" " WHERE sub_system = ?",
515                &plugin->select_peerstoredata);
516   sql_prepare (plugin->dbh,
517                "SELECT * FROM peerstoredata" " WHERE sub_system = ?"
518                " AND peer_id = ?", &plugin->select_peerstoredata_by_pid);
519   sql_prepare (plugin->dbh,
520                "SELECT * FROM peerstoredata" " WHERE sub_system = ?"
521                " AND key = ?", &plugin->select_peerstoredata_by_key);
522   sql_prepare (plugin->dbh,
523                "SELECT * FROM peerstoredata" " WHERE sub_system = ?"
524                " AND peer_id = ?" " AND key = ?",
525                &plugin->select_peerstoredata_by_all);
526   sql_prepare (plugin->dbh,
527                "DELETE FROM peerstoredata" " WHERE UINT64_LT(expiry, ?)",
528                &plugin->expire_peerstoredata);
529   sql_prepare (plugin->dbh,
530                "DELETE FROM peerstoredata" " WHERE sub_system = ?"
531                " AND peer_id = ?" " AND key = ?",
532                &plugin->delete_peerstoredata);
533   return GNUNET_OK;
534 }
535
536
537 /**
538  * Shutdown database connection and associate data
539  * structures.
540  * @param plugin the plugin context (state for this module)
541  */
542 static void
543 database_shutdown (struct Plugin *plugin)
544 {
545   int result;
546   sqlite3_stmt *stmt;
547
548   while (NULL != (stmt = sqlite3_next_stmt (plugin->dbh, NULL)))
549   {
550     result = sqlite3_finalize (stmt);
551     if (SQLITE_OK != result)
552       LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to close statement %p: %d\n",
553            stmt, result);
554   }
555   if (SQLITE_OK != sqlite3_close (plugin->dbh))
556     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite3_close");
557   GNUNET_free_non_null (plugin->fn);
558 }
559
560
561 /**
562  * Entry point for the plugin.
563  *
564  * @param cls The struct GNUNET_CONFIGURATION_Handle.
565  * @return NULL on error, otherwise the plugin context
566  */
567 void *
568 libgnunet_plugin_peerstore_sqlite_init (void *cls)
569 {
570   static struct Plugin plugin;
571   const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
572   struct GNUNET_PEERSTORE_PluginFunctions *api;
573
574   if (NULL != plugin.cfg)
575     return NULL;                /* can only initialize once! */
576   memset (&plugin, 0, sizeof (struct Plugin));
577   plugin.cfg = cfg;
578   if (GNUNET_OK != database_setup (&plugin))
579   {
580     database_shutdown (&plugin);
581     return NULL;
582   }
583   api = GNUNET_new (struct GNUNET_PEERSTORE_PluginFunctions);
584   api->cls = &plugin;
585   api->store_record = &peerstore_sqlite_store_record;
586   api->iterate_records = &peerstore_sqlite_iterate_records;
587   api->expire_records = &peerstore_sqlite_expire_records;
588   LOG (GNUNET_ERROR_TYPE_DEBUG, "Sqlite plugin is running\n");
589   return api;
590 }
591
592
593 /**
594  * Exit point from the plugin.
595  *
596  * @param cls The plugin context (as returned by "init")
597  * @return Always NULL
598  */
599 void *
600 libgnunet_plugin_peerstore_sqlite_done (void *cls)
601 {
602   struct GNUNET_PEERSTORE_PluginFunctions *api = cls;
603   struct Plugin *plugin = api->cls;
604
605   database_shutdown (plugin);
606   plugin->cfg = NULL;
607   GNUNET_free (api);
608   LOG (GNUNET_ERROR_TYPE_DEBUG, "Sqlite plugin is finished\n");
609   return NULL;
610 }
611
612 /* end of plugin_peerstore_sqlite.c */