Update of /cvsroot/monetdb/pathfinder/compiler/sql
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11995/compiler/sql
Modified Files:
lalg2sql.brg sql.c sqlprint.c
Log Message:
Implementations for string-functions:
-- fn:string-length
-- fn:string-upper
-- fn:string-lower
Index: sql.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/sql/sql.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- sql.c 4 Feb 2008 16:52:32 -0000 1.49
+++ sql.c 5 Feb 2008 14:29:33 -0000 1.50
@@ -972,6 +972,37 @@
return wire1 (sql_sum, column);
}
+/* ........... String Functions ........... */
+
+/**
+ * Construct a SQL tree node representing
+ * the SQL length functions for strings
+ */
+PFsql_t *
+PFsql_str_length (const PFsql_t *a)
+{
+ return wire1 (sql_str_length, a);
+}
+
+/**
+ * Construct a SQL tree node representing
+ * the SQL length functions for strings
+ */
+PFsql_t *
+PFsql_str_upper (const PFsql_t *a)
+{
+ return wire1 (sql_str_upper, a);
+}
+
+/**
+ * Construct a SQL tree node representing
+ * the SQL length functions for strings
+ */
+PFsql_t *
+PFsql_str_lower (const PFsql_t *a)
+{
+ return wire1 (sql_str_lower, a);
+}
/* .......... OLAP Functionality .......... */
Index: lalg2sql.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/sql/lalg2sql.brg,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- lalg2sql.brg 5 Feb 2008 10:38:28 -0000 1.110
+++ lalg2sql.brg 5 Feb 2008 14:29:31 -0000 1.111
@@ -3046,8 +3046,15 @@
case alg_fun_num_divide:
res_expr = div (expr[0], expr[1]); break;
case alg_fun_fn_contains:
- /* FIXME: this only works with constant expr[1] */
- res_expr = like (expr[0], expr[1]); break;
+ /* adding check for constant expression */
+ if (!PFprop_const (L(p)->prop, att[1]) ||
+ ty[1] != aat_str ||
+ expr[1]->kind == sql_column_name)
+ PFoops (OOPS_FATAL, "fn_contains works only with
constant "
+ "string expressions");
+
+ res_expr = like (expr[0], expr[1]);
+ break;
/**< fn:ceiling */
case alg_fun_fn_ceiling:
res_expr = ceil (expr[0]); break;
@@ -3072,9 +3079,14 @@
/** string functions */
case alg_fun_fn_starts_with:
case alg_fun_fn_ends_with:
+ assert (!"missing");
+ break;
case alg_fun_fn_string_length:
+ res_expr = str_length (expr[0]); break;
case alg_fun_fn_upper_case:
+ res_expr = str_upper (expr[0]); break;
case alg_fun_fn_lower_case:
+ res_expr = str_lower (expr[0]); break;
case alg_fun_fn_translate:
case alg_fun_fn_substring_before:
case alg_fun_fn_substring_after:
Index: sqlprint.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/sql/sqlprint.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- sqlprint.c 4 Feb 2008 16:52:32 -0000 1.45
+++ sqlprint.c 5 Feb 2008 14:29:33 -0000 1.46
@@ -122,7 +122,7 @@
[sql_between] = "between",
[sql_like] = "like",
[sql_in] = "in",
- [sql_stmt_list] = "stmt_list",
+ [sql_stmt_list] = "stmt_list",
[sql_list_list] = "list_list",
[sql_not] = "not",
[sql_and] /* used */ = "AND",
@@ -132,6 +132,9 @@
[sql_sum] /* used */ = "SUM",
[sql_min] /* used */ = "MIN",
[sql_avg] /* used */ = "AVG",
+ [sql_str_length] = "LENGTH",
+ [sql_str_upper] = "UPPER",
+ [sql_str_lower] = "LOWER",
[sql_over] = "over",
[sql_row_number] = "ROW_NUMBER",
[sql_dense_rank] = "DENSE_RANK",
@@ -617,6 +620,14 @@
PFprettyprintf(")");
break;
+ case sql_str_length:
+ case sql_str_upper:
+ case sql_str_lower:
+ PFprettyprintf("%s (", ID[n->kind]);
+ print_statement (L(n));
+ PFprettyprintf(")");
+ break;
+
case sql_cast:
assert (R(n)->kind == sql_type);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins