27 #include <mysql/mysql.h>
52 for (
unsigned int i = 0; NULL != params[i].
conv; i++)
55 MYSQL_BIND qbind[num];
62 for (
unsigned int i = 0; NULL != (
p = ¶ms[i])->
conv; i++)
70 "Conversion for MySQL query failed at offset %u\n",
77 if (mysql_stmt_bind_param (stmt,
82 _ (
"`%s' failed at %s:%d with error: %s\n"),
83 "mysql_stmt_bind_param",
85 mysql_stmt_error (stmt));
90 if (mysql_stmt_execute (stmt))
94 _ (
"`%s' failed at %s:%d with error: %s\n"),
95 "mysql_stmt_execute", __FILE__, __LINE__,
96 mysql_stmt_error (stmt));
118 for (
unsigned int i = 0; NULL != qp[i].
conv; i++)
140 unsigned int num_fields;
152 mysql_stmt_free_result (stmt);
157 for (
unsigned int i = 0; NULL != rs[i].
pre_conv; i++)
158 num_fields += rs[i].num_fields;
160 if (mysql_stmt_field_count (stmt) != num_fields)
163 "Number of fields mismatch between SQL result and result specification\n");
168 MYSQL_BIND
result[num_fields];
169 unsigned int field_off;
171 memset (
result, 0,
sizeof(MYSQL_BIND) * num_fields);
173 for (
unsigned int i = 0; NULL != rs[i].
pre_conv; i++)
178 rp->pre_conv (
rp->conv_cls,
186 "Pre-conversion for MySQL result failed at offset %u\n",
190 field_off +=
rp->num_fields;
193 if (mysql_stmt_bind_result (stmt,
result))
197 _ (
"%s failed at %s:%d with error: %s\n"),
198 "mysql_stmt_bind_result",
200 mysql_stmt_error (stmt));
203 #if TEST_OPTIMIZATION
204 (void) mysql_stmt_store_result (stmt);
206 ret = mysql_stmt_fetch (stmt);
207 if (MYSQL_NO_DATA ==
ret)
209 mysql_stmt_free_result (stmt);
216 _ (
"%s failed at %s:%d with error: %s\n"),
219 mysql_stmt_error (stmt));
221 mysql_stmt_free_result (stmt);
225 for (
unsigned int i = 0; NULL != rs[i].
post_conv; i++)
229 if (NULL !=
rp->post_conv)
231 rp->post_conv (
rp->conv_cls,
238 "Post-conversion for MySQL result failed at offset %u\n",
240 mysql_stmt_free_result (stmt);
241 for (
unsigned int j = 0; j < i; j++)
247 field_off +=
rp->num_fields;
263 for (
unsigned int i = 0; NULL != rs[i].
post_conv; i++)
static int ret
Return value of the commandline.
static struct SolverHandle * sh
static char * rp
Relying party.
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
static int result
Global testing status.
static struct GNUNET_OS_Process * p
Helper process we started.
Helper library to access a MySQL database.
#define GNUNET_log(kind,...)
#define GNUNET_log_from(kind, comp,...)
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
void GNUNET_MY_cleanup_query(struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Free all memory that was allocated in qp during GNUNET_MY_exec_prepared().
void GNUNET_MY_cleanup_result(struct GNUNET_MY_ResultSpec *rs)
Free all memory that was allocated in rs during GNUNET_MY_extract_result().
MYSQL_STMT * GNUNET_MYSQL_statement_get_stmt(struct GNUNET_MYSQL_StatementHandle *sh)
Get internal handle for a prepared statement.
void GNUNET_MYSQL_statements_invalidate(struct GNUNET_MYSQL_Context *mc)
Close database connection and all prepared statements (we got a DB error).
int GNUNET_MY_exec_prepared(struct GNUNET_MYSQL_Context *mc, struct GNUNET_MYSQL_StatementHandle *sh, struct GNUNET_MY_QueryParam *params)
Run a prepared SELECT statement.
int GNUNET_MY_extract_result(struct GNUNET_MYSQL_StatementHandle *sh, struct GNUNET_MY_ResultSpec *rs)
Extract results from a query result according to the given specification.
Handle for a prepared statement.
Information we pass to GNUNET_MY_exec_prepared() to initialize the arguments of the prepared statemen...
void * conv_cls
Closure for conv.
unsigned int num_params
Number of arguments the conv converter expects to initialize.
GNUNET_MY_QueryCleanup cleaner
Function to call for cleaning up the query.
GNUNET_MY_QueryConverter conv
Function to call for the type conversion.
Information we pass to GNUNET_MY_extract_result() to initialize the arguments of the prepared stateme...
void * conv_cls
Closure for conv.
GNUNET_MY_ResultConverter post_conv
Function to call for converting the result.
void * dst
Destination for the data.
GNUNET_MY_ResultConverter pre_conv
Function to call to initialize the MYSQL_BIND array.
GNUNET_MY_ResultCleanup cleaner
Function to call for cleaning up the result.