[tracker/wip/carlosg/sparql-parser-ng: 6/43] libtracker-data: Make SparqlRegex() SQL function take 2/3 arguments
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql-parser-ng: 6/43] libtracker-data: Make SparqlRegex() SQL function take 2/3 arguments
- Date: Sat, 3 Nov 2018 13:08:01 +0000 (UTC)
commit 55cf093a518d289b76e167e753c64935d98288e0
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Mar 19 11:37:29 2018 +0100
libtracker-data: Make SparqlRegex() SQL function take 2/3 arguments
So the sparql parser can defer optional arguments to it.
src/libtracker-data/tracker-db-interface-sqlite.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c
b/src/libtracker-data/tracker-db-interface-sqlite.c
index dbecce9e5..80c1eee8b 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -509,11 +509,11 @@ function_sparql_regex (sqlite3_context *context,
sqlite3_value *argv[])
{
gboolean ret;
- const gchar *text, *pattern, *flags;
+ const gchar *text, *pattern, *flags = "";
GRegexCompileFlags regex_flags;
GRegex *regex;
- if (argc != 3) {
+ if (argc != 2 && argc != 3) {
sqlite3_result_error (context, "Invalid argument count", -1);
return;
}
@@ -521,7 +521,9 @@ function_sparql_regex (sqlite3_context *context,
regex = sqlite3_get_auxdata (context, 1);
text = (gchar *)sqlite3_value_text (argv[0]);
- flags = (gchar *)sqlite3_value_text (argv[2]);
+
+ if (argc == 3)
+ flags = (gchar *)sqlite3_value_text (argv[2]);
if (regex == NULL) {
gchar *err_str;
@@ -1396,7 +1398,7 @@ initialize_functions (TrackerDBInterface *db_interface)
{ "SparqlEncodeForUri", 1, SQLITE_ANY | SQLITE_DETERMINISTIC,
function_sparql_encode_for_uri },
/* Strings */
- { "SparqlRegex", 3, SQLITE_ANY | SQLITE_DETERMINISTIC,
+ { "SparqlRegex", -1, SQLITE_ANY | SQLITE_DETERMINISTIC,
function_sparql_regex },
{ "SparqlStringJoin", -1, SQLITE_ANY | SQLITE_DETERMINISTIC,
function_sparql_string_join },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]