gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: modernize namestore postgres plugin, a


From: gnunet
Subject: [gnunet] branch master updated: modernize namestore postgres plugin, a bit
Date: Mon, 21 Nov 2022 17:08:50 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new d237b33a4 modernize namestore postgres plugin, a bit
     new e46e53f7f Merge branch 'master' of git+ssh://git.gnunet.org/gnunet
d237b33a4 is described below

commit d237b33a42048e26f409375af65ec275ae0eb027
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Nov 21 17:08:39 2022 +0100

    modernize namestore postgres plugin, a bit
---
 src/include/gnunet_namestore_plugin.h     |  83 +++++----
 src/namestore/Makefile.am                 |   6 +
 src/namestore/gnunet-namestore-dbtool.c   |  55 +++---
 src/namestore/namestore-0001.sql          |  48 +++++
 src/namestore/namestore-drop.sql          |  25 +++
 src/namestore/plugin_namestore_postgres.c | 288 ++++++++++++------------------
 src/namestore/plugin_namestore_sqlite.c   | 109 ++++++-----
 src/namestore/test_common.c               |  46 +++--
 src/namestore/test_plugin_namestore.c     |  21 ++-
 9 files changed, 362 insertions(+), 319 deletions(-)

diff --git a/src/include/gnunet_namestore_plugin.h 
b/src/include/gnunet_namestore_plugin.h
index 1df0a5eb0..4f08ccbcf 100644
--- a/src/include/gnunet_namestore_plugin.h
+++ b/src/include/gnunet_namestore_plugin.h
@@ -88,12 +88,12 @@ struct GNUNET_NAMESTORE_PluginFunctions
    * @param rd array of records with data to store
    * @return #GNUNET_OK on success, else #GNUNET_SYSERR
    */
-  int
-  (*store_records) (void *cls,
-                    const struct GNUNET_IDENTITY_PrivateKey *zone,
-                    const char *label,
-                    unsigned int rd_count,
-                    const struct GNUNET_GNSRECORD_Data *rd);
+  enum GNUNET_GenericReturnValue
+  (*store_records)(void *cls,
+                   const struct GNUNET_IDENTITY_PrivateKey *zone,
+                   const char *label,
+                   unsigned int rd_count,
+                   const struct GNUNET_GNSRECORD_Data *rd);
 
   /**
    * Lookup records in the datastore for which we are the authority.
@@ -105,12 +105,12 @@ struct GNUNET_NAMESTORE_PluginFunctions
    * @param iter_cls closure for @a iter
    * @return #GNUNET_OK on success, #GNUNET_NO for no results, else 
#GNUNET_SYSERR
    */
-  int
-  (*lookup_records) (void *cls,
-                     const struct GNUNET_IDENTITY_PrivateKey *zone,
-                     const char *label,
-                     GNUNET_NAMESTORE_RecordIterator iter,
-                     void *iter_cls);
+  enum GNUNET_GenericReturnValue
+  (*lookup_records)(void *cls,
+                    const struct GNUNET_IDENTITY_PrivateKey *zone,
+                    const char *label,
+                    GNUNET_NAMESTORE_RecordIterator iter,
+                    void *iter_cls);
 
 
   /**
@@ -127,13 +127,13 @@ struct GNUNET_NAMESTORE_PluginFunctions
    * @param iter_cls closure for @a iter
    * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, 
#GNUNET_SYSERR on error
    */
-  int
-  (*iterate_records) (void *cls,
-                      const struct GNUNET_IDENTITY_PrivateKey *zone,
-                      uint64_t serial,
-                      uint64_t limit,
-                      GNUNET_NAMESTORE_RecordIterator iter,
-                      void *iter_cls);
+  enum GNUNET_GenericReturnValue
+  (*iterate_records)(void *cls,
+                     const struct GNUNET_IDENTITY_PrivateKey *zone,
+                     uint64_t serial,
+                     uint64_t limit,
+                     GNUNET_NAMESTORE_RecordIterator iter,
+                     void *iter_cls);
 
 
   /**
@@ -147,12 +147,12 @@ struct GNUNET_NAMESTORE_PluginFunctions
    * @param iter_cls closure for @a iter
    * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, 
#GNUNET_SYSERR on error
    */
-  int
-  (*zone_to_name) (void *cls,
-                   const struct GNUNET_IDENTITY_PrivateKey *zone,
-                   const struct GNUNET_IDENTITY_PublicKey *value_zone,
-                   GNUNET_NAMESTORE_RecordIterator iter,
-                   void *iter_cls);
+  enum GNUNET_GenericReturnValue
+  (*zone_to_name)(void *cls,
+                  const struct GNUNET_IDENTITY_PrivateKey *zone,
+                  const struct GNUNET_IDENTITY_PublicKey *value_zone,
+                  GNUNET_NAMESTORE_RecordIterator iter,
+                  void *iter_cls);
 
   /** Transaction-based API draft **/
 
@@ -164,7 +164,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    */
   enum GNUNET_GenericReturnValue
-  (*transaction_begin) (void *cls, char **emsg);
+  (*transaction_begin)(void *cls, char **emsg);
 
   /**
    * Abort and roll back a transaction in the database
@@ -174,7 +174,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    */
   enum GNUNET_GenericReturnValue
-  (*transaction_rollback) (void *cls, char **emsg);
+  (*transaction_rollback)(void *cls, char **emsg);
 
   /**
    * Commit a transaction in the database
@@ -184,7 +184,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
    * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    */
   enum GNUNET_GenericReturnValue
-  (*transaction_commit) (void *cls, char **emsg);
+  (*transaction_commit)(void *cls, char **emsg);
 
   /**
    * Edit records in the datastore for which we are the authority.
@@ -198,35 +198,32 @@ struct GNUNET_NAMESTORE_PluginFunctions
    * @param iter_cls closure for @a iter
    * @return #GNUNET_OK on success, #GNUNET_NO for no results, else 
#GNUNET_SYSERR
    */
-  int
-  (*edit_records) (void *cls,
-                     const struct GNUNET_IDENTITY_PrivateKey *zone,
-                     const char *label,
-                     GNUNET_NAMESTORE_RecordIterator iter,
-                     void *iter_cls);
+  enum GNUNET_GenericReturnValue
+  (*edit_records)(void *cls,
+                  const struct GNUNET_IDENTITY_PrivateKey *zone,
+                  const char *label,
+                  GNUNET_NAMESTORE_RecordIterator iter,
+                  void *iter_cls);
 
   /**
    * Setup the database.
-   * Note that this will also fail if the database is already initialized.
-   * See reset_database().
    *
    * @param cls closure (internal context for the plugin)
-   * @param emsg error message on failure. Will be allocated, must be freed.
    * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR
    */
-  int
-  (*initialize_database) (void *cls, char **emsg);
+  enum GNUNET_GenericReturnValue
+  (*create_tables)(void *cls);
+
 
   /**
-   * Re-initializes the database.
+   * Drop existing tables.
    * DANGEROUS: All existing data in the dabase will be lost!
    *
    * @param cls closure (internal context for the plugin)
-   * @param emsg error message on failure. Will be allocated, must be freed.
    * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR
    */
-  int
-  (*reset_database) (void *cls, char **emsg);
+  enum GNUNET_GenericReturnValue
+  (*drop_tables)(void *cls);
 };
 
 
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index a0ca32fa4..b4d2b0ff2 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -7,6 +7,12 @@ pkgcfgdir= $(pkgdatadir)/config.d/
 
 libexecdir= $(pkglibdir)/libexec/
 
+sqldir = $(prefix)/share/gnunet/sql/
+
+sql_DATA = \
+  namestore-0001.sql \
+  namestore-drop.sql
+
 pkgcfg_DATA = \
    namestore.conf
 
diff --git a/src/namestore/gnunet-namestore-dbtool.c 
b/src/namestore/gnunet-namestore-dbtool.c
index a1ecf5e71..835d7a228 100644
--- a/src/namestore/gnunet-namestore-dbtool.c
+++ b/src/namestore/gnunet-namestore-dbtool.c
@@ -59,6 +59,8 @@ do_shutdown (void *cls)
   if (NULL != pluginname)
     GNUNET_free (pluginname);
 }
+
+
 /**
  * Main function that will be run.
  *
@@ -74,7 +76,6 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char *db_lib_name;
-  char *emsg;
   struct GNUNET_NAMESTORE_PluginFunctions *plugin;
 
   (void) cls;
@@ -86,7 +87,8 @@ run (void *cls,
       _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
       args[0]);
 
-  GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                 (void *) cfg);
   if (NULL == pluginname)
   {
     fprintf (stderr, "No plugin given!\n");
@@ -94,11 +96,15 @@ run (void *cls,
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", pluginname);
+  GNUNET_asprintf (&db_lib_name,
+                   "libgnunet_plugin_namestore_%s",
+                   pluginname);
   plugin = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg);
   if (NULL == plugin)
   {
-    fprintf (stderr, "Failed to load %s!\n", db_lib_name);
+    fprintf (stderr,
+             "Failed to load %s!\n",
+             db_lib_name);
     ret = 1;
     GNUNET_SCHEDULER_shutdown ();
     GNUNET_free (db_lib_name);
@@ -106,34 +112,33 @@ run (void *cls,
   }
   if (reset)
   {
-    if (GNUNET_OK != plugin->reset_database (plugin->cls, &emsg))
+    if (GNUNET_OK !=
+        plugin->drop_tables (plugin->cls))
     {
-      // FIXME do we want to return a reason?
-      fprintf (stderr, "Failed to reset database: %s\n",
-               emsg);
+      fprintf (stderr,
+               "Failed to reset database\n");
       ret = 1;
-      GNUNET_free (emsg);
       GNUNET_free (db_lib_name);
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
   }
-  else if (init)
+  if (init || reset)
   {
-    if (GNUNET_OK != plugin->initialize_database (plugin->cls, &emsg))
+    if (GNUNET_OK !=
+        plugin->create_tables (plugin->cls))
     {
-      // FIXME do we want to return a reason?
-      fprintf (stderr, "Failed to initialize database: %s\n",
-               emsg);
+      fprintf (stderr,
+               "Failed to initialize database\n");
       ret = 1;
-      GNUNET_free (emsg);
       GNUNET_free (db_lib_name);
       GNUNET_SCHEDULER_shutdown ();
       return;
     }
   }
   GNUNET_SCHEDULER_shutdown ();
-  GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, plugin));
+  GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name,
+                                              plugin));
   GNUNET_free (db_lib_name);
 }
 
@@ -148,9 +153,10 @@ run (void *cls,
 int
 main (int argc, char *const *argv)
 {
-  struct GNUNET_GETOPT_CommandLineOption options[] =
-  { GNUNET_GETOPT_option_flag ('i', "init", gettext_noop (
-                                 "initialize database"), &init),
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_option_flag ('i', "init",
+                               gettext_noop ("initialize database"),
+                               &init),
     GNUNET_GETOPT_option_flag ('r',
                                "reset",
                                gettext_noop (
@@ -163,13 +169,18 @@ main (int argc, char *const *argv)
       gettext_noop (
         "the namestore plugin to work with, e.g. 'sqlite'"),
       &pluginname),
-    GNUNET_GETOPT_OPTION_END };
+    GNUNET_GETOPT_OPTION_END
+  };
   int lret;
 
-  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+  if (GNUNET_OK !=
+      GNUNET_STRINGS_get_utf8_args (argc, argv,
+                                    &argc, &argv))
     return 2;
 
-  GNUNET_log_setup ("gnunet-namestore-dbtool", "WARNING", NULL);
+  GNUNET_log_setup ("gnunet-namestore-dbtool",
+                    "WARNING",
+                    NULL);
   if (GNUNET_OK !=
       (lret = GNUNET_PROGRAM_run (argc,
                                   argv,
diff --git a/src/namestore/namestore-0001.sql b/src/namestore/namestore-0001.sql
new file mode 100644
index 000000000..bdfb31976
--- /dev/null
+++ b/src/namestore/namestore-0001.sql
@@ -0,0 +1,48 @@
+--
+-- This file is part of GNUnet
+-- Copyright (C) 2014--2022 GNUnet e.V.
+--
+-- GNUnet is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+-- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- GNUnet; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+--
+
+-- Everything in one big transaction
+BEGIN;
+
+-- Check patch versioning is in place.
+SELECT _v.register_patch('namestore-0001', NULL, NULL);
+
+-------------------- Schema ----------------------------
+
+CREATE SCHEMA namestore;
+COMMENT ON SCHEMA namestore IS 'gnunet-namestore data';
+
+SET search_path TO namestore;
+
+CREATE TABLE ns098records (
+  seq BIGSERIAL PRIMARY KEY,
+  zone_private_key BYTEA NOT NULL DEFAULT '',
+  pkey BYTEA DEFAULT '',
+  rvalue BYTEA NOT NULL DEFAULT '',
+  record_count INTEGER NOT NULL DEFAULT 0,
+  record_data BYTEA NOT NULL DEFAULT '',
+  label TEXT NOT NULL DEFAULT '',
+  CONSTRAINT zl UNIQUE (zone_private_key,label));
+
+CREATE INDEX IF NOT EXISTS ir_pkey_reverse 
+  ON ns098records (zone_private_key,pkey);
+CREATE INDEX IF NOT EXISTS ir_pkey_iter 
+  ON ns098records (zone_private_key,seq);
+CREATE INDEX IF NOT EXISTS ir_label 
+  ON ns098records (label);
+
+
+COMMIT;
diff --git a/src/namestore/namestore-drop.sql b/src/namestore/namestore-drop.sql
new file mode 100644
index 000000000..231417af8
--- /dev/null
+++ b/src/namestore/namestore-drop.sql
@@ -0,0 +1,25 @@
+--
+-- This file is part of GNUnet
+-- Copyright (C) 2014--2022 GNUnet e.V.
+--
+-- GNUnet is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+-- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- GNUnet; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+--
+
+-- Everything in one big transaction
+BEGIN;
+
+
+SELECT _v.unregister_patch('namestore-0001');
+
+DROP SCHEMA namestore CASCADE;
+
+COMMIT;
diff --git a/src/namestore/plugin_namestore_postgres.c 
b/src/namestore/plugin_namestore_postgres.c
index d453bc977..de819f196 100644
--- a/src/namestore/plugin_namestore_postgres.c
+++ b/src/namestore/plugin_namestore_postgres.c
@@ -45,165 +45,118 @@ struct Plugin
   const struct GNUNET_CONFIGURATION_Handle *cfg;
 
   /**
-   * Database is prepared and ready
+   * Postgres database handle.
    */
-  int ready;
+  struct GNUNET_PQ_Context *dbh;
 
   /**
-   * Postgres database handle.
+   * Database is prepared and ready
    */
-  struct GNUNET_PQ_Context *dbh;
+  bool ready;
 };
 
 
 /**
- * Initialize the database connections and associated
- * data structures (create tables and indices
- * as needed as well).
+ * Initialize the database connections and associated data structures (create
+ * tables and indices as needed as well).
  *
- * @param plugin the plugin context (state for this module)
+ * @param cls the plugin context (state for this module)
  * @return #GNUNET_OK on success
  */
-static int
-init_database (struct Plugin *plugin, char **emsg, int drop)
+static enum GNUNET_GenericReturnValue
+namestore_postgres_create_tables (void *cls)
 {
-  struct GNUNET_PQ_ExecuteStatement es_temporary =
-    GNUNET_PQ_make_execute (
-      "CREATE TEMPORARY TABLE ns098records ("
-      " seq BIGSERIAL PRIMARY KEY,"
-      " zone_private_key BYTEA NOT NULL DEFAULT '',"
-      " pkey BYTEA DEFAULT '',"
-      " rvalue BYTEA NOT NULL DEFAULT '',"
-      " record_count INTEGER NOT NULL DEFAULT 0,"
-      " record_data BYTEA NOT NULL DEFAULT '',"
-      " label TEXT NOT NULL DEFAULT '',"
-      " CONSTRAINT zl UNIQUE (zone_private_key,label)"
-      ")");
-  struct GNUNET_PQ_ExecuteStatement es_default =
-    GNUNET_PQ_make_execute ("CREATE TABLE ns098records ("
-                            " seq BIGSERIAL PRIMARY KEY,"
-                            " zone_private_key BYTEA NOT NULL DEFAULT '',"
-                            " pkey BYTEA DEFAULT '',"
-                            " rvalue BYTEA NOT NULL DEFAULT '',"
-                            " record_count INTEGER NOT NULL DEFAULT 0,"
-                            " record_data BYTEA NOT NULL DEFAULT '',"
-                            " label TEXT NOT NULL DEFAULT '',"
-                            " CONSTRAINT zl UNIQUE (zone_private_key,label)"
-                            ")");
-  const struct GNUNET_PQ_ExecuteStatement *cr;
-  struct GNUNET_PQ_ExecuteStatement sc = GNUNET_PQ_EXECUTE_STATEMENT_END;
-  struct GNUNET_PQ_ExecuteStatement es_drop =
-    GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS ns098records");
-  if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
-                                            "namestore-postgres",
-                                            "TEMPORARY_TABLE"))
-    cr = &es_temporary;
-  else
-    cr = &es_default;
+  struct Plugin *plugin = cls;
+  struct GNUNET_PQ_Context *dbh;
 
-  if (GNUNET_YES ==
-      GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
-                                            "namestore-postgres",
-                                            "ASYNC_COMMIT"))
-    sc = GNUNET_PQ_make_try_execute ("SET synchronous_commit TO off");
+  dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
+                                    "namestore-postgres",
+                                    "namestore-",
+                                    NULL,
+                                    NULL);
+  if (NULL == dbh)
+    return GNUNET_SYSERR;
+  GNUNET_PQ_disconnect (dbh);
+  return GNUNET_OK;
+}
 
+
+/**
+ * Drop existing namestore tables.
+ *
+ * @param cls the plugin context (state for this module)
+ * @return #GNUNET_OK on success
+ */
+static enum GNUNET_GenericReturnValue
+namestore_postgres_drop_tables (void *cls)
+{
+  struct Plugin *plugin = cls;
+  struct GNUNET_PQ_Context *dbh;
+  enum GNUNET_GenericReturnValue ret;
+
+  dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
+                                    "namestore-postgres",
+                                    NULL,
+                                    NULL,
+                                    NULL);
+  if (NULL == dbh)
   {
-    struct GNUNET_PQ_ExecuteStatement es[] = {
-      *cr,
-      GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_reverse "
-                                  "ON ns098records (zone_private_key,pkey)"),
-      GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_iter "
-                                  "ON ns098records (zone_private_key,seq)"),
-      GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_label "
-                                  "ON ns098records (label)"),
-      GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS zone_label "
-                                  "ON ns098records (zone_private_key,label)"),
-      sc,
-      GNUNET_PQ_EXECUTE_STATEMENT_END
-    };
-    struct GNUNET_PQ_ExecuteStatement es_alt[] = {
-      es_drop,
-      *cr,
-      GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_reverse "
-                                  "ON ns098records (zone_private_key,pkey)"),
-      GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_iter "
-                                  "ON ns098records (zone_private_key,seq)"),
-      GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_label "
-                                  "ON ns098records (label)"),
-      GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS zone_label "
-                                  "ON ns098records (zone_private_key,label)"),
-      sc,
-      GNUNET_PQ_EXECUTE_STATEMENT_END
-    };
-    if (GNUNET_NO == drop)
-    {
-      plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
-                                                "namestore-postgres",
-                                                NULL,
-                                                es,
-                                                NULL);
-    }
-    else
-    {
-      plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
-                                                "namestore-postgres",
-                                                NULL,
-                                                es_alt,
-                                                NULL);
-    }
-  }
-  if (NULL == plugin->dbh)
-  {
-    *emsg = GNUNET_strdup ("Failed to connect to PQ database");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to connect to database\n");
     return GNUNET_SYSERR;
   }
-  GNUNET_PQ_disconnect (plugin->dbh);
-  plugin->dbh = NULL;
-  return GNUNET_OK;
+  ret = GNUNET_PQ_exec_sql (dbh,
+                            "namestore-drop");
+  GNUNET_PQ_disconnect (dbh);
+  return ret;
 }
 
 
-static int
+static enum GNUNET_GenericReturnValue
 database_prepare (struct Plugin *plugin)
 {
   enum GNUNET_GenericReturnValue ret;
-  if (GNUNET_YES == plugin->ready)
+
+  if (plugin->ready)
     return GNUNET_OK;
-  struct GNUNET_PQ_PreparedStatement ps[] = {
-    GNUNET_PQ_make_prepare ("store_records",
-                            "INSERT INTO ns098records"
-                            " (zone_private_key, pkey, rvalue, record_count, 
record_data, label)"
-                            " VALUES ($1, $2, $3, $4, $5, $6)"
-                            " ON CONFLICT ON CONSTRAINT zl"
-                            " DO UPDATE"
-                            "    SET 
pkey=$2,rvalue=$3,record_count=$4,record_data=$5"
-                            "    WHERE ns098records.zone_private_key = $1"
-                            "          AND ns098records.label = $6"),
-    GNUNET_PQ_make_prepare ("delete_records",
-                            "DELETE FROM ns098records "
-                            "WHERE zone_private_key=$1 AND label=$2"),
-    GNUNET_PQ_make_prepare ("zone_to_name",
-                            "SELECT seq,record_count,record_data,label FROM 
ns098records"
-                            " WHERE zone_private_key=$1 AND pkey=$2"),
-    GNUNET_PQ_make_prepare ("iterate_zone",
-                            "SELECT seq,record_count,record_data,label FROM 
ns098records "
-                            "WHERE zone_private_key=$1 AND seq > $2 ORDER BY 
seq ASC LIMIT $3"),
-    GNUNET_PQ_make_prepare ("iterate_all_zones",
-                            "SELECT 
seq,record_count,record_data,label,zone_private_key"
-                            " FROM ns098records WHERE seq > $1 ORDER BY seq 
ASC LIMIT $2"),
-    GNUNET_PQ_make_prepare ("lookup_label",
-                            "SELECT seq,record_count,record_data,label "
-                            "FROM ns098records WHERE zone_private_key=$1 AND 
label=$2"),
-    GNUNET_PQ_make_prepare ("edit_set",
-                            "SELECT seq,record_count,record_data,label "
-                            "FROM ns098records WHERE zone_private_key=$1 AND 
label=$2 FOR UPDATE NOWAIT"),
-    GNUNET_PQ_PREPARED_STATEMENT_END
-  };
-  ret = GNUNET_PQ_prepare_statements (plugin->dbh, ps);
+  {
+    struct GNUNET_PQ_PreparedStatement ps[] = {
+      GNUNET_PQ_make_prepare ("store_records",
+                              "INSERT INTO namestore.ns098records"
+                              " (zone_private_key, pkey, rvalue, record_count, 
record_data, label)"
+                              " VALUES ($1, $2, $3, $4, $5, $6)"
+                              " ON CONFLICT ON CONSTRAINT zl"
+                              " DO UPDATE"
+                              "    SET 
pkey=$2,rvalue=$3,record_count=$4,record_data=$5"
+                              "    WHERE ns098records.zone_private_key = $1"
+                              "          AND ns098records.label = $6"),
+      GNUNET_PQ_make_prepare ("delete_records",
+                              "DELETE FROM namestore.ns098records "
+                              "WHERE zone_private_key=$1 AND label=$2"),
+      GNUNET_PQ_make_prepare ("zone_to_name",
+                              "SELECT seq,record_count,record_data,label FROM 
namestore.ns098records"
+                              " WHERE zone_private_key=$1 AND pkey=$2"),
+      GNUNET_PQ_make_prepare ("iterate_zone",
+                              "SELECT seq,record_count,record_data,label FROM 
namestore.ns098records "
+                              "WHERE zone_private_key=$1 AND seq > $2 ORDER BY 
seq ASC LIMIT $3"),
+      GNUNET_PQ_make_prepare ("iterate_all_zones",
+                              "SELECT 
seq,record_count,record_data,label,zone_private_key"
+                              " FROM namestore.ns098records WHERE seq > $1 
ORDER BY seq ASC LIMIT $2"),
+      GNUNET_PQ_make_prepare ("lookup_label",
+                              "SELECT seq,record_count,record_data,label "
+                              "FROM namestore.ns098records WHERE 
zone_private_key=$1 AND label=$2"),
+      GNUNET_PQ_make_prepare ("edit_set",
+                              "SELECT seq,record_count,record_data,label "
+                              "FROM namestore.ns098records WHERE 
zone_private_key=$1 AND label=$2 FOR UPDATE NOWAIT"),
+      GNUNET_PQ_PREPARED_STATEMENT_END
+    };
+
+    ret = GNUNET_PQ_prepare_statements (plugin->dbh,
+                                        ps);
+  }
   if (GNUNET_OK != ret)
     return ret;
-  plugin->ready = GNUNET_YES;
+  plugin->ready = true;
   return GNUNET_OK;
 }
 
@@ -219,32 +172,37 @@ database_prepare (struct Plugin *plugin)
 static enum GNUNET_GenericReturnValue
 database_connect (struct Plugin *plugin)
 {
-  char *emsg;
+  struct GNUNET_PQ_ExecuteStatement ess[] = {
+    GNUNET_PQ_make_try_execute ("SET synchronous_commit TO off"),
+    GNUNET_PQ_EXECUTE_STATEMENT_END
+  };
+  struct GNUNET_PQ_ExecuteStatement *es;
+
+  if (GNUNET_YES ==
+      GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
+                                            "namestore-postgres",
+                                            "ASYNC_COMMIT"))
+    es = &ess[0];
+  else
+    es = &ess[1];
 
   if (GNUNET_YES ==
       GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
                                             "namestore-postgres",
                                             "INIT_ON_CONNECT"))
   {
-    /**
-     * Gracefully fail as this should not be a critical error if the
-     * database is already created
-     */
     if (GNUNET_OK !=
-        init_database (plugin,
-                       &emsg,
-                       GNUNET_NO))
+        namestore_postgres_create_tables (plugin))
     {
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Failed to initialize database on connect: `%s'\n",
-           emsg);
-      GNUNET_free (emsg);
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Failed to create tables\n");
+      return GNUNET_SYSERR;
     }
   }
   plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
                                             "namestore-postgres",
                                             NULL,
-                                            NULL,
+                                            es,
                                             NULL);
   if (NULL == plugin->dbh)
     return GNUNET_SYSERR;
@@ -263,7 +221,7 @@ database_connect (struct Plugin *plugin)
  * @param rd array of records with data to store
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
-static int
+static enum GNUNET_GenericReturnValue
 namestore_postgres_store_records (void *cls,
                                   const struct
                                   GNUNET_IDENTITY_PrivateKey *zone_key,
@@ -495,7 +453,7 @@ parse_result_call_iterator (void *cls,
  * @param method the method to use "lookup_record" or "edit_set"
  * @return #GNUNET_OK on success, #GNUNET_NO for no results, else 
#GNUNET_SYSERR
  */
-static int
+static enum GNUNET_GenericReturnValue
 lookup_records (void *cls,
                 const struct
                 GNUNET_IDENTITY_PrivateKey *zone,
@@ -545,7 +503,7 @@ lookup_records (void *cls,
  * @param iter_cls closure for @a iter
  * @return #GNUNET_OK on success, #GNUNET_NO for no results, else 
#GNUNET_SYSERR
  */
-static int
+static enum GNUNET_GenericReturnValue
 namestore_postgres_lookup_records (void *cls,
                                    const struct
                                    GNUNET_IDENTITY_PrivateKey *zone,
@@ -591,7 +549,7 @@ namestore_postgres_edit_records (void *cls,
  * @param iter_cls closure for @a iter
  * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, 
#GNUNET_SYSERR on error
  */
-static int
+static enum GNUNET_GenericReturnValue
 namestore_postgres_iterate_records (void *cls,
                                     const struct
                                     GNUNET_IDENTITY_PrivateKey *zone,
@@ -659,7 +617,7 @@ namestore_postgres_iterate_records (void *cls,
  * @param iter_cls closure for @a iter
  * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, 
#GNUNET_SYSERR on error
  */
-static int
+static enum GNUNET_GenericReturnValue
 namestore_postgres_zone_to_name (void *cls,
                                  const struct
                                  GNUNET_IDENTITY_PrivateKey *zone,
@@ -760,30 +718,6 @@ namestore_postgres_transaction_commit (void *cls,
 }
 
 
-static enum GNUNET_GenericReturnValue
-namestore_postgres_initialize_database (void *cls,
-                                        char **emsg)
-{
-  int ret;
-  ret = init_database (cls, emsg, GNUNET_NO);
-  if (GNUNET_SYSERR == ret)
-    return ret;
-  return database_connect (cls);
-}
-
-
-static enum GNUNET_GenericReturnValue
-namestore_postgres_reset_database (void *cls,
-                                   char **emsg)
-{
-  int ret;
-  ret = init_database (cls, emsg, GNUNET_YES);
-  if (GNUNET_SYSERR == ret)
-    return ret;
-  return database_connect (cls);
-}
-
-
 /**
  * Shutdown database connection and associate data
  * structures.
@@ -821,6 +755,8 @@ libgnunet_plugin_namestore_postgres_init (void *cls)
   }
   api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions);
   api->cls = plugin;
+  api->create_tables = &namestore_postgres_create_tables;
+  api->drop_tables = &namestore_postgres_drop_tables;
   api->store_records = &namestore_postgres_store_records;
   api->iterate_records = &namestore_postgres_iterate_records;
   api->zone_to_name = &namestore_postgres_zone_to_name;
@@ -828,8 +764,6 @@ libgnunet_plugin_namestore_postgres_init (void *cls)
   api->transaction_begin = &namestore_postgres_transaction_begin;
   api->transaction_commit = &namestore_postgres_transaction_commit;
   api->transaction_rollback = &namestore_postgres_transaction_rollback;
-  api->initialize_database = &namestore_postgres_initialize_database;
-  api->reset_database = &namestore_postgres_reset_database;
   api->edit_records = &namestore_postgres_edit_records;
   LOG (GNUNET_ERROR_TYPE_INFO,
        "Postgres namestore plugin running\n");
diff --git a/src/namestore/plugin_namestore_sqlite.c 
b/src/namestore/plugin_namestore_sqlite.c
index 1602da4ab..15a6586b5 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -50,13 +50,14 @@
  * a failure of the command 'cmd' on file 'filename'
  * with the message given by strerror(errno).
  */
-#define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, \
-                                                         "namestore-sqlite", _ 
( \
-                                                           "`%s' failed at 
%s:%d with error: %s\n"), \
-                                                         cmd, \
-                                                         __FILE__, __LINE__, \
-                                                         sqlite3_errmsg ( \
-                                                           db->dbh)); \
+#define LOG_SQLITE(db, level, cmd) do { \
+    GNUNET_log_from (level,                                             \
+                     "namestore-sqlite", _ (                            \
+                       "`%s' failed at %s:%d with error: %s\n"), \
+                     cmd,                                               \
+                     __FILE__, __LINE__,                                \
+                     sqlite3_errmsg (                                   \
+                       db->dbh));                         \
 } while (0)
 
 #define LOG(kind, ...) GNUNET_log_from (kind, "namestore-sqlite", __VA_ARGS__)
@@ -75,9 +76,9 @@ struct Plugin
   char *fn;
 
   /**
-   * Statements prepared, we are ready to go if GNUNET_YES
+   * Statements prepared, we are ready to go if true.
    */
-  int ready;
+  bool ready;
 
   /**
    * Native SQLite database handle.
@@ -124,10 +125,10 @@ struct Plugin
  * @param plugin the plugin context (state for this module)
  * @return #GNUNET_OK on success
  */
-static int
+static enum GNUNET_GenericReturnValue
 database_prepare (struct Plugin *plugin)
 {
-  if (GNUNET_YES == plugin->ready)
+  if (plugin->ready)
     return GNUNET_OK;
   struct GNUNET_SQ_ExecuteStatement es[] = {
     GNUNET_SQ_make_try_execute ("PRAGMA temp_store=MEMORY"),
@@ -264,7 +265,7 @@ database_shutdown (struct Plugin *plugin)
  * @param rd array of records with data to store
  * @return #GNUNET_OK on success, else #GNUNET_SYSERR
  */
-static int
+static enum GNUNET_GenericReturnValue
 namestore_sqlite_store_records (void *cls,
                                 const struct
                                 GNUNET_IDENTITY_PrivateKey *zone_key,
@@ -421,7 +422,7 @@ namestore_sqlite_store_records (void *cls,
  * @param iter_cls closure for @a iter
  * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, 
#GNUNET_SYSERR on error
  */
-static int
+static enum GNUNET_GenericReturnValue
 get_records_and_call_iterator (struct Plugin *plugin,
                                sqlite3_stmt *stmt,
                                const struct
@@ -539,7 +540,7 @@ get_records_and_call_iterator (struct Plugin *plugin,
  * @param iter_cls closure for @a iter
  * @return #GNUNET_OK on success, #GNUNET_NO for no results, else 
#GNUNET_SYSERR
  */
-static int
+static enum GNUNET_GenericReturnValue
 namestore_sqlite_lookup_records (void *cls,
                                  const struct
                                  GNUNET_IDENTITY_PrivateKey *zone,
@@ -591,7 +592,7 @@ namestore_sqlite_lookup_records (void *cls,
  * @param iter_cls closure for @a iter
  * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, 
#GNUNET_SYSERR on error
  */
-static int
+static enum GNUNET_GenericReturnValue
 namestore_sqlite_iterate_records (void *cls,
                                   const struct
                                   GNUNET_IDENTITY_PrivateKey *zone,
@@ -659,7 +660,7 @@ namestore_sqlite_iterate_records (void *cls,
  * @param iter_cls closure for @a iter
  * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, 
#GNUNET_SYSERR on error
  */
-static int
+static enum GNUNET_GenericReturnValue
 namestore_sqlite_zone_to_name (void *cls,
                                const struct GNUNET_IDENTITY_PrivateKey *zone,
                                const struct
@@ -697,6 +698,7 @@ namestore_sqlite_zone_to_name (void *cls,
                                         iter_cls);
 }
 
+
 /**
  * Begin a transaction for a client.
  * This locks the database. SQLite is unable to discern between different
@@ -726,6 +728,7 @@ namestore_sqlite_transaction_begin (void *cls,
   return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES;
 }
 
+
 /**
  * Commit a transaction for a client.
  * This releases the lock on the database.
@@ -753,6 +756,7 @@ namestore_sqlite_transaction_rollback (void *cls,
   return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES;
 }
 
+
 /**
  * Roll back a transaction for a client.
  * This releases the lock on the database.
@@ -780,14 +784,11 @@ namestore_sqlite_transaction_commit (void *cls,
   return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES;
 }
 
+
 static enum GNUNET_GenericReturnValue
-init_database (void *cls, char **emsg, int drop)
+namestore_sqlite_create_tables (void *cls)
 {
   struct Plugin *plugin = cls;
-  struct GNUNET_SQ_ExecuteStatement es_drop[] = {
-    GNUNET_SQ_make_execute ("DROP TABLE IF EXISTS ns098records"),
-    GNUNET_SQ_EXECUTE_STATEMENT_END
-  };
   struct GNUNET_SQ_ExecuteStatement es[] = {
     GNUNET_SQ_make_try_execute ("PRAGMA temp_store=MEMORY"),
     GNUNET_SQ_make_try_execute ("PRAGMA synchronous=NORMAL"),
@@ -797,7 +798,7 @@ init_database (void *cls, char **emsg, int drop)
     GNUNET_SQ_make_try_execute ("PRAGMA locking_mode=NORMAL"),
     GNUNET_SQ_make_try_execute ("PRAGMA journal_mode=WAL"),
     GNUNET_SQ_make_try_execute ("PRAGMA page_size=4092"),
-    GNUNET_SQ_make_execute ("CREATE TABLE ns098records ("
+    GNUNET_SQ_make_execute ("CREATE TABLE IF NOT EXISTS ns098records ("
                             " uid INTEGER PRIMARY KEY,"
                             " zone_private_key BLOB NOT NULL,"
                             " pkey BLOB,"
@@ -812,39 +813,42 @@ init_database (void *cls, char **emsg, int drop)
                                 "ON ns098records (zone_private_key,uid)"),
     GNUNET_SQ_EXECUTE_STATEMENT_END
   };
-  if ((GNUNET_YES == drop) &&
-      (GNUNET_OK != GNUNET_SQ_exec_statements (plugin->dbh,
-                                               es_drop)))
-  {
-    GNUNET_asprintf (emsg,
-                     _ ("Failed to drop database with: `%s'\n"),
-                     sqlite3_errmsg (plugin->dbh));
-    return GNUNET_SYSERR;
-  }
+
   if (GNUNET_OK !=
       GNUNET_SQ_exec_statements (plugin->dbh,
                                  es))
   {
-    GNUNET_asprintf (emsg,
-                     _ ("Failed to setup database with: `%s'\n"),
-                     sqlite3_errmsg (plugin->dbh));
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to setup database with: `%s'\n",
+                sqlite3_errmsg (plugin->dbh));
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
 }
 
-enum GNUNET_GenericReturnValue
-namestore_sqlite_initialize_database (void *cls, char **emsg)
-{
-  return init_database (cls, emsg, GNUNET_NO);
-}
 
-enum GNUNET_GenericReturnValue
-namestore_sqlite_reset_database (void *cls, char **emsg)
+static enum GNUNET_GenericReturnValue
+namestore_sqlite_drop_tables (void *cls)
 {
-  return init_database (cls, emsg, GNUNET_YES);
+  struct Plugin *plugin = cls;
+  struct GNUNET_SQ_ExecuteStatement es_drop[] = {
+    GNUNET_SQ_make_execute ("DROP TABLE IF EXISTS ns098records"),
+    GNUNET_SQ_EXECUTE_STATEMENT_END
+  };
+
+  if (GNUNET_OK !=
+      GNUNET_SQ_exec_statements (plugin->dbh,
+                                 es_drop))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to drop database with: `%s'\n",
+                sqlite3_errmsg (plugin->dbh));
+    return GNUNET_SYSERR;
+  }
+  return GNUNET_OK;
 }
 
+
 /**
  * Initialize the database connections and associated
  * data structures (create tables and indices
@@ -853,11 +857,10 @@ namestore_sqlite_reset_database (void *cls, char **emsg)
  * @param plugin the plugin context (state for this module)
  * @return #GNUNET_OK on success
  */
-static int
+static enum GNUNET_GenericReturnValue
 database_connect (struct Plugin *plugin)
 {
   char *sqlite_filename;
-  char *emsg;
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_filename (plugin->cfg,
@@ -902,17 +905,9 @@ database_connect (struct Plugin *plugin)
                                             "namestore-sqlite",
                                             "INIT_ON_CONNECT"))
   {
-    /**
-     * Gracefully fail as this should not be a critical error if the
-     * database is already created
-     */
-    if (GNUNET_OK != init_database (plugin, &emsg, GNUNET_NO))
-    {
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Failed to initialize database on connect: `%s'\n",
-           emsg);
-      GNUNET_free (emsg);
-    }
+    if (GNUNET_OK !=
+        namestore_sqlite_create_tables (plugin))
+      return GNUNET_SYSERR;
   }
   return GNUNET_OK;
 }
@@ -949,8 +944,8 @@ libgnunet_plugin_namestore_sqlite_init (void *cls)
   api->transaction_begin = &namestore_sqlite_transaction_begin;
   api->transaction_commit = &namestore_sqlite_transaction_commit;
   api->transaction_rollback = &namestore_sqlite_transaction_rollback;
-  api->initialize_database = &namestore_sqlite_initialize_database;
-  api->reset_database = &namestore_sqlite_reset_database;
+  api->create_tables = &namestore_sqlite_create_tables;
+  api->drop_tables = &namestore_sqlite_drop_tables;
   /**
    * NOTE: Since SQlite does not support SELECT ... FOR UPDATE this is
    * just an alias to lookup_records. The BEGIN IMMEDIATE mechanic currently
diff --git a/src/namestore/test_common.c b/src/namestore/test_common.c
index fbcb51399..4f3a3562b 100644
--- a/src/namestore/test_common.c
+++ b/src/namestore/test_common.c
@@ -31,35 +31,52 @@ TNC_test_plugin (const char *cfg_name)
 {
   char *database;
   char *db_lib_name;
-  char *emsg;
   struct GNUNET_NAMESTORE_PluginFunctions *db;
   struct GNUNET_CONFIGURATION_Handle *cfg;
 
   cfg = GNUNET_CONFIGURATION_create ();
-  if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_name))
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_load (cfg,
+                                 cfg_name))
   {
     GNUNET_break (0);
     GNUNET_CONFIGURATION_destroy (cfg);
     return GNUNET_SYSERR;
   }
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
-                                                          "namestore",
-                                                          "database",
-                                                          &database))
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "namestore",
+                                             "database",
+                                             &database))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "No database backend configured\n");
     GNUNET_CONFIGURATION_destroy (cfg);
     return GNUNET_SYSERR;
   }
-  GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", database);
+  GNUNET_asprintf (&db_lib_name,
+                   "libgnunet_plugin_namestore_%s",
+                   database);
   GNUNET_free (database);
   db = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg);
-  if (NULL != db)
+  if (NULL == db)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to load plugin `%s'\n",
+                db_lib_name);
+  }
+  else
   {
-    if (GNUNET_OK != db->reset_database (db->cls, &emsg))
+    if (GNUNET_OK != db->create_tables (db->cls))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error resetting database: %s\n", 
emsg);
-      GNUNET_free (emsg);
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Error creating tables\n");
+      return GNUNET_SYSERR;
+    }
+    if (GNUNET_OK != db->drop_tables (db->cls))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Error dropping tables\n");
       return GNUNET_SYSERR;
     }
     GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db));
@@ -71,13 +88,15 @@ TNC_test_plugin (const char *cfg_name)
   return GNUNET_YES;
 }
 
+
 /**
  * General setup logic for starting the tests.  Obtains the @a
  * plugin_name and initializes the @a cfg_name.
  */
-#define SETUP_CFG2(file_template, plugin_name, cfg_name)                       
             \
+#define SETUP_CFG2(file_template, plugin_name, cfg_name)                    \
   do                                                                        \
   {                                                                         \
+    GNUNET_log_setup (__FILE__, "WARNING", NULL);                           \
     plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]);    \
     GNUNET_asprintf (&cfg_name, file_template, plugin_name); \
     if (! TNC_test_plugin (cfg_name))                                       \
@@ -94,6 +113,7 @@ TNC_test_plugin (const char *cfg_name)
 #define SETUP_CFG(plugin_name, cfg_name)                                    \
   do                                                                        \
   {                                                                         \
+    GNUNET_log_setup (__FILE__, "WARNING", NULL);                           \
     plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]);    \
     GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \
     if (! TNC_test_plugin (cfg_name))                                       \
diff --git a/src/namestore/test_plugin_namestore.c 
b/src/namestore/test_plugin_namestore.c
index e35542ff0..24af148bf 100644
--- a/src/namestore/test_plugin_namestore.c
+++ b/src/namestore/test_plugin_namestore.c
@@ -66,23 +66,30 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_NAMESTORE_PluginFunctions *ret;
   char *libname;
-  char *emsg;
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _ ("Loading `%s' namestore plugin\n"),
+              "Loading `%s' namestore plugin\n",
               plugin_name);
-  GNUNET_asprintf (&libname, "libgnunet_plugin_namestore_%s", plugin_name);
+  GNUNET_asprintf (&libname,
+                   "libgnunet_plugin_namestore_%s",
+                   plugin_name);
   if (NULL == (ret = GNUNET_PLUGIN_load (libname, (void *) cfg)))
   {
-    fprintf (stderr, "Failed to load plugin `%s'!\n", plugin_name);
+    fprintf (stderr,
+             "Failed to load plugin `%s'!\n",
+             plugin_name);
     GNUNET_free (libname);
     return NULL;
   }
   GNUNET_free (libname);
-  if (GNUNET_OK != ret->reset_database (ret->cls, &emsg))
+  if (GNUNET_OK != ret->drop_tables (ret->cls))
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
+  if (GNUNET_OK != ret->create_tables (ret->cls))
   {
-    fprintf (stderr, "Error resetting database: %s\n", emsg);
-    GNUNET_free (emsg);
+    GNUNET_break (0);
     return NULL;
   }
   return ret;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]