Changeset: e7ebd125b103 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e7ebd125b103 Modified Files: clients/mapiclient/mclient.c monetdb5/mal/mal_profiler.c monetdb5/mal/mal_recycle.c monetdb5/modules/mal/pcre.c monetdb5/optimizer/opt_mergetable.c monetdb5/optimizer/opt_pipes.c monetdb5/optimizer/optimizer.c monetdb5/optimizer/optimizer_private.h sql/server/rel_semantic.c sql/storage/bat/bat_storage.c Branch: default Log Message:
Merge with Jun2016 branch. diffs (truncated from 623 to 300 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -3322,6 +3322,7 @@ main(int argc, char **argv) if (command != NULL) { #ifdef HAVE_ICONV iconv_t cd_in; + int free_command = 0; if (encoding != NULL && (cd_in = iconv_open("utf-8", encoding)) != (iconv_t) -1) { @@ -3331,6 +3332,7 @@ main(int argc, char **argv) int factor = 4; size_t tolen = factor * fromlen + 1; char *to = malloc(tolen); + free_command = 1; try_again: command = to; @@ -3367,6 +3369,10 @@ main(int argc, char **argv) timerStart(); c = doRequest(mid, command); timerEnd(); +#ifdef HAVE_ICONV + if (free_command) + free(command); +#endif } if (optind < argc) { diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -626,9 +626,11 @@ static BAT *TRACE_id_stmt = 0; int TRACEtable(BAT **r) { - if (TRACE_init == 0) + MT_lock_set(&mal_profileLock); + if (TRACE_init == 0) { + MT_lock_unset(&mal_profileLock); return -1; /* not initialized */ - MT_lock_set(&mal_profileLock); + } r[0] = COLcopy(TRACE_id_event, TRACE_id_event->ttype, 0, TRANSIENT); r[1] = COLcopy(TRACE_id_time, TRACE_id_time->ttype, 0, TRANSIENT); r[2] = COLcopy(TRACE_id_pc, TRACE_id_pc->ttype, 0, TRANSIENT); @@ -649,35 +651,39 @@ TRACEtable(BAT **r) BAT * getTrace(const char *nme) { - if (TRACE_init == 0) - return NULL; - if (strcmp(nme, "event") == 0) - return COLcopy(TRACE_id_event, TRACE_id_event->ttype, 0, TRANSIENT); - if (strcmp(nme, "time") == 0) - return COLcopy(TRACE_id_time, TRACE_id_time->ttype, 0, TRANSIENT); - if (strcmp(nme, "pc") == 0) - return COLcopy(TRACE_id_pc, TRACE_id_pc->ttype, 0, TRANSIENT); - if (strcmp(nme, "thread") == 0) - return COLcopy(TRACE_id_thread, TRACE_id_thread->ttype, 0, TRANSIENT); - if (strcmp(nme, "usec") == 0) - return COLcopy(TRACE_id_ticks, TRACE_id_ticks->ttype, 0, TRANSIENT); - if (strcmp(nme, "rssMB") == 0) - return COLcopy(TRACE_id_rssMB, TRACE_id_rssMB->ttype, 0, TRANSIENT); - if (strcmp(nme, "tmpspace") == 0) - return COLcopy(TRACE_id_tmpspace, TRACE_id_tmpspace->ttype, 0, TRANSIENT); - if (strcmp(nme, "reads") == 0) - return COLcopy(TRACE_id_inblock, TRACE_id_inblock->ttype, 0, TRANSIENT); - if (strcmp(nme, "writes") == 0) - return COLcopy(TRACE_id_oublock, TRACE_id_oublock->ttype, 0, TRANSIENT); - if (strcmp(nme, "minflt") == 0) - return COLcopy(TRACE_id_minflt, TRACE_id_minflt->ttype, 0, TRANSIENT); - if (strcmp(nme, "majflt") == 0) - return COLcopy(TRACE_id_majflt, TRACE_id_majflt->ttype, 0, TRANSIENT); - if (strcmp(nme, "nvcsw") == 0) - return COLcopy(TRACE_id_nvcsw, TRACE_id_nvcsw->ttype, 0, TRANSIENT); - if (strcmp(nme, "stmt") == 0) - return COLcopy(TRACE_id_stmt, TRACE_id_stmt->ttype, 0, TRANSIENT); - return NULL; + BAT *bn = NULL; + + MT_lock_set(&mal_profileLock); + if (TRACE_init) { + if (strcmp(nme, "event") == 0) + bn = COLcopy(TRACE_id_event, TRACE_id_event->ttype, 0, TRANSIENT); + else if (strcmp(nme, "time") == 0) + bn = COLcopy(TRACE_id_time, TRACE_id_time->ttype, 0, TRANSIENT); + else if (strcmp(nme, "pc") == 0) + bn = COLcopy(TRACE_id_pc, TRACE_id_pc->ttype, 0, TRANSIENT); + else if (strcmp(nme, "thread") == 0) + bn = COLcopy(TRACE_id_thread, TRACE_id_thread->ttype, 0, TRANSIENT); + else if (strcmp(nme, "usec") == 0) + bn = COLcopy(TRACE_id_ticks, TRACE_id_ticks->ttype, 0, TRANSIENT); + else if (strcmp(nme, "rssMB") == 0) + bn = COLcopy(TRACE_id_rssMB, TRACE_id_rssMB->ttype, 0, TRANSIENT); + else if (strcmp(nme, "tmpspace") == 0) + bn = COLcopy(TRACE_id_tmpspace, TRACE_id_tmpspace->ttype, 0, TRANSIENT); + else if (strcmp(nme, "reads") == 0) + bn = COLcopy(TRACE_id_inblock, TRACE_id_inblock->ttype, 0, TRANSIENT); + else if (strcmp(nme, "writes") == 0) + bn = COLcopy(TRACE_id_oublock, TRACE_id_oublock->ttype, 0, TRANSIENT); + else if (strcmp(nme, "minflt") == 0) + bn = COLcopy(TRACE_id_minflt, TRACE_id_minflt->ttype, 0, TRANSIENT); + else if (strcmp(nme, "majflt") == 0) + bn = COLcopy(TRACE_id_majflt, TRACE_id_majflt->ttype, 0, TRANSIENT); + else if (strcmp(nme, "nvcsw") == 0) + bn = COLcopy(TRACE_id_nvcsw, TRACE_id_nvcsw->ttype, 0, TRANSIENT); + else if (strcmp(nme, "stmt") == 0) + bn = COLcopy(TRACE_id_stmt, TRACE_id_stmt->ttype, 0, TRANSIENT); + } + MT_lock_unset(&mal_profileLock); + return bn; } static BAT * @@ -731,9 +737,11 @@ initTrace(void) { int ret = -1; - if (TRACE_init) + MT_lock_set(&mal_contextLock); + if (TRACE_init) { + MT_lock_unset(&mal_contextLock); return 0; /* already initialized */ - MT_lock_set(&mal_contextLock); + } TRACE_id_event = TRACEcreate("id", "event", TYPE_int); TRACE_id_time = TRACEcreate("id", "time", TYPE_str); // TODO split pc into its components fcn,pc,tag @@ -774,23 +782,25 @@ initTrace(void) void clearTrace(void) { - if (TRACE_init == 0) + MT_lock_set(&mal_contextLock); + if (TRACE_init == 0) { + MT_lock_unset(&mal_contextLock); return; /* not initialized */ - MT_lock_set(&mal_contextLock); + } /* drop all trace tables */ - BBPclear(TRACE_id_event->batCacheid); - BBPclear(TRACE_id_time->batCacheid); - BBPclear(TRACE_id_pc->batCacheid); - BBPclear(TRACE_id_thread->batCacheid); - BBPclear(TRACE_id_ticks->batCacheid); - BBPclear(TRACE_id_rssMB->batCacheid); - BBPclear(TRACE_id_tmpspace->batCacheid); - BBPclear(TRACE_id_inblock->batCacheid); - BBPclear(TRACE_id_oublock->batCacheid); - BBPclear(TRACE_id_minflt->batCacheid); - BBPclear(TRACE_id_majflt->batCacheid); - BBPclear(TRACE_id_nvcsw->batCacheid); - BBPclear(TRACE_id_stmt->batCacheid); + BBPunfix(TRACE_id_event->batCacheid); + BBPunfix(TRACE_id_time->batCacheid); + BBPunfix(TRACE_id_pc->batCacheid); + BBPunfix(TRACE_id_thread->batCacheid); + BBPunfix(TRACE_id_ticks->batCacheid); + BBPunfix(TRACE_id_rssMB->batCacheid); + BBPunfix(TRACE_id_tmpspace->batCacheid); + BBPunfix(TRACE_id_inblock->batCacheid); + BBPunfix(TRACE_id_oublock->batCacheid); + BBPunfix(TRACE_id_minflt->batCacheid); + BBPunfix(TRACE_id_majflt->batCacheid); + BBPunfix(TRACE_id_nvcsw->batCacheid); + BBPunfix(TRACE_id_stmt->batCacheid); TRACE_init = 0; MT_lock_unset(&mal_contextLock); initTrace(); @@ -876,6 +886,10 @@ cachedProfilerEvent(MalBlkPtr mb, MalStk // keep it a short transaction MT_lock_set(&mal_profileLock); + if (TRACE_init == 0) { + MT_lock_unset(&mal_profileLock); + return; + } errors += BUNappend(TRACE_id_event, &TRACE_event, FALSE) != GDK_SUCCEED; errors += BUNappend(TRACE_id_time, ct, FALSE) != GDK_SUCCEED; errors += BUNappend(TRACE_id_pc, buf, FALSE) != GDK_SUCCEED; diff --git a/monetdb5/mal/mal_recycle.c b/monetdb5/mal/mal_recycle.c --- a/monetdb5/mal/mal_recycle.c +++ b/monetdb5/mal/mal_recycle.c @@ -424,6 +424,8 @@ RECYCLEkeep(Client cntxt, MalBlkPtr mb, c = fndConstant(recycleBlk, &cst, recycleBlk->vtop); if (c<0) c = defConstant(recycleBlk, v->vtype, &cst); + else + VALclear(&cst); } else { c = newTmpVariable(recycleBlk, v->vtype); setVarConstant(recycleBlk, c); @@ -434,6 +436,7 @@ RECYCLEkeep(Client cntxt, MalBlkPtr mb, clrVarCleanup(recycleBlk, c); v = &getVarConstant(recycleBlk, c); VALcopy(v,&cst); + VALclear(&cst); } if (v->vtype == TYPE_bat) BBPincref( *(const int*)VALptr(v), TRUE); @@ -864,7 +867,7 @@ RECYCLEexit(Client cntxt, MalBlkPtr mb, /* infinite case, admit all new instructions */ if (RECYCLEfind(cntxt,mb,stk,p)<0 ) - (void) RECYCLEkeep(cntxt,mb, stk, p, prof); + RECYCLEkeep(cntxt,mb, stk, p, prof); recycleSearchTime += GDKusec()-clk; recycleSearchCalls++; MT_lock_unset(&recycleLock); diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c --- a/monetdb5/modules/mal/pcre.c +++ b/monetdb5/modules/mal/pcre.c @@ -318,14 +318,14 @@ pcre_likesubselect(BAT **bnp, BAT *b, BA pe = pcre_study(re, 0, &error); if (error != NULL) { my_pcre_free(re); - my_pcre_free(pe); + pcre_free_study(pe); throw(MAL, "pcre.likesubselect", OPERATION_FAILED ": studying pattern \"%s\" failed\n", pat); } bn = BATnew(TYPE_void, TYPE_oid, s ? BATcount(s) : BATcount(b), TRANSIENT); if (bn == NULL) { my_pcre_free(re); - my_pcre_free(pe); + pcre_free_study(pe); throw(MAL, "pcre.likesubselect", MAL_MALLOC_FAIL); } off = b->hseqbase - BUNfirst(b); @@ -373,7 +373,7 @@ pcre_likesubselect(BAT **bnp, BAT *b, BA pcre_exec(re, pe, v, (int) strlen(v), 0, 0, ovector, 10) >= 0); } my_pcre_free(re); - my_pcre_free(pe); + pcre_free_study(pe); bn->tsorted = 1; bn->trevsorted = bn->batCount <= 1; bn->tkey = 1; @@ -391,7 +391,7 @@ pcre_likesubselect(BAT **bnp, BAT *b, BA bunins_failed: BBPreclaim(bn); my_pcre_free(re); - my_pcre_free(pe); + pcre_free_study(pe); *bnp = NULL; throw(MAL, "pcre.likesubselect", OPERATION_FAILED); } @@ -567,6 +567,7 @@ pcre_replace(str *res, const char *origi offset = ovector[1]; } } while((j > 0) && (offset < len_origin_str) && (ncaptures < MAX_NR_CAPTURES)); + pcre_free_study(extra); if (ncaptures > 0){ tmpres = GDKmalloc(len_origin_str - len_del + (len_replacement * ncaptures) + 1); @@ -688,6 +689,7 @@ pcre_replace_bat(BAT **res, BAT *origin_ replaced_str = GDKmalloc(len_origin_str - len_del + (len_replacement * ncaptures) + 1); if (!replaced_str) { my_pcre_free(pcre_code); + pcre_free_study(extra); GDKfree(ovector); throw(MAL, "pcre_replace_bat", MAL_MALLOC_FAIL); } @@ -725,6 +727,7 @@ pcre_replace_bat(BAT **res, BAT *origin_ } } + pcre_free_study(extra); my_pcre_free(pcre_code); GDKfree(ovector); BATseqbase(tmpbat, origin_strs->hseqbase); @@ -1576,7 +1579,7 @@ pcresubjoin(BAT *r1, BAT *r2, BAT *l, BA } if (pcrere) { my_pcre_free(pcrere); - my_pcre_free(pcreex); + pcre_free_study(pcreex); pcrere = NULL; pcreex = NULL; } @@ -1618,7 +1621,7 @@ pcresubjoin(BAT *r1, BAT *r2, BAT *l, BA if (pcrere) my_pcre_free(pcrere); if (pcreex) - my_pcre_free(pcreex); + pcre_free_study(pcreex); assert(msg != MAL_SUCCEED); return msg; } diff --git a/monetdb5/optimizer/opt_mergetable.c b/monetdb5/optimizer/opt_mergetable.c --- a/monetdb5/optimizer/opt_mergetable.c +++ b/monetdb5/optimizer/opt_mergetable.c @@ -27,7 +27,7 @@ typedef struct mat { int pm; /* parent mat, for sub relations */ mat_type_t type; /* type of operation */ int packed; - int pushed; + int pushed; /* set if instruction pushed and shouldn't be freed */ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list