Changeset: 1e5d5ece3fc5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1e5d5ece3fc5
Modified Files:
gdk/gdk_calc.c
gdk/gdk_system.c
gdk/gdk_utils.c
gdk/gdk_value.c
monetdb5/extras/rapi/rapi.c
monetdb5/mal/mal.c
monetdb5/mal/mal_builder.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_module.c
monetdb5/modules/mal/calc.c
monetdb5/modules/mal/iterator.c
monetdb5/optimizer/Makefile.ag
monetdb5/optimizer/opt_garbageCollector.c
monetdb5/optimizer/opt_pipes.c
monetdb5/optimizer/opt_support.c
monetdb5/optimizer/opt_wrapper.c
sql/backends/monet5/UDF/pyapi/pyapi.c
sql/backends/monet5/iot/basket.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_orderidx.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statistics.c
sql/include/sql_catalog.h
sql/server/rel_distribute.c
sql/server/rel_dump.c
sql/server/rel_optimizer.c
sql/server/rel_partition.c
sql/server/rel_planner.c
sql/server/rel_psm.c
sql/server/rel_rel.c
sql/server/rel_schema.c
sql/server/rel_select.c
sql/server/rel_updates.c
sql/storage/bat/bat_storage.c
sql/storage/sql_storage.h
sql/storage/store.c
Branch: iot
Log Message:
Partial recovery of the malicious merge with default
Most of the stuff is back in place, but IOT queries
don't work yet due to
INSERT INTO: cannot insert into stream 'stmp'
diffs (truncated from 2253 to 300 lines):
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -3099,10 +3099,11 @@ addstr_loop(BAT *b1, const char *l, BAT
if (s == NULL)
goto bunins_failed;
}
-#ifdef HAVE_STPCPY
- (void) stpcpy(stpcpy(s, l), r);
+#ifdef HAVE_STRCPY_S
+ strcpy_s(s, slen, l);
+ strcpy_s(s + llen, slen - llen, r);
#else
- snprintf(s, slen, "%s%s", l, r);
+ (void) strcpy(strcpy(s, l) + llen, r);
#endif
tfastins_nocheck(bn, i, s, Tsize(bn));
}
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -237,18 +237,25 @@ void
join_detached_threads(void)
{
struct winthread *w;
+ int waited;
- EnterCriticalSection(&winthread_cs);
- while (winthreads) {
- w = winthreads;
- winthreads = w->next;
+ do {
+ waited = 0;
+ EnterCriticalSection(&winthread_cs);
+ for (w = winthreads; w; w = w->next) {
+ if ((w->flags & (DETACHED | WAITING)) == DETACHED) {
+ w->flags |= WAITING;
+ LeaveCriticalSection(&winthread_cs);
+ WaitForSingleObject(w->hdl, INFINITE);
+ CloseHandle(w->hdl);
+ rm_winthread(w);
+ waited = 1;
+ EnterCriticalSection(&winthread_cs);
+ break;
+ }
+ }
LeaveCriticalSection(&winthread_cs);
- WaitForSingleObject(w->hdl, INFINITE);
- CloseHandle(w->hdl);
- free(w);
- EnterCriticalSection(&winthread_cs);
- }
- LeaveCriticalSection(&winthread_cs);
+ } while (waited);
}
int
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -643,6 +643,7 @@ GDKprepareExit(void)
GDKfree(st);
}
MT_lock_unset(&GDKthreadLock);
+ join_detached_threads();
}
/* Register a thread that should be waited for in GDKreset. The
diff --git a/gdk/gdk_value.c b/gdk/gdk_value.c
--- a/gdk/gdk_value.c
+++ b/gdk/gdk_value.c
@@ -166,7 +166,9 @@ VALcopy(ValPtr d, const ValRecord *s)
/* Create a copy of the type value combination in TPE/S, allocating
* space for external values (non-fixed sized values). See VALcopy
* for a version where the source is in a ValRecord, and see VALset
- * for a version where ownership of the source is transferred. */
+ * for a version where ownership of the source is transferred.
+ *
+ * Returns NULL in case of (malloc) failure. */
ValPtr
VALinit(ValPtr d, int tpe, const void *s)
{
@@ -199,6 +201,8 @@ VALinit(ValPtr d, int tpe, const void *s
#endif
case TYPE_str:
d->val.sval = GDKstrdup(s);
+ if (d->val.sval == NULL)
+ return NULL;
d->len = strLen(s);
break;
case TYPE_ptr:
@@ -209,8 +213,9 @@ VALinit(ValPtr d, int tpe, const void *s
assert(ATOMextern(ATOMstorage(tpe)));
d->len = ATOMlen(tpe, s);
d->val.pval = GDKmalloc(d->len);
- if( d->val.pval)
- memcpy(d->val.pval, s, d->len);
+ if (d->val.pval == NULL)
+ return NULL;
+ memcpy(d->val.pval, s, d->len);
break;
}
return d;
diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c
--- a/monetdb5/extras/rapi/rapi.c
+++ b/monetdb5/extras/rapi/rapi.c
@@ -437,8 +437,11 @@ str RAPIeval(Client cntxt, MalBlkPtr mb,
*getArgReference_bat(stk, pci, i) = b->batCacheid;
} else { // single value return, only for non-grouped
aggregations
BATiter li = bat_iterator(b);
- VALinit(&stk->stk[pci->argv[i]], bat_type,
- BUNtail(li, 0)); // TODO BUNtail here
+ if (VALinit(&stk->stk[pci->argv[i]], bat_type,
+ BUNtail(li, 0)) == NULL) { //
TODO BUNtail here
+ msg = createException(MAL, "rapi.eval",
MAL_MALLOC_FAIL);
+ goto wrapup;
+ }
}
msg = MAL_SUCCEED;
}
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -167,11 +167,7 @@ void mserver_reset(void)
* Beware, mal_exit is also called during a SIGTERM from the monetdb tool
*/
-static int serverstopped;
void mal_exit(void){
- if( serverstopped)
- return;
- serverstopped = 1;
mserver_reset();
GDKexit(0); /* properly end GDK */
}
diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c
--- a/monetdb5/mal/mal_builder.c
+++ b/monetdb5/mal/mal_builder.c
@@ -512,8 +512,10 @@ pushNil(MalBlkPtr mb, InstrPtr q, int tp
ptr p = ATOMnil(tpe);
VALset(&cst, tpe, p);
} else {
- const void *p = ATOMnilptr(tpe);
- VALinit(&cst, tpe, p);
+ if (VALinit(&cst, tpe, ATOMnilptr(tpe)) == NULL) {
+ freeInstruction(q);
+ return NULL;
+ }
}
_t = defConstant(mb,tpe,&cst);
} else {
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -1150,8 +1150,8 @@ convertConstant(int type, ValPtr vr)
/* if the value we're converting from is nil, the to
* convert to value will also be nil */
if (ATOMcmp(vr->vtype, ATOMnilptr(vr->vtype), VALptr(vr)) == 0)
{
- VALinit(vr, type, ATOMnilptr(type));
- vr->vtype = type;
+ if (VALinit(vr, type, ATOMnilptr(type)) == NULL)
+ throw(MAL, "convertConstant", MAL_MALLOC_FAIL);
break;
}
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -551,7 +551,7 @@ str runMALsequence(Client cntxt, MalBlkP
//Ensure we spread system resources over multiple users as well.
runtimeProfileBegin(cntxt, mb, stk, pci, &runtimeProfile);
if (runtimeProfile.ticks > lastcheck + CHECKINTERVAL) {
- if (cntxt->fdin && cntxt->fdin->s &&
!mnstr_isalive(cntxt->fdin->s)) {
+ if (cntxt->fdin && !mnstr_isalive(cntxt->fdin->s)) {
cntxt->mode = FINISHCLIENT;
stkpc = stoppc;
ret= createException(MAL, "mal.interpreter",
"prematurely stopped client");
diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c
--- a/monetdb5/mal/mal_module.c
+++ b/monetdb5/mal/mal_module.c
@@ -250,7 +250,7 @@ Module findModule(Module scope, str name
scope= scope->link;
}
/* default is always matched with current */
- if( def == NULL || def->name==NULL) return NULL;
+ if( def->name==NULL) return NULL;
return def;
}
int isModuleDefined(Module scope, str name){
diff --git a/monetdb5/modules/mal/calc.c b/monetdb5/modules/mal/calc.c
--- a/monetdb5/modules/mal/calc.c
+++ b/monetdb5/modules/mal/calc.c
@@ -646,7 +646,8 @@ CALCswitchbit(Client cntxt, MalBlkPtr mb
return mythrow(MAL, "ifthenelse", SEMANTIC_TYPE_MISMATCH);
if (b == bit_nil) {
- VALinit(&stk->stk[pci->argv[0]], t1, ATOMnilptr(t1));
+ if (VALinit(&stk->stk[pci->argv[0]], t1, ATOMnilptr(t1)) ==
NULL)
+ return mythrow(MAL, "ifthenelse", MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
if (b) {
@@ -686,7 +687,8 @@ CALCmin(Client cntxt, MalBlkPtr mb, MalS
p1 = nil;
else if (ATOMcmp(t, p1, p2) > 0)
p1 = p2;
- VALinit(&stk->stk[getArg(pci, 0)], t, p1);
+ if (VALinit(&stk->stk[getArg(pci, 0)], t, p1) == NULL)
+ return mythrow(MAL, "calc.min", MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -711,7 +713,8 @@ CALCmin_no_nil(Client cntxt, MalBlkPtr m
if (ATOMcmp(t, p1, nil) == 0 ||
(ATOMcmp(t, p2, nil) != 0 && ATOMcmp(t, p1, p2) > 0))
p1 = p2;
- VALinit(&stk->stk[getArg(pci, 0)], t, p1);
+ if (VALinit(&stk->stk[getArg(pci, 0)], t, p1) == NULL)
+ return mythrow(MAL, "calc.min", MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -737,7 +740,8 @@ CALCmax(Client cntxt, MalBlkPtr mb, MalS
p1 = nil;
else if (ATOMcmp(t, p1, p2) < 0)
p1 = p2;
- VALinit(&stk->stk[getArg(pci, 0)], t, p1);
+ if (VALinit(&stk->stk[getArg(pci, 0)], t, p1) == NULL)
+ return mythrow(MAL, "calc.max", MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
@@ -762,7 +766,8 @@ CALCmax_no_nil(Client cntxt, MalBlkPtr m
if (ATOMcmp(t, p1, nil) == 0 ||
(ATOMcmp(t, p2, nil) != 0 && ATOMcmp(t, p1, p2) < 0))
p1 = p2;
- VALinit(&stk->stk[getArg(pci, 0)], t, p1);
+ if (VALinit(&stk->stk[getArg(pci, 0)], t, p1) == NULL)
+ return mythrow(MAL, "calc.max", MAL_MALLOC_FAIL);
return MAL_SUCCEED;
}
diff --git a/monetdb5/modules/mal/iterator.c b/monetdb5/modules/mal/iterator.c
--- a/monetdb5/modules/mal/iterator.c
+++ b/monetdb5/modules/mal/iterator.c
@@ -139,7 +139,10 @@ ITRbunIterator(Client cntxt, MalBlkPtr m
*head = 0;
bi = bat_iterator(b);
- VALinit(tail, b->ttype, BUNtail(bi, *(BUN*) head));
+ if (VALinit(tail, b->ttype, BUNtail(bi, *(BUN*) head)) == NULL) {
+ BBPunfix(b->batCacheid);
+ throw(MAL, "iterator.nextChunk", MAL_MALLOC_FAIL);
+ }
BBPunfix(b->batCacheid);
return MAL_SUCCEED;
}
@@ -170,7 +173,10 @@ ITRbunNext(Client cntxt, MalBlkPtr mb, M
return MAL_SUCCEED;
}
bi = bat_iterator(b);
- VALinit(tail, b->ttype, BUNtail(bi, *(BUN*) head));
+ if (VALinit(tail, b->ttype, BUNtail(bi, *(BUN*) head)) == NULL) {
+ BBPunfix(b->batCacheid);
+ throw(MAL, "iterator.nextChunk", MAL_MALLOC_FAIL);
+ }
BBPunfix(b->batCacheid);
return MAL_SUCCEED;
}
diff --git a/monetdb5/optimizer/Makefile.ag b/monetdb5/optimizer/Makefile.ag
--- a/monetdb5/optimizer/Makefile.ag
+++ b/monetdb5/optimizer/Makefile.ag
@@ -26,13 +26,14 @@ lib_optimizer = {
opt_costModel.c opt_costModel.h \
opt_dataflow.c opt_dataflow.h \
opt_deadcode.c opt_deadcode.h \
+ opt_emptybind.c opt_emptybind.h \
opt_evaluate.c opt_evaluate.h \
opt_factorize.c opt_factorize.h \
opt_garbageCollector.c opt_garbageCollector.h \
opt_generator.c opt_generator.h \
opt_querylog.c opt_querylog.h \
opt_inline.c opt_inline.h \
- opt_iot.c opt_iot.h \
+ opt_jit.c opt_jit.h \
opt_projectionpath.c opt_projectionpath.h \
opt_macro.c opt_macro.h \
opt_matpack.c opt_matpack.h \
diff --git a/monetdb5/optimizer/opt_garbageCollector.c
b/monetdb5/optimizer/opt_garbageCollector.c
--- a/monetdb5/optimizer/opt_garbageCollector.c
+++ b/monetdb5/optimizer/opt_garbageCollector.c
@@ -70,10 +70,10 @@ OPTgarbageCollectorImplementation(Client
}
if (blockStart(p) )
depth++;
+ if ( p->token == ENDsymbol)
+ break;
pushInstruction(mb, p);
- if ( p->token == ENDsymbol)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list