#include "gnunet_util_lib.h"
#include "gnunet_mysql_lib.h"
-#define DEBUG_MYSQL GNUNET_EXTRA_LOGGING
#define MAX_DATUM_SIZE 65536
{
int ret;
-#if DEBUG_MYSQL
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting value %llu from gn090 table\n",
uid);
-#endif
ret = GNUNET_MYSQL_statement_run_prepared (plugin->mc,
plugin->delete_entry_by_uid, NULL,
MYSQL_TYPE_LONGLONG, &uid, GNUNET_YES, -1);
MYSQL_TYPE_BLOB, &vhash, hashSize2, &hashSize2,
MYSQL_TYPE_BLOB, data, lsize, &lsize, -1))
return GNUNET_SYSERR;
-#if DEBUG_MYSQL
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Inserted value `%s' with size %u into gn090 table\n",
GNUNET_h2s (key), (unsigned int) size);
-#endif
if (size > 0)
plugin->env->duc (plugin->env->cls, size);
return GNUNET_OK;
unsigned long long lexpire = expire.abs_value;
int ret;
-#if DEBUG_MYSQL
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Updating value %llu adding %d to priority and maxing exp at %llu\n",
vkey, delta, lexpire);
-#endif
ret =
GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_entry, NULL,
MYSQL_TYPE_LONG, &delta, GNUNET_NO,
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
-#if DEBUG_MYSQL
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found %u-byte value under key `%s' with prio %u, anon %u, expire %llu selecting from gn090 table\n",
(unsigned int) size, GNUNET_h2s (&key), priority, anonymity, exp);
-#endif
GNUNET_assert (size < MAX_DATUM_SIZE);
expiration.abs_value = exp;
ret =
}
offset = offset % total;
off = (unsigned long long) offset;
-#if DEBUG_MYSQL
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Obtaining %llu/%lld result for GET `%s'\n", off, total,
GNUNET_h2s (key));
-#endif
-
if (type != GNUNET_BLOCK_TYPE_ANY)
{
if (NULL != vhash)
#include "gnunet_postgres_lib.h"
#include <postgresql/libpq-fe.h>
-#define DEBUG_POSTGRES GNUNET_EXTRA_LOGGING
/**
* After how many ms "busy" should a DB operation fail for good?
return GNUNET_SYSERR;
PQclear (ret);
plugin->env->duc (plugin->env->cls, size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
-#if DEBUG_POSTGRES
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres",
"Stored %u bytes in database\n", (unsigned int) size);
-#endif
return GNUNET_OK;
}
GNUNET_POSTGRES_check_result_ (plugin->dbh, res, PGRES_TUPLES_OK, "PQexecPrepared", "select",
filename, line))
{
-#if DEBUG_POSTGRES
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres",
"Ending iteration (postgres error)\n");
-#endif
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
if (0 == PQntuples (res))
{
/* no result */
-#if DEBUG_POSTGRES
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres",
"Ending iteration (no more results)\n");
-#endif
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
PQclear (res);
return;
GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, 0, 3));
memcpy (&key, PQgetvalue (res, 0, 4), sizeof (GNUNET_HashCode));
size = PQgetlength (res, 0, 5);
-#if DEBUG_POSTGRES
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres",
"Found result of size %u bytes and type %u in database\n",
(unsigned int) size, (unsigned int) type);
-#endif
iret =
proc (proc_cls, &key, size, PQgetvalue (res, 0, 5),
(enum GNUNET_BLOCK_Type) type, priority, anonymity, expiration_time,
PQclear (res);
if (iret == GNUNET_NO)
{
-#if DEBUG_POSTGRES
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processor asked for item %u to be removed.\n", rowid);
-#endif
if (GNUNET_OK == GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, "delrow", rowid))
{
-#if DEBUG_POSTGRES
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres",
"Deleting %u bytes from database\n",
(unsigned int) size);
-#endif
plugin->env->duc (plugin->env->cls,
-(size + GNUNET_DATASTORE_ENTRY_OVERHEAD));
-#if DEBUG_POSTGRES
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres",
"Deleted %u bytes from database\n", (unsigned int) size);
-#endif
}
}
}
#include "gnunet_datastore_plugin.h"
#include <sqlite3.h>
-/**
- * Enable or disable logging debug messages.
- */
-#define DEBUG_SQLITE GNUNET_EXTRA_LOGGING
/**
* We allocate items on the stack at times. To prevent a stack
result =
sqlite3_prepare_v2 (dbh, zSql, strlen (zSql), ppStmt,
(const char **) &dummy);
-#if DEBUG_SQLITE && 0
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Prepared `%s' / %p: %d\n", zSql, *ppStmt, result);
-#endif
return result;
}
stmt = sqlite3_next_stmt (plugin->dbh, NULL);
while (stmt != NULL)
{
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Closing statement %p\n", stmt);
-#endif
result = sqlite3_finalize (stmt);
if (result != SQLITE_OK)
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "sqlite",
if (size > MAX_ITEM_SIZE)
return GNUNET_SYSERR;
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Storing in database block with type %u/key `%s'/priority %u/expiration in %llu ms (%lld).\n",
type, GNUNET_h2s (key), priority,
(unsigned long long)
GNUNET_TIME_absolute_get_remaining (expiration).rel_value,
(long long) expiration.abs_value);
-#endif
GNUNET_CRYPTO_hash (data, size, &vhash);
stmt = plugin->insertContent;
rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
{
case SQLITE_DONE:
plugin->env->duc (plugin->env->cls, size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Stored new entry (%u bytes)\n",
size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
-#endif
ret = GNUNET_OK;
break;
case SQLITE_BUSY:
switch (n)
{
case SQLITE_DONE:
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Block updated\n");
-#endif
return GNUNET_OK;
case SQLITE_BUSY:
LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
break;
}
expiration.abs_value = sqlite3_column_int64 (stmt, 3);
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Found reply in database with expiration %llu\n",
(unsigned long long) expiration.abs_value);
-#endif
ret = proc (proc_cls, sqlite3_column_blob (stmt, 4) /* key */ ,
size, sqlite3_column_blob (stmt, 5) /* data */ ,
sqlite3_column_int (stmt, 0) /* type */ ,
uint32_t repl;
sqlite3_stmt *stmt;
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Getting random block based on replication order.\n");
-#endif
rc.have_uid = GNUNET_NO;
rc.proc = proc;
rc.proc_cls = proc_cls;
sqlite3_stmt *stmt;
struct GNUNET_TIME_Absolute now;
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Getting random block based on expiration and priority order.\n");
-#endif
now = GNUNET_TIME_absolute_get ();
stmt = plugin->selExpi;
if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value))
struct GNUNET_DATASTORE_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"sqlite plugin is done\n");
-#endif
-
fn = NULL;
if (plugin->drop_on_shutdown)
fn = GNUNET_strdup (plugin->fn);
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"Shutting down database\n");
-#endif
database_shutdown (plugin);
plugin->env = NULL;
GNUNET_free (api);
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
GNUNET_free (fn);
}
-#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite",
"sqlite plugin is finished\n");
-#endif
return NULL;
}