Changeset: 394bce144c31 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/394bce144c31 Modified Files: monetdb5/modules/mal/remote.c sql/backends/monet5/sql_result.c tools/monetdbe/monetdbe.c Branch: default Log Message:
Merged with Jul2021 diffs (140 lines): diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c --- a/monetdb5/modules/mal/remote.c +++ b/monetdb5/modules/mal/remote.c @@ -248,8 +248,11 @@ static str RMTconnectScen( if (columnar && *columnar) { char set_protocol_query_buf[50]; snprintf(set_protocol_query_buf, 50, "sql.set_protocol(%d:int);", PROTOCOL_COLUMNAR); - if ((msg = RMTquery(&hdl, "remote.connect", m, set_protocol_query_buf))) + if ((msg = RMTquery(&hdl, "remote.connect", m, set_protocol_query_buf))) { + mapi_destroy(m); + MT_lock_unset(&mal_remoteLock); return msg; + } } /* connection established, add to list */ @@ -1396,17 +1399,16 @@ static str RMTexec(Client cntxt, MalBlkP results[i].scale = mapi_get_scale(mhdl, i); } - if (tmp == MAL_SUCCEED) { - assert(rcb->context); - tmp = rcb->call(rcb->context, mapi_get_table(mhdl, 0), results, fields); - } - if (tmp != MAL_SUCCEED) { for (int j = 0; j < i; j++) BBPunfix(results[j].id); } else { for (int j = 0; j < i; j++) BBPkeepref(results[j].id); + assert(rcb->context); + tmp = rcb->call(rcb->context, mapi_get_table(mhdl, 0), results, fields); + for (int j = 0; j < i; j++) + BBPrelease(results[j].id); } GDKfree(results); } 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 @@ -1738,7 +1738,8 @@ mvc_export_head(backend *b, stream *s, i return -4; /* row count, min(count, reply_size) */ - if (mvc_send_int(s, (m->reply_size >= 0 && (BUN) m->reply_size < count) ? m->reply_size : (int) count) != 1) + /* the columnar protocol ignores the reply size by fetching the entire resultset at once, so don't set it */ + if (mvc_send_int(s, (b->client->protocol != PROTOCOL_COLUMNAR && m->reply_size >= 0 && (BUN) m->reply_size < count) ? m->reply_size : (int) count) != 1) return -4; // export query id diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c --- a/tools/monetdbe/monetdbe.c +++ b/tools/monetdbe/monetdbe.c @@ -1063,19 +1063,24 @@ monetdbe_set_remote_results(backend *be, } BAT* order = BATdense(0, 0, BATcount(b_0)); - if (mvc_result_table(be, 0, (int) nr_results, Q_TABLE, order) < 0) { - BBPreclaim(order); + if (!order) { + BBPunfix(b_0->batCacheid); + error = createException(MAL,"monetdbe.monetdbe_set_remote_results",SQLSTATE(HY005) MAL_MALLOC_FAIL); + return error; + } + + int res = mvc_result_table(be, 0, (int) nr_results, Q_TABLE, order); + BBPunfix(order->batCacheid); + if (res < 0) { BBPunfix(b_0->batCacheid); error = createException(MAL,"monetdbe.monetdbe_set_remote_results",SQLSTATE(HY005) "Cannot create result table"); return error; } - unsigned i = 0; - for (i = 0; i < nr_results; i++) { + for (size_t i = 0; i < nr_results; i++) { BAT *b = NULL; - if (i > 0) { + if (i > 0) b = BATdescriptor(results[i].id); - } else b = b_0; // We already fetched this first column @@ -1084,26 +1089,22 @@ monetdbe_set_remote_results(backend *be, int digits = results[i].digits; int scale = results[i].scale; - if ( b == NULL) { - error= createException(MAL,"monetdbe.monetdbe_set_remote_results",SQLSTATE(HY005) "Cannot access column descriptor "); - break; - } - else if (mvc_result_column(be, tblname, colname, tpename, digits, scale, b)) { - error = createException(SQL, "monetdbe.monetdbe_set_remote_results", SQLSTATE(42000) "Cannot access column descriptor %s.%s",tblname,colname); - BBPunfix(b->batCacheid); + if (b == NULL) { + error = createException(MAL,"monetdbe.monetdbe_result_cb",SQLSTATE(HY005) "Cannot access column descriptor"); break; } + + int res = mvc_result_column(be, tblname, colname, tpename, digits, scale, b); BBPunfix(b->batCacheid); + if (res) { + error = createException(MAL,"monetdbe.monetdbe_result_cb", SQLSTATE(42000) "Cannot access column descriptor %s.%s",tblname,colname); + break; + } } - BBPunfix(order->batCacheid); - - if (error) { + if (error) res_tables_destroy(be->results); - return error; - } - - return MAL_SUCCEED; + return error; } static str @@ -1172,7 +1173,7 @@ monetdbe_prepare_cb(void* context, char* !(bcolumn = BATdescriptor(results[5].id)) || !(bimpl = BATdescriptor(results[6].id))) { - msg = createException(SQL, "monetdbe.monetdbe_prepare_cb", SQLSTATE(42000) "Cannot access prepare result"); + msg = createException(SQL, "monetdbe.monetdbe_prepare_cb", SQLSTATE(HY005) "Cannot access column descriptor"); goto cleanup; } @@ -1185,7 +1186,7 @@ monetdbe_prepare_cb(void* context, char* nparams != BATcount(btable) || nparams != BATcount(bcolumn)) { - msg = createException(SQL, "monetdbe.monetdbe_prepare_cb", SQLSTATE(42000) "prepare results are incorrect."); + msg = createException(SQL, "monetdbe.monetdbe_prepare_cb", SQLSTATE(42000) "Prepare results are incorrect"); goto cleanup; } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list