Changeset: 513cc2701933 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=513cc2701933
Added Files:
        sql/test/BugTracker-2012/Tests/grant_on_qname.Bug-2958.sql
        sql/test/BugTracker-2012/Tests/grant_on_qname.Bug-2958.stable.err
        sql/test/BugTracker-2012/Tests/grant_on_qname.Bug-2958.stable.out
        sql/test/BugTracker-2012/Tests/mal_syntax_error.Bug-2949.sql
        sql/test/BugTracker-2012/Tests/mal_syntax_error.Bug-2949.stable.err
        sql/test/BugTracker-2012/Tests/mal_syntax_error.Bug-2949.stable.out
        sql/test/BugTracker-2012/Tests/non_keyword_no.Bug-3079.sql
        sql/test/BugTracker-2012/Tests/non_keyword_no.Bug-3079.stable.err
        sql/test/BugTracker-2012/Tests/non_keyword_no.Bug-3079.stable.out
        sql/test/BugTracker-2012/Tests/round-type-inference.Bug-2987.sql
        sql/test/BugTracker-2012/Tests/round-type-inference.Bug-2987.stable.err
        sql/test/BugTracker-2012/Tests/round-type-inference.Bug-2987.stable.out
        
sql/test/BugTracker-2012/Tests/user_defined_decimal_function.Bug-2992.sql
        
sql/test/BugTracker-2012/Tests/user_defined_decimal_function.Bug-2992.stable.err
        
sql/test/BugTracker-2012/Tests/user_defined_decimal_function.Bug-2992.stable.out
Modified Files:
        configure.ag
        gdk/gdk_bbp.mx
        gdk/gdk_posix.c
        monetdb5/modules/atoms/url.mx
        monetdb5/optimizer/opt_multiplex.mx
        sql/common/sql_types.c
        sql/include/sql_catalog.h
        sql/server/rel_select.c
        sql/server/sql_parser.y
        sql/storage/store.c
        sql/test/BugTracker-2012/Tests/All
        sql/test/BugTracker-2012/Tests/sticky-precision.Bug-2969.stable.out
Branch: default
Log Message:

Merge with Apr2012 branch.


diffs (truncated from 853 to 300 lines):

diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2650,6 +2650,7 @@ AC_CHECK_FUNCS([\
                                trunc \
                                uname \
                                ])
+
 LIBS="$save_LIBS"
 save_LIBS="$LIBS"
 LIBS=
diff --git a/gdk/gdk_bbp.mx b/gdk/gdk_bbp.mx
--- a/gdk/gdk_bbp.mx
+++ b/gdk/gdk_bbp.mx
@@ -2860,17 +2860,17 @@ BBPfree(BAT *b, str calledFrom)
 #define BBPSMALLBAT 1000
 
 typedef struct {
-       int lastused;           /* bat lastused stamp; sort on this field */
        bat bid;                /* bat id */
+       int next;               /* next position in list */
        BUN cnt;                /* bat count */
-       int next;               /* next position in list */
-#if SIZEOF_OID == 8
-       size_t dummy;           /* round up */
+#if SIZEOF_BUN == SIZEOF_INT
+       BUN dummy;              /* padding to power-of-two size */
 #endif
 } bbptrim_t;
 
-bbptrim_t bbptrim[BBPMAXTRIM];
-int bbptrimfirst = BBPMAXTRIM, bbptrimlast = 0, bbpunloadtail, bbpunload, 
bbptrimmax = BBPMAXTRIM, bbpscanstart = 1;
+static int lastused[BBPMAXTRIM]; /* bat lastused stamp; sort on this field */
+static bbptrim_t bbptrim[BBPMAXTRIM];
+static int bbptrimfirst = BBPMAXTRIM, bbptrimlast = 0, bbpunloadtail, 
bbpunload, bbptrimmax = BBPMAXTRIM, bbpscanstart = 1;
 
 static bat
 BBPtrim_scan(bat bbppos, bat bbplim)
@@ -2911,7 +2911,7 @@ BBPtrim_scan(bat bbppos, bat bbplim)
                                        /* subtract 2-billion to make
                                         * sure the swap_first class
                                         * bats are unloaded first */
-                                       bbptrim[bbptrimlast].lastused = 
BBPLASTUSED(BBP_lastused(bbppos)) | (swap_first << 31);
+                                       lastused[bbptrimlast] = 
BBPLASTUSED(BBP_lastused(bbppos)) | (swap_first << 31);
                                        bbptrim[bbptrimlast].bid = bbppos;
                                        bbptrim[bbptrimlast].cnt = cnt;
                                        if (++bbptrimlast == bbptrimmax)
@@ -2924,9 +2924,10 @@ BBPtrim_scan(bat bbppos, bat bbplim)
 
        if (bbptrimlast > 0) {
                int i;
-               GDKqsort(bbptrim, NULL, NULL, bbptrimlast, sizeof(bbptrim_t), 
0, TYPE_int);
+               GDKqsort(lastused, bbptrim, NULL, bbptrimlast,
+                        sizeof(lastused[0]), sizeof(bbptrim[0]), TYPE_int);
                for (i = bbptrimfirst = 0; i < bbptrimlast; i++) {
-                       MEMDEBUG THRprintf(GDKstdout, "#TRIMSCAN: %11d%c 
%9d=%s\t(#" BUNFMT ")\n", BBPLASTUSED(bbptrim[i].lastused), 
(bbptrim[i].lastused & 0x80000000) ? '*' : ' ', i, BBPname(bbptrim[i].bid), 
bbptrim[i].cnt);
+                       MEMDEBUG THRprintf(GDKstdout, "#TRIMSCAN: %11d%c 
%9d=%s\t(#" BUNFMT ")\n", BBPLASTUSED(lastused[i]), (lastused[i] & 0x80000000) 
? '*' : ' ', i, BBPname(bbptrim[i].bid), bbptrim[i].cnt);
 
                        bbptrim[i].next = i + 1;
                }
@@ -2955,7 +2956,7 @@ BBPtrim_select(size_t target, int dirty)
 
        while (next != BBPMAXTRIM) {
                int cur = next; /* cur is the entry in the old bbptrimlist we 
are processing */
-               int untouched = BBPLASTUSED(BBP_lastused(bbptrim[cur].bid)) <= 
BBPLASTUSED(bbptrim[cur].lastused);
+               int untouched = BBPLASTUSED(BBP_lastused(bbptrim[cur].bid)) <= 
BBPLASTUSED(lastused[cur]);
                BAT *b = BBP_cache(bbptrim[cur].bid);
 
                next = bbptrim[cur].next;       /* do now, because we overwrite 
bbptrim[cur].next below */
@@ -2975,8 +2976,8 @@ BBPtrim_select(size_t target, int dirty)
                                  VIEWhparent(b),
                                  VIEWtparent(b),
                                  BBP_lastused(b->batCacheid),
-                                 BBPLASTUSED(bbptrim[cur].lastused),
-                                 bbptrim[cur].lastused);
+                                 BBPLASTUSED(lastused[cur]),
+                                 lastused[cur]);
                }
                /* recheck if conditions encountered by trimscan in
                 * the past still hold */
@@ -3163,7 +3164,7 @@ BBPtrim(size_t target)
                                continue;
                        }
                        MEMDEBUG THRprintf(GDKstdout, "#BBPTRIM: %9d %7d %s\n",
-                                          bbptrim[i].lastused,
+                                          lastused[i],
                                           (int) bbptrim[i].bid,
                                           BBPname(bbptrim[i].bid));
 
@@ -3220,7 +3221,7 @@ BBPcold(bat i)
                /* make very cold and insert on top of trim list */
                BBP_lastused(i) = 0;
                if (BBP_cache(i) && bbptrimlast < bbptrimmax) {
-                       bbptrim[--bbptrimmax].lastused = 0;
+                       lastused[--bbptrimmax] = 0;
                        bbptrim[bbptrimmax].bid = i;
                        bbptrim[bbptrimmax].next = bbptrimfirst;
                        bbptrimfirst = bbptrimmax;
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -763,15 +763,10 @@ MT_getrss(void)
 {
 #if defined(HAVE_PROCFS_H) && defined(__sun__)
        /* retrieve RSS the Solaris way (2.6+) */
-       static char MT_mmap_procfile[128] = { 0 };
        int fd;
        psinfo_t psbuff;
 
-       if (MT_mmap_procfile[0] == 0) {
-               /* getpid returns pid_t, cast to long to be sure */
-               sprintf(MT_mmap_procfile, "/proc/%ld/psinfo", (long) getpid());
-       }
-       fd = open(MT_mmap_procfile, O_RDONLY);
+       fd = open("/proc/self/psinfo", O_RDONLY);
        if (fd >= 0) {
                if (read(fd, &psbuff, sizeof(psbuff)) == sizeof(psbuff)) {
                        close(fd);
@@ -811,14 +806,9 @@ MT_getrss(void)
        return rss * MT_pagesize();
 #else
        /* get RSS on Linux */
-       static char MT_mmap_procfile[128] = { 0 };
        int fd;
 
-       if (MT_mmap_procfile[0] == 0) {
-               /* getpid returns pid_t, cast to long to be sure */
-               sprintf(MT_mmap_procfile, "/proc/%ld/stat", (long) getpid());
-       }
-       fd = open(MT_mmap_procfile, O_RDONLY);
+       fd = open("/proc/self/stat", O_RDONLY);
        if (fd >= 0) {
                char buf[1024], *r = buf;
                size_t i, sz = read(fd, buf, 1024);
diff --git a/monetdb5/modules/atoms/url.mx b/monetdb5/modules/atoms/url.mx
--- a/monetdb5/modules/atoms/url.mx
+++ b/monetdb5/modules/atoms/url.mx
@@ -1158,11 +1158,11 @@ URLnew4(str *url, str *protocol, str *se
        str File = *file;
        int l, i;
 
-       if (GDK_STRNIL(file))
+       if (GDK_STRNIL(File))
                File = "";
-       if (GDK_STRNIL(server))
+       if (GDK_STRNIL(Server))
                Server = "";
-       if (GDK_STRNIL(protocol))
+       if (GDK_STRNIL(Protocol))
                Protocol = "";
        l = (int) (strlen(File) + strlen(Server) + strlen(Protocol) + 20);
        *url = (str) GDKmalloc(l);
diff --git a/monetdb5/optimizer/opt_multiplex.mx 
b/monetdb5/optimizer/opt_multiplex.mx
--- a/monetdb5/optimizer/opt_multiplex.mx
+++ b/monetdb5/optimizer/opt_multiplex.mx
@@ -139,8 +139,7 @@ OPTexpandMultiplex(Client cntxt, MalBlkP
        fcn = VALget(&getVar(mb, getArg(pci, 2))->value);
        fcn = putName(fcn,strlen(fcn));
 
-       /* search the iterator bat after type checking first */
-       chkProgram(cntxt->fdout, cntxt->nspace,mb);
+       /* search the iterator bat */
        for (i = 3; i < pci->argc; i++)
                if (isaBatType(getArgType(mb, pci, i))) {
                        iter = getArg(pci, i);
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -702,6 +702,28 @@ sql_bind_member(sql_allocator *sa, sql_s
                        }
                }
        }
+       if (tp->type->eclass == EC_NUM) {
+               /* add second round but now look for Decimals only */
+               for (n = funcs->h; n; n = n->next) {
+                       sql_func *f = n->data;
+
+                       if (!f->res.type)
+                               continue;
+                       if (strcmp(f->base.name, sqlfname) == 0 && 
list_length(f->ops) == nrargs) {
+                               if (((sql_arg *) 
f->ops->h->data)->type.type->eclass == EC_DEC && 
+                                   ((sql_arg *) 
f->ops->h->data)->type.type->localtype == tp->type->localtype) {
+
+                                       unsigned int scale = 0, digits;
+                                       sql_subfunc *fres = SA_ZNEW(sa, 
sql_subfunc);
+
+                                       fres->func = f;
+                                       digits = f->res.digits;
+                                       sql_init_subtype(&fres->res, 
f->res.type, digits, scale);
+                                       return fres;
+                               }
+                       }
+               }
+       }
        return NULL;
 }
 
@@ -757,7 +779,7 @@ sql_bind_func_(sql_allocator *sa, sql_sc
                                if (IS_FUNC(f)) { /* not needed for PROC/FILT */
                                        /* fix the scale */
                                        digits = f->res.digits;
-                                       if (f->fix_scale > SCALE_NONE) {
+                                       if (f->fix_scale > SCALE_NONE && 
f->fix_scale < SCALE_EQ) {
                                                for (n = ops->h; n; n = 
n->next) {
                                                        sql_subtype *a = 
n->data;
 
@@ -804,7 +826,7 @@ sql_bind_func_(sql_allocator *sa, sql_sc
                                        sql_subfunc *fres = SA_ZNEW(sa, 
sql_subfunc);
 
                                        fres->func = f;
-                                       if (f->fix_scale > SCALE_NONE) {
+                                       if (f->fix_scale > SCALE_NONE && 
f->fix_scale < SCALE_EQ) {
                                                for (n = ops->h; n; n = 
n->next) {
                                                        sql_subtype *a = 
n->data;
 
diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -85,6 +85,7 @@
 #define SCALE_DIV      4       /* div on the other hand reduces the scales */ 
 #define DIGITS_ADD     5       /* some types grow under functions (concat) */
 #define INOUT          6       /* output type equals input type */
+#define SCALE_EQ       7       /* user defined functions need equal scales */
 
 #define TR_OLD 0
 #define TR_NEW 1
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
@@ -1949,8 +1949,7 @@ static sql_exp *
 exp_sum_scales(mvc *sql, sql_subfunc *f, sql_exp *l, sql_exp *r)
 {
        if (strcmp(f->func->imp, "*") == 0 &&
-                       f->func->res.type->scale == SCALE_FIX)
-       {
+                       f->func->res.type->scale == SCALE_FIX) {
                sql_subtype t;
                sql_subtype *lt = exp_subtype(l);
                sql_subtype *rt = exp_subtype(r);
@@ -3434,6 +3433,13 @@ rel_binop_(mvc *sql, sql_exp *l, sql_exp
                if (f->func->fix_scale == SCALE_FIX) {
                        l = exp_fix_scale(sql, t2, l, 0, 0);
                        r = exp_fix_scale(sql, t1, r, 0, 0);
+               } else if (f->func->fix_scale == SCALE_EQ) {
+                       sql_arg *a1 = f->func->ops->h->data;
+                       sql_arg *a2 = f->func->ops->h->next->data;
+                       t1 = &a1->type;
+                       t2 = &a2->type;
+                       l = exp_fix_scale(sql, t1, l, 0, 0);
+                       r = exp_fix_scale(sql, t2, r, 0, 0);
                } else if (f->func->fix_scale == SCALE_DIV) {
                        l = exp_scale_algebra(sql, f, l, r);
                } else if (f->func->fix_scale == SCALE_MUL) {
@@ -3480,6 +3486,13 @@ rel_binop_(mvc *sql, sql_exp *l, sql_exp
                                if (f->func->fix_scale == SCALE_FIX) {
                                        l = exp_fix_scale(sql, t2, l, 0, 0);
                                        r = exp_fix_scale(sql, t1, r, 0, 0);
+                               } else if (f->func->fix_scale == SCALE_EQ) {
+                                       sql_arg *a1 = f->func->ops->h->data;
+                                       sql_arg *a2 = 
f->func->ops->h->next->data;
+                                       t1 = &a1->type;
+                                       t2 = &a2->type;
+                                       l = exp_fix_scale(sql, t1, l, 0, 0);
+                                       r = exp_fix_scale(sql, t2, r, 0, 0);
                                } else if (f->func->fix_scale == SCALE_DIV) {
                                        l = exp_scale_algebra(sql, f, l, r);
                                } else if (f->func->fix_scale == SCALE_MUL) {
@@ -3542,8 +3555,6 @@ rel_binop_(mvc *sql, sql_exp *l, sql_exp
        return res;
 }
 
-#define SQLMAXDEPTH ((THREAD_STACK_SIZE/4096))
-
 static sql_exp *
 rel_binop(mvc *sql, sql_rel **rel, symbol *se, int f, exp_kind ek)
 {
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
@@ -4673,7 +4673,7 @@ ident:
  |  non_reserved_word
  ;
 
-non_reserved_word:  /* (lexicographically sorted for convenience) */
+non_reserved_word: 
   LARGE                { $$ = sa_strdup(SA, "large"); }        /* sloppy: 
officially reserved */
 | sqlNAME      { $$ = sa_strdup(SA, "name"); }
 | OBJECT       { $$ = sa_strdup(SA, "object"); }       /* sloppy: officially 
reserved */
@@ -4711,6 +4711,7 @@ non_reserved_word:  /* (lexicographicall
 |  SQL_TRACE   { $$ = sa_strdup(SA, "trace"); }
 |  sqlTEXT             { $$ = sa_strdup(SA, "text"); }
 |  AUTO_COMMIT { $$ = sa_strdup(SA, "auto_commit"); }
+|  NO          { $$ = sa_strdup(SA, "no"); }
 /* SQL/XML non reserved words */
 |  STRIP       { $$ = sa_strdup(SA, "strip"); }
 |  WHITESPACE  { $$ = sa_strdup(SA, "whitespace"); }
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -729,6 +729,7 @@ load_func(sql_trans *tr, sql_schema *s, 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to