*/
static MYSQL *conn;
-#define INSERT_QUERIES_STMT "INSERT INTO queries (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid) "\
- "VALUES (?, ?, ?, ?, ?, ?, ?)"
+#define INSERT_QUERIES_STMT "INSERT INTO queries (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid, time) "\
+ "VALUES (?, ?, ?, ?, ?, ?, ?, NOW())"
static struct StatementHandle *insert_query;
#define INSERT_ROUTES_STMT "INSERT INTO routes (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid, from_node, to_node) "\
"VALUES (?, ?, ?)"
static struct StatementHandle *insert_node;
+#define INSERT_ROUNDS_STMT "INSERT INTO rounds (trialuid, round_type, round_count, starttime) "\
+ "VALUES (?, ?, ?, NOW())"
+
+static struct StatementHandle *insert_round;
+
#define INSERT_TRIALS_STMT "INSERT INTO trials"\
"(starttime, other_trial_identifier, numnodes, topology,"\
"topology_percentage, topology_probability,"\
if (PINIT (insert_query, INSERT_QUERIES_STMT) ||
PINIT (insert_route, INSERT_ROUTES_STMT) ||
PINIT (insert_trial, INSERT_TRIALS_STMT) ||
+ PINIT (insert_round, INSERT_ROUNDS_STMT) ||
PINIT (insert_stat, INSERT_STAT_STMT) ||
PINIT (insert_generic_stat, INSERT_GENERIC_STAT_STMT) ||
PINIT (insert_node, INSERT_NODES_STMT) ||
/**
* Run a prepared SELECT statement.
*
- * @param result_size number of elements in results array
+ * @param s handle to the statement we should execute
+ * @param result_size number of results in set
* @param results pointer to already initialized MYSQL_BIND
* array (of sufficient size) for passing results
* @param processor function to call on each result
* @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective
* values (size + buffer-reference for pointers); terminated
* with "-1"
+ *
* @return GNUNET_SYSERR on error, otherwise
* the number of successfully affected (or queried) rows
*/
int
-prepared_statement_run_select (struct StatementHandle
- *s, unsigned int result_size,
+prepared_statement_run_select (struct StatementHandle *s,
+ unsigned int result_size,
MYSQL_BIND * results,
GNUNET_MysqlDataProcessor
processor, void *processor_cls,
/**
* Run a prepared statement that does NOT produce results.
*
+ * @param s handle to the statement we should execute
+ * @param insert_id NULL or address where to store the row ID of whatever
+ * was inserted (only for INSERT statements!)
* @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective
* values (size + buffer-reference for pointers); terminated
* with "-1"
- * @param insert_id NULL or address where to store the row ID of whatever
- * was inserted (only for INSERT statements!)
+ *
* @return GNUNET_SYSERR on error, otherwise
* the number of successfully affected rows
*/
return GNUNET_OK;
}
+/*
+ * Inserts the specified round into the dhttests.rounds table
+ *
+ * @param round_type the type of round that is being started
+ * @param round_count counter for the round (if applicable)
+ *
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int add_round (unsigned int round_type, unsigned int round_count)
+{
+
+ MYSQL_STMT *stmt;
+ int ret;
+
+ stmt = mysql_stmt_init(conn);
+ ret = prepared_statement_run (insert_round,
+ NULL,
+ MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES,
+ MYSQL_TYPE_LONG, &round_type, GNUNET_YES,
+ MYSQL_TYPE_LONG, &round_count, GNUNET_YES, -1);
+ mysql_stmt_close(stmt);
+ if (ret != GNUNET_OK)
+ return GNUNET_SYSERR;
+ return ret;
+}
/*
* Inserts the specified stats into the dhttests.node_statistics table
if (GNUNET_OK !=
(ret = prepared_statement_run (insert_topology,
NULL,
- MYSQL_TYPE_LONGLONG,
- ¤t_trial,
- GNUNET_YES,
- MYSQL_TYPE_LONG,
- &num_connections,
- GNUNET_YES, -1)))
+ MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES,
+ MYSQL_TYPE_LONG, &num_connections, GNUNET_YES,
+ -1)))
{
if (ret == GNUNET_SYSERR)
{
plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
plugin->dhtlog_api->insert_trial = &add_trial;
plugin->dhtlog_api->insert_stat = &add_stat;
+ plugin->dhtlog_api->insert_round = &add_round;
plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
plugin->dhtlog_api->insert_query = &add_query;
plugin->dhtlog_api->update_trial = &update_trials;
prepared_statement_close(insert_query);
prepared_statement_close(insert_route);
prepared_statement_close(insert_trial);
+ prepared_statement_close(insert_round);
prepared_statement_close(insert_node);
prepared_statement_close(insert_dhtkey);
prepared_statement_close(update_trial);