-
-#if DEBUG_DATACACHE_SQLITE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n",
- "PUT",
- (unsigned int) size,
- GNUNET_h2s (key),
- (unsigned long long) GNUNET_TIME_absolute_get_remaining (discard_time).value);
-#endif
- if (sq_prepare (plugin->dbh,
- "INSERT INTO ds090 "
- "(type, expire, key, value) "
- "VALUES (?, ?, ?, ?)", &stmt) != SQLITE_OK)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- _("`%s' failed at %s:%d with error: %s\n"),
- "sq_prepare", __FILE__, __LINE__,
- sqlite3_errmsg (plugin->dbh));
- return 0;
- }
- if ( (SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) ||
- (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, discard_time.value)) ||
- (SQLITE_OK != sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode),
- SQLITE_TRANSIENT)) ||
- (SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size, SQLITE_TRANSIENT)))
- {
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind_xxx");
- sqlite3_finalize (stmt);
- return 0;
- }
+ int64_t dval;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Processing `%s' of %u bytes with key `%4s' and expiration %s\n",
+ "PUT", (unsigned int) size, GNUNET_h2s (key),
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (discard_time), GNUNET_YES));
+ dval = (int64_t) discard_time.abs_value;
+ if (dval < 0)
+ dval = INT64_MAX;
+ if (sq_prepare
+ (plugin->dbh,
+ "INSERT INTO ds090 (type, expire, key, value) VALUES (?, ?, ?, ?)",
+ &stmt) != SQLITE_OK)
+ {
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sq_prepare");
+ return 0;
+ }
+ if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) ||
+ (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, dval)) ||
+ (SQLITE_OK !=
+ sqlite3_bind_blob (stmt, 3, key, sizeof (struct GNUNET_HashCode),
+ SQLITE_TRANSIENT)) ||
+ (SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size, SQLITE_TRANSIENT)))
+ {
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_bind_xxx");
+ sqlite3_finalize (stmt);
+ return 0;
+ }