Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv31268/src/backends/monet5
Modified Files:
sql_result.mx
Log Message:
propagated changes of Tuesday Nov 10 2009
from the Nov2009 branch to the development trunk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/11/10 - stmane: src/backends/monet5/sql_result.mx,1.127.2.3
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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/11/10 - stmane: src/backends/monet5/sql_result.mx,1.127.2.4
correctly fix potential NULL-pointer dereference detected by Coverity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/11/10 - stmane: src/backends/monet5/sql_result.mx,1.127.2.5
Handle 2 more Coverity-detected potential NULL-dereferences.
In fact, I'm not completely sure, whether we can simply ignore
the failing BATdescriptor() calls in these cases, or should rather
return an error code; in the latter case, which would be the correct
error code to be used, here, -1|0|1 ?
For now, we ignore in case assertions are disabled,
and trigger an assertion otherwise ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: sql_result.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_result.mx,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- sql_result.mx 8 Nov 2009 23:57:13 -0000 1.129
+++ sql_result.mx 10 Nov 2009 18:27:35 -0000 1.130
@@ -445,13 +445,15 @@
m->type = -1;
return NULL;
}
- if (!bs ){
- showException(IO,"sql", "stream not open %d",
stream_errnr(bs->s));
+ if (!bs) {
+ showException(IO,"sql", "no stream (pointer) provided");
+
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;
}
@@ -840,9 +842,18 @@
if (bid) {
BAT *b = BATdescriptor(bid);
- if ( b ){
+ if (b) {
l = bat_max_strlength(b);
BBPunfix(b->batCacheid);
+ } else {
+ assert(b);
+ /* [[email protected]]:
+ * Instead of an assert() or simply
ignoring the problem,
+ * we could/should return an error
code, but I don't know
+ * which it the correct/suitable error
code -1|0|1 ?
+ *
+ return -1|0|1 ;
+ */
}
} else if (p) {
str v = (str) p;
@@ -858,7 +869,7 @@
if (bid) {
BAT *b = BATdescriptor(bid);
- if ( b ) {
+ if (b) {
if (mtype == TYPE_bte) {
count = bat_max_btelength(b);
} else if (mtype == TYPE_sht) {
@@ -869,6 +880,15 @@
count = bat_max_lnglength(b);
}
BBPunfix(b->batCacheid);
+ } else {
+ assert(b);
+ /* [[email protected]]:
+ * Instead of an assert() or simply ignoring
the problem,
+ * we could/should return an error code, but I
don't know
+ * which it the correct/suitable error code
-1|0|1 ?
+ *
+ return -1|0|1 ;
+ */
}
} else {
if (p) {
@@ -1135,12 +1155,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 +1167,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 +1186,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 +1228,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