aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/plugin_datacache_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
commit9fac6b6eefdc9144053f736fd388cb2199a97046 (patch)
tree82740a981b7f6ae973d915aa77797acd9db668b2 /src/datacache/plugin_datacache_postgres.c
parent23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff)
downloadgnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.tar.gz
gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.zip
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/datacache/plugin_datacache_postgres.c')
-rw-r--r--src/datacache/plugin_datacache_postgres.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index cd4286b92..b40f1fd04 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -29,7 +29,7 @@
29#include "gnunet_datacache_plugin.h" 29#include "gnunet_datacache_plugin.h"
30#include <postgresql/libpq-fe.h> 30#include <postgresql/libpq-fe.h>
31 31
32#define DEBUG_POSTGRES GNUNET_EXTRA_LOGGING 32#define LOG(kind,...) GNUNET_log_from (kind, "datacache-postgres", __VA_ARGS__)
33 33
34/** 34/**
35 * Per-entry overhead estimate 35 * Per-entry overhead estimate
@@ -236,20 +236,16 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
236 GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", 236 GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared",
237 (type == 0) ? "getk" : "getkt")) 237 (type == 0) ? "getk" : "getkt"))
238 { 238 {
239#if DEBUG_POSTGRES 239 LOG (GNUNET_ERROR_TYPE_DEBUG,
240 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 240 "Ending iteration (postgres error)\n");
241 "Ending iteration (postgres error)\n");
242#endif
243 return 0; 241 return 0;
244 } 242 }
245 243
246 if (0 == (cnt = PQntuples (res))) 244 if (0 == (cnt = PQntuples (res)))
247 { 245 {
248 /* no result */ 246 /* no result */
249#if DEBUG_POSTGRES 247 LOG (GNUNET_ERROR_TYPE_DEBUG,
250 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 248 "Ending iteration (no more results)\n");
251 "Ending iteration (no more results)\n");
252#endif
253 PQclear (res); 249 PQclear (res);
254 return 0; 250 return 0;
255 } 251 }
@@ -271,19 +267,15 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
271 GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, i, 0)); 267 GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, i, 0));
272 type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1)); 268 type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1));
273 size = PQgetlength (res, i, 2); 269 size = PQgetlength (res, i, 2);
274#if DEBUG_POSTGRES 270 LOG (GNUNET_ERROR_TYPE_DEBUG,
275 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 271 "Found result of size %u bytes and type %u in database\n",
276 "Found result of size %u bytes and type %u in database\n", 272 (unsigned int) size, (unsigned int) type);
277 (unsigned int) size, (unsigned int) type);
278#endif
279 if (GNUNET_SYSERR == 273 if (GNUNET_SYSERR ==
280 iter (iter_cls, expiration_time, key, size, PQgetvalue (res, i, 2), 274 iter (iter_cls, expiration_time, key, size, PQgetvalue (res, i, 2),
281 (enum GNUNET_BLOCK_Type) type)) 275 (enum GNUNET_BLOCK_Type) type))
282 { 276 {
283#if DEBUG_POSTGRES 277 LOG (GNUNET_ERROR_TYPE_DEBUG,
284 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 278 "Ending iteration (client error)\n");
285 "Ending iteration (client error)\n");
286#endif
287 PQclear (res); 279 PQclear (res);
288 return cnt; 280 return cnt;
289 } 281 }
@@ -313,19 +305,15 @@ postgres_plugin_del (void *cls)
313 if (GNUNET_OK != 305 if (GNUNET_OK !=
314 GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", "getm")) 306 GNUNET_POSTGRES_check_result (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", "getm"))
315 { 307 {
316#if DEBUG_POSTGRES 308 LOG (GNUNET_ERROR_TYPE_DEBUG,
317 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 309 "Ending iteration (postgres error)\n");
318 "Ending iteration (postgres error)\n");
319#endif
320 return 0; 310 return 0;
321 } 311 }
322 if (0 == PQntuples (res)) 312 if (0 == PQntuples (res))
323 { 313 {
324 /* no result */ 314 /* no result */
325#if DEBUG_POSTGRES 315 LOG (GNUNET_ERROR_TYPE_DEBUG,
326 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", 316 "Ending iteration (no more results)\n");
327 "Ending iteration (no more results)\n");
328#endif
329 PQclear (res); 317 PQclear (res);
330 return GNUNET_SYSERR; 318 return GNUNET_SYSERR;
331 } 319 }
@@ -375,8 +363,8 @@ libgnunet_plugin_datacache_postgres_init (void *cls)
375 api->get = &postgres_plugin_get; 363 api->get = &postgres_plugin_get;
376 api->put = &postgres_plugin_put; 364 api->put = &postgres_plugin_put;
377 api->del = &postgres_plugin_del; 365 api->del = &postgres_plugin_del;
378 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datacache-postgres", 366 LOG (GNUNET_ERROR_TYPE_INFO,
379 _("Postgres datacache running\n")); 367 _("Postgres datacache running\n"));
380 return api; 368 return api;
381} 369}
382 370