Changeset: d9d7507d0a5f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d9d7507d0a5f
Added Files:
        sql/test/BugTracker-2017/Tests/nested_with.Bug-6187.sql
        sql/test/BugTracker-2017/Tests/nested_with.Bug-6187.stable.err
        sql/test/BugTracker-2017/Tests/nested_with.Bug-6187.stable.out
        sql/test/BugTracker-2017/Tests/prepare.Bug-6133.sql
        sql/test/BugTracker-2017/Tests/prepare.Bug-6133.stable.err
        sql/test/BugTracker-2017/Tests/prepare.Bug-6133.stable.out
        sql/test/BugTracker-2017/Tests/sqlsmith01.stable.err
        sql/test/BugTracker-2017/Tests/sqlsmith02.stable.err
        sql/test/BugTracker-2017/Tests/sqlsmith03.stable.err
        sql/test/BugTracker-2017/Tests/sqlsmith04.stable.err
Modified Files:
        gdk/gdk.h
        gdk/gdk_batop.c
        gdk/gdk_join.c
        gdk/gdk_orderidx.c
        gdk/gdk_private.h
        gdk/gdk_search.c
        gdk/gdk_select.c
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_runtime.c
        monetdb5/modules/mal/orderidx.c
        sql/server/sql_parser.y
        sql/storage/bat/bat_storage.c
        sql/test/BugTracker-2016/Tests/All
        sql/test/BugTracker-2017/Tests/All
        sql/test/BugTracker-2017/Tests/sqlsmith01.stable.out
        sql/test/BugTracker-2017/Tests/sqlsmith04.stable.out
        sql/test/emptydb/updatetests
        sql/test/lateral/Tests/lateral.sql
Branch: queryid2
Log Message:

merge with default. PAAAANOS :)


diffs (truncated from 2109 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -587,8 +587,6 @@ typedef size_t BUN;
 #else
 #define BUN_NONE ((BUN) LLONG_MAX)
 #endif
-#define BUN_MSK (~BUN_NONE)
-#define BUN_UNMSK BUN_NONE
 #define BUN_MAX (BUN_NONE - 1) /* maximum allowed size of a BAT */
 
 #define BUN2 2
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1729,6 +1729,8 @@ BATcount_no_nil(BAT *b)
        return cnt;
 }
 
+/* create a new, dense candidate list with values from `first' up to,
+ * but not including, `last' */
 static BAT *
 newdensecand(oid first, oid last)
 {
@@ -1738,7 +1740,7 @@ newdensecand(oid first, oid last)
                return NULL;
        if (last < first)
                first = last = 0; /* empty range */
-       BATsetcount(bn, last - first + 1);
+       BATsetcount(bn, last - first);
        BATtseqbase(bn, first);
        return bn;
 }
@@ -1790,19 +1792,19 @@ BATmergecand(BAT *a, BAT *b)
                if (af <= bf && bf <= al + 1) {
                        /* partial overlap starting with a, or b is
                         * smack bang after a */
-                       return newdensecand(af, al < bl ? bl : al);
+                       return newdensecand(af, al < bl ? bl + 1 : al + 1);
                }
                if (bf <= af && af <= bl + 1) {
                        /* partial overlap starting with b, or a is
                         * smack bang after b */
-                       return newdensecand(bf, al < bl ? bl : al);
+                       return newdensecand(bf, al < bl ? bl + 1 : al + 1);
                }
        }
        if (ad && af <= bf && al >= bl) {
-               return newdensecand(af, al);
+               return newdensecand(af, al + 1);
        }
        if (bd && bf <= af && bl >= al) {
-               return newdensecand(bf, bl);
+               return newdensecand(bf, bl + 1);
        }
 
        bn = COLnew(0, TYPE_oid, BATcount(a) + BATcount(b), TRANSIENT);
@@ -1912,7 +1914,7 @@ BATintersectcand(BAT *a, BAT *b)
 
        if ((af + BATcount(a) - 1 == al) && (bf + BATcount(b) - 1 == bl)) {
                /* both lists are VOID */
-               return newdensecand(MAX(af, bf), MIN(al, bl));
+               return newdensecand(MAX(af, bf), MIN(al, bl) + 1);
        }
 
        bn = COLnew(0, TYPE_oid, MIN(BATcount(a), BATcount(b)), TRANSIENT);
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -182,251 +182,6 @@ joininitresults(BAT **r1p, BAT **r2p, BU
                         s##vals + ((x) * s##width))
 #define FVALUE(s, x)   (s##vals + ((x) * s##width))
 
-#define BINSEARCHFUNC(TYPE)                                            \
-static inline BUN                                                      \
-binsearch_##TYPE(const oid *rcand, oid offset, const TYPE *rvals,      \
-                BUN lo, BUN hi, TYPE v, int ordering, int last)        \
-{                                                                      \
-       BUN mid;                                                        \
-       TYPE x;                                                         \
-                                                                       \
-       assert(ordering == 1 || ordering == -1);                        \
-       assert(lo <= hi);                                               \
-                                                                       \
-       if (ordering > 0) {                                             \
-               if (rcand) {                                            \
-                       if (last) {                                     \
-                               if ((x = rvals[rcand[lo] - offset]) > v) \
-                                       return lo;                      \
-                               if ((x = rvals[rcand[hi] - offset]) < v || \
-                                   x == v)                             \
-                                       return hi + 1;                  \
-                                                                       \
-                               /* loop invariant: */                   \
-                               /* value@lo <= v < value@hi */          \
-                               while (hi - lo > 1) {                   \
-                                       mid = (hi + lo) / 2;            \
-                                       if (rvals[rcand[mid] - offset] > v) \
-                                               hi = mid;               \
-                                       else                            \
-                                               lo = mid;               \
-                               }                                       \
-                       } else {                                        \
-                               if ((x = rvals[rcand[lo] - offset]) > v || \
-                                   x == v)                             \
-                                       return lo;                      \
-                               if ((x = rvals[rcand[hi] - offset]) < v) \
-                                       return hi + 1;                  \
-                                                                       \
-                               /* loop invariant: */                   \
-                               /* value@lo < v <= value@hi */          \
-                               while (hi - lo > 1) {                   \
-                                       mid = (hi + lo) / 2;            \
-                                       if (rvals[rcand[mid] - offset] >= v) \
-                                               hi = mid;               \
-                                       else                            \
-                                               lo = mid;               \
-                               }                                       \
-                       }                                               \
-               } else {                                                \
-                       if (last) {                                     \
-                               if ((x = rvals[lo]) > v)                \
-                                       return lo;                      \
-                               if ((x = rvals[hi]) < v || x == v)      \
-                                       return hi + 1;                  \
-                                                                       \
-                               /* loop invariant: */                   \
-                               /* value@lo <= v < value@hi */          \
-                               while (hi - lo > 1) {                   \
-                                       mid = (hi + lo) / 2;            \
-                                       if (rvals[mid] > v)             \
-                                               hi = mid;               \
-                                       else                            \
-                                               lo = mid;               \
-                               }                                       \
-                       } else {                                        \
-                               if ((x = rvals[lo]) > v || x == v)      \
-                                       return lo;                      \
-                               if ((x = rvals[hi]) < v)                \
-                                       return hi + 1;                  \
-                                                                       \
-                               /* loop invariant: */                   \
-                               /* value@lo < v <= value@hi */          \
-                               while (hi - lo > 1) {                   \
-                                       mid = (hi + lo) / 2;            \
-                                       if (rvals[mid] >= v)            \
-                                               hi = mid;               \
-                                       else                            \
-                                               lo = mid;               \
-                               }                                       \
-                       }                                               \
-               }                                                       \
-       } else {                                                        \
-               if (rcand) {                                            \
-                       if (last) {                                     \
-                               if ((x = rvals[rcand[lo] - offset]) < v) \
-                                       return lo;                      \
-                               if ((x = rvals[rcand[hi] - offset]) > v || \
-                                   x == v)                             \
-                                       return hi + 1;                  \
-                                                                       \
-                               /* loop invariant: */                   \
-                               /* value@lo >= v > value@hi */          \
-                               while (hi - lo > 1) {                   \
-                                       mid = (hi + lo) / 2;            \
-                                       if (rvals[rcand[mid] - offset] < v) \
-                                               hi = mid;               \
-                                       else                            \
-                                               lo = mid;               \
-                               }                                       \
-                       } else {                                        \
-                               if ((x = rvals[rcand[lo] - offset]) < v || \
-                                   x == v)                             \
-                                       return lo;                      \
-                               if ((x = rvals[rcand[hi] - offset]) > v) \
-                                       return hi + 1;                  \
-                                                                       \
-                               /* loop invariant: */                   \
-                               /* value@lo > v >= value@hi */          \
-                               while (hi - lo > 1) {                   \
-                                       mid = (hi + lo) / 2;            \
-                                       if (rvals[rcand[mid] - offset] <= v) \
-                                               hi = mid;               \
-                                       else                            \
-                                               lo = mid;               \
-                               }                                       \
-                       }                                               \
-               } else {                                                \
-                       if (last) {                                     \
-                               if ((x = rvals[lo]) < v)                \
-                                       return lo;                      \
-                               if ((x = rvals[hi]) > v || x == v)      \
-                                       return hi + 1;                  \
-                                                                       \
-                               /* loop invariant: */                   \
-                               /* value@lo >= v > value@hi */          \
-                               while (hi - lo > 1) {                   \
-                                       mid = (hi + lo) / 2;            \
-                                       if (rvals[mid] < v)             \
-                                               hi = mid;               \
-                                       else                            \
-                                               lo = mid;               \
-                               }                                       \
-                       } else {                                        \
-                               if ((x = rvals[lo]) < v || x == v)      \
-                                       return lo;                      \
-                               if ((x = rvals[hi]) > v)                \
-                                       return hi + 1;                  \
-                                                                       \
-                               /* loop invariant: */                   \
-                               /* value@lo > v >= value@hi */          \
-                               while (hi - lo > 1) {                   \
-                                       mid = (hi + lo) / 2;            \
-                                       if (rvals[mid] <= v)            \
-                                               hi = mid;               \
-                                       else                            \
-                                               lo = mid;               \
-                               }                                       \
-                       }                                               \
-               }                                                       \
-       }                                                               \
-       return hi;                                                      \
-}
-
-BINSEARCHFUNC(bte)
-BINSEARCHFUNC(sht)
-BINSEARCHFUNC(int)
-BINSEARCHFUNC(lng)
-#ifdef HAVE_HGE
-BINSEARCHFUNC(hge)
-#endif
-BINSEARCHFUNC(flt)
-BINSEARCHFUNC(dbl)
-#if SIZEOF_OID == SIZEOF_INT
-#define binsearch_oid(rcand, offset, rvals, lo, hi, v, ordering, last) 
binsearch_int(rcand, offset, (const int *) rvals, lo, hi, (int) (v), ordering, 
last)
-#endif
-#if SIZEOF_OID == SIZEOF_LNG
-#define binsearch_oid(rcand, offset, rvals, lo, hi, v, ordering, last) 
binsearch_lng(rcand, offset, (const lng *) rvals, lo, hi, (lng) (v), ordering, 
last)
-#endif
-
-/* Do a binary search for the first/last occurrence of v between lo and hi
- * (lo inclusive, hi not inclusive) in rvals/rvars.
- * If last is set, return the index of the first value > v; if last is
- * not set, return the index of the first value >= v.
- * If ordering is -1, the values are sorted in reverse order and hence
- * all comparisons are reversed.
- */
-static BUN
-binsearch(const oid *rcand, oid offset,
-         int type, const char *rvals, const char *rvars,
-         int rwidth, BUN lo, BUN hi, const char *v,
-         int (*cmp)(const void *, const void *), int ordering, int last)
-{
-       BUN mid;
-       int c;
-
-       assert(ordering == 1 || ordering == -1);
-       assert(lo < hi);
-
-       --hi;                   /* now hi is inclusive */
-
-       switch (type) {
-       case TYPE_bte:
-               return binsearch_bte(rcand, offset, (const bte *) rvals,
-                                    lo, hi, *(const bte *) v, ordering, last);
-       case TYPE_sht:
-               return binsearch_sht(rcand, offset, (const sht *) rvals,
-                                    lo, hi, *(const sht *) v, ordering, last);
-       case TYPE_int:
-#if SIZEOF_OID == SIZEOF_INT
-       case TYPE_oid:
-#endif
-               return binsearch_int(rcand, offset, (const int *) rvals,
-                                    lo, hi, *(const int *) v, ordering, last);
-       case TYPE_lng:
-#if SIZEOF_OID == SIZEOF_LNG
-       case TYPE_oid:
-#endif
-               return binsearch_lng(rcand, offset, (const lng *) rvals,
-                                    lo, hi, *(const lng *) v, ordering, last);
-#ifdef HAVE_HGE
-       case TYPE_hge:
-               return binsearch_hge(rcand, offset, (const hge *) rvals,
-                                    lo, hi, *(const hge *) v, ordering, last);
-#endif
-       case TYPE_flt:
-               return binsearch_flt(rcand, offset, (const flt *) rvals,
-                                    lo, hi, *(const flt *) v, ordering, last);
-       case TYPE_dbl:
-               return binsearch_dbl(rcand, offset, (const dbl *) rvals,
-                                    lo, hi, *(const dbl *) v, ordering, last);
-       }
-
-       if ((c = ordering * cmp(VALUE(r, rcand ? rcand[lo] - offset : lo), v)) 
> 0 ||
-           (!last && c == 0))
-               return lo;
-       if ((c = ordering * cmp(VALUE(r, rcand ? rcand[hi] - offset : hi), v)) 
< 0 ||
-           (last && c == 0))
-               return hi + 1;
-
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to