[tracker] libtracker-data: Add SparqlEncodeForUri sqlite function
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Add SparqlEncodeForUri sqlite function
- Date: Mon, 19 Oct 2015 12:15:24 +0000 (UTC)
commit 9041399e4c51508c6770d4ed26a0990e63105a64
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jul 28 22:03:10 2015 +0200
libtracker-data: Add SparqlEncodeForUri sqlite function
This will be used on ENCODE_FOR_URI(), as per sparql 1.1.
src/libtracker-data/tracker-db-interface-sqlite.c | 22 +++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c
b/src/libtracker-data/tracker-db-interface-sqlite.c
index a1d4d83..01fc19d 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -883,6 +883,24 @@ function_sparql_unaccent (sqlite3_context *context,
#endif
+static void
+function_sparql_encode_for_uri (sqlite3_context *context,
+ int argc,
+ sqlite3_value *argv[])
+{
+ const gchar *str;
+ gchar *encoded;
+
+ if (argc != 1) {
+ sqlite3_result_error (context, "Invalid argument count", -1);
+ return;
+ }
+
+ str = sqlite3_value_text (argv[0]);
+ encoded = g_uri_escape_string (str, NULL, FALSE);
+ sqlite3_result_text (context, encoded, -1, g_free);
+}
+
static inline int
stmt_step (sqlite3_stmt *stmt)
{
@@ -1006,6 +1024,10 @@ open_database (TrackerDBInterface *db_interface,
db_interface, &function_sparql_format_time,
NULL, NULL);
+ sqlite3_create_function (db_interface->db, "SparqlEncodeForUri", 1, SQLITE_ANY,
+ db_interface, &function_sparql_encode_for_uri,
+ NULL, NULL);
+
sqlite3_extended_result_codes (db_interface->db, 0);
sqlite3_busy_timeout (db_interface->db, 100000);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]