/*
* This file is part of GNUnet
* (C) 2009, 2011 Christian Grothoff (and other contributing authors)
- *
+ *
* GNUnet is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 3, or (at your
* option) any later version.
- *
+ *
* GNUnet is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNUnet; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
/**
* Create our database indices.
- *
+ *
* @param dbh handle to the database
*/
static void
(sq_prepare
(plugin->dbh,
"SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ "
- "FROM gn090 INDEXED BY idx_repl_rvalue " "WHERE repl=?2 AND"
- " (rvalue>=?1 OR"
- " NOT EXISTS (SELECT 1 FROM gn090 INDEXED BY idx_repl_rvalue WHERE repl=?2 AND rvalue>=?1 LIMIT 1))"
- " ORDER BY rvalue ASC" " LIMIT 1",
- &plugin->selRepl) != SQLITE_OK) ||
+ "FROM gn090 "
+#if SQLITE_VERSION_NUMBER >= 3007000
+ "INDEXED BY idx_repl_rvalue "
+#endif
+ "WHERE repl=?2 AND "
+ " (rvalue>=?1 OR "
+ " NOT EXISTS (SELECT 1 FROM gn090 "
+#if SQLITE_VERSION_NUMBER >= 3007000
+ "INDEXED BY idx_repl_rvalue "
+#endif
+ "WHERE repl=?2 AND rvalue>=?1 LIMIT 1) ) "
+ "ORDER BY rvalue ASC LIMIT 1", &plugin->selRepl) != SQLITE_OK) ||
(sq_prepare
- (plugin->dbh,
- "SELECT MAX(repl) " "FROM gn090 INDEXED BY idx_repl_rvalue",
+ (plugin->dbh, "SELECT MAX(repl) FROM gn090"
+#if SQLITE_VERSION_NUMBER >= 3007000
+ " INDEXED BY idx_repl_rvalue"
+#endif
+ "",
&plugin->maxRepl) != SQLITE_OK) ||
(sq_prepare
(plugin->dbh,
"SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ "
- "FROM gn090 INDEXED BY idx_expire"
- " WHERE NOT EXISTS (SELECT 1 FROM gn090 WHERE expire < ?1 LIMIT 1) OR (expire < ?1) "
- " ORDER BY expire ASC LIMIT 1", &plugin->selExpi) != SQLITE_OK) ||
+ "FROM gn090 "
+#if SQLITE_VERSION_NUMBER >= 3007000
+ "INDEXED BY idx_expire "
+#endif
+ "WHERE NOT EXISTS (SELECT 1 FROM gn090 WHERE expire < ?1 LIMIT 1) OR (expire < ?1) "
+ "ORDER BY expire ASC LIMIT 1", &plugin->selExpi) != SQLITE_OK) ||
(sq_prepare
(plugin->dbh,
"SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ "
- "FROM gn090 INDEXED BY idx_anon_type_hash "
+ "FROM gn090 "
+#if SQLITE_VERSION_NUMBER >= 3007000
+ "INDEXED BY idx_anon_type_hash "
+#endif
"WHERE (anonLevel = 0 AND type=?1) "
"ORDER BY hash DESC LIMIT 1 OFFSET ?2",
&plugin->selZeroAnon) != SQLITE_OK) ||
(sq_prepare
(plugin->dbh,
- "INSERT INTO gn090 (repl, type, prio, "
- "anonLevel, expire, rvalue, hash, vhash, value) "
+ "INSERT INTO gn090 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
&plugin->insertContent) != SQLITE_OK) ||
(sq_prepare
* the given processor for the item.
*
* @param cls our plugin context
- * @param offset offset of the result (modulo num-results);
+ * @param offset offset of the result (modulo num-results);
* specific ordering does not matter for the offset
* @param type entries of which type should be considered?
* Use 0 for any type.
/**
* Get a random item for replication. Returns a single random item
- * from those with the highest replication counters. The item's
+ * from those with the highest replication counters. The item's
* replication counter is decremented by one IF it was positive before.
* Call 'proc' with all values ZERO or NULL if the datastore is empty.
*