From 063ce6a14df7382df008f07c547bf3d3f5c79dae Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 14 Sep 2011 12:29:57 +0000 Subject: [PATCH] use INDEXED BY only for sqlite >= 3.7 --- src/datastore/plugin_datastore_sqlite.c | 28 ++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 2620c3682..931202707 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -326,23 +326,41 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, (sq_prepare (plugin->dbh, "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " - "FROM gn090 INDEXED BY idx_repl_rvalue WHERE repl=?2 AND " + "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 INDEXED BY idx_repl_rvalue WHERE repl=?2 AND rvalue>=?1 LIMIT 1) ) " + " 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 " + "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) || -- 2.25.1