Changeset: 81279396873d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=81279396873d
Added Files:
        sql/test/BugTracker-2014/Tests/sample-crash.Bug-3429.sql
        sql/test/BugTracker-2014/Tests/sample-crash.Bug-3429.stable.err
        sql/test/BugTracker-2014/Tests/sample-crash.Bug-3429.stable.out
Modified Files:
        clients/odbc/driver/ODBCUtil.c
        clients/odbc/driver/SQLGetInfo.c
        gdk/gdk_bat.c
        gdk/gdk_sample.c
        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/All
        sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.sql
        sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.err
Branch: default
Log Message:

Merge with Jan2014 branch.


diffs (truncated from 801 to 300 lines):

diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -335,7 +335,7 @@ static struct scalars {
        {"sin", 1, "\"sin\"(\1)", },
        {"sqrt", 1, "\"sqrt\"(\1)", },
        {"tan", 1, "\"tan\"(\1)", },
-       {"truncate", 2, "\"truncate\"(\1,\2)", },
+       /* {"truncate", 2, "\"truncate\"(\1,\2)", }, */
        {"current_date", 0, "\"current_date\"()", },
        {"current_time", 0, "\"current_time\"()", },
        {"current_time", 1, NULL, },
diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c
--- a/clients/odbc/driver/SQLGetInfo.c
+++ b/clients/odbc/driver/SQLGetInfo.c
@@ -519,7 +519,7 @@ SQLGetInfo_(ODBCDbc *dbc,
                        SQL_FN_NUM_SIGN |
                        SQL_FN_NUM_SIN |
                        SQL_FN_NUM_SQRT |
-                       SQL_FN_NUM_TRUNCATE |
+                       /* SQL_FN_NUM_TRUNCATE | */
                        SQL_FN_NUM_TAN;
                len = sizeof(SQLUINTEGER);
                break;
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -2576,29 +2576,6 @@ BATcheckmodes(BAT *b, int existing)
        return 0;
 }
 
-#define heap_unshare(heap, heapname, id)                               \
-       do {                                                            \
-               if ((heap)->copied) {                                   \
-                       Heap hp;                                        \
-                                                                       \
-                       memset(&hp, 0, sizeof(Heap));                   \
-                       if (HEAPcopy(&hp, (heap)) < 0) {                \
-                               GDKerror("%s: remapped " #heapname      \
-                                        " of %s could not be copied.\n", \
-                                        fcn, BATgetId(b));             \
-                               return -1;                              \
-                                                                       \
-                       }                                               \
-                       hp.parentid = (id);                             \
-                       if ((heap)->parentid == (id))                   \
-                               HEAPfree(heap);                         \
-                       else                                            \
-                               BBPunshare((heap)->parentid);           \
-                       * (heap) = hp;                                  \
-                       (heap)->copied = 0;                             \
-               }                                                       \
-       } while (0)
-
 BAT *
 BATsetaccess(BAT *b, int newmode)
 {
diff --git a/gdk/gdk_sample.c b/gdk/gdk_sample.c
--- a/gdk/gdk_sample.c
+++ b/gdk/gdk_sample.c
@@ -146,7 +146,7 @@ BATsample_(BAT *b, BUN n)
                wrd top = b->hseqbase + cnt - n;
                wrd p = ((wrd) b->hseqbase) - 1;
                oid *o;
-               bn = BATnew(TYPE_void, TYPE_oid, smp);
+               bn = BATnew(TYPE_void, TYPE_oid, n);
                if (bn == NULL) {
                        GDKerror("#BATsample: memory allocation error");
                        return NULL;
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
@@ -3322,12 +3322,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;
@@ -3360,6 +3360,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
@@ -1659,7 +1659,7 @@ static int
                        sql_subtype *res = s->op4.aggrval->res->h->data;
                        int restype = res->type->localtype;
                        int complex_aggr = 0;
-                       int abort_on_error;
+                       int abort_on_error, i, *stmt_nr = NULL;
 
                        if (backend_create_subaggr(sql, s->op4.aggrval) < 0)
                                return -1;
@@ -1688,12 +1688,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);
                                                }
                                        }
                                }
@@ -1706,10 +1707,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) {
@@ -2179,7 +2183,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
@@ -3309,11 +3309,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 >  
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to