* </pre>
* and do the following. [You should replace $USER with the username
* that will be running the gnunetd process].
- * <pre>
- *
+ * @verbatim
CREATE DATABASE gnunet;
GRANT select,insert,update,delete,create,alter,drop,create temporary tables
ON gnunet.* TO $USER@localhost;
SET PASSWORD FOR $USER@localhost=PASSWORD('$the_password_you_like');
FLUSH PRIVILEGES;
- *
- * </pre>
+ @endverbatim
* 2) In the $HOME directory of $USER, create a ".my.cnf" file
* with the following lines
- * <pre>
-
+ * @verbatim
[client]
user=$USER
password=$the_password_you_like
-
- * </pre>
+ @endverbatim
*
* Thats it -- now you can configure your datastores in GNUnet to
* use MySQL. Note that .my.cnf file is a security risk unless its on
*
* 3) Still, perhaps you should briefly try if the DB connection
* works. First, login as $USER. Then use,
- *
- * <pre>
- * $ mysql -u $USER -p $the_password_you_like
- * mysql> use gnunet;
- * </pre>
+ * @verbatim
+ $ mysql -u $USER -p $the_password_you_like
+ mysql> use gnunet;
+ @endverbatim
*
* If you get the message "Database changed" it probably works.
*
* "ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock"
* so there may be some additional trouble depending on your mysql setup.]
*
- * REPAIRING TABLES:
- * - Its probably healthy to check your tables for inconsistencies
- * every now and then.
- * - If you get odd SEGVs on gnunetd startup, it might be that the mysql
- * databases have been corrupted.
- * - The tables can be verified/fixed in two ways;
- * 1) by running mysqlcheck -A, or
- * 2) by executing (inside of mysql using the GNUnet database):
- * mysql> SHOW TABLES;
- * mysql> REPAIR TABLE gnXXX;
- *
- * Make sure to replace XXX with the actual names of all tables.
- *
* PROBLEMS?
*
* If you have problems related to the mysql module, your best
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-#include "plugin_datacache.h"
+#include "gnunet_datacache_plugin.h"
#include <mysql/mysql.h>
#define DEBUG_DATACACHE_MYSQL GNUNET_NO
/**
* Obtain the location of ".my.cnf".
+ *
+ * @param cfg our configuration
* @return NULL on error
*/
static char *
/**
* Free a prepared statement.
+ *
+ * @param plugin plugin context
+ * @param s prepared statement
*/
static void
prepared_statement_destroy (struct Plugin *plugin,
static int
iclose (struct Plugin *plugin)
{
- struct GNUNET_MysqlStatementHandle *spos;
-
- spos = plugin->shead;
while (NULL != plugin->shead)
prepared_statement_destroy (plugin,
plugin->shead);
* Bind the parameters for the given MySQL statement
* and run it.
*
+ * @param plugin plugin context
* @param s statement to bind and run
* @param ap arguments for the binding
* @return GNUNET_SYSERR on error, GNUNET_OK on success
memset (qbind, 0, sizeof (qbind));
off = 0;
ft = 0;
- while ((pc > 0) && (-1 != (ft = va_arg (ap, enum enum_field_types))))
+ while ( (pc > 0) && (-1 != (int) (ft = va_arg (ap, enum enum_field_types))) )
{
qbind[off].buffer_type = ft;
switch (ft)
pc--;
off++;
}
- if (!((pc == 0) && (ft != -1) && (va_arg (ap, int) == -1)))
+ if (! ( (pc == 0) && (-1 != (int) ft) && (va_arg (ap, int) == -1)) )
{
GNUNET_break (0);
return GNUNET_SYSERR;
/**
* Run a prepared SELECT statement.
*
+ * @param plugin plugin context
+ * @param s handle to SELECT statment
* @param result_size number of elements in results array
* @param results pointer to already initialized MYSQL_BIND
* array (of sufficient size) for passing results
/**
* Run a prepared statement that does NOT produce results.
*
+ * @param plugin plugin context
+ * @param s handle to SELECT statment
* @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective
* values (size + buffer-reference for pointers); terminated
* with "-1"
}
+/**
+ * Create temporary table and prepare statements.
+ *
+ * @param plugin plugin context
+ * @return GNUNET_OK on success
+ */
static int
itable (struct Plugin *plugin)
{
* @param discard_time when to discard the value in any case
* @return 0 on error, number of bytes used otherwise
*/
-static uint32_t
+static size_t
mysql_plugin_put (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
k_length = sizeof (GNUNET_HashCode);
v_length = size;
v_type = type;
- v_now = (unsigned long long) now.value;
- v_discard_time = (unsigned long long) discard_time.value;
+ v_now = (unsigned long long) now.abs_value;
+ v_discard_time = (unsigned long long) discard_time.abs_value;
if (GNUNET_OK ==
prepared_statement_run (plugin,
plugin->update_value,
rbind[0].buffer = &total;
rbind[0].is_unsigned = GNUNET_YES;
v_type = type;
- v_now = (unsigned long long) now.value;
+ v_now = (unsigned long long) now.abs_value;
if ((GNUNET_OK !=
(ret = prepared_statement_run_select (plugin,
plugin->count_value,
return GNUNET_SYSERR;
}
cnt++;
- expire.value = v_expire;
+ expire.abs_value = v_expire;
if (GNUNET_OK != iter (iter_cls,
expire,
key,