Changeset: be0051b026da for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=be0051b026da Modified Files: monetdb5/mal/mal_instruction.c monetdb5/mal/mal_interpreter.c sql/backends/monet5/sql.c sql/backends/monet5/sql_gencode.c sql/server/rel_schema.c sql/server/rel_select.c sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.sql sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.stable.out sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.sql sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.err Branch: Jan2014 Log Message:
approved output for bug 3427 (also use auto commit mode) fixed bug 3430, ie check if local temporary tables are stored in the 'tmp' schema fixed bug 3428, don't overwrite the statement number, but use a temporary structure to store the NotNil select statements. Solves the problem that the sum(a), sub(a*b) uses the a after nil removal in the a*b. fixed bug 3425, correctly add the timezone with the proper type (ie second interval (ie with scale 3)) diffs (265 lines): 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 @@ -913,7 +913,7 @@ makeVarSpace(MalBlkPtr mb) { if (mb->vtop >= mb->vsize) { VarPtr *new; - int s = mb->vtop + MAXVARS; + int s = mb->vsize * 2; new = (VarPtr *) GDKzalloc(s * sizeof(VarPtr)); if (new == NULL) { 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 @@ -511,7 +511,17 @@ str runMALsequence(Client cntxt, MalBlkP throw(MAL, "mal.interpreter", MAL_STACK_FAIL); /* prepare extended backup and garbage structures */ - if ( mb->maxarg > 16 ){ + if (startpc+1 == stoppc) { + pci = getInstrPtr(mb, startpc); + if (pci->argc > 16) { + backup = GDKzalloc(pci->argc * sizeof(ValRecord)); + garbage = (int*)GDKzalloc(pci->argc * sizeof(int)); + } else { + backup = backups; + garbage = garbages; + memset((char*) garbages, 0, 16 * sizeof(int)); + } + } else if ( mb->maxarg > 16 ){ backup = GDKzalloc(mb->maxarg * sizeof(ValRecord)); garbage = (int*)GDKzalloc(mb->maxarg * sizeof(int)); } else { 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 @@ -3324,12 +3324,12 @@ month_interval(Client cntxt, MalBlkPtr m str second_interval(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { - lng *ret = (lng *) getArgReference(stk, pci, 0); - int k = digits2ek(*(int *) getArgReference(stk, pci, 2)); - lng r; + lng *ret = (lng *) getArgReference(stk, pci, 0), r; + int k = digits2ek(*(int *) getArgReference(stk, pci, 2)), scale = 0; (void) cntxt; - (void) mb; + if (pci->argc > 3) + scale = *(int*) getArgReference(stk, pci, 3); switch (getArgType(mb, pci, 1)) { case TYPE_bte: r = stk->stk[getArg(pci, 1)].val.btval; @@ -3362,6 +3362,8 @@ second_interval(Client cntxt, MalBlkPtr default: throw(ILLARG, "calc.sec_interval", "illegal argument"); } + if (scale) + r /= scales[scale]; *ret = r; return MAL_SUCCEED; } diff --git a/sql/backends/monet5/sql_gencode.c b/sql/backends/monet5/sql_gencode.c --- a/sql/backends/monet5/sql_gencode.c +++ b/sql/backends/monet5/sql_gencode.c @@ -1722,7 +1722,7 @@ static int char aggrF[64]; int restype = s->op4.aggrval->res.type->localtype; int complex_aggr = 0; - int abort_on_error; + int abort_on_error, i, *stmt_nr = NULL; if (backend_create_func(sql, s->op4.aggrval->aggr) < 0) return -1; @@ -1751,12 +1751,13 @@ static int q = pushArgument(mb, q, l); l = getDestVar(q); } else { - for (n = s->op1->op4.lval->h; n; n = n->next) { + stmt_nr = SA_NEW_ARRAY(sql->mvc->sa, int, list_length(s->op1->op4.lval)); + for (i=0, n = s->op1->op4.lval->h; n; n = n->next, i++) { stmt *op = n->data; q = newStmt2(mb, algebraRef, selectNotNilRef); q = pushArgument(mb, q, op->nr); - op->nr = getDestVar(q); + stmt_nr[i] = getDestVar(q); } } } @@ -1769,10 +1770,13 @@ static int if (s->op1->type != st_list) { q = pushArgument(mb, q, l); } else { - for (n = s->op1->op4.lval->h; n; n = n->next) { + for (i=0, n = s->op1->op4.lval->h; n; n = n->next, i++) { stmt *op = n->data; - q = pushArgument(mb, q, op->nr); + if (stmt_nr) + q = pushArgument(mb, q, stmt_nr[i]); + else + q = pushArgument(mb, q, op->nr); } } if (g) { @@ -2242,7 +2246,6 @@ backend_callinline(backend *be, Client c curInstr = newAssignment(curBlk); a->varid = varid = getDestVar(curInstr); - renameVariable(curBlk, varid, "A%d", argc); setVarType(curBlk, varid, type); setVarUDFtype(curBlk, varid); diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c --- a/sql/server/rel_schema.c +++ b/sql/server/rel_schema.c @@ -815,6 +815,8 @@ rel_create_table(mvc *sql, sql_schema *s if (temp != SQL_DECLARED_TABLE) { if (temp != SQL_PERSIST && tt == tt_table) { s = mvc_bind_schema(sql, "tmp"); + if (temp == SQL_LOCAL_TEMP && sname && strcmp(sname, s->base.name) != 0) + return sql_error(sql, 02, "3F000!CREATE TABLE: local tempory tables should be stored in the '%s' schema", s->base.name); } else if (s == NULL) { s = ss; } 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 @@ -3301,11 +3301,11 @@ rel_unop(mvc *sql, sql_rel **rel, symbol return _rel_aggr(sql, rel, 0, s, fname, l->next, fs); if (f && type_has_tz(t) && f->func->fix_scale == SCALE_FIX) { - /* set timezone (using msec) */ - sql_subtype *intsec = sql_bind_subtype(sql->sa, "sec_interval", 10 /*hour to second */, 0); - sql_exp *tz = exp_atom_lng(sql->sa, sql->timezone); - - tz = exp_convert(sql->sa, tz, exp_subtype(tz), intsec); + /* set timezone (using msec (.3)) */ + sql_subtype *intsec = sql_bind_subtype(sql->sa, "sec_interval", 10 /*hour to second */, 3); + atom *a = atom_int(sql->sa, intsec, sql->timezone); + sql_exp *tz = exp_atom(sql->sa, a); + e = rel_binop_(sql, e, tz, NULL, "sql_add", ek.card); if (!e) return NULL; diff --git a/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.sql b/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.sql --- a/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.sql +++ b/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.sql @@ -1,1 +1,11 @@ select extract(second from timestamp '2011-3-10 9:30:42.246'); +select extract(minute from timestamp '2011-3-10 9:30:42.246'); +select extract(hour from timestamp '2011-3-10 9:30:42.246'); +select extract(month from timestamp '2011-3-10 9:30:42.246'); +select extract(year from timestamp '2011-3-10 9:30:42.246'); + +select extract(second from timestamp '2011-3-10 9:30:42.246+01:00'); +select extract(minute from timestamp '2011-3-10 9:30:42.246+01:00'); +select extract(hour from timestamp '2011-3-10 9:30:42.246+01:00'); +select extract(month from timestamp '2011-3-10 9:30:42.246+01:00'); +select extract(year from timestamp '2011-3-10 9:30:42.246+01:00'); diff --git a/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.stable.out b/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.stable.out --- a/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.stable.out +++ b/sql/test/BugTracker-2011/Tests/extract_seconds.Bug-2793.stable.out @@ -30,8 +30,62 @@ Ready. % decimal # type % 11 # length [ 42.246 ] +#select extract(minute from timestamp '2011-3-10 9:30:42.246'); +% .L # table_name +% minute_single_value # name +% int # type +% 2 # length +[ 30 ] +#select extract(hour from timestamp '2011-3-10 9:30:42.246'); +% .L # table_name +% hour_single_value # name +% int # type +% 1 # length +[ 9 ] +#select extract(month from timestamp '2011-3-10 9:30:42.246'); +% .L # table_name +% month_single_value # name +% int # type +% 1 # length +[ 3 ] +#select extract(year from timestamp '2011-3-10 9:30:42.246'); +% .L # table_name +% year_single_value # name +% int # type +% 4 # length +[ 2011 ] +#select extract(second from timestamp '2011-3-10 9:30:42.246+01:00'); +% .L # table_name +% second_single_value # name +% decimal # type +% 11 # length +[ 42.246 ] +#select extract(minute from timestamp '2011-3-10 9:30:42.246+01:00'); +% .L # table_name +% minute_single_value # name +% int # type +% 2 # length +[ 30 ] +#select extract(hour from timestamp '2011-3-10 9:30:42.246+01:00'); +% .L # table_name +% hour_single_value # name +% int # type +% 1 # length +[ 8 ] +#select extract(month from timestamp '2011-3-10 9:30:42.246+01:00'); +% .L # table_name +% month_single_value # name +% int # type +% 1 # length +[ 3 ] +#select extract(year from timestamp '2011-3-10 9:30:42.246+01:00'); +% .L # table_name +% year_single_value # name +% int # type +% 4 # length +[ 2011 ] -# 11:57:21 > -# 11:57:21 > Done. -# 11:57:21 > +# 11:23:24 > +# 11:23:24 > "Done." +# 11:23:24 > diff --git a/sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.sql b/sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.sql --- a/sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.sql +++ b/sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.sql @@ -27,13 +27,11 @@ declare tt time; set t = now(); set t = current_timestamp; set t = current_time; +rollback; set tt = now(); set tt = current_time; set tt = current_timestamp; create table d(t timestamp default current_time, i integer); -drop table d; create table d(t time default current_timestamp, i integer); drop table d; - -rollback; diff --git a/sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.err b/sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.err --- a/sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.err +++ b/sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.err @@ -28,6 +28,12 @@ stderr of test 'current_timestamp.Bug-34 # 14:58:53 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-29380" "--port=32929" # 14:58:53 > +MAPI = (monetdb) /var/tmp/mtest-8628/.s.monetdb.30406 +QUERY = set t = current_time; +ERROR = !types timetz(7,0) and timestamp(7,0) are not equal +MAPI = (monetdb) /var/tmp/mtest-8628/.s.monetdb.30406 +QUERY = create table d(t timestamp default current_time, i integer); +ERROR = !types timetz(7,0) and timestamp(7,0) are not equal # 14:58:53 > # 14:58:53 > "Done." _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list