MonetDB: default - Merge with Aug2024 branch.

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: c5da0e80df1a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c5da0e80df1a
Modified Files:
sql/server/rel_exp.c
testing/Mtest.py.in
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (289 lines):

diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -2875,7 +2875,14 @@ ignorecase(const bat *ic_id, bool *icase
if ((c = BATdescriptor(*ic_id)) == NULL)
throw(MAL, fname, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
 
-   assert(BATcount(c) >= 1);
+   if (BATcount(c) != 1) {
+   BUN cnt = BATcount(c);
+   BBPreclaim(c);
+   if (cnt == 0)
+   throw(MAL, fname, SQLSTATE(42000) "Missing ignore case 
value\n");
+   else
+   throw(MAL, fname, SQLSTATE(42000) "Multiple ignore case 
values passed, only one expected\n");
+   }
 
BATiter bi = bat_iterator(c);
*icase = *(bit *) BUNtloc(bi, 0);
diff --git a/sql/jdbc/tests/Tests/All b/sql/jdbc/tests/Tests/All
--- a/sql/jdbc/tests/Tests/All
+++ b/sql/jdbc/tests/Tests/All
@@ -1,5 +1,5 @@
 HAVE_JDBCTESTS?JDBC_API_Tester
-HAVE_JDBCTESTS?TLSTester
+HAVE_JDBCTESTS&HAVE_CRYPTOGRAPHY?TLSTester
 HAVE_JDBCTESTS?OnClientTester
 HAVE_JDBCCLIENT_JAR?Test_JdbcClient
 # next test should be done AFTER all the other tests have completed
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -1950,7 +1950,8 @@ exp_is_cmp_exp_is_false(sql_exp* e)
 }
 
 static inline bool
-exp_single_bound_cmp_exp_is_false(sql_exp* e) {
+exp_single_bound_cmp_exp_is_false(sql_exp* e)
+{
 assert(e->type == e_cmp);
 sql_exp* l = e->l;
 sql_exp* r = e->r;
@@ -1984,7 +1985,8 @@ exp_regular_cmp_exp_is_false(sql_exp* e)
 }
 
 static inline bool
-exp_or_exp_is_false(sql_exp* e) {
+exp_or_exp_is_false(sql_exp* e)
+{
 assert(e->type == e_cmp && e->flag == cmp_or);
 
list* left = e->l;
@@ -2012,7 +2014,8 @@ exp_or_exp_is_false(sql_exp* e) {
 }
 
 static inline bool
-exp_cmp_exp_is_false(sql_exp* e) {
+exp_cmp_exp_is_false(sql_exp* e)
+{
 assert(e->type == e_cmp);
 
 switch (e->flag) {
@@ -2131,7 +2134,7 @@ exp_is_null(sql_exp *e )
return ((e->flag == cmp_in && 
exp_is_null(e->l)) ||
(e->flag == cmp_notin && 
(exp_is_null(e->l) || exps_have_null(e->r;
} else if (e->f) {
-   return exp_is_null(e->l) || (!is_anti(e) && 
(exp_is_null(e->r) || exp_is_null(e->f)));
+   return exp_is_null(e->l) && exp_is_null(e->r) 
&& exp_is_null(e->f);
} else {
return exp_is_null(e->l) || exp_is_null(e->r);
}
@@ -2660,6 +2663,14 @@ exp_has_func_or_cmp(sql_exp *e, bool cmp
return exps_have_func_or_cmp(e->f, true);
return 0;
case e_convert:
+   {
+   sql_subtype *t = exp_totype(e);
+   sql_subtype *f = exp_fromtype(e);
+   if (t->type->eclass == EC_FLT && (f->type->eclass == 
EC_DEC || f->type->eclass == EC_NUM))
+   return exp_has_func_or_cmp(e->l, cmp);
+   if (f->type->localtype > t->type->localtype)
+   return true;
+   }
return exp_has_func_or_cmp(e->l, cmp);
case e_func:
return 1;
diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h
--- a/sql/server/rel_exp.h
+++ b/sql/server/rel_exp.h
@@ -160,6 +160,7 @@ extern int exp_is_join(sql_exp *e, list 
 extern int exp_is_eqjoin(sql_exp *e);
 extern int exp_is_join_exp(sql_exp *e);
 extern int exp_is_atom(sql_exp *e);
+/* exp_is_true/false etc return true if the expression is true, on unknown etc 
false is returned */
 extern int exp_is_true(sql_exp *e);
 extern int exp_is_false(sql_exp *e);
 extern int exp_is_zero(sql_exp *e);
diff --git a/sql/server/rel_optimize_exps.c b/sql/server/rel_optimize_exps.c
--- a/sql/server/rel_optimize_exps.c
+++ b/sql/server/rel_optimize_exps.c
@@ -456,7 +456,7 @@ rel_simplify_predicates(visitor *v, sql_
sql_exp *le = n->data;
sql_exp *re = n->next->data;
 
-   if (exp_is_atom(le) && !exp_is_null(le) && exp_is_atom(re) && 
le->type == e_atom && le->l && re->type == e_atom && re->l) {
+   if (exp_is_atom(le) && exp_is_not_null(le) && exp_is_atom(re) 
&& le->type == e_atom && le->l && re->type == e_atom && re->l) {
n = n->next->next;
if (exp_match_exp(le, re)) { /* x==y -> a */
sql_exp *res = n->data;
diff --git a/sql/server/rel_rewriter.c b/sql/server/rel_rewriter.c
--- a/sql/server/r

MonetDB: default - New function nextafter.

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: 9fbe4a6b2745 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9fbe4a6b2745
Modified Files:
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: default
Log Message:

New function nextafter.


diffs (24 lines):

diff --git a/sql/test/emptydb/Tests/check.stable.out.32bit 
b/sql/test/emptydb/Tests/check.stable.out.32bit
--- a/sql/test/emptydb/Tests/check.stable.out.32bit
+++ b/sql/test/emptydb/Tests/check.stable.out.32bit
@@ -2178,6 +2178,8 @@ select 'null in fkeys.delete_action', de
 [ "sys.functions", "sys",  "newurl",   "SYSTEM",   "create 
function newurl(protocol string, hostname string, \"port\" int, file string) 
returns url external name url.\"new\";",   "url",  "MAL",  "Scalar function",   
   false,  false,  false,  true,   NULL,   "result",   "url",  0,  0,   
   "out",  "protocol", "varchar",  0,  0,  "in",   "hostname",  
   "varchar",  0,  0,  "in",   "port", "int",  31, 0,  
"in",   "file", "varchar",  0,  0,  "in",   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL]
 [ "sys.functions", "sys",  "newurl",   "SYSTEM",   "create 
function newurl(protocol string, hostname string, file string) returns url 
external name url.\"new\";", "url",  "MAL",  "Scalar function",  false,  
false,  false,  true,   NULL,   "result",   "url",  0,  0,  "out",  
"protocol", "varchar",  0,  0,  "in",   "hostname", 
"varchar",  0,  0,  "in",   "file", "varchar",  0,  0,  
"in",   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL]
 [ "sys.functions", "sys",  "next_value_for",   "SYSTEM",   
"next_value",   "sql",  "Internal C",   "Scalar function",  true,   false,  
false,  true,   NULL,   "res_0","bigint",   63, 0,  "out",  
"arg_1","varchar",  0,  0,  "in",   "arg_2",
"varchar",  0,  0,  "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL
]
+[ "sys.functions", "sys",  "nextafter","SYSTEM",   "nextafter",
"mmath","Internal C",   "Scalar function",  false,  false,  false,  
false,  NULL,   "res_0","double",   53, 0,  "out",  
"arg_1","double",   53, 0,  "in",   "arg_2",
"double",   53, 0,  "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL
]
+[ "sys.functions", "sys",  "nextafter","SYSTEM",   "nextafter",
"mmath","Internal C",   "Scalar function",  false,  false,  false,  
false,  NULL,   "res_0","real", 24, 0,  "out",  "arg_1",
"real", 24, 0,  "in",   "arg_2","real", 24, 0,  "in",   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   

MonetDB: Dec2023 - Lock both the view and its parent when making...

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: 05d2729d1875 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/05d2729d1875
Modified Files:
gdk/gdk_bat.c
Branch: Dec2023
Log Message:

Lock both the view and its parent when making a copy.
This hopefully fixes a race between COLcopy making a copy and insert
in another thread happening at the same time.


diffs (32 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -822,6 +822,17 @@ COLcopy(BAT *b, int tt, bool writable, r
 * table and that would result in buckets containing values
 * beyond the original vheap that we're copying */
MT_lock_set(&b->theaplock);
+   BAT *pb = NULL, *pvb = NULL;
+   if (b->theap->parentid != b->batCacheid) {
+   pb = BBP_desc(b->theap->parentid);
+   MT_lock_set(&pb->theaplock);
+   }
+   if (b->tvheap &&
+   b->tvheap->parentid != b->batCacheid &&
+   b->tvheap->parentid != b->theap->parentid) {
+   pvb = BBP_desc(b->tvheap->parentid);
+   MT_lock_set(&pvb->theaplock);
+   }
bi = bat_iterator_nolock(b);
if (ATOMstorage(b->ttype) == TYPE_str && b->tvheap->free >= 
GDK_STRHASHSIZE)
memcpy(strhash, b->tvheap->base, GDK_STRHASHSIZE);
@@ -832,6 +843,10 @@ COLcopy(BAT *b, int tt, bool writable, r
HEAPincref(bi.h);
if (bi.vh)
HEAPincref(bi.vh);
+   if (pvb)
+   MT_lock_unset(&pvb->theaplock);
+   if (pb)
+   MT_lock_unset(&pb->theaplock);
MT_lock_unset(&b->theaplock);
 
/* first try case (1); create a view, possibly with different
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - Use a barrier to synchronize starting the ser...

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: d850cdd4d46e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d850cdd4d46e
Modified Files:
common/stream/Tests/urlstream.py
Branch: Dec2023
Log Message:

Use a barrier to synchronize starting the server and the client.


diffs (54 lines):

diff --git a/common/stream/Tests/urlstream.py b/common/stream/Tests/urlstream.py
--- a/common/stream/Tests/urlstream.py
+++ b/common/stream/Tests/urlstream.py
@@ -9,25 +9,6 @@ import time
 
 OUTPUT = io.StringIO()
 
-def wait_for_server(timeout):
-deadline = time.time() + timeout
-while time.time() < deadline:
-if port == 0:
-time.sleep(0.25)
-continue
-s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-s.settimeout(0.1)
-try:
-s.connect(('localhost', port))
-break
-except ConnectionRefusedError:
-time.sleep(0.1)
-finally:
-s.close()
-else:
-print(f'Warning: waited {timeout} seconds for the server to start but 
could still not connect', file=OUTPUT)
-
-
 class Handler(http.server.BaseHTTPRequestHandler):
 def log_message(self, format, *args):
 # add a # at the beginning of the line to not mess up Mtest diffs
@@ -66,19 +47,23 @@ class Handler(http.server.BaseHTTPReques
 self.end_headers()
 self.wfile.write(b'NOT FOUND\n')
 
+b = threading.Barrier(2)
+
 def runserver():
 global port
 addr = ('127.0.0.1', 0)
 srv = http.server.HTTPServer(addr, Handler)
 port = srv.server_port
 print(f"Listening on {port}", file=OUTPUT)
+b.wait()
 srv.serve_forever()
 
 # Start the http server
 port = 0
 t = threading.Thread(target=lambda: runserver(), daemon=True)
 t.start()
-wait_for_server(5.0)
+# and wait for it to fill in the port
+b.wait()
 
 url = f'http://localhost:{port}'
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Aug2024 - Merge with Dec2023 branch.

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: 3da1a8a4ab38 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3da1a8a4ab38
Modified Files:
gdk/gdk_bat.c
Branch: Aug2024
Log Message:

Merge with Dec2023 branch.


diffs (84 lines):

diff --git a/common/stream/Tests/urlstream.py b/common/stream/Tests/urlstream.py
--- a/common/stream/Tests/urlstream.py
+++ b/common/stream/Tests/urlstream.py
@@ -9,25 +9,6 @@ import time
 
 OUTPUT = io.StringIO()
 
-def wait_for_server(timeout):
-deadline = time.time() + timeout
-while time.time() < deadline:
-if port == 0:
-time.sleep(0.25)
-continue
-s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-s.settimeout(0.1)
-try:
-s.connect(('localhost', port))
-break
-except ConnectionRefusedError:
-time.sleep(0.1)
-finally:
-s.close()
-else:
-print(f'Warning: waited {timeout} seconds for the server to start but 
could still not connect', file=OUTPUT)
-
-
 class Handler(http.server.BaseHTTPRequestHandler):
 def log_message(self, format, *args):
 # add a # at the beginning of the line to not mess up Mtest diffs
@@ -66,19 +47,23 @@ class Handler(http.server.BaseHTTPReques
 self.end_headers()
 self.wfile.write(b'NOT FOUND\n')
 
+b = threading.Barrier(2)
+
 def runserver():
 global port
 addr = ('127.0.0.1', 0)
 srv = http.server.HTTPServer(addr, Handler)
 port = srv.server_port
 print(f"Listening on {port}", file=OUTPUT)
+b.wait()
 srv.serve_forever()
 
 # Start the http server
 port = 0
 t = threading.Thread(target=lambda: runserver(), daemon=True)
 t.start()
-wait_for_server(5.0)
+# and wait for it to fill in the port
+b.wait()
 
 url = f'http://localhost:{port}'
 
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -817,11 +817,26 @@ COLcopy(BAT *b, int tt, bool writable, r
 * table and that would result in buckets containing values
 * beyond the original vheap that we're copying */
MT_lock_set(&b->theaplock);
+   BAT *pb = NULL, *pvb = NULL;
+   if (b->theap->parentid != b->batCacheid) {
+   pb = BBP_desc(b->theap->parentid);
+   MT_lock_set(&pb->theaplock);
+   }
+   if (b->tvheap &&
+   b->tvheap->parentid != b->batCacheid &&
+   b->tvheap->parentid != b->theap->parentid) {
+   pvb = BBP_desc(b->tvheap->parentid);
+   MT_lock_set(&pvb->theaplock);
+   }
bi = bat_iterator_nolock(b);
if (ATOMstorage(b->ttype) == TYPE_str && b->tvheap->free >= 
GDK_STRHASHSIZE)
memcpy(strhash, b->tvheap->base, GDK_STRHASHSIZE);
 
bat_iterator_incref(&bi);
+   if (pvb)
+   MT_lock_unset(&pvb->theaplock);
+   if (pb)
+   MT_lock_unset(&pb->theaplock);
MT_lock_unset(&b->theaplock);
 
/* first try case (1); create a view, possibly with different
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Aug2024 - Remove unused argument.

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: 44ecf7ec956e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/44ecf7ec956e
Modified Files:
gdk/gdk_calc_private.h
Branch: Aug2024
Log Message:

Remove unused argument.


diffs (51 lines):

diff --git a/gdk/gdk_calc_private.h b/gdk/gdk_calc_private.h
--- a/gdk/gdk_calc_private.h
+++ b/gdk/gdk_calc_private.h
@@ -36,7 +36,7 @@
 #include "gdk_cand.h"
 
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
-#define OP_WITH_CHECK(lft, rgt, dst, op, nil, max, on_overflow)
\
+#define OP_WITH_CHECK(lft, rgt, dst, op, max, on_overflow) \
do {\
if (__builtin_##op##_overflow(lft, rgt, &(dst)) ||  \
(dst) < -(max) || (dst) > (max)) {  \
@@ -68,7 +68,7 @@
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
 /* integer version using Gnu CC builtin function for overflow check */
 #define ADDI_WITH_CHECK(lft, rgt, TYPE3, dst, max, on_overflow)
\
-   OP_WITH_CHECK(lft, rgt, dst, add, TYPE3##_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, add, max, on_overflow)
 #else
 /* integer version using generic version */
 #define ADDI_WITH_CHECK(lft, rgt, TYPE3, dst, max, on_overflow) \
@@ -102,7 +102,7 @@
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
 /* integer version using Gnu CC builtin function for overflow check */
 #define SUBI_WITH_CHECK(lft, rgt, TYPE3, dst, max, on_overflow)
\
-   OP_WITH_CHECK(lft, rgt, dst, sub, TYPE3##_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, sub, max, on_overflow)
 #else
 /* integer version using generic version */
 #define SUBI_WITH_CHECK(lft, rgt, TYPE3, dst, max, on_overflow) \
@@ -130,9 +130,9 @@
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
 /* integer version using Gnu CC builtin function for overflow check */
 #define MULI4_WITH_CHECK(lft, rgt, TYPE3, dst, max, TYPE4, on_overflow) \
-   OP_WITH_CHECK(lft, rgt, dst, mul, TYPE3##_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, mul, max, on_overflow)
 #define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow)  \
-   OP_WITH_CHECK(lft, rgt, dst, mul, lng_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, mul, max, on_overflow)
 #else
 /* integer version using generic version */
 #define MULI4_WITH_CHECK(lft, rgt, TYPE3, dst, max, TYPE4, on_overflow) \
@@ -195,7 +195,7 @@
 #ifdef HAVE_HGE
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
 #define HGEMUL_CHECK(lft, rgt, dst, max, on_overflow)  \
-   OP_WITH_CHECK(lft, rgt, dst, mul, hge_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, mul, max, on_overflow)
 #else
 #define HGEMUL_CHECK(lft, rgt, dst, max, on_overflow)  \
do {\
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: nilmask - Implemented some basic stuff for unsigned types.

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: 553f9299d443 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/553f9299d443
Modified Files:
gdk/gdk.h
gdk/gdk_atoms.c
gdk/gdk_atoms.h
gdk/gdk_value.c
Branch: nilmask
Log Message:

Implemented some basic stuff for unsigned types.


diffs (truncated from 499 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -458,9 +458,13 @@ enum {
 typedef bool msk;
 typedef int8_t bit;
 typedef int8_t bte;
+typedef uint8_t ubte;
 typedef int16_t sht;
+typedef uint16_t usht;
+typedef uint32_t uint;
 /* typedef int64_t lng; -- defined in gdk_system.h */
 typedef uint64_t ulng;
+/* hge and uhge are defined in monetdb_config.h */
 
 #define SIZEOF_OID SIZEOF_SIZE_T
 typedef size_t oid;
@@ -648,6 +652,13 @@ typedef struct {
hge hval;
 #endif
uuid uval;
+   ubte ubtval;
+   usht ushval;
+   uint uival;
+   ulng ulval;
+#ifdef HAVE_HGE
+   uhge uhval;
+#endif
} val;
size_t len;
short vtype;
@@ -1952,13 +1963,18 @@ VALptr(const ValRecord *v)
case TYPE_void: return (const void *) &v->val.oval;
case TYPE_msk: return (const void *) &v->val.mval;
case TYPE_bte: return (const void *) &v->val.btval;
+   case TYPE_ubte: return (const void *) &v->val.ubtval;
case TYPE_sht: return (const void *) &v->val.shval;
+   case TYPE_usht: return (const void *) &v->val.ushval;
case TYPE_int: return (const void *) &v->val.ival;
+   case TYPE_uint: return (const void *) &v->val.uival;
case TYPE_flt: return (const void *) &v->val.fval;
case TYPE_dbl: return (const void *) &v->val.dval;
+   case TYPE_ulng: return (const void *) &v->val.ulval;
case TYPE_lng: return (const void *) &v->val.lval;
 #ifdef HAVE_HGE
case TYPE_hge: return (const void *) &v->val.hval;
+   case TYPE_uhge: return (const void *) &v->val.uhval;
 #endif
case TYPE_uuid: return (const void *) &v->val.uval;
case TYPE_ptr: return (const void *) &v->val.pval;
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -88,6 +88,38 @@ dblCmp(const dbl *l, const dbl *r)
return is_dbl_nil(*l) ? -!is_dbl_nil(*r) : is_dbl_nil(*r) ? 1 : (*l > 
*r) - (*l < *r);
 }
 
+static int
+ubteCmp(const ubte *l, const ubte *r)
+{
+   return (*l > *r) - (*l < *r);
+}
+
+static int
+ushtCmp(const usht *l, const usht *r)
+{
+   return (*l > *r) - (*l < *r);
+}
+
+static int
+uintCmp(const uint *l, const uint *r)
+{
+   return (*l > *r) - (*l < *r);
+}
+
+static int
+ulngCmp(const ulng *l, const ulng *r)
+{
+   return (*l > *r) - (*l < *r);
+}
+
+#ifdef HAVE_HGE
+static int
+uhgeCmp(const uhge *l, const uhge *r)
+{
+   return (*l > *r) - (*l < *r);
+}
+#endif
+
 /*
  * @- inline hash routines
  * Return some positive integer derived from one atom value.
@@ -878,6 +910,137 @@ hgeFromStr(const char *src, size_t *len,
 }
 #endif
 
+#ifdef HAVE_HGE
+const uhge maxunum = ((uhge) UINT64_C(18446744073709551615) << 64) |
+   (uhge) UINT64_C(18446744073709551615); /* (1 << 128) - 1: 
340282366920938463463374607431768211455*/
+#else
+const ulng maxunum = UINT64_C(18446744073709551615); /* (1 << 64) - 1 */
+#endif
+
+static ssize_t
+unumFromStr(const char *src, size_t *len, void **dst, int tp)
+{
+   const char *p = src;
+   size_t sz = ATOMsize(tp);
+#ifdef HAVE_HGE
+   uhge base = 0;
+#else
+   ulng base = 0;
+#endif
+
+   /* a valid unsigned number has the following syntax:
+* [0-9]+(LL)? -- PCRE syntax, or in other words
+* one or more digits, optional LL
+* embedded spaces are not allowed
+* the optional LL at the end are only allowed for lng and hge
+* values */
+   atommem(sz);
+
+   if (strNil(src)) {
+   GDKerror("not a number");
+   goto bailout;
+   }
+
+   while (GDKisspace(*p))
+   p++;
+   if (!GDKisdigit(*p)) {
+   GDKerror("not a number");
+   goto bailout;
+   }
+   do {
+   int dig = base10(*p);
+   if (base > maxunum / 10 ||
+   (base == maxunum / 10 && dig > 5)) {
+   /* overflow */
+   goto overflow;
+   }
+   base = 10 * base + dig;
+   p++;
+   } while (GDKisdigit(*p));
+   switch (sz) {
+   case 1:
+   if (base > GDK_ubte_max)
+   goto overflow;
+   **(ubte **) dst = (ubte) base;
+   break;
+   case 2:
+   if (base > GDK_usht_max)
+   goto overflow;
+   **(usht **) dst = (usht) base;
+   break;
+   case 4:
+   if (base > GDK_uint_max)
+   goto overflow;
+   **(uint **) dst = (uint) base;
+ 

MonetDB: nilmask - Implemented aggregates for unsigned.

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: a86ef1afc8ff for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a86ef1afc8ff
Modified Files:
gdk/gdk_aggr.c
Branch: nilmask
Log Message:

Implemented aggregates for unsigned.


diffs (truncated from 2230 to 300 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -704,6 +704,139 @@ dofsum(const void *restrict values, oid 
}   \
} while (0)
 
+#define AGGR_USUM(TYPE1, TYPE2)
\
+   do {\
+   TYPE1 x;\
+   const TYPE1 *restrict vals = (const TYPE1 *) values;\
+   if (ngrp == 1 && ci->tpe == cand_dense) {   \
+   /* single group, no candidate list */   \
+   TYPE2 sum;  \
+   *algo = "sum: no nils, no candidates, no groups"; \
+   sum = 0;\
+   TIMEOUT_LOOP_IDX(i, ci->ncand, qry_ctx) {   \
+   x = vals[ci->seq + i - seqb];   \
+   ADD_WITH_CHECK(x, sum,  \
+  TYPE2, sum,  \
+  GDK_##TYPE2##_max,   \
+  goto overflow);  \
+   }   \
+   TIMEOUT_CHECK(qry_ctx,  \
+ GOTO_LABEL_TIMEOUT_HANDLER(bailout, 
qry_ctx)); \
+   *sums = sum;\
+   } else if (ngrp == 1) { \
+   /* single group, with candidate list */ \
+   TYPE2 sum;  \
+   *algo = "sum: no nils, with candidates, no groups"; \
+   sum = 0;\
+   TIMEOUT_LOOP_IDX(i, ci->ncand, qry_ctx) {   \
+   x = vals[canditer_next(ci) - seqb]; \
+   ADD_WITH_CHECK(x, sum,  \
+  TYPE2, sum,  \
+  GDK_##TYPE2##_max,   \
+  goto overflow);  \
+   }   \
+   TIMEOUT_CHECK(qry_ctx,  \
+ GOTO_LABEL_TIMEOUT_HANDLER(bailout, 
qry_ctx)); \
+   *sums = sum;\
+   } else if (ci->tpe == cand_dense) { \
+   /* multiple groups, no candidate list */\
+   *algo = "sum: no nils, no candidates, with groups"; \
+   TIMEOUT_LOOP_IDX(i, ci->ncand, qry_ctx) {   \
+   if (gids == NULL || \
+   (gids[i] >= min && gids[i] <= max)) { \
+   gid = gids ? gids[i] - min : (oid) i; \
+   x = vals[ci->seq + i - seqb];   \
+   ADD_WITH_CHECK( \
+   x,  \
+   sums[gid],  \
+   TYPE2,  \
+   sums[gid],  \
+   GDK_##TYPE2##_max,  \
+   goto overflow); \
+   }   \
+   }   \
+   TIMEOUT_CHECK(qry_ctx,  \
+ GOTO_LABEL_TIMEOUT_HANDLER(bailout, 
qry_ctx)); \
+   } else {\
+   /* multiple groups, with candidate list */  \
+   *algo = "sum: no nils, with candidates, with groups"; \
+   TIMEOUT_LOOP(ci->ncand, qry_ctx) {  \
+   i = canditer_next(ci) - seqb;   \
+   if (gids == NULL || \
+   (gids[i] >= min && gids[i] <= ma

MonetDB: default - Merge with Aug2024 branch.

2024-07-23 Thread Sjoerd Mullender via checkin-list
Changeset: 250f771255c3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/250f771255c3
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (135 lines):

diff --git a/common/stream/Tests/urlstream.py b/common/stream/Tests/urlstream.py
--- a/common/stream/Tests/urlstream.py
+++ b/common/stream/Tests/urlstream.py
@@ -9,25 +9,6 @@ import time
 
 OUTPUT = io.StringIO()
 
-def wait_for_server(timeout):
-deadline = time.time() + timeout
-while time.time() < deadline:
-if port == 0:
-time.sleep(0.25)
-continue
-s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-s.settimeout(0.1)
-try:
-s.connect(('localhost', port))
-break
-except ConnectionRefusedError:
-time.sleep(0.1)
-finally:
-s.close()
-else:
-print(f'Warning: waited {timeout} seconds for the server to start but 
could still not connect', file=OUTPUT)
-
-
 class Handler(http.server.BaseHTTPRequestHandler):
 def log_message(self, format, *args):
 # add a # at the beginning of the line to not mess up Mtest diffs
@@ -66,19 +47,23 @@ class Handler(http.server.BaseHTTPReques
 self.end_headers()
 self.wfile.write(b'NOT FOUND\n')
 
+b = threading.Barrier(2)
+
 def runserver():
 global port
 addr = ('127.0.0.1', 0)
 srv = http.server.HTTPServer(addr, Handler)
 port = srv.server_port
 print(f"Listening on {port}", file=OUTPUT)
+b.wait()
 srv.serve_forever()
 
 # Start the http server
 port = 0
 t = threading.Thread(target=lambda: runserver(), daemon=True)
 t.start()
-wait_for_server(5.0)
+# and wait for it to fill in the port
+b.wait()
 
 url = f'http://localhost:{port}'
 
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -817,11 +817,26 @@ COLcopy(BAT *b, int tt, bool writable, r
 * table and that would result in buckets containing values
 * beyond the original vheap that we're copying */
MT_lock_set(&b->theaplock);
+   BAT *pb = NULL, *pvb = NULL;
+   if (b->theap->parentid != b->batCacheid) {
+   pb = BBP_desc(b->theap->parentid);
+   MT_lock_set(&pb->theaplock);
+   }
+   if (b->tvheap &&
+   b->tvheap->parentid != b->batCacheid &&
+   b->tvheap->parentid != b->theap->parentid) {
+   pvb = BBP_desc(b->tvheap->parentid);
+   MT_lock_set(&pvb->theaplock);
+   }
bi = bat_iterator_nolock(b);
if (ATOMstorage(b->ttype) == TYPE_str && b->tvheap->free >= 
GDK_STRHASHSIZE)
memcpy(strhash, b->tvheap->base, GDK_STRHASHSIZE);
 
bat_iterator_incref(&bi);
+   if (pvb)
+   MT_lock_unset(&pvb->theaplock);
+   if (pb)
+   MT_lock_unset(&pb->theaplock);
MT_lock_unset(&b->theaplock);
 
/* first try case (1); create a view, possibly with different
diff --git a/gdk/gdk_calc_private.h b/gdk/gdk_calc_private.h
--- a/gdk/gdk_calc_private.h
+++ b/gdk/gdk_calc_private.h
@@ -36,7 +36,7 @@
 #include "gdk_cand.h"
 
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
-#define OP_WITH_CHECK(lft, rgt, dst, op, nil, max, on_overflow)
\
+#define OP_WITH_CHECK(lft, rgt, dst, op, max, on_overflow) \
do {\
if (__builtin_##op##_overflow(lft, rgt, &(dst)) ||  \
(dst) < -(max) || (dst) > (max)) {  \
@@ -68,7 +68,7 @@
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
 /* integer version using Gnu CC builtin function for overflow check */
 #define ADDI_WITH_CHECK(lft, rgt, TYPE3, dst, max, on_overflow)
\
-   OP_WITH_CHECK(lft, rgt, dst, add, TYPE3##_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, add, max, on_overflow)
 #else
 /* integer version using generic version */
 #define ADDI_WITH_CHECK(lft, rgt, TYPE3, dst, max, on_overflow) \
@@ -102,7 +102,7 @@
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
 /* integer version using Gnu CC builtin function for overflow check */
 #define SUBI_WITH_CHECK(lft, rgt, TYPE3, dst, max, on_overflow)
\
-   OP_WITH_CHECK(lft, rgt, dst, sub, TYPE3##_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, sub, max, on_overflow)
 #else
 /* integer version using generic version */
 #define SUBI_WITH_CHECK(lft, rgt, TYPE3, dst, max, on_overflow) \
@@ -130,9 +130,9 @@
 #ifdef HAVE___BUILTIN_ADD_OVERFLOW
 /* integer version using Gnu CC builtin function for overflow check */
 #define MULI4_WITH_CHECK(lft, rgt, TYPE3, dst, max, TYPE4, on_overflow) \
-   OP_WITH_CHECK(lft, rgt, dst, mul, TYPE3##_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, mul, max, on_overflow)
 #define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow)  \
-   OP_WITH_CHECK(lft, rgt, dst, mul, lng_nil, max, on_overflow)
+   OP_WITH_CHECK(lft, rgt, dst, mul, ma