[tracker/wip/carlosg/serialize-api: 3/11] libtracker-data: Forward number of columns to cursor




commit 52193b75d74e7f5eb2a09e1673fd734bffb8aa49
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jan 30 12:52:59 2022 +0100

    libtracker-data: Forward number of columns to cursor
    
    This way, we can allow the amount of columns as seen by the user
    differ from the real number of columns. These extra columns might
    bring additional per-row data, like correct column value types
    that do not depend on static information or lacking (from our
    perspective) SQLite type information.

 src/libtracker-data/tracker-db-interface-sqlite.c | 3 ++-
 src/libtracker-data/tracker-db-interface.h        | 1 +
 src/libtracker-data/tracker-sparql.c              | 9 ++++++---
 3 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 6fec55741..53a53af2d 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -3693,6 +3693,7 @@ tracker_db_statement_start_cursor (TrackerDBStatement  *stmt,
 
 TrackerDBCursor *
 tracker_db_statement_start_sparql_cursor (TrackerDBStatement   *stmt,
+                                          guint                 n_columns,
                                           TrackerPropertyType  *types,
                                           guint                 n_types,
                                           GError              **error)
@@ -3700,7 +3701,7 @@ tracker_db_statement_start_sparql_cursor (TrackerDBStatement   *stmt,
        g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL);
        g_return_val_if_fail (!stmt->stmt_is_used, NULL);
 
-       return tracker_db_cursor_sqlite_new (stmt, 0, types, n_types);
+       return tracker_db_cursor_sqlite_new (stmt, n_columns, types, n_types);
 }
 
 static void
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index 83e0e9438..67b76704d 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -143,6 +143,7 @@ void                    tracker_db_statement_execute                 (TrackerDBS
 TrackerDBCursor *       tracker_db_statement_start_cursor            (TrackerDBStatement         *stmt,
                                                                       GError                    **error);
 TrackerDBCursor *       tracker_db_statement_start_sparql_cursor     (TrackerDBStatement         *stmt,
+                                                                      guint                       n_columns,
                                                                       TrackerPropertyType        *types,
                                                                       guint                       n_types,
                                                                       GError                    **error);
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index e527a217f..30e43e5dc 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -4650,7 +4650,7 @@ get_solution_for_pattern (TrackerSparql      *sparql,
 
        iface = tracker_data_manager_get_writable_db_interface (sparql->data_manager);
        stmt = prepare_query (sparql, iface,
-                             TRACKER_SELECT_CONTEXT (sparql->context)->literal_bindings,
+                             TRACKER_SELECT_CONTEXT (sparql->context)->literal_bindings,
                              NULL, TRUE,
                              error);
        g_clear_object (&sparql->context);
@@ -4658,7 +4658,7 @@ get_solution_for_pattern (TrackerSparql      *sparql,
        if (!stmt)
                return NULL;
 
-       cursor = tracker_db_statement_start_sparql_cursor (stmt,
+       cursor = tracker_db_statement_start_sparql_cursor (stmt, 0,
                                                           NULL, 0,
                                                           error);
        g_object_unref (stmt);
@@ -9955,6 +9955,7 @@ tracker_sparql_execute_cursor (TrackerSparql  *sparql,
        TrackerDBStatement *stmt;
        TrackerDBInterface *iface = NULL;
        TrackerDBCursor *cursor = NULL;
+       TrackerSelectContext *select_context;
        TrackerPropertyType *types;
        guint n_types;
 
@@ -9996,8 +9997,9 @@ tracker_sparql_execute_cursor (TrackerSparql  *sparql,
        if (!iface)
                goto error;
 
+       select_context = TRACKER_SELECT_CONTEXT (sparql->context);
        stmt = prepare_query (sparql, iface,
-                             TRACKER_SELECT_CONTEXT (sparql->context)->literal_bindings,
+                             select_context->literal_bindings,
                              parameters,
                              sparql->cacheable,
                              error);
@@ -10008,6 +10010,7 @@ tracker_sparql_execute_cursor (TrackerSparql  *sparql,
        n_types = sparql->var_types->len;
 
        cursor = tracker_db_statement_start_sparql_cursor (stmt,
+                                                          select_context->n_columns,
                                                           types, n_types,
                                                           error);
        g_object_unref (stmt);


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