diff options
author | Jeffrey Burdges <burdges@gnunet.org> | 2017-06-03 22:43:47 +0200 |
---|---|---|
committer | Jeffrey Burdges <burdges@gnunet.org> | 2017-06-03 22:43:47 +0200 |
commit | c53f7586d98f5a147dd3ce102eadae2834e363d2 (patch) | |
tree | 23edc77fbcf90ef7c1f936fb5beda427c0c48d10 | |
parent | b46cad2d494d1bcb998fe5add6b35fa0b583d5ea (diff) | |
download | gnunet-c53f7586d98f5a147dd3ce102eadae2834e363d2.tar.gz gnunet-c53f7586d98f5a147dd3ce102eadae2834e363d2.zip |
Do non-select statements
-rw-r--r-- | src/psycstore/plugin_psycstore_postgres.c | 132 |
1 files changed, 22 insertions, 110 deletions
diff --git a/src/psycstore/plugin_psycstore_postgres.c b/src/psycstore/plugin_psycstore_postgres.c index 26c732fbe..cd933667f 100644 --- a/src/psycstore/plugin_psycstore_postgres.c +++ b/src/psycstore/plugin_psycstore_postgres.c | |||
@@ -386,22 +386,15 @@ static int | |||
386 | exec_channel (struct Plugin *plugin, const char *stmt, | 386 | exec_channel (struct Plugin *plugin, const char *stmt, |
387 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key) | 387 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key) |
388 | { | 388 | { |
389 | PGresult *ret; | ||
390 | struct GNUNET_PQ_QueryParam params[] = { | 389 | struct GNUNET_PQ_QueryParam params[] = { |
391 | GNUNET_PQ_query_param_auto_from_type (channel_key), | 390 | GNUNET_PQ_query_param_auto_from_type (channel_key), |
392 | GNUNET_PQ_query_param_end | 391 | GNUNET_PQ_query_param_end |
393 | }; | 392 | }; |
394 | 393 | ||
395 | ret = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params); | 394 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
396 | if (GNUNET_OK != | 395 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params)) |
397 | GNUNET_POSTGRES_check_result (plugin->dbh, | ||
398 | ret, | ||
399 | PGRES_COMMAND_OK, | ||
400 | "PQexecPrepared", stmt)) | ||
401 | return GNUNET_SYSERR; | 396 | return GNUNET_SYSERR; |
402 | 397 | ||
403 | PQclear (ret); | ||
404 | |||
405 | return GNUNET_OK; | 398 | return GNUNET_OK; |
406 | } | 399 | } |
407 | 400 | ||
@@ -412,23 +405,15 @@ exec_channel (struct Plugin *plugin, const char *stmt, | |||
412 | static int | 405 | static int |
413 | transaction_begin (struct Plugin *plugin, enum Transactions transaction) | 406 | transaction_begin (struct Plugin *plugin, enum Transactions transaction) |
414 | { | 407 | { |
415 | PGresult *ret; | ||
416 | struct GNUNET_PQ_QueryParam params[] = { | 408 | struct GNUNET_PQ_QueryParam params[] = { |
417 | GNUNET_PQ_query_param_end | 409 | GNUNET_PQ_query_param_end |
418 | }; | 410 | }; |
419 | 411 | ||
420 | ret = GNUNET_PQ_exec_prepared (plugin->dbh, "transaction_begin", params); | 412 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
421 | if (GNUNET_OK != | 413 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_begin", params)) |
422 | GNUNET_POSTGRES_check_result (plugin->dbh, | ||
423 | ret, | ||
424 | PGRES_COMMAND_OK, | ||
425 | "PQexecPrepared", "transaction_begin")) | ||
426 | { | ||
427 | return GNUNET_SYSERR; | 414 | return GNUNET_SYSERR; |
428 | } | ||
429 | 415 | ||
430 | plugin->transaction = transaction; | 416 | plugin->transaction = transaction; |
431 | PQclear (ret); | ||
432 | return GNUNET_OK; | 417 | return GNUNET_OK; |
433 | } | 418 | } |
434 | 419 | ||
@@ -439,23 +424,14 @@ transaction_begin (struct Plugin *plugin, enum Transactions transaction) | |||
439 | static int | 424 | static int |
440 | transaction_commit (struct Plugin *plugin) | 425 | transaction_commit (struct Plugin *plugin) |
441 | { | 426 | { |
442 | PGresult *ret; | ||
443 | |||
444 | struct GNUNET_PQ_QueryParam params[] = { | 427 | struct GNUNET_PQ_QueryParam params[] = { |
445 | GNUNET_PQ_query_param_end | 428 | GNUNET_PQ_query_param_end |
446 | }; | 429 | }; |
447 | 430 | ||
448 | ret = GNUNET_PQ_exec_prepared (plugin->dbh, "transaction_commit", params); | 431 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
449 | if (GNUNET_OK != | 432 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_commit", params)) |
450 | GNUNET_POSTGRES_check_result (plugin->dbh, | ||
451 | ret, | ||
452 | PGRES_COMMAND_OK, | ||
453 | "PQexecPrepared", "transaction_commit")) | ||
454 | { | ||
455 | return GNUNET_SYSERR; | 433 | return GNUNET_SYSERR; |
456 | } | ||
457 | 434 | ||
458 | PQclear (ret); | ||
459 | plugin->transaction = TRANSACTION_NONE; | 435 | plugin->transaction = TRANSACTION_NONE; |
460 | return GNUNET_OK; | 436 | return GNUNET_OK; |
461 | } | 437 | } |
@@ -467,23 +443,14 @@ transaction_commit (struct Plugin *plugin) | |||
467 | static int | 443 | static int |
468 | transaction_rollback (struct Plugin *plugin) | 444 | transaction_rollback (struct Plugin *plugin) |
469 | { | 445 | { |
470 | PGresult *ret; | ||
471 | |||
472 | struct GNUNET_PQ_QueryParam params[] = { | 446 | struct GNUNET_PQ_QueryParam params[] = { |
473 | GNUNET_PQ_query_param_end | 447 | GNUNET_PQ_query_param_end |
474 | }; | 448 | }; |
475 | 449 | ||
476 | ret = GNUNET_PQ_exec_prepared (plugin->dbh, "transaction_rollback", params); | 450 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
477 | if (GNUNET_OK != | 451 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_rollback", params)) |
478 | GNUNET_POSTGRES_check_result (plugin->dbh, | ||
479 | ret, | ||
480 | PGRES_COMMAND_OK, | ||
481 | "PQexecPrepared", "transaction_rollback")) | ||
482 | { | ||
483 | return GNUNET_SYSERR; | 452 | return GNUNET_SYSERR; |
484 | } | ||
485 | 453 | ||
486 | PQclear (ret); | ||
487 | plugin->transaction = TRANSACTION_NONE; | 454 | plugin->transaction = TRANSACTION_NONE; |
488 | return GNUNET_OK; | 455 | return GNUNET_OK; |
489 | } | 456 | } |
@@ -493,24 +460,15 @@ static int | |||
493 | channel_key_store (struct Plugin *plugin, | 460 | channel_key_store (struct Plugin *plugin, |
494 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key) | 461 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key) |
495 | { | 462 | { |
496 | PGresult *ret; | ||
497 | |||
498 | struct GNUNET_PQ_QueryParam params[] = { | 463 | struct GNUNET_PQ_QueryParam params[] = { |
499 | GNUNET_PQ_query_param_auto_from_type (channel_key), | 464 | GNUNET_PQ_query_param_auto_from_type (channel_key), |
500 | GNUNET_PQ_query_param_end | 465 | GNUNET_PQ_query_param_end |
501 | }; | 466 | }; |
502 | 467 | ||
503 | ret = GNUNET_PQ_exec_prepared (plugin->dbh, "insert_channel_key", params); | 468 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
504 | if (GNUNET_OK != | 469 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_channel_key", params)) |
505 | GNUNET_POSTGRES_check_result (plugin->dbh, | ||
506 | ret, | ||
507 | PGRES_COMMAND_OK, | ||
508 | "PQexecPrepared", "insert_channel_key")) | ||
509 | { | ||
510 | return GNUNET_SYSERR; | 470 | return GNUNET_SYSERR; |
511 | } | ||
512 | 471 | ||
513 | PQclear (ret); | ||
514 | return GNUNET_OK; | 472 | return GNUNET_OK; |
515 | } | 473 | } |
516 | 474 | ||
@@ -519,24 +477,15 @@ static int | |||
519 | slave_key_store (struct Plugin *plugin, | 477 | slave_key_store (struct Plugin *plugin, |
520 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key) | 478 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key) |
521 | { | 479 | { |
522 | PGresult *ret; | ||
523 | |||
524 | struct GNUNET_PQ_QueryParam params[] = { | 480 | struct GNUNET_PQ_QueryParam params[] = { |
525 | GNUNET_PQ_query_param_auto_from_type (slave_key), | 481 | GNUNET_PQ_query_param_auto_from_type (slave_key), |
526 | GNUNET_PQ_query_param_end | 482 | GNUNET_PQ_query_param_end |
527 | }; | 483 | }; |
528 | 484 | ||
529 | ret = GNUNET_PQ_exec_prepared (plugin->dbh, "insert_slave_key", params); | 485 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
530 | if (GNUNET_OK != | 486 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_slave_key", params)) |
531 | GNUNET_POSTGRES_check_result (plugin->dbh, | ||
532 | ret, | ||
533 | PGRES_COMMAND_OK, | ||
534 | "PQexecPrepared", "insert_slave_key")) | ||
535 | { | ||
536 | return GNUNET_SYSERR; | 487 | return GNUNET_SYSERR; |
537 | } | ||
538 | 488 | ||
539 | PQclear (ret); | ||
540 | return GNUNET_OK; | 489 | return GNUNET_OK; |
541 | } | 490 | } |
542 | 491 | ||
@@ -558,7 +507,6 @@ postgres_membership_store (void *cls, | |||
558 | uint64_t effective_since, | 507 | uint64_t effective_since, |
559 | uint64_t group_generation) | 508 | uint64_t group_generation) |
560 | { | 509 | { |
561 | PGresult *ret; | ||
562 | struct Plugin *plugin = cls; | 510 | struct Plugin *plugin = cls; |
563 | 511 | ||
564 | uint32_t idid_join = (uint32_t)did_join; | 512 | uint32_t idid_join = (uint32_t)did_join; |
@@ -587,17 +535,10 @@ postgres_membership_store (void *cls, | |||
587 | GNUNET_PQ_query_param_end | 535 | GNUNET_PQ_query_param_end |
588 | }; | 536 | }; |
589 | 537 | ||
590 | ret = GNUNET_PQ_exec_prepared (plugin->dbh, "insert_membership", params); | 538 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
591 | if (GNUNET_OK != | 539 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_membership", params)) |
592 | GNUNET_POSTGRES_check_result (plugin->dbh, | ||
593 | ret, | ||
594 | PGRES_COMMAND_OK, | ||
595 | "PQexecPrepared", "insert_membership")) | ||
596 | { | ||
597 | return GNUNET_SYSERR; | 540 | return GNUNET_SYSERR; |
598 | } | ||
599 | 541 | ||
600 | PQclear (ret); | ||
601 | return GNUNET_OK; | 542 | return GNUNET_OK; |
602 | } | 543 | } |
603 | 544 | ||
@@ -673,7 +614,6 @@ fragment_store (void *cls, | |||
673 | const struct GNUNET_MULTICAST_MessageHeader *msg, | 614 | const struct GNUNET_MULTICAST_MessageHeader *msg, |
674 | uint32_t psycstore_flags) | 615 | uint32_t psycstore_flags) |
675 | { | 616 | { |
676 | PGresult *res; | ||
677 | struct Plugin *plugin = cls; | 617 | struct Plugin *plugin = cls; |
678 | 618 | ||
679 | GNUNET_assert (TRANSACTION_NONE == plugin->transaction); | 619 | GNUNET_assert (TRANSACTION_NONE == plugin->transaction); |
@@ -716,15 +656,10 @@ fragment_store (void *cls, | |||
716 | GNUNET_PQ_query_param_end | 656 | GNUNET_PQ_query_param_end |
717 | }; | 657 | }; |
718 | 658 | ||
719 | res = GNUNET_PQ_exec_prepared (plugin->dbh, "insert_fragment", params_insert); | 659 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
720 | if (GNUNET_OK != | 660 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_fragment", params_insert)) |
721 | GNUNET_POSTGRES_check_result (plugin->dbh, | ||
722 | res, | ||
723 | PGRES_COMMAND_OK, | ||
724 | "PQexecPrepared", "insert_fragment")) | ||
725 | return GNUNET_SYSERR; | 661 | return GNUNET_SYSERR; |
726 | 662 | ||
727 | PQclear (res); | ||
728 | return GNUNET_OK; | 663 | return GNUNET_OK; |
729 | } | 664 | } |
730 | 665 | ||
@@ -741,7 +676,6 @@ message_add_flags (void *cls, | |||
741 | uint64_t message_id, | 676 | uint64_t message_id, |
742 | uint32_t psycstore_flags) | 677 | uint32_t psycstore_flags) |
743 | { | 678 | { |
744 | PGresult *res; | ||
745 | struct Plugin *plugin = cls; | 679 | struct Plugin *plugin = cls; |
746 | 680 | ||
747 | struct GNUNET_PQ_QueryParam params_update[] = { | 681 | struct GNUNET_PQ_QueryParam params_update[] = { |
@@ -751,14 +685,10 @@ message_add_flags (void *cls, | |||
751 | GNUNET_PQ_query_param_end | 685 | GNUNET_PQ_query_param_end |
752 | }; | 686 | }; |
753 | 687 | ||
754 | res = GNUNET_PQ_exec_prepared (plugin->dbh, "update_message_flags", params_update); | 688 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
755 | if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, | 689 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "update_message_flags", params_update)) |
756 | res, | ||
757 | PGRES_COMMAND_OK, | ||
758 | "PQexecPrepared","update_message_flags")) | ||
759 | return GNUNET_SYSERR; | 690 | return GNUNET_SYSERR; |
760 | 691 | ||
761 | PQclear (res); | ||
762 | return GNUNET_OK; | 692 | return GNUNET_OK; |
763 | } | 693 | } |
764 | 694 | ||
@@ -1173,8 +1103,6 @@ state_assign (struct Plugin *plugin, const char *stmt, | |||
1173 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 1103 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
1174 | const char *name, const void *value, size_t value_size) | 1104 | const char *name, const void *value, size_t value_size) |
1175 | { | 1105 | { |
1176 | PGresult *res; | ||
1177 | |||
1178 | struct GNUNET_PQ_QueryParam params[] = { | 1106 | struct GNUNET_PQ_QueryParam params[] = { |
1179 | GNUNET_PQ_query_param_auto_from_type (channel_key), | 1107 | GNUNET_PQ_query_param_auto_from_type (channel_key), |
1180 | GNUNET_PQ_query_param_string (name), | 1108 | GNUNET_PQ_query_param_string (name), |
@@ -1182,16 +1110,9 @@ state_assign (struct Plugin *plugin, const char *stmt, | |||
1182 | GNUNET_PQ_query_param_end | 1110 | GNUNET_PQ_query_param_end |
1183 | }; | 1111 | }; |
1184 | 1112 | ||
1185 | res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params); | 1113 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
1186 | if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, | 1114 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params)) |
1187 | res, | ||
1188 | PGRES_COMMAND_OK, | ||
1189 | "PQexecPrepared", stmt)) | ||
1190 | { | ||
1191 | return GNUNET_SYSERR; | 1115 | return GNUNET_SYSERR; |
1192 | } | ||
1193 | |||
1194 | PQclear (res); | ||
1195 | 1116 | ||
1196 | return GNUNET_OK; | 1117 | return GNUNET_OK; |
1197 | } | 1118 | } |
@@ -1203,24 +1124,15 @@ update_message_id (struct Plugin *plugin, | |||
1203 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 1124 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
1204 | uint64_t message_id) | 1125 | uint64_t message_id) |
1205 | { | 1126 | { |
1206 | PGresult *res; | ||
1207 | |||
1208 | struct GNUNET_PQ_QueryParam params[] = { | 1127 | struct GNUNET_PQ_QueryParam params[] = { |
1209 | GNUNET_PQ_query_param_uint64 (&message_id), | 1128 | GNUNET_PQ_query_param_uint64 (&message_id), |
1210 | GNUNET_PQ_query_param_auto_from_type (channel_key), | 1129 | GNUNET_PQ_query_param_auto_from_type (channel_key), |
1211 | GNUNET_PQ_query_param_end | 1130 | GNUNET_PQ_query_param_end |
1212 | }; | 1131 | }; |
1213 | 1132 | ||
1214 | res = GNUNET_PQ_exec_prepared (plugin->dbh, stmt, params); | 1133 | if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != |
1215 | if (GNUNET_OK != GNUNET_POSTGRES_check_result (plugin->dbh, | 1134 | GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params)) |
1216 | res, | ||
1217 | PGRES_COMMAND_OK, | ||
1218 | "PQexecPrepared", stmt)) | ||
1219 | { | ||
1220 | return GNUNET_SYSERR; | 1135 | return GNUNET_SYSERR; |
1221 | } | ||
1222 | |||
1223 | PQclear (res); | ||
1224 | 1136 | ||
1225 | return GNUNET_OK; | 1137 | return GNUNET_OK; |
1226 | } | 1138 | } |