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

Modified Files:
      Tag: Nov2009
        sql_result.mx 
Log Message:

undoing
"
2009/11/08 - mlkersten: sql/src/backends/monet5/sql_result.mx,1.127.2.2
Handling og Coverty complaints.
"

This makes the following tests work, again, that started failing due to
this checkin
(see also "Update 2" of
ID: 2893878 "SQL: more tests fail with Nov2009 that worked with Aug2009" at
https://sourceforge.net/tracker/?func=detail&aid=2893878&group_id=56967&atid=482468
):
src/odbc/samples/odbcsample1.SQL.sh
src/test/mapi/python_dbapi.SQL.sh
src/test/mapi/python_test_monetdb_sql_dbapi20.SQL.sh
src/test/mapi/python_test_monetdb_sql_capabilities.SQL.sh

Fixing Coverity-detected problems must not invalidate code correctness.


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


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