From: Schanzenbach, Martin Date: Mon, 15 Oct 2018 09:41:29 +0000 (+0900) Subject: modify sqlite logic to accomodate rowcount starting from 1 X-Git-Tag: v0.11.0~238^2~67 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=03fb70c9384b208cbeb57fb6c9b06145aa9c2e9e;p=oweals%2Fgnunet.git modify sqlite logic to accomodate rowcount starting from 1 --- diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index cdefd0be9..6ad7354ad 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c @@ -713,9 +713,8 @@ send_store_response (struct NamestoreClient *nc, { struct GNUNET_MQ_Envelope *env; struct RecordStoreResponseMessage *rcr_msg; - - if (NULL == nc) - return; + + GNUNET_assert (NULL != nc); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending RECORD_STORE_RESPONSE message\n"); GNUNET_STATISTICS_update (statistics, @@ -804,9 +803,10 @@ refresh_block (struct NamestoreClient *nc, } if (0 == res_count) { - send_store_response (nc, - GNUNET_OK, - rid); + if (NULL != nc) + send_store_response (nc, + GNUNET_OK, + rid); return; /* no data, no need to update cache */ } if (GNUNET_YES == disable_namecache) @@ -815,9 +815,10 @@ refresh_block (struct NamestoreClient *nc, "Namecache updates skipped (NC disabled)", 1, GNUNET_NO); - send_store_response (nc, - GNUNET_OK, - rid); + if (NULL != nc) + send_store_response (nc, + GNUNET_OK, + rid); return; } exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, @@ -1808,7 +1809,6 @@ handle_iteration_start (void *cls, zi->request_id = ntohl (zis_msg->gns_header.r_id); zi->offset = 0; zi->nc = nc; - zi->seq = 1; zi->zone = zis_msg->zone; GNUNET_CONTAINER_DLL_insert (nc->op_head, diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 07784a779..1a4e0138c 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c @@ -152,14 +152,14 @@ database_setup (struct Plugin *plugin) &plugin->zone_to_name), GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label" " FROM ns098records" - " WHERE zone_private_key=? AND _rowid_ >= ?" - " ORDER BY _rowid_ ASC" + " WHERE zone_private_key=? AND uid >= ?" + " ORDER BY uid ASC" " LIMIT ?", &plugin->iterate_zone), GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label,zone_private_key" " FROM ns098records" - " WHERE _rowid_ >= ?" - " ORDER BY _rowid_ ASC" + " WHERE uid >= ?" + " ORDER BY uid ASC" " LIMIT ?", &plugin->iterate_all_zones), GNUNET_SQ_make_prepare ("SELECT uid,record_count,record_data,label,zone_private_key" @@ -540,7 +540,7 @@ get_records_and_call_iterator (struct Plugin *plugin, zk = *zone_key; if (NULL != iter) iter (iter_cls, - seq + 1, + seq, &zk, label, record_count, @@ -627,11 +627,12 @@ namestore_sqlite_iterate_records (void *cls, struct Plugin *plugin = cls; sqlite3_stmt *stmt; int err; + uint64_t rowid = serial + 1; //SQLite starts counting at 1 if (NULL == zone) { struct GNUNET_SQ_QueryParam params[] = { - GNUNET_SQ_query_param_uint64 (&serial), + GNUNET_SQ_query_param_uint64 (&rowid), GNUNET_SQ_query_param_uint64 (&limit), GNUNET_SQ_query_param_end }; @@ -644,7 +645,7 @@ namestore_sqlite_iterate_records (void *cls, { struct GNUNET_SQ_QueryParam params[] = { GNUNET_SQ_query_param_auto_from_type (zone), - GNUNET_SQ_query_param_uint64 (&serial), + GNUNET_SQ_query_param_uint64 (&rowid), GNUNET_SQ_query_param_uint64 (&limit), GNUNET_SQ_query_param_end };