aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/plugin_namestore_sqlite.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-23 17:27:42 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-23 17:27:42 +0000
commit37488aed2cecebf4472d8e7bef0ebea2a92c9c01 (patch)
tree533bbc8cb1a64f230fd782b6deb2f9c5db846ca6 /src/namestore/plugin_namestore_sqlite.c
parent6a970be4b56545fe71f12f7abe0384cd81975245 (diff)
downloadgnunet-37488aed2cecebf4472d8e7bef0ebea2a92c9c01.tar.gz
gnunet-37488aed2cecebf4472d8e7bef0ebea2a92c9c01.zip
-fixing bugs and testcase, plugin now works for updated API again
Diffstat (limited to 'src/namestore/plugin_namestore_sqlite.c')
-rw-r--r--src/namestore/plugin_namestore_sqlite.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c
index 1543573e0..ba8f8bca6 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -289,9 +289,9 @@ database_setup (struct Plugin *plugin)
289 " zone_key BLOB NOT NULL DEFAULT ''," 289 " zone_key BLOB NOT NULL DEFAULT '',"
290 " zone_hash BLOB NOT NULL DEFAULT ''," 290 " zone_hash BLOB NOT NULL DEFAULT '',"
291 " record_count INT NOT NULL DEFAULT 0," 291 " record_count INT NOT NULL DEFAULT 0,"
292 " record_data BLOB NOT NULL DEFAULT ''" 292 " record_data BLOB NOT NULL DEFAULT '',"
293 " block_expiration_time INT8 NOT NULL DEFAULT 0," 293 " block_expiration_time INT8 NOT NULL DEFAULT 0,"
294 " signature BLOB NOT NULL DEFAULT ''" 294 " signature BLOB NOT NULL DEFAULT '',"
295 " record_name TEXT NOT NULL DEFAULT ''," 295 " record_name TEXT NOT NULL DEFAULT '',"
296 " record_name_hash BLOB NOT NULL DEFAULT ''," 296 " record_name_hash BLOB NOT NULL DEFAULT '',"
297 " rvalue INT8 NOT NULL DEFAULT ''" 297 " rvalue INT8 NOT NULL DEFAULT ''"
@@ -310,7 +310,7 @@ database_setup (struct Plugin *plugin)
310 if ((sq_prepare 310 if ((sq_prepare
311 (plugin->dbh, 311 (plugin->dbh,
312 "INSERT INTO ns090records (" ALL ", zone_hash, record_name_hash, rvalue) VALUES " 312 "INSERT INTO ns090records (" ALL ", zone_hash, record_name_hash, rvalue) VALUES "
313 "(?, ?, ?, ?, ?, ?)", 313 "(?, ?, ?, ?, ?, ?, ?, ?, ?)",
314 &plugin->put_records) != SQLITE_OK) || 314 &plugin->put_records) != SQLITE_OK) ||
315 (sq_prepare 315 (sq_prepare
316 (plugin->dbh, 316 (plugin->dbh,
@@ -319,22 +319,22 @@ database_setup (struct Plugin *plugin)
319 (sq_prepare 319 (sq_prepare
320 (plugin->dbh, 320 (plugin->dbh,
321 "SELECT " ALL 321 "SELECT " ALL
322 "FROM ns090records WHERE zone_hash=? AND record_name_hash=? ORDER BY rvalue OFFSET ? LIMIT 1", 322 " FROM ns090records WHERE zone_hash=? AND record_name_hash=? ORDER BY rvalue LIMIT 1 OFFSET ?",
323 &plugin->iterate_records) != SQLITE_OK) || 323 &plugin->iterate_records) != SQLITE_OK) ||
324 (sq_prepare 324 (sq_prepare
325 (plugin->dbh, 325 (plugin->dbh,
326 "SELECT " ALL 326 "SELECT " ALL
327 "FROM ns090records WHERE zone_hash=? ORDER BY rvalue OFFSET ? LIMIT 1", 327 " FROM ns090records WHERE zone_hash=? ORDER BY rvalue LIMIT 1 OFFSET ?",
328 &plugin->iterate_by_zone) != SQLITE_OK) || 328 &plugin->iterate_by_zone) != SQLITE_OK) ||
329 (sq_prepare 329 (sq_prepare
330 (plugin->dbh, 330 (plugin->dbh,
331 "SELECT " ALL 331 "SELECT " ALL
332 "FROM ns090records WHERE record_name_hash=? ORDER BY rvalue OFFSET ? LIMIT 1", 332 " FROM ns090records WHERE record_name_hash=? ORDER BY rvalue LIMIT 1 OFFSET ?",
333 &plugin->iterate_by_name) != SQLITE_OK) || 333 &plugin->iterate_by_name) != SQLITE_OK) ||
334 (sq_prepare 334 (sq_prepare
335 (plugin->dbh, 335 (plugin->dbh,
336 "SELECT " ALL 336 "SELECT " ALL
337 "FROM ns090records ORDER BY rvalue OFFSET ? LIMIT 1", 337 " FROM ns090records ORDER BY rvalue LIMIT 1 OFFSET ?",
338 &plugin->iterate_all) != SQLITE_OK) || 338 &plugin->iterate_all) != SQLITE_OK) ||
339 (sq_prepare 339 (sq_prepare
340 (plugin->dbh, 340 (plugin->dbh,
@@ -645,16 +645,16 @@ namestore_sqlite_iterate_records (void *cls,
645 const char *name; 645 const char *name;
646 646
647 ret = GNUNET_YES; 647 ret = GNUNET_YES;
648 zone_key = sqlite3_column_blob (plugin->iterate_records, 0); 648 zone_key = sqlite3_column_blob (stmt, 0);
649 name = (const char*) sqlite3_column_text (plugin->iterate_records, 1); 649 name = (const char*) sqlite3_column_text (stmt, 1);
650 record_count = sqlite3_column_int (plugin->iterate_records, 2); 650 record_count = sqlite3_column_int (stmt, 2);
651 data_size = sqlite3_column_bytes (plugin->iterate_records, 3); 651 data_size = sqlite3_column_bytes (stmt, 3);
652 data = sqlite3_column_blob (plugin->iterate_records, 3); 652 data = sqlite3_column_blob (stmt, 3);
653 expiration.abs_value = (uint64_t) sqlite3_column_int64 (plugin->iterate_records, 4); 653 expiration.abs_value = (uint64_t) sqlite3_column_int64 (stmt, 4);
654 sig = sqlite3_column_blob (plugin->iterate_records, 5); 654 sig = sqlite3_column_blob (stmt, 5);
655 655
656 if ( (sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) != sqlite3_column_bytes (plugin->iterate_records, 0)) || 656 if ( (sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) != sqlite3_column_bytes (stmt, 0)) ||
657 (sizeof (struct GNUNET_CRYPTO_RsaSignature) != sqlite3_column_bytes (plugin->iterate_records, 5)) || 657 (sizeof (struct GNUNET_CRYPTO_RsaSignature) != sqlite3_column_bytes (stmt, 5)) ||
658 (sizeof (struct DbRecord) * record_count > data_size) ) 658 (sizeof (struct DbRecord) * record_count > data_size) )
659 { 659 {
660 GNUNET_break (0); 660 GNUNET_break (0);
@@ -670,7 +670,7 @@ namestore_sqlite_iterate_records (void *cls,
670 off = record_count * sizeof (struct DbRecord); 670 off = record_count * sizeof (struct DbRecord);
671 for (i=0;i<record_count;i++) 671 for (i=0;i<record_count;i++)
672 { 672 {
673 if (off + db[i].data_size > data_size) 673 if (off + ntohl (db[i].data_size) > data_size)
674 { 674 {
675 GNUNET_break (0); 675 GNUNET_break (0);
676 ret = GNUNET_SYSERR; 676 ret = GNUNET_SYSERR;
@@ -690,10 +690,10 @@ namestore_sqlite_iterate_records (void *cls,
690 } 690 }
691 else 691 else
692 { 692 {
693 if (SQLITE_DONE != sret)
694 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
693 iter (iter_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL); 695 iter (iter_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL);
694 } 696 }
695 if (SQLITE_DONE != sret)
696 LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
697 if (SQLITE_OK != sqlite3_reset (stmt)) 697 if (SQLITE_OK != sqlite3_reset (stmt))
698 LOG_SQLITE (plugin, 698 LOG_SQLITE (plugin,
699 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 699 GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,