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

Modified Files:
      Tag: SQL_2-24
        rel_select.mx sql_schema.mx sql_select.mx sql_semantic.mx 
Log Message:
added dynamic type checks in more cases (fixes 
auto_coersion_bug.SF-2075157.sql,string_length_not_checked.SF-2075078.sql)
added checks in alter table (fixes alter_view_not_allowed.SF-2075195.sql)
fixed hanling of not in (fixes select_in_wrong_result.SF-2080168.sql)
use the new thetauselect (fixes select_not_wrong_result.SF-2080151.sql)


U rel_select.mx
Index: rel_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_select.mx,v
retrieving revision 1.75.2.4
retrieving revision 1.75.2.5
diff -u -d -r1.75.2.4 -r1.75.2.5
--- rel_select.mx       21 Jul 2008 07:48:27 -0000      1.75.2.4
+++ rel_select.mx       30 Aug 2008 06:43:54 -0000      1.75.2.5
@@ -2213,6 +2213,7 @@
                dnode *n = dl->h->next;
                sql_exp *l = rel_value_exp(sql, &rel, lo, f, ek), *e;
                sql_rel *left = rel, *right = NULL;
+               int correlated = 0;
 
                if (!l)
                        return NULL;
@@ -2242,6 +2243,11 @@
                                sql_exp *r = rel_value_exp(sql, &z, sval, f, 
ek);
                                sql_rel *rl;
 
+                               if (!r) {
+                                       r = rel_value_exp(sql, &left, sval, f, 
ek);
+                                       z = left;
+                                       correlated = 1;
+                               }
                                if (!r || !(r=rel_check_type(sql, st, r, 
type_equal))) {
                                        if (r)
                                                exp_destroy(r);
@@ -2261,18 +2267,22 @@
                                }
                                right = rl;
                        }
-                       rel_label(right, ++sql->label);
-                       right = rel_distinct(right);
+                       if (!correlated) {
+                               rel_label(right, ++sql->label);
+                               right = rel_distinct(right);
+                       }
                } else {
                        return sql_error(sql, 02, "IN: missing inner query");
                }
-               /* right is a relation without correlations */
                if (right) {
                        sql_exp *r = NULL;
 
                        r = rel_lastexp(sql, right);
                        rel_setsubquery(right);
-                       rel = rel_crossproduct(left, right, op_join);
+                       if (correlated)
+                               rel = left;
+                       else
+                               rel = rel_crossproduct(left, right, op_join);
                        if (rel_convert_types(sql, &l, &r, 1, type_equal) < 0) {
                                exp_destroy(l);
                                exp_destroy(r);
@@ -2588,7 +2598,8 @@
                sql_exp *ol = exp_dup(l);
                sql_exp *or = exp_dup(r);
 
-               if ((f = sql_bind_member(s, fname, t1, 2)) != NULL) {
+               if (!EC_NUMBER(t1->type->eclass) &&
+                  (f = sql_bind_member(s, fname, t1, 2)) != NULL) {
                        /* try finding function based on first argument */
                        node *m = f->func->ops->h;
                        sql_arg *a = m->data;
@@ -3524,6 +3535,7 @@
 {
        int found = 0;
        list *exps = rel_projections(sql, t1, NULL, 1);
+       list *r_exps = rel_projections(sql, t2, NULL, 1);
        list *outexps = new_exp_list();
        node *n;
 
@@ -3532,7 +3544,7 @@
        for (n = exps->h; n; n = n->next) {
                sql_exp *lc = n->data;
                char *nm = lc->name;
-               sql_exp *rc = rel_bind_column(sql, t2, nm);
+               sql_exp *rc = exps_bind_column(r_exps, nm);
 
                if (rc) {
                        sql_exp *cond;
@@ -3542,9 +3554,12 @@
                        lc = rel_nop_(sql, cond, exp_dup(rc), exp_dup(lc), 
NULL, NULL, "ifthenelse");
                        exp_setname(lc, NULL, nm);
                        append(outexps, lc);
+                       list_remove_data(r_exps, rc);
                } else if (all) {
                        found = 0;
                        break;
+               } else {
+                       append(outexps, exp_dup(lc));
                }
        }
        list_destroy(exps);
@@ -3554,6 +3569,8 @@
                rel_destroy(rel);
                return NULL;
        }
+       list_merge(outexps, r_exps, (fdup)&exp_dup);
+       list_destroy(r_exps);
        return rel_project(rel, outexps);
 }
 

U sql_semantic.mx
Index: sql_semantic.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_semantic.mx,v
retrieving revision 1.181.2.2
retrieving revision 1.181.2.3
diff -u -d -r1.181.2.2 -r1.181.2.3
--- sql_semantic.mx     13 Jul 2008 18:27:10 -0000      1.181.2.2
+++ sql_semantic.mx     30 Aug 2008 06:43:57 -0000      1.181.2.3
@@ -1032,6 +1032,7 @@
                char *l = symbol2string(sql, lst->next->data.sym);
                len = snprintf( buf+len, BUFSIZ-len, "%s(%s)", op, l); 
                _DELETE(l);
+               break;
        }
        case SQL_NULL:
                strcpy(buf,"NULL");

U sql_select.mx
Index: sql_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_select.mx,v
retrieving revision 1.231.2.9
retrieving revision 1.231.2.10
diff -u -d -r1.231.2.9 -r1.231.2.10
--- sql_select.mx       21 Jul 2008 15:30:19 -0000      1.231.2.9
+++ sql_select.mx       30 Aug 2008 06:43:56 -0000      1.231.2.10
@@ -911,7 +911,8 @@
                stmt *ors = stmt_dup(rs);
 
                /* try finding function based on first argument */
-               if ((f = sql_bind_member(s, fname, t1, 2)) != NULL) {
+               if (!EC_NUMBER(t1->type->eclass) &&
+                  (f = sql_bind_member(s, fname, t1, 2)) != NULL) {
                        node *m = f->func->ops->h;
                        sql_arg *a = m->data;
 
@@ -2089,7 +2090,6 @@
                if (matching_columns) {
                        /* Natural join and join on columns list output the
                           join columns once.  
-                          Natural join only outputs join columns.
                         */
                        list *l2 = create_stmt_list();
                        node *o = NULL, *m = l1->h, *rm;
@@ -2115,20 +2115,18 @@
                                        list_append(l2, ls);
                                }
                        }
-                       if (js) {
-                               t = tv1;
-                               m = l1->h;
-                               for (n = t->columns->h; n; n = n->next, m = 
m->next) {
-                                       cvar *cs = n->data;
-                                       if (!(o = list_find(matching_columns, 
cs, (fcmp)&cvar_cmp))) 
-                                               list_append(l2, 
stmt_dup(m->data));
-                               }
-                               t = tv2;
-                               for (n = t->columns->h; n; n = n->next, m = 
m->next) {
-                                       cvar *cs = n->data;
-                                       if (!(o = list_find(matching_columns, 
cs, (fcmp)&cvar_cmp))) 
-                                               list_append(l2, 
stmt_dup(m->data));
-                               }
+                       t = tv1;
+                       m = l1->h;
+                       for (n = t->columns->h; n; n = n->next, m = m->next) {
+                               cvar *cs = n->data;
+                               if (!(o = list_find(matching_columns, cs, 
(fcmp)&cvar_cmp))) 
+                                       list_append(l2, stmt_dup(m->data));
+                       }
+                       t = tv2;
+                       for (n = t->columns->h; n; n = n->next, m = m->next) {
+                               cvar *cs = n->data;
+                               if (!(o = list_find(matching_columns, cs, 
(fcmp)&cvar_cmp))) 
+                                       list_append(l2, stmt_dup(m->data));
                        }
                        /* add no join columns */
                        list_destroy(l1);
@@ -3556,7 +3554,11 @@
                break;
        case SQL_NOT: {
                symbol *lo = sc->data.sym;
-               stmt *ls = sql_logical_exp(sql, scp, lo, grp, subset, f, ek);
+               exp_kind iek = ek;
+               stmt *ls;
+
+               iek.reduce = 0;
+               ls = sql_logical_exp(sql, scp, lo, grp, subset, f, iek);
 
                if (!ls)
                        return NULL;
@@ -3566,10 +3568,13 @@
                
                        return stmt_unop(ls, not);
                } else { /* R.diff(ls) */
+                       return stmt_select(ls, stmt_bool(0), cmp_equal);
+                       /*
                        if (subset)
                                return stmt_diff(first_subset(subset), ls);
                        else
                                return 
stmt_diff(stmt_dup(scope_first_column(scp)->s), ls);
+                       */
                }
        }
                break;

U sql_schema.mx
Index: sql_schema.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_schema.mx,v
retrieving revision 1.140.2.4
retrieving revision 1.140.2.5
diff -u -d -r1.140.2.4 -r1.140.2.5
--- sql_schema.mx       2 Aug 2008 17:12:44 -0000       1.140.2.4
+++ sql_schema.mx       30 Aug 2008 06:43:55 -0000      1.140.2.5
@@ -1244,6 +1244,9 @@
        dlist *opt_list = NULL;
        stmt *res = NULL;
 
+       if (alter && !isTable(t)) {
+               return sql_error(sql, 02, "ALTER TABLE: cannot add column to 
VIEW '%s'\n", t->base.name);
+       }
        if (l->h->next->next)
                opt_list = l->h->next->next->data.lval;
 
@@ -1376,9 +1379,6 @@
 {
        stmt *res = NULL;
 
-       if (!isTable(t)) {
-               return sql_error(sql, 02, "ALTER TABLE: cannot add constraint 
to VIEW '%s'\n", t->base.name);
-       }
        if (isTempTable(t))
                return sql_error(sql, 02, "CONSTRAINT: constraints on temporary 
tables are not supported\n");
        switch (s->token) {
@@ -1449,6 +1449,35 @@
 {
        stmt *res = NULL;
 
+       if (alter && !isTable(t)) {
+               char *msg = "";
+
+               switch (s->token) {
+               case SQL_COLUMN:        
+                       msg = "add column to"; 
+                       break;
+               case SQL_CONSTRAINT:    
+                       msg = "add constraint to"; 
+                       break;
+               case SQL_COLUMN_OPTIONS:
+               case SQL_DEFAULT:
+               case SQL_NOT_NULL:
+               case SQL_NULL:
+                       msg = "set column options for"; 
+                       break;
+               case SQL_DROP_DEFAULT:
+                       msg = "drop default column option from"; 
+                       break;
+               case SQL_DROP_COLUMN:
+                       msg = "drop column from"; 
+                       break;
+               case SQL_DROP_CONSTRAINT:
+                       msg = "drop constraint from"; 
+                       break;
+               }
+               return sql_error(sql, 02, "ALTER TABLE: cannot %s VIEW '%s'\n", 
                        msg, t->base.name);
+       }
+
        switch (s->token) {
        case SQL_COLUMN:
                res = create_column(sql, s, ss, t, alter);


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to