GNUnet  0.19.5

Helper library to access a MySQL database. More...

Collaboration diagram for MySQL library:

Data Structures

struct  GNUNET_MY_QueryParam
 Information we pass to GNUNET_MY_exec_prepared() to initialize the arguments of the prepared statement. More...
 
struct  GNUNET_MY_ResultSpec
 Information we pass to GNUNET_MY_extract_result() to initialize the arguments of the prepared statement. More...
 

Macros

#define GNUNET_MY_query_param_end   { NULL, NULL, NULL, 0, NULL, 0 }
 End of query parameter specification. More...
 
#define GNUNET_MY_result_spec_end   { NULL, NULL, NULL, 0, NULL, 0, 0 }
 End of result speceter specification. More...
 
#define GNUNET_MY_query_param_auto_from_type(x)   GNUNET_MY_query_param_fixed_size ((x), sizeof(*(x)))
 Generate fixed-size query parameter with size determined by variable type. More...
 
#define GNUNET_MY_result_spec_auto_from_type(dst)   GNUNET_MY_result_spec_fixed_size ((dst), sizeof(*(dst)))
 We expect a fixed-size result, with size determined by the type of * dst More...
 
#define MYSQL_BOOL   my_bool
 

Typedefs

typedef int(* GNUNET_MY_QueryConverter) (void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
 Function called to convert input argument into SQL parameters. More...
 
typedef void(* GNUNET_MY_QueryCleanup) (void *cls, MYSQL_BIND *qbind)
 Function called to cleanup result data. More...
 
typedef int(* GNUNET_MY_ResultConverter) (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
 Function called to convert input argument into SQL parameters. More...
 
typedef void(* GNUNET_MY_ResultCleanup) (void *cls, struct GNUNET_MY_ResultSpec *rs)
 Function called to cleanup result data. More...
 
typedef int(* GNUNET_MYSQL_DataProcessor) (void *cls, unsigned int num_values, MYSQL_BIND *values)
 Type of a callback that will be called for each data set returned from MySQL. More...
 

Functions

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_fixed_size (const void *ptr, size_t ptr_size)
 Generate query parameter for a buffer ptr of ptr_size bytes.FG. More...
 
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. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_fixed_size (void *ptr, size_t ptr_size)
 Obtain fixed size result of ptr_size bytes from MySQL, store in already allocated buffer at ptr. More...
 
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_string (const char *ptr)
 Generate query parameter for a string. More...
 
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x)
 Generate query parameter for an RSA public key. More...
 
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x)
 Generate query parameter for an RSA signature. More...
 
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x)
 Generate query parameter for an absolute time value. More...
 
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x)
 Generate query parameter for an absolute time value. More...
 
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint16 (const uint16_t *x)
 Generate query parameter for an uint16_t in host byte order. More...
 
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint32 (const uint32_t *x)
 Generate query parameter for an uint32_t in host byte order. More...
 
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint64 (const uint64_t *x)
 Generate query parameter for an uint64_t in host byte order. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_variable_size (void **dst, size_t *ptr_size)
 Variable-size result expected. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa)
 RSA public key expected. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig)
 RSA signature expected. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_string (char **dst)
 0- terminated string exprected. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at)
 Absolute time expected. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at)
 Absolute time in network byte order expected. More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint16 (uint16_t *u16)
 uint16_t expected More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint32 (uint32_t *u32)
 uint32_t expected More...
 
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint64 (uint64_t *u64)
 uint64_t expected. More...
 
int GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh, struct GNUNET_MY_ResultSpec *specs)
 Extract results from a query result according to the given specification. More...
 
void GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
 Free all memory that was allocated in qp during #GNUNET_MY_exect_prepared(). More...
 
void GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs)
 Free all memory that was allocated in rs during GNUNET_MY_extract_result(). More...
 
struct GNUNET_MYSQL_ContextGNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
 Create a mysql context. More...
 
void GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc)
 Destroy 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...
 
MYSQL_STMT * GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh)
 Get internal handle for a prepared statement. More...
 
struct GNUNET_MYSQL_StatementHandleGNUNET_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...
 

Detailed Description

Helper library to access a MySQL database.

Macro Definition Documentation

◆ GNUNET_MY_query_param_end

#define GNUNET_MY_query_param_end   { NULL, NULL, NULL, 0, NULL, 0 }

End of query parameter specification.

Returns
array last entry for the result specification to use

Definition at line 130 of file gnunet_my_lib.h.

◆ GNUNET_MY_result_spec_end

#define GNUNET_MY_result_spec_end   { NULL, NULL, NULL, 0, NULL, 0, 0 }

End of result speceter specification.

Returns
array last entry for the result specification to use

Definition at line 266 of file gnunet_my_lib.h.

◆ GNUNET_MY_query_param_auto_from_type

#define GNUNET_MY_query_param_auto_from_type (   x)    GNUNET_MY_query_param_fixed_size ((x), sizeof(*(x)))

Generate fixed-size query parameter with size determined by variable type.

Parameters
xpointer to the query parameter to pass

Definition at line 294 of file gnunet_my_lib.h.

◆ GNUNET_MY_result_spec_auto_from_type

#define GNUNET_MY_result_spec_auto_from_type (   dst)    GNUNET_MY_result_spec_fixed_size ((dst), sizeof(*(dst)))

We expect a fixed-size result, with size determined by the type of * dst

@spec name name of the field in the table @spec dst point to where to store the result, type fits expected result size

Returns
array entry for the result specification to use

Definition at line 371 of file gnunet_my_lib.h.

◆ MYSQL_BOOL

#define MYSQL_BOOL   my_bool

Definition at line 46 of file gnunet_mysql_compat.h.

Typedef Documentation

◆ GNUNET_MY_QueryConverter

typedef int(* GNUNET_MY_QueryConverter) (void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
pqdata about the query
qbindarray of parameters to initialize
Returns
-1 on error

Definition at line 71 of file gnunet_my_lib.h.

◆ GNUNET_MY_QueryCleanup

typedef void(* GNUNET_MY_QueryCleanup) (void *cls, MYSQL_BIND *qbind)

Function called to cleanup result data.

Parameters
clsclosure
rsspec to clean up

Definition at line 83 of file gnunet_my_lib.h.

◆ GNUNET_MY_ResultConverter

typedef int(* GNUNET_MY_ResultConverter) (void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)

Function called to convert input argument into SQL parameters.

Parameters
clsclosure
[in,out]rs
stmtthe mysql statement that is being run
columnthe column that is being processed
[out]results
Returns
-1 on error

Definition at line 181 of file gnunet_my_lib.h.

◆ GNUNET_MY_ResultCleanup

typedef void(* GNUNET_MY_ResultCleanup) (void *cls, struct GNUNET_MY_ResultSpec *rs)

Function called to cleanup result data.

Parameters
clsclosure
rsspec to clean up

Definition at line 194 of file gnunet_my_lib.h.

◆ GNUNET_MYSQL_DataProcessor

typedef int(* GNUNET_MYSQL_DataProcessor) (void *cls, unsigned int num_values, MYSQL_BIND *values)

Type of a callback that will be called for each data set returned from MySQL.

Parameters
clsuser-defined argument
num_valuesnumber of elements in values
valuesvalues returned by MySQL
Returns
GNUNET_OK to continue iterating, GNUNET_SYSERR to abort

Definition at line 66 of file gnunet_mysql_lib.h.

Function Documentation

◆ GNUNET_MY_query_param_fixed_size()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_fixed_size ( const void *  ptr,
size_t  ptr_size 
)

Generate query parameter for a buffer ptr of ptr_size bytes.FG.

Parameters
ptrpointer to the query parameter to pass
ptr_sizenumber of bytes in ptr

Generate query parameter for a buffer ptr of ptr_size bytes.FG.

Parameters
ptrpointer to the query parameter to pass
ptr_sizenumber of bytes in ptr

Definition at line 57 of file my_query_helper.c.

81 {
82  struct GNUNET_MY_QueryParam qp = {
84  .cleaner = NULL,
85  .conv_cls = NULL,
86  .num_params = 1,
87  .data = ptr,
88  .data_len = (unsigned long) ptr_size
89  };
90 
91  return qp;
92 }
static int my_conv_fixed_size(void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Function called to convert input argument into SQL parameters.
Information we pass to GNUNET_MY_exec_prepared() to initialize the arguments of the prepared statemen...
Definition: gnunet_my_lib.h:93
GNUNET_MY_QueryConverter conv
Function to call for the type conversion.
Definition: gnunet_my_lib.h:97

Referenced by mysql_plugin_put(), mysql_plugin_remove_key(), and regex_iterator().

Here is the caller graph for this function:

◆ GNUNET_MY_exec_prepared()

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.

Parameters
mcmysql context
shhandle to SELECT statement
paramsparameters to the statement
Returns
TBD
Parameters
mcmysql context
shhandle to SELECT statement
paramsparameters to the statement
Returns
GNUNET_YES if we can prepare all statement GNUNET_SYSERR if we can't prepare all statement

Definition at line 43 of file my.c.

46 {
47  const struct GNUNET_MY_QueryParam *p;
48  unsigned int num;
49  MYSQL_STMT *stmt;
50 
51  num = 0;
52  for (unsigned int i = 0; NULL != params[i].conv; i++)
53  num += params[i].num_params;
54  {
55  MYSQL_BIND qbind[num];
56  unsigned int off;
57 
58  memset (qbind,
59  0,
60  sizeof(qbind));
61  off = 0;
62  for (unsigned int i = 0; NULL != (p = &params[i])->conv; i++)
63  {
64  if (GNUNET_OK !=
65  p->conv (p->conv_cls,
66  p,
67  &qbind[off]))
68  {
70  "Conversion for MySQL query failed at offset %u\n",
71  i);
72  return GNUNET_SYSERR;
73  }
74  off += p->num_params;
75  }
77  if (mysql_stmt_bind_param (stmt,
78  qbind))
79  {
81  "my",
82  _ ("`%s' failed at %s:%d with error: %s\n"),
83  "mysql_stmt_bind_param",
84  __FILE__, __LINE__,
85  mysql_stmt_error (stmt));
87  return GNUNET_SYSERR;
88  }
89 
90  if (mysql_stmt_execute (stmt))
91  {
93  "my",
94  _ ("`%s' failed at %s:%d with error: %s\n"),
95  "mysql_stmt_execute", __FILE__, __LINE__,
96  mysql_stmt_error (stmt));
98  return GNUNET_SYSERR;
99  }
100  GNUNET_MY_cleanup_query (params,
101  qbind);
102  }
103  return GNUNET_OK;
104 }
static struct SolverHandle * sh
static GstElement * conv
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
#define GNUNET_log(kind,...)
#define GNUNET_log_from(kind, comp,...)
@ GNUNET_OK
@ GNUNET_SYSERR
@ 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().
Definition: my.c:115
MYSQL_STMT * GNUNET_MYSQL_statement_get_stmt(struct GNUNET_MYSQL_StatementHandle *sh)
Get internal handle for a prepared statement.
Definition: mysql.c:478
void GNUNET_MYSQL_statements_invalidate(struct GNUNET_MYSQL_Context *mc)
Close database connection and all prepared statements (we got a DB error).
Definition: mysql.c:342
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
unsigned int num_params
Number of arguments the conv converter expects to initialize.

References _, conv, GNUNET_MY_QueryParam::conv, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_from, GNUNET_MY_cleanup_query(), GNUNET_MYSQL_statement_get_stmt(), GNUNET_MYSQL_statements_invalidate(), GNUNET_OK, GNUNET_SYSERR, mc, GNUNET_MY_QueryParam::num_params, p, and sh.

Referenced by do_delete_entry(), execute_select(), mysql_plugin_estimate_size(), mysql_plugin_get_keys(), mysql_plugin_get_replication(), mysql_plugin_put(), mysql_plugin_remove_key(), regex_iterator(), and repl_proc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MY_result_spec_fixed_size()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_fixed_size ( void *  ptr,
size_t  ptr_size 
)

Obtain fixed size result of ptr_size bytes from MySQL, store in already allocated buffer at ptr.

@spec ptr where to write the result

Parameters
ptr_sizenumber of bytes available at ptr

Obtain fixed size result of ptr_size bytes from MySQL, store in already allocated buffer at ptr.

Parameters
namename of the field in the table
[out]dstwhere to store the result
ptr_sizenumber of bytes in dst
Returns
array entry for the result specification to use

Definition at line 194 of file my_result_helper.c.

219 {
220  struct GNUNET_MY_ResultSpec res = {
221  .pre_conv = &pre_extract_fixed_blob,
222  .post_conv = &post_extract_fixed_blob,
223  .cleaner = NULL,
224  .dst = (void *) (ptr),
225  .dst_size = ptr_size,
226  .num_fields = 1
227  };
228 
229  return res;
230 }
static int res
static int post_extract_fixed_blob(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Check size of extracted fixed size data from a Mysql database result at row row.
static int pre_extract_fixed_blob(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a Mysql database result at row row.
Information we pass to GNUNET_MY_extract_result() to initialize the arguments of the prepared stateme...

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::mysql_bind_output_length, and results.

◆ GNUNET_MY_query_param_string()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_string ( const char *  ptr)

Generate query parameter for a string.

Parameters
ptrpointer to the string query parameter to pass

Definition at line 104 of file my_query_helper.c.

124 {
125  struct GNUNET_MY_QueryParam qp = {
126  .conv = &my_conv_string,
127  .cleaner = NULL,
128  .conv_cls = NULL,
129  .num_params = 1,
130  .data = ptr,
131  .data_len = strlen (ptr)
132  };
133 
134  return qp;
135 }
static int my_conv_string(void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Function called to convert input argument into SQL parameters.

Referenced by regex_iterator().

Here is the caller graph for this function:

◆ GNUNET_MY_query_param_rsa_public_key()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_rsa_public_key ( const struct GNUNET_CRYPTO_RsaPublicKey x)

Generate query parameter for an RSA public key.

The database must contain a BLOB type in the respective position.

Parameters
xthe query parameter to pass
Returns
array entry for the query parameters to use

Definition at line 279 of file my_query_helper.c.

308 {
309  struct GNUNET_MY_QueryParam res = {
310  .conv = &my_conv_rsa_public_key,
311  .cleaner = &my_clean_query,
312  .conv_cls = NULL,
313  .num_params = 1,
314  .data = x,
315  .data_len = 0
316  };
317 
318  return res;
319 }
static void my_clean_query(void *cls, MYSQL_BIND *qbind)
Function called to clean up memory allocated by a GNUNET_MY_QueryConverter.
static int my_conv_rsa_public_key(void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Function called to convert input argument into SQL parameters.

◆ GNUNET_MY_query_param_rsa_signature()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_rsa_signature ( const struct GNUNET_CRYPTO_RsaSignature x)

Generate query parameter for an RSA signature.

The database must contain a BLOB type in the respective position

Parameters
xthe query parameter to pass
Returns
array entry for the query parameters to use

Definition at line 331 of file my_query_helper.c.

359 {
360  struct GNUNET_MY_QueryParam res = {
361  .conv = &my_conv_rsa_signature,
362  .cleaner = &my_clean_query,
363  .conv_cls = NULL,
364  .num_params = 1,
365  .data = (x),
366  .data_len = 0
367  };
368 
369  return res;
370 }
static int my_conv_rsa_signature(void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Function called to convert input argument into SQL parameters.
unsigned long data_len
Information to pass to conv.

◆ GNUNET_MY_query_param_absolute_time()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_absolute_time ( const struct GNUNET_TIME_Absolute x)

Generate query parameter for an absolute time value.

The database must store a 64-bit integer.

Parameters
xpointer to the query parameter to pass
Returns
array entry for the query parameters to use

Definition at line 331 of file my_query_helper.c.

382 {
384 }
struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint64(const uint64_t *x)
Generate query parameter for an uint64_t in host byte order.
uint64_t abs_value_us
The actual value.

Referenced by mysql_plugin_get_expiration().

Here is the caller graph for this function:

◆ GNUNET_MY_query_param_absolute_time_nbo()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_absolute_time_nbo ( const struct GNUNET_TIME_AbsoluteNBO x)

Generate query parameter for an absolute time value.

The database must store a 64-bit integer.

Parameters
xpointer to the query parameter to pass

Definition at line 331 of file my_query_helper.c.

396 {
398 }
#define GNUNET_MY_query_param_auto_from_type(x)
Generate fixed-size query parameter with size determined by variable type.
uint64_t abs_value_us__
The actual value (in network byte order).

◆ GNUNET_MY_query_param_uint16()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint16 ( const uint16_t *  x)

Generate query parameter for an uint16_t in host byte order.

Parameters
xpointer to the query parameter to pass

Definition at line 147 of file my_query_helper.c.

168 {
169  struct GNUNET_MY_QueryParam res = {
170  .conv = &my_conv_uint16,
171  .cleaner = NULL,
172  .conv_cls = NULL,
173  .num_params = 1,
174  .data = x,
175  .data_len = sizeof(*x)
176  };
177 
178  return res;
179 }
static int my_conv_uint16(void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Function called to convert input argument into SQL parameters.

◆ GNUNET_MY_query_param_uint32()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint32 ( const uint32_t *  x)

Generate query parameter for an uint32_t in host byte order.

Parameters
xpointer to the query parameter to pass

Definition at line 191 of file my_query_helper.c.

212 {
213  struct GNUNET_MY_QueryParam res = {
214  .conv = &my_conv_uint32,
215  .cleaner = NULL,
216  .conv_cls = NULL,
217  .num_params = 1,
218  .data = x,
219  .data_len = sizeof(*x)
220  };
221 
222  return res;
223 }
static int my_conv_uint32(void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Function called to convert input argument into SQL parameters.

Referenced by mysql_plugin_get_key(), mysql_plugin_get_replication(), mysql_plugin_get_zero_anonymity(), mysql_plugin_put(), and regex_iterator().

Here is the caller graph for this function:

◆ GNUNET_MY_query_param_uint64()

struct GNUNET_MY_QueryParam GNUNET_MY_query_param_uint64 ( const uint64_t *  x)

Generate query parameter for an uint64_t in host byte order.

Parameters
xpointer to the query parameter to pass

Definition at line 235 of file my_query_helper.c.

256 {
257  struct GNUNET_MY_QueryParam res = {
258  .conv = &my_conv_uint64,
259  .cleaner = NULL,
260  .conv_cls = NULL,
261  .num_params = 1,
262  .data = x,
263  .data_len = sizeof(*x)
264  };
265 
266  return res;
267 }
static int my_conv_uint64(void *cls, const struct GNUNET_MY_QueryParam *qp, MYSQL_BIND *qbind)
Function called to convert input argument into SQL parameters.

Referenced by do_delete_entry(), mysql_plugin_get_key(), mysql_plugin_get_replication(), mysql_plugin_get_zero_anonymity(), mysql_plugin_put(), and repl_proc().

Here is the caller graph for this function:

◆ GNUNET_MY_result_spec_variable_size()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_variable_size ( void **  dst,
size_t *  ptr_size 
)

Variable-size result expected.

Parameters
[out]dstwhere to store the result, allocated
[out]ptr_sizewhere to store the size of dst
Returns
array entry for the result specification to use

Definition at line 120 of file my_result_helper.c.

136 {
137  struct GNUNET_MY_ResultSpec res = {
138  .pre_conv = &pre_extract_varsize_blob,
139  .post_conv = &post_extract_varsize_blob,
140  .cleaner = &cleanup_varsize_blob,
141  .dst = (void *) (dst),
142  .result_size = ptr_size,
143  .num_fields = 1
144  };
145 
146  return res;
147 }
static int pre_extract_varsize_blob(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
extract data from a Mysql database result at row row
static int post_extract_varsize_blob(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
extract data from a Mysql database result at row row
static void cleanup_varsize_blob(void *cls, struct GNUNET_MY_ResultSpec *rs)
extract data from a Mysql database result at row row
void * dst
Destination for the data.

Referenced by execute_select().

Here is the caller graph for this function:

◆ GNUNET_MY_result_spec_rsa_public_key()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_rsa_public_key ( struct GNUNET_CRYPTO_RsaPublicKey **  rsa)

RSA public key expected.

Parameters
namename of the field in the table
[out]rsawhere to store the result
Returns
array entry for the result specification to use

Definition at line 331 of file my_result_helper.c.

353 {
354  struct GNUNET_MY_ResultSpec res = {
355  .pre_conv = &pre_extract_rsa_public_key,
356  .post_conv = &post_extract_rsa_public_key,
357  .cleaner = &clean_rsa_public_key,
358  .dst = (void *) rsa,
359  .dst_size = 0,
360  .num_fields = 1
361  };
362 
363  return res;
364 }
static int pre_extract_rsa_public_key(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a Mysql database result at row row.
static void clean_rsa_public_key(void *cls, struct GNUNET_MY_ResultSpec *rs)
Function called to clean up memory allocated by a GNUNET_MY_ResultConverter.
static int post_extract_rsa_public_key(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Check size of extracted fixed size data from a Mysql database result at row row.
size_t dst_size
Allowed size for the data, 0 for variable-size (in this case, the type of dst is a void ** and we nee...
unsigned int num_fields
How many fields does this result specification occupy in the result returned by MySQL.

◆ GNUNET_MY_result_spec_rsa_signature()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_rsa_signature ( struct GNUNET_CRYPTO_RsaSignature **  sig)

RSA signature expected.

Parameters
[out]sigwhere to store the result;
Returns
array entry for the result specification to use

Definition at line 462 of file my_result_helper.c.

483 {
484  struct GNUNET_MY_ResultSpec res = {
485  .pre_conv = &pre_extract_rsa_signature,
486  .post_conv = &post_extract_rsa_signature,
487  .cleaner = &clean_rsa_signature,
488  .dst = (void *) sig,
489  .dst_size = 0,
490  .num_fields = 1
491  };
492 
493  return res;
494 }
static int post_extract_rsa_signature(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a Mysql database result at row row.
static void clean_rsa_signature(void *cls, struct GNUNET_MY_ResultSpec *rs)
Function called to clean up memory allocated by a GNUNET_MY_ResultConverter.
static int pre_extract_rsa_signature(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a Mysql database result at row row.

◆ GNUNET_MY_result_spec_string()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_string ( char **  dst)

0- terminated string exprected.

Parameters
[out]dstwhere to store the result, allocated
Returns
array entry for the result specification to use

Definition at line 540 of file my_result_helper.c.

585 {
586  struct GNUNET_MY_ResultSpec res = {
587  .pre_conv = &pre_extract_string,
588  .post_conv = &post_extract_string,
589  .cleaner = NULL,
590  .dst = (void *) dst,
591  .dst_size = 0,
592  .num_fields = 1
593  };
594 
595  return res;
596 }
static int post_extract_string(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Check size of extracted fixed size data from a Mysql database.
static int pre_extract_string(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a Mysql database result at row row.

◆ GNUNET_MY_result_spec_absolute_time()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_absolute_time ( struct GNUNET_TIME_Absolute at)

Absolute time expected.

Parameters
namename of the field in the table
[out]atwhere to store the result
Returns
array entry for the result specification to use

Definition at line 540 of file my_result_helper.c.

608 {
610 }
struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint64(uint64_t *u64)
uint64_t expected.

References buf, GNUNET_MY_ResultSpec::dst, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::mysql_bind_output_length, results, and size.

Referenced by execute_select().

Here is the caller graph for this function:

◆ GNUNET_MY_result_spec_absolute_time_nbo()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_absolute_time_nbo ( struct GNUNET_TIME_AbsoluteNBO at)

Absolute time in network byte order expected.

Parameters
[out]atwhere to store the result
Returns
array entry for the result specification to use

Definition at line 540 of file my_result_helper.c.

621 {
622  struct GNUNET_MY_ResultSpec res =
624 
625  return res;
626 }
#define GNUNET_MY_result_spec_auto_from_type(dst)
We expect a fixed-size result, with size determined by the type of * dst

◆ GNUNET_MY_result_spec_uint16()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint16 ( uint16_t *  u16)

uint16_t expected

Parameters
[out]u16where to store the result
Returns
array entry for the result specification to use

Definition at line 672 of file my_result_helper.c.

694 {
695  struct GNUNET_MY_ResultSpec res = {
696  .pre_conv = &pre_extract_uint16,
697  .post_conv = &post_extract_uint16,
698  .cleaner = NULL,
699  .dst = (void *) u16,
700  .dst_size = sizeof(*u16),
701  .num_fields = 1
702  };
703 
704  return res;
705 }
static int pre_extract_uint16(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a Postgres database result at row row.
static int post_extract_uint16(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Check size of extracted fixed size data from a Mysql database.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::mysql_bind_output_length, and results.

◆ GNUNET_MY_result_spec_uint32()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint32 ( uint32_t *  u32)

uint32_t expected

Parameters
[out]u32where to store the result
Returns
array entry for the result specification to use

Definition at line 751 of file my_result_helper.c.

773 {
774  struct GNUNET_MY_ResultSpec res = {
775  .pre_conv = &pre_extract_uint32,
776  .post_conv = &post_extract_uint32,
777  .cleaner = NULL,
778  .dst = (void *) u32,
779  .dst_size = sizeof(*u32),
780  .num_fields = 1
781  };
782 
783  return res;
784 }
static int pre_extract_uint32(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a MYSQL database result at row row.
static int post_extract_uint32(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a MYSQL database result at row row.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::mysql_bind_output_length, and results.

Referenced by execute_select(), and mysql_plugin_get_replication().

Here is the caller graph for this function:

◆ GNUNET_MY_result_spec_uint64()

struct GNUNET_MY_ResultSpec GNUNET_MY_result_spec_uint64 ( uint64_t *  u64)

uint64_t expected.

Parameters
[out]u64where to store the result
Returns
array entry for the result specification to use

Definition at line 832 of file my_result_helper.c.

854 {
855  struct GNUNET_MY_ResultSpec res = {
856  .pre_conv = &pre_extract_uint64,
857  .post_conv = &post_extract_uint64,
858  .cleaner = NULL,
859  .dst = (void *) u64,
860  .dst_size = sizeof(*u64),
861  .num_fields = 1
862  };
863 
864  return res;
865 }
static int post_extract_uint64(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Check size of extracted fixed-size data from a Mysql database.
static int pre_extract_uint64(void *cls, struct GNUNET_MY_ResultSpec *rs, MYSQL_STMT *stmt, unsigned int column, MYSQL_BIND *results)
Extract data from a MYSQL database result at row row.

References GNUNET_MY_ResultSpec::dst_size, GNUNET_OK, GNUNET_SYSERR, and results.

Referenced by execute_select(), mysql_plugin_estimate_size(), and regex_iterator().

Here is the caller graph for this function:

◆ GNUNET_MY_extract_result()

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.

Always fetches the next row.

Parameters
shstatement that returned results
rsspecification to extract for
Returns
GNUNET_YES if all results could be extracted GNUNET_NO if there is no more data in the result set GNUNET_SYSERR if a result was invalid

Definition at line 137 of file my.c.

139 {
140  unsigned int num_fields;
141  int ret;
142  MYSQL_STMT *stmt;
143 
145  if (NULL == stmt)
146  {
147  GNUNET_break (0);
148  return GNUNET_SYSERR;
149  }
150  if (NULL == rs)
151  {
152  mysql_stmt_free_result (stmt);
153  return GNUNET_NO;
154  }
155 
156  num_fields = 0;
157  for (unsigned int i = 0; NULL != rs[i].pre_conv; i++)
158  num_fields += rs[i].num_fields;
159 
160  if (mysql_stmt_field_count (stmt) != num_fields)
161  {
163  "Number of fields mismatch between SQL result and result specification\n");
164  return GNUNET_SYSERR;
165  }
166 
167  {
168  MYSQL_BIND result[num_fields];
169  unsigned int field_off;
170 
171  memset (result, 0, sizeof(MYSQL_BIND) * num_fields);
172  field_off = 0;
173  for (unsigned int i = 0; NULL != rs[i].pre_conv; i++)
174  {
175  struct GNUNET_MY_ResultSpec *rp = &rs[i];
176 
177  if (GNUNET_OK !=
178  rp->pre_conv (rp->conv_cls,
179  rp,
180  stmt,
181  field_off,
182  &result[field_off]))
183 
184  {
186  "Pre-conversion for MySQL result failed at offset %u\n",
187  i);
188  return GNUNET_SYSERR;
189  }
190  field_off += rp->num_fields;
191  }
192 
193  if (mysql_stmt_bind_result (stmt, result))
194  {
196  "my",
197  _ ("%s failed at %s:%d with error: %s\n"),
198  "mysql_stmt_bind_result",
199  __FILE__, __LINE__,
200  mysql_stmt_error (stmt));
201  return GNUNET_SYSERR;
202  }
203 #if TEST_OPTIMIZATION
204  (void) mysql_stmt_store_result (stmt);
205 #endif
206  ret = mysql_stmt_fetch (stmt);
207  if (MYSQL_NO_DATA == ret)
208  {
209  mysql_stmt_free_result (stmt);
210  return GNUNET_NO;
211  }
212  if (1 == ret)
213  {
215  "my",
216  _ ("%s failed at %s:%d with error: %s\n"),
217  "mysql_stmt_fetch",
218  __FILE__, __LINE__,
219  mysql_stmt_error (stmt));
221  mysql_stmt_free_result (stmt);
222  return GNUNET_SYSERR;
223  }
224  field_off = 0;
225  for (unsigned int i = 0; NULL != rs[i].post_conv; i++)
226  {
227  struct GNUNET_MY_ResultSpec *rp = &rs[i];
228 
229  if (NULL != rp->post_conv)
230  if (GNUNET_OK !=
231  rp->post_conv (rp->conv_cls,
232  rp,
233  stmt,
234  field_off,
235  &result[field_off]))
236  {
238  "Post-conversion for MySQL result failed at offset %u\n",
239  i);
240  mysql_stmt_free_result (stmt);
241  for (unsigned int j = 0; j < i; j++)
242  if (NULL != rs[j].cleaner)
243  rs[j].cleaner (rs[j].conv_cls,
244  rs[j].dst);
245  return GNUNET_SYSERR;
246  }
247  field_off += rp->num_fields;
248  }
249  }
250  return GNUNET_OK;
251 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char * rp
Relying party.
static int result
Global testing status.
@ GNUNET_NO
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_INFO
void GNUNET_MY_cleanup_result(struct GNUNET_MY_ResultSpec *rs)
Free all memory that was allocated in rs during GNUNET_MY_extract_result().
Definition: my.c:261
void * conv_cls
Closure for conv.
GNUNET_MY_ResultConverter post_conv
Function to call for converting the result.
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.

References _, GNUNET_MY_ResultSpec::cleaner, GNUNET_MY_ResultSpec::conv_cls, GNUNET_MY_ResultSpec::dst, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_log_from, GNUNET_MY_cleanup_result(), GNUNET_MYSQL_statement_get_stmt(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_MY_ResultSpec::post_conv, GNUNET_MY_ResultSpec::pre_conv, result, ret, rp, and sh.

Referenced by execute_select(), mysql_plugin_estimate_size(), mysql_plugin_get_keys(), mysql_plugin_get_replication(), mysql_plugin_put(), and regex_iterator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MY_cleanup_query()

void GNUNET_MY_cleanup_query ( struct GNUNET_MY_QueryParam qp,
MYSQL_BIND *  qbind 
)

Free all memory that was allocated in qp during #GNUNET_MY_exect_prepared().

Parameters
qpquery specification to clean up
qbindmysql query

Free all memory that was allocated in qp during #GNUNET_MY_exect_prepared().

Parameters
qpquery specification to clean up
qbindarray of parameter to clean up

Definition at line 115 of file my.c.

117 {
118  for (unsigned int i = 0; NULL != qp[i].conv; i++)
119  if (NULL != qp[i].cleaner)
120  qp[i].cleaner (qp[i].conv_cls,
121  &qbind[i]);
122 }
GNUNET_MY_QueryCleanup cleaner
Function to call for cleaning up the query.

References GNUNET_MY_QueryParam::cleaner, GNUNET_MY_QueryParam::conv, and GNUNET_MY_QueryParam::conv_cls.

Referenced by GNUNET_MY_exec_prepared().

Here is the caller graph for this function:

◆ GNUNET_MY_cleanup_result()

void GNUNET_MY_cleanup_result ( struct GNUNET_MY_ResultSpec rs)

Free all memory that was allocated in rs during GNUNET_MY_extract_result().

Parameters
rsreult specification to clean up
rsresult specification to clean up

Definition at line 261 of file my.c.

262 {
263  for (unsigned int i = 0; NULL != rs[i].post_conv; i++)
264  if (NULL != rs[i].cleaner)
265  rs[i].cleaner (rs[i].conv_cls,
266  &rs[i]);
267 }

References GNUNET_MY_ResultSpec::cleaner, GNUNET_MY_ResultSpec::conv_cls, and GNUNET_MY_ResultSpec::post_conv.

Referenced by execute_select(), and GNUNET_MY_extract_result().

Here is the caller graph for this function:

◆ GNUNET_MYSQL_context_create()

struct GNUNET_MYSQL_Context* GNUNET_MYSQL_context_create ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  section 
)

Create a mysql context.

Parameters
cfgconfiguration
sectionconfiguration section to use to get MySQL configuration options
Returns
the mysql context

Definition at line 321 of file mysql.c.

323 {
324  struct GNUNET_MYSQL_Context *mc;
325 
327  mc->cfg = cfg;
328  mc->section = section;
329  mc->cnffile = get_my_cnf_path (cfg, section);
330 
331  return mc;
332 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static char * get_my_cnf_path(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Obtain the location of ".my.cnf".
Definition: mysql.c:155
Mysql context.
Definition: mysql.c:77
const char * section
Our section.
Definition: mysql.c:86
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration to use while connecting to controller.
Definition: testbed_api.h:213

References cfg, GNUNET_TESTBED_Controller::cfg, get_my_cnf_path(), GNUNET_new, mc, and GNUNET_MYSQL_Context::section.

Referenced by libgnunet_plugin_datastore_mysql_init(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MYSQL_context_destroy()

void GNUNET_MYSQL_context_destroy ( struct GNUNET_MYSQL_Context mc)

Destroy a mysql context.

Also frees all associated prepared statements.

Parameters
mccontext to destroy

Definition at line 369 of file mysql.c.

370 {
372 
374  while (NULL != (sh = mc->shead))
375  {
376  GNUNET_CONTAINER_DLL_remove (mc->shead, mc->stail, sh);
377  GNUNET_free (sh->query);
378  GNUNET_free (sh);
379  }
380  GNUNET_free (mc);
381  mysql_library_end ();
382 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Handle for a prepared statement.
Definition: mysql.c:114

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MYSQL_statements_invalidate(), mc, and sh.

Referenced by do_shutdown(), libgnunet_plugin_datastore_mysql_done(), and libgnunet_plugin_datastore_mysql_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MYSQL_statements_invalidate()

void GNUNET_MYSQL_statements_invalidate ( struct GNUNET_MYSQL_Context mc)

Close database connection and all prepared statements (we got a DB error).

The connection will automatically be re-opened and statements will be re-prepared if they are needed again later.

Parameters
mcmysql context
mcmysql context

Definition at line 342 of file mysql.c.

343 {
345 
346  for (sh = mc->shead; NULL != sh; sh = sh->next)
347  {
348  if (GNUNET_YES == sh->valid)
349  {
350  mysql_stmt_close (sh->statement);
351  sh->valid = GNUNET_NO;
352  }
353  sh->statement = NULL;
354  }
355  if (NULL != mc->dbf)
356  {
357  mysql_close (mc->dbf);
358  mc->dbf = NULL;
359  }
360 }
@ GNUNET_YES

References GNUNET_NO, GNUNET_YES, mc, and sh.

Referenced by GNUNET_MY_exec_prepared(), GNUNET_MYSQL_context_destroy(), GNUNET_MYSQL_statement_run(), mysql_plugin_get_keys(), and prepare_statement().

Here is the caller graph for this function:

◆ GNUNET_MYSQL_statement_get_stmt()

MYSQL_STMT* GNUNET_MYSQL_statement_get_stmt ( struct GNUNET_MYSQL_StatementHandle sh)

Get internal handle for a prepared statement.

This function should rarely be used, and if, with caution! On failures during the interaction with the handle, you must call GNUNET_MYSQL_statements_invalidate()!

Parameters
shprepared statement to introspect
Returns
MySQL statement handle, NULL on error

This function should rarely be used, and if, with caution! On failures during the interaction with the handle, you must call 'GNUNET_MYSQL_statements_invalidate'!

Parameters
shprepared statement to introspect
Returns
MySQL statement handle, NULL on error

Definition at line 478 of file mysql.c.

479 {
480  (void) prepare_statement (sh);
481  return sh->statement;
482 }
static int prepare_statement(struct GNUNET_MYSQL_StatementHandle *sh)
Prepare a statement for running.
Definition: mysql.c:438

References prepare_statement(), and sh.

Referenced by GNUNET_MY_exec_prepared(), GNUNET_MY_extract_result(), mysql_plugin_get_keys(), mysql_plugin_put(), and mysql_plugin_remove_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MYSQL_statement_prepare()

struct GNUNET_MYSQL_StatementHandle* GNUNET_MYSQL_statement_prepare ( struct GNUNET_MYSQL_Context mc,
const char *  query 
)

Prepare a statement.

Prepared statements are automatically discarded when the MySQL context is destroyed.

Parameters
mcmysql context
queryquery text
Returns
prepared statement, NULL on error

Definition at line 394 of file mysql.c.

396 {
398 
400  sh->mc = mc;
401  sh->query = GNUNET_strdup (query);
402  GNUNET_CONTAINER_DLL_insert (mc->shead, mc->stail, sh);
403  return sh;
404 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
char * query
Original query string.
Definition: mysql.c:133

References GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_strdup, mc, GNUNET_MYSQL_StatementHandle::query, and sh.

Referenced by do_directory_scan().

Here is the caller graph for this function:

◆ GNUNET_MYSQL_statement_run()

int GNUNET_MYSQL_statement_run ( struct GNUNET_MYSQL_Context mc,
const char *  sql 
)

Run a SQL statement.

Parameters
mcmysql context
sqlSQL statement to run
Returns
GNUNET_OK on success GNUNET_SYSERR if there was a problem

Definition at line 416 of file mysql.c.

417 {
418  if ((NULL == mc->dbf) && (GNUNET_OK != iopen (mc)))
419  return GNUNET_SYSERR;
420  mysql_query (mc->dbf, sql);
421  if (mysql_error (mc->dbf)[0])
422  {
423  LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_query", mc);
425  return GNUNET_SYSERR;
426  }
427  return GNUNET_OK;
428 }
static int iopen(struct GNUNET_MYSQL_Context *mc)
Open the connection with the database (and initialize our default options).
Definition: mysql.c:217
#define LOG_MYSQL(level, cmd, dbh)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' on file 'file...
Definition: mysql.c:60

References GNUNET_ERROR_TYPE_ERROR, GNUNET_MYSQL_statements_invalidate(), GNUNET_OK, GNUNET_SYSERR, iopen(), LOG_MYSQL, and mc.

Referenced by mysql_plugin_drop().

Here is the call graph for this function:
Here is the caller graph for this function: