modify sqlite logic to accomodate rowcount starting from 1
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 15 Oct 2018 09:41:29 +0000 (18:41 +0900)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 15 Oct 2018 09:41:29 +0000 (18:41 +0900)
src/namestore/gnunet-service-namestore.c
src/namestore/plugin_namestore_sqlite.c

index cdefd0be9e54b01136a71b494b4f60e50b22a022..6ad7354ad00375a2d40659ab384a74a0fadb5a17 100644 (file)
@@ -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,
index 07784a7794cb08a3ff99bc2f4488461fe92f23ef..1a4e0138c6780420243c68fded5a3a9a898ac3c1 100644 (file)
@@ -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
     };