library to help with access to a MySQL database More...
#include "platform.h"
#include <mysql/mysql.h>
#include "gnunet_mysql_lib.h"
#include "gnunet_mysql_compat.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MYSQL_Context |
Mysql context. More... | |
struct | GNUNET_MYSQL_StatementHandle |
Handle for a prepared statement. More... | |
Macros | |
#define | MAX_PARAM 16 |
Maximum number of supported parameters for a prepared statement. More... | |
#define | DIE_MYSQL(cmd, dbh) |
Die with an error message that indicates a failure of the command 'cmd' with the message given by strerror(errno). More... | |
#define | LOG_MYSQL(level, cmd, dbh) |
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' on file 'filename' with the message given by strerror(errno). More... | |
Functions | |
static char * | get_my_cnf_path (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) |
Obtain the location of ".my.cnf". More... | |
static int | iopen (struct GNUNET_MYSQL_Context *mc) |
Open the connection with the database (and initialize our default options). More... | |
struct GNUNET_MYSQL_Context * | GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) |
Create a mysql context. More... | |
void | GNUNET_MYSQL_statements_invalidate (struct GNUNET_MYSQL_Context *mc) |
Close database connection and all prepared statements (we got a DB error). More... | |
void | GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc) |
Destroy a mysql context. More... | |
struct GNUNET_MYSQL_StatementHandle * | GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc, const char *query) |
Prepare a statement. More... | |
int | GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc, const char *sql) |
Run a SQL statement. More... | |
static int | prepare_statement (struct GNUNET_MYSQL_StatementHandle *sh) |
Prepare a statement for running. More... | |
MYSQL_STMT * | GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh) |
Get internal handle for a prepared statement. More... | |
library to help with access to a MySQL database
Definition in file mysql.c.
#define MAX_PARAM 16 |
#define DIE_MYSQL | ( | cmd, | |
dbh | |||
) |
Die with an error message that indicates a failure of the command 'cmd' with the message given by strerror(errno).
#define LOG_MYSQL | ( | level, | |
cmd, | |||
dbh | |||
) |
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' on file 'filename' with the message given by strerror(errno).
|
static |
Obtain the location of ".my.cnf".
cfg | our configuration |
section | the section |
Definition at line 155 of file mysql.c.
References _, cfg, GNUNET_MYSQL_Context::cnffile, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log_from, GNUNET_log_from_strerror, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_YES, and st.
Referenced by GNUNET_MYSQL_context_create().
|
static |
Open the connection with the database (and initialize our default options).
mc | database context to initialize |
Definition at line 217 of file mysql.c.
References GNUNET_TESTBED_Controller::cfg, GNUNET_assert, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, GNUNET_YES, LOG_MYSQL, mc, MYSQL_BOOL, reconnect(), and timeout.
Referenced by GNUNET_MYSQL_statement_run(), and prepare_statement().
|
static |
Prepare a statement for running.
sh | statement handle to prepare |
Definition at line 438 of file mysql.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_log_from, GNUNET_MYSQL_statements_invalidate(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, iopen(), LOG_MYSQL, mc, and sh.
Referenced by GNUNET_MYSQL_statement_get_stmt().