Changeset: 76e225aaa920 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=76e225aaa920 Modified Files: clients/Tests/exports.stable.out monetdb5/modules/mal/tablet.c monetdb5/modules/mal/tablet.h sql/backends/monet5/sql_result.c Branch: default Log Message:
Merge with Apr2019 branch. diffs (104 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -1793,7 +1793,7 @@ str SERVERsetAlias(void *ret, int *mid, str SERVERstop(void *ret); str SERVERsuspend(void *ret); str SERVERtrace(void *ret, int *mid, int *flag); -BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool from_stdin); +BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool from_stdin, const char *tabnam); str STRBytes(int *res, const str *arg1); str STRConcat(str *res, const str *val1, const str *val2); str STRFromWChr(str *res, const int *at); diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c --- a/monetdb5/modules/mal/tablet.c +++ b/monetdb5/modules/mal/tablet.c @@ -402,14 +402,16 @@ tablet_read_more(bstream *in, stream *ou do { /* query is not finished ask for more */ /* we need more query text */ - if (in->eof) { - if (mnstr_write(out, PROMPT2, sizeof(PROMPT2) - 1, 1) < 0 || - mnstr_flush(out) < 0) - return false; - in->eof = false; - } if (bstream_next(in) < 0) return false; + if (in->eof) { + if (mnstr_write(out, PROMPT2, sizeof(PROMPT2) - 1, 1) == 1) + mnstr_flush(out); + in->eof = false; + /* we need more query text */ + if (bstream_next(in) <= 0) + return false; + } } while (in->len <= in->pos); } else if (bstream_read(in, n) <= 0) { return false; @@ -1580,7 +1582,7 @@ create_rejects_table(Client cntxt) } BUN -SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool from_stdin) +SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool from_stdin, const char *tabnam) { BUN cnt = 0, cntstart = 0, leftover = 0; int res = 0; /* < 0: error, > 0: success, == 0: continue processing */ @@ -1591,6 +1593,7 @@ SQLload_file(Client cntxt, Tablet *as, b READERtask ptask[MAXWORKERS]; int threads = (!maxrow || maxrow > (1 << 16)) ? (GDKnr_threads < MAXWORKERS && GDKnr_threads > 1 ? GDKnr_threads - 1 : MAXWORKERS - 1) : 1; lng lio = 0, tio, t1 = 0, total = 0, iototal = 0; + char name[16]; #ifdef _DEBUG_TABLET_ mnstr_printf(GDKout, "#Prepare copy work for %d threads col '%s' rec '%s' quot '%c'\n", @@ -1699,7 +1702,8 @@ SQLload_file(Client cntxt, Tablet *as, b } task.id = 0; - if ((task.tid = THRcreate(SQLproducer, (void *) &task, MT_THR_JOINABLE, "SQLproducer")) == 0) { + snprintf(name, sizeof(name), "prod-%s", tabnam); + if ((task.tid = THRcreate(SQLproducer, (void *) &task, MT_THR_JOINABLE, name)) == 0) { tablet_error(&task, lng_nil, int_nil, SQLSTATE(42000) "failed to start producer thread", "SQLload_file"); goto bailout; } @@ -1722,12 +1726,12 @@ SQLload_file(Client cntxt, Tablet *as, b #ifdef MLOCK_TST mlock(ptask[j].cols, sizeof(char *) * task.limit); #endif - char name[16]; snprintf(name, sizeof(name), "ptask%d.sema", j); MT_sema_init(&ptask[j].sema, 0, name); snprintf(name, sizeof(name), "ptask%d.repl", j); MT_sema_init(&ptask[j].reply, 0, name); - if ((ptask[j].tid = THRcreate(SQLworker, (void *) &ptask[j], MT_THR_JOINABLE, "SQLworker")) == 0) { + snprintf(name, sizeof(name), "wrkr%d-%s", j, tabnam); + if ((ptask[j].tid = THRcreate(SQLworker, (void *) &ptask[j], MT_THR_JOINABLE, name)) == 0) { tablet_error(&task, lng_nil, int_nil, SQLSTATE(42000) "failed to start worker thread", "SQLload_file"); threads = j; for (j = 0; j < threads; j++) diff --git a/monetdb5/modules/mal/tablet.h b/monetdb5/modules/mal/tablet.h --- a/monetdb5/modules/mal/tablet.h +++ b/monetdb5/modules/mal/tablet.h @@ -71,7 +71,7 @@ typedef struct Table_t { BAT *complaints; /* lines that did not match the required input */ } Tablet; -mal_export BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool from_stdin); +mal_export BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, const char *csep, const char *rsep, char quote, lng skip, lng maxrow, int best, bool from_stdin, const char *tabnam); mal_export str TABLETcreate_bats(Tablet *as, BUN est); mal_export str TABLETcollect(BAT **bats, Tablet *as); mal_export str TABLETcollect_parts(BAT **bats, Tablet *as, BUN offset); 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 @@ -993,7 +993,7 @@ mvc_import_table(Client cntxt, BAT ***ba } } if ( (locked || (msg = TABLETcreate_bats(&as, (BUN) (sz < 0 ? 1000 : sz))) == MAL_SUCCEED) ){ - if (!sz || (SQLload_file(cntxt, &as, bs, out, sep, rsep, ssep ? ssep[0] : 0, offset, sz, best, from_stdin) != BUN_NONE && + if (!sz || (SQLload_file(cntxt, &as, bs, out, sep, rsep, ssep ? ssep[0] : 0, offset, sz, best, from_stdin, t->base.name) != BUN_NONE && (best || !as.error))) { *bats = (BAT**) GDKzalloc(sizeof(BAT *) * as.nr_attrs); if ( *bats == NULL){ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list