Changeset: ed9eaef52e2f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ed9eaef52e2f Modified Files: monetdb5/mal/Tests/tst180.stable.err monetdb5/mal/mal_instruction.c Branch: default Log Message:
Detect illegal constant conversion. diffs (43 lines): diff --git a/monetdb5/mal/Tests/tst180.stable.err b/monetdb5/mal/Tests/tst180.stable.err --- a/monetdb5/mal/Tests/tst180.stable.err +++ b/monetdb5/mal/Tests/tst180.stable.err @@ -28,6 +28,7 @@ MAPI = (monetdb) /var/tmp/mtest-25335/. QUERY = # errors in the constant types x:= 1:bat[:int]; io.print(x); +ERROR = !TypeException:user.main[0]:BAT coercion error # 23:13:31 > 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 @@ -989,6 +989,8 @@ convertConstant(int type, ValPtr vr) return MAL_SUCCEED; if (type == TYPE_bat || isaBatType(type)) { /* BAT variables can only be set to nil */ + if( vr->vtype != TYPE_void) + throw(SYNTAX, "convertConstant", "BAT conversion error"); VALclear(vr); vr->vtype = type; vr->val.bval = bat_nil; @@ -1064,10 +1066,15 @@ defConstant(MalBlkPtr mb, int type, ValP int k; str msg; - if (isaBatType(type) && cst->vtype == TYPE_void) { - cst->vtype = TYPE_bat; - cst->val.bval = bat_nil; - } else if (cst->vtype != type && !isaBatType(type) && !isPolyType(type)) { + if (isaBatType(type)){ + if( cst->vtype == TYPE_void) { + cst->vtype = TYPE_bat; + cst->val.bval = bat_nil; + } else { + mb->errors = createMalException(mb, 0, TYPE, "BAT coercion error"); + return -1; + } + } else if (cst->vtype != type && !isPolyType(type)) { int otype = cst->vtype; assert(type != TYPE_any); /* help Coverity */ msg = convertConstant(getBatType(type), cst); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list