Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv31470

Modified Files:
      Tag: Nov2009
        sql_gencode.mx sql_optimizer.mx sql_result.mx 
Log Message:
Handling og Coverty complaints.


Index: sql_result.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_result.mx,v
retrieving revision 1.127.2.1
retrieving revision 1.127.2.2
diff -u -d -r1.127.2.1 -r1.127.2.2
--- sql_result.mx       6 Oct 2009 14:50:53 -0000       1.127.2.1
+++ sql_result.mx       8 Nov 2009 14:36:34 -0000       1.127.2.2
@@ -445,9 +445,13 @@
                m->type = -1;
                return NULL;
        }
-       if (!bs ||stream_errnr(bs->s)) {
+       if (!bs ){
+               showException(IO,"sql", "stream not open %d", 
stream_errnr(bs->s));
+               m->type = -1;
+               return NULL;
+       }
+       if (stream_errnr(bs->s)) {
                showException(IO,"sql", "stream not open %d", 
stream_errnr(bs->s));
-
                m->type = -1;
                return NULL;
        }
@@ -836,8 +840,10 @@
                        if (bid) {
                                BAT *b = BATdescriptor(bid);
 
-                               l = bat_max_strlength(b);
-                               BBPunfix(b->batCacheid);
+                               if ( b ){
+                                       l = bat_max_strlength(b);
+                                       BBPunfix(b->batCacheid);
+                               }
                        } else if (p) {
                                str v = (str) p;
 
@@ -852,16 +858,18 @@
                if (bid) {
                        BAT *b = BATdescriptor(bid);
 
-                       if (mtype == TYPE_bte) {
-                               count = bat_max_btelength(b);
-                       } else if (mtype == TYPE_sht) {
-                               count = bat_max_shtlength(b);
-                       } else if (mtype == TYPE_int) {
-                               count = bat_max_intlength(b);
-                       } else { /* TYPE_lng */
-                               count = bat_max_lnglength(b);
+                       if ( b ) {
+                               if (mtype == TYPE_bte) {
+                                       count = bat_max_btelength(b);
+                               } else if (mtype == TYPE_sht) {
+                                       count = bat_max_shtlength(b);
+                               } else if (mtype == TYPE_int) {
+                                       count = bat_max_intlength(b);
+                               } else { /* TYPE_lng */
+                                       count = bat_max_lnglength(b);
+                               }
+                               BBPunfix(b->batCacheid);
                        }
-                       BBPunfix(b->batCacheid);
                } else {
                        if (p) {
                                lng val = 0;
@@ -1127,10 +1135,12 @@
                res = mvc_export_row(m, s, t, "", t->tsep, t->rsep, t->ssep, 
t->ns);
        } else {
                order = BATdescriptor(t->order);
-               count = BATcount(order);
+               if ( order) {
+                       count = BATcount(order);
 
-               res = mvc_export_table(m, s, t, order, 0, count, "", t->tsep, 
t->rsep, t->ssep, t->ns);
-               BBPunfix(order->batCacheid);
+                       res = mvc_export_table(m, s, t, order, 0, count, "", 
t->tsep, t->rsep, t->ssep, t->ns);
+                       BBPunfix(order->batCacheid);
+               }
                m->results = res_tables_remove(m->results, t);
        } 
        return res;
@@ -1139,7 +1149,7 @@
 int
 mvc_export_result(mvc *m, stream *s, int res_id)
 {
-       int clean = 0, res = 0;
+       int res = 1;
        BUN count;
        res_table *t = res_tables_find(m->results, res_id);
        BAT *order = NULL;
@@ -1158,15 +1168,13 @@
                return mvc_export_row(m, s, t, "[ ", ",\t", "\t]\n", "\"", 
"NULL");
        order = BATdescriptor(t->order);
 
-       count = m->reply_size;
-       if (count == 0 || count >= BATcount(order)) {
+       if ( order ) {
                count = BATcount(order);
-               clean = 1;
-       }
-       res = mvc_export_table(m, s, t, order, 0, count, "[ ", ",\t", "\t]\n", 
"\"", "NULL");
-       BBPunfix(order->batCacheid);
-       if (clean)
+               count = (BUN) m->reply_size  < count? (BUN) m->reply_size: 
count;
+               res = mvc_export_table(m, s, t, order, 0, count, "[ ", ",\t", 
"\t]\n", "\"", "NULL");
+               BBPunfix(order->batCacheid);
                m->results = res_tables_remove(m->results, t);
+       }
 
        if (res > 0)
                res = mvc_export_warning(s, "");
@@ -1200,28 +1208,30 @@
                return export_error(order);
 
        order = BATdescriptor(t->order);
-       cnt = nr;
-       if (cnt == 0) 
-               cnt = BATcount(order);
-       if (offset >= BATcount(order))
-               cnt = 0;
-       if (offset + cnt > BATcount(order)) 
-               cnt = BATcount(order) - offset;
+       if ( order) {
+               cnt = nr;
+               if (cnt == 0) 
+                       cnt = BATcount(order);
+               if (offset >= BATcount(order))
+                       cnt = 0;
+               if (offset + cnt > BATcount(order)) 
+                       cnt = BATcount(order) - offset;
 
-       /* row count */
-       if (!mvc_send_lng(s, (lng) cnt) || 
-                       stream_write(s, " ", 1, 1) != 1)
-               return export_error(order);
+               /* row count */
+               if (!mvc_send_lng(s, (lng) cnt) || 
+                               stream_write(s, " ", 1, 1) != 1)
+                       return export_error(order);
 
-       /* block offset */
-       if (!mvc_send_lng(s, (lng) offset)) 
-               return export_error(order);
+               /* block offset */
+               if (!mvc_send_lng(s, (lng) offset)) 
+                       return export_error(order);
 
-       if (stream_write(s, "\n", 1, 1) != 1)
-               return export_error(order);
+               if (stream_write(s, "\n", 1, 1) != 1)
+                       return export_error(order);
 
-       res = mvc_export_table(m, s, t, order, offset, cnt, "[ ", ",\t", 
"\t]\n", "\"", "NULL");
-       BBPunfix(order->batCacheid);
+               res = mvc_export_table(m, s, t, order, offset, cnt, "[ ", 
",\t", "\t]\n", "\"", "NULL");
+               BBPunfix(order->batCacheid);
+       }
        return res;
 }
 

Index: sql_gencode.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_gencode.mx,v
retrieving revision 1.336.2.2
retrieving revision 1.336.2.3
diff -u -d -r1.336.2.2 -r1.336.2.3
--- sql_gencode.mx      8 Oct 2009 13:26:12 -0000       1.336.2.2
+++ sql_gencode.mx      8 Nov 2009 14:36:34 -0000       1.336.2.3
@@ -872,7 +872,9 @@
                                        showException(SQL,"sql","SQL2MAL: error 
impossible\n");
                                }
                        }
-                       s->nr = getDestVar(q);
+                       if ( q )
+                               s->nr = getDestVar(q);
+                       else s->nr = newTmpVariable(mb, TYPE_any);
                }
                        break;
                case st_uselect2:

Index: sql_optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_optimizer.mx,v
retrieving revision 1.230.2.7
retrieving revision 1.230.2.8
diff -u -d -r1.230.2.7 -r1.230.2.8
--- sql_optimizer.mx    31 Oct 2009 18:53:16 -0000      1.230.2.7
+++ sql_optimizer.mx    8 Nov 2009 14:36:34 -0000       1.230.2.8
@@ -343,7 +343,7 @@
                        }
 
 
-                       if (s && f == bindidxRef) {
+                       if (s && f == bindidxRef && cname) {
                                size_t cnt;
                                sql_idx *i = mvc_bind_idx(m, s, cname);
 


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