aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-12-16 22:42:54 +0000
committerChristian Grothoff <christian@grothoff.org>2011-12-16 22:42:54 +0000
commitfe028c46f5b2bcf7f14ef1d587c8b54bf7d1343a (patch)
treee7e359fde8ab2a7e214f6825ed63600299aa3a49 /src/datastore
parentfca68d261172f147382f00b685faf52a9b022846 (diff)
downloadgnunet-fe028c46f5b2bcf7f14ef1d587c8b54bf7d1343a.tar.gz
gnunet-fe028c46f5b2bcf7f14ef1d587c8b54bf7d1343a.zip
implementing get_keys API for sqlite datastore plugin (#2013)
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/plugin_datastore_sqlite.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 6d3d56c02..765c7f34a 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -1084,6 +1084,43 @@ sqlite_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
1084} 1084}
1085 1085
1086 1086
1087
1088/**
1089 * Get all of the keys in the datastore.
1090 *
1091 * @param cls closure
1092 * @param proc function to call on each key
1093 * @param proc_cls closure for proc
1094 */
1095static void
1096sqlite_plugin_get_keys (void *cls,
1097 PluginKeyProcessor proc,
1098 void *proc_cls)
1099{
1100 struct Plugin *plugin = cls;
1101 const GNUNET_HashCode *key;
1102 sqlite3_stmt *stmt;
1103 int ret;
1104
1105 GNUNET_assert (proc != NULL);
1106 if (sq_prepare (plugin->dbh, "SELECT hash FROM gn090", &stmt) != SQLITE_OK)
1107 {
1108 LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
1109 "sqlite_prepare");
1110 return;
1111 }
1112 while (SQLITE_ROW == (ret = sqlite3_step (stmt)))
1113 {
1114 key = sqlite3_column_blob (stmt, 1);
1115 if (sizeof (GNUNET_HashCode) == sqlite3_column_bytes (stmt, 1))
1116 proc (proc_cls, key, 1);
1117 }
1118 if (SQLITE_DONE != ret)
1119 LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
1120 sqlite3_finalize (stmt);
1121}
1122
1123
1087/** 1124/**
1088 * Drop database. 1125 * Drop database.
1089 * 1126 *
@@ -1177,6 +1214,7 @@ libgnunet_plugin_datastore_sqlite_init (void *cls)
1177 api->get_replication = &sqlite_plugin_get_replication; 1214 api->get_replication = &sqlite_plugin_get_replication;
1178 api->get_expiration = &sqlite_plugin_get_expiration; 1215 api->get_expiration = &sqlite_plugin_get_expiration;
1179 api->get_zero_anonymity = &sqlite_plugin_get_zero_anonymity; 1216 api->get_zero_anonymity = &sqlite_plugin_get_zero_anonymity;
1217 api->get_keys = &sqlite_plugin_get_keys;
1180 api->drop = &sqlite_plugin_drop; 1218 api->drop = &sqlite_plugin_drop;
1181 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "sqlite", 1219 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "sqlite",
1182 _("Sqlite database running\n")); 1220 _("Sqlite database running\n"));