diff options
author | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-06-23 15:20:02 +0000 |
---|---|---|
committer | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-06-23 15:20:02 +0000 |
commit | 0c67d6b5bf7f6378eaf8b0829b88b29f741f4bfe (patch) | |
tree | 55b9040283cda493bcdd8a7091b0a3f91b13c7f0 /src/datastore | |
parent | 5742938289524f4c5fba7883742e4dd69cccf11d (diff) | |
download | gnunet-0c67d6b5bf7f6378eaf8b0829b88b29f741f4bfe.tar.gz gnunet-0c67d6b5bf7f6378eaf8b0829b88b29f741f4bfe.zip |
continue to fix execute select
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/plugin_datastore_mysql.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index 9672937ed..4dc9334c8 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c | |||
@@ -495,19 +495,17 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt | |||
495 | unsigned int anonymity; | 495 | unsigned int anonymity; |
496 | // unsigned long long exp; | 496 | // unsigned long long exp; |
497 | uint64_t exp; | 497 | uint64_t exp; |
498 | //char *type = NULL; | 498 | size_t hashSize; |
499 | //size_t hashSize; | ||
500 | // unsigned long size; | 499 | // unsigned long size; |
501 | size_t size; | 500 | size_t size; |
502 | uint64_t uid; | 501 | uint64_t uid; |
503 | void *value; | 502 | void *value; |
504 | struct GNUNET_HashCode key; | 503 | struct GNUNET_HashCode key; |
505 | struct GNUNET_TIME_Absolute expiration; | 504 | struct GNUNET_TIME_Absolute expiration; |
506 | // MYSQL_BIND rbind[7]; | 505 | //MYSQL_BIND rbind[7]; |
507 | 506 | ||
508 | /* | ||
509 | hashSize = sizeof (struct GNUNET_HashCode); | 507 | hashSize = sizeof (struct GNUNET_HashCode); |
510 | memset (rbind, 0, sizeof (rbind)); | 508 | /* memset (rbind, 0, sizeof (rbind)); |
511 | rbind[0].buffer_type = MYSQL_TYPE_LONG; | 509 | rbind[0].buffer_type = MYSQL_TYPE_LONG; |
512 | rbind[0].buffer = &type; | 510 | rbind[0].buffer = &type; |
513 | rbind[0].is_unsigned = 1; | 511 | rbind[0].is_unsigned = 1; |
@@ -532,11 +530,13 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt | |||
532 | rbind[6].buffer = &uid; | 530 | rbind[6].buffer = &uid; |
533 | rbind[6].is_unsigned = 1; | 531 | rbind[6].is_unsigned = 1; |
534 | */ | 532 | */ |
535 | // ret = GNUNET_MYSQL_statement_run_prepared_select_va (plugin->mc, stmt, 7, rbind, NULL, NULL, ap); | 533 | // ret = GNUNET_MYSQL_statement_run_prepared_select_va (stmt, 7, rbind, NULL, NULL, ap); |
536 | va_start (ap, proc_cls); | 534 | va_start (ap, proc_cls); |
537 | 535 | ||
536 | int pc = 0; | ||
537 | pc = mysql_stmt_param_count (stmt); | ||
538 | |||
538 | struct GNUNET_MY_QueryParam *params_select = NULL; | 539 | struct GNUNET_MY_QueryParam *params_select = NULL; |
539 | struct GNUNET_MY_QueryParam end = GNUNET_MY_query_param_end; | ||
540 | 540 | ||
541 | unsigned int *param_long = NULL; | 541 | unsigned int *param_long = NULL; |
542 | int param_is_unsigned; | 542 | int param_is_unsigned; |
@@ -548,47 +548,42 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt | |||
548 | 548 | ||
549 | // enum enum_field_type ft; | 549 | // enum enum_field_type ft; |
550 | int ft; | 550 | int ft; |
551 | int i = 0; | 551 | int j = 0; |
552 | 552 | ||
553 | ft = 0; | 553 | ft = 0; |
554 | 554 | ||
555 | while (-1 != (ft = va_arg(ap, int))) | 555 | while ((pc > 0) && (-1 != (ft = va_arg(ap, int)))) |
556 | { | 556 | { |
557 | switch (ft) | 557 | switch (ft) |
558 | { | 558 | { |
559 | case MYSQL_TYPE_LONG: | 559 | case MYSQL_TYPE_LONG: |
560 | param_long = va_arg (ap, unsigned int*); | 560 | param_long = va_arg (ap, unsigned int*); |
561 | param_is_unsigned = va_arg (ap, int); | 561 | param_is_unsigned = va_arg (ap, int); |
562 | params_select[i] = GNUNET_MY_query_param_uint32 (param_long); | 562 | params_select[j] = GNUNET_MY_query_param_uint32 (param_long); |
563 | break; | 563 | break; |
564 | 564 | ||
565 | case MYSQL_TYPE_LONGLONG: | 565 | case MYSQL_TYPE_LONGLONG: |
566 | param_longlong = va_arg (ap, unsigned long long *); | 566 | param_longlong = va_arg (ap, unsigned long long *); |
567 | param_is_unsigned = va_arg (ap, int); | 567 | param_is_unsigned = va_arg (ap, int); |
568 | params_select[i] = GNUNET_MY_query_param_uint64 (param_longlong); | 568 | params_select[j] = GNUNET_MY_query_param_uint64 (param_longlong); |
569 | break; | 569 | break; |
570 | 570 | ||
571 | case MYSQL_TYPE_BLOB: | 571 | case MYSQL_TYPE_BLOB: |
572 | param_blob = va_arg (ap, void *); | 572 | param_blob = va_arg (ap, void *); |
573 | param_length = va_arg (ap, unsigned long); | 573 | param_length = va_arg (ap, unsigned long); |
574 | length = va_arg (ap, unsigned long *); | 574 | length = va_arg (ap, unsigned long *); |
575 | params_select[i] = GNUNET_MY_query_param_fixed_size (param_blob, param_length); | 575 | params_select[j] = GNUNET_MY_query_param_fixed_size (param_blob, param_length); |
576 | fprintf(stderr, "indice de segfault : %d\n", j); | ||
576 | break; | 577 | break; |
577 | 578 | ||
578 | default: | 579 | default: |
579 | GNUNET_break(0); | 580 | GNUNET_break(0); |
580 | } | 581 | } |
581 | i++; | 582 | pc--; |
583 | j++; | ||
582 | } | 584 | } |
583 | 585 | ||
584 | params_select[i] = end; | ||
585 | |||
586 | /* | 586 | /* |
587 | struct GNUNET_MY_QueryParam params_select[] ={ | ||
588 | |||
589 | GNUNET_MY_query_param_end | ||
590 | }; | ||
591 | */ | ||
592 | struct GNUNET_MY_ResultSpec results_select[] = { | 587 | struct GNUNET_MY_ResultSpec results_select[] = { |
593 | GNUNET_MY_result_spec_uint32 (&type), | 588 | GNUNET_MY_result_spec_uint32 (&type), |
594 | GNUNET_MY_result_spec_uint32 (&priority), | 589 | GNUNET_MY_result_spec_uint32 (&priority), |
@@ -599,15 +594,21 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt | |||
599 | GNUNET_MY_result_spec_uint64 (&uid), | 594 | GNUNET_MY_result_spec_uint64 (&uid), |
600 | GNUNET_MY_query_param_end | 595 | GNUNET_MY_query_param_end |
601 | }; | 596 | }; |
597 | */ | ||
598 | /* | ||
602 | 599 | ||
600 | !!!! FAIL HERE FOR SELECT QUERY | ||
603 | ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select); | 601 | ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select); |
604 | va_end (ap); | 602 | |
605 | if (ret <= 0) | 603 | if (ret <= 0) |
606 | { | 604 | { |
607 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | 605 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
608 | return; | 606 | return; |
609 | } | 607 | } |
608 | */ | ||
609 | va_end (ap); | ||
610 | 610 | ||
611 | /* | ||
611 | ret = GNUNET_MY_extract_result (stmt, results_select); | 612 | ret = GNUNET_MY_extract_result (stmt, results_select); |
612 | if (ret <= 0) | 613 | if (ret <= 0) |
613 | { | 614 | { |
@@ -620,7 +621,7 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt | |||
620 | if ((rbind[4].buffer_length != sizeof (struct GNUNET_HashCode)) || | 621 | if ((rbind[4].buffer_length != sizeof (struct GNUNET_HashCode)) || |
621 | (hashSize != sizeof (struct GNUNET_HashCode))) | 622 | (hashSize != sizeof (struct GNUNET_HashCode))) |
622 | { | 623 | { |
623 | */ | 624 | |
624 | expiration.abs_value_us = exp; | 625 | expiration.abs_value_us = exp; |
625 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 626 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
626 | "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n", | 627 | "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n", |
@@ -631,12 +632,15 @@ execute_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt | |||
631 | ret = | 632 | ret = |
632 | proc (proc_cls, &key, size, value, type, priority, anonymity, expiration, | 633 | proc (proc_cls, &key, size, value, type, priority, anonymity, expiration, |
633 | uid); | 634 | uid); |
634 | if (ret == GNUNET_NO) | 635 | */ |
636 | |||
637 | /* if (ret == GNUNET_NO) | ||
635 | { | 638 | { |
636 | do_delete_entry (plugin, uid); | 639 | do_delete_entry (plugin, uid); |
637 | if (size != 0) | 640 | if (size != 0) |
638 | plugin->env->duc (plugin->env->cls, -size); | 641 | plugin->env->duc (plugin->env->cls, -size); |
639 | } | 642 | } |
643 | */ | ||
640 | } | 644 | } |
641 | 645 | ||
642 | 646 | ||