aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-08-06 11:35:50 +0000
committerChristian Grothoff <christian@grothoff.org>2010-08-06 11:35:50 +0000
commitf9b7adcad3cc030a800cbc9a96709454c45ae06f (patch)
tree293a54815eb1a8ce0983698d2c345dd5df0de2e3
parent95aed93238058bb5ba896454a6f4505cc08b6146 (diff)
downloadgnunet-f9b7adcad3cc030a800cbc9a96709454c45ae06f.tar.gz
gnunet-f9b7adcad3cc030a800cbc9a96709454c45ae06f.zip
getting mysql to work
-rw-r--r--TODO1
-rw-r--r--src/datastore/plugin_datastore_mysql.c65
-rw-r--r--src/datastore/test_datastore_api.c4
3 files changed, 43 insertions, 27 deletions
diff --git a/TODO b/TODO
index b3a85bf4f..44173a18b 100644
--- a/TODO
+++ b/TODO
@@ -52,7 +52,6 @@
52 - integration with transport service 52 - integration with transport service
53* MYSQL database backends: [CG] 53* MYSQL database backends: [CG]
54 - datacache 54 - datacache
55 - datastore
56* FS: [CG] 55* FS: [CG]
57 - library: 56 - library:
58 + reconstruct IBLOCKS from DBLOCKS if possible (during download; see FIXME in fs_download) 57 + reconstruct IBLOCKS from DBLOCKS if possible (during download; see FIXME in fs_download)
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c
index 703ba8c32..5fc3f6878 100644
--- a/src/datastore/plugin_datastore_mysql.c
+++ b/src/datastore/plugin_datastore_mysql.c
@@ -1233,7 +1233,8 @@ mysql_next_request_cont (void *next_cls,
1233 } 1233 }
1234#if DEBUG_MYSQL 1234#if DEBUG_MYSQL
1235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1236 "Calling iterator with value %llu of size %u with type %u, priority %u, anonymity %u and expiration %llu\n", 1236 "Calling iterator with value `%s' number %llu of size %u with type %u, priority %u, anonymity %u and expiration %llu\n",
1237 GNUNET_h2s (&key),
1237 vkey, 1238 vkey,
1238 size, 1239 size,
1239 type, 1240 type,
@@ -1445,7 +1446,8 @@ mysql_plugin_put (void *cls,
1445 } 1446 }
1446#if DEBUG_MYSQL 1447#if DEBUG_MYSQL
1447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1448 "Inserted value number %llu with size %u into gn080 table\n", 1449 "Inserted value `%s' number %llu with size %u into gn080 table\n",
1450 GNUNET_h2s (key),
1449 vkey, 1451 vkey,
1450 isize); 1452 isize);
1451#endif 1453#endif
@@ -1484,7 +1486,6 @@ struct GetContext
1484 1486
1485 unsigned int prio; 1487 unsigned int prio;
1486 unsigned int anonymity; 1488 unsigned int anonymity;
1487 unsigned int limit_off;
1488 unsigned long long expiration; 1489 unsigned long long expiration;
1489 unsigned long long vkey; 1490 unsigned long long vkey;
1490 unsigned long long total; 1491 unsigned long long total;
@@ -1492,7 +1493,6 @@ struct GetContext
1492 int count; 1493 int count;
1493 int have_vhash; 1494 int have_vhash;
1494 unsigned long size; /* OBSOLETE! */ 1495 unsigned long size; /* OBSOLETE! */
1495 unsigned long hashSize;
1496}; 1496};
1497 1497
1498 1498
@@ -1503,6 +1503,8 @@ get_statement_prepare (void *cls,
1503 struct GetContext *gc = cls; 1503 struct GetContext *gc = cls;
1504 struct Plugin *plugin; 1504 struct Plugin *plugin;
1505 int ret; 1505 int ret;
1506 unsigned int limit_off;
1507 unsigned long hashSize;
1506 1508
1507 if (NULL == nrc) 1509 if (NULL == nrc)
1508 { 1510 {
@@ -1512,12 +1514,22 @@ get_statement_prepare (void *cls,
1512 if (gc->count == gc->total) 1514 if (gc->count == gc->total)
1513 return GNUNET_NO; 1515 return GNUNET_NO;
1514 plugin = nrc->plugin; 1516 plugin = nrc->plugin;
1515 gc->hashSize = sizeof (GNUNET_HashCode); 1517 hashSize = sizeof (GNUNET_HashCode);
1518 if (gc->count + gc->off == gc->total)
1519 nrc->last_vkey = 0; /* back to start */
1516 if (gc->count == 0) 1520 if (gc->count == 0)
1517 gc->limit_off = gc->off; 1521 limit_off = gc->off;
1518 else 1522 else
1519 gc->limit_off = 0; 1523 limit_off = 0;
1520 1524#if DEBUG_MYSQL
1525 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1526 "Obtaining result number %d/%lld at offset %d with lvc %llu for GET `%s'\n",
1527 gc->count+1,
1528 gc->total,
1529 limit_off,
1530 nrc->last_vkey,
1531 GNUNET_h2s (&gc->key));
1532#endif
1521 if (nrc->type != 0) 1533 if (nrc->type != 0)
1522 { 1534 {
1523 if (gc->have_vhash) 1535 if (gc->have_vhash)
@@ -1526,10 +1538,10 @@ get_statement_prepare (void *cls,
1526 prepared_statement_run_select 1538 prepared_statement_run_select
1527 (plugin, 1539 (plugin,
1528 plugin->select_entry_by_hash_vhash_and_type, 7, nrc->rbind, &return_ok, 1540 plugin->select_entry_by_hash_vhash_and_type, 7, nrc->rbind, &return_ok,
1529 NULL, MYSQL_TYPE_BLOB, &gc->key, gc->hashSize, &gc->hashSize, 1541 NULL, MYSQL_TYPE_BLOB, &gc->key, hashSize, &hashSize,
1530 MYSQL_TYPE_BLOB, &gc->vhash, gc->hashSize, &gc->hashSize, 1542 MYSQL_TYPE_BLOB, &gc->vhash, hashSize, &hashSize,
1531 MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG, 1543 MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG,
1532 &nrc->type, GNUNET_YES, MYSQL_TYPE_LONG, &gc->limit_off, GNUNET_YES, 1544 &nrc->type, GNUNET_YES, MYSQL_TYPE_LONG, &limit_off, GNUNET_YES,
1533 -1); 1545 -1);
1534 } 1546 }
1535 else 1547 else
@@ -1538,9 +1550,9 @@ get_statement_prepare (void *cls,
1538 prepared_statement_run_select 1550 prepared_statement_run_select
1539 (plugin, 1551 (plugin,
1540 plugin->select_entry_by_hash_and_type, 7, nrc->rbind, &return_ok, NULL, 1552 plugin->select_entry_by_hash_and_type, 7, nrc->rbind, &return_ok, NULL,
1541 MYSQL_TYPE_BLOB, &gc->key, gc->hashSize, &gc->hashSize, 1553 MYSQL_TYPE_BLOB, &gc->key, hashSize, &hashSize,
1542 MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG, 1554 MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG,
1543 &nrc->type, GNUNET_YES, MYSQL_TYPE_LONG, &gc->limit_off, GNUNET_YES, 1555 &nrc->type, GNUNET_YES, MYSQL_TYPE_LONG, &limit_off, GNUNET_YES,
1544 -1); 1556 -1);
1545 } 1557 }
1546 } 1558 }
@@ -1552,9 +1564,9 @@ get_statement_prepare (void *cls,
1552 prepared_statement_run_select 1564 prepared_statement_run_select
1553 (plugin, 1565 (plugin,
1554 plugin->select_entry_by_hash_and_vhash, 7, nrc->rbind, &return_ok, NULL, 1566 plugin->select_entry_by_hash_and_vhash, 7, nrc->rbind, &return_ok, NULL,
1555 MYSQL_TYPE_BLOB, &gc->key, gc->hashSize, &gc->hashSize, MYSQL_TYPE_BLOB, 1567 MYSQL_TYPE_BLOB, &gc->key, hashSize, &hashSize, MYSQL_TYPE_BLOB,
1556 &gc->vhash, gc->hashSize, &gc->hashSize, MYSQL_TYPE_LONGLONG, 1568 &gc->vhash, hashSize, &hashSize, MYSQL_TYPE_LONGLONG,
1557 &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG, &gc->limit_off, 1569 &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG, &limit_off,
1558 GNUNET_YES, -1); 1570 GNUNET_YES, -1);
1559 } 1571 }
1560 else 1572 else
@@ -1563,13 +1575,12 @@ get_statement_prepare (void *cls,
1563 prepared_statement_run_select 1575 prepared_statement_run_select
1564 (plugin, 1576 (plugin,
1565 plugin->select_entry_by_hash, 7, nrc->rbind, &return_ok, NULL, 1577 plugin->select_entry_by_hash, 7, nrc->rbind, &return_ok, NULL,
1566 MYSQL_TYPE_BLOB, &gc->key, gc->hashSize, &gc->hashSize, 1578 MYSQL_TYPE_BLOB, &gc->key, hashSize, &hashSize,
1567 MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG, 1579 MYSQL_TYPE_LONGLONG, &nrc->last_vkey, GNUNET_YES, MYSQL_TYPE_LONG,
1568 &gc->limit_off, GNUNET_YES, -1); 1580 &limit_off, GNUNET_YES, -1);
1569 } 1581 }
1570 } 1582 }
1571 if (gc->count + gc->off == gc->total) 1583 gc->count++;
1572 nrc->last_vkey = 0; /* back to start */
1573 return ret; 1584 return ret;
1574} 1585}
1575 1586
@@ -1604,7 +1615,7 @@ mysql_plugin_get (void *cls,
1604 MYSQL_BIND cbind[1]; 1615 MYSQL_BIND cbind[1];
1605 struct GetContext *gc; 1616 struct GetContext *gc;
1606 struct NextRequestClosure *nrc; 1617 struct NextRequestClosure *nrc;
1607 unsigned long long total; 1618 long long total;
1608 unsigned long hashSize; 1619 unsigned long hashSize;
1609 1620
1610 if (iter == NULL) 1621 if (iter == NULL)
@@ -1621,7 +1632,7 @@ mysql_plugin_get (void *cls,
1621 total = -1; 1632 total = -1;
1622 cbind[0].buffer_type = MYSQL_TYPE_LONGLONG; 1633 cbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
1623 cbind[0].buffer = &total; 1634 cbind[0].buffer = &total;
1624 cbind[0].is_unsigned = GNUNET_YES; 1635 cbind[0].is_unsigned = GNUNET_NO;
1625 if (type != 0) 1636 if (type != 0)
1626 { 1637 {
1627 if (vhash != NULL) 1638 if (vhash != NULL)
@@ -1668,13 +1679,19 @@ mysql_plugin_get (void *cls,
1668 &hashSize, -1); 1679 &hashSize, -1);
1669 } 1680 }
1670 } 1681 }
1671 if ((ret != GNUNET_OK) || (-1 == total) || (0 == total)) 1682 if ((ret != GNUNET_OK) || (0 >= total))
1672 { 1683 {
1673 iter (iter_cls, 1684 iter (iter_cls,
1674 NULL, NULL, 0, NULL, 0, 0, 0, 1685 NULL, NULL, 0, NULL, 0, 0, 0,
1675 GNUNET_TIME_UNIT_ZERO_ABS, 0); 1686 GNUNET_TIME_UNIT_ZERO_ABS, 0);
1676 return; 1687 return;
1677 } 1688 }
1689#if DEBUG_MYSQL
1690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1691 "Iterating over %lld results for GET `%s'\n",
1692 total,
1693 GNUNET_h2s (key));
1694#endif
1678 gc = GNUNET_malloc (sizeof (struct GetContext)); 1695 gc = GNUNET_malloc (sizeof (struct GetContext));
1679 gc->key = *key; 1696 gc->key = *key;
1680 if (vhash != NULL) 1697 if (vhash != NULL)
@@ -1694,7 +1711,7 @@ mysql_plugin_get (void *cls,
1694 nrc->dviter_cls = iter_cls; 1711 nrc->dviter_cls = iter_cls;
1695 nrc->prep = &get_statement_prepare; 1712 nrc->prep = &get_statement_prepare;
1696 nrc->prep_cls = gc; 1713 nrc->prep_cls = gc;
1697 nrc->last_vkey = 0; // FIXME: used to be 'vkey', why? where did vkey come from? 1714 nrc->last_vkey = 0;
1698 mysql_plugin_next_request (nrc, GNUNET_NO); 1715 mysql_plugin_next_request (nrc, GNUNET_NO);
1699} 1716}
1700 1717
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index 2ae6dbe4a..000601df3 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -111,10 +111,10 @@ enum RunPhase
111 RP_PUT_MULTIPLE, 111 RP_PUT_MULTIPLE,
112 RP_PUT_MULTIPLE_NEXT, 112 RP_PUT_MULTIPLE_NEXT,
113 RP_GET_MULTIPLE, 113 RP_GET_MULTIPLE,
114 RP_GET_MULTIPLE_NEXT, 114 RP_GET_MULTIPLE_NEXT, /* 10 */
115 RP_GET_MULTIPLE_DONE, 115 RP_GET_MULTIPLE_DONE,
116 RP_UPDATE, 116 RP_UPDATE,
117 RP_UPDATE_VALIDATE, 117 RP_UPDATE_VALIDATE, /* 13 */
118 RP_UPDATE_DONE, 118 RP_UPDATE_DONE,
119 RP_ERROR 119 RP_ERROR
120 }; 120 };