Changeset: 51719a0961b8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=51719a0961b8
Modified Files:
pathfinder/compiler/algebra/algebra.c
pathfinder/compiler/algebra/logical.c
pathfinder/compiler/algebra/physical.c
pathfinder/compiler/algebra/prop/prop_ocol.c
pathfinder/compiler/include/algebra.h
pathfinder/compiler/mil/milgen.brg
pathfinder/compiler/sql/lalg2sql.brg
pathfinder/compiler/sql/sqlprint.c
pathfinder/compiler/xmlimport/xml2lalg_converters.c
Branch: default
Log Message:
On behalf of Fabian Kliebhan added support for a SQL 'like' operator.
diffs (120 lines):
diff -r 21a781ce6ff6 -r 51719a0961b8 pathfinder/compiler/algebra/algebra.c
--- a/pathfinder/compiler/algebra/algebra.c Tue Jul 13 17:51:47 2010 +0200
+++ b/pathfinder/compiler/algebra/algebra.c Wed Jul 14 21:33:36 2010 +0200
@@ -1196,6 +1196,7 @@
case alg_fun_fn_lower_case: return "fn:lower-case";
case alg_fun_fn_translate: return "fn:translate";
case alg_fun_fn_contains: return "fn:contains";
+ case alg_fun_fn_like: return "fn:like";
case alg_fun_fn_starts_with: return "fn:starts-with";
case alg_fun_fn_ends_with: return "fn:ends-with";
case alg_fun_fn_substring_before: return "fn:substring-before";
diff -r 21a781ce6ff6 -r 51719a0961b8 pathfinder/compiler/algebra/logical.c
--- a/pathfinder/compiler/algebra/logical.c Tue Jul 13 17:51:47 2010 +0200
+++ b/pathfinder/compiler/algebra/logical.c Wed Jul 14 21:33:36 2010 +0200
@@ -1473,6 +1473,7 @@
break;
case alg_fun_fn_contains:
+ case alg_fun_fn_like:
case alg_fun_fn_starts_with:
case alg_fun_fn_ends_with:
case alg_fun_fn_matches:
diff -r 21a781ce6ff6 -r 51719a0961b8 pathfinder/compiler/algebra/physical.c
--- a/pathfinder/compiler/algebra/physical.c Tue Jul 13 17:51:47 2010 +0200
+++ b/pathfinder/compiler/algebra/physical.c Wed Jul 14 21:33:36 2010 +0200
@@ -1680,6 +1680,7 @@
break;
case alg_fun_fn_contains:
+ case alg_fun_fn_like:
case alg_fun_fn_starts_with:
case alg_fun_fn_ends_with:
case alg_fun_fn_matches:
diff -r 21a781ce6ff6 -r 51719a0961b8
pathfinder/compiler/algebra/prop/prop_ocol.c
--- a/pathfinder/compiler/algebra/prop/prop_ocol.c Tue Jul 13 17:51:47
2010 +0200
+++ b/pathfinder/compiler/algebra/prop/prop_ocol.c Wed Jul 14 21:33:36
2010 +0200
@@ -391,6 +391,7 @@
break;
case alg_fun_fn_contains:
+ case alg_fun_fn_like:
case alg_fun_fn_starts_with:
case alg_fun_fn_ends_with:
case alg_fun_fn_matches:
diff -r 21a781ce6ff6 -r 51719a0961b8 pathfinder/compiler/include/algebra.h
--- a/pathfinder/compiler/include/algebra.h Tue Jul 13 17:51:47 2010 +0200
+++ b/pathfinder/compiler/include/algebra.h Wed Jul 14 21:33:36 2010 +0200
@@ -391,6 +391,7 @@
, alg_fun_fn_lower_case /**< fn:lower-case */
, alg_fun_fn_translate /**< fn:translate */
, alg_fun_fn_contains /**< fn:contains */
+ , alg_fun_fn_like /**< fn:like */
, alg_fun_fn_starts_with /**< fn:starts-with */
, alg_fun_fn_ends_with /**< fn:ends-with */
, alg_fun_fn_substring_before /**< fn:substring-before */
diff -r 21a781ce6ff6 -r 51719a0961b8 pathfinder/compiler/mil/milgen.brg
--- a/pathfinder/compiler/mil/milgen.brg Tue Jul 13 17:51:47 2010 +0200
+++ b/pathfinder/compiler/mil/milgen.brg Wed Jul 14 21:33:36 2010 +0200
@@ -5517,6 +5517,7 @@
VAR (L(p)->env, col2, aat_str),
VAR (L(p)->env, col3, aat_str))));
} break; /* fold) */
+ case alg_fun_fn_like:
case alg_fun_fn_contains: /* fold( */
{
PFalg_col_t col1, col2;
diff -r 21a781ce6ff6 -r 51719a0961b8 pathfinder/compiler/sql/lalg2sql.brg
--- a/pathfinder/compiler/sql/lalg2sql.brg Tue Jul 13 17:51:47 2010 +0200
+++ b/pathfinder/compiler/sql/lalg2sql.brg Wed Jul 14 21:33:36 2010 +0200
@@ -3676,13 +3676,25 @@
case alg_fun_num_divide:
res_expr = div (expr[0], expr[1]); break;
case alg_fun_fn_contains:
+ {
+ /* adding check for constant expression */
+ if (!PFprop_const (L(p)->prop, col[1]) ||
+ ty[1] != aat_str ||
+ expr[1]->kind == sql_column_name)
+ PFoops (OOPS_FATAL, "fn_contains works only with
constant "
+ "string expressions");
+ char *str = PFmalloc
(strlen(expr[1]->sem.atom.val.s)+2);
+ sprintf (str, "%%%s%%", expr[1]->sem.atom.val.s);
+ res_expr = like (expr[0], PFsql_lit_str(str));
+ }
+ break;
+ case alg_fun_fn_like:
/* adding check for constant expression */
if (!PFprop_const (L(p)->prop, col[1]) ||
ty[1] != aat_str ||
expr[1]->kind == sql_column_name)
- PFoops (OOPS_FATAL, "fn_contains works only with
constant "
+ PFoops (OOPS_FATAL, "fn_like works only with constant "
"string expressions");
-
res_expr = like (expr[0], expr[1]);
break;
/**< fn:ceiling */
diff -r 21a781ce6ff6 -r 51719a0961b8 pathfinder/compiler/sql/sqlprint.c
--- a/pathfinder/compiler/sql/sqlprint.c Tue Jul 13 17:51:47 2010 +0200
+++ b/pathfinder/compiler/sql/sqlprint.c Wed Jul 14 21:33:36 2010 +0200
@@ -484,7 +484,7 @@
print_statement (L(n));
/* write the string without beginning and trailing ' */
- PFprettyprintf (" LIKE '%%%s%%'", R(n)->sem.atom.val.s);
+ PFprettyprintf (" LIKE '%s'", R(n)->sem.atom.val.s);
break;
case sql_in:
diff -r 21a781ce6ff6 -r 51719a0961b8
pathfinder/compiler/xmlimport/xml2lalg_converters.c
--- a/pathfinder/compiler/xmlimport/xml2lalg_converters.c Tue Jul 13
17:51:47 2010 +0200
+++ b/pathfinder/compiler/xmlimport/xml2lalg_converters.c Wed Jul 14
21:33:36 2010 +0200
@@ -345,6 +345,7 @@
mapto_fun_kind (alg_fun_fn_lower_case)
mapto_fun_kind (alg_fun_fn_translate)
mapto_fun_kind (alg_fun_fn_contains)
+ mapto_fun_kind (alg_fun_fn_like)
mapto_fun_kind (alg_fun_fn_starts_with)
mapto_fun_kind (alg_fun_fn_ends_with)
mapto_fun_kind (alg_fun_fn_substring_before)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list