Changeset: 72eed75428a0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=72eed75428a0 Added Files: sql/test/BugTracker-2017/Tests/sqlitelogictest-cast-decimal.Bug-6445.sql Modified Files: monetdb5/mal/mal_parser.c monetdb5/modules/atoms/str.c sql/server/rel_select.c sql/server/sql_parser.y sql/test/BugTracker-2017/Tests/All Branch: default Log Message:
Merge with Jul2017 diffs (124 lines): diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c --- a/monetdb5/mal/mal_parser.c +++ b/monetdb5/mal/mal_parser.c @@ -1111,8 +1111,11 @@ fcnHeader(Client cntxt, int kind) assert(!cntxt->backup); cntxt->backup = cntxt->curprg; cntxt->curprg = newFunction( modnme, fnme, kind); - cntxt->curprg->def->errors = cntxt->backup->def->errors; - cntxt->backup->def->errors = 0; + if(cntxt->curprg == NULL) { + parseError(cntxt, MAL_MALLOC_FAIL); + cntxt->curprg = cntxt->backup; + return 0; + } curPrg = cntxt->curprg; curBlk = curPrg->def; curInstr = getInstrPtr(curBlk, 0); @@ -1363,6 +1366,10 @@ parseFunction(Client cntxt, int kind) return 0; } nme = idCopy(cntxt, i); + if (nme == NULL) { + parseError(cntxt, MAL_MALLOC_FAIL); + return 0; + } curInstr->fcn = getAddress(nme); GDKfree(nme); if (curInstr->fcn == NULL) { @@ -1515,7 +1522,11 @@ parseAssign(Client cntxt, int cntrl) curPrg = cntxt->curprg; curBlk = curPrg->def; curInstr = newInstruction(curBlk, NULL, NULL); - + if((curInstr = newInstruction(curBlk, NULL, NULL)) == NULL) { + parseError(cntxt, MAL_MALLOC_FAIL); + return; + } + if( cntrl){ curInstr->token = ASSIGNsymbol; curInstr->barrier = cntrl; @@ -1758,12 +1769,19 @@ parseMAL(Client cntxt, Symbol curPrg, in *e = 0; if (! skipcomments && e > start && curBlk->stop > 0 ) { ValRecord cst; - curInstr = newInstruction(curBlk, NULL, NULL); + if((curInstr = newInstruction(curBlk, NULL, NULL)) == NULL) { + parseError(cntxt, MAL_MALLOC_FAIL); + continue; + } curInstr->token= REMsymbol; curInstr->barrier= 0; cst.vtype = TYPE_str; - cst.len = strlen(start); - cst.val.sval = GDKstrdup(start); + cst.len = (int) strlen(start); + if((cst.val.sval = GDKstrdup(start)) == NULL) { + parseError(cntxt, MAL_MALLOC_FAIL); + freeInstruction(curInstr); + continue; + } getArg(curInstr, 0) = defConstant(curBlk, TYPE_str, &cst); clrVarConstant(curBlk, getArg(curInstr, 0)); setVarDisabled(curBlk, getArg(curInstr, 0)); diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c --- a/monetdb5/modules/atoms/str.c +++ b/monetdb5/modules/atoms/str.c @@ -3655,6 +3655,7 @@ STRLtrim2(str *res, const str *arg1, con throw(MAL, "str.trim", SQLSTATE(HY001) MAL_MALLOC_FAIL); len = strlen(s); n = lstrip(s, len, chars, nchars); + GDKfree(chars); *res = GDKstrndup(s + n, len - n); } if (*res == NULL) @@ -3681,6 +3682,7 @@ STRRtrim2(str *res, const str *arg1, con throw(MAL, "str.trim", SQLSTATE(HY001) MAL_MALLOC_FAIL); len = strlen(s); n = rstrip(s, len, chars, nchars); + GDKfree(chars); *res = GDKstrndup(s, n); } if (*res == NULL) diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1051,7 +1051,7 @@ rel_column_ref(mvc *sql, sql_rel **rel, /* some views are just in the stack, like before and after updates views */ - if (!exp && sql->use_views) { + if (rel && !exp && sql->use_views) { sql_rel *v = stack_find_rel_view(sql, tname); if (v) { diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y --- a/sql/server/sql_parser.y +++ b/sql/server/sql_parser.y @@ -3951,7 +3951,7 @@ window_frame_end: ; window_frame_following: - value_exp PRECEDING { $$ = $1; } + value_exp FOLLOWING { $$ = $1; } ; window_frame_exclusion: diff --git a/sql/test/BugTracker-2017/Tests/All b/sql/test/BugTracker-2017/Tests/All --- a/sql/test/BugTracker-2017/Tests/All +++ b/sql/test/BugTracker-2017/Tests/All @@ -97,3 +97,4 @@ sqlitelogictest-aggregation-distinct-coa sqlsmith.Bug-6432 sqlitelogictest-select-in.Bug-6433 sqlitelogictest-select-not-in.Bug-6435 +sqlitelogictest-cast-decimal.Bug-6445 diff --git a/sql/test/BugTracker-2017/Tests/sqlitelogictest-cast-decimal.Bug-6445.sql b/sql/test/BugTracker-2017/Tests/sqlitelogictest-cast-decimal.Bug-6445.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2017/Tests/sqlitelogictest-cast-decimal.Bug-6445.sql @@ -0,0 +1,4 @@ +CREATE TABLE tab1(col0 INTEGER, col1 INTEGER, col2 INTEGER); +SELECT col0 + - - CAST ( NULL AS REAL ) - + col0 + + col1 FROM tab1 cor0 WHERE ( NULL ) IS NOT NULL; +SELECT col0 + - - CAST( NULL AS DECIMAL ) - + col0 + + col1 FROM tab1 cor0 WHERE ( NULL ) IS NOT NULL; +DROP TABLE tab1; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list