[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18655 - gnunet/src/datastore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18655 - gnunet/src/datastore |
Date: |
Sat, 17 Dec 2011 01:45:04 +0100 |
Author: grothoff
Date: 2011-12-17 01:45:04 +0100 (Sat, 17 Dec 2011)
New Revision: 18655
Modified:
gnunet/src/datastore/plugin_datastore_postgres.c
Log:
-implementing get_keys for postgres
Modified: gnunet/src/datastore/plugin_datastore_postgres.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_postgres.c 2011-12-16 23:31:38 UTC
(rev 18654)
+++ gnunet/src/datastore/plugin_datastore_postgres.c 2011-12-17 00:45:04 UTC
(rev 18655)
@@ -317,6 +317,9 @@
"ORDER BY repl DESC,RANDOM() LIMIT 1", 0, __LINE__)) ||
(GNUNET_OK !=
pq_prepare (plugin, "delrow", "DELETE FROM gn090 " "WHERE oid=$1", 1,
+ __LINE__)) ||
+ (GNUNET_OK !=
+ pq_prepare (plugin, "get_keys", "SELECT hash FROM gn090", 0,
__LINE__)))
{
PQfinish (plugin->dbh);
@@ -933,7 +936,41 @@
}
+
/**
+ * Get all of the keys in the datastore.
+ *
+ * @param cls closure
+ * @param proc function to call on each key
+ * @param proc_cls closure for proc
+ */
+static void
+postgres_plugin_get_keys (void *cls,
+ PluginKeyProcessor proc,
+ void *proc_cls)
+{
+ struct Plugin *plugin = cls;
+ int ret;
+ int i;
+ GNUNET_HashCode key;
+ PGresult * res;
+
+ res = PQexecPrepared (plugin->dbh, "get_keys", 0, NULL, NULL, NULL, 1);
+ ret = PQntuples (res);
+ for (i=0;i<ret;i++)
+ {
+ if (sizeof (GNUNET_HashCode) != PQgetlength (res, i, 0))
+ {
+ memcpy (&key, PQgetvalue (res, i, 0), sizeof (GNUNET_HashCode));
+ proc (proc_cls, &key, 1);
+ }
+ }
+ PQclear (res);
+}
+
+
+
+/**
* Drop database.
*/
static void
@@ -974,6 +1011,7 @@
api->get_replication = &postgres_plugin_get_replication;
api->get_expiration = &postgres_plugin_get_expiration;
api->get_zero_anonymity = &postgres_plugin_get_zero_anonymity;
+ api->get_keys = &postgres_plugin_get_keys;
api->drop = &postgres_plugin_drop;
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datastore-postgres",
_("Postgres database running\n"));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18655 - gnunet/src/datastore,
gnunet <=