[tracker/wip/carlosg/serialize-api: 1/13] libtracker-data: Do not forward cursor variable names separately
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/serialize-api: 1/13] libtracker-data: Do not forward cursor variable names separately
- Date: Wed, 2 Feb 2022 15:10:14 +0000 (UTC)
commit 52c1ab9d928c56568a9381b06d0d451bbe33c8de
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jan 29 22:07:07 2022 +0100
libtracker-data: Do not forward cursor variable names separately
Forward variable names via the AS keyword in SQL in all cases, so we do
not need to forward these names separately, and have these fetched from
the sqlite3_stmt instead.
src/libtracker-data/tracker-db-interface-sqlite.c | 45 ++++++-----------------
src/libtracker-data/tracker-db-interface.h | 2 -
src/libtracker-data/tracker-sparql.c | 15 +-------
3 files changed, 12 insertions(+), 50 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 31f7d9f68..a0944e9bd 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -117,8 +117,6 @@ struct TrackerDBCursor {
gboolean finished;
TrackerPropertyType *types;
guint n_types;
- gchar **variable_names;
- guint n_variable_names;
};
struct TrackerDBCursorClass {
@@ -145,9 +143,7 @@ static TrackerDBStatement *tracker_db_statement_sqlite_new (TrackerDBIn
static void tracker_db_statement_sqlite_reset (TrackerDBStatement *stmt);
static TrackerDBCursor *tracker_db_cursor_sqlite_new (TrackerDBStatement *ref_stmt,
TrackerPropertyType *types,
- guint n_types,
- const gchar * const *variable_names,
- guint
n_variable_names);
+ guint n_types);
static gboolean tracker_db_cursor_get_boolean (TrackerSparqlCursor *cursor,
guint column);
static gboolean db_cursor_iter_next (TrackerDBCursor *cursor,
@@ -3129,7 +3125,6 @@ static void
tracker_db_cursor_finalize (GObject *object)
{
TrackerDBCursor *cursor;
- guint i;
cursor = TRACKER_DB_CURSOR (object);
@@ -3137,11 +3132,6 @@ tracker_db_cursor_finalize (GObject *object)
g_free (cursor->types);
- for (i = 0; i < cursor->n_variable_names; i++) {
- g_free (cursor->variable_names[i]);
- }
- g_free (cursor->variable_names);
-
G_OBJECT_CLASS (tracker_db_cursor_parent_class)->finalize (object);
}
@@ -3231,9 +3221,7 @@ tracker_db_cursor_class_init (TrackerDBCursorClass *class)
static TrackerDBCursor *
tracker_db_cursor_sqlite_new (TrackerDBStatement *ref_stmt,
TrackerPropertyType *types,
- guint n_types,
- const gchar * const *variable_names,
- guint n_variable_names)
+ guint n_types)
{
TrackerDBCursor *cursor;
TrackerDBInterface *iface;
@@ -3274,16 +3262,6 @@ tracker_db_cursor_sqlite_new (TrackerDBStatement *ref_stmt,
}
}
- if (variable_names) {
- guint i;
-
- cursor->variable_names = g_new (gchar *, n_variable_names);
- cursor->n_variable_names = n_variable_names;
- for (i = 0; i < n_variable_names; i++) {
- cursor->variable_names[i] = g_strdup (variable_names[i]);
- }
- }
-
return cursor;
}
@@ -3637,14 +3615,15 @@ tracker_db_cursor_get_variable_name (TrackerDBCursor *cursor,
iface = cursor->ref_stmt->db_interface;
tracker_db_interface_lock (iface);
+ result = sqlite3_column_name (cursor->stmt, column);
+ tracker_db_interface_unlock (iface);
- if (column < cursor->n_variable_names) {
- result = cursor->variable_names[column];
- } else {
- result = sqlite3_column_name (cursor->stmt, column);
- }
+ if (!result)
+ return NULL;
- tracker_db_interface_unlock (iface);
+ /* Weed out our own internal variable prefixes */
+ if (g_str_has_prefix (result, "v_"))
+ return &result[2];
return result;
}
@@ -3693,21 +3672,19 @@ tracker_db_statement_start_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, NULL, 0, NULL, 0);
+ return tracker_db_cursor_sqlite_new (stmt, NULL, 0);
}
TrackerDBCursor *
tracker_db_statement_start_sparql_cursor (TrackerDBStatement *stmt,
TrackerPropertyType *types,
guint n_types,
- const gchar * const *variable_names,
- guint n_variable_names,
GError **error)
{
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, types, n_types, variable_names, n_variable_names);
+ return tracker_db_cursor_sqlite_new (stmt, types, n_types);
}
static void
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index ca651126d..83e0e9438 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -145,8 +145,6 @@ TrackerDBCursor * tracker_db_statement_start_cursor (TrackerDBS
TrackerDBCursor * tracker_db_statement_start_sparql_cursor (TrackerDBStatement *stmt,
TrackerPropertyType *types,
guint n_types,
- const gchar * const
*variable_names,
- guint
n_variable_names,
GError **error);
/* Functions to deal with a cursor */
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 225554dc8..b773a0901 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -174,7 +174,6 @@ struct _TrackerSparql
GHashTable *prefix_map;
GList *filter_clauses;
- GPtrArray *var_names;
GArray *var_types;
GHashTable *cached_bindings;
@@ -243,7 +242,6 @@ tracker_sparql_finalize (GObject *object)
g_ptr_array_unref (sparql->named_graphs);
g_ptr_array_unref (sparql->anon_graphs);
- g_ptr_array_unref (sparql->var_names);
g_array_unref (sparql->var_types);
g_free (sparql->base);
@@ -2792,7 +2790,6 @@ tracker_sparql_add_select_var (TrackerSparql *sparql,
{
if (sparql->current_state->select_context == sparql->context) {
/* Topmost select context */
- g_ptr_array_add (sparql->var_names, g_strdup (name));
g_array_append_val (sparql->var_types, type);
} else {
TrackerContext *parent;
@@ -2890,9 +2887,6 @@ translate_SelectClause (TrackerSparql *sparql,
convert_expression_to_string (sparql, prop_type);
}
- if (sparql->current_state->select_context == sparql->context)
- _append_string_printf (sparql, "AS \"%s\" ", var->name);
-
tracker_sparql_swap_builder (sparql, old);
first = FALSE;
}
@@ -4648,7 +4642,6 @@ get_solution_for_pattern (TrackerSparql *sparql,
return NULL;
cursor = tracker_db_statement_start_sparql_cursor (stmt,
- NULL, 0,
NULL, 0,
error);
g_object_unref (stmt);
@@ -9738,7 +9731,6 @@ tracker_sparql_init (TrackerSparql *sparql)
g_free, g_object_unref);
sparql->parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
- sparql->var_names = g_ptr_array_new_with_free_func (g_free);
sparql->var_types = g_array_new (FALSE, FALSE, sizeof (TrackerPropertyType));
sparql->anon_graphs = g_ptr_array_new_with_free_func (g_free);
sparql->named_graphs = g_ptr_array_new_with_free_func (g_free);
@@ -9931,7 +9923,6 @@ tracker_sparql_reset_state (TrackerSparql *sparql)
g_clear_object (&sparql->context);
g_list_free (sparql->filter_clauses);
sparql->filter_clauses = NULL;
- g_ptr_array_set_size (sparql->var_names, 0);
g_array_set_size (sparql->var_types, 0);
g_hash_table_remove_all (sparql->cached_bindings);
g_hash_table_remove_all (sparql->parameters);
@@ -9948,8 +9939,7 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
TrackerDBInterface *iface = NULL;
TrackerDBCursor *cursor = NULL;
TrackerPropertyType *types;
- const gchar * const *names;
- guint n_types, n_names;
+ guint n_types;
g_mutex_lock (&sparql->mutex);
@@ -9999,12 +9989,9 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
types = (TrackerPropertyType *) sparql->var_types->data;
n_types = sparql->var_types->len;
- names = (const gchar * const *) sparql->var_names->pdata;
- n_names = sparql->var_names->len;
cursor = tracker_db_statement_start_sparql_cursor (stmt,
types, n_types,
- names, n_names,
error);
g_object_unref (stmt);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]