diff options
Diffstat (limited to 'src/datacache/plugin_datacache_mysql.c')
-rw-r--r-- | src/datacache/plugin_datacache_mysql.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/datacache/plugin_datacache_mysql.c b/src/datacache/plugin_datacache_mysql.c index 4559a9d39..d83d18cd6 100644 --- a/src/datacache/plugin_datacache_mysql.c +++ b/src/datacache/plugin_datacache_mysql.c | |||
@@ -33,24 +33,20 @@ | |||
33 | * </pre> | 33 | * </pre> |
34 | * and do the following. [You should replace $USER with the username | 34 | * and do the following. [You should replace $USER with the username |
35 | * that will be running the gnunetd process]. | 35 | * that will be running the gnunetd process]. |
36 | * <pre> | 36 | * @verbatim |
37 | * | ||
38 | CREATE DATABASE gnunet; | 37 | CREATE DATABASE gnunet; |
39 | GRANT select,insert,update,delete,create,alter,drop,create temporary tables | 38 | GRANT select,insert,update,delete,create,alter,drop,create temporary tables |
40 | ON gnunet.* TO $USER@localhost; | 39 | ON gnunet.* TO $USER@localhost; |
41 | SET PASSWORD FOR $USER@localhost=PASSWORD('$the_password_you_like'); | 40 | SET PASSWORD FOR $USER@localhost=PASSWORD('$the_password_you_like'); |
42 | FLUSH PRIVILEGES; | 41 | FLUSH PRIVILEGES; |
43 | * | 42 | * @endverbatim |
44 | * </pre> | ||
45 | * 2) In the $HOME directory of $USER, create a ".my.cnf" file | 43 | * 2) In the $HOME directory of $USER, create a ".my.cnf" file |
46 | * with the following lines | 44 | * with the following lines |
47 | * <pre> | 45 | * @verbatim |
48 | |||
49 | [client] | 46 | [client] |
50 | user=$USER | 47 | user=$USER |
51 | password=$the_password_you_like | 48 | password=$the_password_you_like |
52 | 49 | * @endverbatim | |
53 | * </pre> | ||
54 | * | 50 | * |
55 | * Thats it -- now you can configure your datastores in GNUnet to | 51 | * Thats it -- now you can configure your datastores in GNUnet to |
56 | * use MySQL. Note that .my.cnf file is a security risk unless its on | 52 | * use MySQL. Note that .my.cnf file is a security risk unless its on |
@@ -62,11 +58,10 @@ | |||
62 | * | 58 | * |
63 | * 3) Still, perhaps you should briefly try if the DB connection | 59 | * 3) Still, perhaps you should briefly try if the DB connection |
64 | * works. First, login as $USER. Then use, | 60 | * works. First, login as $USER. Then use, |
65 | * | 61 | * @verbatim |
66 | * <pre> | 62 | $ mysql -u $USER -p $the_password_you_like |
67 | * $ mysql -u $USER -p $the_password_you_like | 63 | mysql> use gnunet; |
68 | * mysql> use gnunet; | 64 | * @endverbatim |
69 | * </pre> | ||
70 | * | 65 | * |
71 | * If you get the message "Database changed" it probably works. | 66 | * If you get the message "Database changed" it probably works. |
72 | * | 67 | * |
@@ -75,19 +70,6 @@ | |||
75 | * "ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock" | 70 | * "ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock" |
76 | * so there may be some additional trouble depending on your mysql setup.] | 71 | * so there may be some additional trouble depending on your mysql setup.] |
77 | * | 72 | * |
78 | * REPAIRING TABLES: | ||
79 | * - Its probably healthy to check your tables for inconsistencies | ||
80 | * every now and then. | ||
81 | * - If you get odd SEGVs on gnunetd startup, it might be that the mysql | ||
82 | * databases have been corrupted. | ||
83 | * - The tables can be verified/fixed in two ways; | ||
84 | * 1) by running mysqlcheck -A, or | ||
85 | * 2) by executing (inside of mysql using the GNUnet database): | ||
86 | * mysql> SHOW TABLES; | ||
87 | * mysql> REPAIR TABLE gnXXX; | ||
88 | * | ||
89 | * Make sure to replace XXX with the actual names of all tables. | ||
90 | * | ||
91 | * PROBLEMS? | 73 | * PROBLEMS? |
92 | * | 74 | * |
93 | * If you have problems related to the mysql module, your best | 75 | * If you have problems related to the mysql module, your best |
@@ -191,6 +173,8 @@ struct Plugin | |||
191 | 173 | ||
192 | /** | 174 | /** |
193 | * Obtain the location of ".my.cnf". | 175 | * Obtain the location of ".my.cnf". |
176 | * | ||
177 | * @param cfg our configuration | ||
194 | * @return NULL on error | 178 | * @return NULL on error |
195 | */ | 179 | */ |
196 | static char * | 180 | static char * |
@@ -251,6 +235,9 @@ get_my_cnf_path (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
251 | 235 | ||
252 | /** | 236 | /** |
253 | * Free a prepared statement. | 237 | * Free a prepared statement. |
238 | * | ||
239 | * @param plugin plugin context | ||
240 | * @param s prepared statement | ||
254 | */ | 241 | */ |
255 | static void | 242 | static void |
256 | prepared_statement_destroy (struct Plugin *plugin, | 243 | prepared_statement_destroy (struct Plugin *plugin, |
@@ -467,6 +454,7 @@ prepare_statement (struct Plugin *plugin, | |||
467 | * Bind the parameters for the given MySQL statement | 454 | * Bind the parameters for the given MySQL statement |
468 | * and run it. | 455 | * and run it. |
469 | * | 456 | * |
457 | * @param plugin plugin context | ||
470 | * @param s statement to bind and run | 458 | * @param s statement to bind and run |
471 | * @param ap arguments for the binding | 459 | * @param ap arguments for the binding |
472 | * @return GNUNET_SYSERR on error, GNUNET_OK on success | 460 | * @return GNUNET_SYSERR on error, GNUNET_OK on success |
@@ -565,6 +553,8 @@ typedef int (*GNUNET_MysqlDataProcessor) (void *cls, | |||
565 | /** | 553 | /** |
566 | * Run a prepared SELECT statement. | 554 | * Run a prepared SELECT statement. |
567 | * | 555 | * |
556 | * @param plugin plugin context | ||
557 | * @param s handle to SELECT statment | ||
568 | * @param result_size number of elements in results array | 558 | * @param result_size number of elements in results array |
569 | * @param results pointer to already initialized MYSQL_BIND | 559 | * @param results pointer to already initialized MYSQL_BIND |
570 | * array (of sufficient size) for passing results | 560 | * array (of sufficient size) for passing results |
@@ -649,6 +639,8 @@ prepared_statement_run_select (struct Plugin *plugin, | |||
649 | /** | 639 | /** |
650 | * Run a prepared statement that does NOT produce results. | 640 | * Run a prepared statement that does NOT produce results. |
651 | * | 641 | * |
642 | * @param plugin plugin context | ||
643 | * @param s handle to SELECT statment | ||
652 | * @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective | 644 | * @param ... pairs and triplets of "MYSQL_TYPE_XXX" keys and their respective |
653 | * values (size + buffer-reference for pointers); terminated | 645 | * values (size + buffer-reference for pointers); terminated |
654 | * with "-1" | 646 | * with "-1" |
@@ -682,6 +674,12 @@ prepared_statement_run (struct Plugin *plugin, | |||
682 | } | 674 | } |
683 | 675 | ||
684 | 676 | ||
677 | /** | ||
678 | * Create temporary table and prepare statements. | ||
679 | * | ||
680 | * @param plugin plugin context | ||
681 | * @return GNUNET_OK on success | ||
682 | */ | ||
685 | static int | 683 | static int |
686 | itable (struct Plugin *plugin) | 684 | itable (struct Plugin *plugin) |
687 | { | 685 | { |