Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13162/src/backends/monet5
Modified Files:
sql_result.mx
Log Message:
propagated changes of Sunday Nov 08 2009 - Monday Nov 09 2009
from the Nov2009 branch to the development trunk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/11/08 - mlkersten: src/backends/monet5/sql_result.mx,1.127.2.2
Handling og Coverty complaints.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: sql_result.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_result.mx,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- sql_result.mx 6 Oct 2009 13:30:13 -0000 1.128
+++ sql_result.mx 8 Nov 2009 23:57:13 -0000 1.129
@@ -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;
}
------------------------------------------------------------------------------
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