Changeset: 99f9be40d724 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/99f9be40d724
Modified Files:
        monetdb5/modules/mal/batExtensions.c
        monetdb5/modules/mal/pcre.c
        sql/backends/monet5/sql.c
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.int128
Branch: string_imprints
Log Message:

Merge with default


diffs (truncated from 1709 to 300 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2391,7 +2391,7 @@ dump_database(Mapi mid, stream *toConsol
        const char *sequences2 =
                "SELECT s.name, "
                     "seq.name, "
-                    "get_value_for(s.name, seq.name), "
+                    "peak_next_value_for(s.name, seq.name), "
                     "seq.\"minvalue\", "
                     "seq.\"maxvalue\", "
                     "seq.\"increment\", "
diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -57,7 +57,6 @@
 /* #define NO_ATOMIC_INSTRUCTIONS */
 
 /* the atomic type we export is always a 64 bit unsigned integer */
-typedef uint64_t ATOMIC_BASE_TYPE;
 
 /* ignore __STDC_NO_ATOMICS__ if compiling using Intel compiler on
  * Windows since otherwise we can't compile this at all in C99 mode */
@@ -67,8 +66,10 @@ typedef uint64_t ATOMIC_BASE_TYPE;
 
 #if SIZEOF_LONG_LONG == 8
 typedef volatile atomic_ullong ATOMIC_TYPE;
+typedef unsigned long long ATOMIC_BASE_TYPE;
 #elif SIZEOF_LONG == 8
 typedef volatile atomic_ulong ATOMIC_TYPE;
+typedef unsigned long ATOMIC_BASE_TYPE;
 #else
 #error "we need a 64 bit atomic type"
 #endif
@@ -106,6 +107,8 @@ typedef volatile atomic_flag ATOMIC_FLAG
 
 #elif defined(_MSC_VER) && !defined(NO_ATOMIC_INSTRUCTIONS)
 
+typedef uint64_t ATOMIC_BASE_TYPE;
+
 #include <intrin.h>
 
 /* On Windows, with Visual Studio 2005, the compiler uses acquire
@@ -227,6 +230,7 @@ typedef volatile int ATOMIC_FLAG;
 /* the new way of doing this according to GCC (the old way, using
  * __sync_* primitives is not supported) */
 
+typedef uint64_t ATOMIC_BASE_TYPE;
 typedef volatile ATOMIC_BASE_TYPE ATOMIC_TYPE;
 
 #define ATOMIC_VAR_INIT(val)   (val)
@@ -262,6 +266,8 @@ typedef volatile char ATOMIC_FLAG;
 
 /* emulate using mutexes */
 
+typedef uint64_t ATOMIC_BASE_TYPE;
+
 #include <pthread.h> /* required for pthread_mutex_t */
 
 typedef struct {
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -598,7 +598,7 @@ MCreadClient(Client c)
                in->pos++;
 
        if (in->pos >= in->len || in->mode) {
-               ssize_t rd, sum = 0;
+               ssize_t rd;
 
                if (in->eof || !isa_block_stream(c->fdout)) {
                        if (!isa_block_stream(c->fdout) && c->promptlength > 0)
@@ -607,7 +607,6 @@ MCreadClient(Client c)
                        in->eof = false;
                }
                while ((rd = bstream_next(in)) > 0 && !in->eof) {
-                       sum += rd;
                        if (!in->mode) /* read one line at a time in line mode 
*/
                                break;
                }
diff --git a/monetdb5/modules/mal/batExtensions.c 
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -100,7 +100,7 @@ CMDBATsingle(Client cntxt, MalBlkPtr mb,
        if( b == 0)
                throw(MAL,"bat.single", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        if (ATOMextern(b->ttype))
-               u = (ptr) *(str *)u;
+               u = (ptr) *(ptr *)u;
        if (BUNappend(b, u, false) != GDK_SUCCEED) {
                BBPreclaim(b);
                throw(MAL, "bat.single", SQLSTATE(HY013) MAL_MALLOC_FAIL);
diff --git a/monetdb5/modules/mal/mal_io.c b/monetdb5/modules/mal/mal_io.c
--- a/monetdb5/modules/mal/mal_io.c
+++ b/monetdb5/modules/mal/mal_io.c
@@ -120,8 +120,8 @@ IOprintBoth(Client cntxt, MalBlkPtr mb, 
        if (hd)
                mnstr_printf(fp, "%s", hd);
 
-       if (ATOMvarsized(tpe))
-               ATOMprint(tpe, *(str *) val, fp);
+       if (ATOMextern(tpe))
+               ATOMprint(tpe, *(ptr *) val, fp);
        else
                ATOMprint(tpe, val, fp);
 
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -285,8 +285,6 @@ mywstrcasestr(const char *restrict hayst
        if (nlen == 0)
                return atend ? haystack + strlen(haystack) : haystack;
 
-       size_t hlen = strlen(haystack);
-
        while (*haystack) {
                size_t i;
                size_t h;
@@ -312,7 +310,6 @@ mywstrcasestr(const char *restrict hayst
                if (i == nlen && (!atend || haystack[h] == 0))
                        return haystack;
                haystack += step;
-               hlen -= step;
        }
        return NULL;
 }
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -1102,7 +1102,7 @@ static str RMTput(Client cntxt, MalBlkPt
                int (*atomcmp)(const void *, const void *) = ATOMcompare(type);
 
                if (ATOMextern(type))
-                       p = *(str *)value;
+                       p = *(ptr *)value;
 
                val = ATOMformat(type, p);
                if (val == NULL) {
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -1550,7 +1550,7 @@ SQLload_file(Client cntxt, Tablet *as, b
        READERtask task;
        READERtask ptask[MAXWORKERS];
        int threads = (maxrow< 0 || maxrow > (1 << 16)) && GDKnr_threads > 1 ? 
(GDKnr_threads < MAXWORKERS ? GDKnr_threads - 1 : MAXWORKERS - 1) : 1;
-       lng lio = 0, tio, t1 = 0, total = 0, iototal = 0;
+       lng tio, t1 = 0;
        char name[MT_NAME_LEN];
 
 /*     TRC_DEBUG(MAL_SERVER, "Prepare copy work for '%d' threads col '%s' rec 
'%s' quot '%c'\n", threads, csep, rsep, quote);*/
@@ -1722,8 +1722,6 @@ SQLload_file(Client cntxt, Tablet *as, b
                if (task.ateof && !task.top[task.cur])
                        break;
                t1 = GDKusec() - t1;
-               total += t1;
-               iototal += tio;
 /*             TRC_DEBUG(MAL_SERVER, "Break: %d rows\n", task.top[task.cur]);*/
 
                t1 = GDKusec();
@@ -1757,7 +1755,6 @@ SQLload_file(Client cntxt, Tablet *as, b
                        "Fill the BATs '%d' " BUNFMT " cap " BUNFMT "\n",
                        task.top[task.cur], task.cnt, 
BATcapacity(as->format[task.cur].c));*/
 
-               lio += GDKusec() - t1;  /* row break done */
                if (task.top[task.cur]) {
                        if (res == 0) {
                                SQLworkdivider(&task, ptask, (int) 
as->nr_attrs, threads);
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
@@ -951,23 +951,11 @@ mvc_next_value_bulk(Client cntxt, MalBlk
        if (!(r = COLnew(0, TYPE_lng, card, TRANSIENT)))
                throw(SQL, "sql.next_value", SQLSTATE(HY013) MAL_MALLOC_FAIL);
 
-       lng start, inc, minv, maxv, end, *restrict rb = Tloc(r, 0);
-
-       if (seqbulk_next_value(be->mvc->session->tr->store, seq, card, &start, 
&inc, &minv, &maxv, &end)) {
-               be->last_id = end;
+       lng *restrict rb = Tloc(r, 0);
+
+       if (seqbulk_next_value(be->mvc->session->tr->store, seq, card, rb)) {
+               be->last_id = rb[card-1];
                sqlvar_set_number(find_global_var(be->mvc, 
mvc_bind_schema(be->mvc, "sys"), "last_id"), be->last_id);
-               lng c = start;
-               for(BUN i = 0; i<card; ) {
-                       if (maxv && c > maxv) {
-                               if (!seq->cycle)
-                                       break;
-                               c = minv;
-                       }
-                       rb[i++] = c;
-                       if (i < card)
-                               c += inc;
-               }
-               assert(c == end);
                BATsetcount(r, card);
                r->tnonil = true;
                r->tnil = false;
@@ -1007,6 +995,33 @@ mvc_get_value(Client cntxt, MalBlkPtr mb
        throw(SQL, "sql.get_value", SQLSTATE(HY050) "Cannot get sequence value 
%s.%s", sname, seqname);
 }
 
+/* str mvc_peak_next_value(lng *res, str *sname, str *seqname); */
+str
+mvc_peak_next_value(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+       mvc *m = NULL;
+       str msg;
+       sql_schema *s;
+       sql_sequence *seq;
+       lng *res = getArgReference_lng(stk, pci, 0);
+       const char *sname = *getArgReference_str(stk, pci, 1);
+       const char *seqname = *getArgReference_str(stk, pci, 2);
+
+       if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL)
+               return msg;
+       if ((msg = checkSQLContext(cntxt)) != NULL)
+               return msg;
+       if (!(s = mvc_bind_schema(m, sname)))
+               throw(SQL, "sql.peak_next_value", SQLSTATE(3F000) "Cannot find 
the schema %s", sname);
+       if (!(seq = find_sql_sequence(m->session->tr, s, seqname)))
+               throw(SQL, "sql.peak_next_value", SQLSTATE(HY050) "Cannot find 
the sequence %s.%s", sname, seqname);
+
+       if (seq_peak_next_value(m->session->tr->store, seq, res))
+               return MAL_SUCCEED;
+
+       throw(SQL, "sql.peak_next_value", SQLSTATE(HY050) "Cannot peak at next 
sequence value %s.%s", sname, seqname);
+}
+
 str
 mvc_getVersion(lng *version, const int *clientid)
 {
@@ -5099,6 +5114,7 @@ static mel_func sql_init_funcs[] = {
  pattern("sql", "next_value", mvc_next_value, true, "return the next value of 
the sequence", args(1,3, arg("",lng),arg("sname",str),arg("sequence",str))),
  pattern("batsql", "next_value", mvc_next_value_bulk, true, "return the next 
value of the sequence", args(1,4, batarg("",lng),arg("card",lng), 
arg("sname",str),arg("sequence",str))),
  pattern("sql", "get_value", mvc_get_value, false, "return the current value 
of the sequence", args(1,3, arg("",lng),arg("sname",str),arg("sequence",str))),
+ pattern("sql", "peak_next_value", mvc_peak_next_value, false, "Peaks at the 
next value of the sequence", args(1,3, 
arg("",lng),arg("sname",str),arg("sequence",str))),
  pattern("sql", "restart", mvc_restart_seq, true, "restart the sequence with 
value start", args(1,4, 
arg("",lng),arg("sname",str),arg("sequence",str),arg("start",lng))),
  pattern("sql", "deltas", mvc_delta_values, false, "Return the delta values 
sizes of all columns of the schema's tables, plus the current transaction 
level", args(7,8, 
batarg("ids",int),batarg("segments",lng),batarg("all",lng),batarg("inserted",lng),batarg("updated",lng),batarg("deleted",lng),batarg("tr_level",int),arg("schema",str))),
  pattern("sql", "deltas", mvc_delta_values, false, "Return the delta values 
sizes from the table's columns, plus the current transaction level", args(7,9, 
batarg("ids",int),batarg("segments",lng),batarg("all",lng),batarg("inserted",lng),batarg("updated",lng),batarg("deleted",lng),batarg("tr_level",int),arg("schema",str),arg("table",str))),
diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h
--- a/sql/backends/monet5/sql.h
+++ b/sql/backends/monet5/sql.h
@@ -102,6 +102,7 @@ extern str mvc_logfile(Client cntxt, Mal
 extern str mvc_next_value(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
 extern str mvc_next_value_bulk(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str mvc_get_value(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+extern str mvc_peak_next_value(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str mvc_getVersion(lng *r, const int *clientid);
 extern str mvc_restart_seq(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
 extern str not_unique(bit *ret, const bat *bid);
diff --git a/sql/backends/monet5/sql_fround_impl.h 
b/sql/backends/monet5/sql_fround_impl.h
--- a/sql/backends/monet5/sql_fround_impl.h
+++ b/sql/backends/monet5/sql_fround_impl.h
@@ -355,7 +355,9 @@ round_wrap(TYPE *res, const TYPE *v, con
        assert(res && v && r);
        bte rr = *r;
 
-       if (is_bte_nil(rr) || (size_t) abs(rr) >= sizeof(scales) / 
sizeof(scales[0]))
+       if (is_bte_nil(rr))
+               throw(MAL, "round", SQLSTATE(42000) "Number of digits cannot be 
NULL");
+       if ((size_t) abs(rr) >= sizeof(scales) / sizeof(scales[0]))
                throw(MAL, "round", SQLSTATE(42000) "Digits out of bounds");
        *res = (ISNIL(TYPE)(*v)) ? NIL(TYPE) : round_body(*v, rr);
        if (isinf(*res))
@@ -380,7 +382,11 @@ bat_round_wrap(Client cntxt, MalBlkPtr m
 
        (void) cntxt;
        (void) mb;
-       if (is_bte_nil(r) || (size_t) abs(r) >= sizeof(scales) / 
sizeof(scales[0])) {
+       if (is_bte_nil(r)) {
+               msg = createException(MAL, "round", SQLSTATE(42000) "Number of 
digits cannot be NULL");
+               goto bailout;
+       }
+       if ((size_t) abs(r) >= sizeof(scales) / sizeof(scales[0])) {
                msg = createException(MAL, "round", SQLSTATE(42000) "Digits out 
of bounds");
                goto bailout;
        }
@@ -491,7 +497,10 @@ bat_round_wrap_cst(Client cntxt, MalBlkP
                        oid p1 = (canditer_next_dense(&ci1) - off1);
                        r = src[p1];
 
-                       if (is_bte_nil(r) || (size_t) abs(r) >= sizeof(scales) 
/ sizeof(scales[0])) {
+                       if (is_bte_nil(r)) {
+                               msg = createException(MAL, "round", 
SQLSTATE(42000) "Number of digits cannot be NULL");
+                               goto bailout1;
+                       } else if ((size_t) abs(r) >= sizeof(scales) / 
sizeof(scales[0])) {
                                msg = createException(MAL, "round", 
SQLSTATE(42000) "Digits out of bounds");
                                goto bailout1;
                        } else if (ISNIL(TYPE)(x)) {
@@ -510,7 +519,10 @@ bat_round_wrap_cst(Client cntxt, MalBlkP
                        oid p1 = (canditer_next(&ci1) - off1);
                        r = src[p1];
 
-                       if (is_bte_nil(r) || (size_t) abs(r) >= sizeof(scales) 
/ sizeof(scales[0])) {
+                       if (is_bte_nil(r)) {
+                               msg = createException(MAL, "round", 
SQLSTATE(42000) "Number of digits cannot be NULL");
+                               goto bailout1;
+                       } else if ((size_t) abs(r) >= sizeof(scales) / 
sizeof(scales[0])) {
                                msg = createException(MAL, "round", 
SQLSTATE(42000) "Digits out of bounds");
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to