[tracker/wip/carlosg/sparql-parser-ng: 15/43] libtracker-data: Add method to fetch unused URNs
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql-parser-ng: 15/43] libtracker-data: Add method to fetch unused URNs
- Date: Sat, 3 Nov 2018 13:08:47 +0000 (UTC)
commit 6df5550fffd431f1480450333379a4af0718100d
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Aug 31 11:43:38 2018 +0200
libtracker-data: Add method to fetch unused URNs
src/libtracker-data/tracker-data-query.c | 33 ++++++++++++++++++++++++++++++++
src/libtracker-data/tracker-data-query.h | 3 +++
2 files changed, 36 insertions(+)
---
diff --git a/src/libtracker-data/tracker-data-query.c b/src/libtracker-data/tracker-data-query.c
index bce3e93a8..b6f553fbb 100644
--- a/src/libtracker-data/tracker-data-query.c
+++ b/src/libtracker-data/tracker-data-query.c
@@ -130,6 +130,39 @@ tracker_data_query_resource_id (TrackerDataManager *manager,
return id;
}
+gchar *
+tracker_data_query_unused_uuid (TrackerDataManager *manager,
+ TrackerDBInterface *iface)
+{
+ TrackerDBCursor *cursor = NULL;
+ TrackerDBStatement *stmt;
+ GError *error = NULL;
+ gchar *uuid = NULL;
+
+ stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT, &error,
+ "SELECT SparqlUUID()");
+
+ if (stmt) {
+ cursor = tracker_db_statement_start_cursor (stmt, &error);
+ g_object_unref (stmt);
+ }
+
+ if (cursor) {
+ if (tracker_db_cursor_iter_next (cursor, NULL, &error)) {
+ uuid = g_strdup (tracker_db_cursor_get_string (cursor, 0, NULL));
+ }
+
+ g_object_unref (cursor);
+ }
+
+ if (G_UNLIKELY (error)) {
+ g_critical ("Could not query resource ID: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ return uuid;
+}
+
TrackerDBCursor *
tracker_data_query_sparql_cursor (TrackerDataManager *manager,
diff --git a/src/libtracker-data/tracker-data-query.h b/src/libtracker-data/tracker-data-query.h
index 1add89f91..3b2df21fd 100644
--- a/src/libtracker-data/tracker-data-query.h
+++ b/src/libtracker-data/tracker-data-query.h
@@ -37,6 +37,9 @@ G_BEGIN_DECLS
gint tracker_data_query_resource_id (TrackerDataManager *manager,
TrackerDBInterface *iface,
const gchar *uri);
+gchar *tracker_data_query_unused_uuid (TrackerDataManager *manager,
+ TrackerDBInterface *iface);
+
TrackerDBCursor *tracker_data_query_sparql_cursor (TrackerDataManager *manager,
const gchar *query,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]