Update of /cvsroot/monetdb/pathfinder/compiler/sql
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3499/sql

Modified Files:
        sqlprint.c sql.c 
Log Message:
-- Added support for DB2s SELECTIVITY hint
   (to systematically toy around with this handle).

-- Added support for a unique column identifier
   (as anticipation for changes in the last select list).


Index: sql.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/sql/sql.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- sql.c       4 Oct 2007 10:41:09 -0000       1.39
+++ sql.c       26 Nov 2007 09:12:31 -0000      1.40
@@ -1079,6 +1079,15 @@
 }
 
 /**
+ * Create a DB2 selectivity hint.
+ */
+PFsql_t *
+PFsql_selectivity (PFsql_t *pred, PFsql_t *sel)
+{
+    return wire2 (sql_db2_selectivity, pred, sel);
+}
+
+/**
  * Duplicate a given SQL tree.
  */
 PFsql_t *
@@ -1253,6 +1262,11 @@
             case sql_col_pos:      return "pos";
             case sql_col_guide:    return "guide";
             case sql_col_max:      return "max";
+            case sql_col_dist:
+                assert (name->ty < 100);
+                res = (char *) PFmalloc (7 * sizeof (char));
+                snprintf (res, 7, "dist%02i", name->ty);
+                return res;
         }
     else {
         char  *attstr = PFatt_str (name->att);

Index: sqlprint.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/sql/sqlprint.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- sqlprint.c  4 Oct 2007 10:41:10 -0000       1.39
+++ sqlprint.c  26 Nov 2007 09:12:31 -0000      1.40
@@ -325,11 +325,9 @@
     {
         case sql_is:
         case sql_is_not:
-            PFprettyprintf ("(");
             print_statement (L(n));
             PFprettyprintf(" %s ", ID[n->kind]);
             print_statement (R(n));
-            PFprettyprintf (")");
             break;
 
         case sql_not:
@@ -341,68 +339,69 @@
         case sql_and:
         case sql_or:
             /* expression : '(' expression 'OP' expression ')' */
-            PFprettyprintf ("(");
+            PFprettyprintf ("((");
             print_condition (L(n));
+            PFprettyprintf (")");
             PFprettyprintf (" %s ", ID[n->kind]);
+            PFprettyprintf ("(");
             print_condition (R(n));
-            PFprettyprintf (")");
+            PFprettyprintf ("))");
             break;
             
         case sql_eq:
-            PFprettyprintf ("(");
             print_statement (L(n));
             PFprettyprintf (" = ");
             print_statement (R(n));
-            PFprettyprintf (")");
             break;
             
         case sql_gt:
             /* switch arguments */
-            PFprettyprintf ("(");
             print_statement (R(n));
             PFprettyprintf (" < ");
             print_statement (L(n));
-            PFprettyprintf (")");
             break;
 
         case sql_gteq:
             /* switch arguments */
-            PFprettyprintf ("(");
             print_statement (R(n));
             PFprettyprintf (" <= ");
             print_statement (L(n));
-            PFprettyprintf (")");
             break;
         
         case sql_between:
-            PFprettyprintf ("(");
             print_statement (n->child[0]);
             PFprettyprintf (" BETWEEN ");
             print_statement (n->child[1]);
             PFprettyprintf (" AND ");
             assert (n->child[2]);
             print_statement (n->child[2]);        
-            PFprettyprintf (")");
             break;
             
         case sql_like:
             if (R(n)->kind != sql_lit_str)
                 PFoops (OOPS_FATAL, "LIKE only works with constant strings");
             
-            PFprettyprintf ("(");
             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:
-            PFprettyprintf ("(");
             print_statement (L(n));
             PFprettyprintf (" IN (");
             print_stmt_list (R(n));
-            PFprettyprintf ("))");
+            PFprettyprintf (")");
             break; 
             
+        case sql_db2_selectivity:
+            PFprettyprintf ("(");
+            print_condition (L(n));
+            PFprettyprintf (" SELECTIVITY ");
+            assert (R(n)->kind == sql_lit_dec);
+            print_literal (R(n));
+            PFprettyprintf (")");
+            break;
+
         default:
             PFoops (OOPS_FATAL,
                     "SQL grammar conflict. (Expected: condition; "


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
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

Reply via email to