[tracker] libtracker-data: Add support for MD5/SHA1/256/512 builtin functions
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Add support for MD5/SHA1/256/512 builtin functions
- Date: Mon, 19 Oct 2015 12:16:15 +0000 (UTC)
commit 3ab7ca19c48052868020452ba0bf504984d63ac4
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jul 30 00:08:38 2015 +0200
libtracker-data: Add support for MD5/SHA1/256/512 builtin functions
These functions are defined in Sparql 1.1 query language recommendation,
http://www.w3.org/TR/sparql11-query/#func-md5
http://www.w3.org/TR/sparql11-query/#func-sha1
http://www.w3.org/TR/sparql11-query/#func-sha256
http://www.w3.org/TR/sparql11-query/#func-sha512
src/libtracker-data/tracker-sparql-expression.vala | 24 +++++++++++++++++
src/libtracker-data/tracker-sparql-scanner.vala | 27 ++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-expression.vala
b/src/libtracker-data/tracker-sparql-expression.vala
index be1646f..59c4964 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -1379,6 +1379,30 @@ class Tracker.Sparql.Expression : Object {
var result = translate_function (sql, FN_NS + "year-from-dateTime");
expect (SparqlTokenType.CLOSE_PARENS);
return result;
+ case SparqlTokenType.MD5:
+ next ();
+ sql.append ("SparqlChecksum(");
+ type = translate_aggregate_expression (sql);
+ sql.append (", \"md5\")");
+ return type;
+ case SparqlTokenType.SHA1:
+ next ();
+ sql.append ("SparqlChecksum(");
+ type = translate_aggregate_expression (sql);
+ sql.append (", \"sha1\")");
+ return type;
+ case SparqlTokenType.SHA256:
+ next ();
+ sql.append ("SparqlChecksum(");
+ type = translate_aggregate_expression (sql);
+ sql.append (", \"sha256\")");
+ return type;
+ case SparqlTokenType.SHA512:
+ next ();
+ sql.append ("SparqlChecksum(");
+ type = translate_aggregate_expression (sql);
+ sql.append (", \"sha512\")");
+ return type;
case SparqlTokenType.GROUP_CONCAT:
next ();
sql.append ("GROUP_CONCAT(");
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index 35a417e..a27b99b 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -117,6 +117,10 @@ public class Tracker.SparqlScanner : Object {
case 'a':
if (matches (begin, "MAX")) return SparqlTokenType.MAX;
break;
+ case 'D':
+ case 'd':
+ if (matches (begin, "MD5")) return SparqlTokenType.MD5;
+ break;
case 'I':
case 'i':
if (matches (begin, "MIN")) return SparqlTokenType.MIN;
@@ -185,6 +189,10 @@ public class Tracker.SparqlScanner : Object {
case 'n':
if (matches (begin, "NULL")) return SparqlTokenType.NULL;
break;
+ case 'S':
+ case 's':
+ if (matches (begin, "SHA1")) return SparqlTokenType.SHA1;
+ break;
case 'T':
case 't':
if (matches (begin, "TRUE")) return SparqlTokenType.TRUE;
@@ -367,6 +375,17 @@ public class Tracker.SparqlScanner : Object {
case 'u':
if (matches (begin, "SUBSTR")) return SparqlTokenType.SUBSTR;
break;
+ case 'H':
+ case 'h':
+ switch (begin[3]) {
+ case '2':
+ if (matches (begin, "SHA256")) return SparqlTokenType.SHA256;
+ break;
+ case '5':
+ if (matches (begin, "SHA512")) return SparqlTokenType.SHA512;
+ break;
+ }
+ break;
}
break;
}
@@ -1041,6 +1060,7 @@ public enum Tracker.SparqlTokenType {
LCASE,
LIMIT,
MAX,
+ MD5,
MIN,
MINUS,
MINUTES,
@@ -1076,6 +1096,9 @@ public enum Tracker.SparqlTokenType {
SECONDS,
SELECT,
SEMICOLON,
+ SHA1,
+ SHA256,
+ SHA512,
SILENT,
STAR,
STR,
@@ -1159,6 +1182,7 @@ public enum Tracker.SparqlTokenType {
case LCASE: return "`LCASE'";
case LIMIT: return "`LIMIT'";
case MAX: return "`MAX'";
+ case MD5: return "`MD5'";
case MIN: return "`MIN'";
case MINUS: return "`-'";
case MINUTES: return "`MINUTES'";
@@ -1193,6 +1217,9 @@ public enum Tracker.SparqlTokenType {
case SECONDS: return "`SECONDS'";
case SELECT: return "`SELECT'";
case SEMICOLON: return "`;'";
+ case SHA1: return "`SHA1'";
+ case SHA256: return "`SHA256'";
+ case SHA512: return "`SHA512'";
case SILENT: return "`SILENT'";
case STAR: return "`*'";
case STR: return "`STR'";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]