aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/plugin_datastore_sqlite.c
diff options
context:
space:
mode:
authorgrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2011-06-10 15:39:28 +0000
committergrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2011-06-10 15:39:28 +0000
commitb12dc78cbe078f720290520c3e8ea52f0932112b (patch)
treee7f65e618e3ea4700af1e212b802e484216b8d9c /src/datastore/plugin_datastore_sqlite.c
parentf78bdabf3c0151b72130cf9de65b3f1a5562f891 (diff)
fixing datastore schema for future change for improved performance
git-svn-id: https://gnunet.org/svn/gnunet@15550 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/datastore/plugin_datastore_sqlite.c')
-rw-r--r--src/datastore/plugin_datastore_sqlite.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 3267869d5d..613b6a1a76 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -178,7 +178,7 @@ create_indices (sqlite3 * dbh)
NULL, NULL, NULL);
sqlite3_exec (dbh, "CREATE INDEX idx_expire ON gn090 (expire)",
NULL, NULL, NULL);
- sqlite3_exec (dbh, "CREATE INDEX idx_repl ON gn090 (repl)",
+ sqlite3_exec (dbh, "CREATE INDEX idx_repl_rvalue ON gn090 (repl,rvalue)",
NULL, NULL, NULL);
}
@@ -292,6 +292,7 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
" prio INT4 NOT NULL DEFAULT 0,"
" anonLevel INT4 NOT NULL DEFAULT 0,"
" expire INT8 NOT NULL DEFAULT 0,"
+ " rvalue INT8 NOT NULL,"
" hash TEXT NOT NULL DEFAULT '',"
" vhash TEXT NOT NULL DEFAULT '',"
" value BLOB NOT NULL DEFAULT '')", NULL, NULL,
@@ -328,8 +329,8 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
&plugin->selZeroAnon) != SQLITE_OK) ||
(sq_prepare (plugin->dbh,
"INSERT INTO gn090 (repl, type, prio, "
- "anonLevel, expire, hash, vhash, value) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
+ "anonLevel, expire, rvalue, hash, vhash, value) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
&plugin->insertContent) != SQLITE_OK) ||
(sq_prepare (plugin->dbh,
"DELETE FROM gn090 WHERE _ROWID_ = ?",
@@ -469,6 +470,7 @@ sqlite_plugin_put (void *cls,
int ret;
sqlite3_stmt *stmt;
GNUNET_HashCode vhash;
+ uint64_t rvalue;
if (size > MAX_ITEM_SIZE)
return GNUNET_SYSERR;
@@ -484,19 +486,21 @@ sqlite_plugin_put (void *cls,
#endif
GNUNET_CRYPTO_hash (data, size, &vhash);
stmt = plugin->insertContent;
+ rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, replication)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 3, priority)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 4, anonymity)) ||
(SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expiration.abs_value)) ||
+ (SQLITE_OK != sqlite3_bind_int64 (stmt, 6, rvalue)) ||
(SQLITE_OK !=
- sqlite3_bind_blob (stmt, 6, key, sizeof (GNUNET_HashCode),
+ sqlite3_bind_blob (stmt, 7, key, sizeof (GNUNET_HashCode),
SQLITE_TRANSIENT)) ||
(SQLITE_OK !=
- sqlite3_bind_blob (stmt, 7, &vhash, sizeof (GNUNET_HashCode),
+ sqlite3_bind_blob (stmt, 8, &vhash, sizeof (GNUNET_HashCode),
SQLITE_TRANSIENT))
|| (SQLITE_OK !=
- sqlite3_bind_blob (stmt, 8, data, size,
+ sqlite3_bind_blob (stmt, 9, data, size,
SQLITE_TRANSIENT)))
{
LOG_SQLITE (plugin,