Changeset: ccc6b181ff16 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ccc6b181ff16
Modified Files:
clients/mapiclient/mclient.c
clients/mapilib/mapi.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
Branch: protocol
Log Message:
Fix multiple result sets.
diffs (144 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1779,7 +1779,6 @@ format_result(Mapi mid, MapiHdl hdl, cha
#endif
setWidth();
-
do {
/* handle errors first */
if (mapi_result_error(hdl) != NULL) {
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -4474,9 +4474,10 @@ read_into_cache(MapiHdl hdl, int lookahe
}
//printf("Column %d: %s - %s (%d, %p)\n", i,
col_name, type_sql_name, typelen, result->fields[i].converter);
}
+ /*
hdl->result = result;
hdl->active = result;
-
+*/
{
char dummy;
// we flush on the other side so this read will
always fail
@@ -5171,7 +5172,8 @@ mapi_fetch_line(MapiHdl hdl)
hdl->mid->languageId == LANG_SQL &&
result->querytype == Q_TABLE &&
result->row_count > 0 &&
- result->cache.first + result->cache.tuplecount < result->row_count)
{
+ result->cache.first + result->cache.tuplecount < result->row_count
&&
+ !hdl->prot10_resultset) {
if (hdl->needmore) /* escalate */
return NULL;
if (hdl->mid->active != NULL)
@@ -5692,7 +5694,7 @@ mapi_split_line(MapiHdl hdl)
struct MapiResultSet *result;
result = hdl->result;
assert(result != NULL);
- if (hdl->mid->protocol == prot10 || hdl->mid->protocol ==
prot10compressed) {
+ if (hdl->prot10_resultset) {
assert(0);
return -1;
}
@@ -5716,6 +5718,7 @@ mapi_fetch_row(MapiHdl hdl)
size_t i;
struct MapiResultSet *result;
+ mapi_hdl_check(hdl, "mapi_fetch_row");
if (hdl->prot10_resultset) {
char* buf;
@@ -5723,11 +5726,10 @@ mapi_fetch_row(MapiHdl hdl)
// check if we have read the entire result set
if (result->rows_read >= result->row_count) {
char dummy;
- hdl->mid->active = NULL;
- hdl->active = NULL;
+ mnstr_readChr(hdl->mid->from, &dummy);
bs2_resetbuf(hdl->mid->from);
- mnstr_readChr(hdl->mid->from, &dummy);
hdl->prot10_resultset = 0;
+ mapi_fetch_line(hdl);
return 0;
}
// if not, check if our cache is empty
@@ -5912,7 +5914,6 @@ mapi_fetch_row(MapiHdl hdl)
return result->fieldcnt;
}
- mapi_hdl_check(hdl, "mapi_fetch_row");
do {
if ((reply = mapi_fetch_line(hdl)) == NULL)
return 0;
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -3414,6 +3414,7 @@ mvc_scalar_value_wrap(Client cntxt, MalB
int *eclass = getArgReference_int(stk, pci, 6);
ptr p = getArgReference(stk, pci, 7);
int mtype = getArgType(mb, pci, 7);
+ int res_id;
str msg;
backend *b = NULL;
@@ -3424,10 +3425,16 @@ mvc_scalar_value_wrap(Client cntxt, MalB
if (ATOMextern(mtype))
p = *(ptr *) p;
+ if (b->output_format == OFMT_NONE) {
+ return MAL_SUCCEED;
+ }
+
// scalar values are single-column result sets
- mvc_result_table(b->mvc, 1, 1, NULL);
+ res_id = mvc_result_table(b->mvc, 1, 1, NULL);
mvc_result_value(b->mvc, *tn, *cn, *type, *digits, *scale, p, mtype);
- if (b->output_format == OFMT_NONE) {
+ if (b->client->protocol == prot10 || b->client->protocol ==
prot10compressed) {
+ if (mvc_export_result(b, cntxt->fdout, res_id))
+ throw(SQL, "sql.exportResult", "failed");
return MAL_SUCCEED;
}
if (b->out == NULL || mvc_export_value(b, b->out, 1, *tn, *cn, *type,
*digits, *scale, *eclass, p, mtype, "", "NULL") != SQL_OK)
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -1898,7 +1898,6 @@ static int mvc_export_resultset_prot10(r
errno = 0;
}
}
- fprintf(stdout, "Export resultset 10.\n");
iterators = GDKzalloc(sizeof(BATiter) * t->nr_cols);
@@ -2018,7 +2017,11 @@ static int mvc_export_resultset_prot10(r
goto cleanup;
}
}
- mnstr_flush(s);
+ if (mnstr_flush(s) < 0) {
+ fprintf(stderr, "Failed to flush.\n");
+ fres = -1;
+ goto cleanup;
+ }
while (row < (size_t) count) {
char *buf = bs2_buffer(s).buf;
@@ -2347,12 +2350,13 @@ static int mvc_export_resultset_prot10(r
bs2_setpos(s, buf - bs2_buffer(s).buf);
if (mnstr_flush(s) < 0) {
fprintf(stderr, "Failed to flush.\n");
+ bs2_setpos(s, 0); // clear the buffer
fres = -1;
goto cleanup;
}
srow = row;
}
-cleanup:
+cleanup:
if (iterators) {
for(i = 0; i < (size_t) t->nr_cols; i++) {
if (iterators[i].b) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list