GNUnet  0.11.x
Data Structures | Macros | Typedefs | Functions
MySQL library

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

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...
 

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 my_bool MYSQL_BOOL
 
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 121 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 257 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 285 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 362 of file gnunet_my_lib.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 62 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 74 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 172 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 185 of file gnunet_my_lib.h.

◆ MYSQL_BOOL

typedef my_bool MYSQL_BOOL

Definition at line 47 of file gnunet_mysql_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 72 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 @oaran ptr_size number 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 56 of file my_query_helper.c.

80 {
81  struct GNUNET_MY_QueryParam qp = {
83  .cleaner = NULL,
84  .conv_cls = NULL,
85  .num_params = 1,
86  .data = ptr,
87  .data_len = (unsigned long) ptr_size
88  };
89 
90  return qp;
91 }
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:84
GNUNET_MY_QueryConverter conv
Function to call for the type conversion.
Definition: gnunet_my_lib.h:88

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 42 of file my.c.

45 {
46  const struct GNUNET_MY_QueryParam *p;
47  unsigned int num;
48  MYSQL_STMT *stmt;
49 
50  num = 0;
51  for (unsigned int i = 0; NULL != params[i].conv; i++)
52  num += params[i].num_params;
53  {
54  MYSQL_BIND qbind[num];
55  unsigned int off;
56 
57  memset (qbind,
58  0,
59  sizeof(qbind));
60  off = 0;
61  for (unsigned int i = 0; NULL != (p = &params[i])->conv; i++)
62  {
63  if (GNUNET_OK !=
64  p->conv (p->conv_cls,
65  p,
66  &qbind[off]))
67  {
69  "Conversion for MySQL query failed at offset %u\n",
70  i);
71  return GNUNET_SYSERR;
72  }
73  off += p->num_params;
74  }
76  if (mysql_stmt_bind_param (stmt,
77  qbind))
78  {
80  "my",
81  _ ("`%s' failed at %s:%d with error: %s\n"),
82  "mysql_stmt_bind_param",
83  __FILE__, __LINE__,
84  mysql_stmt_error (stmt));
86  return GNUNET_SYSERR;
87  }
88 
89  if (mysql_stmt_execute (stmt))
90  {
92  "my",
93  _ ("`%s' failed at %s:%d with error: %s\n"),
94  "mysql_stmt_execute", __FILE__, __LINE__,
95  mysql_stmt_error (stmt));
97  return GNUNET_SYSERR;
98  }
100  qbind);
101  }
102  return GNUNET_OK;
103 }
static struct SolverHandle * sh
static GstElement * conv
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
#define GNUNET_log(kind,...)
#define GNUNET_log_from(kind, comp,...)
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
@ 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:114
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:341
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
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 @oaran ptr_size number 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 200 of file my_result_helper.c.

225 {
226  struct GNUNET_MY_ResultSpec res = {
227  .pre_conv = &pre_extract_fixed_blob,
228  .post_conv = &post_extract_fixed_blob,
229  .cleaner = NULL,
230  .dst = (void *) (ptr),
231  .dst_size = ptr_size,
232  .num_fields = 1
233  };
234 
235  return res;
236 }
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 103 of file my_query_helper.c.

123 {
124  struct GNUNET_MY_QueryParam qp = {
125  .conv = &my_conv_string,
126  .cleaner = NULL,
127  .conv_cls = NULL,
128  .num_params = 1,
129  .data = ptr,
130  .data_len = strlen (ptr)
131  };
132 
133  return qp;
134 }
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 278 of file my_query_helper.c.

307 {
308  struct GNUNET_MY_QueryParam res = {
309  .conv = &my_conv_rsa_public_key,
310  .cleaner = &my_clean_query,
311  .conv_cls = NULL,
312  .num_params = 1,
313  .data = x,
314  .data_len = 0
315  };
316 
317  return res;
318 }
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 330 of file my_query_helper.c.

358 {
359  struct GNUNET_MY_QueryParam res = {
360  .conv = &my_conv_rsa_signature,
361  .cleaner = &my_clean_query,
362  .conv_cls = NULL,
363  .num_params = 1,
364  .data = (x),
365  .data_len = 0
366  };
367 
368  return res;
369 }
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 330 of file my_query_helper.c.

381 {
383 }
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 330 of file my_query_helper.c.

395 {
397 }
#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 146 of file my_query_helper.c.

167 {
168  struct GNUNET_MY_QueryParam res = {
169  .conv = &my_conv_uint16,
170  .cleaner = NULL,
171  .conv_cls = NULL,
172  .num_params = 1,
173  .data = x,
174  .data_len = sizeof(*x)
175  };
176 
177  return res;
178 }
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 190 of file my_query_helper.c.

211 {
212  struct GNUNET_MY_QueryParam res = {
213  .conv = &my_conv_uint32,
214  .cleaner = NULL,
215  .conv_cls = NULL,
216  .num_params = 1,
217  .data = x,
218  .data_len = sizeof(*x)
219  };
220 
221  return res;
222 }
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 234 of file my_query_helper.c.

255 {
256  struct GNUNET_MY_QueryParam res = {
257  .conv = &my_conv_uint64,
258  .cleaner = NULL,
259  .conv_cls = NULL,
260  .num_params = 1,
261  .data = x,
262  .data_len = sizeof(*x)
263  };
264 
265  return res;
266 }
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]sptrwhere to store the size of dst
Returns
array entru for the result specification to use
Parameters
[out]dstwhere to store the result, allocated
[out]ptr_sizewhere to store the size of dst
Returns
array entru for the result specification to use

Definition at line 119 of file my_result_helper.c.

142 {
143  struct GNUNET_MY_ResultSpec res = {
144  .pre_conv = &pre_extract_varsize_blob,
145  .post_conv = &post_extract_varsize_blob,
146  .cleaner = &cleanup_varsize_blob,
147  .dst = (void *) (dst),
148  .result_size = ptr_size,
149  .num_fields = 1
150  };
151 
152  return res;
153 }
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 337 of file my_result_helper.c.

359 {
360  struct GNUNET_MY_ResultSpec res = {
361  .pre_conv = &pre_extract_rsa_public_key,
362  .post_conv = &post_extract_rsa_public_key,
363  .cleaner = &clean_rsa_public_key,
364  .dst = (void *) rsa,
365  .dst_size = 0,
366  .num_fields = 1
367  };
368 
369  return res;
370 }
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 468 of file my_result_helper.c.

489 {
490  struct GNUNET_MY_ResultSpec res = {
491  .pre_conv = &pre_extract_rsa_signature,
492  .post_conv = &post_extract_rsa_signature,
493  .cleaner = &clean_rsa_signature,
494  .dst = (void *) sig,
495  .dst_size = 0,
496  .num_fields = 1
497  };
498 
499  return res;
500 }
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 546 of file my_result_helper.c.

591 {
592  struct GNUNET_MY_ResultSpec res = {
593  .pre_conv = &pre_extract_string,
594  .post_conv = &post_extract_string,
595  .cleaner = NULL,
596  .dst = (void *) dst,
597  .dst_size = 0,
598  .num_fields = 1
599  };
600 
601  return res;
602 }
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 546 of file my_result_helper.c.

614 {
616 }
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 546 of file my_result_helper.c.

627 {
628  struct GNUNET_MY_ResultSpec res =
630 
631  return res;
632 }
#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 678 of file my_result_helper.c.

700 {
701  struct GNUNET_MY_ResultSpec res = {
702  .pre_conv = &pre_extract_uint16,
703  .post_conv = &post_extract_uint16,
704  .cleaner = NULL,
705  .dst = (void *) u16,
706  .dst_size = sizeof(*u16),
707  .num_fields = 1
708  };
709 
710  return res;
711 }
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 759 of file my_result_helper.c.

781 {
782  struct GNUNET_MY_ResultSpec res = {
783  .pre_conv = &pre_extract_uint32,
784  .post_conv = &post_extract_uint32,
785  .cleaner = NULL,
786  .dst = (void *) u32,
787  .dst_size = sizeof(*u32),
788  .num_fields = 1
789  };
790 
791  return res;
792 }
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 840 of file my_result_helper.c.

862 {
863  struct GNUNET_MY_ResultSpec res = {
864  .pre_conv = &pre_extract_uint64,
865  .post_conv = &post_extract_uint64,
866  .cleaner = NULL,
867  .dst = (void *) u64,
868  .dst_size = sizeof(*u64),
869  .num_fields = 1
870  };
871 
872  return res;
873 }
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 136 of file my.c.

138 {
139  unsigned int num_fields;
140  int ret;
141  MYSQL_STMT *stmt;
142 
144  if (NULL == stmt)
145  {
146  GNUNET_break (0);
147  return GNUNET_SYSERR;
148  }
149  if (NULL == rs)
150  {
151  mysql_stmt_free_result (stmt);
152  return GNUNET_NO;
153  }
154 
155  num_fields = 0;
156  for (unsigned int i = 0; NULL != rs[i].pre_conv; i++)
157  num_fields += rs[i].num_fields;
158 
159  if (mysql_stmt_field_count (stmt) != num_fields)
160  {
162  "Number of fields mismatch between SQL result and result specification\n");
163  return GNUNET_SYSERR;
164  }
165 
166  {
167  MYSQL_BIND result[num_fields];
168  unsigned int field_off;
169 
170  memset (result, 0, sizeof(MYSQL_BIND) * num_fields);
171  field_off = 0;
172  for (unsigned int i = 0; NULL != rs[i].pre_conv; i++)
173  {
174  struct GNUNET_MY_ResultSpec *rp = &rs[i];
175 
176  if (GNUNET_OK !=
177  rp->pre_conv (rp->conv_cls,
178  rp,
179  stmt,
180  field_off,
181  &result[field_off]))
182 
183  {
185  "Pre-conversion for MySQL result failed at offset %u\n",
186  i);
187  return GNUNET_SYSERR;
188  }
189  field_off += rp->num_fields;
190  }
191 
192  if (mysql_stmt_bind_result (stmt, result))
193  {
195  "my",
196  _ ("%s failed at %s:%d with error: %s\n"),
197  "mysql_stmt_bind_result",
198  __FILE__, __LINE__,
199  mysql_stmt_error (stmt));
200  return GNUNET_SYSERR;
201  }
202 #if TEST_OPTIMIZATION
203  (void) mysql_stmt_store_result (stmt);
204 #endif
205  ret = mysql_stmt_fetch (stmt);
206  if (MYSQL_NO_DATA == ret)
207  {
208  mysql_stmt_free_result (stmt);
209  return GNUNET_NO;
210  }
211  if (1 == ret)
212  {
214  "my",
215  _ ("%s failed at %s:%d with error: %s\n"),
216  "mysql_stmt_fetch",
217  __FILE__, __LINE__,
218  mysql_stmt_error (stmt));
220  mysql_stmt_free_result (stmt);
221  return GNUNET_SYSERR;
222  }
223  field_off = 0;
224  for (unsigned int i = 0; NULL != rs[i].post_conv; i++)
225  {
226  struct GNUNET_MY_ResultSpec *rp = &rs[i];
227 
228  if (NULL != rp->post_conv)
229  if (GNUNET_OK !=
230  rp->post_conv (rp->conv_cls,
231  rp,
232  stmt,
233  field_off,
234  &result[field_off]))
235  {
237  "Post-conversion for MySQL result failed at offset %u\n",
238  i);
239  mysql_stmt_free_result (stmt);
240  for (unsigned int j = 0; j < i; j++)
241  if (NULL != rs[j].cleaner)
242  rs[j].cleaner (rs[j].conv_cls,
243  rs[j].dst);
244  return GNUNET_SYSERR;
245  }
246  field_off += rp->num_fields;
247  }
248  }
249  return GNUNET_OK;
250 }
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
Definition: gnunet_common.h:94
#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:260
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 114 of file my.c.

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

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 260 of file my.c.

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

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 320 of file mysql.c.

322 {
323  struct GNUNET_MYSQL_Context *mc;
324 
326  mc->cfg = cfg;
327  mc->section = section;
328  mc->cnffile = get_my_cnf_path (cfg, section);
329 
330  return mc;
331 }
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:154
Mysql context.
Definition: mysql.c:76
const char * section
Our section.
Definition: mysql.c:85
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 368 of file mysql.c.

369 {
371 
373  while (NULL != (sh = mc->shead))
374  {
375  GNUNET_CONTAINER_DLL_remove (mc->shead, mc->stail, sh);
376  GNUNET_free (sh->query);
377  GNUNET_free (sh);
378  }
379  GNUNET_free (mc);
380  mysql_library_end ();
381 }
#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:113

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 341 of file mysql.c.

342 {
344 
345  for (sh = mc->shead; NULL != sh; sh = sh->next)
346  {
347  if (GNUNET_YES == sh->valid)
348  {
349  mysql_stmt_close (sh->statement);
350  sh->valid = GNUNET_NO;
351  }
352  sh->statement = NULL;
353  }
354  if (NULL != mc->dbf)
355  {
356  mysql_close (mc->dbf);
357  mc->dbf = NULL;
358  }
359 }
@ GNUNET_YES
Definition: gnunet_common.h:97

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 393 of file mysql.c.

395 {
397 
399  sh->mc = mc;
400  sh->query = GNUNET_strdup (query);
401  GNUNET_CONTAINER_DLL_insert (mc->shead, mc->stail, sh);
402  return sh;
403 }
#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:132

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 415 of file mysql.c.

416 {
417  if ((NULL == mc->dbf) && (GNUNET_OK != iopen (mc)))
418  return GNUNET_SYSERR;
419  mysql_query (mc->dbf, sql);
420  if (mysql_error (mc->dbf)[0])
421  {
422  LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_query", mc);
424  return GNUNET_SYSERR;
425  }
426  return GNUNET_OK;
427 }
static int iopen(struct GNUNET_MYSQL_Context *mc)
Open the connection with the database (and initialize our default options).
Definition: mysql.c:216
#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:59

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: