Changeset: ab6aa5aed19c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ab6aa5aed19c
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/include/sql.h
pathfinder/compiler/include/sql_mnemonic.h
pathfinder/compiler/mil/milgen.brg
pathfinder/compiler/sql/lalg2sql.brg
pathfinder/compiler/sql/sql.c
pathfinder/compiler/sql/sqlprint.c
pathfinder/compiler/xmlimport/xml2lalg_converters.c
Branch: default
Log Message:
alexander urlichs patch applied to support SQL99s 'SIMILAR TO', which is a more
sophisticated 'LIKE' including regular expressions
diffs (193 lines):
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/algebra/algebra.c
--- a/pathfinder/compiler/algebra/algebra.c Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/algebra/algebra.c Thu Jul 22 17:45:40 2010 +0200
@@ -1212,6 +1212,7 @@
case alg_fun_fn_number_lax: return "fn:number";
case alg_fun_fn_qname: return "fn:QName";
case alg_fun_fn_doc_available: return "fn:doc-available";
+ case alg_fun_fn_similar_to: return "fn:similar_to";
case alg_fun_pf_fragment: return "#pf:fragment";
case alg_fun_pf_supernode: return "#pf:supernode";
case alg_fun_pf_add_doc_str: return "pf:add-doc";
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/algebra/logical.c
--- a/pathfinder/compiler/algebra/logical.c Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/algebra/logical.c Thu Jul 22 17:45:40 2010 +0200
@@ -1477,6 +1477,7 @@
case alg_fun_fn_starts_with:
case alg_fun_fn_ends_with:
case alg_fun_fn_matches:
+ case alg_fun_fn_similar_to:
assert (clsize (refs) == 2);
/* make sure both columns are of type string */
assert (n->schema.items[ix[0]].type == aat_str &&
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/algebra/physical.c
--- a/pathfinder/compiler/algebra/physical.c Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/algebra/physical.c Thu Jul 22 17:45:40 2010 +0200
@@ -1684,6 +1684,7 @@
case alg_fun_fn_starts_with:
case alg_fun_fn_ends_with:
case alg_fun_fn_matches:
+ case alg_fun_fn_similar_to:
assert (clsize (refs) == 2);
/* make sure both columns are of type string */
assert (n->schema.items[ix[0]].type == aat_str &&
diff -r 7d1285b15988 -r ab6aa5aed19c
pathfinder/compiler/algebra/prop/prop_ocol.c
--- a/pathfinder/compiler/algebra/prop/prop_ocol.c Thu Jul 22 14:09:05
2010 +0200
+++ b/pathfinder/compiler/algebra/prop/prop_ocol.c Thu Jul 22 17:45:40
2010 +0200
@@ -395,6 +395,7 @@
case alg_fun_fn_starts_with:
case alg_fun_fn_ends_with:
case alg_fun_fn_matches:
+ case alg_fun_fn_similar_to:
assert (clsize (n->sem.fun_1to1.refs) == 2);
/* make sure both columns are of type string */
assert (ocol_at (L(n), ix[0]).type == aat_str &&
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/include/algebra.h
--- a/pathfinder/compiler/include/algebra.h Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/include/algebra.h Thu Jul 22 17:45:40 2010 +0200
@@ -407,6 +407,7 @@
, alg_fun_fn_number_lax /**< fn:number (ignoring NaN) */
, alg_fun_fn_qname /**< fn:QName */
, alg_fun_fn_doc_available /**< fn:doc-available */
+ , alg_fun_fn_similar_to /**< fn:similar_to */
, alg_fun_pf_fragment /**< #pf:fragment */
, alg_fun_pf_supernode /**< #pf:supernode */
, alg_fun_pf_add_doc_str /**< pf:add-doc */
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/include/sql.h
--- a/pathfinder/compiler/include/sql.h Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/include/sql.h Thu Jul 22 17:45:40 2010 +0200
@@ -174,6 +174,7 @@
, sql_gteq /* >= comparison */
, sql_between /* range predicate */
, sql_like /* like comparison */
+ , sql_similar_to /* similar to comparison */
, sql_in /* in comparison */
, sql_stmt_list /* an item of a list of statments
(second argument of a sql_in operator) */
@@ -793,6 +794,14 @@
* with a certain pattern.
*/
PFsql_t * PFsql_like (const PFsql_t *a, const PFsql_t *b);
+
+/**
+ * Create a tree node representing the SQL99
+ * 'similar to' statement to compare a string with
+ * a certain pattern.
+ */
+PFsql_t * PFsql_similar_to (const PFsql_t *a, const PFsql_t *b);
+
/**
* Create a SQL tree node representing the in operator
*/
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/include/sql_mnemonic.h
--- a/pathfinder/compiler/include/sql_mnemonic.h Thu Jul 22 14:09:05
2010 +0200
+++ b/pathfinder/compiler/include/sql_mnemonic.h Thu Jul 22 17:45:40
2010 +0200
@@ -117,6 +117,7 @@
#define gteq(a,b) PFsql_gteq(a,b)
#define between(c,a,b) PFsql_between(c,a,b)
#define like(a,b) PFsql_like(a,b)
+#define similar_to(a,b) PFsql_similar_to(a,b)
#define in(a,b) PFsql_in(a,b)
#define stmt_list(...) PFsql_stmt_list(__VA_ARGS__)
#define not_(a) PFsql_not(a)
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/mil/milgen.brg
--- a/pathfinder/compiler/mil/milgen.brg Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/mil/milgen.brg Thu Jul 22 17:45:40 2010 +0200
@@ -5535,6 +5535,9 @@
VAR (L(p)->env, col2, aat_str)),
lit_int (-1)))));
} break; /* fold) */
+ case alg_fun_fn_similar_to:
+ PFoops (OOPS_FATAL,
+ "fn:similar_to not implemented for MIL");
#ifdef HAVE_GEOXML
case alg_fun_geo_wkb: /* fold( */
{
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/sql/lalg2sql.brg
--- a/pathfinder/compiler/sql/lalg2sql.brg Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/sql/lalg2sql.brg Thu Jul 22 17:45:40 2010 +0200
@@ -3697,6 +3697,8 @@
"string expressions");
res_expr = like (expr[0], expr[1]);
break;
+ case alg_fun_fn_similar_to:
+ res_expr = similar_to (expr[0], expr[1]); break;
/**< fn:ceiling */
case alg_fun_fn_ceiling:
res_expr = ceil (expr[0]); break;
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/sql/sql.c
--- a/pathfinder/compiler/sql/sql.c Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/sql/sql.c Thu Jul 22 17:45:40 2010 +0200
@@ -870,6 +870,17 @@
}
/**
+ * Create a tree node representing the SQL99
+ * 'similar to' statement to compare a string with
+ * a certain pattern.
+ */
+PFsql_t *
+PFsql_similar_to (const PFsql_t *a, const PFsql_t *b)
+{
+ return wire2 (sql_similar_to, a, b);
+}
+
+/**
* Create a SQL tree node representing the in operator
*/
PFsql_t *
diff -r 7d1285b15988 -r ab6aa5aed19c pathfinder/compiler/sql/sqlprint.c
--- a/pathfinder/compiler/sql/sqlprint.c Thu Jul 22 14:09:05 2010 +0200
+++ b/pathfinder/compiler/sql/sqlprint.c Thu Jul 22 17:45:40 2010 +0200
@@ -70,7 +70,7 @@
}
static char *ID[] = {
- [sql_root] = "root",
+ [sql_root] = "root",
[sql_ser_info] = "ser_info",
[sql_ser_comment] = "ser_comment",
[sql_ser_mapping] = "ser_mapping",
@@ -121,6 +121,7 @@
[sql_gteq] = "gteq",
[sql_between] = "between",
[sql_like] = "like",
+ [sql_similar_to] = "similar to",
[sql_in] = "in",
[sql_stmt_list] = "stmt_list",
[sql_list_list] = "list_list",
@@ -486,6 +487,12 @@
/* write the string without beginning and trailing ' */
PFprettyprintf (" LIKE '%s'", R(n)->sem.atom.val.s);
break;
+
+ case sql_similar_to:
+ print_statement (L(n));
+ PFprettyprintf (" SIMILAR TO ");
+ print_statement (R(n));
+ break;
case sql_in:
print_statement (L(n));
@@ -721,6 +728,10 @@
PFprettyprintf (")");
break;
case sql_concat:
+ print_statement (L(n));
+ PFprettyprintf (" || ");
+ print_statement (R(n));
+ break;
case sql_modulo:
PFprettyprintf ("%s (", ID[n->kind]);
print_statement (L(n));
diff -r 7d1285b15988 -r ab6aa5aed19c
pathfinder/compiler/xmlimport/xml2lalg_converters.c
--- a/pathfinder/compiler/xmlimport/xml2lalg_converters.c Thu Jul 22
14:09:05 2010 +0200
+++ b/pathfinder/compiler/xmlimport/xml2lalg_converters.c Thu Jul 22
17:45:40 2010 +0200
@@ -361,6 +361,7 @@
mapto_fun_kind (alg_fun_fn_number_lax)
mapto_fun_kind (alg_fun_fn_qname)
mapto_fun_kind (alg_fun_fn_doc_available)
+ mapto_fun_kind (alg_fun_fn_similar_to)
mapto_fun_kind (alg_fun_pf_fragment)
mapto_fun_kind (alg_fun_pf_supernode)
mapto_fun_kind (alg_fun_pf_add_doc_str)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list