}
-/**
- * Select a subset of the items in the datastore and call
- * the given iterator for each of them.
- *
- * @param cls our "struct Plugin*"
- * @param type entries of which type should be considered?
- * Use 0 for any type.
- * @param iter function to call on each matching value;
- * will be called once with a NULL value at the end
- * @param iter_cls closure for iter
- */
-static void
-mysql_plugin_iter_all_now (void *cls,
- enum GNUNET_BLOCK_Type type,
- PluginIterator iter,
- void *iter_cls)
-{
- struct Plugin *plugin = cls;
- iterateHelper (plugin, 0, GNUNET_YES, 0, iter, iter_cls);
-}
-
-
/**
* Drop database.
*/
api->expiration_get = &mysql_plugin_expiration_get;
api->update = &mysql_plugin_update;
api->iter_zero_anonymity = &mysql_plugin_iter_zero_anonymity;
- api->iter_all_now = &mysql_plugin_iter_all_now;
api->drop = &mysql_plugin_drop;
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
"mysql", _("Mysql database running\n"));
}
-/**
- * Select a subset of the items in the datastore and call
- * the given iterator for each of them.
- *
- * @param cls our "struct Plugin*"
- * @param type entries of which type should be considered?
- * Use 0 for any type.
- * @param iter function to call on each matching value;
- * will be called once with a NULL value at the end
- * @param iter_cls closure for iter
- */
-static void
-postgres_plugin_iter_all_now (void *cls,
- enum GNUNET_BLOCK_Type type,
- PluginIterator iter,
- void *iter_cls)
-{
- struct Plugin *plugin = cls;
-
- postgres_iterate (plugin,
- 0, GNUNET_YES, 0,
- iter, iter_cls);
-}
-
-
/**
* Drop database.
*/
api->expiration_get = &postgres_plugin_expiration_get;
api->update = &postgres_plugin_update;
api->iter_zero_anonymity = &postgres_plugin_iter_zero_anonymity;
- api->iter_all_now = &postgres_plugin_iter_all_now;
api->drop = &postgres_plugin_drop;
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
"datastore-postgres",
}
-/**
- * Closure for 'all_next_prepare'.
- */
-struct IterateAllContext
-{
-
- /**
- * Offset for the current result.
- */
- unsigned int off;
-
- /**
- * Requested block type.
- */
- enum GNUNET_BLOCK_Type type;
-
- /**
- * Our prepared statement.
- */
- sqlite3_stmt *stmt;
-};
-
-
-/**
- * Call sqlite using the already prepared query to get
- * the next result.
- *
- * @param cls context with the prepared query (of type 'struct IterateAllContext')
- * @param nc generic context with the prepared query
- * @return GNUNET_OK on success, GNUNET_SYSERR on error, GNUNET_NO if
- * there are no more results
- */
-static int
-all_next_prepare (void *cls,
- struct NextContext *nc)
-{
- struct IterateAllContext *iac = cls;
- struct Plugin *plugin;
- int ret;
- unsigned int sqoff;
-
- if (nc == NULL)
- {
-#if DEBUG_SQLITE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to clean up iterator state.\n");
-#endif
- if (NULL != iac->stmt)
- {
- sqlite3_finalize (iac->stmt);
- iac->stmt = NULL;
- }
- return GNUNET_SYSERR;
- }
- plugin = nc->plugin;
- sqoff = 1;
- ret = SQLITE_OK;
- if (iac->type != 0)
- ret = sqlite3_bind_int (nc->stmt, sqoff++, iac->type);
- if (SQLITE_OK == ret)
- ret = sqlite3_bind_int64 (nc->stmt, sqoff++, iac->off++);
- if (ret != SQLITE_OK)
- {
- LOG_SQLITE (plugin, NULL,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_XXXX");
- return GNUNET_SYSERR;
- }
- ret = sqlite3_step (nc->stmt);
- switch (ret)
- {
- case SQLITE_ROW:
- return GNUNET_OK;
- case SQLITE_DONE:
- return GNUNET_NO;
- default:
- LOG_SQLITE (plugin, NULL,
- GNUNET_ERROR_TYPE_ERROR |
- GNUNET_ERROR_TYPE_BULK,
- "sqlite3_step");
- return GNUNET_SYSERR;
- }
-}
-
-
-/**
- * Select a subset of the items in the datastore and call
- * the given iterator for each of them.
- *
- * @param cls our plugin context
- * @param type entries of which type should be considered?
- * Use 0 for any type.
- * @param iter function to call on each matching value;
- * will be called once with a NULL value at the end
- * @param iter_cls closure for iter
- */
-static void
-sqlite_plugin_iter_all_now (void *cls,
- enum GNUNET_BLOCK_Type type,
- PluginIterator iter,
- void *iter_cls)
-{
- struct Plugin *plugin = cls;
- struct NextContext *nc;
- struct IterateAllContext *iac;
- sqlite3_stmt *stmt;
- const char *q;
-
- if (type == 0)
- q = "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 ORDER BY _ROWID_ ASC LIMIT 1 OFFSET ?";
- else
- q = "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 WHERE type=? ORDER BY _ROWID_ ASC LIMIT 1 OFFSET ?";
- if (sq_prepare (plugin->dbh, q, &stmt) != SQLITE_OK)
- {
- LOG_SQLITE (plugin, NULL,
- GNUNET_ERROR_TYPE_ERROR |
- GNUNET_ERROR_TYPE_BULK, "sqlite3_prepare_v2");
- iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
- return;
- }
- nc = GNUNET_malloc (sizeof(struct NextContext) +
- sizeof(struct IterateAllContext));
- iac = (struct IterateAllContext*) &nc[1];
- nc->plugin = plugin;
- nc->iter = iter;
- nc->iter_cls = iter_cls;
- nc->stmt = stmt;
- nc->prep = &all_next_prepare;
- nc->prep_cls = iac;
- iac->off = 0;
- iac->type = type;
- iac->stmt = stmt; /* alias used for freeing at the end */
- sqlite_next_request (nc, GNUNET_NO);
-}
-
-
/**
* Context for get_next_prepare.
*/
api->expiration_get = &sqlite_plugin_expiration_get;
api->update = &sqlite_plugin_update;
api->iter_zero_anonymity = &sqlite_plugin_iter_zero_anonymity;
- api->iter_all_now = &sqlite_plugin_iter_all_now;
api->drop = &sqlite_plugin_drop;
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
"sqlite", _("Sqlite database running\n"));
}
-/**
- * Select a subset of the items in the datastore and call
- * the given iterator for each of them.
- *
- * @param cls our "struct Plugin*"
- * @param type entries of which type should be considered?
- * Use 0 for any type.
- * @param iter function to call on each matching value;
- * will be called once with a NULL value at the end
- * @param iter_cls closure for iter
- */
-static void
-template_plugin_iter_all_now (void *cls,
- enum GNUNET_BLOCK_Type type,
- PluginIterator iter,
- void *iter_cls)
-{
- GNUNET_break (0);
-}
-
-
/**
* Drop database.
*/
api->expiration_get = &template_plugin_expiration_get;
api->update = &template_plugin_update;
api->iter_zero_anonymity = &template_plugin_iter_zero_anonymity;
- api->iter_all_now = &template_plugin_iter_all_now;
api->drop = &template_plugin_drop;
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
"template", _("Template database running\n"));