diff options
Diffstat (limited to 'src/plugin/peerstore/plugin_peerstore_sqlite.c')
-rw-r--r-- | src/plugin/peerstore/plugin_peerstore_sqlite.c | 56 |
1 files changed, 8 insertions, 48 deletions
diff --git a/src/plugin/peerstore/plugin_peerstore_sqlite.c b/src/plugin/peerstore/plugin_peerstore_sqlite.c index 373315bab..c7132bd85 100644 --- a/src/plugin/peerstore/plugin_peerstore_sqlite.c +++ b/src/plugin/peerstore/plugin_peerstore_sqlite.c | |||
@@ -106,11 +106,6 @@ struct Plugin | |||
106 | sqlite3_stmt *select_peerstoredata_by_all; | 106 | sqlite3_stmt *select_peerstoredata_by_all; |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Precompiled SQL for selecting from peerstoredata | ||
110 | */ | ||
111 | sqlite3_stmt *upsert_peerstoredata_later_expiry; | ||
112 | |||
113 | /** | ||
114 | * Precompiled SQL for deleting expired | 109 | * Precompiled SQL for deleting expired |
115 | * records from peerstoredata | 110 | * records from peerstoredata |
116 | */ | 111 | */ |
@@ -438,40 +433,15 @@ peerstore_sqlite_store_record (void *cls, | |||
438 | key); | 433 | key); |
439 | } | 434 | } |
440 | 435 | ||
441 | if (GNUNET_PEERSTORE_STOREOPTION_UPSERT_LATER_EXPIRY == options) | 436 | stmt = plugin->insert_peerstoredata; |
442 | { | 437 | if (GNUNET_OK != |
443 | struct GNUNET_SQ_QueryParam params_upsert[] = { | 438 | GNUNET_SQ_bind (stmt, |
444 | GNUNET_SQ_query_param_fixed_size (value, size), | 439 | params)) |
445 | GNUNET_SQ_query_param_absolute_time (&expiry), | ||
446 | GNUNET_SQ_query_param_string (sub_system), | ||
447 | GNUNET_SQ_query_param_auto_from_type (peer), | ||
448 | GNUNET_SQ_query_param_string (key), | ||
449 | GNUNET_SQ_query_param_absolute_time (&expiry), | ||
450 | GNUNET_SQ_query_param_end | ||
451 | }; | ||
452 | stmt = plugin->upsert_peerstoredata_later_expiry; | ||
453 | if (GNUNET_OK != | ||
454 | GNUNET_SQ_bind (stmt, | ||
455 | params_upsert)) | ||
456 | { | ||
457 | LOG_SQLITE (plugin, | ||
458 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
459 | "sqlite3_bind"); | ||
460 | GNUNET_assert (0); | ||
461 | } | ||
462 | } | ||
463 | else | ||
464 | { | 440 | { |
465 | stmt = plugin->insert_peerstoredata; | 441 | LOG_SQLITE (plugin, |
466 | if (GNUNET_OK != | 442 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
467 | GNUNET_SQ_bind (stmt, | 443 | "sqlite3_bind"); |
468 | params)) | 444 | GNUNET_assert (0); |
469 | { | ||
470 | LOG_SQLITE (plugin, | ||
471 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
472 | "sqlite3_bind"); | ||
473 | GNUNET_assert (0); | ||
474 | } | ||
475 | } | 445 | } |
476 | if (SQLITE_DONE != sqlite3_step (stmt)) | 446 | if (SQLITE_DONE != sqlite3_step (stmt)) |
477 | { | 447 | { |
@@ -641,16 +611,6 @@ database_setup (struct Plugin *plugin) | |||
641 | " VALUES (?,?,?,?,?);", | 611 | " VALUES (?,?,?,?,?);", |
642 | &plugin->insert_peerstoredata); | 612 | &plugin->insert_peerstoredata); |
643 | sql_prepare (plugin->dbh, | 613 | sql_prepare (plugin->dbh, |
644 | "UPDATE peerstoredata" | ||
645 | " SET" | ||
646 | " value = ?," | ||
647 | " expiry = ?" | ||
648 | " WHERE sub_system = ?" | ||
649 | " AND peer_id = ?" | ||
650 | " AND key = ?" | ||
651 | " AND expiry < ?", | ||
652 | &plugin->upsert_peerstoredata_later_expiry); | ||
653 | sql_prepare (plugin->dbh, | ||
654 | "SELECT uid,sub_system,peer_id,key,value,expiry FROM peerstoredata" | 614 | "SELECT uid,sub_system,peer_id,key,value,expiry FROM peerstoredata" |
655 | " WHERE sub_system = ?" | 615 | " WHERE sub_system = ?" |
656 | " AND uid > ?" | 616 | " AND uid > ?" |