aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2016-10-13 00:29:45 +0000
committerDaniel Golle <daniel@makrotopia.org>2016-10-13 00:29:45 +0000
commit331e5f39acc40be5037771f860a32052b09448fd (patch)
treecbee48c947c0691e45b3310be73db7548b3d4416 /src/datastore
parent505c2e0638d66e48a44bb52bfd5127f59b8d6353 (diff)
downloadgnunet-331e5f39acc40be5037771f860a32052b09448fd.tar.gz
gnunet-331e5f39acc40be5037771f860a32052b09448fd.zip
datastore: postgres: use IF NOT EXISTS to avoid error messages
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/plugin_datastore_postgres.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c
index 332a8688b..994118bfa 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -78,8 +78,8 @@ init_connection (struct Plugin *plugin)
78 78
79 ret = 79 ret =
80 PQexec (plugin->dbh, 80 PQexec (plugin->dbh,
81 "CREATE TABLE gn090 (" 81 "CREATE TABLE IF NOT EXISTS gn090 ("
82 " repl INTEGER NOT NULL DEFAULT 0," 82 " repl INTEGER NOT NULL DEFAULT 0,"
83 " type INTEGER NOT NULL DEFAULT 0," 83 " type INTEGER NOT NULL DEFAULT 0,"
84 " prio INTEGER NOT NULL DEFAULT 0," 84 " prio INTEGER NOT NULL DEFAULT 0,"
85 " anonLevel INTEGER NOT NULL DEFAULT 0," 85 " anonLevel INTEGER NOT NULL DEFAULT 0,"
@@ -88,7 +88,7 @@ init_connection (struct Plugin *plugin)
88 " hash BYTEA NOT NULL DEFAULT ''," 88 " hash BYTEA NOT NULL DEFAULT '',"
89 " vhash BYTEA NOT NULL DEFAULT ''," 89 " vhash BYTEA NOT NULL DEFAULT '',"
90 " value BYTEA NOT NULL DEFAULT '')" 90 " value BYTEA NOT NULL DEFAULT '')"
91 "WITH OIDS"); 91 "WITH OIDS");
92 if ( (NULL == ret) || 92 if ( (NULL == ret) ||
93 ((PQresultStatus (ret) != PGRES_COMMAND_OK) && 93 ((PQresultStatus (ret) != PGRES_COMMAND_OK) &&
94 (0 != strcmp ("42P07", /* duplicate table */ 94 (0 != strcmp ("42P07", /* duplicate table */
@@ -109,23 +109,23 @@ init_connection (struct Plugin *plugin)
109 if (PQresultStatus (ret) == PGRES_COMMAND_OK) 109 if (PQresultStatus (ret) == PGRES_COMMAND_OK)
110 { 110 {
111 if ((GNUNET_OK != 111 if ((GNUNET_OK !=
112 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX idx_hash ON gn090 (hash)")) || 112 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX IF NOT EXISTS idx_hash ON gn090 (hash)")) ||
113 (GNUNET_OK != 113 (GNUNET_OK !=
114 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX idx_hash_vhash ON gn090 (hash,vhash)")) || 114 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX IF NOT EXISTS idx_hash_vhash ON gn090 (hash,vhash)")) ||
115 (GNUNET_OK != 115 (GNUNET_OK !=
116 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX idx_prio ON gn090 (prio)")) || 116 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX IF NOT EXISTS idx_prio ON gn090 (prio)")) ||
117 (GNUNET_OK != 117 (GNUNET_OK !=
118 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX idx_expire ON gn090 (expire)")) || 118 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX IF NOT EXISTS idx_expire ON gn090 (expire)")) ||
119 (GNUNET_OK != 119 (GNUNET_OK !=
120 GNUNET_POSTGRES_exec (plugin->dbh, 120 GNUNET_POSTGRES_exec (plugin->dbh,
121 "CREATE INDEX idx_prio_anon ON gn090 (prio,anonLevel)")) || 121 "CREATE INDEX IF NOT EXISTS idx_prio_anon ON gn090 (prio,anonLevel)")) ||
122 (GNUNET_OK != 122 (GNUNET_OK !=
123 GNUNET_POSTGRES_exec (plugin->dbh, 123 GNUNET_POSTGRES_exec (plugin->dbh,
124 "CREATE INDEX idx_prio_hash_anon ON gn090 (prio,hash,anonLevel)")) || 124 "CREATE INDEX IF NOT EXISTS idx_prio_hash_anon ON gn090 (prio,hash,anonLevel)")) ||
125 (GNUNET_OK != 125 (GNUNET_OK !=
126 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX idx_repl_rvalue ON gn090 (repl,rvalue)")) || 126 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX IF NOT EXISTS idx_repl_rvalue ON gn090 (repl,rvalue)")) ||
127 (GNUNET_OK != 127 (GNUNET_OK !=
128 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX idx_expire_hash ON gn090 (expire,hash)"))) 128 GNUNET_POSTGRES_exec (plugin->dbh, "CREATE INDEX IF NOT EXISTS idx_expire_hash ON gn090 (expire,hash)")))
129 { 129 {
130 PQclear (ret); 130 PQclear (ret);
131 PQfinish (plugin->dbh); 131 PQfinish (plugin->dbh);