[tracker: 1/2] libtracker-data: Enhance nrl:secondaryIndex validation




commit e5fb8f922895b29bcfeb816ec1ccf8c7b902cee6
Author: Daniele Nicolodi <daniele grinta net>
Date:   Mon May 17 11:56:04 2021 +0200

    libtracker-data: Enhance nrl:secondaryIndex validation
    
    This should avoid the creation of nonsensical SQLite indexes.

 src/libtracker-data/tracker-data-manager.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index b2e774ee8..eb1941ee6 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1204,6 +1204,17 @@ tracker_data_ontology_load_statement (TrackerDataManager  *manager,
                        return;
                }
 
+                if (!tracker_property_get_indexed (property)) {
+                        g_critical ("%s: nrl:secondaryindex only applies to nrl:indexed properties", 
ontology_path);
+                        return;
+                }
+
+                if (tracker_property_get_multiple_values (property) ||
+                    tracker_property_get_multiple_values (secondary_index)) {
+                        g_critical ("%s: nrl:secondaryindex cannot be applied to properties with 
nrl:maxCardinality higher than one", ontology_path);
+                        return;
+                }
+
                tracker_property_set_secondary_index (property, secondary_index);
        } else if (g_strcmp0 (predicate, TRACKER_PREFIX_NRL "fulltextIndexed") == 0) {
                TrackerProperty *property;


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