}
if (SQLITE_DONE != sret)
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
- sqlite3_finalize (plugin->iterate_records);
+ if (SQLITE_OK != sqlite3_reset (plugin->iterate_records))
+ LOG_SQLITE (plugin,
+ GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_reset");
return ret;
}
}
else if (SQLITE_DONE != ret)
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
- sqlite3_finalize (plugin->get_node);
+ if (SQLITE_OK != sqlite3_reset (plugin->get_node))
+ LOG_SQLITE (plugin,
+ GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_reset");
return ret;
}
{
struct Plugin *plugin = cls;
int ret;
+ int sret;
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key;
struct GNUNET_NAMESTORE_SignatureLocation top_loc;
const struct GNUNET_CRYPTO_RsaSignature *zone_sig;
return GNUNET_SYSERR;
}
ret = GNUNET_NO;
- if (SQLITE_ROW == (ret = sqlite3_step (plugin->get_signature)))
+ if (SQLITE_ROW == (sret = sqlite3_step (plugin->get_signature)))
{
top_loc.offset = 0;
top_loc.revision = sqlite3_column_int (plugin->get_signature, 0);
top_hash);
}
}
- if (SQLITE_DONE != ret)
+ else if (SQLITE_DONE != sret)
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
- sqlite3_finalize (plugin->get_signature);
+ if (SQLITE_OK != sqlite3_reset (plugin->get_signature))
+ LOG_SQLITE (plugin,
+ GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_reset");
return ret;
}
{
int n;
- if (SQLITE_OK != sqlite3_bind_blob (plugin->delete_zone_records, 1, zone, sizeof (GNUNET_HashCode), SQLITE_STATIC))
+ if (SQLITE_OK != sqlite3_bind_blob (stmt, 1, zone, sizeof (GNUNET_HashCode), SQLITE_STATIC))
{
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_bind_XXXX");
- if (SQLITE_OK != sqlite3_reset (plugin->delete_zone_records))
+ if (SQLITE_OK != sqlite3_reset (stmt))
LOG_SQLITE (plugin,
GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_reset");
return;
}
- n = sqlite3_step (plugin->put_signature);
- if (SQLITE_OK != sqlite3_reset (plugin->delete_zone_records))
+ n = sqlite3_step (stmt);
+ if (SQLITE_OK != sqlite3_reset (stmt))
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_reset");
switch (n)
{
case SQLITE_DONE:
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Zone records deleted\n");
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Values deleted\n");
break;
case SQLITE_BUSY:
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
GNUNET_HashCode zone;
struct DeleteContext dc;
+ GNUNET_break (0 == loc->offset); /* little sanity check */
GNUNET_CRYPTO_hash (zone_key,
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
&zone);
GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_reset");
return GNUNET_SYSERR;
-
}
n = sqlite3_step (plugin->put_signature);
if (SQLITE_OK != sqlite3_reset (plugin->put_signature))
memset (&tzone_key, 13, sizeof (tzone_key));
tloc.depth = (id % 10);
- tloc.offset = (id % 3);
+ tloc.offset = 0;
tloc.revision = id % 1024;
memset (&ttop_sig, 24, sizeof (ttop_sig));
memset (&troot_hash, 42, sizeof (troot_hash));
static void
get_signature (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id)
{
- GNUNET_HashCode root_hash;
+ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
+ GNUNET_HashCode zone;
- memset (&root_hash, 42, sizeof (root_hash));
+ memset (&zone_key, 13, sizeof (zone_key));
+ GNUNET_CRYPTO_hash (&zone_key, sizeof (zone_key), &zone);
GNUNET_assert (GNUNET_OK ==
nsp->get_signature (nsp->cls,
- &root_hash,
+ &zone,
test_signature,
&id));
}
memset (&zone_key, 13, sizeof (zone_key));
loc.depth = (id % 10);
- loc.offset = (id % 3);
+ loc.offset = 0;
loc.revision = id % 1024;
memset (&top_sig, 24, sizeof (top_sig));
memset (&root_hash, 42, sizeof (root_hash));
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_NAMESTORE_PluginFunctions *nsp;
+ GNUNET_HashCode zone;
ok = 0;
nsp = load_plugin (cfg);
get_node (nsp, 1);
put_signature (nsp, 1);
get_signature (nsp, 1);
-
+
+ memset (&zone, 42, sizeof (zone));
+ nsp->delete_zone (nsp->cls, &zone);
unload_plugin (nsp);
}
GNUNET_GETOPT_OPTION_END
};
+ GNUNET_DISK_directory_remove ("/tmp/gnunet-test-plugin-namestore-sqlite");
GNUNET_log_setup ("test-plugin-namestore",
#if VERBOSE
"DEBUG",
"test-plugin-namestore", "nohelp", options, &run, NULL);
if (ok != 0)
FPRINTF (stderr, "Missed some testcases: %d\n", ok);
+ GNUNET_DISK_directory_remove ("/tmp/gnunet-test-plugin-namestore-sqlite");
return ok;
}