[128276] trunk/base/src/cregistry/entry.c

cal at macports.org cal at macports.org
Mon Nov 17 15:31:22 PST 2014


Revision: 128276
          https://trac.macports.org/changeset/128276
Author:   cal at macports.org
Date:     2014-11-17 15:31:21 -0800 (Mon, 17 Nov 2014)
Log Message:
-----------
base: cregistry/entry.c: Fix queries using wrong indices with SQLite NGQP

Modified Paths:
--------------
    trunk/base/src/cregistry/entry.c

Modified: trunk/base/src/cregistry/entry.c
===================================================================
--- trunk/base/src/cregistry/entry.c	2014-11-17 23:23:34 UTC (rev 128275)
+++ trunk/base/src/cregistry/entry.c	2014-11-17 23:31:21 UTC (rev 128276)
@@ -185,11 +185,17 @@
     int lower_bound = 0;
     char* query;
     if (strlen(epoch) > 0) {
-        query = "SELECT id FROM registry.ports WHERE name=? AND version=? "
-        "AND revision=? AND variants=? AND epoch=?";
+        query = "SELECT id FROM registry.ports "
+#if SQLITE_VERSION_NUMBER >= 3006004
+                "INDEXED BY port_name "
+#endif
+                "WHERE name=? AND version=? AND revision=? AND variants=? AND epoch=?";
     } else {
-        query = "SELECT id FROM registry.ports WHERE name=? AND version=? "
-        "AND revision=? AND variants=? AND epoch!=?";
+        query = "SELECT id FROM registry.ports "
+#if SQLITE_VERSION_NUMBER >= 3006004
+                "INDEXED BY port_name "
+#endif
+                "WHERE name=? AND version=? AND revision=? AND variants=? AND epoch!=?";
     }
     if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_text(stmt, 1, name, -1, SQLITE_STATIC)
@@ -494,7 +500,11 @@
     if (name == NULL) {
         format = "%s WHERE state='installed'";
     } else {
-        format = "%s WHERE state='installed' AND name='%q'";
+        format = "%s "
+#if SQLITE_VERSION_NUMBER >= 3006004
+                "INDEXED BY port_name "
+#endif
+                "WHERE state='installed' AND name='%q'";
     }
     query = sqlite3_mprintf(format, select, name);
     result = reg_all_entries(reg, query, -1, entries, errPtr);
@@ -826,7 +836,11 @@
     reg_registry* reg = entry->reg;
     int result = 1;
     sqlite3_stmt* stmt = NULL;
-    char* query = "DELETE FROM registry.files WHERE path=? AND id=?";
+    char* query = "DELETE FROM registry.files "
+#if SQLITE_VERSION_NUMBER >= 3006004
+                  "INDEXED BY file_path "
+#endif
+                  "WHERE path=? AND id=?";
     if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(stmt, 2, entry->id) == SQLITE_OK)) {
         int i;
@@ -1030,8 +1044,8 @@
     char* update_query = "UPDATE registry.files "
 #if SQLITE_VERSION_NUMBER >= 3006004
         /* if the version of SQLite supports it force the usage of the index on
-         * path, rather than the one on id (which has a lot less discriminative
-         * power) and leads to very slow queries. This is needed for the new
+         * path, rather than the one on id which has a lot less discriminative
+         * power and leads to very slow queries. This is needed for the new
          * query planner introduced in 3.8.0 which would not use the correct
          * index automatically. */
         "INDEXED BY file_path "
@@ -1137,8 +1151,8 @@
     char* query = "UPDATE registry.files "
 #if SQLITE_VERSION_NUMBER >= 3006004
         /* if the version of SQLite supports it force the usage of the index on
-         * path, rather than the one on id (which has a lot less discriminative
-         * power) and leads to very slow queries. This is needed for the new
+         * path, rather than the one on id which has a lot less discriminative
+         * power and leads to very slow queries. This is needed for the new
          * query planner introduced in 3.8.0 which would not use the correct
          * index automatically. */
         "INDEXED BY file_actual "
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20141117/ffa3a6e1/attachment.html>


More information about the macports-changes mailing list