#define SELECT_ENTRY_BY_HASH_VHASH_AND_TYPE "SELECT type,prio,anonLevel,expire,hash,value,uid FROM gn090 FORCE INDEX (idx_hash_vhash) WHERE hash=? AND vhash=? AND type=? ORDER BY uid ASC LIMIT 1 OFFSET ?"
struct GNUNET_MysqlStatementHandle *select_entry_by_hash_vhash_and_type;
-#define UPDATE_ENTRY "UPDATE gn090 FORCE INDEX (uid) SET prio=prio+?,expire=IF(expire>=?,expire,?) WHERE uid=? LIMIT 1"
+#define UPDATE_ENTRY "UPDATE gn090 SET prio=prio+?,expire=IF(expire>=?,expire,?) WHERE uid=? LIMIT 1"
struct GNUNET_MysqlStatementHandle *update_entry;
#define SELECT_SIZE "SELECT SUM(BIT_LENGTH(value) DIV 8) FROM gn090"
}
GNUNET_assert (mysql_dbname != NULL);
- mysql_real_connect (ret->dbf, mysql_server, mysql_user, mysql_password,
- mysql_dbname, (unsigned int) mysql_port, NULL,
+ mysql_real_connect (ret->dbf,
+ mysql_server,
+ mysql_user, mysql_password,
+ mysql_dbname,
+ (unsigned int) mysql_port, NULL,
CLIENT_IGNORE_SIGPIPE);
GNUNET_free_non_null (mysql_server);
GNUNET_free_non_null (mysql_user);
}
if (! ( (pc == 0) && (-1 != (int) ft) && (va_arg (ap, int) == -1) ) )
{
- GNUNET_break (0);
+ GNUNET_assert (0);
return GNUNET_SYSERR;
}
if (mysql_stmt_bind_param (s->statement, qbind))
ret = prepared_statement_run (plugin,
plugin->delete_entry_by_uid,
NULL,
- MYSQL_TYPE_LONGLONG, uid, GNUNET_YES,
+ MYSQL_TYPE_LONGLONG, &uid, GNUNET_YES,
-1);
if (ret > 0)
return GNUNET_OK;
exp);
#endif
expiration.abs_value = exp;
- ret = nrc->dviter (nrc->dviter_cls, nrc,
+ ret = nrc->dviter (nrc->dviter_cls, (nrc->end_it == GNUNET_YES) ? NULL : nrc,
&key,
size, value,
type, priority, anonymity, expiration,
struct NextRequestClosure *nrc)
{
struct Plugin *plugin = cls;
- unsigned long long nt;
- nt = (unsigned long long) nrc->now.abs_value;
+ nrc->end_it = GNUNET_YES;
return prepared_statement_run_select (plugin,
plugin->select_replication,
- 6, nrc->rbind,
+ 7, nrc->rbind,
&return_ok, NULL,
- MYSQL_TYPE_LONGLONG, &nt, GNUNET_YES,
-1);
}
*
* @param cls the 'struct Plugin'
* @param nrc the context (not used)
+ * @return GNUNET_OK on success, GNUNET_NO if there are
+ * no more values, GNUNET_SYSERR on error
*/
static int
expiration_prepare (void *cls,
struct Plugin *plugin = cls;
long long nt;
+ if (NULL == nrc)
+ return GNUNET_NO;
+ nrc->end_it = GNUNET_YES;
nt = (long long) nrc->now.abs_value;
return prepared_statement_run_select
(plugin,
plugin->select_expiration,
- 6, nrc->rbind,
+ 7, nrc->rbind,
&return_ok, NULL,
MYSQL_TYPE_LONGLONG, &nt, GNUNET_YES,
-1);
{
struct Plugin *plugin = cls;
- if ((GNUNET_OK != run_statement (plugin,
- "DROP TABLE gn090")) ||
- (GNUNET_OK != run_statement (plugin,
- "DROP TABLE gn072")))
+ if (GNUNET_OK != run_statement (plugin,
+ "DROP TABLE gn090"))
return; /* error */
plugin->env->duc (plugin->env->cls, 0);
}
" expire BIGINT UNSIGNED NOT NULL DEFAULT 0,"
" hash BINARY(64) NOT NULL DEFAULT '',"
" vhash BINARY(64) NOT NULL DEFAULT '',"
- " value BLOB NOT NULL DEFAULT ''"
- " uid BIGINT NOT NULL AUTO_INCREMENT"
- " PRIMARY KEY (uid)"
+ " value BLOB NOT NULL DEFAULT '',"
+ " uid BIGINT NOT NULL AUTO_INCREMENT,"
+ " PRIMARY KEY (uid),"
" INDEX idx_hash (hash(64)),"
" INDEX idx_hash_uid (hash(64),uid),"
" INDEX idx_hash_vhash (hash(64),vhash(64)),"