MonetDB: Jun2023 - add missing component name

2023-07-12 Thread Niels Nes via checkin-list
Changeset: 5ad8bbd19001 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5ad8bbd19001
Modified Files:
gdk/CMakeLists.txt
Branch: Jun2023
Log Message:

add missing component name


diffs (25 lines):

diff --git a/gdk/CMakeLists.txt b/gdk/CMakeLists.txt
--- a/gdk/CMakeLists.txt
+++ b/gdk/CMakeLists.txt
@@ -138,9 +138,11 @@ endif()
 
 install(TARGETS
   bat
+  COMPONENT monetdb
   EXPORT gdkTargets
   RUNTIME
   DESTINATION ${CMAKE_INSTALL_BINDIR}
+  COMPONENT monetdb
   LIBRARY
   DESTINATION ${CMAKE_INSTALL_LIBDIR}
   COMPONENT monetdb
@@ -151,8 +153,7 @@ install(TARGETS
   PUBLIC_HEADER
   DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/monetdb
   COMPONENT monetdbdev
-  INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-  COMPONENT monetdbdev)
+  INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 install(EXPORT gdkTargets
   FILE gdkTargets.cmake
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - merged

2023-07-12 Thread Niels Nes via checkin-list
Changeset: 18a20334a698 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/18a20334a698
Branch: Jun2023
Log Message:

merged


diffs (truncated from 9143 to 300 lines):

diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c
--- a/gdk/gdk_firstn.c
+++ b/gdk/gdk_firstn.c
@@ -227,9 +227,9 @@ BATfirstn_unique(BATiter *bi, BAT *s, BU
 
if (n >= cnt) {
/* trivial: return all candidates */
-   if (lastp)
-   *lastp = 0;
bn = canditer_slice(&ci, 0, ci.ncand);
+   if (bn && lastp)
+   *lastp = oid_nil;
TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",s=" ALGOOPTBATFMT
  ",n=" BUNFMT " -> " ALGOOPTBATFMT
  " (trivial -- " LLFMT " usec)\n",
@@ -1061,7 +1061,7 @@ BATfirstn_grouped(BAT **topn, BAT **gids
BBPunfix(bn1->batCacheid);
if (bn == NULL)
return GDK_FAIL;
-   } else {
+   } else if (last != oid_nil) {
BAT *bn1, *bn2;
 
bn1 = bn;
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -683,7 +683,7 @@ ALGfirstn(Client cntxt, MalBlkPtr mb, Ma
bat *ret1, *ret2 = NULL;
bat bid, sid, gid;
BAT *b, *s = NULL, *g = NULL;
-   BAT *bn, *gn;
+   BAT *bn = NULL, *gn = NULL;
lng n;
bit asc, nilslast, distinct;
gdk_return rc;
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
@@ -1218,7 +1218,7 @@ exp_refers( sql_exp *p, sql_exp *c)
if (p->alias.rname && strcmp(p->alias.rname, c->l) != 0)
return 0;
// if the parent does NOT have a relation name alias 
compare his relation name with the child's
-   if (!p->alias.rname && strcmp(p->l, c->l) != 0)
+   if (!p->alias.rname && p->l && strcmp(p->l, c->l) != 0)
return 0;
}
return 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
@@ -4590,10 +4590,12 @@ rel_order_by(sql_query *query, sql_rel *
if ((selection = simple_selection(col)) != NULL) {
dnode *o = selection->h;
order = o->data.sym;
-   col = order->data.lval->h->data.sym;
+   if (order->data.lval->h->type == type_symbol)
+   col = order->data.lval->h->data.sym;
/* remove optional name from selection */
order->data.lval->h->next = NULL;
}
+
if (col->token == SQL_COLUMN || col->token == SQL_IDENT 
|| col->token == SQL_ATOM) {
exp_kind ek = {type_value, card_column, FALSE};
 
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -2342,7 +2342,14 @@ rel_set_type(visitor *v, sql_rel *rel)
if (te->type == e_convert) {
sql_exp *l = te->l;
if (l->type == e_column) {
-   sql_exp *e = 
rel_find_exp(rel->l, l);
+   sql_rel *sl = rel->l;
+   sql_exp *e = 
rel_find_exp(sl, l);
+   if (is_groupby(sl->op) 
&& exp_equal(e, l) == 0) {
+   sql_exp *e2 = 
list_find_exp(sl->r, l);
+   if (e2) {
+   e = e2;
+   }
+   }
sql_subtype *t = 
exp_subtype(e);
 
if (t && 
!t->type->localtype) {
diff --git a/sql/test/BugTracker-2023/Tests/All 
b/sql/test/BugTracker-2023/Tests/All
--- a/sql/test/BugTracker-2023/Tests/All
+++ b/sql/test/BugTracker-2023/Tests/All
@@ -9,3 +9,4 @@ empty-optimizer-crash-7384
 rollback-alter-drop-col-crash-7385
 view-on-alias-crash-7386
 alter-inc-seq-crash-7387
+misc-crashes-7390
diff --git a/sql/test/BugTracker-2023/Tests/misc-crashes-7390.test 
b/sql/test/BugTracker-2023/Tests/misc-crashes-7390.test
new file mode 100644

MonetDB: default - protect against missing stmt (is st_result is...

2023-07-12 Thread Niels Nes via checkin-list
Changeset: e6ebbbf25705 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e6ebbbf25705
Modified Files:
sql/backends/monet5/sql_statement.c
Branch: default
Log Message:

protect against missing stmt (is st_result is used with direct mal statement)


diffs (14 lines):

diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -4186,7 +4186,9 @@ schema_name(sql_allocator *sa, stmt *st)
return schema_name(sa, st->op1);
case st_alias:
/* there are no schema aliases, ie look into the base column */
-   return schema_name(sa, st->op1);
+   if (st->op1)
+   return schema_name(sa, st->op1);
+   return NULL;
case st_bat:
return st->op4.cval->t->s->base.name;
case st_atom:
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - fix schema_name for st_result

2023-07-12 Thread Niels Nes via checkin-list
Changeset: dc67ad68ad58 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/dc67ad68ad58
Modified Files:
sql/backends/monet5/sql_statement.c
Branch: default
Log Message:

fix schema_name for st_result


diffs (18 lines):

diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -4183,12 +4183,12 @@ schema_name(sql_allocator *sa, stmt *st)
case st_convert:
case st_Nop:
case st_aggr:
-   return schema_name(sa, st->op1);
-   case st_alias:
/* there are no schema aliases, ie look into the base column */
if (st->op1)
return schema_name(sa, st->op1);
return NULL;
+   case st_alias:
+   return schema_name(sa, st->op1);
case st_bat:
return st->op4.cval->t->s->base.name;
case st_atom:
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Free heap on failure.

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: 1833a77a18ed for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1833a77a18ed
Modified Files:
gdk/gdk_hash.c
Branch: Jun2023
Log Message:

Free heap on failure.


diffs (19 lines):

diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -141,8 +141,14 @@ HASHnew(Hash *h, int tpe, BUN size, BUN 
h->heaplink.dirty = true;
h->Link = h->heaplink.base;
}
-   if (HEAPalloc(&h->heapbckt, mask + HASH_HEADER_SIZE * SIZEOF_SIZE_T / 
h->width, h->width) != GDK_SUCCEED)
+   if (HEAPalloc(&h->heapbckt, mask + HASH_HEADER_SIZE * SIZEOF_SIZE_T / 
h->width, h->width) != GDK_SUCCEED) {
+   if (!bcktonly) {
+   HEAPfree(&h->heaplink, true);
+   h->heaplink.free = 0;
+   h->Link = NULL;
+   }
return GDK_FAIL;
+   }
h->heapbckt.free = mask * h->width + HASH_HEADER_SIZE * SIZEOF_SIZE_T;
h->heapbckt.dirty = true;
h->nbucket = mask;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Improve datasize counting code and don't atte...

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: 747aa0eba3b1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/747aa0eba3b1
Modified Files:
gdk/gdk_heap.c
Branch: Jun2023
Log Message:

Improve datasize counting code and don't attempt mmap twice.


diffs (276 lines):

diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -143,7 +143,7 @@ gdk_return
 HEAPalloc(Heap *h, size_t nitems, size_t itemsize)
 {
size_t size = 0;
-   QryCtx *qc = NULL;
+   QryCtx *qc = h->farmid == 1 ? MT_thread_get_qry_ctx() : NULL;
 
h->base = NULL;
h->size = 1;
@@ -165,7 +165,7 @@ HEAPalloc(Heap *h, size_t nitems, size_t
 h->size < ((GDK_mem_maxsize - allocated) >> 6))) {
h->storage = STORE_MEM;
size = h->size;
-   if (h->farmid == 1 && (qc = MT_thread_get_qry_ctx()) != NULL) {
+   if (qc != NULL) {
ATOMIC_BASE_TYPE sz = ATOMIC_ADD(&qc->datasize, size);
sz += size;
if (qc->maxmem > 0 && sz > qc->maxmem) {
@@ -174,22 +174,22 @@ HEAPalloc(Heap *h, size_t nitems, size_t
return GDK_FAIL;
}
}
-   h->base = GDKmalloc(h->size);
-   TRC_DEBUG(HEAP, "%s %zu %p\n", h->filename, h->size, h->base);
+   h->base = GDKmalloc(size);
+   TRC_DEBUG(HEAP, "%s %zu %p\n", h->filename, size, h->base);
+   if (h->base == NULL && qc != NULL)
+   ATOMIC_SUB(&qc->datasize, size);
}
 
-   char *nme = NULL;
-   if (!GDKinmemory(h->farmid) && h->base == NULL) {
-   nme = GDKfilepath(h->farmid, BATDIR, h->filename, NULL);
+   if (h->base == NULL && !GDKinmemory(h->farmid)) {
+   char *nme = GDKfilepath(h->farmid, BATDIR, h->filename, NULL);
if (nme == NULL)
return GDK_FAIL;
h->storage = STORE_MMAP;
h->size = (h->size + GDK_mmap_pagesize - 1) & 
~(GDK_mmap_pagesize - 1);
-   if (h->farmid == 1 && h->size > size &&
-   (qc != NULL || (qc = MT_thread_get_qry_ctx()) != NULL)) {
-   ATOMIC_BASE_TYPE sz = ATOMIC_ADD(&qc->datasize, h->size 
- size);
-   sz += h->size - size;
-   size = h->size;
+   size = h->size;
+   if (qc != NULL) {
+   ATOMIC_BASE_TYPE sz = ATOMIC_ADD(&qc->datasize, size);
+   sz += size;
if (qc->maxmem > 0 && sz > qc->maxmem) {
ATOMIC_SUB(&qc->datasize, size);
GDKerror("Query using too much memory.\n");
@@ -198,22 +198,20 @@ HEAPalloc(Heap *h, size_t nitems, size_t
}
h->base = HEAPcreatefile(NOFARM, &h->size, nme);
h->hasfile = true;
-   }
-   if (h->base == NULL) {
-   /* remove file we may just have created */
-   if (nme != NULL) {
-   /* file may or may not exist, depending on what
+   if (h->base == NULL) {
+   if (qc != NULL)
+   ATOMIC_SUB(&qc->datasize, size);
+   /* remove file we may just have created
+* it may or may not exist, depending on what
 * failed */
(void) MT_remove(nme);
GDKfree(nme);
h->hasfile = false; /* just removed it */
+   GDKerror("Insufficient space for HEAP of %zu bytes.", 
h->size);
+   return GDK_FAIL;
}
-   if (qc != NULL && size > 0)
-   ATOMIC_SUB(&qc->datasize, size);
-   GDKerror("Insufficient space for HEAP of %zu bytes.", h->size);
-   return GDK_FAIL;
+   GDKfree(nme);
}
-   GDKfree(nme);
h->newstorage = h->storage;
return GDK_SUCCEED;
 }
@@ -240,7 +238,8 @@ gdk_return
 HEAPextend(Heap *h, size_t size, bool mayshare)
 {
size_t osize = h->size;
-   QryCtx *qc = NULL;
+   size_t xsize;
+   QryCtx *qc = h->farmid == 1 ? MT_thread_get_qry_ctx() : NULL;
 
if (size <= h->size)
return GDK_SUCCEED; /* nothing to do */
@@ -271,12 +270,14 @@ HEAPextend(Heap *h, size_t size, bool ma
if (size == 0)
size = GDK_mmap_pagesize;
 
-   if (h->farmid == 1 && (qc = MT_thread_get_qry_ctx()) != NULL) {
-   ATOMIC_BASE_TYPE sz = ATOMIC_ADD(&qc->datasize, size - 
osize);
+   xsize = size - osize;
+
+   if (qc != NULL) {
+   ATOMIC_BASE_TYPE sz = ATOMIC_ADD(&qc->datasize, xsize);
sz += size - osize;

MonetDB: Jun2023 - More aggressively unload bats when virtual me...

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: 1a1b2cb7aed2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1a1b2cb7aed2
Modified Files:
gdk/gdk_bbp.c
Branch: Jun2023
Log Message:

More aggressively unload bats when virtual memory becomes tight.


diffs (38 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2915,13 +2915,18 @@ decref(bat i, bool logical, bool lock, c
/* we destroy transients asap and unload persistent bats only
 * if they have been made cold or are not dirty */
unsigned chkflag = BBPSYNCING;
-   if (b && GDKvm_cursize() < GDK_vm_maxsize) {
-   if (!locked) {
-   MT_lock_set(&b->theaplock);
-   locked = true;
-   }
-   if (((b->theap ? b->theap->size : 0) + (b->tvheap ? 
b->tvheap->size : 0)) < (GDK_vm_maxsize - GDKvm_cursize()) / 32)
-   chkflag |= BBPHOT;
+   size_t cursize;
+   bool swapdirty = false;
+   if (b) {
+   if ((cursize = GDKvm_cursize()) < (size_t) (GDK_vm_maxsize * 
0.75)) {
+   if (!locked) {
+   MT_lock_set(&b->theaplock);
+   locked = true;
+   }
+   if (((b->theap ? b->theap->size : 0) + (b->tvheap ? 
b->tvheap->size : 0)) < (GDK_vm_maxsize - cursize) / 32)
+   chkflag |= BBPHOT;
+   } else if (cursize > (size_t) (GDK_vm_maxsize * 0.85))
+   swapdirty = true;
}
/* only consider unloading if refs is 0; if, in addition, lrefs
 * is 0, we can definitely unload, else only if some more
@@ -2929,7 +2934,7 @@ decref(bat i, bool logical, bool lock, c
if (BBP_refs(i) == 0 &&
(BBP_lrefs(i) == 0 ||
 (b != NULL && b->theap != NULL
- ? (!BATdirty(b) &&
+ ? ((swapdirty || !BATdirty(b)) &&
 !(BBP_status(i) & chkflag) &&
 (BBP_status(i) & BBPPERSISTENT) &&
 /* cannot unload in-memory data */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - For small mallocs, ignore GDK_vm_maxsize.

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: de64b94dc5a9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/de64b94dc5a9
Modified Files:
gdk/gdk_utils.c
Branch: Jun2023
Log Message:

For small mallocs, ignore GDK_vm_maxsize.


diffs (33 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1904,6 +1904,9 @@ GDKvm_cursize(void)
 #define DEBUG_SPACE16
 #endif
 
+/* malloc smaller than this aren't subject to the GDK_vm_maxsize test */
+#define SMALL_MALLOC   256
+
 static void *
 GDKmalloc_internal(size_t size, bool clear)
 {
@@ -1924,7 +1927,8 @@ GDKmalloc_internal(size_t size, bool cle
return NULL;
}
 #endif
-   if (GDKvm_cursize() + size >= GDK_vm_maxsize &&
+   if (size > SMALL_MALLOC &&
+   GDKvm_cursize() + size >= GDK_vm_maxsize &&
!MT_thread_override_limits()) {
GDKerror("allocating too much memory\n");
return NULL;
@@ -2063,7 +2067,8 @@ GDKrealloc(void *s, size_t size)
nsize = (size + 7) & ~7;
asize = ((size_t *) s)[-1]; /* how much allocated last */
 
-   if (nsize > asize &&
+   if (size > SMALL_MALLOC &&
+   nsize > asize &&
GDKvm_cursize() + nsize - asize >= GDK_vm_maxsize &&
!MT_thread_override_limits()) {
GDKerror("allocating too much memory\n");
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Check that allocation succeeded.

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: 709b42ab5e6c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/709b42ab5e6c
Modified Files:
sql/backends/monet5/sql_statement.c
Branch: Jun2023
Log Message:

Check that allocation succeeded.


diffs (12 lines):

diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -3036,7 +3036,7 @@ stmt_append(backend *be, stmt *c, stmt *
MalBlkPtr mb = be->mb;
InstrPtr q = NULL;
 
-   if (c->nr < 0 || a->nr < 0)
+   if (c == NULL || a == NULL || c->nr < 0 || a->nr < 0)
return NULL;
q = newStmt(mb, batRef, appendRef);
q = pushArgument(mb, q, c->nr);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Free heap after failure.

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: 06cdc963c855 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/06cdc963c855
Modified Files:
gdk/gdk_bat.c
Branch: Jun2023
Log Message:

Free heap after failure.


diffs (16 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -283,10 +283,12 @@ COLnew2(oid hseq, int tt, BUN cap, role_
}
 
if (bn->tvheap && width == 0 && ATOMheap(tt, bn->tvheap, cap) != 
GDK_SUCCEED) {
+   HEAPfree(bn->theap, true);
goto bailout;
}
DELTAinit(bn);
if (BBPcacheit(bn, true) != GDK_SUCCEED) {
+   /* cannot happen, function always returns success */
goto bailout;
}
TRC_DEBUG(ALGO, "-> " ALGOBATFMT "\n", ALGOBATPAR(bn));
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Do some error checking.

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: 1b7960ab78a5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1b7960ab78a5
Modified Files:
monetdb5/optimizer/opt_mergetable.c
Branch: Jun2023
Log Message:

Do some error checking.


diffs (44 lines):

diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -401,7 +401,10 @@ mat_assign(MalBlkPtr mb, InstrPtr p, mat
for(int k=1; k < mat[m].mi->argc; k++) {
/* reuse inputs of old mat */
r = pushArgument(mb, r, getArg(mat[m].mi, k));
-   (void)setPartnr(ml, -1, getArg(mat[m].mi, k), k);
+   if (setPartnr(ml, -1, getArg(mat[m].mi, k), k)) {
+   freeInstruction(r);
+   return NULL;
+   }
}
if (mat_add(ml, r, mat_none, getFunctionId(p))) {
freeInstruction(r);
@@ -873,7 +876,7 @@ join_split(Client cntxt, InstrPtr p, int
len = strlen( getFunctionId(p) );
name = GDKmalloc(len+3);
if (!name)
-   return -1;
+   return -2;
strncpy(name, getFunctionId(p), len-7);
strcpy(name+len-7, "join");
 
@@ -929,6 +932,10 @@ mat_joinNxM(Client cntxt, MalBlkPtr mb, 
int split = join_split(cntxt, p, args);
int nr_mv1 = split;
 
+   if (split == -2) {
+   GDKfree(mats);
+   return -1;
+   }
l = newInstructionArgs(mb, matRef, packRef, mat[mv1].mi->argc * 
mat[mv2].mi->argc);
r = newInstructionArgs(mb, matRef, packRef, mat[mv1].mi->argc * 
mat[mv2].mi->argc);
if (l == NULL || r == NULL) {
@@ -2575,6 +2582,8 @@ OPTmergetableImplementation(Client cntxt
for (k = p->retc; msg == MAL_SUCCEED && kargc; k++) {
if((m=is_a_mat(getArg(p,k), &ml)) >= 0){
msg = mat_pack(mb, &ml, m);
+   if (msg)
+   break;
}
}
if (msg)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Slightly different way of recording that limi...

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: fe9d73aef611 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fe9d73aef611
Modified Files:
gdk/gdk_system.c
Branch: Jun2023
Log Message:

Slightly different way of recording that limits can be overridden temporarily.


diffs (76 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -199,7 +199,7 @@ static struct winthread {
char algorithm[512];/* the algorithm used in the last operation */
size_t algolen; /* length of string in .algorithm */
ATOMIC_TYPE exited;
-   bool detached:1, waiting:1;
+   bool detached:1, waiting:1, limit_override:1;
char threadname[MT_NAME_LEN];
QryCtx *qry_ctx;
 } *winthreads = NULL;
@@ -405,8 +405,15 @@ MT_thread_setworking(const char *work)
return;
struct winthread *w = TlsGetValue(threadslot);
 
-   if (w)
-   w->working = work;
+   if (w) {
+   if (work == NULL)
+   w->working = NULL;
+   else if (strcmp(work, "store locked") == 0)
+   w->limit_override = true;
+   else if (strcmp(work, "store unlocked") == 0)
+   w->limit_override = false;
+   else
+   w->working = work;
 }
 
 void
@@ -447,7 +454,7 @@ MT_thread_override_limits(void)
return false;
struct winthread *w = TlsGetValue(threadslot);
 
-   return w && w->working && strcmp(w->working, "store locked") == 0;
+   return w && w->limit_override;
 }
 
 static void
@@ -673,7 +680,7 @@ static struct posthread {
pthread_t tid;
MT_Id mtid;
ATOMIC_TYPE exited;
-   bool detached:1, waiting:1;
+   bool detached:1, waiting:1, limit_override:1;
QryCtx *qry_ctx;
 } *posthreads = NULL;
 static struct posthread mainthread = {
@@ -880,8 +887,16 @@ MT_thread_setworking(const char *work)
return;
struct posthread *p = pthread_getspecific(threadkey);
 
-   if (p)
-   p->working = work;
+   if (p) {
+   if (work == NULL)
+   p->working = NULL;
+   else if (strcmp(work, "store locked") == 0)
+   p->limit_override = true;
+   else if (strcmp(work, "store unlocked") == 0)
+   p->limit_override = false;
+   else
+   p->working = work;
+   }
 }
 
 void
@@ -922,7 +937,7 @@ MT_thread_override_limits(void)
return false;
struct posthread *p = pthread_getspecific(threadkey);
 
-   return p && p->working && strcmp(p->working, "store locked") == 0;
+   return p && p->limit_override;
 }
 
 #ifdef HAVE_PTHREAD_SIGMASK
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Lots of error checking.

2023-07-12 Thread Sjoerd Mullender via checkin-list
Changeset: 1556d7390b49 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1556d7390b49
Modified Files:
monetdb5/mal/mal_builder.c
monetdb5/mal/mal_instruction.c
monetdb5/optimizer/opt_mergetable.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/common/sql_list.c
Branch: Jun2023
Log Message:

Lots of error checking.


diffs (truncated from 951 to 300 lines):

diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c
--- a/monetdb5/mal/mal_builder.c
+++ b/monetdb5/mal/mal_builder.c
@@ -536,7 +536,6 @@ getStrConstant(MalBlkPtr mb, str val)
memcpy(cst.val.sval, val, cst.len); /* includes terminating \0 
*/
_t = defConstant(mb, TYPE_str, &cst);
}
-   assert(_t >= 0);
return _t;
 }
 
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -1191,8 +1191,8 @@ extendInstruction(MalBlkPtr mb, InstrPtr
 InstrPtr
 pushArgument(MalBlkPtr mb, InstrPtr p, int varid)
 {
-   if (p == NULL)
-   return NULL;
+   if (p == NULL || mb->errors)
+   return p;
if (varid < 0) {
/* leave everything as is in this exceptional programming error 
*/
mb->errors = createMalException(mb, 0, TYPE,"improper variable 
id");
@@ -1221,8 +1221,8 @@ setArgument(MalBlkPtr mb, InstrPtr p, in
 {
int i;
 
-   if (p == NULL)
-   return NULL;
+   if (p == NULL || mb->errors)
+   return p;
p = pushArgument(mb, p, varid); /* make space */
if (p == NULL)
return NULL;
@@ -1235,8 +1235,8 @@ setArgument(MalBlkPtr mb, InstrPtr p, in
 InstrPtr
 pushReturn(MalBlkPtr mb, InstrPtr p, int varid)
 {
-   if (p == NULL)
-   return NULL;
+   if (p == NULL || mb->errors)
+   return p;
if (p->retc == 1 && p->argv[0] == -1) {
p->argv[0] = varid;
return p;
@@ -1258,8 +1258,8 @@ pushArgumentId(MalBlkPtr mb, InstrPtr p,
 {
int v;
 
-   if (p == NULL)
-   return NULL;
+   if (p == NULL || mb->errors)
+   return p;
v = findVariable(mb, name);
if (v < 0) {
size_t namelen = strlen(name);
@@ -1348,28 +1348,27 @@ pushInstruction(MalBlkPtr mb, InstrPtr p
extra = mb->vsize - mb->vtop; // the extra variables already known
if (mb->stop + 1 >= mb->ssize) {
int s = ((mb->ssize + extra) / MALCHUNK + 1) * MALCHUNK;
-   if( resizeMalBlk(mb, s) < 0 ){
-   /* perhaps we can continue with a smaller increment.
-* But the block remains marked as faulty.
+   if (resizeMalBlk(mb, s) < 0) {
+   /* we are now left with the situation that the new
+* instruction is dangling.
+* The hack is to take an instruction out of the block 
that
+* is likely not referenced independently.
+* The last resort is to take the first, which should 
always
+* be there.
+* This assumes that no references are kept elsewhere 
to the
+* statement.
 */
-   if( resizeMalBlk(mb,mb->ssize + 1) < 0){
-   /* we are now left with the situation that the 
new instruction is dangling .
-* The hack is to take an instruction out of 
the block that is likely not referenced independently
-* The last resort is to take the first, which 
should always be there
-* This assumes that no references are kept 
elsewhere to the statement
-*/
-   for( i = 1; i < mb->stop; i++){
-   q= getInstrPtr(mb,i);
-   if( q->token == REMsymbol){
-   freeInstruction(q);
-   mb->stmt[i] = p;
-   return;
-   }
+   for (i = 1; i < mb->stop; i++) {
+   q = getInstrPtr(mb,i);
+   if (q->token == REMsymbol) {
+   freeInstruction(q);
+   mb->stmt[i] = p;
+   return;
}
-   freeInstruction(getInstrPtr(mb,0));
-   mb->stmt[0] = p;
-   return;
}
+   freeInstruction(getInstrPt

monetdb-java: default - Fixed javac version 20 compiler warning.

2023-07-12 Thread Martin van Dinther via checkin-list
Changeset: 1b9fe515f574 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/1b9fe515f574
Modified Files:
src/main/java/org/monetdb/client/JdbcClient.java
Branch: default
Log Message:

Fixed javac version 20 compiler warning.
The java.net.URL(String) constructor is deprecated since version 20.
It needs to be replaced by: java.net.URI(String).toURL() and some extra 
Exception catching.


diffs (87 lines):

diff --git a/src/main/java/org/monetdb/client/JdbcClient.java 
b/src/main/java/org/monetdb/client/JdbcClient.java
--- a/src/main/java/org/monetdb/client/JdbcClient.java
+++ b/src/main/java/org/monetdb/client/JdbcClient.java
@@ -26,6 +26,7 @@ import java.io.InputStreamReader;
 import java.io.File;
 import java.io.PrintWriter;
 import java.net.HttpURLConnection;
+import java.net.URI;
 import java.net.URL;
 import java.nio.charset.Charset;
 import java.sql.Connection;
@@ -580,42 +581,46 @@ public final class JdbcClient {
 */
static BufferedReader getReader(final String uri) throws Exception {
BufferedReader ret = null;
-   URL u = null;
 
-   // Try and parse as URL first
-   try {
-   u = new URL(uri);
-   } catch (java.net.MalformedURLException e) {
-   // no URL, try as file
+   if (uri.contains(":")) {
+   // Try and parse as URL
try {
-   ret = new BufferedReader(new 
java.io.FileReader(uri));
-   } catch (java.io.FileNotFoundException fnfe) {
-   // the message is descriptive enough, adds "(No 
such file
-   // or directory)" itself.
-   throw new Exception(fnfe.getMessage());
+   // Note: as of Java version 20 
java.net.URL(String) constructor is deprecated.
+   // 
https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/net/URL.html#%3Cinit%3E(java.lang.String)
+   final URI u = new java.net.URI(uri);
+   // the URL must start with a scheme such as: 
"http:" or "https:" else u.toURL() errors
+   if (u.isAbsolute()) {
+   final URL url = u.toURL();
+   
HttpURLConnection.setFollowRedirects(true);
+   final HttpURLConnection con = 
(HttpURLConnection)url.openConnection();
+   con.setRequestMethod("GET");
+   final String ct = con.getContentType();
+   if ("application/x-gzip".equals(ct)) {
+   // open gzip stream
+   ret = new BufferedReader(new 
InputStreamReader(
+   new 
java.util.zip.GZIPInputStream(con.getInputStream(;
+   } else {
+   // text/plain otherwise just 
attempt to read as is
+   ret = new BufferedReader(new 
InputStreamReader(con.getInputStream()));
+   }
+   }
+   } catch (IOException e) {
+   // failed to open the url
+   throw new Exception("No such http host/file: " 
+ e.getMessage());
+   } catch (Exception e) {
+   // this is an exception that comes from deep ...
+   throw new Exception("Invalid URL: " + uri + 
"\n" + e.getMessage());
}
}
 
if (ret == null) {
+   // uri doesn't contain a ":" or is not an URL, so 
probably a file name
try {
-   HttpURLConnection.setFollowRedirects(true);
-   final HttpURLConnection con = 
(HttpURLConnection)u.openConnection();
-   con.setRequestMethod("GET");
-   final String ct = con.getContentType();
-   if ("application/x-gzip".equals(ct)) {
-   // open gzip stream
-   ret = new BufferedReader(new 
InputStreamReader(
-   new 
java.util.zip.GZIPInputStream(con.getInputStream(;
-   } else {
-   // text/plain otherwise just attempt to 
read as is
-   ret = new BufferedReader(new 
InputStreamReader(con.getInputStream()));
-  

MonetDB: Jun2023 - Fix compilation error on windows

2023-07-12 Thread Martin van Dinther via checkin-list
Changeset: 26f5c9c672f3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/26f5c9c672f3
Modified Files:
gdk/gdk_system.c
Branch: Jun2023
Log Message:

Fix compilation error on windows


diffs (11 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -414,6 +414,7 @@ MT_thread_setworking(const char *work)
w->limit_override = false;
else
w->working = work;
+   }
 }
 
 void
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org