27 #include <mysql/mysql.h>
51 for (
unsigned int i = 0; NULL != params[i].
conv; i++)
54 MYSQL_BIND qbind[num];
61 for (
unsigned int i = 0; NULL != (
p = ¶ms[i])->
conv; i++)
69 "Conversion for MySQL query failed at offset %u\n",
76 if (mysql_stmt_bind_param (stmt,
81 _ (
"`%s' failed at %s:%d with error: %s\n"),
82 "mysql_stmt_bind_param",
84 mysql_stmt_error (stmt));
89 if (mysql_stmt_execute (stmt))
93 _ (
"`%s' failed at %s:%d with error: %s\n"),
94 "mysql_stmt_execute", __FILE__, __LINE__,
95 mysql_stmt_error (stmt));
117 for (
unsigned int i = 0; NULL != qp[i].
conv; i++)
139 unsigned int num_fields;
151 mysql_stmt_free_result (stmt);
156 for (
unsigned int i = 0; NULL != rs[i].
pre_conv; i++)
157 num_fields += rs[i].num_fields;
159 if (mysql_stmt_field_count (stmt) != num_fields)
162 "Number of fields mismatch between SQL result and result specification\n");
167 MYSQL_BIND
result[num_fields];
168 unsigned int field_off;
170 memset (
result, 0,
sizeof(MYSQL_BIND) * num_fields);
172 for (
unsigned int i = 0; NULL != rs[i].
pre_conv; i++)
177 rp->pre_conv (
rp->conv_cls,
185 "Pre-conversion for MySQL result failed at offset %u\n",
189 field_off +=
rp->num_fields;
192 if (mysql_stmt_bind_result (stmt,
result))
196 _ (
"%s failed at %s:%d with error: %s\n"),
197 "mysql_stmt_bind_result",
199 mysql_stmt_error (stmt));
202 #if TEST_OPTIMIZATION
203 (void) mysql_stmt_store_result (stmt);
205 ret = mysql_stmt_fetch (stmt);
206 if (MYSQL_NO_DATA ==
ret)
208 mysql_stmt_free_result (stmt);
215 _ (
"%s failed at %s:%d with error: %s\n"),
218 mysql_stmt_error (stmt));
220 mysql_stmt_free_result (stmt);
224 for (
unsigned int i = 0; NULL != rs[i].
post_conv; i++)
228 if (NULL !=
rp->post_conv)
230 rp->post_conv (
rp->conv_cls,
237 "Post-conversion for MySQL result failed at offset %u\n",
239 mysql_stmt_free_result (stmt);
240 for (
unsigned int j = 0; j < i; j++)
246 field_off +=
rp->num_fields;
262 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.
#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.