namestore: postgres: use IF NOT EXISTS to avoid error messages
authorDaniel Golle <daniel@makrotopia.org>
Thu, 13 Oct 2016 00:29:39 +0000 (00:29 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 13 Oct 2016 00:29:39 +0000 (00:29 +0000)
src/namestore/plugin_namestore_postgres.c

index 8ea6b43ad4682de903d5ec5a9b2dcd9f843870fa..01dbf9e61e5b3d7bbdc6b401f3456b3a8efba45a 100644 (file)
@@ -85,14 +85,14 @@ create_indices (PGconn * dbh)
   /* create indices */
   if ( (GNUNET_OK !=
        GNUNET_POSTGRES_exec (dbh,
-                              "CREATE INDEX ir_pkey_reverse ON ns097records (zone_private_key,pkey)")) ||
+                              "CREATE INDEX IF NOT EXISTS ir_pkey_reverse ON ns097records (zone_private_key,pkey)")) ||
        (GNUNET_OK !=
        GNUNET_POSTGRES_exec (dbh,
-                              "CREATE INDEX ir_pkey_iter ON ns097records (zone_private_key,rvalue)")) ||
+                              "CREATE INDEX IF NOT EXISTS ir_pkey_iter ON ns097records (zone_private_key,rvalue)")) ||
        (GNUNET_OK !=
-       GNUNET_POSTGRES_exec (dbh, "CREATE INDEX it_iter ON ns097records (rvalue)")) ||
+       GNUNET_POSTGRES_exec (dbh, "CREATE INDEX IF NOT EXISTS it_iter ON ns097records (rvalue)")) ||
        (GNUNET_OK !=
-        GNUNET_POSTGRES_exec (dbh, "CREATE INDEX ir_label ON ns097records (label)")) )
+        GNUNET_POSTGRES_exec (dbh, "CREATE INDEX IF NOT EXISTS ir_label ON ns097records (label)")) )
     LOG (GNUNET_ERROR_TYPE_ERROR,
         _("Failed to create indices\n"));
 }
@@ -122,7 +122,7 @@ database_setup (struct Plugin *plugin)
   {
     res =
       PQexec (plugin->dbh,
-              "CREATE TEMPORARY TABLE ns097records ("
+              "CREATE TEMPORARY TABLE IF NOT EXISTS ns097records ("
              " zone_private_key BYTEA NOT NULL DEFAULT '',"
              " pkey BYTEA DEFAULT '',"
              " rvalue BYTEA NOT NULL DEFAULT '',"
@@ -135,7 +135,7 @@ database_setup (struct Plugin *plugin)
   {
     res =
       PQexec (plugin->dbh,
-              "CREATE TABLE ns097records ("
+              "CREATE TABLE IF NOT EXISTS ns097records ("
              " zone_private_key BYTEA NOT NULL DEFAULT '',"
              " pkey BYTEA DEFAULT '',"
              " rvalue BYTEA NOT NULL DEFAULT '',"