aboutsummaryrefslogtreecommitdiff
path: root/src/mysql
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/mysql
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/mysql')
-rw-r--r--src/mysql/mysql.c347
1 files changed, 174 insertions, 173 deletions
diff --git a/src/mysql/mysql.c b/src/mysql/mysql.c
index 918d24cf2..76effd95a 100644
--- a/src/mysql/mysql.c
+++ b/src/mysql/mysql.c
@@ -1,4 +1,3 @@
1
2/* 1/*
3 This file is part of GNUnet 2 This file is part of GNUnet
4 Copyright (C) 2012 GNUnet e.V. 3 Copyright (C) 2012 GNUnet e.V.
@@ -41,16 +40,16 @@
41 */ 40 */
42#define DIE_MYSQL(cmd, dbh) \ 41#define DIE_MYSQL(cmd, dbh) \
43 do \ 42 do \
44 { \ 43 { \
45 GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, \ 44 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \
46 "mysql", \ 45 "mysql", \
47 _("`%s' failed at %s:%d with error: %s\n"), \ 46 _ ("`%s' failed at %s:%d with error: %s\n"), \
48 cmd, \ 47 cmd, \
49 __FILE__, \ 48 __FILE__, \
50 __LINE__, \ 49 __LINE__, \
51 mysql_error((dbh)->dbf)); \ 50 mysql_error ((dbh)->dbf)); \
52 GNUNET_assert(0); \ 51 GNUNET_assert (0); \
53 } while (0); 52 } while (0);
54 53
55/** 54/**
56 * Log an error message at log-level 'level' that indicates 55 * Log an error message at log-level 'level' that indicates
@@ -59,21 +58,22 @@
59 */ 58 */
60#define LOG_MYSQL(level, cmd, dbh) \ 59#define LOG_MYSQL(level, cmd, dbh) \
61 do \ 60 do \
62 { \ 61 { \
63 GNUNET_log_from(level, \ 62 GNUNET_log_from (level, \
64 "mysql", \ 63 "mysql", \
65 _("`%s' failed at %s:%d with error: %s\n"), \ 64 _ ("`%s' failed at %s:%d with error: %s\n"), \
66 cmd, \ 65 cmd, \
67 __FILE__, \ 66 __FILE__, \
68 __LINE__, \ 67 __LINE__, \
69 mysql_error((dbh)->dbf)); \ 68 mysql_error ((dbh)->dbf)); \
70 } while (0); 69 } while (0);
71 70
72 71
73/** 72/**
74 * Mysql context. 73 * Mysql context.
75 */ 74 */
76struct GNUNET_MYSQL_Context { 75struct GNUNET_MYSQL_Context
76{
77 /** 77 /**
78 * Our configuration. 78 * Our configuration.
79 */ 79 */
@@ -109,7 +109,8 @@ struct GNUNET_MYSQL_Context {
109/** 109/**
110 * Handle for a prepared statement. 110 * Handle for a prepared statement.
111 */ 111 */
112struct GNUNET_MYSQL_StatementHandle { 112struct GNUNET_MYSQL_StatementHandle
113{
113 /** 114 /**
114 * Kept in a DLL. 115 * Kept in a DLL.
115 */ 116 */
@@ -150,8 +151,8 @@ struct GNUNET_MYSQL_StatementHandle {
150 * @return NULL on error 151 * @return NULL on error
151 */ 152 */
152static char * 153static char *
153get_my_cnf_path(const struct GNUNET_CONFIGURATION_Handle *cfg, 154get_my_cnf_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
154 const char *section) 155 const char *section)
155{ 156{
156 char *cnffile; 157 char *cnffile;
157 char *home_dir; 158 char *home_dir;
@@ -161,45 +162,45 @@ get_my_cnf_path(const struct GNUNET_CONFIGURATION_Handle *cfg,
161 162
162 int configured; 163 int configured;
163 164
164 pw = getpwuid(getuid()); 165 pw = getpwuid (getuid ());
165 if (!pw) 166 if (! pw)
166 { 167 {
167 GNUNET_log_from_strerror(GNUNET_ERROR_TYPE_ERROR, "mysql", "getpwuid"); 168 GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_ERROR, "mysql", "getpwuid");
168 return NULL; 169 return NULL;
169 } 170 }
170 if (GNUNET_YES == GNUNET_CONFIGURATION_have_value(cfg, section, "CONFIG")) 171 if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, section, "CONFIG"))
171 { 172 {
172 GNUNET_assert(GNUNET_OK == 173 GNUNET_assert (GNUNET_OK ==
173 GNUNET_CONFIGURATION_get_value_filename(cfg, 174 GNUNET_CONFIGURATION_get_value_filename (cfg,
174 section, 175 section,
175 "CONFIG", 176 "CONFIG",
176 &cnffile)); 177 &cnffile));
177 configured = GNUNET_YES; 178 configured = GNUNET_YES;
178 } 179 }
179 else 180 else
180 { 181 {
181 home_dir = GNUNET_strdup(pw->pw_dir); 182 home_dir = GNUNET_strdup (pw->pw_dir);
182 GNUNET_asprintf(&cnffile, "%s/.my.cnf", home_dir); 183 GNUNET_asprintf (&cnffile, "%s/.my.cnf", home_dir);
183 GNUNET_free(home_dir); 184 GNUNET_free (home_dir);
184 configured = GNUNET_NO; 185 configured = GNUNET_NO;
185 } 186 }
186 187
187 GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, 188 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
188 "mysql", 189 "mysql",
189 _("Trying to use file `%s' for MySQL configuration.\n"), 190 _ ("Trying to use file `%s' for MySQL configuration.\n"),
190 cnffile); 191 cnffile);
191 if ((0 != stat(cnffile, &st)) || (0 != access(cnffile, R_OK)) || 192 if ((0 != stat (cnffile, &st)) || (0 != access (cnffile, R_OK)) ||
192 (!S_ISREG(st.st_mode))) 193 (! S_ISREG (st.st_mode)))
193 { 194 {
194 if (configured == GNUNET_YES) 195 if (configured == GNUNET_YES)
195 GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, 196 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
196 "mysql", 197 "mysql",
197 _("Could not access file `%s': %s\n"), 198 _ ("Could not access file `%s': %s\n"),
198 cnffile, 199 cnffile,
199 strerror(errno)); 200 strerror (errno));
200 GNUNET_free(cnffile); 201 GNUNET_free (cnffile);
201 return NULL; 202 return NULL;
202 } 203 }
203 return cnffile; 204 return cnffile;
204} 205}
205 206
@@ -212,7 +213,7 @@ get_my_cnf_path(const struct GNUNET_CONFIGURATION_Handle *cfg,
212 * @return #GNUNET_OK on success 213 * @return #GNUNET_OK on success
213 */ 214 */
214static int 215static int
215iopen(struct GNUNET_MYSQL_Context *mc) 216iopen (struct GNUNET_MYSQL_Context *mc)
216{ 217{
217 char *mysql_dbname; 218 char *mysql_dbname;
218 char *mysql_server; 219 char *mysql_server;
@@ -222,88 +223,88 @@ iopen(struct GNUNET_MYSQL_Context *mc)
222 my_bool reconnect; 223 my_bool reconnect;
223 unsigned int timeout; 224 unsigned int timeout;
224 225
225 mc->dbf = mysql_init(NULL); 226 mc->dbf = mysql_init (NULL);
226 if (mc->dbf == NULL) 227 if (mc->dbf == NULL)
227 return GNUNET_SYSERR; 228 return GNUNET_SYSERR;
228 if (mc->cnffile != NULL) 229 if (mc->cnffile != NULL)
229 mysql_options(mc->dbf, MYSQL_READ_DEFAULT_FILE, mc->cnffile); 230 mysql_options (mc->dbf, MYSQL_READ_DEFAULT_FILE, mc->cnffile);
230 mysql_options(mc->dbf, MYSQL_READ_DEFAULT_GROUP, "client"); 231 mysql_options (mc->dbf, MYSQL_READ_DEFAULT_GROUP, "client");
231 reconnect = 0; 232 reconnect = 0;
232 mysql_options(mc->dbf, MYSQL_OPT_RECONNECT, &reconnect); 233 mysql_options (mc->dbf, MYSQL_OPT_RECONNECT, &reconnect);
233 mysql_options(mc->dbf, MYSQL_OPT_CONNECT_TIMEOUT, (const void *)&timeout); 234 mysql_options (mc->dbf, MYSQL_OPT_CONNECT_TIMEOUT, (const void *) &timeout);
234 mysql_options(mc->dbf, MYSQL_SET_CHARSET_NAME, "UTF8"); 235 mysql_options (mc->dbf, MYSQL_SET_CHARSET_NAME, "UTF8");
235 timeout = 60; /* in seconds */ 236 timeout = 60; /* in seconds */
236 mysql_options(mc->dbf, MYSQL_OPT_READ_TIMEOUT, (const void *)&timeout); 237 mysql_options (mc->dbf, MYSQL_OPT_READ_TIMEOUT, (const void *) &timeout);
237 mysql_options(mc->dbf, MYSQL_OPT_WRITE_TIMEOUT, (const void *)&timeout); 238 mysql_options (mc->dbf, MYSQL_OPT_WRITE_TIMEOUT, (const void *) &timeout);
238 mysql_dbname = NULL; 239 mysql_dbname = NULL;
239 if (GNUNET_YES == 240 if (GNUNET_YES ==
240 GNUNET_CONFIGURATION_have_value(mc->cfg, mc->section, "DATABASE")) 241 GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "DATABASE"))
241 GNUNET_assert(GNUNET_OK == 242 GNUNET_assert (GNUNET_OK ==
242 GNUNET_CONFIGURATION_get_value_string(mc->cfg, 243 GNUNET_CONFIGURATION_get_value_string (mc->cfg,
243 mc->section, 244 mc->section,
244 "DATABASE", 245 "DATABASE",
245 &mysql_dbname)); 246 &mysql_dbname));
246 else 247 else
247 mysql_dbname = GNUNET_strdup("gnunet"); 248 mysql_dbname = GNUNET_strdup ("gnunet");
248 mysql_user = NULL; 249 mysql_user = NULL;
249 if (GNUNET_YES == 250 if (GNUNET_YES ==
250 GNUNET_CONFIGURATION_have_value(mc->cfg, mc->section, "USER")) 251 GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "USER"))
251 { 252 {
252 GNUNET_assert(GNUNET_OK == 253 GNUNET_assert (GNUNET_OK ==
253 GNUNET_CONFIGURATION_get_value_string(mc->cfg, 254 GNUNET_CONFIGURATION_get_value_string (mc->cfg,
254 mc->section, 255 mc->section,
255 "USER", 256 "USER",
256 &mysql_user)); 257 &mysql_user));
257 } 258 }
258 mysql_password = NULL; 259 mysql_password = NULL;
259 if (GNUNET_YES == 260 if (GNUNET_YES ==
260 GNUNET_CONFIGURATION_have_value(mc->cfg, mc->section, "PASSWORD")) 261 GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "PASSWORD"))
261 { 262 {
262 GNUNET_assert(GNUNET_OK == 263 GNUNET_assert (GNUNET_OK ==
263 GNUNET_CONFIGURATION_get_value_string(mc->cfg, 264 GNUNET_CONFIGURATION_get_value_string (mc->cfg,
264 mc->section, 265 mc->section,
265 "PASSWORD", 266 "PASSWORD",
266 &mysql_password)); 267 &mysql_password));
267 } 268 }
268 mysql_server = NULL; 269 mysql_server = NULL;
269 if (GNUNET_YES == 270 if (GNUNET_YES ==
270 GNUNET_CONFIGURATION_have_value(mc->cfg, mc->section, "HOST")) 271 GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "HOST"))
271 { 272 {
272 GNUNET_assert(GNUNET_OK == 273 GNUNET_assert (GNUNET_OK ==
273 GNUNET_CONFIGURATION_get_value_string(mc->cfg, 274 GNUNET_CONFIGURATION_get_value_string (mc->cfg,
274 mc->section, 275 mc->section,
275 "HOST", 276 "HOST",
276 &mysql_server)); 277 &mysql_server));
277 } 278 }
278 mysql_port = 0; 279 mysql_port = 0;
279 if (GNUNET_YES == 280 if (GNUNET_YES ==
280 GNUNET_CONFIGURATION_have_value(mc->cfg, mc->section, "PORT")) 281 GNUNET_CONFIGURATION_have_value (mc->cfg, mc->section, "PORT"))
281 { 282 {
282 GNUNET_assert(GNUNET_OK == 283 GNUNET_assert (GNUNET_OK ==
283 GNUNET_CONFIGURATION_get_value_number(mc->cfg, 284 GNUNET_CONFIGURATION_get_value_number (mc->cfg,
284 mc->section, 285 mc->section,
285 "PORT", 286 "PORT",
286 &mysql_port)); 287 &mysql_port));
287 } 288 }
288 289
289 GNUNET_assert(mysql_dbname != NULL); 290 GNUNET_assert (mysql_dbname != NULL);
290 mysql_real_connect(mc->dbf, 291 mysql_real_connect (mc->dbf,
291 mysql_server, 292 mysql_server,
292 mysql_user, 293 mysql_user,
293 mysql_password, 294 mysql_password,
294 mysql_dbname, 295 mysql_dbname,
295 (unsigned int)mysql_port, 296 (unsigned int) mysql_port,
296 NULL, 297 NULL,
297 CLIENT_IGNORE_SIGPIPE); 298 CLIENT_IGNORE_SIGPIPE);
298 GNUNET_free_non_null(mysql_server); 299 GNUNET_free_non_null (mysql_server);
299 GNUNET_free_non_null(mysql_user); 300 GNUNET_free_non_null (mysql_user);
300 GNUNET_free_non_null(mysql_password); 301 GNUNET_free_non_null (mysql_password);
301 GNUNET_free(mysql_dbname); 302 GNUNET_free (mysql_dbname);
302 if (mysql_error(mc->dbf)[0]) 303 if (mysql_error (mc->dbf)[0])
303 { 304 {
304 LOG_MYSQL(GNUNET_ERROR_TYPE_ERROR, "mysql_real_connect", mc); 305 LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_real_connect", mc);
305 return GNUNET_SYSERR; 306 return GNUNET_SYSERR;
306 } 307 }
307 return GNUNET_OK; 308 return GNUNET_OK;
308} 309}
309 310
@@ -316,15 +317,15 @@ iopen(struct GNUNET_MYSQL_Context *mc)
316 * @return the mysql context 317 * @return the mysql context
317 */ 318 */
318struct GNUNET_MYSQL_Context * 319struct GNUNET_MYSQL_Context *
319GNUNET_MYSQL_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg, 320GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
320 const char *section) 321 const char *section)
321{ 322{
322 struct GNUNET_MYSQL_Context *mc; 323 struct GNUNET_MYSQL_Context *mc;
323 324
324 mc = GNUNET_new(struct GNUNET_MYSQL_Context); 325 mc = GNUNET_new (struct GNUNET_MYSQL_Context);
325 mc->cfg = cfg; 326 mc->cfg = cfg;
326 mc->section = section; 327 mc->section = section;
327 mc->cnffile = get_my_cnf_path(cfg, section); 328 mc->cnffile = get_my_cnf_path (cfg, section);
328 329
329 return mc; 330 return mc;
330} 331}
@@ -337,24 +338,24 @@ GNUNET_MYSQL_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg,
337 * @param mc mysql context 338 * @param mc mysql context
338 */ 339 */
339void 340void
340GNUNET_MYSQL_statements_invalidate(struct GNUNET_MYSQL_Context *mc) 341GNUNET_MYSQL_statements_invalidate (struct GNUNET_MYSQL_Context *mc)
341{ 342{
342 struct GNUNET_MYSQL_StatementHandle *sh; 343 struct GNUNET_MYSQL_StatementHandle *sh;
343 344
344 for (sh = mc->shead; NULL != sh; sh = sh->next) 345 for (sh = mc->shead; NULL != sh; sh = sh->next)
346 {
347 if (GNUNET_YES == sh->valid)
345 { 348 {
346 if (GNUNET_YES == sh->valid) 349 mysql_stmt_close (sh->statement);
347 { 350 sh->valid = GNUNET_NO;
348 mysql_stmt_close(sh->statement);
349 sh->valid = GNUNET_NO;
350 }
351 sh->statement = NULL;
352 } 351 }
352 sh->statement = NULL;
353 }
353 if (NULL != mc->dbf) 354 if (NULL != mc->dbf)
354 { 355 {
355 mysql_close(mc->dbf); 356 mysql_close (mc->dbf);
356 mc->dbf = NULL; 357 mc->dbf = NULL;
357 } 358 }
358} 359}
359 360
360 361
@@ -364,19 +365,19 @@ GNUNET_MYSQL_statements_invalidate(struct GNUNET_MYSQL_Context *mc)
364 * @param mc context to destroy 365 * @param mc context to destroy
365 */ 366 */
366void 367void
367GNUNET_MYSQL_context_destroy(struct GNUNET_MYSQL_Context *mc) 368GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc)
368{ 369{
369 struct GNUNET_MYSQL_StatementHandle *sh; 370 struct GNUNET_MYSQL_StatementHandle *sh;
370 371
371 GNUNET_MYSQL_statements_invalidate(mc); 372 GNUNET_MYSQL_statements_invalidate (mc);
372 while (NULL != (sh = mc->shead)) 373 while (NULL != (sh = mc->shead))
373 { 374 {
374 GNUNET_CONTAINER_DLL_remove(mc->shead, mc->stail, sh); 375 GNUNET_CONTAINER_DLL_remove (mc->shead, mc->stail, sh);
375 GNUNET_free(sh->query); 376 GNUNET_free (sh->query);
376 GNUNET_free(sh); 377 GNUNET_free (sh);
377 } 378 }
378 GNUNET_free(mc); 379 GNUNET_free (mc);
379 mysql_library_end(); 380 mysql_library_end ();
380} 381}
381 382
382 383
@@ -389,15 +390,15 @@ GNUNET_MYSQL_context_destroy(struct GNUNET_MYSQL_Context *mc)
389 * @return prepared statement, NULL on error 390 * @return prepared statement, NULL on error
390 */ 391 */
391struct GNUNET_MYSQL_StatementHandle * 392struct GNUNET_MYSQL_StatementHandle *
392GNUNET_MYSQL_statement_prepare(struct GNUNET_MYSQL_Context *mc, 393GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc,
393 const char *query) 394 const char *query)
394{ 395{
395 struct GNUNET_MYSQL_StatementHandle *sh; 396 struct GNUNET_MYSQL_StatementHandle *sh;
396 397
397 sh = GNUNET_new(struct GNUNET_MYSQL_StatementHandle); 398 sh = GNUNET_new (struct GNUNET_MYSQL_StatementHandle);
398 sh->mc = mc; 399 sh->mc = mc;
399 sh->query = GNUNET_strdup(query); 400 sh->query = GNUNET_strdup (query);
400 GNUNET_CONTAINER_DLL_insert(mc->shead, mc->stail, sh); 401 GNUNET_CONTAINER_DLL_insert (mc->shead, mc->stail, sh);
401 return sh; 402 return sh;
402} 403}
403 404
@@ -411,17 +412,17 @@ GNUNET_MYSQL_statement_prepare(struct GNUNET_MYSQL_Context *mc,
411 * #GNUNET_SYSERR if there was a problem 412 * #GNUNET_SYSERR if there was a problem
412 */ 413 */
413int 414int
414GNUNET_MYSQL_statement_run(struct GNUNET_MYSQL_Context *mc, const char *sql) 415GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc, const char *sql)
415{ 416{
416 if ((NULL == mc->dbf) && (GNUNET_OK != iopen(mc))) 417 if ((NULL == mc->dbf) && (GNUNET_OK != iopen (mc)))
417 return GNUNET_SYSERR; 418 return GNUNET_SYSERR;
418 mysql_query(mc->dbf, sql); 419 mysql_query (mc->dbf, sql);
419 if (mysql_error(mc->dbf)[0]) 420 if (mysql_error (mc->dbf)[0])
420 { 421 {
421 LOG_MYSQL(GNUNET_ERROR_TYPE_ERROR, "mysql_query", mc); 422 LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_query", mc);
422 GNUNET_MYSQL_statements_invalidate(mc); 423 GNUNET_MYSQL_statements_invalidate (mc);
423 return GNUNET_SYSERR; 424 return GNUNET_SYSERR;
424 } 425 }
425 return GNUNET_OK; 426 return GNUNET_OK;
426} 427}
427 428
@@ -434,32 +435,32 @@ GNUNET_MYSQL_statement_run(struct GNUNET_MYSQL_Context *mc, const char *sql)
434 * @return #GNUNET_OK on success 435 * @return #GNUNET_OK on success
435 */ 436 */
436static int 437static int
437prepare_statement(struct GNUNET_MYSQL_StatementHandle *sh) 438prepare_statement (struct GNUNET_MYSQL_StatementHandle *sh)
438{ 439{
439 struct GNUNET_MYSQL_Context *mc = sh->mc; 440 struct GNUNET_MYSQL_Context *mc = sh->mc;
440 441
441 if (GNUNET_YES == sh->valid) 442 if (GNUNET_YES == sh->valid)
442 return GNUNET_OK; 443 return GNUNET_OK;
443 if ((NULL == mc->dbf) && (GNUNET_OK != iopen(mc))) 444 if ((NULL == mc->dbf) && (GNUNET_OK != iopen (mc)))
444 return GNUNET_SYSERR; 445 return GNUNET_SYSERR;
445 sh->statement = mysql_stmt_init(mc->dbf); 446 sh->statement = mysql_stmt_init (mc->dbf);
446 if (NULL == sh->statement) 447 if (NULL == sh->statement)
447 { 448 {
448 GNUNET_MYSQL_statements_invalidate(mc); 449 GNUNET_MYSQL_statements_invalidate (mc);
449 return GNUNET_SYSERR; 450 return GNUNET_SYSERR;
450 } 451 }
451 if (0 != mysql_stmt_prepare(sh->statement, sh->query, strlen(sh->query))) 452 if (0 != mysql_stmt_prepare (sh->statement, sh->query, strlen (sh->query)))
452 { 453 {
453 GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, 454 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
454 "mysql", 455 "mysql",
455 "prepare_statement: %s\n", 456 "prepare_statement: %s\n",
456 sh->query); 457 sh->query);
457 LOG_MYSQL(GNUNET_ERROR_TYPE_ERROR, "mysql_stmt_prepare", mc); 458 LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_stmt_prepare", mc);
458 mysql_stmt_close(sh->statement); 459 mysql_stmt_close (sh->statement);
459 sh->statement = NULL; 460 sh->statement = NULL;
460 GNUNET_MYSQL_statements_invalidate(mc); 461 GNUNET_MYSQL_statements_invalidate (mc);
461 return GNUNET_SYSERR; 462 return GNUNET_SYSERR;
462 } 463 }
463 sh->valid = GNUNET_YES; 464 sh->valid = GNUNET_YES;
464 return GNUNET_OK; 465 return GNUNET_OK;
465} 466}
@@ -474,9 +475,9 @@ prepare_statement(struct GNUNET_MYSQL_StatementHandle *sh)
474 * @return MySQL statement handle, NULL on error 475 * @return MySQL statement handle, NULL on error
475 */ 476 */
476MYSQL_STMT * 477MYSQL_STMT *
477GNUNET_MYSQL_statement_get_stmt(struct GNUNET_MYSQL_StatementHandle *sh) 478GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh)
478{ 479{
479 (void)prepare_statement(sh); 480 (void) prepare_statement (sh);
480 return sh->statement; 481 return sh->statement;
481} 482}
482 483