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

Modified Files:
        rel_select.mx 
Log Message:
propagated changes of Saturday Aug 30 2008 - Friday Sep 05 2008
from the SQL_2-24 branch to the development trunk


Index: rel_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_select.mx,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- rel_select.mx       22 Aug 2008 09:52:19 -0000      1.85
+++ rel_select.mx       5 Sep 2008 14:49:50 -0000       1.86
@@ -2263,6 +2263,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;
@@ -2291,6 +2292,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);
@@ -2310,19 +2316,23 @@
                                }
                                right = rl;
                        }
-                       if (right->processed && !right->name)
-                               rel_label(right, ++sql->label);
-                       right = rel_distinct(right);
+                       if (!correlated) {
+                               if (right->processed && !right->name)
+                                       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);
@@ -2636,7 +2646,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;
@@ -3570,6 +3581,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;
 
@@ -3578,7 +3590,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;
@@ -3588,9 +3600,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);
@@ -3600,6 +3615,8 @@
                rel_destroy(rel);
                return NULL;
        }
+       list_merge(outexps, r_exps, (fdup)&exp_dup);
+       list_destroy(r_exps);
        return rel_project(rel, outexps);
 }
 


-------------------------------------------------------------------------
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