[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 02/05: enforce query is primary key
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 02/05: enforce query is primary key |
Date: |
Thu, 08 Mar 2018 16:43:09 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit b52546aa5836a260fa9fca2edb5287d48cc44a2f
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Mar 8 16:27:21 2018 +0100
enforce query is primary key
---
src/namecache/plugin_namecache_sqlite.c | 46 ++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/src/namecache/plugin_namecache_sqlite.c
b/src/namecache/plugin_namecache_sqlite.c
index 2f7b2a981..669729f37 100644
--- a/src/namecache/plugin_namecache_sqlite.c
+++ b/src/namecache/plugin_namecache_sqlite.c
@@ -23,7 +23,6 @@
* @brief sqlite-based namecache backend
* @author Christian Grothoff
*/
-
#include "platform.h"
#include "gnunet_sq_lib.h"
#include "gnunet_namecache_plugin.h"
@@ -106,16 +105,23 @@ struct Plugin
* @return 0 on success
*/
static int
-sq_prepare (sqlite3 * dbh, const char *zSql, sqlite3_stmt ** ppStmt)
+sq_prepare (sqlite3 *dbh,
+ const char *zSql,
+ sqlite3_stmt **ppStmt)
{
char *dummy;
int result;
- result =
- sqlite3_prepare_v2 (dbh, zSql, strlen (zSql), ppStmt,
- (const char **) &dummy);
+ result = sqlite3_prepare_v2 (dbh,
+ zSql,
+ strlen (zSql),
+ ppStmt,
+ (const char **) &dummy);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Prepared `%s' / %p: %d\n", zSql, *ppStmt, result);
+ "Prepared `%s' / %p: %d\n",
+ zSql,
+ *ppStmt,
+ result);
return result;
}
@@ -168,16 +174,21 @@ database_setup (struct Plugin *plugin)
#endif
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, "namecache-sqlite",
- "FILENAME", &afsdir))
+ GNUNET_CONFIGURATION_get_value_filename (plugin->cfg,
+ "namecache-sqlite",
+ "FILENAME",
+ &afsdir))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "namecache-sqlite", "FILENAME");
+ "namecache-sqlite",
+ "FILENAME");
return GNUNET_SYSERR;
}
- if (GNUNET_OK != GNUNET_DISK_file_test (afsdir))
+ if (GNUNET_OK !=
+ GNUNET_DISK_file_test (afsdir))
{
- if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (afsdir))
+ if (GNUNET_OK !=
+ GNUNET_DISK_directory_create_for_file (afsdir))
{
GNUNET_break (0);
GNUNET_free (afsdir);
@@ -188,7 +199,8 @@ database_setup (struct Plugin *plugin)
plugin->fn = afsdir;
/* Open database and precompile statements */
- if (sqlite3_open (plugin->fn, &plugin->dbh) != SQLITE_OK)
+ if (SQLITE_OK !=
+ sqlite3_open (plugin->fn, &plugin->dbh))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Unable to initialize SQLite: %s.\n"),
@@ -229,9 +241,9 @@ database_setup (struct Plugin *plugin)
(sqlite3_exec
(plugin->dbh,
"CREATE TABLE ns096blocks ("
- " query BLOB NOT NULL DEFAULT '',"
- " block BLOB NOT NULL DEFAULT '',"
- " expiration_time INT8 NOT NULL DEFAULT 0"
+ " query BLOB NOT NULL PRIMARY KEY,"
+ " block BLOB NOT NULL,"
+ " expiration_time INT8 NOT NULL"
")",
NULL, NULL, NULL) != SQLITE_OK))
{
@@ -399,6 +411,10 @@ namecache_sqlite_cache_block (void *cls,
GNUNET_CRYPTO_hash (&block->derived_key,
sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
&query);
+ fprintf (stderr,
+ "Caching new version of block %s (expires %llu)\n",
+ GNUNET_h2s (&query),
+ (unsigned long long) expiration.abs_value_us);
expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time);
if (block_size > 64 * 65536)
{
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (800d91ce4 -> da76b1b40), gnunet, 2018/03/08
- [GNUnet-SVN] [gnunet] 03/05: enable cache use by default, gnunet, 2018/03/08
- [GNUnet-SVN] [gnunet] 02/05: enforce query is primary key,
gnunet <=
- [GNUnet-SVN] [gnunet] 01/05: fix off-by-one in BOX type processing, gnunet, 2018/03/08
- [GNUnet-SVN] [gnunet] 04/05: avoid specifying useless DEFAULT values, gnunet, 2018/03/08
- [GNUnet-SVN] [gnunet] 05/05: SSL->TLS / X.509 in log messages and comments, remove unnecessary check, gnunet, 2018/03/08