gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r1667 - in GNUnet/src/applications: fs/ecrs sqstore_mysql s


From: grothoff
Subject: [GNUnet-SVN] r1667 - in GNUnet/src/applications: fs/ecrs sqstore_mysql sqstore_sqlite
Date: Sun, 14 Aug 2005 12:32:21 -0700 (PDT)

Author: grothoff
Date: 2005-08-14 12:32:19 -0700 (Sun, 14 Aug 2005)
New Revision: 1667

Modified:
   GNUnet/src/applications/fs/ecrs/namespacetest.c
   GNUnet/src/applications/sqstore_mysql/mysql.c
   GNUnet/src/applications/sqstore_mysql/mysqltest.c
   GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
Log:
DB fixes

Modified: GNUnet/src/applications/fs/ecrs/namespacetest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespacetest.c     2005-08-14 18:52:31 UTC 
(rev 1666)
+++ GNUnet/src/applications/fs/ecrs/namespacetest.c     2005-08-14 19:32:19 UTC 
(rev 1667)
@@ -53,29 +53,29 @@
   meta = ECRS_createMetaData();
   adv = ECRS_keywordsToUri(keys);
   hash("root", 4, &root);
-  CHECK(OK ==
-       ECRS_createNamespace(CHECKNAME,
-                            meta,
-                            0,
-                            0,
-                            cronTime(NULL) + 5 * cronMINUTES,
-                            adv,
-                            &root,
-                            &rootURI));
+  rootURI = 
+    ECRS_createNamespace(CHECKNAME,
+                        meta,
+                        0,
+                        0,
+                        cronTime(NULL) + 5 * cronMINUTES,
+                        adv,
+                        &root);
+  CHECK(NULL != rootURI);
   hash("this", 4, &thisId);
   hash("next", 4, &nextId);
   uri = rootURI; /* just for fun: NS::this advertises NS::root */  
-  CHECK(OK == ECRS_addToNamespace(CHECKNAME,
-                                 0,
-                                 0,
-                                 TIME(NULL) + 300,
-                                 TIME(NULL),
-                                 1 * cronMINUTES,
-                                 &thisId,
-                                 &nextId,
-                                 uri,
-                                 meta,
-                                 &advURI));
+  advURI = ECRS_addToNamespace(CHECKNAME,
+                              0,
+                              0,
+                              TIME(NULL) + 300,
+                              TIME(NULL),
+                              1 * cronMINUTES,
+                              &thisId,
+                              &nextId,
+                              uri,
+                              meta);
+  CHECK(NULL != advURI);
   CHECK(OK == ECRS_deleteNamespace(CHECKNAME));
   CHECK(SYSERR == ECRS_deleteNamespace(CHECKNAME));
   ECRS_freeMetaData(meta);

Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c       2005-08-14 18:52:31 UTC 
(rev 1666)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c       2005-08-14 19:32:19 UTC 
(rev 1667)
@@ -294,7 +294,7 @@
                " INDEX (hash(64)),"
                " INDEX (prio),"
                " INDEX (expire)"
-               ") TYPE=MyISAM");
+               ") TYPE=InnoDB");
     if (mysql_error(dbhI->dbf)[0]) {
       LOG_MYSQL(LOG_ERROR,
                "mysql_query",
@@ -462,6 +462,9 @@
 
   MUTEX_LOCK(&dbhI.DATABASE_Lock_);
 
+  mysql_query(dbhI.dbf,
+             "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED");
+
   if (type==0) {
     typestr[0] = '\0';
   } else {
@@ -473,8 +476,8 @@
 
   scratch = MALLOC(256);
   SNPRINTF(scratch,
-          256,
-          "SELECT * FROM gn070"
+          256, // SQL_BIG_RESULT SQL_BUFFER_RESULT
+          "SELECT SQL_NO_CACHE * FROM gn070"
           " %s"
           "ORDER BY prio ASC",
           typestr);
@@ -556,6 +559,10 @@
     return SYSERR;
 
   MUTEX_LOCK(&dbhI.DATABASE_Lock_);
+
+  mysql_query(dbhI.dbf,
+             "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED");
+
   if (type==0) {
     typestr[0] = 0;
   } else {
@@ -565,9 +572,9 @@
   }
 
   scratch = MALLOC(256);
-  SNPRINTF(scratch,
+  SNPRINTF(scratch, //SQL_BIG_RESULT SQL_BUFFER_RESULT SQL_NO_CACHE
           256,
-          "SELECT * FROM gn070"
+          "SELECT SQL_NO_CACHE * FROM gn070"
           " %s"
           " ORDER BY expire ASC",
           typestr);
@@ -917,12 +924,6 @@
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
 
   twenty = sizeof(HashCode512);
-  type = ntohl(value->type);
-  size = ntohl(value->size);
-  prio = ntohl(value->prio);
-  anon = ntohl(value->anonymityLevel);
-  expiration = ntohll(value->expirationTime);
-  datasize = ntohl(value->size) - sizeof(Datastore_Value);
 
   if(value == NULL) {
     stmt = dbh->deleteh;
@@ -931,6 +932,12 @@
     GNUNET_ASSERT(mysql_stmt_param_count(stmt) <= 1);
   } else {
     stmt = dbh->deleteg;
+    type = ntohl(value->type);
+    size = ntohl(value->size);
+    prio = ntohl(value->prio);
+    anon = ntohl(value->anonymityLevel);
+    expiration = ntohll(value->expirationTime);
+    datasize = ntohl(value->size) - sizeof(Datastore_Value);
     dbh->dbind[0].buffer = (char*) key;
     dbh->dbind[0].length = &twenty;
     dbh->dbind[1].buffer = (char*) &size;

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest.c   2005-08-14 18:52:31 UTC 
(rev 1666)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest.c   2005-08-14 19:32:19 UTC 
(rev 1667)
@@ -107,10 +107,10 @@
   int id;
 
   id = (*closure);
-  if (id == ntohl(val->prio))
+  if (id + 1 == ntohl(val->prio))
     return OK;
-  else
-    return SYSERR;
+  else 
+    return SYSERR;  
 }
 
 static int multipleCheck(const HashCode512 * key,

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2005-08-14 18:52:31 UTC 
(rev 1666)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2005-08-14 19:32:19 UTC 
(rev 1667)
@@ -93,8 +93,8 @@
 }
 
 static int iterateDelete(const HashCode512 * key,
-                      const Datastore_Value * val,
-                          SQstore_ServiceAPI * api) {
+                        const Datastore_Value * val,
+                        SQstore_ServiceAPI * api) {
   if (1 == api->del(key, val))
        return OK;
   else
@@ -132,7 +132,6 @@
 }
 
 
-
 /**
  * Add testcode here!
  */
@@ -142,7 +141,6 @@
   unsigned long long oldSize;
   int i;
 
-  cronTime(&now);
   now = 1000000;
   oldSize = api->getSize();
   for (i=0;i<256;i++) {
@@ -162,6 +160,7 @@
     memset(&key, 256-i, sizeof(HashCode512));
     ASSERT(1 == api->get(&key, i, &checkValue, (void*) &i));
   }
+
   oldSize = api->getSize();
   for (i=255;i>=0;i-=2) {
     memset(&key, 256-i, sizeof(HashCode512));
@@ -172,19 +171,19 @@
   ASSERT(oldSize > api->getSize());
   i = 0;
   ASSERT(128 == api->iterateLowPriority(ANY_BLOCK,
-                                                                               
(Datum_Iterator) &iterateUp,
-                                                                               
&i));
+                                       (Datum_Iterator) &iterateUp,
+                                       &i));
   ASSERT(256 == i);
   ASSERT(128 == api->iterateExpirationTime(ANY_BLOCK,
-                                                                               
   (Datum_Iterator) &iterateDown,
-                                                                               
   &i));
+                                          (Datum_Iterator) &iterateDown,
+                                          &i));
   ASSERT(0 == i);
   ASSERT(128 == api->iterateExpirationTime(ANY_BLOCK,
-                                                                               
   (Datum_Iterator) &iterateDelete,
-                                                                               
   api));
+                                          (Datum_Iterator) &iterateDelete,
+                                          api));
   ASSERT(0 == api->iterateExpirationTime(ANY_BLOCK,
-                                                                               
 (Datum_Iterator) &iterateDown,
-                                                                               
 &i));
+                                        (Datum_Iterator) &iterateDown,
+                                        &i));
 
   i = 42;
   value = initValue(i);
@@ -217,8 +216,8 @@
   api->del(&key,
           NULL);
   ASSERT(0 == api->iterateExpirationTime(ANY_BLOCK,
-                                                                               
 NULL,
-                                                                               
 NULL));
+                                        NULL,
+                                        NULL));
   api->drop();
   return OK;
  FAILURE:
@@ -258,7 +257,7 @@
   if (OK != initUtil(argc, argv, &parser))
     errexit(_("Could not initialize libgnunetutil!\n"));
   initCore();
-  api = requestService("sqstore_sqlite");
+  api = requestService("sqstore");
   if (api != NULL) {
     ok = test(api);
     releaseService(api);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]