Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12164/src/server

Modified Files:
      Tag: SQL_2-24
        rel_select.mx sql_optimize.mx sql_parser.mx sql_select.mx 
Log Message:
fixed support for IS NULL in selection
fixed bug in groupby and selection with constants (old bin alg only)
fixed bug in range join rewrites


U rel_select.mx
Index: rel_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_select.mx,v
retrieving revision 1.75.2.2
retrieving revision 1.75.2.3
diff -u -d -r1.75.2.2 -r1.75.2.3
--- rel_select.mx       17 Jun 2008 09:25:13 -0000      1.75.2.2
+++ rel_select.mx       10 Jul 2008 19:13:37 -0000      1.75.2.3
@@ -2118,8 +2118,8 @@
                        return rel_binop_(sql, e1, e2, NULL, "and");
                }
        }
-       case SQL_NULL:
-       case SQL_NOT_NULL:
+       case SQL_IS_NULL:
+       case SQL_IS_NOT_NULL:
        /* is (NOT) NULL */
        {
                sql_exp *le = rel_value_exp(sql, rel, sc->data.sym, f, ek);
@@ -2127,7 +2127,7 @@
                if (!le)
                        return NULL;
                le = rel_unop_(sql, le, NULL, "isnull");
-               if (sc->token != SQL_NULL) 
+               if (sc->token != SQL_IS_NULL) 
                        le = rel_unop_(sql, le, NULL, "not");
                return le;
        }
@@ -2419,8 +2419,8 @@
                }
                return rel;
        }
-       case SQL_NULL:
-       case SQL_NOT_NULL:
+       case SQL_IS_NULL:
+       case SQL_IS_NOT_NULL:
        /* is (NOT) NULL */
        {
                sql_exp *re, *le = rel_value_exp(sql, &rel, sc->data.sym, f, 
ek);
@@ -2428,7 +2428,7 @@
                if (!le)
                        return NULL;
                le = rel_unop_(sql, le, NULL, "isnull");
-               if (sc->token == SQL_NULL) 
+               if (sc->token == SQL_IS_NULL) 
                        re = exp_atom_bool(1);
                else
                        re = exp_atom_bool(0);

U sql_parser.mx
Index: sql_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_parser.mx,v
retrieving revision 1.283.2.1
retrieving revision 1.283.2.2
diff -u -d -r1.283.2.1 -r1.283.2.2
--- sql_parser.mx       13 Jun 2008 21:26:55 -0000      1.283.2.1
+++ sql_parser.mx       10 Jul 2008 19:13:38 -0000      1.283.2.2
@@ -87,6 +87,8 @@
        SQL_DEFAULT,
        SQL_NOT_NULL,
        SQL_NULL,
+       SQL_IS_NULL,
+       SQL_IS_NOT_NULL,
        SQL_NULLIF,
        SQL_UNIQUE,
        SQL_PRIMARY_KEY,
@@ -3136,8 +3138,8 @@
  ;
 
 test_for_null:
-    scalar_exp IS NOT sqlNULL { $$ = _symbol_create_symbol( SQL_NOT_NULL, $1 
);}
- |  scalar_exp IS sqlNULL     { $$ = _symbol_create_symbol( SQL_NULL, $1 ); }
+    scalar_exp IS NOT sqlNULL { $$ = _symbol_create_symbol( SQL_IS_NOT_NULL, 
$1 );}
+ |  scalar_exp IS sqlNULL     { $$ = _symbol_create_symbol( SQL_IS_NULL, $1 ); 
}
  ;
 
 in_predicate:

U sql_optimize.mx
Index: sql_optimize.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_optimize.mx,v
retrieving revision 1.92.2.2
retrieving revision 1.92.2.3
diff -u -d -r1.92.2.2 -r1.92.2.3
--- sql_optimize.mx     22 Jun 2008 13:45:36 -0000      1.92.2.2
+++ sql_optimize.mx     10 Jul 2008 19:13:37 -0000      1.92.2.3
@@ -1241,12 +1241,14 @@
                                                
stmt_reverse(stmt_dup(o2->op2.stval)),
                                                cmp);
                                } else {
+                                       /* we need to swap compare */
+                                       if (cmp == 1 || cmp == 2)
+                                               cmp = 3-cmp;
                                        s = stmt_join2(
                                                
stmt_reverse(stmt_dup(o1->op2.stval)),
-                                               /* we need to swap order too */
                                                stmt_dup(o2->op1.stval),
                                                stmt_dup(o1->op1.stval),
-                                               3-cmp);
+                                               cmp);
                                }
                                stmt_destroy(o1);
                                stmt_destroy(o2);

U sql_select.mx
Index: sql_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_select.mx,v
retrieving revision 1.231.2.7
retrieving revision 1.231.2.8
diff -u -d -r1.231.2.7 -r1.231.2.8
--- sql_select.mx       17 Jun 2008 08:37:30 -0000      1.231.2.7
+++ sql_select.mx       10 Jul 2008 19:13:38 -0000      1.231.2.8
@@ -3520,14 +3520,13 @@
                }
        }
                break;
-       case SQL_NULL:
-       case SQL_NOT_NULL:
+       case SQL_IS_NULL:
+       case SQL_IS_NOT_NULL:
        /* is (NOT) NULL */
        {
                symbol *cr = sc->data.sym;
                stmt *res = sql_value_exp(sql, scp, cr, grp, subset, f, iek);
 
-               /* TODO predicate! */
                if (res && (res->nrcols == 0 || f == sql_sel)) {
                        sql_subtype *bt = sql_bind_localtype("bit");
                        sql_subtype *tp = tail_type(res);
@@ -3538,7 +3537,7 @@
                                return NULL;
                        }
                        res = stmt_unop(res, isnul);
-                       if (sc->token != SQL_NULL) {
+                       if (sc->token != SQL_IS_NULL) {
                                sql_subfunc *not = 
sql_bind_func_result(sql->session->schema, "not", bt, NULL, bt);
                                res = stmt_unop(res, not);
                        } 
@@ -3546,7 +3545,7 @@
                        sql_subtype *tpe = tail_type(res);
                        stmt *a = stmt_atom(atom_general(tpe, NULL, 0));
 
-                       if (sc->token == SQL_NULL) {
+                       if (sc->token == SQL_IS_NULL) {
                                res = stmt_uselect(res, a, cmp_equal);
                        } else {
                                res = stmt_uselect(res, a, cmp_notequal);
@@ -4050,7 +4049,9 @@
                                        return sql_error(sql, 02, "SELECT: 
single value in column expression");
                                        /* properly handle select '' from x */
                                } else if (!cs->aggr && !aggr) {
-                                       stmt *ss = first_subset(subset);
+                                       stmt *ss = (grp)?
+                                               stmt_dup(grp->ext):
+                                               first_subset(subset);
 
                                        cs = stmt_const(ss, stmt_dup(cs));
                                        list_append(rl, cs);


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to