aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2024-02-25 10:56:57 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2024-02-25 10:56:57 +0100
commitc38572985e80f253fdca25cfeefda777bb02bbaf (patch)
treedcfa8b6596369451fe448b090f6b463711f530c1
parent2de3ca3a659f731aa9e533991db5fd46e7e90860 (diff)
downloadgnunet-c38572985e80f253fdca25cfeefda777bb02bbaf.tar.gz
gnunet-c38572985e80f253fdca25cfeefda777bb02bbaf.zip
PEERSTORE: Remove faulty upsert API again.
NEWS: -
-rw-r--r--src/include/gnunet_peerstore_service.h4
-rw-r--r--src/plugin/peerstore/plugin_peerstore_sqlite.c56
-rw-r--r--src/service/peerstore/peerstore_api.c2
3 files changed, 9 insertions, 53 deletions
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h
index 319946e1d..3fb9df82a 100644
--- a/src/include/gnunet_peerstore_service.h
+++ b/src/include/gnunet_peerstore_service.h
@@ -110,10 +110,6 @@ enum GNUNET_PEERSTORE_StoreOption
110 */ 110 */
111 GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1, 111 GNUNET_PEERSTORE_STOREOPTION_REPLACE = 1,
112 112
113 /**
114 * Upserts values. Replaces if expiry is later than existing.
115 */
116 GNUNET_PEERSTORE_STOREOPTION_UPSERT_LATER_EXPIRY = 2
117}; 113};
118 114
119/** 115/**
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 > ?"
diff --git a/src/service/peerstore/peerstore_api.c b/src/service/peerstore/peerstore_api.c
index bf8b990e5..9f6523e38 100644
--- a/src/service/peerstore/peerstore_api.c
+++ b/src/service/peerstore/peerstore_api.c
@@ -876,7 +876,7 @@ hello_add_iter (void *cls, const struct GNUNET_PEERSTORE_Record *record,
876 huc->hello, 876 huc->hello,
877 ntohs (huc->hello->size), 877 ntohs (huc->hello->size),
878 hello_exp, 878 hello_exp,
879 GNUNET_PEERSTORE_STOREOPTION_UPSERT_LATER_EXPIRY, 879 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
880 &hello_store_success, 880 &hello_store_success,
881 huc); 881 huc);
882 return; 882 return;