Update of /cvsroot/monetdb/sql/src/server
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14962/src/server

Modified Files:
        rel_bin.mx rel_optimizer.mx 
Log Message:
first steps into coverity fixes.


Index: rel_optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_optimizer.mx,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- rel_optimizer.mx    9 Oct 2009 20:47:36 -0000       1.72
+++ rel_optimizer.mx    9 Nov 2009 22:06:36 -0000       1.73
@@ -2006,7 +2006,7 @@
                                        if (je->card >= CARD_ATOM && je->type 
== e_cmp && je->flag != cmp_or) {
                                                /* expect right expression to 
match */
                                                sql_exp *r = je->r;
-                                               if (r->type != e_column)
+                                               if (r && r->type != e_column)
                                                        continue;
                                                if (r && r->l && rname && 
strcmp(r->l, rname) == 0 && strcmp(r->r,gbe->name)==0) {
                                                        fnd = 1;

Index: rel_bin.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_bin.mx,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- rel_bin.mx  27 Oct 2009 06:38:12 -0000      1.97
+++ rel_bin.mx  9 Nov 2009 22:06:36 -0000       1.98
@@ -85,7 +85,7 @@
                for (n = sub->op1.lval->h; n; n = n->next) {
                        char *nme = column_name(n->data);
 
-                       if (strcmp(nme, name) == 0) {
+                       if (nme && strcmp(nme, name) == 0) {
                                res = n->data;
                                _DELETE(nme);
                                break;
@@ -324,8 +324,13 @@
                                else
                                        orderby = stmt_order(orderbycols, 
is_ascending(orderbycole));
                        }
-                       if (!orderby)
+                       if (!orderby && left)
                                orderby = stmt_mirror(bin_first_column(left));
+                       if (!orderby) {
+                               list_destroy(l);
+                               grp_destroy(g);
+                               return NULL;
+                       }
                        list_append(l, orderby);
                        if (g) {
                                list_append(l, stmt_dup(g->grp));
@@ -417,7 +422,7 @@
                        print_stmtlist(left);
                        print_stmtlist(right);
                }
-               if (sel)
+               if (s && sel)
                        s = stmt_semijoin(s, stmt_dup(sel));
         }      break;
        case e_cmp: {
@@ -746,8 +751,6 @@
                }
                if (sub && sub->nrcols >= 1 && s->nrcols == 0)
                        s = stmt_const(bin_first_column(sub), s);
-               else if (!sub)
-                       s = column(s);
                rnme = (rnme)?_strdup(rnme):NULL;
                s = stmt_alias(s, rnme, _strdup(exp->name));
                list_append(l, s);
@@ -1156,6 +1159,12 @@
        for (n = right->op1.lval->h; n; n = n->next) 
                rgrp = grp_create(column(n->data), rgrp);
 
+       if (!lgrp || !rgrp) {
+               grp_destroy(lgrp);
+               grp_destroy(rgrp);
+               return NULL;
+       }
+
        a = sql_bind_aggr(sql->session->schema, "count", NULL);
        ls = stmt_aggr(stmt_dup(lgrp->grp), grp_dup(lgrp), a, 1); 
        a = sql_dup_aggr(a);
@@ -1294,6 +1303,12 @@
        for (n = right->op1.lval->h; n; n = n->next) 
                rgrp = grp_create(column(n->data), rgrp);
 
+       if (!lgrp || !rgrp) {
+               grp_destroy(lgrp);
+               grp_destroy(rgrp);
+               return NULL;
+       }
+
        a = sql_bind_aggr(sql->session->schema, "count", NULL);
        ls = stmt_aggr(stmt_dup(lgrp->grp), grp_dup(lgrp), a, 1); 
        a = sql_dup_aggr(a);
@@ -1558,6 +1573,11 @@
                assert(e->type == e_cmp && e->flag == cmp_equal);
                s = exp_bin(sql, e->r, NULL, NULL, NULL, NULL);
 
+               if (!s) {
+                       stmt_destroy(h);
+                       stmt_destroy(bits);
+                       return NULL;
+               }
                if (h) {
                        sql_subfunc *xor = 
sql_bind_func_result3(sql->session->schema, "rotate_xor_hash", wrd, it, 
tail_type(s), wrd);
 
@@ -1605,7 +1625,7 @@
        }
        /* handle possible index lookups */
        /* expressions are in index order ! */
-       if ( (en = rel->exps->h) != NULL) { 
+       if (sub && (en = rel->exps->h) != NULL) { 
                sql_exp *e = en->data;
                prop *p;
 
@@ -3198,13 +3218,11 @@
        int len;
        node *n, *m;
 
-       if (rel->r) { /* first construct the update relation */
+       if (rel->r) /* first construct the update relation */
                update = subrel_bin(sql, rel->r, refs);
-
-               if (!update) { 
-                       assert(0);
-                       return NULL;    
-               }
+       if (!update) { 
+               assert(0);
+               return NULL;    
        }
        updates = table_update_array(t, &len);
        tid = update->op1.lval->h->data;


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to