[tracker] libtracker-data: mark most sqlite functions as SQLITE_DETERMINISTIC



commit 24a8c0968ca083a692a9127237b3eb58f54687b5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 8 00:20:58 2016 +0200

    libtracker-data: mark most sqlite functions as SQLITE_DETERMINISTIC
    
    This flag helps the query planner in optimizing functions that are
    guaranteed to return the same result given the same input. This
    is the case for all functions, but SparqlRand().

 src/libtracker-data/tracker-db-interface-sqlite.c |   57 ++++++++++++++-------
 1 files changed, 38 insertions(+), 19 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 88cbd90..0b0bb99 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1323,69 +1323,86 @@ open_database (TrackerDBInterface  *db_interface,
        sqlite3_progress_handler (db_interface->db, 100,
                                  check_interrupt, db_interface);
 
-       sqlite3_create_function (db_interface->db, "SparqlRegex", 3, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlRegex", 3,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_regex,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlHaversineDistance", 4, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlHaversineDistance", 4,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_haversine_distance,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlCartesianDistance", 4, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlCartesianDistance", 4,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_cartesian_distance,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlStringFromFilename", 1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlStringFromFilename", 1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_string_from_filename,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlStringJoin", -1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlStringJoin", -1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_string_join,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlUriIsParent", 2, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlUriIsParent", 2,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_uri_is_parent,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlUriIsDescendant", -1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlUriIsDescendant", -1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_uri_is_descendant,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlLowerCase", 1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlLowerCase", 1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_lower_case,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlCaseFold", 1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlCaseFold", 1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_case_fold,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlNormalize", 2, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlNormalize", 2,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_normalize,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlUnaccent", 1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlUnaccent", 1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_unaccent,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlFormatTime", 1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlFormatTime", 1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_format_time,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlEncodeForUri", 1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlEncodeForUri", 1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_encode_for_uri,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlStringBefore", 2, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlStringBefore", 2,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_string_before,
                                 NULL, NULL);
-       sqlite3_create_function (db_interface->db, "SparqlStringAfter", 2, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlStringAfter", 2,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_string_after,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlCeil", 1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlCeil", 1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_ceil,
                                 NULL, NULL);
-       sqlite3_create_function (db_interface->db, "SparqlFloor", 1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlFloor", 1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_floor,
                                 NULL, NULL);
 
@@ -1393,11 +1410,13 @@ open_database (TrackerDBInterface  *db_interface,
                                 db_interface, &function_sparql_rand,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlChecksum", 2, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlChecksum", 2,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_checksum,
                                 NULL, NULL);
 
-       sqlite3_create_function (db_interface->db, "SparqlReplace", -1, SQLITE_ANY,
+       sqlite3_create_function (db_interface->db, "SparqlReplace", -1,
+                                SQLITE_ANY | SQLITE_DETERMINISTIC,
                                 db_interface, &function_sparql_replace,
                                 NULL, NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]