[tracker/wip/carlosg/fts-consistence-fixes: 2/4] libtracker-sparql: Remove value from array after deletion




commit 6067f032d3b7ed4614bedf840b4edc86165567e3
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed May 4 21:44:55 2022 +0200

    libtracker-sparql: Remove value from array after deletion
    
    Every other path that fetches the array of previous values for
    deletion also deletes the GValue from the cached array. This
    place handling our almost unused, non-standard INSERT OR REPLACE
    syntax, was missing this.
    
    Since the handling of FTS updates later poke the cached values
    to update all FTS columns, this may result in the deleted value
    being inserted again in the FTS tree, resulting in another
    unbalanced tree situation (as the actual column containing the
    data and the token tree for the corresponding content-less column
    in the FTS table differ).
    
    An example of this situation is:
    
      INSERT OR REPLACE {
        <a> a nie:InformationElement;
          nie:title 'title';
      }
      INSERT OR REPLACE {
        <a> a nie:InformationElement;
          nie:title 'title2';
      }
    
      SELECT ?u { ?u fts:match 'title' }
    
    Returning matches for the old value.

 src/libtracker-sparql/core/tracker-data-update.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c 
b/src/libtracker-sparql/core/tracker-data-update.c
index 866c8e081..0ada33356 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -2444,6 +2444,8 @@ delete_single_valued (TrackerData       *data,
                                            FALSE);
                        if (tracker_property_get_data_type (predicate) == TRACKER_PROPERTY_TYPE_RESOURCE)
                                tracker_data_resource_unref (data, g_value_get_int64 (value), 
multiple_values);
+
+                       g_array_remove_index (old_values, 0);
                } else {
                        /* no need to error out if statement does not exist for any reason */
                        g_clear_error (&inner_error);


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