Changeset: 34184b3fa046 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=34184b3fa046
Modified Files:
        clients/python/monetdb/sql/cursors.py
        configure.ag
        gdk/gdk.h
        gdk/gdk_select.c
        monetdb5/mal/mal_debugger.c
        monetdb5/modules/kernel/algebra.mx
        monetdb5/modules/mal/language.c
        tools/mserver/Makefile.ag
        tools/mserver/mserver5.c
Branch: xid
Log Message:

merge from default branch


diffs (truncated from 491 to 300 lines):

diff --git a/clients/python/monetdb/sql/cursors.py 
b/clients/python/monetdb/sql/cursors.py
--- a/clients/python/monetdb/sql/cursors.py
+++ b/clients/python/monetdb/sql/cursors.py
@@ -158,6 +158,9 @@ class Cursor(object):
         # clear message history
         self.messages = []
 
+        # convert to utf-8
+        operation = unicode(operation).encode('utf-8')
+
         # set the number of rows to fetch
         self.connection.command('Xreply_size %s' % self.arraysize)
 
@@ -172,12 +175,8 @@ class Cursor(object):
             if isinstance(parameters, dict):
                 query = operation % dict([(k, monetize.convert(v))
                     for (k,v) in parameters.items()])
-            elif type(parameters) == list:
-                query = operation % tuple([monetize.convert(item)
-                    for item in parameters])
-            elif type(parameters) == tuple:
-                query = operation % tuple([monetize.convert(item)
-                    for item in parameters])
+            elif type(parameters) == list or type(parameters) == tuple:
+                query = operation % tuple([monetize.convert(item) for item in 
parameters])
             elif isinstance(parameters, str):
                 query = operation % monetize.convert(parameters)
             else:
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -1641,28 +1641,30 @@ if test "x$have_pthread" != xno; then
        esac
        CPPFLAGS="$save_CPPFLAGS"
 
-       case $GCC in
-               yes)
+       save_LIBS="$LIBS"
+       save_CPPFLAGS="$CPPFLAGS"
+       case $GCC-$have_pthread in
+               yes-auto|yes-yes)
                        # use GCC's knowledge about the target platform, sets 
flags
                        # for both the preprocessor as well as the linker
-                       PTHREAD_INCS="$PTHREAD_INCS -pthread"
-                       PTHREAD_LIBS="$PTHREAD_LIBS -pthread"
-                       CPPFLAGS="$CPPFLAGS -pthread"
-                       LIBS="$LIBS -pthread"
+                       PTHREAD_INCS="-pthread"
+                       PTHREAD_LIBS="-pthread"
+                       CPPFLAGS="$CPPFLAGS $PTHREAD_INCS"
+                       LIBS="$LIBS $PTHREAD_LIBS"
                ;;
                *)
-                       save_LIBS="$LIBS"
                        # ok, do old-fashioned stuff
-                       LIBS="$LIBS $PTHREAD_LIBS" # in case user did 
--with-pthreads
+                       CPPFLAGS="$CPPFLAGS $PTHREAD_INCS" # in case user did 
--with-pthreads
+                       LIBS="$LIBS $PTHREAD_LIBS"
                        pthread_found=yes
                        AC_SEARCH_LIBS([sem_init], [pthreadGC2 pthreadGC1 
pthreadGC pthread],
-                               [PTHREAD_LIBS="$PTHREAD_LIBS 
$ac_cv_search_sem_init"],
+                               [LIBS="$LIBS $ac_cv_search_sem_init"],
                                [pthread_found=no])
                        if test x"$pthread_found" = xno ; then
                                pthread_found=yes
                                dnl sun
                                AC_SEARCH_LIBS([sem_post], [pthread],
-                                       [PTHREAD_LIBS="$PTHREAD_LIBS -lpthread 
-lposix4"],
+                                       [LIBS="$LIBS -lpthread -lposix4"],
                                        [pthread_found=no],
                                        "-lposix4")
                        fi
@@ -1670,7 +1672,7 @@ if test "x$have_pthread" != xno; then
                                pthread_found=yes
                                dnl hp-ux
                                AC_SEARCH_LIBS([sem_post], [pthread],
-                                       [PTHREAD_LIBS="$PTHREAD_LIBS -lpthread 
-lrt"],
+                                       [LIBS="$LIBS -lpthread -lrt"],
                                        [pthread_found=no],
                                        "-lrt")
                        fi
@@ -1680,7 +1682,7 @@ if test "x$have_pthread" != xno; then
                                fi
                                have_pthread=no
                        fi
-                       LIBS="$save_LIBS"
+                       PTHREAD_LIBS="$LIBS"
                ;;
        esac
 
@@ -1699,11 +1701,9 @@ if test "x$have_pthread" != xno; then
        dnl this function very ugly is overloaded with semaphore stuff
        dnl so we DO need to check for it, for platforms which have it
        dnl in a separate lib, like Solaris
-       oldLIBS="$LIBS"
-       LIBS="$PTHREAD_LIBS"
        AC_SEARCH_LIBS(sem_wait, rt)
-       PTHREAD_LIBS="$LIBS"
-       LIBS="$oldLIBS"
+
+       LIBS="$save_LIBS"
        CPPFLAGS="$save_CPPFLAGS"
 
 fi
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -3143,6 +3143,7 @@ gdk_export int BATtopN(BAT *b, BUN topN)
 #define JOIN_BAND      3
 
 gdk_export BAT *BATsubselect(BAT *b, BAT *s, const void *tl, const void *th, 
int li, int hi, int anti);
+gdk_export BAT *BATthetasubselect(BAT *b, BAT *s, const void *val, const char 
*op);
 gdk_export BAT *BATselect_(BAT *b, const void *tl, const void *th, bit li, bit 
hi);
 gdk_export BAT *BATuselect_(BAT *b, const void *tl, const void *th, bit li, 
bit hi);
 gdk_export BAT *BATantiuselect_(BAT *b, const void *tl, const void *th, bit 
li, bit hi);
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -161,18 +161,13 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, 
                            "#BATsubselect(b=%s#"BUNFMT",s=%s,anti=%d): " \
                            "scanselect %s\n", BATgetId(b), BATcount(b), \
                            s ? BATgetId(s) : "NULL", anti, #TEST);     \
-               BATloop(s, p, q) {                                      \
-                       o = * (oid *) BUNtloc(si, p);                   \
-                       if (o == oid_nil ||                             \
-                           o < seqbase ||                              \
-                           o - seqbase >= b->U->count) {               \
-                               /* XXX return an error? */              \
-                               continue;                               \
-                       }                                               \
-                       p = (BUN) (o - off);                            \
-                       v = BUNtail(bi, p);                             \
+               while (p < q) {                                         \
+                       o = *candlist++;                                \
+                       r = (BUN) (o - off);                            \
+                       v = BUNtail(bi, r);                             \
                        if (TEST)                                       \
                                bunfastins(bn, NULL, &o);               \
+                       p++;                                            \
                }                                                       \
        } while (0)
 
@@ -199,7 +194,7 @@ BAT_scanselect(BAT *b, BAT *s, BAT *bn, 
        BATiter bi = bat_iterator(b);
        int (*cmp)(const void *, const void *);
        BUN p, q;
-       oid o, seqbase, off;
+       oid o, off;
        const void *nil, *v;
        int c;
 
@@ -216,14 +211,22 @@ BAT_scanselect(BAT *b, BAT *s, BAT *bn, 
        assert(!lval || !hval || (*cmp)(tl, th) <= 0);
 
        nil = b->T->nonil ? NULL : ATOMnilptr(b->ttype);
-       seqbase = b->hseqbase;
-       off = seqbase - BUNfirst(b);
+       off = b->hseqbase - BUNfirst(b);
 
        if (s) {
-               BATiter si = bat_iterator(s);
+               const oid *candlist;
+               BUN r;
 
                assert(s->tsorted);
                assert(s->tkey);
+               /* setup candscanloop loop vars to only iterate over
+                * part of s that has values that are in range of b */
+               o = b->hseqbase + BATcount(b);
+               q = SORTfndfirst(s, &o);
+               p = SORTfndfirst(s, &b->hseqbase);
+               /* should we return an error if p > BUNfirst(s) || q <
+                * BUNlast(s) (i.e. s not fully used)? */
+               candlist = (const oid *) Tloc(s, p);
                if (equi) {
                        assert(li && hi);
                        assert(!anti);
@@ -324,7 +327,6 @@ BATsubselect(BAT *b, BAT *s, const void 
 {
        int hval, lval, equi, t, lnil;
        const void *nil;
-       BAT *orig_s = s;
        BAT *bn;
        BUN estimate;
 
@@ -433,10 +435,7 @@ BATsubselect(BAT *b, BAT *s, const void 
                 * any: i.e. return everything */
                ALGODEBUG fprintf(stderr, 
"#BATsubselect(b=%s#"BUNFMT",s=%s,anti=%d): everything, nonil\n", BATgetId(b), 
BATcount(b), s ? BATgetId(s) : "NULL", anti);
                if (s) {
-                       if (s == orig_s)
-                               return BATcopy(s, TYPE_void, s->ttype, 0);
-                       else
-                               return s; /* already made a copy: return it */
+                       return BATcopy(s, TYPE_void, s->ttype, 0);
                } else {
                        return BATmirror(BATmark(b, 0));
                }
@@ -526,8 +525,6 @@ BATsubselect(BAT *b, BAT *s, const void 
                                o = (oid) high;
                                high = SORTfndfirst(s, &o);
                                v = VIEWhead(BATmirror(s));
-                               if (s != orig_s)
-                                       BBPunfix(s->batCacheid);
                        } else {
                                v = VIEWhead(b); /* [oid,nil] */
                        }
@@ -540,8 +537,6 @@ BATsubselect(BAT *b, BAT *s, const void 
                                o = (oid) high;
                                high = SORTfndfirst(s, &o);
                                v = VIEWhead(BATmirror(s));
-                               if (s != orig_s)
-                                       BBPunfix(s->batCacheid);
                        } else {
                                v = VIEWhead(b); /* [oid,nil] */
                        }
@@ -584,11 +579,8 @@ BATsubselect(BAT *b, BAT *s, const void 
        }
 
        bn = BATnew(TYPE_void, TYPE_oid, estimate);
-       if (bn == NULL) {
-               if (s && s != orig_s)
-                       BBPreclaim(s);
+       if (bn == NULL)
                return NULL;
-       }
 
        if (equi &&
            (b->T->hash ||
@@ -602,9 +594,6 @@ BATsubselect(BAT *b, BAT *s, const void 
                bn = BAT_scanselect(b, s, bn, tl, th, li, hi, equi, anti, lval, 
hval);
        }
 
-       if (bn == NULL && s && s != orig_s)
-               BBPreclaim(s);
-
        return bn;
 }
 
@@ -730,3 +719,41 @@ BATuselect(BAT *b, const void *h, const 
 {
        return BATuselect_(b, h, t, TRUE, TRUE);
 }
+
+BAT *
+BATthetasubselect(BAT *b, BAT *s, const void *val, const char *op)
+{
+       const void *nil;
+
+       BATcheck(b, "BATthetasubselect");
+       BATcheck(val, "BATthetasubselect");
+       BATcheck(op, "BATthetasubselect");
+
+       if (op[0] == '=' && ((op[1] == '=' && op[2] == 0) || op[2] == 0)) {
+               /* "=" or "==" */
+               return BATsubselect(b, s, val, NULL, 1, 1, 0);
+       }
+       nil = ATOMnilptr(b->ttype);
+       if (op[0] == '<') {
+               if (op[1] == 0) {
+                       /* "<" */
+                       return BATsubselect(b, s, nil, val, 0, 0, 0);
+               }
+               if (op[1] == '=' && op[2] == 0) {
+                       /* "<=" */
+                       return BATsubselect(b, s, nil, val, 0, 1, 0);
+               }
+       }
+       if (op[0] == '>') {
+               if (op[1] == 0) {
+                       /* ">" */
+                       return BATsubselect(b, s, val, nil, 0, 0, 0);
+               }
+               if (op[1] == '=' && op[2] == 0) {
+                       /* ">=" */
+                       return BATsubselect(b, s, val, nil, 1, 0, 0);
+               }
+       }
+       GDKerror("BATthetasubselect: unknown operator.\n");
+       return NULL;
+}
diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -1455,19 +1455,24 @@ printStackElm(stream *f, MalBlkPtr mb, V
 void
 printBatDetails(stream *f, int bid)
 {
-       BAT *b;
-       int ret;
+       BAT *b[2];
+       int ret,ret2;
        MALfcn fcn;
 
+       /* at this level we don't know bat kernel primitives */
        mnstr_printf(f, "#Show info for %d\n", bid);
        fcn = getAddress(f, "bat", "bat", "BKCinfo", 0);
        if (fcn) {
-               (*fcn)(&ret, &bid);
-               b = BATdescriptor(ret);
-               if (b == NULL)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to