Changeset: e0110e589d40 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e0110e589d40
Modified Files:
monetdb5/mal/mal_builder.c
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_recycle.c
monetdb5/mal/mal_runtime.c
monetdb5/modules/kernel/algebra.c
monetdb5/modules/kernel/bat5.c
monetdb5/modules/mal/mat.c
sql/backends/monet5/generator/generator.c
sql/backends/monet5/sql.c
Branch: Oct2014
Log Message:
Use bat_nil instead of 0 for nil:bat.
diffs (279 lines):
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
@@ -419,7 +419,7 @@ pushNil(MalBlkPtr mb, InstrPtr q, int tp
_t = defConstant(mb,tpe,&cst);
} else {
cst.vtype = TYPE_bat;
- cst.val.bval = 0;
+ cst.val.bval = bat_nil;
_t = defConstant(mb,TYPE_bat,&cst);
mb->var[_t]->type = tpe;
}
diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -1346,7 +1346,7 @@ printStackElm(stream *f, MalBlkPtr mb, V
mnstr_printf(f, "\n");
GDKfree(nmeOnStk);
- if (cnt && v && (isaBatType(n->type) || v->vtype == TYPE_bat) &&
v->val.ival) {
+ if (cnt && v && (isaBatType(n->type) || v->vtype == TYPE_bat) &&
v->val.bval != bat_nil) {
BAT *b, *bs;
b = BATdescriptor(v->val.ival);
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
@@ -1334,7 +1334,7 @@ convertConstant(int type, ValPtr vr)
if (type == TYPE_bat || isaBatType(type)) {
/* BAT variables can only be set to nil */
vr->vtype = type;
- vr->val.bval = 0;
+ vr->val.bval = bat_nil;
return MAL_SUCCEED;
}
switch (ATOMstorage(type)) {
@@ -1385,7 +1385,7 @@ convertConstant(int type, ValPtr vr)
case TYPE_bat:
/* BAT variables can only be set to nil */
vr->vtype = type;
- vr->val.bval = 0;
+ vr->val.bval = bat_nil;
return MAL_SUCCEED;
case TYPE_ptr:
/* all coercions should be avoided to protect against memory
probing */
@@ -1521,7 +1521,7 @@ defConstant(MalBlkPtr mb, int type, ValP
if (isaBatType(type) && cst->vtype == TYPE_void) {
cst->vtype = TYPE_bat;
- cst->val.bval = 0;
+ cst->val.bval = bat_nil;
} else if (cst->vtype != type && !isaBatType(type) &&
!isPolyType(type)) {
ValRecord vr = *cst;
int otype = cst->vtype;
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
@@ -637,7 +637,7 @@ str runMALsequence(Client cntxt, MalBlkP
lhs = &stk->stk[pci->argv[k]];
rhs = &stk->stk[pci->argv[i]];
VALcopy(lhs, rhs);
- if (lhs->vtype == TYPE_bat &&
lhs->val.bval)
+ if (lhs->vtype == TYPE_bat &&
lhs->val.bval != bat_nil)
BBPincref(lhs->val.bval, TRUE);
}
FREE_EXCEPTION(ret);
@@ -767,7 +767,8 @@ str runMALsequence(Client cntxt, MalBlkP
for (i = 0; i < pci->retc; i++) {
if (garbage[i] == -1 &&
stk->stk[getArg(pci, i)].vtype == TYPE_bat &&
- stk->stk[getArg(pci,
i)].val.bval) {
+ stk->stk[getArg(pci,
i)].val.bval != bat_nil &&
+ stk->stk[getArg(pci,
i)].val.bval != 0) {
b =
BBPquickdesc(abs(stk->stk[getArg(pci, i)].val.bval), FALSE);
if (b == NULL) {
ret =
createException(MAL, "mal.propertyCheck", RUNTIME_OBJECT_MISSING);
@@ -803,15 +804,15 @@ str runMALsequence(Client cntxt, MalBlkP
if (isaBatType(getArgType(mb,
pci, i))) {
bat bid =
stk->stk[a].val.bval;
- if (i < pci->retc &&
backup[i].val.bval) {
+ if (i < pci->retc &&
backup[i].val.bval != bat_nil) {
bat bx =
backup[i].val.bval;
-
backup[i].val.bval = 0;
+
backup[i].val.bval = bat_nil;
BBPdecref(bx,
TRUE);
}
if (garbage[i] >= 0) {
PARDEBUG
mnstr_printf(GDKstdout, "#GC pc=%d bid=%d %s done\n", stkpc, bid,
getVarName(mb, garbage[i]));
bid =
abs(stk->stk[garbage[i]].val.bval);
-
stk->stk[garbage[i]].val.bval = 0;
+
stk->stk[garbage[i]].val.bval = bat_nil;
BBPdecref(bid,
TRUE);
}
} else if (i < pci->retc &&
@@ -1376,8 +1377,8 @@ void garbageElement(Client cntxt, ValPtr
bat bid = abs(v->val.bval);
/* printf("garbage collecting: %d lrefs=%d refs=%d\n",
bid, BBP_lrefs(bid),BBP_refs(bid));*/
- v->val.bval = 0;
- if (bid == 0)
+ v->val.bval = bat_nil;
+ if (bid == bat_nil)
return;
if (!BBP_lrefs(bid))
return;
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
@@ -153,7 +153,7 @@ RECYCLEgarbagecollect(MalBlkPtr mb, Inst
for(j=0; j< q->argc; j++){
v= &getVarConstant(mb,getArg(q,j));
if(isaBatType(getArgType(mb, q,j)) ){
- if( v->val.bval ){
+ if( v->val.bval != bat_nil ){
BBPdecref(abs(v->val.bval), TRUE);
if (!BBP_lrefs(v->val.bval)){
v->vtype= TYPE_int;
@@ -712,7 +712,7 @@ static int
RECYCLEreuse(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p,
RuntimeProfile outerprof)
{
int i, j, pc= -1;
- bat bid= 0, nbid= 0;
+ bat bid= bat_nil, nbid= bat_nil;
InstrPtr q;
MT_lock_set(&recycleLock, "recycle");
@@ -746,7 +746,7 @@ RECYCLEreuse(Client cntxt, MalBlkPtr mb,
if (subsmp){
BAT *b1, *b2;
nbid = getVarConstant(recycleBlk,
getArg(q,0)).val.bval;
- if( bid == 0){
+ if( bid == bat_nil){
bid = nbid;
pc = i;
} else {
@@ -785,7 +785,7 @@ RECYCLEreuse(Client cntxt, MalBlkPtr mb,
/*
* We have a candidate table
*/
- if (bid ) {
+ if (bid != bat_nil) {
int k;
RuntimeProfileRecord prof;
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -192,7 +192,7 @@ runtimeProfileExit(Client cntxt, MalBlkP
if (getProfileCounter(PROFfootprint) ){
for (i = 0; i < pci->retc; i++)
- if ( isaBatType(getArgType(mb,pci,i)) &&
stk->stk[getArg(pci,i)].val.bval){
+ if ( isaBatType(getArgType(mb,pci,i)) &&
stk->stk[getArg(pci,i)].val.bval != bat_nil){
/* avoid simple alias operations */
fnd= 0;
for ( j= pci->retc; j< pci->argc; j++)
diff --git a/monetdb5/modules/kernel/algebra.c
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -361,7 +361,7 @@ ALGsubselect2(bat *result, bat *bid, bat
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "algebra.subselect", RUNTIME_OBJECT_MISSING);
}
- if (sid && *sid && (s = BATdescriptor(*sid)) == NULL) {
+ if (sid && *sid != bat_nil && (s = BATdescriptor(*sid)) == NULL) {
BBPreleaseref(b->batCacheid);
throw(MAL, "algebra.subselect", RUNTIME_OBJECT_MISSING);
}
@@ -399,7 +399,7 @@ ALGthetasubselect2(bat *result, bat *bid
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "algebra.thetasubselect", RUNTIME_OBJECT_MISSING);
}
- if (sid && *sid && (s = BATdescriptor(*sid)) == NULL) {
+ if (sid && *sid != bat_nil && (s = BATdescriptor(*sid)) == NULL) {
BBPreleaseref(b->batCacheid);
throw(MAL, "algebra.thetasubselect", RUNTIME_OBJECT_MISSING);
}
@@ -708,9 +708,9 @@ do_join(bat *r1, bat *r2, bat *lid, bat
goto fail;
if ((right = BATdescriptor(*rid)) == NULL)
goto fail;
- if (slid && *slid && (candleft = BATdescriptor(*slid)) == NULL)
+ if (slid && *slid != bat_nil && (candleft = BATdescriptor(*slid)) ==
NULL)
goto fail;
- if (srid && *srid && (candright = BATdescriptor(*srid)) == NULL)
+ if (srid && *srid != bat_nil && (candright = BATdescriptor(*srid)) ==
NULL)
goto fail;
if (estimate == NULL || *estimate < 0 || *estimate == lng_nil ||
*estimate > (lng) BUN_MAX)
est = BUN_NONE;
@@ -991,7 +991,7 @@ ALGsubunique2(bat *result, bat *bid, bat
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "algebra.subunique", RUNTIME_OBJECT_MISSING);
}
- if (sid && *sid && (s = BATdescriptor(*sid)) == NULL) {
+ if (sid && *sid != bat_nil && (s = BATdescriptor(*sid)) == NULL) {
BBPreleaseref(b->batCacheid);
throw(MAL, "algebra.subunique", RUNTIME_OBJECT_MISSING);
}
@@ -1591,11 +1591,11 @@ ALGsubsort33(bat *result, bat *norder, b
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "algebra.subsort", RUNTIME_OBJECT_MISSING);
- if (order && *order && (o = BATdescriptor(*order)) == NULL) {
+ if (order && *order != bat_nil && (o = BATdescriptor(*order)) == NULL) {
BBPreleaseref(b->batCacheid);
throw(MAL, "algebra.subsort", RUNTIME_OBJECT_MISSING);
}
- if (group && *group && (g = BATdescriptor(*group)) == NULL) {
+ if (group && *group != bat_nil && (g = BATdescriptor(*group)) == NULL) {
if (o)
BBPreleaseref(o->batCacheid);
BBPreleaseref(b->batCacheid);
@@ -2150,7 +2150,7 @@ ALGprojecthead(Client cntxt, MalBlkPtr m
b = BATmirror(b);
bn = BATconst(b, v->vtype, VALptr(v), TRANSIENT);
if (bn == NULL) {
- *ret = 0;
+ *ret = bat_nil;
throw(MAL, "algebra.project", MAL_MALLOC_FAIL);
}
bn = BATmirror(bn);
@@ -2176,7 +2176,7 @@ ALGprojecttail(Client cntxt, MalBlkPtr m
throw(MAL, "algebra.project", RUNTIME_OBJECT_MISSING);
bn = BATconst(b, v->vtype, VALptr(v), TRANSIENT);
if (bn == NULL) {
- *ret = 0;
+ *ret = bat_nil;
throw(MAL, "algebra.project", MAL_MALLOC_FAIL);
}
if (!(bn->batDirty&2))
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -1016,7 +1016,7 @@ BKCdestroy(bit *r, int *bid)
(void) r;
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "bat.destroy", RUNTIME_OBJECT_MISSING);
- *bid = 0;
+ *bid = bat_nil;
BATmode(b, TRANSIENT);
BBPreleaseref(b->batCacheid);
return MAL_SUCCEED;
diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c
--- a/monetdb5/modules/mal/mat.c
+++ b/monetdb5/modules/mal/mat.c
@@ -109,7 +109,7 @@ MATpackInternal(Client cntxt, MalBlkPtr
}
}
if (tt == TYPE_any){
- *ret = 0;
+ *ret = bat_nil;
return MAL_SUCCEED;
}
diff --git a/sql/backends/monet5/generator/generator.c
b/sql/backends/monet5/generator/generator.c
--- a/sql/backends/monet5/generator/generator.c
+++ b/sql/backends/monet5/generator/generator.c
@@ -577,7 +577,7 @@ str VLTgenerator_thetasubselect(Client c
if( pci->argc == 5){ // candidate list included
cndid = *(int*) getArgReference(stk,pci, 2);
- if( cndid){
+ if( cndid != bat_nil){
cand = BATdescriptor(cndid);
if( cand == NULL)
throw(MAL,"generator.subselect",RUNTIME_OBJECT_MISSING);
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
@@ -2254,7 +2254,7 @@ SQLtid(Client cntxt, MalBlkPtr mb, MalSt
size_t nr, inr = 0;
oid sb = 0;
- *res = 0;
+ *res = bat_nil;
if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL)
return msg;
tr = m->session->tr;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list