diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-24 12:27:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-24 12:27:52 +0000 |
commit | 67edb6d2abc0b4a3b0d79bbd854a90218a81e2cc (patch) | |
tree | e111e9d7c1a6e1a0afb5b7ed4a7338171455db5e /src/datastore | |
parent | 8e2ad5ae986fefae627cb360d0a6b9167893c024 (diff) | |
download | gnunet-67edb6d2abc0b4a3b0d79bbd854a90218a81e2cc.tar.gz gnunet-67edb6d2abc0b4a3b0d79bbd854a90218a81e2cc.zip |
fixing compiler warnings...
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/plugin_datastore_mysql.c | 498 |
1 files changed, 173 insertions, 325 deletions
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index 5754e57dc..09dbdc5b6 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c | |||
@@ -227,19 +227,11 @@ static int | |||
227 | do_delete_entry (struct Plugin *plugin, unsigned long long uid) | 227 | do_delete_entry (struct Plugin *plugin, unsigned long long uid) |
228 | { | 228 | { |
229 | int ret; | 229 | int ret; |
230 | uint64_t uid64 = (uint64_t) uid; | ||
230 | 231 | ||
231 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting value %llu from gn090 table\n", | 232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
233 | "Deleting value %llu from gn090 table\n", | ||
232 | uid); | 234 | uid); |
233 | /* ret = GNUNET_MYSQL_statement_run_prepared (plugin->mc, | ||
234 | plugin->delete_entry_by_uid, | ||
235 | NULL, | ||
236 | MYSQL_TYPE_LONGLONG, | ||
237 | &uid, | ||
238 | GNUNET_YES, | ||
239 | -1); | ||
240 | |||
241 | */ | ||
242 | uint64_t uid64 = (uint64_t) uid; | ||
243 | 235 | ||
244 | struct GNUNET_MY_QueryParam params_delete[] = { | 236 | struct GNUNET_MY_QueryParam params_delete[] = { |
245 | GNUNET_MY_query_param_uint64 (&uid64), | 237 | GNUNET_MY_query_param_uint64 (&uid64), |
@@ -268,21 +260,11 @@ do_delete_entry (struct Plugin *plugin, unsigned long long uid) | |||
268 | * @return number of bytes used on disk | 260 | * @return number of bytes used on disk |
269 | */ | 261 | */ |
270 | static void | 262 | static void |
271 | mysql_plugin_estimate_size (void *cls, unsigned long long *estimate) | 263 | mysql_plugin_estimate_size (void *cls, |
264 | unsigned long long *estimate) | ||
272 | { | 265 | { |
273 | struct Plugin *plugin = cls; | 266 | struct Plugin *plugin = cls; |
274 | // MYSQL_BIND cbind[1]; | ||
275 | uint64_t total; | 267 | uint64_t total; |
276 | // long long total; | ||
277 | /* | ||
278 | if (NULL == estimate) | ||
279 | return; | ||
280 | memset (cbind, 0, sizeof (cbind)); | ||
281 | total = 0; | ||
282 | cbind[0].buffer_type = MYSQL_TYPE_LONGLONG; | ||
283 | cbind[0].buffer = &total; | ||
284 | cbind[0].is_unsigned = GNUNET_NO; | ||
285 | */ | ||
286 | struct GNUNET_MY_QueryParam params_get[] = { | 268 | struct GNUNET_MY_QueryParam params_get[] = { |
287 | GNUNET_MY_query_param_end | 269 | GNUNET_MY_query_param_end |
288 | }; | 270 | }; |
@@ -293,8 +275,6 @@ mysql_plugin_estimate_size (void *cls, unsigned long long *estimate) | |||
293 | }; | 275 | }; |
294 | int ret; | 276 | int ret; |
295 | 277 | ||
296 | // if (GNUNET_OK == | ||
297 | // GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->get_size, 1, cbind, NULL, NULL, -1)) | ||
298 | ret = GNUNET_MY_exec_prepared (plugin->mc, plugin->get_size, params_get); | 278 | ret = GNUNET_MY_exec_prepared (plugin->mc, plugin->get_size, params_get); |
299 | if (GNUNET_OK == ret) | 279 | if (GNUNET_OK == ret) |
300 | { | 280 | { |
@@ -303,7 +283,6 @@ mysql_plugin_estimate_size (void *cls, unsigned long long *estimate) | |||
303 | *estimate = (unsigned long long)total; | 283 | *estimate = (unsigned long long)total; |
304 | } | 284 | } |
305 | } | 285 | } |
306 | //*estimate = total; | ||
307 | else | 286 | else |
308 | *estimate = 0; | 287 | *estimate = 0; |
309 | } | 288 | } |
@@ -325,42 +304,27 @@ mysql_plugin_estimate_size (void *cls, unsigned long long *estimate) | |||
325 | * @param cont_cls continuation closure | 304 | * @param cont_cls continuation closure |
326 | */ | 305 | */ |
327 | static void | 306 | static void |
328 | mysql_plugin_put (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | 307 | mysql_plugin_put (void *cls, |
329 | const void *data, enum GNUNET_BLOCK_Type type, | 308 | const struct GNUNET_HashCode *key, |
330 | uint32_t priority, uint32_t anonymity, uint32_t replication, | 309 | uint32_t size, |
331 | struct GNUNET_TIME_Absolute expiration, PluginPutCont cont, | 310 | const void *data, |
311 | enum GNUNET_BLOCK_Type type, | ||
312 | uint32_t priority, | ||
313 | uint32_t anonymity, | ||
314 | uint32_t replication, | ||
315 | struct GNUNET_TIME_Absolute expiration, | ||
316 | PluginPutCont cont, | ||
332 | void *cont_cls) | 317 | void *cont_cls) |
333 | { | 318 | { |
334 | struct Plugin *plugin = cls; | 319 | struct Plugin *plugin = cls; |
335 | unsigned int irepl = replication; | 320 | unsigned int irepl = replication; |
336 | unsigned int ipriority = priority; | 321 | unsigned int ipriority = priority; |
337 | unsigned int ianonymity = anonymity; | 322 | unsigned int ianonymity = anonymity; |
338 | // unsigned long long lexpiration = expiration.abs_value_us; | ||
339 | uint64_t lexpiration = expiration.abs_value_us; | 323 | uint64_t lexpiration = expiration.abs_value_us; |
340 | 324 | uint64_t lrvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | |
341 | /* unsigned long long lrvalue = | 325 | UINT64_MAX); |
342 | (unsigned long long) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
343 | UINT64_MAX); | ||
344 | */ | ||
345 | uint64_t lrvalue = | ||
346 | (uint64_t) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
347 | UINT64_MAX); | ||
348 | unsigned long hashSize; | ||
349 | unsigned long hashSize2; | ||
350 | unsigned long lsize; | 326 | unsigned long lsize; |
351 | struct GNUNET_HashCode vhash; | 327 | struct GNUNET_HashCode vhash; |
352 | |||
353 | if (size > MAX_DATUM_SIZE) | ||
354 | { | ||
355 | GNUNET_break (0); | ||
356 | cont (cont_cls, key, size, GNUNET_SYSERR, _("Data too large")); | ||
357 | return; | ||
358 | } | ||
359 | hashSize = sizeof (struct GNUNET_HashCode); | ||
360 | hashSize2 = sizeof (struct GNUNET_HashCode); | ||
361 | lsize = size; | ||
362 | GNUNET_CRYPTO_hash (data, size, &vhash); | ||
363 | |||
364 | struct GNUNET_MY_QueryParam params_insert[] = { | 328 | struct GNUNET_MY_QueryParam params_insert[] = { |
365 | GNUNET_MY_query_param_uint32 (&irepl), | 329 | GNUNET_MY_query_param_uint32 (&irepl), |
366 | GNUNET_MY_query_param_uint32 (&type), | 330 | GNUNET_MY_query_param_uint32 (&type), |
@@ -368,28 +332,23 @@ mysql_plugin_put (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | |||
368 | GNUNET_MY_query_param_uint32 (&ianonymity), | 332 | GNUNET_MY_query_param_uint32 (&ianonymity), |
369 | GNUNET_MY_query_param_uint64 (&lexpiration), | 333 | GNUNET_MY_query_param_uint64 (&lexpiration), |
370 | GNUNET_MY_query_param_uint64 (&lrvalue), | 334 | GNUNET_MY_query_param_uint64 (&lrvalue), |
371 | GNUNET_MY_query_param_fixed_size (key, hashSize), | 335 | GNUNET_MY_query_param_auto_from_type (key), |
372 | GNUNET_MY_query_param_fixed_size (&vhash, hashSize2), | 336 | GNUNET_MY_query_param_auto_from_type (&vhash), |
373 | GNUNET_MY_query_param_fixed_size (data, lsize), | 337 | GNUNET_MY_query_param_fixed_size (data, lsize), |
374 | GNUNET_MY_query_param_end | 338 | GNUNET_MY_query_param_end |
375 | }; | 339 | }; |
376 | /* | 340 | |
377 | if (GNUNET_OK != | 341 | if (size > MAX_DATUM_SIZE) |
378 | GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->insert_entry, NULL, | ||
379 | MYSQL_TYPE_LONG, &irepl, GNUNET_YES, | ||
380 | MYSQL_TYPE_LONG, &type, GNUNET_YES, | ||
381 | MYSQL_TYPE_LONG, &ipriority, GNUNET_YES, | ||
382 | MYSQL_TYPE_LONG, &ianonymity, GNUNET_YES, | ||
383 | MYSQL_TYPE_LONGLONG, &lexpiration, GNUNET_YES, | ||
384 | MYSQL_TYPE_LONGLONG, &lrvalue, GNUNET_YES, | ||
385 | MYSQL_TYPE_BLOB, key, hashSize, &hashSize, | ||
386 | MYSQL_TYPE_BLOB, &vhash, hashSize2, &hashSize2, | ||
387 | MYSQL_TYPE_BLOB, data, lsize, &lsize, -1)) | ||
388 | { | 342 | { |
389 | cont (cont_cls, key, size, GNUNET_SYSERR, _("MySQL statement run failure")); | 343 | GNUNET_break (0); |
344 | cont (cont_cls, key, size, GNUNET_SYSERR, _("Data too large")); | ||
390 | return; | 345 | return; |
391 | } | 346 | } |
392 | */ | 347 | lsize = size; |
348 | GNUNET_CRYPTO_hash (data, | ||
349 | size, | ||
350 | &vhash); | ||
351 | |||
393 | if (GNUNET_OK != | 352 | if (GNUNET_OK != |
394 | GNUNET_MY_exec_prepared (plugin->mc, | 353 | GNUNET_MY_exec_prepared (plugin->mc, |
395 | plugin->insert_entry, | 354 | plugin->insert_entry, |
@@ -482,183 +441,81 @@ mysql_plugin_update (void *cls, uint64_t uid, int delta, | |||
482 | * @param stmt select statement to run | 441 | * @param stmt select statement to run |
483 | * @param proc function to call on result | 442 | * @param proc function to call on result |
484 | * @param proc_cls closure for proc | 443 | * @param proc_cls closure for proc |
485 | * @param ... arguments to initialize stmt | 444 | * @param params_select arguments to initialize stmt |
486 | */ | 445 | */ |
487 | static void | 446 | static void |
488 | execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt, | 447 | execute_select (struct Plugin *plugin, |
489 | PluginDatumProcessor proc, void *proc_cls, ...) | 448 | struct GNUNET_MYSQL_StatementHandle *stmt, |
449 | PluginDatumProcessor proc, | ||
450 | void *proc_cls, | ||
451 | struct GNUNET_MY_QueryParam *params_select) | ||
490 | { | 452 | { |
491 | va_list ap; | ||
492 | int ret; | 453 | int ret; |
493 | unsigned int type; | 454 | uint32_t type; |
494 | // unsigned int priority; | ||
495 | uint32_t priority; | 455 | uint32_t priority; |
496 | unsigned int anonymity; | 456 | uint32_t anonymity; |
497 | // unsigned long long exp; | ||
498 | uint64_t exp; | ||
499 | size_t hashSize; | ||
500 | // unsigned long size; | ||
501 | size_t size; | ||
502 | uint64_t uid; | 457 | uint64_t uid; |
458 | size_t value_size; | ||
503 | void *value; | 459 | void *value; |
504 | struct GNUNET_HashCode key; | 460 | struct GNUNET_HashCode key; |
505 | struct GNUNET_TIME_Absolute expiration; | 461 | struct GNUNET_TIME_Absolute expiration; |
506 | //MYSQL_BIND rbind[7]; | ||
507 | |||
508 | hashSize = sizeof (struct GNUNET_HashCode); | ||
509 | /* memset (rbind, 0, sizeof (rbind)); | ||
510 | rbind[0].buffer_type = MYSQL_TYPE_LONG; | ||
511 | rbind[0].buffer = &type; | ||
512 | rbind[0].is_unsigned = 1; | ||
513 | rbind[1].buffer_type = MYSQL_TYPE_LONG; | ||
514 | rbind[1].buffer = &priority; | ||
515 | rbind[1].is_unsigned = 1; | ||
516 | rbind[2].buffer_type = MYSQL_TYPE_LONG; | ||
517 | rbind[2].buffer = &anonymity; | ||
518 | rbind[2].is_unsigned = 1; | ||
519 | rbind[3].buffer_type = MYSQL_TYPE_LONGLONG; | ||
520 | rbind[3].buffer = &exp; | ||
521 | rbind[3].is_unsigned = 1; | ||
522 | rbind[4].buffer_type = MYSQL_TYPE_BLOB; | ||
523 | rbind[4].buffer = &key; | ||
524 | rbind[4].buffer_length = hashSize; | ||
525 | rbind[4].length = &hashSize; | ||
526 | rbind[5].buffer_type = MYSQL_TYPE_BLOB; | ||
527 | rbind[5].buffer = value; | ||
528 | rbind[5].buffer_length = size = sizeof (value); | ||
529 | rbind[5].length = &size; | ||
530 | rbind[6].buffer_type = MYSQL_TYPE_LONGLONG; | ||
531 | rbind[6].buffer = &uid; | ||
532 | rbind[6].is_unsigned = 1; | ||
533 | */ | ||
534 | // ret = GNUNET_MYSQL_statement_run_prepared_select_va (stmt, 7, rbind, NULL, NULL, ap); | ||
535 | va_start (ap, proc_cls); | ||
536 | |||
537 | int pc = 0; | ||
538 | |||
539 | struct GNUNET_MY_QueryParam *params_select = NULL; | ||
540 | |||
541 | unsigned int *param_long = NULL; | ||
542 | int param_is_unsigned; | ||
543 | unsigned long param_length; | ||
544 | unsigned long *length = NULL; | ||
545 | |||
546 | unsigned long long *param_longlong = NULL; | ||
547 | void *param_blob = NULL; | ||
548 | |||
549 | pc = mysql_stmt_param_count (stmt); | ||
550 | if (pc > MAX_PARAM) | ||
551 | { | ||
552 | GNUNET_break (0); | ||
553 | } | ||
554 | |||
555 | // enum enum_field_type ft; | ||
556 | int ft; | ||
557 | int j = 0; | ||
558 | |||
559 | ft = 0; | ||
560 | |||
561 | while ((pc > 0) && (-1 != (ft = va_arg(ap, int)))) | ||
562 | { | ||
563 | switch (ft) | ||
564 | { | ||
565 | case MYSQL_TYPE_LONGLONG: | ||
566 | param_longlong = va_arg (ap, unsigned long long *); | ||
567 | param_is_unsigned = va_arg (ap, int); | ||
568 | params_select[j] = GNUNET_MY_query_param_uint64 (param_longlong); | ||
569 | break; | ||
570 | |||
571 | case MYSQL_TYPE_LONG: | ||
572 | param_long = va_arg (ap, unsigned int*); | ||
573 | param_is_unsigned = va_arg (ap, int); | ||
574 | params_select[j] = GNUNET_MY_query_param_uint32 (param_long); | ||
575 | break; | ||
576 | |||
577 | case MYSQL_TYPE_VAR_STRING: | ||
578 | case MYSQL_TYPE_STRING: | ||
579 | case MYSQL_TYPE_BLOB: | ||
580 | param_blob = va_arg (ap, void *); | ||
581 | param_length = va_arg (ap, unsigned long); | ||
582 | length = va_arg (ap, unsigned long *); | ||
583 | //params_select[j] = GNUNET_MY_query_param_fixed_size (param_blob, param_length); | ||
584 | params_select[j] = GNUNET_MY_query_param_auto_from_type(&key); | ||
585 | |||
586 | break; | ||
587 | default: | ||
588 | GNUNET_break(0); | ||
589 | } | ||
590 | pc--; | ||
591 | j++; | ||
592 | } | ||
593 | |||
594 | /* | ||
595 | struct GNUNET_MY_ResultSpec results_select[] = { | 462 | struct GNUNET_MY_ResultSpec results_select[] = { |
596 | GNUNET_MY_result_spec_uint32 (&type), | 463 | GNUNET_MY_result_spec_uint32 (&type), |
597 | GNUNET_MY_result_spec_uint32 (&priority), | 464 | GNUNET_MY_result_spec_uint32 (&priority), |
598 | GNUNET_MY_result_spec_uint32 (&anonymity), | 465 | GNUNET_MY_result_spec_uint32 (&anonymity), |
599 | GNUNET_MY_result_spec_uint64 (&exp), | 466 | GNUNET_MY_result_spec_absolute_time (&expiration), |
600 | GNUNET_MY_result_spec_auto_from_type (&key), | 467 | GNUNET_MY_result_spec_auto_from_type (&key), |
601 | GNUNET_MY_result_spec_variable_size (&value, &size), | 468 | GNUNET_MY_result_spec_variable_size (&value, &value_size), |
602 | GNUNET_MY_result_spec_uint64 (&uid), | 469 | GNUNET_MY_result_spec_uint64 (&uid), |
603 | GNUNET_MY_query_param_end | 470 | GNUNET_MY_result_spec_end |
604 | }; | 471 | }; |
605 | */ | ||
606 | /* | ||
607 | 472 | ||
608 | !!!! FAIL HERE FOR SELECT QUERY | 473 | ret = GNUNET_MY_exec_prepared (plugin->mc, |
609 | */ ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select); | 474 | stmt, |
610 | 475 | params_select); | |
611 | if(GNUNET_OK != ret) | 476 | if (GNUNET_OK != ret) |
612 | { | ||
613 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
614 | return; | ||
615 | } | ||
616 | |||
617 | /* if (ret <= 0) | ||
618 | { | 477 | { |
619 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | 478 | proc (proc_cls, |
479 | NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
620 | return; | 480 | return; |
621 | } | 481 | } |
622 | 482 | ||
623 | va_end (ap); | 483 | ret = GNUNET_MY_extract_result (stmt, |
624 | 484 | results_select); | |
625 | /* | ||
626 | ret = GNUNET_MY_extract_result (stmt, results_select); | ||
627 | if (ret <= 0) | 485 | if (ret <= 0) |
628 | { | 486 | { |
629 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | 487 | proc (proc_cls, |
488 | NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
630 | return; | 489 | return; |
631 | } | 490 | } |
632 | 491 | ||
633 | GNUNET_assert (size <= sizeof (value)); | ||
634 | /* | ||
635 | if ((rbind[4].buffer_length != sizeof (struct GNUNET_HashCode)) || | ||
636 | (hashSize != sizeof (struct GNUNET_HashCode))) | ||
637 | { | ||
638 | |||
639 | expiration.abs_value_us = exp; | ||
640 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
641 | "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n", | 493 | "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n", |
642 | (unsigned int) size, GNUNET_h2s (&key), | 494 | (unsigned int) value_size, |
643 | priority, anonymity, | 495 | GNUNET_h2s (&key), |
496 | (unsigned int) priority, | ||
497 | (unsigned int) anonymity, | ||
644 | GNUNET_STRINGS_absolute_time_to_string (expiration)); | 498 | GNUNET_STRINGS_absolute_time_to_string (expiration)); |
645 | GNUNET_assert (size < MAX_DATUM_SIZE); | 499 | GNUNET_assert (value_size < MAX_DATUM_SIZE); |
646 | ret = | 500 | ret = proc (proc_cls, |
647 | proc (proc_cls, &key, size, value, type, priority, anonymity, expiration, | 501 | &key, |
648 | uid); | 502 | value_size, |
649 | */ | 503 | value, |
650 | 504 | type, | |
651 | /* if (ret == GNUNET_NO) | 505 | priority, |
506 | anonymity, | ||
507 | expiration, | ||
508 | uid); | ||
509 | if (ret == GNUNET_NO) | ||
652 | { | 510 | { |
653 | do_delete_entry (plugin, uid); | 511 | do_delete_entry (plugin, uid); |
654 | if (size != 0) | 512 | if (0 != value_size) |
655 | plugin->env->duc (plugin->env->cls, -size); | 513 | plugin->env->duc (plugin->env->cls, |
514 | - value_size); | ||
656 | } | 515 | } |
657 | */ | ||
658 | } | 516 | } |
659 | 517 | ||
660 | 518 | ||
661 | |||
662 | /** | 519 | /** |
663 | * Get one of the results for a particular key in the datastore. | 520 | * Get one of the results for a particular key in the datastore. |
664 | * | 521 | * |
@@ -675,34 +532,24 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt | |||
675 | * Use 0 for any type. | 532 | * Use 0 for any type. |
676 | * @param proc function to call on the matching value, | 533 | * @param proc function to call on the matching value, |
677 | * with NULL for if no value matches | 534 | * with NULL for if no value matches |
678 | * @param proc_cls closure for proc | 535 | * @param proc_cls closure for @a proc |
679 | */ | 536 | */ |
680 | static void | 537 | static void |
681 | mysql_plugin_get_key (void *cls, uint64_t offset, const struct GNUNET_HashCode * key, | 538 | mysql_plugin_get_key (void *cls, |
682 | const struct GNUNET_HashCode * vhash, | 539 | uint64_t offset, |
683 | enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, | 540 | const struct GNUNET_HashCode *key, |
541 | const struct GNUNET_HashCode *vhash, | ||
542 | enum GNUNET_BLOCK_Type type, | ||
543 | PluginDatumProcessor proc, | ||
684 | void *proc_cls) | 544 | void *proc_cls) |
685 | { | 545 | { |
686 | struct Plugin *plugin = cls; | 546 | struct Plugin *plugin = cls; |
687 | int ret; | 547 | int ret; |
688 | //MYSQL_BIND cbind[1]; | ||
689 | //long long total; | ||
690 | uint64_t total; | 548 | uint64_t total; |
691 | unsigned long hashSize; | 549 | unsigned long hashSize; |
692 | unsigned long hashSize2; | 550 | unsigned long hashSize2; |
693 | unsigned long long off; | ||
694 | 551 | ||
695 | GNUNET_assert (key != NULL); | ||
696 | GNUNET_assert (NULL != proc); | ||
697 | hashSize = sizeof (struct GNUNET_HashCode); | ||
698 | hashSize2 = sizeof (struct GNUNET_HashCode); | ||
699 | // memset (cbind, 0, sizeof (cbind)); | ||
700 | total = -1; | 552 | total = -1; |
701 | /* cbind[0].buffer_type = MYSQL_TYPE_LONGLONG; | ||
702 | cbind[0].buffer = &total; | ||
703 | cbind[0].is_unsigned = GNUNET_NO; | ||
704 | */ | ||
705 | |||
706 | struct GNUNET_MY_ResultSpec results_get[] = { | 553 | struct GNUNET_MY_ResultSpec results_get[] = { |
707 | GNUNET_MY_result_spec_uint64 (&total), | 554 | GNUNET_MY_result_spec_uint64 (&total), |
708 | GNUNET_MY_result_spec_end | 555 | GNUNET_MY_result_spec_end |
@@ -712,15 +559,6 @@ mysql_plugin_get_key (void *cls, uint64_t offset, const struct GNUNET_HashCode * | |||
712 | { | 559 | { |
713 | if (vhash != NULL) | 560 | if (vhash != NULL) |
714 | { | 561 | { |
715 | /* ret = | ||
716 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, | ||
717 | plugin-> | ||
718 | count_entry_by_hash_vhash_and_type, 1, | ||
719 | cbind, NULL, NULL, MYSQL_TYPE_BLOB, key, hashSize, | ||
720 | &hashSize, MYSQL_TYPE_BLOB, vhash, | ||
721 | hashSize2, &hashSize2, MYSQL_TYPE_LONG, | ||
722 | &type, GNUNET_YES, -1); | ||
723 | */ | ||
724 | struct GNUNET_MY_QueryParam params_get[] = { | 562 | struct GNUNET_MY_QueryParam params_get[] = { |
725 | GNUNET_MY_query_param_fixed_size (key, hashSize), | 563 | GNUNET_MY_query_param_fixed_size (key, hashSize), |
726 | GNUNET_MY_query_param_fixed_size (vhash, hashSize2), | 564 | GNUNET_MY_query_param_fixed_size (vhash, hashSize2), |
@@ -738,77 +576,54 @@ mysql_plugin_get_key (void *cls, uint64_t offset, const struct GNUNET_HashCode * | |||
738 | } | 576 | } |
739 | else | 577 | else |
740 | { | 578 | { |
741 | /* ret = | 579 | struct GNUNET_MY_QueryParam params_get[] = { |
742 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, | 580 | GNUNET_MY_query_param_fixed_size (key, hashSize), |
743 | plugin->count_entry_by_hash_and_type, | 581 | GNUNET_MY_query_param_uint32 (&type), |
744 | 1, cbind, NULL, NULL, MYSQL_TYPE_BLOB, key, | 582 | GNUNET_MY_query_param_end |
745 | hashSize, &hashSize, MYSQL_TYPE_LONG, | 583 | }; |
746 | &type, GNUNET_YES, -1); | 584 | |
747 | */ | 585 | ret = |
748 | struct GNUNET_MY_QueryParam params_get[] = { | 586 | GNUNET_MY_exec_prepared (plugin->mc, |
749 | GNUNET_MY_query_param_fixed_size (key, hashSize), | 587 | plugin->count_entry_by_hash_and_type, |
750 | GNUNET_MY_query_param_uint32 (&type), | 588 | params_get); |
751 | GNUNET_MY_query_param_end | 589 | ret = |
752 | }; | 590 | GNUNET_MY_extract_result (plugin->count_entry_by_hash_and_type, |
753 | 591 | results_get); | |
754 | |||
755 | ret = | ||
756 | GNUNET_MY_exec_prepared (plugin->mc, | ||
757 | plugin->count_entry_by_hash_and_type, | ||
758 | params_get); | ||
759 | ret = | ||
760 | GNUNET_MY_extract_result (plugin->count_entry_by_hash_and_type, | ||
761 | results_get); | ||
762 | } | 592 | } |
763 | } | 593 | } |
764 | else | 594 | else |
765 | { | 595 | { |
766 | if (vhash != NULL) | 596 | if (vhash != NULL) |
767 | { | 597 | { |
768 | /* ret = | 598 | struct GNUNET_MY_QueryParam params_get[] = { |
769 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, | 599 | GNUNET_MY_query_param_fixed_size (key, hashSize), |
770 | plugin->count_entry_by_hash_and_vhash, | 600 | GNUNET_MY_query_param_fixed_size (vhash, hashSize2), |
771 | 1, cbind, NULL, NULL, MYSQL_TYPE_BLOB, key, | 601 | GNUNET_MY_query_param_end |
772 | hashSize, &hashSize, MYSQL_TYPE_BLOB, | 602 | }; |
773 | vhash, hashSize2, &hashSize2, -1); | 603 | |
774 | */ | 604 | ret = |
775 | struct GNUNET_MY_QueryParam params_get[] = { | 605 | GNUNET_MY_exec_prepared (plugin->mc, |
776 | GNUNET_MY_query_param_fixed_size (key, hashSize), | 606 | plugin->count_entry_by_hash_and_vhash, |
777 | GNUNET_MY_query_param_fixed_size (vhash, hashSize2), | 607 | params_get); |
778 | GNUNET_MY_query_param_end | 608 | ret = |
779 | }; | 609 | GNUNET_MY_extract_result (plugin->count_entry_by_hash_and_vhash, |
780 | 610 | results_get); | |
781 | |||
782 | ret = | ||
783 | GNUNET_MY_exec_prepared (plugin->mc, | ||
784 | plugin->count_entry_by_hash_and_vhash, | ||
785 | params_get); | ||
786 | ret = | ||
787 | GNUNET_MY_extract_result (plugin->count_entry_by_hash_and_vhash, | ||
788 | results_get); | ||
789 | } | 611 | } |
790 | else | 612 | else |
791 | { | 613 | { |
792 | /* ret = | 614 | struct GNUNET_MY_QueryParam params_get[] = { |
793 | GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->count_entry_by_hash, 1, | 615 | GNUNET_MY_query_param_fixed_size (key, hashSize), |
794 | cbind, NULL, NULL, MYSQL_TYPE_BLOB, key, hashSize, | 616 | GNUNET_MY_query_param_end |
795 | &hashSize, -1); | 617 | }; |
796 | */ | ||
797 | struct GNUNET_MY_QueryParam params_get[] = { | ||
798 | GNUNET_MY_query_param_fixed_size (key, hashSize), | ||
799 | GNUNET_MY_query_param_end | ||
800 | }; | ||
801 | |||
802 | |||
803 | ret = | ||
804 | GNUNET_MY_exec_prepared (plugin->mc, | ||
805 | plugin->count_entry_by_hash, | ||
806 | params_get); | ||
807 | ret = | ||
808 | GNUNET_MY_extract_result (plugin->count_entry_by_hash, | ||
809 | results_get); | ||
810 | } | ||
811 | 618 | ||
619 | ret = | ||
620 | GNUNET_MY_exec_prepared (plugin->mc, | ||
621 | plugin->count_entry_by_hash, | ||
622 | params_get); | ||
623 | ret = | ||
624 | GNUNET_MY_extract_result (plugin->count_entry_by_hash, | ||
625 | results_get); | ||
626 | } | ||
812 | } | 627 | } |
813 | if ((ret != GNUNET_OK) || (0 >= total)) | 628 | if ((ret != GNUNET_OK) || (0 >= total)) |
814 | { | 629 | { |
@@ -816,44 +631,71 @@ mysql_plugin_get_key (void *cls, uint64_t offset, const struct GNUNET_HashCode * | |||
816 | return; | 631 | return; |
817 | } | 632 | } |
818 | offset = offset % total; | 633 | offset = offset % total; |
819 | off = (unsigned long long) offset; | ||
820 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
821 | "Obtaining %llu/%lld result for GET `%s'\n", | 635 | "Obtaining %llu/%lld result for GET `%s'\n", |
822 | (unsigned long long) off, | 636 | (unsigned long long) offset, |
823 | (unsigned long long) total, | 637 | (unsigned long long) total, |
824 | GNUNET_h2s (key)); | 638 | GNUNET_h2s (key)); |
825 | if (type != GNUNET_BLOCK_TYPE_ANY) | 639 | if (type != GNUNET_BLOCK_TYPE_ANY) |
826 | { | 640 | { |
827 | if (NULL != vhash) | 641 | if (NULL != vhash) |
828 | { | 642 | { |
829 | execute_select (plugin, plugin->select_entry_by_hash_vhash_and_type, proc, | 643 | struct GNUNET_MY_QueryParam params_select[] = { |
830 | proc_cls, MYSQL_TYPE_BLOB, key, hashSize, &hashSize, | 644 | GNUNET_MY_query_param_auto_from_type (key), |
831 | MYSQL_TYPE_BLOB, vhash, hashSize, &hashSize, | 645 | GNUNET_MY_query_param_auto_from_type (vhash), |
832 | MYSQL_TYPE_LONG, &type, GNUNET_YES, MYSQL_TYPE_LONGLONG, | 646 | GNUNET_MY_query_param_uint32 (&type), |
833 | &off, GNUNET_YES, -1); | 647 | GNUNET_MY_query_param_uint64 (&offset), |
648 | GNUNET_MY_query_param_end | ||
649 | }; | ||
650 | |||
651 | execute_select (plugin, | ||
652 | plugin->select_entry_by_hash_vhash_and_type, | ||
653 | proc, proc_cls, | ||
654 | params_select); | ||
834 | } | 655 | } |
835 | else | 656 | else |
836 | { | 657 | { |
837 | execute_select (plugin, plugin->select_entry_by_hash_and_type, proc, | 658 | struct GNUNET_MY_QueryParam params_select[] = { |
838 | proc_cls, MYSQL_TYPE_BLOB, key, hashSize, &hashSize, | 659 | GNUNET_MY_query_param_auto_from_type (key), |
839 | MYSQL_TYPE_LONG, &type, GNUNET_YES, MYSQL_TYPE_LONGLONG, | 660 | GNUNET_MY_query_param_uint32 (&type), |
840 | &off, GNUNET_YES, -1); | 661 | GNUNET_MY_query_param_uint64 (&offset), |
662 | GNUNET_MY_query_param_end | ||
663 | }; | ||
664 | |||
665 | execute_select (plugin, | ||
666 | plugin->select_entry_by_hash_and_type, | ||
667 | proc, proc_cls, | ||
668 | params_select); | ||
841 | } | 669 | } |
842 | } | 670 | } |
843 | else | 671 | else |
844 | { | 672 | { |
845 | if (NULL != vhash) | 673 | if (NULL != vhash) |
846 | { | 674 | { |
847 | execute_select (plugin, plugin->select_entry_by_hash_and_vhash, proc, | 675 | struct GNUNET_MY_QueryParam params_select[] = { |
848 | proc_cls, MYSQL_TYPE_BLOB, key, hashSize, &hashSize, | 676 | GNUNET_MY_query_param_auto_from_type (key), |
849 | MYSQL_TYPE_BLOB, vhash, hashSize, &hashSize, | 677 | GNUNET_MY_query_param_auto_from_type (vhash), |
850 | MYSQL_TYPE_LONGLONG, &off, GNUNET_YES, -1); | 678 | GNUNET_MY_query_param_uint64 (&offset), |
679 | GNUNET_MY_query_param_end | ||
680 | }; | ||
681 | |||
682 | execute_select (plugin, | ||
683 | plugin->select_entry_by_hash_and_vhash, | ||
684 | proc, proc_cls, | ||
685 | params_select); | ||
851 | } | 686 | } |
852 | else | 687 | else |
853 | { | 688 | { |
854 | execute_select (plugin, plugin->select_entry_by_hash, proc, proc_cls, | 689 | struct GNUNET_MY_QueryParam params_select[] = { |
855 | MYSQL_TYPE_BLOB, key, hashSize, &hashSize, | 690 | GNUNET_MY_query_param_auto_from_type (key), |
856 | MYSQL_TYPE_LONGLONG, &off, GNUNET_YES, -1); | 691 | GNUNET_MY_query_param_uint64 (&offset), |
692 | GNUNET_MY_query_param_end | ||
693 | }; | ||
694 | |||
695 | execute_select (plugin, | ||
696 | plugin->select_entry_by_hash, | ||
697 | proc, proc_cls, | ||
698 | params_select); | ||
857 | } | 699 | } |
858 | } | 700 | } |
859 | } | 701 | } |
@@ -875,19 +717,25 @@ mysql_plugin_get_zero_anonymity (void *cls, uint64_t offset, | |||
875 | PluginDatumProcessor proc, void *proc_cls) | 717 | PluginDatumProcessor proc, void *proc_cls) |
876 | { | 718 | { |
877 | struct Plugin *plugin = cls; | 719 | struct Plugin *plugin = cls; |
878 | unsigned long long rvalue = | 720 | uint32_t typei = (uint32_t) type; |
879 | (unsigned long long) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 721 | uint64_t rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
880 | UINT64_MAX); | 722 | UINT64_MAX); |
723 | struct GNUNET_MY_QueryParam params_zero_iter[] = { | ||
724 | GNUNET_MY_query_param_uint32 (&typei), | ||
725 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
726 | GNUNET_MY_query_param_uint32 (&typei), | ||
727 | GNUNET_MY_query_param_uint64 (&rvalue), | ||
728 | GNUNET_MY_query_param_end | ||
729 | }; | ||
881 | 730 | ||
882 | execute_select (plugin, plugin->zero_iter, proc, proc_cls, MYSQL_TYPE_LONG, | 731 | execute_select (plugin, plugin->zero_iter, |
883 | &type, GNUNET_YES, MYSQL_TYPE_LONGLONG, &rvalue, GNUNET_YES, | 732 | proc, proc_cls, |
884 | MYSQL_TYPE_LONG, &type, GNUNET_YES, MYSQL_TYPE_LONGLONG, | 733 | params_zero_iter); |
885 | &rvalue, GNUNET_YES, -1); | ||
886 | } | 734 | } |
887 | 735 | ||
888 | 736 | ||
889 | /** | 737 | /** |
890 | * Context for 'repl_proc' function. | 738 | * Context for #repl_proc() function. |
891 | */ | 739 | */ |
892 | struct ReplCtx | 740 | struct ReplCtx |
893 | { | 741 | { |
@@ -903,7 +751,7 @@ struct ReplCtx | |||
903 | PluginDatumProcessor proc; | 751 | PluginDatumProcessor proc; |
904 | 752 | ||
905 | /** | 753 | /** |
906 | * Closure for proc. | 754 | * Closure for @e proc. |
907 | */ | 755 | */ |
908 | void *proc_cls; | 756 | void *proc_cls; |
909 | }; | 757 | }; |