MonetDB: default - Better cleanup of dataflow threads.

2023-08-30 Thread Sjoerd Mullender via checkin-list
Changeset: 3e625a4c333d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3e625a4c333d
Modified Files:
monetdb5/mal/mal_dataflow.c
Branch: default
Log Message:

Better cleanup of dataflow threads.


diffs (92 lines):

diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -82,7 +82,7 @@ typedef struct DATAFLOW {
 
 struct worker {
MT_Id id;
-   enum { WAITING, RUNNING, FREE, EXITED } flag;
+   enum { WAITING, RUNNING, FREE, EXITED, FINISHING } flag;
ATOMIC_PTR_TYPE cntxt;  /* client we do work for (NULL -> any) 
*/
MT_Sema s;
struct worker *next;
@@ -245,6 +245,7 @@ static void
 DFLOWworker(void *T)
 {
struct worker *t = (struct worker *) T;
+   bool locked = false;
 #ifdef _MSC_VER
srand((unsigned int) GDKusec());
 #endif
@@ -411,20 +412,8 @@ DFLOWworker(void *T)
}
}
MT_lock_set();
-   if (GDKexiting() || ATOMIC_GET()) {
-   MT_lock_unset();
-   break;
-   }
-   if (free_count >= free_max) {
-   struct worker **tp = 
-   while (*tp && *tp != t)
-   tp = &(*tp)->next;
-   assert(*tp && *tp == t);
-   *tp = t->next;
-   t->flag = EXITED;
-   t->next = exited_workers;
-   exited_workers = t;
-   MT_lock_unset();
+   if (GDKexiting() || ATOMIC_GET() || free_count >= 
free_max) {
+   locked = true;
break;
}
free_count++;
@@ -442,6 +431,19 @@ DFLOWworker(void *T)
break;
assert(t->flag == WAITING);
}
+   if (!locked)
+   MT_lock_set();
+   if (t->flag != FINISHING) {
+   struct worker **tp = t->flag == FREE ? _workers : 
+   while (*tp && *tp != t)
+   tp = &(*tp)->next;
+   assert(*tp && *tp == t);
+   *tp = t->next;
+   t->flag = EXITED;
+   t->next = exited_workers;
+   exited_workers = t;
+   }
+   MT_lock_unset();
GDKsetbuf(NULL);
 }
 
@@ -747,6 +749,7 @@ DFLOWscheduler(DataFlow flow, struct wor
 static inline void
 finish_worker(struct worker *t)
 {
+   t->flag = FINISHING;
MT_lock_unset();
MT_join_thread(t->id);
MT_sema_destroy(>s);
@@ -944,6 +947,8 @@ stopMALdataflow(void)
}
while (free_workers) {
struct worker *t = free_workers;
+   assert(free_count > 0);
+   free_count--;
free_workers = free_workers->next;
MT_sema_up(>s);
finish_worker(t);
@@ -953,6 +958,11 @@ stopMALdataflow(void)
workers = workers->next;
finish_worker(t);
}
+   while (exited_workers) {
+   struct worker *t = exited_workers;
+   exited_workers = exited_workers->next;
+   finish_worker(t);
+   }
MT_lock_unset();
}
 }
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch.

2023-08-30 Thread Sjoerd Mullender via checkin-list
Changeset: e71a4709540b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e71a4709540b
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (24 lines):

diff --git a/sql/test/BugTracker-2020/Tests/All 
b/sql/test/BugTracker-2020/Tests/All
--- a/sql/test/BugTracker-2020/Tests/All
+++ b/sql/test/BugTracker-2020/Tests/All
@@ -26,7 +26,7 @@ table-udf-column-descriptor.Bug-6964
 table-udf-distinct.Bug-6965
 table-udf-on-remote.Bug-6971
 integers-intervals.Bug-6979
-KNOWNFAIL?wrong-key-error.Bug-6982
+wrong-key-error.Bug-6982
 window-function-order.Bug-6997
 semijoin.Bug-7001
 decimal-multiplication.Bug-7003
diff --git a/sql/test/BugTracker-2021/Tests/All 
b/sql/test/BugTracker-2021/Tests/All
--- a/sql/test/BugTracker-2021/Tests/All
+++ b/sql/test/BugTracker-2021/Tests/All
@@ -1,7 +1,7 @@
 update-from-count.Bug-7079
 remote-table-ranges.Bug-7089
 #KNOWNFAIL?query-too-complex.Bug-7092  # this is a feature request rather than 
a bug
-KNOWNFAIL?remote-table-rollback.Bug-7094
+remote-table-rollback.Bug-7094
 ntile-wrong-result.Bug-7104
 union-groupby.Bug-7108
 merge-stmt.wrong-error.Bug-7109
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Refinement of fix for bug #7400.

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

Refinement of fix for bug #7400.
Ignore setting of memory.low, I don't think it's relevant.
memory.swap.max is just swap space, so add it to memory.high to get the
vm limit.
Note, all of this may not be the right thing to do since we're ignoring
the fact that we use file-backed mmaps.


diffs (55 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -689,32 +689,35 @@ MT_init(void)
/* assume "max" if not a number */
fclose(f);
}
-   /* soft low limit */
-   strcpy(q, "memory.low");
-   f = fopen(pth, "r");
-   if (f != NULL) {
-   if (fscanf(f, "%" SCNu64, ) == 1
-   && mem > 0
-   && mem < (uint64_t) _MT_pagesize * 
_MT_npages) {
-   _MT_npages = (size_t) (mem / 
_MT_pagesize);
-   }
-   success = true;
-   /* assume "max" if not a number */
-   fclose(f);
-   }
-   /* limit of memory+swap usage
-* we use this as maximum virtual memory size */
+   /* limit of swap usage, hard limit
+* we use this, together with
+* memory.high, as maximum virtual
+* memory size */
strcpy(q, "memory.swap.max");
f = fopen(pth, "r");
if (f != NULL) {
if (fscanf(f, "%" SCNu64, ) == 1
&& mem > 0
-   && mem < (uint64_t) GDK_vm_maxsize) 
{
+   && (mem += _MT_npages * 
_MT_pagesize) < (uint64_t) GDK_vm_maxsize) {
GDK_vm_maxsize = (size_t) mem;
}
success = true;
fclose(f);
}
+#if 0 /* not sure about using this one */
+   /* limit of swap usage, soft limit */
+   strcpy(q, "memory.swap.high");
+   f = fopen(pth, "r");
+   if (f != NULL) {
+   if (fscanf(f, "%" SCNu64, ) == 1
+   && mem > 0
+   && (mem += _MT_npages * 
_MT_pagesize) < (uint64_t) GDK_vm_maxsize) {
+   GDK_vm_maxsize = (size_t) mem;
+   }
+   success = true;
+   fclose(f);
+   }
+#endif
} else {
/* cgroup v1 entry */
p = strchr(buf, ':');
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Push "virtualizing" certain types of join res...

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

Push "virtualizing" certain types of join results down.


diffs (49 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -43,7 +43,7 @@
  * BATsemijoin
  * equi-join, but the left output is sorted, and if there are
  * multiple matches, only one is returned (i.e., the left output
- * is also key)
+ * is also key, making it a candidate list)
  * BATthetajoin
  * theta-join: an extra operator must be provided encoded as an
  * integer (macros JOIN_EQ, JOIN_NE, JOIN_LT, JOIN_LE, JOIN_GT,
@@ -3768,7 +3768,8 @@ bitmaskjoin(BAT *l, BAT *r,
  * semi: semi join: return one of potentially more than one matches;
  * only_misses: difference: list rows without match on the right;
  * not_in: for implementing NOT IN: if nil on right then there are no matches;
- * max_one: error if there is more than one match. */
+ * max_one: error if there is more than one match;
+ * min_one: error if there are no matches. */
 static gdk_return
 leftjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr,
 bool nil_matches, bool nil_on_miss, bool semi, bool only_misses,
@@ -4025,6 +4026,8 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
   doreturn:
BBPreclaim(lp);
BBPreclaim(rp);
+   if (rc == GDK_SUCCEED && (semi | only_misses))
+   *r1p = virtualize(*r1p);
return rc;
 }
 
@@ -4080,7 +4083,7 @@ BATintersect(BAT *l, BAT *r, BAT *sl, BA
 false, true, false, false, max_one, false,
 estimate, __func__,
 GDK_TRACER_TEST(M_DEBUG, ALGO) ? GDKusec() : 0) == 
GDK_SUCCEED)
-   return virtualize(bn);
+   return bn;
return NULL;
 }
 
@@ -4097,7 +4100,7 @@ BATdiff(BAT *l, BAT *r, BAT *sl, BAT *sr
 false, false, true, not_in, false, false,
 estimate, __func__,
 GDK_TRACER_TEST(M_DEBUG, ALGO) ? GDKusec() : 0) == 
GDK_SUCCEED)
-   return virtualize(bn);
+   return bn;
return NULL;
 }
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Count copy-on-write memory maps towards mallo...

2023-09-06 Thread Sjoerd Mullender via checkin-list
Changeset: 7145f5afe4d8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7145f5afe4d8
Modified Files:
buildtools/coverity_model.c
clients/Tests/exports.stable.out
gdk/gdk_heap.c
gdk/gdk_posix.h
gdk/gdk_utils.c
gdk/gdk_utils.h
monetdb5/modules/mal/mal_io.c
Branch: default
Log Message:

Count copy-on-write memory maps towards malloced memory.
This means that GDK_vm_cursize is exclusively file-backed memory maps.


diffs (281 lines):

diff --git a/buildtools/coverity_model.c b/buildtools/coverity_model.c
--- a/buildtools/coverity_model.c
+++ b/buildtools/coverity_model.c
@@ -126,7 +126,7 @@ GDKmmap(const char *path, int mode, size
 }
 
 gdk_return
-GDKmunmap(void *p, size_t size)
+GDKmunmap(void *p, int mode, size_t size)
 {
int failed;
__coverity_free__(p);
@@ -139,7 +139,7 @@ GDKmremap(const char *path, int mode, vo
 {
void *p = GDKmmap(path, mode, new_size);
if (p) {
-   (void) GDKmunmap(old_address, old_size);
+   (void) GDKmunmap(old_address, mode, old_size);
}
return p;
 }
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -299,7 +299,7 @@ size_t GDKmem_cursize(void);
 gdk_return GDKmergeidx(BAT *b, BAT **a, int n_ar);
 void *GDKmmap(const char *path, int mode, size_t len) 
__attribute__((__warn_unused_result__));
 int GDKms(void);
-gdk_return GDKmunmap(void *addr, size_t len);
+gdk_return GDKmunmap(void *addr, int mode, size_t len);
 int GDKnr_threads;
 void GDKprepareExit(void);
 void GDKprintinfo(void);
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -687,7 +687,11 @@ HEAPfree(Heap *h, bool rmheap)
//heap is stored in regular C memory rather than GDK 
memory,so we call free()
free(h->base);
} else if (h->storage != STORE_NOWN) {  /* mapped file, or 
STORE_PRIV */
-   gdk_return ret = GDKmunmap(h->base, h->size);
+   gdk_return ret = GDKmunmap(h->base,
+  h->storage == STORE_PRIV ?
+  MMAP_COPY | MMAP_READ | 
MMAP_WRITE :
+  MMAP_READ | MMAP_WRITE,
+  h->size);
 
if (ret != GDK_SUCCEED) {
GDKsyserror("HEAPfree: %s was not mapped\n",
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -35,12 +35,6 @@
 #include 
 #endif
 
-/*
- * @- virtual memory
- */
-#define MT_VMUNITLOG   16
-#define MT_VMUNITSIZE  (1 << MT_VMUNITLOG)
-
 /* make sure POSIX_MADV_* and posix_madvise() are defined somehow */
 #ifdef HAVE_SYS_MMAN_H
 # ifndef __USE_BSD
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -452,7 +452,7 @@ size_t GDK_mmap_pagesize = MMAP_PAGESIZE
 size_t GDK_mem_maxsize = GDK_VM_MAXSIZE;
 size_t GDK_vm_maxsize = GDK_VM_MAXSIZE;
 
-#define SEG_SIZE(x,y)  ((x)+(((x)&((1<<(y))-1))?(1<<(y))-((x)&((1<<(y))-1)):0))
+#define SEG_SIZE(x)((ssize_t) (((x) + _MT_pagesize - 1) & ~(_MT_pagesize - 
1)))
 
 /* This block is to provide atomic addition and subtraction to select
  * variables.  We use intrinsic functions (recognized and inlined by
@@ -1666,13 +1666,30 @@ GDKvm_cursize(void)
 
 #define heapinc(_memdelta) \
ATOMIC_ADD(_mallocedbytes_estimate, _memdelta)
+#ifndef NDEBUG
+#define heapdec(_memdelta) 
\
+   do {\
+   ATOMIC_BASE_TYPE old = ATOMIC_ADD(_mallocedbytes_estimate, 
_memdelta); \
+   assert(old >= (ATOMIC_BASE_TYPE) _memdelta);\
+   } while (0)
+#else
 #define heapdec(_memdelta) \
ATOMIC_SUB(_mallocedbytes_estimate, _memdelta)
+#endif
 
 #define meminc(vmdelta)
\
-   ATOMIC_ADD(_vm_cursize, (ssize_t) SEG_SIZE((vmdelta), MT_VMUNITLOG))
+   ATOMIC_ADD(_vm_cursize, SEG_SIZE(vmdelta))
+#ifndef NDEBUG
 #define memdec(vmdelta)
\
-   ATOMIC_SUB(_vm_cursize, (ssize_t) SEG_SIZE((vmdelta), MT_VMUNITLOG))
+   do {\
+   ssize_t diff = SEG_SIZE(vmdelta);   \
+   ATOMIC_BASE_TYPE old = ATOMIC_SUB(_vm_cursize, diff); \
+   assert(old >= (ATOMIC_BASE_TYPE) diff); \
+   } while (0)
+#else
+#define memdec(vmdelta)
\
+   

MonetDB: default - Merge with Jun2023 branch.

2023-09-06 Thread Sjoerd Mullender via checkin-list
Changeset: 5e34c2c93877 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5e34c2c93877
Modified Files:
gdk/gdk_join.c
gdk/gdk_private.h
gdk/gdk_utils.c
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (198 lines):

diff --git a/ChangeLog.Jun2023 b/ChangeLog.Jun2023
--- a/ChangeLog.Jun2023
+++ b/ChangeLog.Jun2023
@@ -1,6 +1,10 @@
 # ChangeLog file for devel
 # This file is updated with Maddlog
 
+* Wed Aug 30 2023 Sjoerd Mullender 
+- Do a lot more error checking, mostly for allocation failures.  More is
+  still needed, though.
+
 * Thu Aug 10 2023 Panagiotis Koutsourakis 
 - Improve performance of the ILIKE operator when the pattern contains only
   ASCII characters. In this case we do not need to treat any characters as
diff --git a/debian/monetdb5-sql.README.Debian 
b/debian/monetdb5-sql.README.Debian
--- a/debian/monetdb5-sql.README.Debian
+++ b/debian/monetdb5-sql.README.Debian
@@ -2,7 +2,16 @@
 Usage
 =
 
-There are multiple ways to use MonetDB5-sql, but this is the most Debianic.
+There are multiple ways to use MonetDB5-sql.
+
+The modern way is to do:
+
+ * Enable and start MonetDB in one go::
+
+   $ sudo systemctl enable --now monetdbd.service
+
+This is the old way using System V init scripts, incompatible with the
+above:
 
  * Set STARTUP to "yes" in /etc/default/monetdb5-sql
 
@@ -10,7 +19,10 @@ There are multiple ways to use MonetDB5-
  
$ sudo /etc/init.d/monetdb5-sql start
 
- * Add yourself to the "monetdb" group::
+In either case, do this:
+
+ * Add yourself to the "monetdb" group (after this, logout and back in
+   for this to take effect)::
 
$ sudo addgroup `whoami` monetdb
 
diff --git a/gdk/ChangeLog.Jun2023 b/gdk/ChangeLog.Jun2023
--- a/gdk/ChangeLog.Jun2023
+++ b/gdk/ChangeLog.Jun2023
@@ -1,3 +1,18 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Wed Aug 30 2023 Sjoerd Mullender 
+- Only check for virtual memory limits when creating or growing bats,
+  not for general memory allocations.  There is (still) too much code
+  that doesn't properly handle failing allocations, so we need to avoid
+  those as much as possible.  This has mostly an effect if there are
+  virtual memory size restrictions imposed by cgroups (memory.swap.max
+  in cgroups v2, memory.memsw.limit_in_bytes in cgroups v1).
+- The low-level commit turned out to always commit every persistent bat
+  in the system.  There is no need for that, it should only commit bats
+  that were changed.  This has now been fixed.
+- Implemented timeout/exit checks in a bunch more operators.  Long(er)
+  running operators occasionally check whether they're taking too long
+  (past a user-specified timeout) or whether the server is exiting.
+  This is now done in more places.
+
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -43,7 +43,7 @@
  * BATsemijoin
  * equi-join, but the left output is sorted, and if there are
  * multiple matches, only one is returned (i.e., the left output
- * is also key)
+ * is also key, making it a candidate list)
  * BATthetajoin
  * theta-join: an extra operator must be provided encoded as an
  * integer (macros JOIN_EQ, JOIN_NE, JOIN_LT, JOIN_LE, JOIN_GT,
@@ -3768,7 +3768,8 @@ bitmaskjoin(BAT *l, BAT *r,
  * semi: semi join: return one of potentially more than one matches;
  * only_misses: difference: list rows without match on the right;
  * not_in: for implementing NOT IN: if nil on right then there are no matches;
- * max_one: error if there is more than one match. */
+ * max_one: error if there is more than one match;
+ * min_one: error if there are no matches. */
 static gdk_return
 leftjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr,
 bool nil_matches, bool nil_on_miss, bool semi, bool only_misses,
@@ -4025,6 +4026,8 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
   doreturn:
BBPreclaim(lp);
BBPreclaim(rp);
+   if (rc == GDK_SUCCEED && (semi | only_misses))
+   *r1p = virtualize(*r1p);
return rc;
 }
 
@@ -4080,7 +4083,7 @@ BATintersect(BAT *l, BAT *r, BAT *sl, BA
 false, true, false, false, max_one, false,
 estimate, __func__,
 GDK_TRACER_TEST(M_DEBUG, ALGO) ? GDKusec() : 0) == 
GDK_SUCCEED)
-   return virtualize(bn);
+   return bn;
return NULL;
 }
 
@@ -4097,7 +4100,7 @@ BATdiff(BAT *l, BAT *r, BAT *sl, BAT *sr
 false, false, true, not_in, false, false,
 estimate, __func__,
 GDK_TRACER_TEST(M_DEBUG, ALGO) ? GDKusec() : 0) == 
GDK_SUCCEED)
-   return virtualize(bn);
+   return bn;
return NULL;
 }
 
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -24,7 +24,7 @@
 #define PERSISTENTSTRIMP 1
 
 /* only check whether we exceed gdk_vm_maxsize when allocating heaps */

MonetDB: Jun2023 - Ignore cgroup settings that are 0.

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

Ignore cgroup settings that are 0.
This should fix bug #7400.


diffs (68 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -667,7 +667,9 @@ MT_init(void)
f = fopen(pth, "r");
}
if (f != NULL) {
-   if (fscanf(f, "%" SCNu64, ) == 1 && 
mem < (uint64_t) _MT_pagesize * _MT_npages) {
+   if (fscanf(f, "%" SCNu64, ) == 1
+   && mem > 0
+   && mem < (uint64_t) _MT_pagesize * 
_MT_npages) {
_MT_npages = (size_t) (mem / 
_MT_pagesize);
}
success = true;
@@ -678,7 +680,9 @@ MT_init(void)
strcpy(q, "memory.high");
f = fopen(pth, "r");
if (f != NULL) {
-   if (fscanf(f, "%" SCNu64, ) == 1 && 
mem < (uint64_t) _MT_pagesize * _MT_npages) {
+   if (fscanf(f, "%" SCNu64, ) == 1
+   && mem > 0
+   && mem < (uint64_t) _MT_pagesize * 
_MT_npages) {
_MT_npages = (size_t) (mem / 
_MT_pagesize);
}
success = true;
@@ -689,7 +693,9 @@ MT_init(void)
strcpy(q, "memory.low");
f = fopen(pth, "r");
if (f != NULL) {
-   if (fscanf(f, "%" SCNu64, ) == 1 && 
mem > 0 && mem < (uint64_t) _MT_pagesize * _MT_npages) {
+   if (fscanf(f, "%" SCNu64, ) == 1
+   && mem > 0
+   && mem < (uint64_t) _MT_pagesize * 
_MT_npages) {
_MT_npages = (size_t) (mem / 
_MT_pagesize);
}
success = true;
@@ -702,6 +708,7 @@ MT_init(void)
f = fopen(pth, "r");
if (f != NULL) {
if (fscanf(f, "%" SCNu64, ) == 1
+   && mem > 0
&& mem < (uint64_t) GDK_vm_maxsize) 
{
GDK_vm_maxsize = (size_t) mem;
}
@@ -735,6 +742,7 @@ MT_init(void)
}
if (f != NULL) {
if (fscanf(f, "%" SCNu64, ) == 1
+   && mem > 0
&& mem < (uint64_t) _MT_pagesize * 
_MT_npages) {
_MT_npages = (size_t) (mem / 
_MT_pagesize);
}
@@ -756,6 +764,7 @@ MT_init(void)
}
if (f != NULL) {
if (fscanf(f, "%" SCNu64, ) == 1
+   && mem > 0
&& mem < (uint64_t) _MT_pagesize * 
_MT_npages) {
_MT_npages = (size_t) (mem / 
_MT_pagesize);
}
@@ -778,6 +787,7 @@ MT_init(void)
}
if (f != NULL) {
if (fscanf(f, "%" SCNu64, ) == 1
+   && mem > 0
&& mem < (uint64_t) GDK_vm_maxsize) 
{
GDK_vm_maxsize = (size_t) mem;
}
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: groupjoin - Merge with default branch.

2023-09-06 Thread Sjoerd Mullender via checkin-list
Changeset: 8788387b1c06 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8788387b1c06
Branch: groupjoin
Log Message:

Merge with default branch.


diffs (truncated from 390 to 300 lines):

diff --git a/ChangeLog.Jun2023 b/ChangeLog.Jun2023
--- a/ChangeLog.Jun2023
+++ b/ChangeLog.Jun2023
@@ -1,6 +1,10 @@
 # ChangeLog file for devel
 # This file is updated with Maddlog
 
+* Wed Aug 30 2023 Sjoerd Mullender 
+- Do a lot more error checking, mostly for allocation failures.  More is
+  still needed, though.
+
 * Thu Aug 10 2023 Panagiotis Koutsourakis 
 - Improve performance of the ILIKE operator when the pattern contains only
   ASCII characters. In this case we do not need to treat any characters as
diff --git a/debian/monetdb5-sql.README.Debian 
b/debian/monetdb5-sql.README.Debian
--- a/debian/monetdb5-sql.README.Debian
+++ b/debian/monetdb5-sql.README.Debian
@@ -2,7 +2,16 @@
 Usage
 =
 
-There are multiple ways to use MonetDB5-sql, but this is the most Debianic.
+There are multiple ways to use MonetDB5-sql.
+
+The modern way is to do:
+
+ * Enable and start MonetDB in one go::
+
+   $ sudo systemctl enable --now monetdbd.service
+
+This is the old way using System V init scripts, incompatible with the
+above:
 
  * Set STARTUP to "yes" in /etc/default/monetdb5-sql
 
@@ -10,7 +19,10 @@ There are multiple ways to use MonetDB5-
  
$ sudo /etc/init.d/monetdb5-sql start
 
- * Add yourself to the "monetdb" group::
+In either case, do this:
+
+ * Add yourself to the "monetdb" group (after this, logout and back in
+   for this to take effect)::
 
$ sudo addgroup `whoami` monetdb
 
diff --git a/gdk/ChangeLog.Jun2023 b/gdk/ChangeLog.Jun2023
--- a/gdk/ChangeLog.Jun2023
+++ b/gdk/ChangeLog.Jun2023
@@ -1,3 +1,18 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Wed Aug 30 2023 Sjoerd Mullender 
+- Only check for virtual memory limits when creating or growing bats,
+  not for general memory allocations.  There is (still) too much code
+  that doesn't properly handle failing allocations, so we need to avoid
+  those as much as possible.  This has mostly an effect if there are
+  virtual memory size restrictions imposed by cgroups (memory.swap.max
+  in cgroups v2, memory.memsw.limit_in_bytes in cgroups v1).
+- The low-level commit turned out to always commit every persistent bat
+  in the system.  There is no need for that, it should only commit bats
+  that were changed.  This has now been fixed.
+- Implemented timeout/exit checks in a bunch more operators.  Long(er)
+  running operators occasionally check whether they're taking too long
+  (past a user-specified timeout) or whether the server is exiting.
+  This is now done in more places.
+
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -43,7 +43,7 @@
  * BATsemijoin
  * equi-join, but the left output is sorted, and if there are
  * multiple matches, only one is returned (i.e., the left output
- * is also key)
+ * is also key, making it a candidate list)
  * BATthetajoin
  * theta-join: an extra operator must be provided encoded as an
  * integer (macros JOIN_EQ, JOIN_NE, JOIN_LT, JOIN_LE, JOIN_GT,
@@ -3768,7 +3768,8 @@ bitmaskjoin(BAT *l, BAT *r,
  * semi: semi join: return one of potentially more than one matches;
  * only_misses: difference: list rows without match on the right;
  * not_in: for implementing NOT IN: if nil on right then there are no matches;
- * max_one: error if there is more than one match. */
+ * max_one: error if there is more than one match;
+ * min_one: error if there are no matches. */
 static gdk_return
 leftjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr,
 bool nil_matches, bool nil_on_miss, bool semi, bool only_misses,
@@ -4025,6 +4026,8 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
   doreturn:
BBPreclaim(lp);
BBPreclaim(rp);
+   if (rc == GDK_SUCCEED && (semi | only_misses))
+   *r1p = virtualize(*r1p);
return rc;
 }
 
@@ -4080,7 +4083,7 @@ BATintersect(BAT *l, BAT *r, BAT *sl, BA
 false, true, false, false, max_one, false,
 estimate, __func__,
 GDK_TRACER_TEST(M_DEBUG, ALGO) ? GDKusec() : 0) == 
GDK_SUCCEED)
-   return virtualize(bn);
+   return bn;
return NULL;
 }
 
@@ -4097,7 +4100,7 @@ BATdiff(BAT *l, BAT *r, BAT *sl, BAT *sr
 false, false, true, not_in, false, false,
 estimate, __func__,
 GDK_TRACER_TEST(M_DEBUG, ALGO) ? GDKusec() : 0) == 
GDK_SUCCEED)
-   return virtualize(bn);
+   return bn;
return NULL;
 }
 
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -24,7 +24,7 @@
 #define PERSISTENTSTRIMP 1
 
 /* only check whether we exceed gdk_vm_maxsize when allocating heaps */
-/* #define SIZE_CHECK_IN_HEAPS_ONLY 1 */
+#define 

MonetDB: Jun2023 - Don't try to trim too much under heavy load w...

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

Don't try to trim too much under heavy load when there is nothing left to trim.


diffs (51 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1467,10 +1467,11 @@ movestrbats(void)
 }
 #endif
 
-static void
+static bool
 BBPtrim(bool aggressive)
 {
int n = 0;
+   bool changed = false;
unsigned flag = BBPUNLOADING | BBPSYNCING | BBPSAVING;
if (!aggressive)
flag |= BBPHOT;
@@ -1501,16 +1502,19 @@ BBPtrim(bool aggressive)
if (BBPfree(b) != GDK_SUCCEED)
GDKerror("unload failed for bat %d", bid);
n++;
+   changed = true;
}
BBPtmunlock();
}
TRC_DEBUG(BAT_, "unloaded %d bats%s\n", n, aggressive ? " (also hot)" : 
"");
+   return changed;
 }
 
 static void
 BBPmanager(void *dummy)
 {
(void) dummy;
+   bool changed = true;
 
for (;;) {
int n = 0;
@@ -1524,12 +1528,12 @@ BBPmanager(void *dummy)
}
TRC_DEBUG(BAT_, "cleared HOT bit from %d bats\n", n);
size_t cur = GDKvm_cursize();
-   for (int i = 0, n = cur > GDK_vm_maxsize / 2 ? 1 : cur > 
GDK_vm_maxsize / 4 ? 10 : 100; i < n; i++) {
+   for (int i = 0, n = changed && cur > GDK_vm_maxsize / 2 ? 1 : 
cur > GDK_vm_maxsize / 4 ? 10 : 100; i < n; i++) {
MT_sleep_ms(100);
if (GDKexiting())
return;
}
-   BBPtrim(false);
+   changed = BBPtrim(false);
BBPcallbacks();
if (GDKexiting())
return;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: groupjoin - Some fixes to new markjoin code.

2023-09-11 Thread Sjoerd Mullender via checkin-list
Changeset: 4e96cf407ef1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4e96cf407ef1
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/exports.stable.out
gdk/gdk_join.c
Branch: groupjoin
Log Message:

Some fixes to new markjoin code.


diffs (100 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -3495,6 +3495,16 @@ PCRElikeselect;
 Select all head values of the first input BAT for which the@tail value is 
"like" the given (SQL-style) pattern and for@which the head value occurs in the 
tail of the second input@BAT.@Input is a dense-headed BAT, output is a 
dense-headed BAT with in@the tail the head value of the input BAT for which 
the@relationship holds.  The output BAT is sorted on the tail value.
 algebra
 markjoin
+command algebra.markjoin(X_0:bat[:any_1], X_1:bat[:any_1], X_2:bat[:oid], 
X_3:bat[:oid], X_4:lng) (X_5:bat[:oid], X_6:bat[:bit]) 
+ALGmark2join;
+Mark join with candidate lists
+algebra
+markjoin
+command algebra.markjoin(X_0:bat[:any_1], X_1:bat[:any_1], X_2:bat[:oid], 
X_3:bat[:oid], X_4:lng) (X_5:bat[:oid], X_6:bat[:oid], X_7:bat[:bit]) 
+ALGmark3join;
+Mark join with candidate lists
+algebra
+markjoin
 command algebra.markjoin(X_0:bat[:any_1], X_1:bat[:any_1], X_2:bat[:oid], 
X_3:bat[:oid], X_4:bit, X_5:lng) (X_6:bat[:oid], X_7:bat[:bit]) 
 ALGmarkjoin;
 Left mark join with candidate lists, produces left output and mark flag; 
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -159,6 +159,7 @@ BAT *BATintersectcand(BAT *a, BAT *b);
 gdk_return BATjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr, 
bool nil_matches, BUN estimate) __attribute__((__warn_unused_result__));
 gdk_return BATkey(BAT *b, bool onoff);
 gdk_return BATleftjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr, 
bool nil_matches, BUN estimate) __attribute__((__warn_unused_result__));
+gdk_return BATmarkjoin(BAT **r1p, BAT **r2p, BAT **r3p, BAT *l, BAT *r, BAT 
*sl, BAT *sr, BUN estimate) __attribute__((__warn_unused_result__));
 BAT *BATmaskedcands(oid hseq, BUN nr, BAT *masked, bool selected);
 void *BATmax(BAT *b, void *aggr);
 void *BATmax_skipnil(BAT *b, void *aggr, bit skipnil);
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -110,11 +110,11 @@ joininitresults(BAT **r1p, BAT **r2p, BA
bool lkey, bool rkey, bool semi, bool nil_on_miss,
bool only_misses, bool min_one, BUN estimate)
 {
-   BAT *r1, *r2, *r3;
+   BAT *r1 = NULL, *r2 = NULL, *r3 = NULL;
BUN maxsize, size;
 
/* if nil_on_miss is set, we really need a right output */
-   assert(!nil_on_miss || r2p != NULL);
+   assert(!nil_on_miss || r2p != NULL || r3p != NULL);
 
lkey |= lcnt <= 1;
rkey |= rcnt <= 1;
@@ -2176,6 +2176,7 @@ mergejoin(BAT **r1p, BAT **r2p, BAT **r3
while (lci->next < lci->ncand) {
GDK_CHECK_TIMEOUT(timeoffset, counter,
GOTO_LABEL_TIMEOUT_HANDLER(bailout));
+   bit mark = defmark;
if (lscan == 0) {
/* always search r completely */
assert(equal_order);
@@ -2357,6 +2358,9 @@ mergejoin(BAT **r1p, BAT **r2p, BAT **r3
/* v is nil and nils don't match anything, set
 * to NULL to indicate nil */
v = NULL;
+   mark = bit_nil;
+   if (r3)
+   r3->tnil = true;
}
 
/* First we find the "first" value in r that is "at
@@ -2695,10 +2699,10 @@ mergejoin(BAT **r1p, BAT **r2p, BAT **r3
/* finally the mark output */
if (r3) {
if (insert_nil) {
-   r3->tnil = rhasnil;
+   r3->tnil |= rhasnil;
for (i = 0; i < nl; i++) {
for (j = 0; j < nr; j++) {
-   ((bit *) 
r3->theap->base)[r3->batCount++] = defmark;
+   ((bit *) 
r3->theap->base)[r3->batCount++] = mark;
}
}
} else {
@@ -3288,6 +3292,11 @@ hashjoin(BAT **r1p, BAT **r2p, BAT **r3p
r2->tseqbase = 0;
}
}
+   if (r3) {
+   r3->tnonil = !r3->tnil;
+   BATsetcount(r3, BATcount(r3));
+   assert(BATcount(r1) == BATcount(r3));
+   }
if (BATcount(r1) > 0) {
if (BATtdense(r1))

MonetDB: groupjoin - Merge with default branch.

2023-09-11 Thread Sjoerd Mullender via checkin-list
Changeset: 13768387d528 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/13768387d528
Modified Files:
gdk/gdk_join.c
sql/server/rel_exp.c
Branch: groupjoin
Log Message:

Merge with default branch.


diffs (25 lines):

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
@@ -1209,16 +1209,18 @@ exp_refers( sql_exp *p, sql_exp *c)
// at first they need to have the same expression names
if (!p->alias.name || !c->r || strcmp(p->alias.name, c->r) != 0)
return 0;
+   if (!c->l)
+   return 1;
// then compare the relation names
-   if (c->l) {
+   if (c->l && (p->alias.rname || p->l)) {
// if the parent has an alias for the relation name 
compare with the child's relation name
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 && p->l && strcmp(p->l, c->l) != 0)
+   if (!p->alias.rname && p->l && (strcmp(p->l, c->l) != 0 
|| strcmp(p->alias.name, p->r) !=0))
return 0;
+   return 1;
}
-   return 1;
}
return 0;
 }
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: groupjoin - Implemented BATmarkjoin.

2023-09-11 Thread Sjoerd Mullender via checkin-list
Changeset: a62315e6e373 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a62315e6e373
Modified Files:
gdk/gdk.h
gdk/gdk_join.c
monetdb5/modules/kernel/algebra.c
Branch: groupjoin
Log Message:

Implemented BATmarkjoin.


diffs (truncated from 1907 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2307,6 +2307,8 @@ gdk_export gdk_return BAToutercross(BAT 
 
 gdk_export gdk_return BATleftjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT 
*sl, BAT *sr, bool nil_matches, BUN estimate)
__attribute__((__warn_unused_result__));
+gdk_export gdk_return BATmarkjoin(BAT **r1p, BAT **r2p, BAT **r3p, BAT *l, BAT 
*r, BAT *sl, BAT *sr, BUN estimate)
+   __attribute__((__warn_unused_result__));
 gdk_export gdk_return BATouterjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT 
*sl, BAT *sr, bool nil_matches, bool match_one, BUN estimate)
__attribute__((__warn_unused_result__));
 gdk_export gdk_return BATthetajoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT 
*sl, BAT *sr, int op, bool nil_matches, BUN estimate)
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -44,6 +44,13 @@
  * equi-join, but the left output is sorted, and if there are
  * multiple matches, only one is returned (i.e., the left output
  * is also key, making it a candidate list)
+ * BATmarkjoin
+ * equi-join, but the left output is sorted, if there is no
+ * match for a value in the left input, there is still an output
+ * with NIL in the right output, and there is a third output column
+ * containing a flag that indicates the "certainty" of the match: 1
+ * there is a match, 0, there is no match and there are no NIL
+ * values, NIL, there is no match but there are NIL values
  * BATthetajoin
  * theta-join: an extra operator must be provided encoded as an
  * integer (macros JOIN_EQ, JOIN_NE, JOIN_LT, JOIN_LE, JOIN_GT,
@@ -99,11 +106,11 @@ joinparamcheck(BAT *l, BAT *r1, BAT *r2,
 /* Create the result bats for a join, returns the absolute maximum
  * number of outputs that could possibly be generated. */
 static BUN
-joininitresults(BAT **r1p, BAT **r2p, BUN lcnt, BUN rcnt, bool lkey, bool rkey,
-   bool semi, bool nil_on_miss, bool only_misses, bool min_one,
-   BUN estimate)
+joininitresults(BAT **r1p, BAT **r2p, BAT **r3p, BUN lcnt, BUN rcnt,
+   bool lkey, bool rkey, bool semi, bool nil_on_miss,
+   bool only_misses, bool min_one, BUN estimate)
 {
-   BAT *r1, *r2;
+   BAT *r1, *r2, *r3;
BUN maxsize, size;
 
/* if nil_on_miss is set, we really need a right output */
@@ -115,6 +122,8 @@ joininitresults(BAT **r1p, BAT **r2p, BU
*r1p = NULL;
if (r2p)
*r2p = NULL;
+   if (r3p)
+   *r3p = NULL;
if (lcnt == 0) {
/* there is nothing to match */
maxsize = 0;
@@ -173,6 +182,17 @@ joininitresults(BAT **r1p, BAT **r2p, BU
}
*r2p = r2;
}
+   if (r3p) {
+   r3 = COLnew(0, TYPE_bit, 0, TRANSIENT);
+   if (r3 == NULL) {
+   BBPreclaim(r1);
+   BBPreclaim(r2);
+   if (r2p)
+   *r2p = NULL;
+   return BUN_NONE;
+   }
+   *r3p = r3;
+   }
*r1p = r1;
return 0;
}
@@ -204,6 +224,22 @@ joininitresults(BAT **r1p, BAT **r2p, BU
r2->theap->dirty = true;
*r2p = r2;
}
+   if (r3p) {
+   BAT *r3 = COLnew(0, TYPE_bit, size, TRANSIENT);
+   if (r3 == NULL) {
+   BBPreclaim(r1);
+   BBPreclaim(r2);
+   return BUN_NONE;
+   }
+   r3->tnil = false;
+   r3->tnonil = true;
+   r3->tkey = false;
+   r3->tsorted = false;
+   r3->trevsorted = false;
+   r3->tseqbase = oid_nil;
+   r3->theap->dirty = true;
+   *r3p = r3;
+   }
return maxsize;
 }
 
@@ -216,7 +252,7 @@ joininitresults(BAT **r1p, BAT **r2p, BU
 #define APPEND(b, o)   (((oid *) b->theap->base)[b->batCount++] = (o))
 
 static inline gdk_return
-maybeextend(BAT *restrict r1, BAT *restrict r2,
+maybeextend(BAT *restrict r1, BAT *restrict r2, BAT *restrict r3,
BUN cnt, BUN lcur, BUN lcnt, BUN maxsize)
 {
if (BATcount(r1) + cnt > BATcapacity(r1)) {
@@ -243,11 +279,17 @@ maybeextend(BAT *restrict r1, BAT *restr
return GDK_FAIL;
assert(BATcapacity(r1) == BATcapacity(r2));
}
+   if (r3) {
+   

MonetDB: default - Work around compiler bug that manifests itsel...

2023-09-14 Thread Sjoerd Mullender via checkin-list
Changeset: 6d5f82ed1c51 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6d5f82ed1c51
Modified Files:
sql/backends/monet5/sql_gencode.c
Branch: default
Log Message:

Work around compiler bug that manifests itself on CentOS 7.


diffs (20 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -1621,7 +1621,6 @@ backend_create_sql_func(backend *be, sql
const char *sql_shared_module = putName(sql_shared_module_name);
const char *sql_private_module = putName(sql_private_module_name);
const char *modname = prepare?sql_private_module:sql_shared_module;
-   Module mod = prepare?c->usermodule:getModule(modname);
exception_buffer ebsave = m->sa->eb;
char befname[IDLENGTH];
int nargs;
@@ -1646,7 +1645,7 @@ backend_create_sql_func(backend *be, sql
sql_error(m, 10, "%s", m->sa->eb.msg);
freeSymbol(c->curprg);
goto bailout;
-   } else if (backend_create_sql_func_body(be, f, restypes, ops, mod, 
fimp, prepare) < 0) {
+   } else if (backend_create_sql_func_body(be, f, restypes, ops, prepare ? 
c->usermodule : getModule(modname), fimp, prepare) < 0) {
goto bailout;
}
*be = bebackup;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Slight code rearrangement.

2023-09-15 Thread Sjoerd Mullender via checkin-list
Changeset: db9e9640d099 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/db9e9640d099
Modified Files:
monetdb5/modules/kernel/bat5.c
Branch: default
Log Message:

Slight code rearrangement.


diffs (87 lines):

diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -675,17 +675,16 @@ HASHinfo(BAT *bk, BAT *bv, Hash *h, str 
return GDK_SUCCEED;
 }
 
-
 static str
-BATinfo(BAT **key, BAT **val, const bat bid)
+BKCinfo(bat *ret1, bat *ret2, const bat *bid)
 {
const char *mode, *accessmode;
BAT *bk = NULL, *bv = NULL, *b;
char bf[oidStrlen];
char buf[32];
 
-   if ((b = BATdescriptor(bid)) == NULL) {
-   throw(MAL, "BATinfo", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+   if ((b = BATdescriptor(*bid)) == NULL) {
+   throw(MAL, "bat.info", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
}
 
bk = COLnew(0, TYPE_str, 128, TRANSIENT);
@@ -694,7 +693,7 @@ BATinfo(BAT **key, BAT **val, const bat 
BBPreclaim(bk);
BBPreclaim(bv);
BBPunfix(b->batCacheid);
-   throw(MAL, "bat.getInfo", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+   throw(MAL, "bat.info", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
 
BATiter bi = bat_iterator(b);
@@ -718,11 +717,11 @@ BATinfo(BAT **key, BAT **val, const bat 
accessmode = "unknown";
}
 
-   if (BUNappend(bk, "batId", false) != GDK_SUCCEED ||
-   BUNappend(bv, BATgetId(b), false) != GDK_SUCCEED ||
-   BUNappend(bk, "batCacheid", false) != GDK_SUCCEED ||
-   BUNappend(bv, local_itoa((ssize_t) b->batCacheid, buf),
- false) != GDK_SUCCEED
+   if (BUNappend(bk, "batId", false) != GDK_SUCCEED
+   || BUNappend(bv, BATgetId(b), false) != GDK_SUCCEED
+   || BUNappend(bk, "batCacheid", false) != GDK_SUCCEED
+   || BUNappend(bv, local_itoa((ssize_t) b->batCacheid, buf),
+false) != GDK_SUCCEED
|| BUNappend(bk, "tparentid", false) != GDK_SUCCEED
|| BUNappend(bv, local_itoa((ssize_t) bi.h->parentid, buf),
 false) != GDK_SUCCEED
@@ -803,7 +802,7 @@ BATinfo(BAT **key, BAT **val, const bat 
BBPreclaim(bk);
BBPreclaim(bv);
BBPunfix(b->batCacheid);
-   throw(MAL, "bat.getInfo", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+   throw(MAL, "bat.info", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
/* dump index information */
MT_rwlock_rdlock(>thashlock);
@@ -813,25 +812,12 @@ BATinfo(BAT **key, BAT **val, const bat 
BBPreclaim(bk);
BBPreclaim(bv);
BBPunfix(b->batCacheid);
-   throw(MAL, "bat.getInfo", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+   throw(MAL, "bat.info", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
MT_rwlock_rdunlock(>thashlock);
bat_iterator_end();
-   *key = bk;
-   *val = bv;
assert(BATcount(bk) == BATcount(bv));
-   BBPunfix(bid);
-   return MAL_SUCCEED;
-}
-
-static str
-BKCinfo(bat *ret1, bat *ret2, const bat *bid)
-{
-   BAT *bv, *bk;
-   str msg;
-
-   if ((msg = BATinfo(, , *bid)) != NULL)
-   return msg;
+   BBPunfix(b->batCacheid);
*ret1 = bk->batCacheid;
BBPkeepref(bk);
*ret2 = bv->batCacheid;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch.

2023-09-15 Thread Sjoerd Mullender via checkin-list
Changeset: 2596a0974baa for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2596a0974baa
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_storage.c
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (31 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2247,7 +2247,7 @@ BBPdump(void)
continue;
BAT *b = BBP_desc(i);
unsigned status = BBP_status(i);
-   printf("# %d: " ALGOOPTBATFMT "refs=%d lrefs=%d status=%u%s",
+   printf("# %d: " ALGOOPTBATFMT " refs=%d lrefs=%d status=%u%s",
   i,
   ALGOOPTBATPAR(b),
   BBP_refs(i),
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -764,13 +764,12 @@ BATsave_iter(BAT *b, BATiter *bi, BUN si
}
if (size != b->batCount || b->batInserted < b->batCount) {
/* if the sizes don't match, the BAT must be dirty */
-   b->batCopiedtodisk = false;
b->theap->dirty = true;
if (b->tvheap)
b->tvheap->dirty = true;
-   } else {
-   b->batCopiedtodisk = true;
}
+   /* there is something on disk now */
+   b->batCopiedtodisk = true;
MT_lock_unset(>theaplock);
if (locked &&  b->thash && b->thash != (Hash *) 1)
BAThashsave(b, dosync);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - When saving a bat succeeded, always set batCo...

2023-09-15 Thread Sjoerd Mullender via checkin-list
Changeset: d0226b4b1333 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d0226b4b1333
Modified Files:
gdk/gdk_storage.c
Branch: Jun2023
Log Message:

When saving a bat succeeded, always set batCopiedtodisk.


diffs (19 lines):

diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -764,13 +764,12 @@ BATsave_iter(BAT *b, BATiter *bi, BUN si
}
if (size != b->batCount || b->batInserted < b->batCount) {
/* if the sizes don't match, the BAT must be dirty */
-   b->batCopiedtodisk = false;
b->theap->dirty = true;
if (b->tvheap)
b->tvheap->dirty = true;
-   } else {
-   b->batCopiedtodisk = true;
}
+   /* there is something on disk now */
+   b->batCopiedtodisk = true;
MT_lock_unset(>theaplock);
if (locked &&  b->thash && b->thash != (Hash *) 1)
BAThashsave(b, dosync);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Updated BBPdump (debug) output.

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

Updated BBPdump (debug) output.


diffs (103 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2243,31 +2243,27 @@ BBPdump(void)
continue;
BAT *b = BBP_desc(i);
unsigned status = BBP_status(i);
-   fprintf(stderr,
-   "# %d: " ALGOOPTBATFMT " "
-   "refs=%d lrefs=%d "
-   "status=%u%s",
-   i,
-   ALGOOPTBATPAR(b),
-   BBP_refs(i),
-   BBP_lrefs(i),
-   status,
-   BBP_cache(i) ? "" : " not cached");
+   printf("# %d: " ALGOOPTBATFMT " refs=%d lrefs=%d status=%u%s",
+  i,
+  ALGOOPTBATPAR(b),
+  BBP_refs(i),
+  BBP_lrefs(i),
+  status,
+  BBP_cache(i) ? "" : " not cached");
if (b == NULL) {
-   fprintf(stderr, ", no descriptor\n");
+   printf(", no descriptor\n");
continue;
}
if (b->theap) {
if (b->theap->parentid != b->batCacheid) {
-   fprintf(stderr, " Theap -> %d", 
b->theap->parentid);
+   printf(" Theap -> %d", b->theap->parentid);
} else {
-   fprintf(stderr,
-   " Theap=[%zu,%zu,f=%d]%s%s",
-   b->theap->free,
-   b->theap->size,
-   b->theap->farmid,
-   b->theap->base == NULL ? "X" : 
b->theap->storage == STORE_MMAP ? "M" : "",
-   status & BBPSWAPPED ? "(Swapped)" : 
b->theap->dirty ? "(Dirty)" : "");
+   printf(" Theap=[%zu,%zu,f=%d]%s%s",
+  b->theap->free,
+  b->theap->size,
+  b->theap->farmid,
+  b->theap->base == NULL ? "X" : 
b->theap->storage == STORE_MMAP ? "M" : "",
+  status & BBPSWAPPED ? "(Swapped)" : 
b->theap->dirty ? "(Dirty)" : "");
mem += HEAPmemsize(b->theap);
vm += HEAPvmsize(b->theap);
n++;
@@ -2275,17 +2271,15 @@ BBPdump(void)
}
if (b->tvheap) {
if (b->tvheap->parentid != b->batCacheid) {
-   fprintf(stderr,
-   " Tvheap -> %d",
-   b->tvheap->parentid);
+   printf(" Tvheap -> %d",
+  b->tvheap->parentid);
} else {
-   fprintf(stderr,
-   " Tvheap=[%zu,%zu,f=%d]%s%s",
-   b->tvheap->free,
-   b->tvheap->size,
-   b->tvheap->farmid,
-   b->tvheap->base == NULL ? "X" : 
b->tvheap->storage == STORE_MMAP ? "M" : "",
-   b->tvheap->dirty ? "(Dirty)" : "");
+   printf(" Tvheap=[%zu,%zu,f=%d]%s%s",
+  b->tvheap->free,
+  b->tvheap->size,
+  b->tvheap->farmid,
+  b->tvheap->base == NULL ? "X" : 
b->tvheap->storage == STORE_MMAP ? "M" : "",
+  b->tvheap->dirty ? "(Dirty)" : "");
mem += HEAPmemsize(b->tvheap);
vm += HEAPvmsize(b->tvheap);
}
@@ -2294,19 +2288,19 @@ BBPdump(void)
if (b->thash && b->thash != (Hash *) 1) {
size_t m = HEAPmemsize(>thash->heaplink) + 
HEAPmemsize(>thash->heapbckt);
size_t v = HEAPvmsize(>thash->heaplink) + 
HEAPvmsize(>thash->heapbckt);
-   fprintf(stderr, " Thash=[%zu,%zu,f=%d/%d]", m, 
v,
-   b->thash->heaplink.farmid,
-   b->thash->heapbckt.farmid);
+   printf(" Thash=[%zu,%zu,f=%d/%d]", m, v,
+  

MonetDB: Jun2023 - Python 3.12 complains about invalid escape se...

2023-09-15 Thread Sjoerd Mullender via checkin-list
Changeset: 91f13c2501a7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/91f13c2501a7
Modified Files:
testing/Mtest.py.in
testing/explain.py
testing/melcheck.py
Branch: Jun2023
Log Message:

Python 3.12 complains about invalid escape sequences in non-raw strings.


diffs (120 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -2069,7 +2069,7 @@ def RunTest(env, TST, COND, oktests, len
 rversion = os.path.join('@LIBR_INCLUDE_DIRS@', 'Rversion.h')
 if os.path.exists(rversion):
 with openutf8(rversion, 'r') as f:
-res = re.search('#define R_VERSION (?P\d+)', 
f.read())
+res = re.search(r'#define R_VERSION 
(?P\d+)', f.read())
 if res is not None:
 r_version = res.group('rversion')
 req_version = cond[11:].split('.')
@@ -2130,7 +2130,7 @@ def RunTest(env, TST, COND, oktests, len
 reason = "as multiple SQL clients in parallel are currently not 
supported by %s." % THISFILE
 elem = SkipTest(env, TST, EXT, reason, length)
 else:
-test = re.compile("^"+TST+"((_[sp][0-9][0-9])?\..*)?$", re.MULTILINE)
+test = re.compile("^"+TST+r"((_[sp][0-9][0-9])?\..*)?$", re.MULTILINE)
 for f in listdir(RELSRCDIR):
 if test.match(f):
 try:
@@ -2159,7 +2159,7 @@ def RunTest(env, TST, COND, oktests, len
 reason = "as source file '%s` is missing." % TSTSRC
 elem = SkipTest(env, TST, EXT+".src", reason, length)
 return TX,Failed,Failed,elem,reason,links
-test = re.compile("^"+TST+"((_[sp][0-9][0-9])?\..*)?\.src$", 
re.MULTILINE)
+test = re.compile("^"+TST+r"((_[sp][0-9][0-9])?\..*)?\.src$", 
re.MULTILINE)
 for ff in listdir(TSTTRGDIR):
 if test.match(ff) and not os.path.isfile(ff[:-4]):
 f = openutf8(ff,"r")
@@ -2174,7 +2174,7 @@ def RunTest(env, TST, COND, oktests, len
% (TSTSRC, ff[:-4], os.getcwd(), err.errno, 
err.strerror))
 else:
 Warn("source file '"+TSTSRC+"` is missing.")
-test = re.compile("^"+TST+"(_[sp][0-9][0-9])?\..*\.in$", re.MULTILINE)
+test = re.compile("^"+TST+r"(_[sp][0-9][0-9])?\..*\.in$", re.MULTILINE)
 for ff in listdir(TSTTRGDIR):
 fff = ff[:-3]
 if test.match(ff) and not os.path.isfile(fff):
@@ -2535,7 +2535,7 @@ def killProc(proc, outfile = None, cmd =
 sym = r'c:\Symbols;'
 elif os.path.exists(r'c:\Program Files\Debugging Tools for Windows 
(x86)\cdb.exe'):
 cdb = r'c:\Program Files\Debugging Tools for Windows (x86)\cdb.exe'
-if os.path.exists('c:\WINDOWS\Symbols'):
+if os.path.exists(r'c:\WINDOWS\Symbols'):
 sym = r'c:\WINDOWS\Symbols;'
 else:
 cdb = None
@@ -3080,7 +3080,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
'segfault'),
   ("aborted too deep recursion",
'recursion'),
-  ("mal_mapi\.listen:operation failed: bind to stream 
socket port",
+  (r"mal_mapi\.listen:operation failed: bind to stream 
socket port",
'socket')]:
 TO = re.compile(regexp, re.MULTILINE)
 # FIXME: this begs for a much nicer solution (100% copy of below)
@@ -3257,7 +3257,7 @@ os.environ['MAPIHOST'] = HOST
 if os.name == "nt":
 SYST= "Windows"
 RELEASE = "5.0"
-r = re.compile('^Microsoft Windows (.*)\[Version 
([0-9]+\.[0-9]+)([^\[0-9].*)\]$')
+r = re.compile(r'^Microsoft Windows (.*)\[Version 
([0-9]+\.[0-9]+)([^\[0-9].*)\]$')
 if procdebug:
 print('starting process "cmd" "/c" "ver" (inpipe,outpipe)\n')
 with process.Popen('cmd /c ver', stdin=process.PIPE,
@@ -3361,7 +3361,7 @@ if SYST == "Linux":
 elif os.path.isfile('/etc/debian_version'):
 LINUX_DIST = "Debian:"+open('/etc/debian_version').readline().strip()
 if not LINUX_DIST:
-LINUX_DIST = SYST+':'+re.match('^([0-9\.]*)([^0-9\.].*)$', 
RELEASE).group(1)
+LINUX_DIST = SYST+':'+re.match(r'^([0-9.]*)([^0-9.].*)$', 
RELEASE).group(1)
 DIST,VERSION = LINUX_DIST.split(':', 1)
 elif SYST == "SunOS" and os.path.isfile('/etc/release'):
 (DIST,VERSION,rest) = open('/etc/release').readline().strip().split(' ',2)
@@ -3651,7 +3651,7 @@ def main(argv) :
stdout=process.PIPE, stderr=process.PIPE,
text=True) as proc:
 ruby_out, ruby_err = proc.communicate()
-ruby_reg = re.compile("^[^ ]* ([0-9]+)\.([0-9]+)[^0-9].*$", 
re.MULTILINE)
+ruby_reg = re.compile(r"^[^ ]* ([0-9]+)\.([0-9]+)[^0-9].*$", 
re.MULTILINE)
 

MonetDB: Jun2023 - No need to escape . inside a re character class.

2023-09-15 Thread Sjoerd Mullender via checkin-list
Changeset: a71da5e25c30 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a71da5e25c30
Modified Files:
testing/Mtest.py.in
Branch: Jun2023
Log Message:

No need to escape . inside a re character class.


diffs (12 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -3076,7 +3076,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
 
 # Try to detect segfaults and the like
 # Try to detect aborts due to too deep recursion
-for (regexp, msg) in [("(^(|[^#]*[\t ])((Memory|Segmentation) [Ff]ault|Bus 
[Ee]rror|Aborted|Assertion (|.* )failed[:\.]|!FATAL: BATSIGabort:)([ \t]|$))",
+for (regexp, msg) in [("(^(|[^#]*[\t ])((Memory|Segmentation) [Ff]ault|Bus 
[Ee]rror|Aborted|Assertion (|.* )failed[:.]|!FATAL: BATSIGabort:)([ \t]|$))",
'segfault'),
   ("aborted too deep recursion",
'recursion'),
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Fix scope.

2023-09-14 Thread Sjoerd Mullender via checkin-list
Changeset: 1c350170ca7b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1c350170ca7b
Modified Files:
monetdb5/modules/kernel/batmmath.c
monetdb5/modules/kernel/mmath.c
Branch: Jun2023
Log Message:

Fix scope.


diffs (40 lines):

diff --git a/monetdb5/modules/kernel/batmmath.c 
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -324,9 +324,10 @@ CMDscienceBINARY(MalStkPtr stk, InstrPtr
throw(MAL, malfunc, GDK_EXCEPTION);
if (e != 0 || ex != 0) {
const char *err;
+   char buf[128];
BBPunfix(bn->batCacheid);
if (e)
-   err = GDKstrerror(e, (char[128]) { 0 }, 128);
+   err = GDKstrerror(e, buf, 128);
else if (ex & FE_DIVBYZERO)
err = "Divide by zero";
else if (ex & FE_OVERFLOW)
diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c
--- a/monetdb5/modules/kernel/mmath.c
+++ b/monetdb5/modules/kernel/mmath.c
@@ -96,8 +96,9 @@ MATHunary##NAME##TYPE(TYPE *res, const T
(ex = fetestexcept(FE_INVALID | FE_DIVBYZERO |  
\
   FE_OVERFLOW)) != 0) 
{\
const char *err;
\
+   char buf[128];  
\
if (e) {
\
-   err = GDKstrerror(e, (char[128]){0}, 128);  
\
+   err = GDKstrerror(e, buf, 128); 
\
} else if (ex & FE_DIVBYZERO)   
\
err = "Divide by zero"; 
\
else if (ex & FE_OVERFLOW)  
\
@@ -129,8 +130,9 @@ MATHbinary##NAME##TYPE(TYPE *res, const 
(ex = fetestexcept(FE_INVALID | FE_DIVBYZERO |  
\
   FE_OVERFLOW)) != 0) 
{\
const char *err;
\
+   char buf[128];  
\
if (e) {
\
-   err = GDKstrerror(e, (char[128]){0}, 128);  
\
+   err = GDKstrerror(e, buf, 128); 
\
} else if (ex & FE_DIVBYZERO)   
\
err = "Divide by zero"; 
\
else if (ex & FE_OVERFLOW)  
\
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Code deduplication: combine Windows and Posix...

2023-08-24 Thread Sjoerd Mullender via checkin-list
Changeset: 739651dcbd34 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/739651dcbd34
Modified Files:
gdk/gdk_system.c
gdk/gdk_utils.c
Branch: default
Log Message:

Code deduplication: combine Windows and Posix thread code.


diffs (truncated from 1474 to 300 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -182,55 +182,74 @@ GDKlockstatistics(int what)
 
 static void MT_thread_setcondwait(MT_Cond *cond);
 
-#if !defined(HAVE_PTHREAD_H) && defined(WIN32)
-static struct winthread {
-   struct winthread *next;
-   HANDLE hdl;
-   DWORD tid;
-   void (*func) (void *);
-   void *data;
+static struct mtthread {
+   struct mtthread *next;
+   void (*func) (void *);  /* function to be called */
+   void *data; /* and its data */
MT_Lock *lockwait;  /* lock we're waiting for */
MT_Sema *semawait;  /* semaphore we're waiting for */
MT_Cond *condwait;  /* condition variable we're waiting for */
 #ifdef LOCK_OWNER
MT_Lock *mylocks;   /* locks we're holding */
 #endif
-   struct winthread *joinwait; /* process we are joining with */
+   struct mtthread *joinwait; /* process we are joining with */
const char *working;/* what we're currently doing */
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, limit_override:1;
+   unsigned int refs:20;
char threadname[MT_NAME_LEN];
QryCtx *qry_ctx;
-} *winthreads = NULL;
-static struct winthread mainthread = {
+#ifdef HAVE_PTHREAD_H
+   pthread_t hdl;
+#else
+   HANDLE hdl;
+#endif
+   MT_Id tid;
+} *mtthreads = NULL;
+struct mtthread mainthread = {
.threadname = "main thread",
.exited = ATOMIC_VAR_INIT(0),
+   .refs = 1,
 };
-
+#ifdef HAVE_PTHREAD_H
+static pthread_mutex_t posthread_lock = PTHREAD_MUTEX_INITIALIZER;
+static MT_Id MT_thread_id = 1;
+static pthread_key_t threadkey;
+#define thread_lock()  pthread_mutex_lock(_lock)
+#define thread_unlock()pthread_mutex_unlock(_lock)
+#define thread_self()  pthread_getspecific(threadkey)
+#define thread_setself(self)   pthread_setspecific(threadkey, self)
+#else
 static CRITICAL_SECTION winthread_cs;
 static DWORD threadslot = TLS_OUT_OF_INDEXES;
+#define thread_lock()  EnterCriticalSection(_cs)
+#define thread_unlock()LeaveCriticalSection(_cs)
+#define thread_self()  TlsGetValue(threadslot)
+#define thread_setself(self)   TlsSetValue(threadslot, self)
+#endif
+static bool thread_initialized = false;
 
 void
 dump_threads(void)
 {
char buf[1024];
-   EnterCriticalSection(_cs);
-   for (struct winthread *w = winthreads; w; w = w->next) {
+   thread_lock();
+   for (struct mtthread *t = mtthreads; t; t = t->next) {
int pos = snprintf(buf, sizeof(buf),
   "%s, waiting for %s, working on %.200s",
-  w->threadname,
-  w->lockwait ? w->lockwait->name :
-  w->semawait ? w->semawait->name :
-  w->condwait ? w->condwait->name :
-  w->joinwait ? w->joinwait->threadname :
+  t->threadname,
+  t->lockwait ? t->lockwait->name :
+  t->semawait ? t->semawait->name :
+  t->condwait ? t->condwait->name :
+  t->joinwait ? t->joinwait->threadname :
   "nothing",
-  ATOMIC_GET(>exited) ? "exiting" :
-  w->working ? w->working : "nothing");
+  ATOMIC_GET(>exited) ? "exiting" :
+  t->working ? t->working : "nothing");
 #ifdef LOCK_OWNER
const char *sep = ", locked: ";
-   for (MT_Lock *l = w->mylocks; l && pos < (int) sizeof(buf); l = 
l->nxt) {
+   for (MT_Lock *l = t->mylocks; l && pos < (int) sizeof(buf); l = 
l->nxt) {
pos += snprintf(buf + pos, sizeof(buf) - pos,
"%s%s(%s)", sep, l->name, l->locker);
sep = ", ";
@@ -241,577 +260,61 @@ dump_threads(void)
else
printf("%s%s\n", buf, pos >= (int) sizeof(buf) ? "..." 
: "");
}
-   LeaveCriticalSection(_cs);
+   thread_unlock();
+}
+
+static void
+rm_mtthread(struct mtthread *t)
+{
+   struct mtthread **pt;
+
+   thread_lock();
+   for (pt =  *pt && *pt != t; pt = &(*pt)->next)
+   ;
+   if 

MonetDB: default - In case there are multiple handles, make sure...

2023-08-24 Thread Sjoerd Mullender via checkin-list
Changeset: 124603154116 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/124603154116
Modified Files:
tools/monetdbe/monetdbe.c
Branch: default
Log Message:

In case there are multiple handles, make sure we use the correct query context.


diffs (60 lines):

diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -219,6 +219,7 @@ validate_database_handle_noerror(monetdb
 {
if (!monetdbe_embedded_initialized || !MCvalid(mdbe->c))
return 0;
+   MT_thread_set_qry_ctx(>c->qryctx);
clear_error(mdbe);
return 1;
 }
@@ -952,6 +953,7 @@ monetdbe_close(monetdbe_database dbhdl)
int err = 0;
int registered_thread = mdbe->registered_thread;
 
+   MT_thread_set_qry_ctx(>c->qryctx);
MT_lock_set(_lock);
if (mdbe->mid)
err = monetdbe_close_remote(mdbe);
@@ -1559,6 +1561,7 @@ monetdbe_query(monetdbe_database dbhdl, 
return NULL;
monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
 
+   MT_thread_set_qry_ctx(>c->qryctx);
if (mdbe->mid) {
mdbe->msg = monetdbe_query_remote(mdbe, query, result, 
affected_rows, NULL);
}
@@ -1578,6 +1581,7 @@ monetdbe_prepare(monetdbe_database dbhdl
 
int prepare_id = 0;
 
+   MT_thread_set_qry_ctx(>c->qryctx);
if (!stmt) {
set_error(mdbe, createException(MAL, 
"monetdbe.monetdbe_prepare", "Parameter stmt is NULL"));
assert(mdbe->msg != MAL_SUCCEED); /* help Coverity */
@@ -1705,6 +1709,7 @@ monetdbe_execute(monetdbe_statement *stm
cq *q = stmt_internal->q;
Symbol s = NULL;
 
+   MT_thread_set_qry_ctx(>c->qryctx);
if ((mdbe->msg = SQLtrans(m)) != MAL_SUCCEED)
return mdbe->msg;
 
@@ -1747,6 +1752,7 @@ monetdbe_cleanup_statement(monetdbe_data
 
assert(!stmt_internal->mdbe || mdbe == stmt_internal->mdbe);
 
+   MT_thread_set_qry_ctx(>c->qryctx);
for (size_t i = 0; i < stmt_internal->res.nparam + 1; i++) {
ValPtr data = _internal->data[i];
VALclear(data);
@@ -1768,7 +1774,7 @@ monetdbe_cleanup_result(monetdbe_databas
monetdbe_database_internal *mdbe = (monetdbe_database_internal*)dbhdl;
monetdbe_result_internal* res = (monetdbe_result_internal *) result;
 
-
+   MT_thread_set_qry_ctx(>c->qryctx);
if (!result) {
set_error(mdbe, createException(MAL, 
"monetdbe.monetdbe_cleanup_result_internal", "Parameter result is NULL"));
} else {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Reworked allocation code in the dataflow.

2023-08-28 Thread Sjoerd Mullender via checkin-list
Changeset: eb0a130ae7a2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/eb0a130ae7a2
Modified Files:
monetdb5/mal/mal_dataflow.c
Branch: default
Log Message:

Reworked allocation code in the dataflow.


diffs (truncated from 401 to 300 lines):

diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -80,20 +80,19 @@ typedef struct DATAFLOW {
bool set_qry_ctx;
 } *DataFlow, DataFlowRec;
 
-static struct worker {
+struct worker {
MT_Id id;
-   enum { IDLE, WAITING, RUNNING, FREE, EXITED } flag;
+   enum { WAITING, RUNNING, FREE, EXITED } flag;
ATOMIC_PTR_TYPE cntxt;  /* client we do work for (NULL -> any) 
*/
-   char *errbuf;   /* GDKerrbuf so that we can 
allocate before fork */
MT_Sema s;
-   int self;
-   int next;
-} workers[THREADS];
-/* heads of two mutually exclusive linked lists, both using the .next
+   struct worker *next;
+   char errbuf[GDKMAXERRLEN];  /* GDKerrbuf so that we can allocate 
before fork */
+};
+/* heads of three mutually exclusive linked lists, all using the .next
  * field in the worker struct */
-static int exited_workers = -1;/* to be joined threads */
-static int idle_workers = -1;  /* idle workers (no thread associated) */
-static int free_workers = -1;  /* free workers (thread doing nothing) */
+static struct worker *workers;   /* "working" workers */
+static struct worker *exited_workers; /* to be joined threads (.flag==EXITED) 
*/
+static struct worker *free_workers;/* free workers (.flag==FREE) */
 static int free_count = 0; /* number of free threads */
 static int free_max = 0;   /* max number of spare free threads */
 
@@ -101,23 +100,6 @@ static Queue *todo = 0;/* pending ins
 
 static ATOMIC_TYPE exiting = ATOMIC_VAR_INIT(0);
 static MT_Lock dataflowLock = MT_LOCK_INITIALIZER(dataflowLock);
-static void stopMALdataflow(void);
-
-void
-mal_dataflow_reset(void)
-{
-   stopMALdataflow();
-   memset((char *) workers, 0, sizeof(workers));
-   idle_workers = -1;
-   exited_workers = -1;
-   if (todo) {
-   MT_lock_destroy(>l);
-   MT_sema_destroy(>s);
-   GDKfree(todo);
-   }
-   todo = 0;   /* pending instructions 
*/
-   ATOMIC_SET(, 0);
-}
 
 /*
  * Calculate the size of the dataflow dependency graph.
@@ -126,9 +108,8 @@ static int
 DFLOWgraphSize(MalBlkPtr mb, int start, int stop)
 {
int cnt = 0;
-   int i;
 
-   for (i = start; i < stop; i++)
+   for (int i = start; i < stop; i++)
cnt += getInstrPtr(mb, i)->argc;
return cnt;
 }
@@ -267,10 +248,8 @@ DFLOWworker(void *T)
 #ifdef _MSC_VER
srand((unsigned int) GDKusec());
 #endif
-   assert(t->errbuf != NULL);
-   t->errbuf[0] = 0;
GDKsetbuf(t->errbuf);   /* where to leave errors */
-   t->errbuf = NULL;
+   snprintf(t->s.name, sizeof(t->s.name), "DFLOWsema%04zu", MT_getpid());
 
for (;;) {
DataFlow flow;
@@ -437,24 +416,32 @@ DFLOWworker(void *T)
break;
}
if (free_count >= free_max) {
+   struct worker **tp = 
+   while (*tp && *tp != t)
+   tp = &(*tp)->next;
+   assert(*tp && *tp == t);
+   *tp = t->next;
t->flag = EXITED;
t->next = exited_workers;
-   exited_workers = t->self;
+   exited_workers = t;
MT_lock_unset();
break;
}
free_count++;
+   struct worker **tp = 
+   while (*tp && *tp != t)
+   tp = &(*tp)->next;
+   assert(*tp && *tp == t);
+   *tp = t->next;
t->flag = FREE;
-   assert(free_workers != t->self);
t->next = free_workers;
-   free_workers = t->self;
+   free_workers = t;
MT_lock_unset();
MT_sema_down(>s);
if (GDKexiting() || ATOMIC_GET())
break;
assert(t->flag == WAITING);
}
-   GDKfree(GDKerrbuf);
GDKsetbuf(NULL);
 }
 
@@ -468,9 +455,8 @@ DFLOWworker(void *T)
 static int
 DFLOWinitialize(void)
 {
-   int i, limit;
+   int limit;
int created = 0;
-   static bool first = true;
 
MT_lock_set(_contextLock);
MT_lock_set();
@@ -488,44 +474,27 @@ DFLOWinitialize(void)
MT_lock_unset(_contextLock);
return -1;
}
-   assert(idle_workers == -1);
-   for (i = 0; i < THREADS; i++) {
-   char 

MonetDB: default - If name for new thread contains "XXXX", repla...

2023-08-28 Thread Sjoerd Mullender via checkin-list
Changeset: 0b7b62ee3aea for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0b7b62ee3aea
Modified Files:
clients/examples/C/testcondvar.c
gdk/gdk_system.c
monetdb5/modules/mal/mal_mapi.c
Branch: default
Log Message:

If name for new thread contains "", replace that with thread ID.


diffs (64 lines):

diff --git a/clients/examples/C/testcondvar.c b/clients/examples/C/testcondvar.c
--- a/clients/examples/C/testcondvar.c
+++ b/clients/examples/C/testcondvar.c
@@ -149,9 +149,7 @@ main(void)
fprintf(stderr, "\n-- Starting the worker threads\n");
for (int i = 0; i < NN; i++) {
struct state *st = [i];
-   char name[MT_NAME_LEN];
-   snprintf(name, sizeof(name), "worker%d", i);
-   MT_create_thread(>id, worker, st, MT_THR_JOINABLE, name);
+   MT_create_thread(>id, worker, st, MT_THR_JOINABLE, 
"worker");
}
MT_sleep_ms(100);
 
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -824,6 +824,13 @@ MT_create_thread(MT_Id *t, void (*f) (vo
};
ATOMIC_INIT(>exited, 0);
strcpy_len(self->threadname, threadname, sizeof(self->threadname));
+   char *p;
+   if ((p = strstr(self->threadname, "")) != NULL) {
+   /* overwrite  with thread ID */
+   char buf[5];
+   snprintf(buf, 5, "%04zu", mtid % );
+   memcpy(p, buf, 4);
+   }
TRC_DEBUG(THRD, "Create thread \"%s\"\n", self->threadname);
 #ifdef HAVE_PTHREAD_H
 #ifdef HAVE_PTHREAD_SIGMASK
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -442,13 +442,11 @@ SERVERlistenThread(SOCKET *Sock)
goto stream_alloc_fail;
}
data->out = s;
-   char name[MT_NAME_LEN];
-   snprintf(name, sizeof(name), "client%d", (int) 
ATOMIC_INC());
 
/* generate the challenge string */
generateChallenge(data->challenge, 8, 12);
 
-   if (MT_create_thread(, doChallenge, data, MT_THR_DETACHED, 
name) < 0) {
+   if (MT_create_thread(, doChallenge, data, MT_THR_DETACHED, 
"client") < 0) {
mnstr_destroy(data->in);
mnstr_destroy(data->out);
GDKfree(data);
@@ -974,13 +972,11 @@ SERVERclient(void *res, const Stream *In
GDKfree(data);
throw(MAL, "mapi.SERVERclient", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
}
-   char name[MT_NAME_LEN];
-   snprintf(name, sizeof(name), "client%d", (int) ATOMIC_INC());
 
/* generate the challenge string */
generateChallenge(data->challenge, 8, 12);
 
-   if (MT_create_thread(, doChallenge, data, MT_THR_DETACHED, name) < 
0) {
+   if (MT_create_thread(, doChallenge, data, MT_THR_DETACHED, 
"client") < 0) {
mnstr_destroy(data->in);
mnstr_destroy(data->out);
GDKfree(data);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Some small fixes to updated thread code.

2023-08-28 Thread Sjoerd Mullender via checkin-list
Changeset: 2bd5d2dc2135 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2bd5d2dc2135
Modified Files:
gdk/gdk_system.c
gdk/gdk_utils.c
Branch: default
Log Message:

Some small fixes to updated thread code.


diffs (149 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -410,7 +410,6 @@ MT_thread_register(void)
GDKerror("too many threads\n");
return false;
}
-   thread_lock();
*self = (struct mtthread) {
.detached = false,
 #ifdef HAVE_PTHREAD_H
@@ -424,6 +423,7 @@ MT_thread_register(void)
snprintf(self->threadname, sizeof(self->threadname), "foreign %zu", 
self->tid);
ATOMIC_INIT(>exited, 0);
thread_setself(self);
+   thread_lock();
self->next = mtthreads;
mtthreads = self;
thread_unlock();
@@ -477,6 +477,8 @@ GDKsetbuf(char *errbuf)
self = 
assert(errbuf == NULL || self->errbuf == NULL);
self->errbuf = errbuf;
+   if (errbuf)
+   *errbuf = 0;/* start clean */
 }
 
 char *
@@ -765,17 +767,6 @@ join_detached_threads(void)
thread_unlock();
 }
 
-#ifdef HAVE_PTHREAD_SIGMASK
-static void
-MT_thread_sigmask(sigset_t *new_mask, sigset_t *orig_mask)
-{
-   /* do not check for errors! */
-   sigdelset(new_mask, SIGQUIT);
-   sigdelset(new_mask, SIGPROF);
-   pthread_sigmask(SIG_SETMASK, new_mask, orig_mask);
-}
-#endif
-
 int
 MT_create_thread(MT_Id *t, void (*f) (void *), void *arg, enum MT_thr_detach 
d, const char *threadname)
 {
@@ -803,11 +794,13 @@ MT_create_thread(MT_Id *t, void (*f) (vo
int ret;
if ((ret = pthread_attr_init()) != 0) {
GDKsyserr(ret, "Cannot init pthread attr");
+   dealloc_thread(mtid);
return -1;
}
if ((ret = pthread_attr_setstacksize(, THREAD_STACK_SIZE)) != 0) {
GDKsyserr(ret, "Cannot set stack size");
pthread_attr_destroy();
+   dealloc_thread(mtid);
return -1;
}
 #endif
@@ -817,6 +810,7 @@ MT_create_thread(MT_Id *t, void (*f) (vo
 #ifdef HAVE_PTHREAD_H
pthread_attr_destroy();
 #endif
+   dealloc_thread(mtid);
return -1;
}
 
@@ -830,38 +824,39 @@ MT_create_thread(MT_Id *t, void (*f) (vo
};
ATOMIC_INIT(>exited, 0);
strcpy_len(self->threadname, threadname, sizeof(self->threadname));
+   TRC_DEBUG(THRD, "Create thread \"%s\"\n", self->threadname);
+#ifdef HAVE_PTHREAD_H
 #ifdef HAVE_PTHREAD_SIGMASK
sigset_t new_mask, orig_mask;
(void) sigfillset(_mask);
-   MT_thread_sigmask(_mask, _mask);
+   sigdelset(_mask, SIGQUIT);
+   sigdelset(_mask, SIGPROF);
+   pthread_sigmask(SIG_SETMASK, _mask, _mask);
 #endif
-   TRC_DEBUG(THRD, "Create thread \"%s\"\n", threadname);
-   thread_lock();
-#ifdef HAVE_PTHREAD_H
ret = pthread_create(>hdl, , thread_starter, self);
+   pthread_attr_destroy();
+#ifdef HAVE_PTHREAD_SIGMASK
+   pthread_sigmask(SIG_SETMASK, _mask, NULL);
+#endif
if (ret != 0) {
-   thread_unlock();
GDKsyserr(ret, "Cannot start thread");
free(self);
+   dealloc_thread(mtid);
+   return -1;
}
-   pthread_attr_destroy();
-#ifdef HAVE_PTHREAD_SIGMASK
-   MT_thread_sigmask(_mask, NULL);
-#endif
-   if (ret != 0)
-   return -1;
 #else
self->hdl = CreateThread(NULL, THREAD_STACK_SIZE, thread_starter, self,
  0, >wtid);
if (self->hdl == NULL) {
GDKwinerror("Failed to create thread");
-   thread_unlock();
free(self);
+   dealloc_thread(mtid);
return -1;
}
 #endif
/* must not fail after this: the thread has been started */
*t = mtid;
+   thread_lock();
self->next = mtthreads;
mtthreads = self;
thread_unlock();
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1153,6 +1153,8 @@ GDKinit(opt *set, int setlen, bool embed
return GDK_FAIL;
}
}
+   if (GDKnr_threads > THREADS)
+   GDKnr_threads = THREADS;
 
if (!GDKinmemory(0)) {
if ((p = GDKgetenv("gdk_dbpath")) != NULL &&
@@ -1251,7 +1253,6 @@ static ATOMIC_TYPE GDKnrofthreads = ATOM
 struct threadStruct {
ATOMIC_TYPE pid;/* thread id, 0 = unallocated */
 };
-static struct threadStruct GDKthreads[THREADS];
 
 bool
 GDKexiting(void)
@@ -1302,8 +1303,6 @@ GDKreset(int status)
if (status == 0) {
/* they had their chance, now kill them */
bool killed = MT_kill_threads();
-   for (int i = 0; i < THREADS; i++)
-   

MonetDB: Jun2023 - Enable restriction to only check for using to...

2023-08-30 Thread Sjoerd Mullender via checkin-list
Changeset: 457fd98f1741 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/457fd98f1741
Modified Files:
gdk/gdk_private.h
Branch: Jun2023
Log Message:

Enable restriction to only check for using too much mem in heap allocs.


diffs (12 lines):

diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -24,7 +24,7 @@
 #define PERSISTENTSTRIMP 1
 
 /* only check whether we exceed gdk_vm_maxsize when allocating heaps */
-/* #define SIZE_CHECK_IN_HEAPS_ONLY 1 */
+#define SIZE_CHECK_IN_HEAPS_ONLY 1
 
 #include "gdk_system_private.h"
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Some changelog blurbs.

2023-08-30 Thread Sjoerd Mullender via checkin-list
Changeset: 8eacd3f43778 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8eacd3f43778
Modified Files:
ChangeLog.Jun2023
gdk/ChangeLog.Jun2023
Branch: Jun2023
Log Message:

Some changelog blurbs.


diffs (36 lines):

diff --git a/ChangeLog.Jun2023 b/ChangeLog.Jun2023
--- a/ChangeLog.Jun2023
+++ b/ChangeLog.Jun2023
@@ -1,6 +1,10 @@
 # ChangeLog file for devel
 # This file is updated with Maddlog
 
+* Wed Aug 30 2023 Sjoerd Mullender 
+- Do a lot more error checking, mostly for allocation failures.  More is
+  still needed, though.
+
 * Thu Aug 10 2023 Panagiotis Koutsourakis 
 - Improve performance of the ILIKE operator when the pattern contains only
   ASCII characters. In this case we do not need to treat any characters as
diff --git a/gdk/ChangeLog.Jun2023 b/gdk/ChangeLog.Jun2023
--- a/gdk/ChangeLog.Jun2023
+++ b/gdk/ChangeLog.Jun2023
@@ -1,3 +1,18 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Wed Aug 30 2023 Sjoerd Mullender 
+- Only check for virtual memory limits when creating or growing bats,
+  not for general memory allocations.  There is (still) too much code
+  that doesn't properly handle failing allocations, so we need to avoid
+  those as much as possible.  This has mostly an effect if there are
+  virtual memory size restrictions imposed by cgroups (memory.swap.max
+  in cgroups v2, memory.memsw.limit_in_bytes in cgroups v1).
+- The low-level commit turned out to always commit every persistent bat
+  in the system.  There is no need for that, it should only commit bats
+  that were changed.  This has now been fixed.
+- Implemented timeout/exit checks in a bunch more operators.  Long(er)
+  running operators occasionally check whether they're taking too long
+  (past a user-specified timeout) or whether the server is exiting.
+  This is now done in more places.
+
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Make sure variables are initialized.

2023-09-12 Thread Sjoerd Mullender via checkin-list
Changeset: 1948c52a3545 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1948c52a3545
Modified Files:
gdk/gdk_join.c
Branch: default
Log Message:

Make sure variables are initialized.


diffs (29 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -307,6 +307,8 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
BATiter li = bat_iterator(l);
const void *v;
BAT *bn = NULL;
+   BAT *r1 = NULL;
+   BAT *r2 = NULL;
BUN bncount;
 
assert(lci->ncand > 0);
@@ -358,7 +360,7 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
goto bailout;
}
}
-   BAT *r1 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
+   r1 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
if (r1 == NULL)
goto bailout;
r1->tsorted = true;
@@ -367,7 +369,6 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
r1->tkey = bncount == 1;
r1->tnil = false;
r1->tnonil = true;
-   BAT *r2 = NULL;
if (bn == NULL) {
/* left outer join, no match, we're returning nil in r2 */
oid *o1p = (oid *) Tloc(r1, 0);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: groupjoin - Merge with default branch.

2023-09-12 Thread Sjoerd Mullender via checkin-list
Changeset: e1de1f2e60fe for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e1de1f2e60fe
Modified Files:
gdk/gdk_join.c
Branch: groupjoin
Log Message:

Merge with default branch.


diffs (184 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -366,6 +366,8 @@ selectjoin(BAT **r1p, BAT **r2p, BAT **r
BATiter li = bat_iterator(l);
const void *v;
BAT *bn = NULL;
+   BAT *r1 = NULL;
+   BAT *r2 = NULL;
BUN bncount;
 
assert(lci->ncand > 0);
@@ -416,46 +418,30 @@ selectjoin(BAT **r1p, BAT **r2p, BAT **r
if (semi)
bncount = 1;
if (max_one) {
-   BBPreclaim(bn);
GDKerror("more than one match");
-   return GDK_FAIL;
+   goto bailout;
}
}
-   BAT *r1 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
-   if (r1 == NULL) {
-   BBPreclaim(bn);
-   return GDK_FAIL;
-   }
+   r1 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
+   if (r1 == NULL)
+   goto bailout;
r1->tsorted = true;
r1->trevsorted = lci->ncand == 1;
r1->tseqbase = bncount == 1 && lci->tpe == cand_dense ? o : oid_nil;
r1->tkey = bncount == 1;
r1->tnil = false;
r1->tnonil = true;
-   BAT *r2 = NULL;
-   if (r2p) {
-   if (bn)
-   r2 = COLnew(0, TYPE_oid, lci->ncand * bncount, 
TRANSIENT);
-   else
-   r2 = BATconstant(0, TYPE_void, _nil, lci->ncand * 
bncount, TRANSIENT);
-   if (r2 == NULL) {
-   BBPreclaim(bn);
-   BBPreclaim(r1);
-   return GDK_FAIL;
-   }
-   if (bn) {
-   r2->tsorted = lci->ncand == 1 || bncount == 1;
-   r2->trevsorted = bncount == 1;
-   r2->tseqbase = lci->ncand == 1 && BATtdense(bn) ? 
bn->tseqbase : oid_nil;
-   r2->tkey = lci->ncand == 1;
-   r2->tnil = false;
-   r2->tnonil = true;
-   }
-   }
if (bn == NULL) {
+   /* left outer join, no match, we're returning nil in r2 */
oid *o1p = (oid *) Tloc(r1, 0);
BUN p, q = bncount;
 
+   if (r2p) {
+   r2 = BATconstant(0, TYPE_void, _nil, lci->ncand * 
bncount, TRANSIENT);
+   if (r2 == NULL)
+   goto bailout;
+   *r2p = r2;
+   }
do {
GDK_CHECK_TIMEOUT(timeoffset, counter,
  GOTO_LABEL_TIMEOUT_HANDLER(bailout));
@@ -464,51 +450,65 @@ selectjoin(BAT **r1p, BAT **r2p, BAT **r
}
o = canditer_next(lci);
} while (!is_oid_nil(o));
-   } else if (BATtdense(bn)) {
-   oid *o1p = (oid *) Tloc(r1, 0);
-   oid *o2p = r2 ? (oid *) Tloc(r2, 0) : NULL;
-   oid bno = bn->tseqbase;
-   BUN p, q = bncount;
-
-   do {
-   GDK_CHECK_TIMEOUT(timeoffset, counter,
- GOTO_LABEL_TIMEOUT_HANDLER(bailout));
-   for (p = 0; p < q; p++) {
-   *o1p++ = o;
-   }
-   if (o2p) {
-   for (p = 0; p < q; p++) {
-   *o2p++ = bno + p;
-   }
-   }
-   o = canditer_next(lci);
-   } while (!is_oid_nil(o));
} else {
oid *o1p = (oid *) Tloc(r1, 0);
-   oid *o2p = r2 ? (oid *) Tloc(r2, 0) : NULL;
-   const oid *bnp = (const oid *) Tloc(bn, 0);
+   oid *o2p;
BUN p, q = bncount;
 
-   do {
-   GDK_CHECK_TIMEOUT(timeoffset, counter,
- GOTO_LABEL_TIMEOUT_HANDLER(bailout));
-   for (p = 0; p < q; p++) {
-   *o1p++ = o;
-   }
-   if (o2p) {
+   if (r2p) {
+   r2 = COLnew(0, TYPE_oid, lci->ncand * bncount, 
TRANSIENT);
+   if (r2 == NULL)
+   goto bailout;
+   r2->tsorted = lci->ncand == 1 || bncount == 1;
+   r2->trevsorted = bncount == 1;
+   r2->tseqbase = lci->ncand == 1 && BATtdense(bn) ? 
bn->tseqbase : oid_nil;
+   r2->tkey = lci->ncand == 1;
+   r2->tnil = false;
+ 

MonetDB: groupjoin - Just always initialize.

2023-09-12 Thread Sjoerd Mullender via checkin-list
Changeset: d7f1fa27dc67 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d7f1fa27dc67
Modified Files:
monetdb5/modules/kernel/algebra.c
Branch: groupjoin
Log Message:

Just always initialize.


diffs (51 lines):

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
@@ -636,7 +636,7 @@ do_join(bat *r1, bat *r2, bat *r3, const
 {
BAT *left = NULL, *right = NULL, *right2 = NULL;
BAT *candleft = NULL, *candright = NULL;
-   BAT *result1, *result2, *result3;
+   BAT *result1 = NULL, *result2 = NULL, *result3 = NULL;
BUN est;
const char *err = RUNTIME_OBJECT_MISSING;
 
@@ -678,7 +678,6 @@ do_join(bat *r1, bat *r2, bat *r3, const
assert(rangefunc == NULL);
assert(difffunc == NULL);
assert(interfunc == NULL);
-   result2 = NULL;
if ((*joinfunc)
(, r2 ?  : NULL, left, right, candleft, 
candright,
 *nil_matches, est) != GDK_SUCCEED)
@@ -689,7 +688,6 @@ do_join(bat *r1, bat *r2, bat *r3, const
assert(rangefunc == NULL);
assert(difffunc == NULL);
assert(interfunc == NULL);
-   result2 = NULL;
if ((*semifunc)
(, r2 ?  : NULL, left, right, candleft, 
candright,
 *nil_matches, *max_one, est) != GDK_SUCCEED)
@@ -699,8 +697,6 @@ do_join(bat *r1, bat *r2, bat *r3, const
assert(rangefunc == NULL);
assert(difffunc == NULL);
assert(interfunc == NULL);
-   result2 = NULL;
-   result3 = NULL;
if ((*markfunc) (, r2 ?  : NULL, ,
 left, right, candleft, 
candright, est) != GDK_SUCCEED)
goto fail;
@@ -730,13 +726,11 @@ do_join(bat *r1, bat *r2, bat *r3, const
if ((result1 = (*difffunc) (left, right, candleft, candright,

*nil_matches, *not_in, est)) == NULL)
goto fail;
-   result2 = NULL;
} else {
assert(r2 == NULL);
if ((result1 = (*interfunc) (left, right, candleft, candright,
 
*nil_matches, *max_one, est)) == NULL)
goto fail;
-   result2 = NULL;
}
*r1 = result1->batCacheid;
BBPkeepref(result1);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: insertonly - singleuser field must be signed.

2023-09-12 Thread Sjoerd Mullender via checkin-list
Changeset: 43e5aad9534d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/43e5aad9534d
Modified Files:
sql/storage/sql_storage.h
Branch: insertonly
Log Message:

singleuser field must be signed.


diffs (12 lines):

diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h
--- a/sql/storage/sql_storage.h
+++ b/sql/storage/sql_storage.h
@@ -490,7 +490,7 @@ typedef struct sqlstore {
ATOMIC_TYPE oldest;
ulng oldest_pending;
bool readonly;  /* store is readonly */
-   char singleuser;/* store is for a single user only (==1 
enable, ==2 single user session running) */
+   int8_t singleuser;  /* store is for a single user only (==1 
enable, ==2 single user session running) */
bool first; /* just created the db */
bool insertonly_nowal;
bool initialized;   /* used during bootstrap only */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Rearrange code a little, fixing some small er...

2023-09-12 Thread Sjoerd Mullender via checkin-list
Changeset: 72b69c67c1a4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/72b69c67c1a4
Modified Files:
gdk/gdk_join.c
Branch: default
Log Message:

Rearrange code a little, fixing some small errors.


diffs (174 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -354,16 +354,13 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
if (semi)
bncount = 1;
if (max_one) {
-   BBPreclaim(bn);
GDKerror("more than one match");
-   return GDK_FAIL;
+   goto bailout;
}
}
BAT *r1 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
-   if (r1 == NULL) {
-   BBPreclaim(bn);
-   return GDK_FAIL;
-   }
+   if (r1 == NULL)
+   goto bailout;
r1->tsorted = true;
r1->trevsorted = lci->ncand == 1;
r1->tseqbase = bncount == 1 && lci->tpe == cand_dense ? o : oid_nil;
@@ -371,29 +368,17 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
r1->tnil = false;
r1->tnonil = true;
BAT *r2 = NULL;
-   if (r2p) {
-   if (bn)
-   r2 = COLnew(0, TYPE_oid, lci->ncand * bncount, 
TRANSIENT);
-   else
-   r2 = BATconstant(0, TYPE_void, _nil, lci->ncand * 
bncount, TRANSIENT);
-   if (r2 == NULL) {
-   BBPreclaim(bn);
-   BBPreclaim(r1);
-   return GDK_FAIL;
-   }
-   if (bn) {
-   r2->tsorted = lci->ncand == 1 || bncount == 1;
-   r2->trevsorted = bncount == 1;
-   r2->tseqbase = lci->ncand == 1 && BATtdense(bn) ? 
bn->tseqbase : oid_nil;
-   r2->tkey = lci->ncand == 1;
-   r2->tnil = false;
-   r2->tnonil = true;
-   }
-   }
if (bn == NULL) {
+   /* left outer join, no match, we're returning nil in r2 */
oid *o1p = (oid *) Tloc(r1, 0);
BUN p, q = bncount;
 
+   if (r2p) {
+   r2 = BATconstant(0, TYPE_void, _nil, lci->ncand * 
bncount, TRANSIENT);
+   if (r2 == NULL)
+   goto bailout;
+   *r2p = r2;
+   }
do {
GDK_CHECK_TIMEOUT(timeoffset, counter,
  GOTO_LABEL_TIMEOUT_HANDLER(bailout));
@@ -402,51 +387,65 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
}
o = canditer_next(lci);
} while (!is_oid_nil(o));
-   } else if (BATtdense(bn)) {
-   oid *o1p = (oid *) Tloc(r1, 0);
-   oid *o2p = r2 ? (oid *) Tloc(r2, 0) : NULL;
-   oid bno = bn->tseqbase;
-   BUN p, q = bncount;
-
-   do {
-   GDK_CHECK_TIMEOUT(timeoffset, counter,
- GOTO_LABEL_TIMEOUT_HANDLER(bailout));
-   for (p = 0; p < q; p++) {
-   *o1p++ = o;
-   }
-   if (o2p) {
-   for (p = 0; p < q; p++) {
-   *o2p++ = bno + p;
-   }
-   }
-   o = canditer_next(lci);
-   } while (!is_oid_nil(o));
} else {
oid *o1p = (oid *) Tloc(r1, 0);
-   oid *o2p = r2 ? (oid *) Tloc(r2, 0) : NULL;
-   const oid *bnp = (const oid *) Tloc(bn, 0);
+   oid *o2p;
BUN p, q = bncount;
 
-   do {
-   GDK_CHECK_TIMEOUT(timeoffset, counter,
- GOTO_LABEL_TIMEOUT_HANDLER(bailout));
-   for (p = 0; p < q; p++) {
-   *o1p++ = o;
-   }
-   if (o2p) {
+   if (r2p) {
+   r2 = COLnew(0, TYPE_oid, lci->ncand * bncount, 
TRANSIENT);
+   if (r2 == NULL)
+   goto bailout;
+   r2->tsorted = lci->ncand == 1 || bncount == 1;
+   r2->trevsorted = bncount == 1;
+   r2->tseqbase = lci->ncand == 1 && BATtdense(bn) ? 
bn->tseqbase : oid_nil;
+   r2->tkey = lci->ncand == 1;
+   r2->tnil = false;
+   r2->tnonil = true;
+   *r2p = r2;
+   o2p = (oid *) Tloc(r2, 0);
+   } else {
+   o2p = NULL;
+   }
+
+   if (BATtdense(bn)) {
+   oid bno = 

MonetDB: default - Merge with Jun2023 branch.

2023-09-13 Thread Sjoerd Mullender via checkin-list
Changeset: 2cf805b41908 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2cf805b41908
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_storage.c
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (120 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2077,7 +2077,7 @@ BBPdir_first(bool subcommit, lng logno, 
 * replacing the entries for the subcommitted bats */
if ((obbpf = GDKfileopen(0, SUBDIR, "BBP", "dir", "r")) == NULL 
&&
(obbpf = GDKfileopen(0, BAKDIR, "BBP", "dir", "r")) == 
NULL) {
-   GDKsyserror("subcommit attempted without backup 
BBP.dir.");
+   GDKsyserror("subcommit attempted without backup 
BBP.dir");
goto bailout;
}
/* read first three lines */
@@ -2143,7 +2143,7 @@ BBPdir_step(bat bid, BUN size, int n, ch
}
n = -1;
if (fclose(*obbpfp) == EOF) {
-   GDKsyserror("Closing backup BBP.dir file 
failed.\n");
+   GDKsyserror("Closing backup BBP.dir file 
failed\n");
GDKclrerr(); /* ignore error */
}
*obbpfp = NULL;
@@ -2181,7 +2181,7 @@ BBPdir_last(int n, char *buf, size_t buf
goto bailout;
}
if (fclose(obbpf) == EOF) {
-   GDKsyserror("Closing backup BBP.dir file 
failed.\n");
+   GDKsyserror("Closing backup BBP.dir file 
failed\n");
GDKclrerr(); /* ignore error */
}
obbpf = NULL;
@@ -3902,7 +3902,7 @@ BBPsync(int cnt, bat *restrict subcommit
 MT_rename(bakdir, deldir) < 0))
ret = GDK_FAIL;
if (ret != GDK_SUCCEED)
-   GDKsyserror("rename(%s,%s) failed.\n", bakdir, deldir);
+   GDKsyserror("rename(%s,%s) failed\n", bakdir, deldir);
TRC_DEBUG(IO_, "rename %s %s = %d\n", bakdir, deldir, (int) 
ret);
}
 
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -439,9 +439,11 @@ log_read_updates(logger *lg, trans *tr, 
} else {
lg->rbuf = t;
lg->rbufsize = tlen;
-   for (BUN p = 0; p < (BUN) nr; p++) {
-   if (r && BUNappend(r, t, true) != 
GDK_SUCCEED)
-   res = LOG_ERR;
+   if (r) {
+   for (BUN p = 0; p < (BUN) nr; p++) {
+   if (BUNappend(r, t, true) != 
GDK_SUCCEED)
+   res = LOG_ERR;
+   }
}
}
} else if (l->flag == LOG_UPDATE_BULK) {
@@ -2505,6 +2507,8 @@ log_flush(logger *lg, ulng ts)
if (updated == NULL) {
nupdated = BATcount(lg->catalog_id);
allocated = ((nupdated + 31) & ~31) / 8;
+   if (allocated == 0)
+   allocated = 4;
updated = GDKzalloc(allocated);
if (updated == NULL) {
log_unlock(lg);
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -184,7 +184,7 @@ GDKremovedir(int farmid, const char *dir
closedir(dirp);
ret = MT_rmdir(dirnamestr);
if (ret != 0)
-   GDKsyserror("rmdir(%s) failed.\n", dirnamestr);
+   GDKsyserror("rmdir(%s) failed\n", dirnamestr);
TRC_DEBUG(IO_, "rmdir %s = %d\n", dirnamestr, ret);
GDKfree(dirnamestr);
return ret ? GDK_FAIL : GDK_SUCCEED;
@@ -550,7 +550,7 @@ GDKload(int farmid, const char *nme, con
for (n_expected = (ssize_t) size; n_expected > 
0; n_expected -= n) {
n = read(fd, dst, (unsigned) MIN(1 << 
30, n_expected));
if (n < 0)
-   GDKsyserror("GDKload: cannot 
read: name=%s, ext=%s, %zu bytes missing.\n", nme, ext ? ext : "", (size_t) 
n_expected);
+   GDKsyserror("GDKload: cannot 
read: name=%s, ext=%s, %zu bytes missing\n", nme, ext ? ext : "", (size_t) 
n_expected);
 #ifndef __COVERITY__
/* Coverity doesn't seem to
 * 

MonetDB: Jun2023 - Skip loop if it is not going to do anything.

2023-09-13 Thread Sjoerd Mullender via checkin-list
Changeset: ed43a1ba032a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ed43a1ba032a
Modified Files:
gdk/gdk_logger.c
Branch: Jun2023
Log Message:

Skip loop if it is not going to do anything.


diffs (18 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -439,9 +439,11 @@ log_read_updates(logger *lg, trans *tr, 
} else {
lg->rbuf = t;
lg->rbufsize = tlen;
-   for (BUN p = 0; p < (BUN) nr; p++) {
-   if (r && BUNappend(r, t, true) != 
GDK_SUCCEED)
-   res = LOG_ERR;
+   if (r) {
+   for (BUN p = 0; p < (BUN) nr; p++) {
+   if (BUNappend(r, t, true) != 
GDK_SUCCEED)
+   res = LOG_ERR;
+   }
}
}
} else if (l->flag == LOG_UPDATE_BULK) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Assert is not the right way for checking for ...

2023-09-13 Thread Sjoerd Mullender via checkin-list
Changeset: adf6394f687c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/adf6394f687c
Modified Files:
sql/storage/bat/bat_storage.c
Branch: Jun2023
Log Message:

Assert is not the right way for checking for allocation failures.


diffs (33 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -3905,7 +3905,8 @@ log_table_append(sql_trans *tr, sql_tabl
if (cur->ts == tr->tid && !cur->deleted && 
cur->start < end) {
/* append col*/
BAT *ins = temp_descriptor(cs->bid);
-   assert(ins);
+   if (ins == NULL)
+   return LOG_ERR;
assert(BATcount(ins) >= cur->end);
ok = log_bat(store->logger, ins, 
c->base.id, cur->start, cur->end-cur->start, nr_appends);
bat_destroy(ins);
@@ -3917,7 +3918,8 @@ log_table_append(sql_trans *tr, sql_tabl
 
if (ok == GDK_SUCCEED && cs->ebid) {
BAT *ins = temp_descriptor(cs->ebid);
-   assert(ins);
+   if (ins == NULL)
+   return LOG_ERR;
if (BATcount(ins) > ins->batInserted)
ok = log_bat(store->logger, ins, -c->base.id, 
ins->batInserted, BATcount(ins)-ins->batInserted, 0);
BATcommit(ins, BATcount(ins));
@@ -3945,7 +3947,8 @@ log_table_append(sql_trans *tr, sql_tabl
if (cur->ts == tr->tid && !cur->deleted 
&& cur->start < end) {
/* append idx */
BAT *ins = 
temp_descriptor(cs->bid);
-   assert(ins);
+   if (ins == NULL)
+   return LOG_ERR;
assert(BATcount(ins) >= 
cur->end);
ok = log_bat(store->logger, 
ins, i->base.id, cur->start, cur->end-cur->start, nr_appends);
bat_destroy(ins);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Don't end GDKsyserror messages with period.

2023-09-13 Thread Sjoerd Mullender via checkin-list
Changeset: ccf5de31a115 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ccf5de31a115
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_storage.c
Branch: Jun2023
Log Message:

Don't end GDKsyserror messages with period.
The message is followed by a colon, and that looks silly.


diffs (60 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2073,7 +2073,7 @@ BBPdir_first(bool subcommit, lng logno, 
 * replacing the entries for the subcommitted bats */
if ((obbpf = GDKfileopen(0, SUBDIR, "BBP", "dir", "r")) == NULL 
&&
(obbpf = GDKfileopen(0, BAKDIR, "BBP", "dir", "r")) == 
NULL) {
-   GDKsyserror("subcommit attempted without backup 
BBP.dir.");
+   GDKsyserror("subcommit attempted without backup 
BBP.dir");
goto bailout;
}
/* read first three lines */
@@ -2139,7 +2139,7 @@ BBPdir_step(bat bid, BUN size, int n, ch
}
n = -1;
if (fclose(*obbpfp) == EOF) {
-   GDKsyserror("Closing backup BBP.dir file 
failed.\n");
+   GDKsyserror("Closing backup BBP.dir file 
failed\n");
GDKclrerr(); /* ignore error */
}
*obbpfp = NULL;
@@ -2177,7 +2177,7 @@ BBPdir_last(int n, char *buf, size_t buf
goto bailout;
}
if (fclose(obbpf) == EOF) {
-   GDKsyserror("Closing backup BBP.dir file 
failed.\n");
+   GDKsyserror("Closing backup BBP.dir file 
failed\n");
GDKclrerr(); /* ignore error */
}
obbpf = NULL;
@@ -3902,7 +3902,7 @@ BBPsync(int cnt, bat *restrict subcommit
 MT_rename(bakdir, deldir) < 0))
ret = GDK_FAIL;
if (ret != GDK_SUCCEED)
-   GDKsyserror("rename(%s,%s) failed.\n", bakdir, deldir);
+   GDKsyserror("rename(%s,%s) failed\n", bakdir, deldir);
TRC_DEBUG(IO_, "rename %s %s = %d\n", bakdir, deldir, (int) 
ret);
}
 
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -184,7 +184,7 @@ GDKremovedir(int farmid, const char *dir
closedir(dirp);
ret = MT_rmdir(dirnamestr);
if (ret != 0)
-   GDKsyserror("rmdir(%s) failed.\n", dirnamestr);
+   GDKsyserror("rmdir(%s) failed\n", dirnamestr);
TRC_DEBUG(IO_, "rmdir %s = %d\n", dirnamestr, ret);
GDKfree(dirnamestr);
return ret ? GDK_FAIL : GDK_SUCCEED;
@@ -550,7 +550,7 @@ GDKload(int farmid, const char *nme, con
for (n_expected = (ssize_t) size; n_expected > 
0; n_expected -= n) {
n = read(fd, dst, (unsigned) MIN(1 << 
30, n_expected));
if (n < 0)
-   GDKsyserror("GDKload: cannot 
read: name=%s, ext=%s, %zu bytes missing.\n", nme, ext ? ext : "", (size_t) 
n_expected);
+   GDKsyserror("GDKload: cannot 
read: name=%s, ext=%s, %zu bytes missing\n", nme, ext ? ext : "", (size_t) 
n_expected);
 #ifndef __COVERITY__
/* Coverity doesn't seem to
 * recognize that we're just
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Protect against 0 allocation.

2023-09-13 Thread Sjoerd Mullender via checkin-list
Changeset: 4d36477c1d82 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4d36477c1d82
Modified Files:
gdk/gdk_logger.c
Branch: Jun2023
Log Message:

Protect against 0 allocation.


diffs (12 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2507,6 +2507,8 @@ log_flush(logger *lg, ulng ts)
if (updated == NULL) {
nupdated = BATcount(lg->catalog_id);
allocated = ((nupdated + 31) & ~31) / 8;
+   if (allocated == 0)
+   allocated = 4;
updated = GDKzalloc(allocated);
if (updated == NULL) {
log_unlock(lg);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Removed MAL tokenizer module.

2023-09-13 Thread Sjoerd Mullender via checkin-list
Changeset: f9f293f6cb21 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f9f293f6cb21
Removed Files:
monetdb5/modules/mal/Tests/tokenizer00.maltest
monetdb5/modules/mal/tokenizer.c
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
common/stream/stream.h
monetdb5/ChangeLog
monetdb5/modules/mal/CMakeLists.txt
monetdb5/modules/mal/Tests/All
Branch: default
Log Message:

Removed MAL tokenizer module.


diffs (truncated from 1043 to 300 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -51033,56 +51033,6 @@ user_statistics
 pattern sysmon.user_statistics() (X_0:bat[:str], X_1:bat[:lng], X_2:bat[:lng], 
X_3:bat[:timestamp], X_4:bat[:timestamp], X_5:bat[:lng], X_6:bat[:str]) 
 SYSMONstatistics;
 (empty)
-tokenizer
-append
-command tokenizer.append(X_0:str):oid 
-TKNZRappend;
-tokenize a new string and append it to the tokenizer (duplicate elimination is 
performed)
-tokenizer
-close
-command tokenizer.close():void 
-TKNZRclose;
-close the current tokenizer store
-tokenizer
-depositFile
-command tokenizer.depositFile(X_0:str):void 
-TKNZRdepositFile;
-batch insertion from a file of strings to tokenize, each string is separated 
by a new line
-tokenizer
-getCardinality
-command tokenizer.getCardinality():bat[:lng] 
-TKNZRgetCardinality;
-debugging function that returns the unique tokens at each level
-tokenizer
-getCount
-command tokenizer.getCount():bat[:lng] 
-TKNZRgetCount;
-debugging function that returns the size of the bats at each level
-tokenizer
-getIndex
-command tokenizer.getIndex():bat[:oid] 
-TKNZRgetIndex;
-administrative function that returns the INDEX bat
-tokenizer
-getLevel
-command tokenizer.getLevel(X_0:int):bat[:str] 
-TKNZRgetLevel;
-administrative function that returns the bat on level i
-tokenizer
-locate
-pattern tokenizer.locate(X_0:str):oid 
-TKNZRlocate;
-if the given string is in the store returns its oid, otherwise oid_nil
-tokenizer
-open
-command tokenizer.open(X_0:str):void 
-TKNZRopen;
-open the named tokenizer store, a new one is created if the specified name 
does not exist
-tokenizer
-take
-pattern tokenizer.take(X_0:oid):str 
-TKNZRtakeOid;
-reconstruct and returns the i-th string
 txtsim
 dameraulevenshtein
 pattern txtsim.dameraulevenshtein(X_0:str, X_1:str):int 
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -39358,56 +39358,6 @@ user_statistics
 pattern sysmon.user_statistics() (X_0:bat[:str], X_1:bat[:lng], X_2:bat[:lng], 
X_3:bat[:timestamp], X_4:bat[:timestamp], X_5:bat[:lng], X_6:bat[:str]) 
 SYSMONstatistics;
 (empty)
-tokenizer
-append
-command tokenizer.append(X_0:str):oid 
-TKNZRappend;
-tokenize a new string and append it to the tokenizer (duplicate elimination is 
performed)
-tokenizer
-close
-command tokenizer.close():void 
-TKNZRclose;
-close the current tokenizer store
-tokenizer
-depositFile
-command tokenizer.depositFile(X_0:str):void 
-TKNZRdepositFile;
-batch insertion from a file of strings to tokenize, each string is separated 
by a new line
-tokenizer
-getCardinality
-command tokenizer.getCardinality():bat[:lng] 
-TKNZRgetCardinality;
-debugging function that returns the unique tokens at each level
-tokenizer
-getCount
-command tokenizer.getCount():bat[:lng] 
-TKNZRgetCount;
-debugging function that returns the size of the bats at each level
-tokenizer
-getIndex
-command tokenizer.getIndex():bat[:oid] 
-TKNZRgetIndex;
-administrative function that returns the INDEX bat
-tokenizer
-getLevel
-command tokenizer.getLevel(X_0:int):bat[:str] 
-TKNZRgetLevel;
-administrative function that returns the bat on level i
-tokenizer
-locate
-pattern tokenizer.locate(X_0:str):oid 
-TKNZRlocate;
-if the given string is in the store returns its oid, otherwise oid_nil
-tokenizer
-open
-command tokenizer.open(X_0:str):void 
-TKNZRopen;
-open the named tokenizer store, a new one is created if the specified name 
does not exist
-tokenizer
-take
-pattern tokenizer.take(X_0:oid):str 
-TKNZRtakeOid;
-reconstruct and returns the i-th string
 txtsim
 dameraulevenshtein
 pattern txtsim.dameraulevenshtein(X_0:str, X_1:str):int 
diff --git a/common/stream/stream.h b/common/stream/stream.h
--- a/common/stream/stream.h
+++ b/common/stream/stream.h
@@ -245,7 +245,7 @@ typedef struct bstream {
 
 stream_export bstream *bstream_create(stream *rs, size_t chunk_size); // used 
all over
 stream_export void bstream_destroy(bstream *s); // all over
-stream_export ssize_t bstream_read(bstream *s, size_t size); // tablet.c, 
tokenizer.c
+stream_export ssize_t bstream_read(bstream *s, size_t size); // tablet.c
 stream_export ssize_t bstream_next(bstream *s); // all over
 
 /* Callback stream is a stream where the read and write 

MonetDB: Jun2023 - When BATdescriptor returns NULL it's almost i...

2023-09-13 Thread Sjoerd Mullender via checkin-list
Changeset: 090b57f9574b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/090b57f9574b
Modified Files:
gdk/gdk_logger.c
sql/backends/monet5/sql_upgrades.c
sql/storage/bat/bat_storage.c
Branch: Jun2023
Log Message:

When BATdescriptor returns NULL it's almost invariably an error.
So return an error, don't just do nothing.


diffs (164 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2085,6 +2085,12 @@ log_load(const char *fn, const char *log
lg->seqs_val = BATdescriptor(BBPindex(bak));
strconcat_len(bak, sizeof(bak), fn, "_dseqs", NULL);
lg->dseqs = BATdescriptor(BBPindex(bak));
+   if (lg->seqs_id == NULL ||
+   lg->seqs_val == NULL ||
+   lg->dseqs == NULL) {
+   GDKerror("Logger_new: cannot load seqs bats");
+   goto error;
+   }
} else {
lg->seqs_id = logbat_new(TYPE_int, 1, PERSISTENT);
lg->seqs_val = logbat_new(TYPE_lng, 1, PERSISTENT);
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -190,26 +190,28 @@ check_sys_tables(Client c, mvc *m, sql_s
if (err)
return err;
BAT *b;
-   if ((b = BATdescriptor(output->cols[0].b)) != NULL) {
-   if (BATcount(b) > 0) {
-   BATiter bi = bat_iterator(b);
-   needsystabfix = * (int *) BUNtloc(bi, 0) != id;
-   bat_iterator_end();
-   }
-   BBPunfix(b->batCacheid);
+   b = BATdescriptor(output->cols[0].b);
+   res_table_destroy(output);
+   if (b == NULL)
+   throw(SQL, "sql.catalog", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+   if (BATcount(b) > 0) {
+   BATiter bi = bat_iterator(b);
+   needsystabfix = * (int *) BUNtloc(bi, 0) != id;
+   bat_iterator_end();
}
-   res_table_destroy(output);
+   BBPunfix(b->batCacheid);
if (i == 0 && !needsystabfix) {
snprintf(buf, sizeof(buf),
 "select a.type from sys.functions f 
join sys.args a on f.id = a.func_id where f.name = 'quarter' and f.schema_id = 
2000 and a.inout = 0 and a.type = 'int';\n");
err = SQLstatementIntern(c, buf, "update", true, false, 
);
if (err)
return err;
-   if ((b = BATdescriptor(output->cols[0].b)) != NULL) {
-   needsystabfix = BATcount(b) > 0;
-   BBPunfix(b->batCacheid);
-   }
+   b = BATdescriptor(output->cols[0].b);
res_table_destroy(output);
+   if (b == NULL)
+   throw(SQL, "sql.catalog", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+   needsystabfix = BATcount(b) > 0;
+   BBPunfix(b->batCacheid);
}
if (needsystabfix)
return sql_fix_system_tables(c, m);
@@ -1703,6 +1705,11 @@ sql_update_jun2020_bam(Client c, mvc *m)
return err;
}
b = BATdescriptor(output->cols[0].b);
+   res_table_destroy(output);
+   if (b == NULL) {
+   GDKfree(buf);
+   throw(SQL, "sql.catalog", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+   }
pos = 0;
pos += snprintf(buf + pos, bufsize - pos,
"update sys.schemas set system = false where name = 
'bam';\n"
@@ -1718,20 +1725,17 @@ sql_update_jun2020_bam(Client c, mvc *m)
"drop function bam.seq_char cascade;\n"
"drop procedure bam.sam_export cascade;\n"
"drop procedure bam.bam_export cascade;\n");
-   if (b) {
-   if (BATcount(b) > 0 && *(lng *) Tloc(b, 0) == 0) {
-   /* tables in bam schema are empty: drop them */
-   pos += snprintf(buf + pos, bufsize - pos,
-   "drop table bam.sq cascade;\n"
-   "drop table bam.rg cascade;\n"
-   "drop table bam.pg cascade;\n"
-   "drop table bam.export cascade;\n"
-   "drop table bam.files cascade;\n"
-   "drop schema bam cascade;\n");
-   }
-   BBPunfix(b->batCacheid);
+   if (BATcount(b) > 0 && 

MonetDB: Jun2023 - A single error message if read fails is enough.

2023-09-13 Thread Sjoerd Mullender via checkin-list
Changeset: b5b4a7c8eae9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b5b4a7c8eae9
Modified Files:
gdk/gdk_storage.c
Branch: Jun2023
Log Message:

A single error message if read fails is enough.


diffs (22 lines):

diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -550,7 +550,7 @@ GDKload(int farmid, const char *nme, con
for (n_expected = (ssize_t) size; n_expected > 
0; n_expected -= n) {
n = read(fd, dst, (unsigned) MIN(1 << 
30, n_expected));
if (n < 0)
-   GDKsyserror("GDKload: cannot 
read: name=%s, ext=%s, %zu bytes missing\n", nme, ext ? ext : "", (size_t) 
n_expected);
+   GDKsyserror("GDKload: cannot 
read: name=%s, ext=%s, expected %zu, %zd bytes missing\n", nme, ext ? ext : "", 
size, n_expected);
 #ifndef __COVERITY__
/* Coverity doesn't seem to
 * recognize that we're just
@@ -567,7 +567,8 @@ GDKload(int farmid, const char *nme, con
/* we couldn't read all, error
 * already generated */
GDKfree(ret);
-   GDKerror("short read from heap %s%s%s, 
expected %zu, missing %zd\n", nme, ext ? "." : "", ext ? ext : "", size, 
n_expected);
+   if (n >= 0) /* don't report error twice 
 */
+   GDKerror("short read from heap 
%s%s%s, expected %zu, missing %zd\n", nme, ext ? "." : "", ext ? ext : "", 
size, n_expected);
ret = NULL;
}
 #ifndef NDEBUG
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Copy-paste error.

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

Copy-paste error.


diffs (12 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1669,7 +1669,7 @@ GDKvm_cursize(void)
 #ifndef NDEBUG
 #define heapdec(_memdelta) 
\
do {\
-   ATOMIC_BASE_TYPE old = ATOMIC_ADD(_mallocedbytes_estimate, 
_memdelta); \
+   ATOMIC_BASE_TYPE old = ATOMIC_SUB(_mallocedbytes_estimate, 
_memdelta); \
assert(old >= (ATOMIC_BASE_TYPE) _memdelta);\
} while (0)
 #else
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - We implemented it, now also use it.

2023-09-08 Thread Sjoerd Mullender via checkin-list
Changeset: 33eb7e878189 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/33eb7e878189
Modified Files:
gdk/gdk_join.c
Branch: default
Log Message:

We implemented it, now also use it.
(Well, potentially.  The nil_on_miss code in selectjoin does not get
exercised by our test set.)


diffs (12 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3902,7 +3902,7 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
goto doreturn;
}
 
-   if (!nil_on_miss && !only_misses && !not_in &&
+   if (!only_misses && !not_in &&
(lci.ncand == 1 || (BATordered(l) && BATordered_rev(l)) ||
 (l->ttype == TYPE_void && is_oid_nil(l->tseqbase {
/* single value to join, use select */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Updated documentation.

2023-08-31 Thread Sjoerd Mullender via checkin-list
Changeset: 328d38218a64 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/328d38218a64
Modified Files:
debian/monetdb5-sql.README.Debian
Branch: Jun2023
Log Message:

Updated documentation.


diffs (33 lines):

diff --git a/debian/monetdb5-sql.README.Debian 
b/debian/monetdb5-sql.README.Debian
--- a/debian/monetdb5-sql.README.Debian
+++ b/debian/monetdb5-sql.README.Debian
@@ -2,7 +2,16 @@
 Usage
 =
 
-There are multiple ways to use MonetDB5-sql, but this is the most Debianic.
+There are multiple ways to use MonetDB5-sql.
+
+The modern way is to do:
+
+ * Enable and start MonetDB in one go::
+
+   $ sudo systemctl enable --now monetdbd.service
+
+This is the old way using System V init scripts, incompatible with the
+above:
 
  * Set STARTUP to "yes" in /etc/default/monetdb5-sql
 
@@ -10,7 +19,10 @@ There are multiple ways to use MonetDB5-
  
$ sudo /etc/init.d/monetdb5-sql start
 
- * Add yourself to the "monetdb" group::
+In either case, do this:
+
+ * Add yourself to the "monetdb" group (after this, logout and back in
+   for this to take effect)::
 
$ sudo addgroup `whoami` monetdb
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: use_min_max_prop - Closing branch use_min_max_prop.

2023-08-31 Thread Sjoerd Mullender via checkin-list
Changeset: c3379072fe3f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c3379072fe3f
Branch: use_min_max_prop
Log Message:

Closing branch use_min_max_prop.

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Fix scope.

2023-09-14 Thread Sjoerd Mullender via checkin-list
Changeset: bf85a4f1f1fc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bf85a4f1f1fc
Modified Files:
monetdb5/modules/kernel/batmmath.c
Branch: Jun2023
Log Message:

Fix scope.


diffs (15 lines):

diff --git a/monetdb5/modules/kernel/batmmath.c 
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -95,9 +95,10 @@ CMDscienceUNARY(MalStkPtr stk, InstrPtr 
BBPreclaim(s);
if (e != 0 || ex != 0) {
const char *err;
+   char buf[128];
BBPunfix(bn->batCacheid);
if (e)
-   err = GDKstrerror(e, (char[128]) { 0 }, 128);
+   err = GDKstrerror(e, buf, 128);
else if (ex & FE_DIVBYZERO)
err = "Divide by zero";
else if (ex & FE_OVERFLOW)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Extend selectjoin implementation to also do s...

2023-09-08 Thread Sjoerd Mullender via checkin-list
Changeset: 43e157bb2be3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/43e157bb2be3
Modified Files:
gdk/gdk_join.c
sql/test/SQLancer/Tests/sqlancer22.test
sql/test/SQLancer/Tests/sqlancer23.test
sql/test/subquery/Tests/subquery3.test
sql/test/subquery/Tests/subquery5.test
Branch: Jun2023
Log Message:

Extend selectjoin implementation to also do semi, min_one, max_one options.


diffs (266 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -301,11 +301,13 @@ nomatch(BAT **r1p, BAT **r2p, BAT *l, BA
 static gdk_return
 selectjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r,
   struct canditer *lci, struct canditer *rci,
-  bool nil_matches, lng t0, bool swapped, const char *reason)
+  bool nil_matches, bool semi, bool max_one, bool min_one,
+  lng t0, bool swapped, const char *reason)
 {
BATiter li = bat_iterator(l);
const void *v;
BAT *bn = NULL;
+   BUN bncount;
 
assert(lci->ncand > 0);
assert(lci->ncand == 1 || (li.sorted && li.revsorted));
@@ -334,32 +336,46 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
if (bn == NULL) {
return GDK_FAIL;
}
-   if (BATcount(bn) == 0) {
+   bncount = BATcount(bn);
+   if (bncount == 0) {
BBPunfix(bn->batCacheid);
+   if (min_one) {
+   GDKerror("not enough matches");
+   return GDK_FAIL;
+   }
return nomatch(r1p, r2p, l, r, lci, false, false,
   reason, t0);
}
-   BAT *r1 = COLnew(0, TYPE_oid, lci->ncand * BATcount(bn), TRANSIENT);
+   if (bncount > 1) {
+   if (semi)
+   bncount = 1;
+   if (max_one) {
+   BBPunfix(bn->batCacheid);
+   GDKerror("more than one match");
+   return GDK_FAIL;
+   }
+   }
+   BAT *r1 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
if (r1 == NULL) {
BBPunfix(bn->batCacheid);
return GDK_FAIL;
}
r1->tsorted = true;
r1->trevsorted = lci->ncand == 1;
-   r1->tseqbase = BATcount(bn) == 1 && lci->tpe == cand_dense ? o : 
oid_nil;
-   r1->tkey = BATcount(bn) == 1;
+   r1->tseqbase = bncount == 1 && lci->tpe == cand_dense ? o : oid_nil;
+   r1->tkey = bncount == 1;
r1->tnil = false;
r1->tnonil = true;
BAT *r2 = NULL;
if (r2p) {
-   r2 = COLnew(0, TYPE_oid, lci->ncand * BATcount(bn), TRANSIENT);
+   r2 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
if (r2 == NULL) {
BBPunfix(bn->batCacheid);
BBPreclaim(r1);
return GDK_FAIL;
}
-   r2->tsorted = lci->ncand == 1 || BATcount(bn) == 1;
-   r2->trevsorted = BATcount(bn) == 1;
+   r2->tsorted = lci->ncand == 1 || bncount == 1;
+   r2->trevsorted = bncount == 1;
r2->tseqbase = lci->ncand == 1 && BATtdense(bn) ? bn->tseqbase 
: oid_nil;
r2->tkey = lci->ncand == 1;
r2->tnil = false;
@@ -369,7 +385,7 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
oid *o1p = (oid *) Tloc(r1, 0);
oid *o2p = r2 ? (oid *) Tloc(r2, 0) : NULL;
oid bno = bn->tseqbase;
-   BUN p, q = BATcount(bn);
+   BUN p, q = bncount;
 
do {
GDK_CHECK_TIMEOUT(timeoffset, counter,
@@ -388,7 +404,7 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
oid *o1p = (oid *) Tloc(r1, 0);
oid *o2p = r2 ? (oid *) Tloc(r2, 0) : NULL;
const oid *bnp = (const oid *) Tloc(bn, 0);
-   BUN p, q = BATcount(bn);
+   BUN p, q = bncount;
 
do {
GDK_CHECK_TIMEOUT(timeoffset, counter,
@@ -404,10 +420,10 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
o = canditer_next(lci);
} while (!is_oid_nil(o));
}
-   BATsetcount(r1, lci->ncand * BATcount(bn));
+   BATsetcount(r1, lci->ncand * bncount);
*r1p = r1;
if (r2p) {
-   BATsetcount(r2, lci->ncand * BATcount(bn));
+   BATsetcount(r2, lci->ncand * bncount);
*r2p = r2;
}
BBPunfix(bn->batCacheid);
@@ -3865,12 +3881,13 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
goto doreturn;
}
 
-   if (!nil_on_miss && !semi && !max_one && !min_one && !only_misses && 
!not_in &&
+   if (!nil_on_miss && !only_misses && !not_in &&
(lci.ncand == 1 || (BATordered(l) && BATordered_rev(l)) ||
 (l->ttype == TYPE_void && is_oid_nil(l->tseqbase {
   

MonetDB: Jun2023 - Keep track of what we're doing.

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

Keep track of what we're doing.


diffs (27 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1518,6 +1518,7 @@ BBPmanager(void *dummy)
 
for (;;) {
int n = 0;
+   MT_thread_setworking("clearing HOT bits");
for (bat bid = 1, nbat = (bat) ATOMIC_GET(); bid < 
nbat; bid++) {
MT_lock_set((bid));
if (BBP_refs(bid) == 0 && BBP_lrefs(bid) != 0) {
@@ -1528,12 +1529,15 @@ BBPmanager(void *dummy)
}
TRC_DEBUG(BAT_, "cleared HOT bit from %d bats\n", n);
size_t cur = GDKvm_cursize();
+   MT_thread_setworking("sleeping");
for (int i = 0, n = changed && cur > GDK_vm_maxsize / 2 ? 1 : 
cur > GDK_vm_maxsize / 4 ? 10 : 100; i < n; i++) {
MT_sleep_ms(100);
if (GDKexiting())
return;
}
+   MT_thread_setworking("BBPtrim");
changed = BBPtrim(false);
+   MT_thread_setworking("BBPcallbacks");
BBPcallbacks();
if (GDKexiting())
return;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Option should be passed on.

2023-09-08 Thread Sjoerd Mullender via checkin-list
Changeset: cf37eba63bdb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cf37eba63bdb
Modified Files:
gdk/gdk_join.c
Branch: default
Log Message:

Option should be passed on.


diffs (21 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -327,7 +327,7 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
(*ATOMcompare(li.type))(v, ATOMnilptr(li.type)) == 0) {
/* NIL doesn't match anything */
bat_iterator_end();
-   return nomatch(r1p, r2p, l, r, lci, false, false,
+   return nomatch(r1p, r2p, l, r, lci, nil_on_miss, false,
   reason, t0);
}
 
@@ -344,7 +344,7 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
return GDK_FAIL;
}
if (!nil_on_miss)
-   return nomatch(r1p, r2p, l, r, lci, false, false,
+   return nomatch(r1p, r2p, l, r, lci, nil_on_miss, false,
   reason, t0);
/* special case: return nil on RHS */
bncount = 1;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch.

2023-09-08 Thread Sjoerd Mullender via checkin-list
Changeset: b45c745c63db for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b45c745c63db
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_join.c
gdk/gdk_utils.c
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (truncated from 379 to 300 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1468,10 +1468,11 @@ movestrbats(void)
 }
 #endif
 
-static void
+static bool
 BBPtrim(bool aggressive)
 {
int n = 0;
+   bool changed = false;
unsigned flag = BBPUNLOADING | BBPSYNCING | BBPSAVING;
if (!aggressive)
flag |= BBPHOT;
@@ -1502,19 +1503,23 @@ BBPtrim(bool aggressive)
if (BBPfree(b) != GDK_SUCCEED)
GDKerror("unload failed for bat %d", bid);
n++;
+   changed = true;
}
BBPtmunlock();
}
TRC_DEBUG(BAT_, "unloaded %d bats%s\n", n, aggressive ? " (also hot)" : 
"");
+   return changed;
 }
 
 static void
 BBPmanager(void *dummy)
 {
(void) dummy;
+   bool changed = true;
 
for (;;) {
int n = 0;
+   MT_thread_setworking("clearing HOT bits");
for (bat bid = 1, nbat = (bat) ATOMIC_GET(); bid < 
nbat; bid++) {
MT_lock_set((bid));
if (BBP_refs(bid) == 0 && BBP_lrefs(bid) != 0) {
@@ -1525,12 +1530,15 @@ BBPmanager(void *dummy)
}
TRC_DEBUG(BAT_, "cleared HOT bit from %d bats\n", n);
size_t cur = GDKvm_cursize();
-   for (int i = 0, n = cur > GDK_vm_maxsize / 2 ? 1 : cur > 
GDK_vm_maxsize / 4 ? 10 : 100; i < n; i++) {
+   MT_thread_setworking("sleeping");
+   for (int i = 0, n = changed && cur > GDK_vm_maxsize / 2 ? 1 : 
cur > GDK_vm_maxsize / 4 ? 10 : 100; i < n; i++) {
MT_sleep_ms(100);
if (GDKexiting())
return;
}
-   BBPtrim(false);
+   MT_thread_setworking("BBPtrim");
+   changed = BBPtrim(false);
+   MT_thread_setworking("BBPcallbacks");
BBPcallbacks();
if (GDKexiting())
return;
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -301,11 +301,13 @@ nomatch(BAT **r1p, BAT **r2p, BAT *l, BA
 static gdk_return
 selectjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r,
   struct canditer *lci, struct canditer *rci,
-  bool nil_matches, lng t0, bool swapped, const char *reason)
+  bool nil_matches, bool semi, bool max_one, bool min_one,
+  lng t0, bool swapped, const char *reason)
 {
BATiter li = bat_iterator(l);
const void *v;
BAT *bn = NULL;
+   BUN bncount;
 
assert(lci->ncand > 0);
assert(lci->ncand == 1 || (li.sorted && li.revsorted));
@@ -334,32 +336,46 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
if (bn == NULL) {
return GDK_FAIL;
}
-   if (BATcount(bn) == 0) {
+   bncount = BATcount(bn);
+   if (bncount == 0) {
BBPunfix(bn->batCacheid);
+   if (min_one) {
+   GDKerror("not enough matches");
+   return GDK_FAIL;
+   }
return nomatch(r1p, r2p, l, r, lci, false, false,
   reason, t0);
}
-   BAT *r1 = COLnew(0, TYPE_oid, lci->ncand * BATcount(bn), TRANSIENT);
+   if (bncount > 1) {
+   if (semi)
+   bncount = 1;
+   if (max_one) {
+   BBPunfix(bn->batCacheid);
+   GDKerror("more than one match");
+   return GDK_FAIL;
+   }
+   }
+   BAT *r1 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
if (r1 == NULL) {
BBPunfix(bn->batCacheid);
return GDK_FAIL;
}
r1->tsorted = true;
r1->trevsorted = lci->ncand == 1;
-   r1->tseqbase = BATcount(bn) == 1 && lci->tpe == cand_dense ? o : 
oid_nil;
-   r1->tkey = BATcount(bn) == 1;
+   r1->tseqbase = bncount == 1 && lci->tpe == cand_dense ? o : oid_nil;
+   r1->tkey = bncount == 1;
r1->tnil = false;
r1->tnonil = true;
BAT *r2 = NULL;
if (r2p) {
-   r2 = COLnew(0, TYPE_oid, lci->ncand * BATcount(bn), TRANSIENT);
+   r2 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
if (r2 == NULL) {
BBPunfix(bn->batCacheid);
BBPreclaim(r1);
return GDK_FAIL;
}
-   r2->tsorted = lci->ncand == 1 || BATcount(bn) == 1;
-   r2->trevsorted = BATcount(bn) == 1;
+   

MonetDB: default - Extend selectjoin implementation to also do n...

2023-09-08 Thread Sjoerd Mullender via checkin-list
Changeset: 46db239e93e6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/46db239e93e6
Modified Files:
gdk/gdk_join.c
Branch: default
Log Message:

Extend selectjoin implementation to also do nil_on_miss option.


diffs (134 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -301,7 +301,7 @@ nomatch(BAT **r1p, BAT **r2p, BAT *l, BA
 static gdk_return
 selectjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r,
   struct canditer *lci, struct canditer *rci,
-  bool nil_matches, bool semi, bool max_one, bool min_one,
+  bool nil_matches, bool nil_on_miss, bool semi, bool max_one, bool 
min_one,
   lng t0, bool swapped, const char *reason)
 {
BATiter li = bat_iterator(l);
@@ -338,26 +338,30 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
}
bncount = BATcount(bn);
if (bncount == 0) {
-   BBPunfix(bn->batCacheid);
+   BBPreclaim(bn);
if (min_one) {
GDKerror("not enough matches");
return GDK_FAIL;
}
-   return nomatch(r1p, r2p, l, r, lci, false, false,
-  reason, t0);
+   if (!nil_on_miss)
+   return nomatch(r1p, r2p, l, r, lci, false, false,
+  reason, t0);
+   /* special case: return nil on RHS */
+   bncount = 1;
+   bn = NULL;
}
if (bncount > 1) {
if (semi)
bncount = 1;
if (max_one) {
-   BBPunfix(bn->batCacheid);
+   BBPreclaim(bn);
GDKerror("more than one match");
return GDK_FAIL;
}
}
BAT *r1 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
if (r1 == NULL) {
-   BBPunfix(bn->batCacheid);
+   BBPreclaim(bn);
return GDK_FAIL;
}
r1->tsorted = true;
@@ -368,20 +372,37 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
r1->tnonil = true;
BAT *r2 = NULL;
if (r2p) {
-   r2 = COLnew(0, TYPE_oid, lci->ncand * bncount, TRANSIENT);
+   if (bn)
+   r2 = COLnew(0, TYPE_oid, lci->ncand * bncount, 
TRANSIENT);
+   else
+   r2 = BATconstant(0, TYPE_void, _nil, lci->ncand * 
bncount, TRANSIENT);
if (r2 == NULL) {
-   BBPunfix(bn->batCacheid);
+   BBPreclaim(bn);
BBPreclaim(r1);
return GDK_FAIL;
}
-   r2->tsorted = lci->ncand == 1 || bncount == 1;
-   r2->trevsorted = bncount == 1;
-   r2->tseqbase = lci->ncand == 1 && BATtdense(bn) ? bn->tseqbase 
: oid_nil;
-   r2->tkey = lci->ncand == 1;
-   r2->tnil = false;
-   r2->tnonil = true;
+   if (bn) {
+   r2->tsorted = lci->ncand == 1 || bncount == 1;
+   r2->trevsorted = bncount == 1;
+   r2->tseqbase = lci->ncand == 1 && BATtdense(bn) ? 
bn->tseqbase : oid_nil;
+   r2->tkey = lci->ncand == 1;
+   r2->tnil = false;
+   r2->tnonil = true;
+   }
}
-   if (BATtdense(bn)) {
+   if (bn == NULL) {
+   oid *o1p = (oid *) Tloc(r1, 0);
+   BUN p, q = bncount;
+
+   do {
+   GDK_CHECK_TIMEOUT(timeoffset, counter,
+ GOTO_LABEL_TIMEOUT_HANDLER(bailout));
+   for (p = 0; p < q; p++) {
+   *o1p++ = o;
+   }
+   o = canditer_next(lci);
+   } while (!is_oid_nil(o));
+   } else if (BATtdense(bn)) {
oid *o1p = (oid *) Tloc(r1, 0);
oid *o2p = r2 ? (oid *) Tloc(r2, 0) : NULL;
oid bno = bn->tseqbase;
@@ -422,11 +443,11 @@ selectjoin(BAT **r1p, BAT **r2p, BAT *l,
}
BATsetcount(r1, lci->ncand * bncount);
*r1p = r1;
-   if (r2p) {
+   if (bn && r2p) {
BATsetcount(r2, lci->ncand * bncount);
*r2p = r2;
}
-   BBPunfix(bn->batCacheid);
+   BBPreclaim(bn);
TRC_DEBUG(ALGO, "l=" ALGOBATFMT ","
  "r=" ALGOBATFMT ",sl=" ALGOOPTBATFMT ","
  "sr=" ALGOOPTBATFMT ",nil_matches=%s;%s %s "
@@ -3886,7 +3907,7 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
 (l->ttype == TYPE_void && is_oid_nil(l->tseqbase {
/* single value to join, use select */
rc = selectjoin(r1p, r2p, l, r, , ,
-   nil_matches, semi, max_one, min_one,
+   

MonetDB: groupjoin - Merge with default branch.

2023-09-08 Thread Sjoerd Mullender via checkin-list
Changeset: 249a62de0e9e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/249a62de0e9e
Modified Files:
clients/Tests/exports.stable.out
Branch: groupjoin
Log Message:

Merge with default branch.


diffs (truncated from 1440 to 300 lines):

diff --git a/buildtools/coverity_model.c b/buildtools/coverity_model.c
--- a/buildtools/coverity_model.c
+++ b/buildtools/coverity_model.c
@@ -126,7 +126,7 @@ GDKmmap(const char *path, int mode, size
 }
 
 gdk_return
-GDKmunmap(void *p, size_t size)
+GDKmunmap(void *p, int mode, size_t size)
 {
int failed;
__coverity_free__(p);
@@ -139,7 +139,7 @@ GDKmremap(const char *path, int mode, vo
 {
void *p = GDKmmap(path, mode, new_size);
if (p) {
-   (void) GDKmunmap(old_address, old_size);
+   (void) GDKmunmap(old_address, mode, old_size);
}
return p;
 }
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -300,7 +300,7 @@ size_t GDKmem_cursize(void);
 gdk_return GDKmergeidx(BAT *b, BAT **a, int n_ar);
 void *GDKmmap(const char *path, int mode, size_t len) 
__attribute__((__warn_unused_result__));
 int GDKms(void);
-gdk_return GDKmunmap(void *addr, size_t len);
+gdk_return GDKmunmap(void *addr, int mode, size_t len);
 int GDKnr_threads;
 void GDKprepareExit(void);
 void GDKprintinfo(void);
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1468,10 +1468,11 @@ movestrbats(void)
 }
 #endif
 
-static void
+static bool
 BBPtrim(bool aggressive)
 {
int n = 0;
+   bool changed = false;
unsigned flag = BBPUNLOADING | BBPSYNCING | BBPSAVING;
if (!aggressive)
flag |= BBPHOT;
@@ -1502,19 +1503,23 @@ BBPtrim(bool aggressive)
if (BBPfree(b) != GDK_SUCCEED)
GDKerror("unload failed for bat %d", bid);
n++;
+   changed = true;
}
BBPtmunlock();
}
TRC_DEBUG(BAT_, "unloaded %d bats%s\n", n, aggressive ? " (also hot)" : 
"");
+   return changed;
 }
 
 static void
 BBPmanager(void *dummy)
 {
(void) dummy;
+   bool changed = true;
 
for (;;) {
int n = 0;
+   MT_thread_setworking("clearing HOT bits");
for (bat bid = 1, nbat = (bat) ATOMIC_GET(); bid < 
nbat; bid++) {
MT_lock_set((bid));
if (BBP_refs(bid) == 0 && BBP_lrefs(bid) != 0) {
@@ -1525,12 +1530,15 @@ BBPmanager(void *dummy)
}
TRC_DEBUG(BAT_, "cleared HOT bit from %d bats\n", n);
size_t cur = GDKvm_cursize();
-   for (int i = 0, n = cur > GDK_vm_maxsize / 2 ? 1 : cur > 
GDK_vm_maxsize / 4 ? 10 : 100; i < n; i++) {
+   MT_thread_setworking("sleeping");
+   for (int i = 0, n = changed && cur > GDK_vm_maxsize / 2 ? 1 : 
cur > GDK_vm_maxsize / 4 ? 10 : 100; i < n; i++) {
MT_sleep_ms(100);
if (GDKexiting())
return;
}
-   BBPtrim(false);
+   MT_thread_setworking("BBPtrim");
+   changed = BBPtrim(false);
+   MT_thread_setworking("BBPcallbacks");
BBPcallbacks();
if (GDKexiting())
return;
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -687,7 +687,11 @@ HEAPfree(Heap *h, bool rmheap)
//heap is stored in regular C memory rather than GDK 
memory,so we call free()
free(h->base);
} else if (h->storage != STORE_NOWN) {  /* mapped file, or 
STORE_PRIV */
-   gdk_return ret = GDKmunmap(h->base, h->size);
+   gdk_return ret = GDKmunmap(h->base,
+  h->storage == STORE_PRIV ?
+  MMAP_COPY | MMAP_READ | 
MMAP_WRITE :
+  MMAP_READ | MMAP_WRITE,
+  h->size);
 
if (ret != GDK_SUCCEED) {
GDKsyserror("HEAPfree: %s was not mapped\n",
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -301,11 +301,13 @@ nomatch(BAT **r1p, BAT **r2p, BAT *l, BA
 static gdk_return
 selectjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r,
   struct canditer *lci, struct canditer *rci,
-  bool nil_matches, lng t0, bool swapped, const char *reason)
+  bool nil_matches, bool nil_on_miss, bool semi, bool max_one, bool 
min_one,
+  lng t0, bool swapped, const char *reason)
 {
BATiter li = bat_iterator(l);
const void *v;
  

MonetDB: Jun2023 - Approve powerpc upgrade output.

2023-10-25 Thread Sjoerd Mullender via checkin-list
Changeset: 5c16ae49b8e7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5c16ae49b8e7
Modified Files:
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
Branch: Jun2023
Log Message:

Approve powerpc upgrade output.


diffs (13 lines):

diff --git 
a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128 
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
@@ -70,7 +70,7 @@ update sys.functions set system = true w
 update sys.functions set system = true where system <> true and name = 
'filter' and schema_id = (select id from sys.schemas where name = 'json') and 
type = 1;
 
 Running database upgrade commands:
-CREATE FUNCTION "timestamp_to_str"(d TIMESTAMP, format STRING) RETURNS STRING 
EXTERNAL NAME mtime."timestamp_to_str";
-GRANT EXECUTE ON FUNCTION "timestamp_to_str"(TIMESTAMP, STRING) TO PUBLIC;
+CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING 
EXTERNAL NAME mtime."timestamp_to_str";
+GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC;
 UPDATE sys.functions SET system = true WHERE system <> true AND name = 
'timestamp_to_str' AND schema_id = 2000 and type = 1;
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Approve upgrades for recent changes.

2023-10-25 Thread Sjoerd Mullender via checkin-list
Changeset: 314bef24a7e2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/314bef24a7e2
Modified Files:

sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out.int128

sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Approve upgrades for recent changes.


diffs (truncated from 3268 to 300 lines):

diff --git 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -599,15 +599,15 @@ CREATE VIEW INFORMATION_SCHEMA.COLUMNS A
   cast(c."number" +1 AS int) AS ORDINAL_POSITION,
   c."default" AS COLUMN_DEFAULT,
   cast(sys.ifthenelse(c."null", 'YES', 'NO') AS varchar(3)) AS IS_NULLABLE,
-  c."type" AS DATA_TYPE,
+  CASE c."type" WHEN 'day_interval' THEN 'interval day' WHEN 'month_interval' 
THEN 'interval month' WHEN 'sec_interval' THEN 'interval second' ELSE c."type" 
END AS DATA_TYPE,
   cast(sys.ifthenelse(c."type" IN 
('varchar','clob','char','json','url','xml'), c."type_digits", NULL) AS int) AS 
CHARACTER_MAXIMUM_LENGTH,
   cast(sys.ifthenelse(c."type" IN 
('varchar','clob','char','json','url','xml'), c."type_digits" * 3, NULL) AS 
int) AS CHARACTER_OCTET_LENGTH,
   cast(sys.ifthenelse(c."type" IN 
('int','smallint','tinyint','bigint','hugeint','float','real','double','decimal','numeric','oid'),
 c."type_digits", NULL) AS int) AS NUMERIC_PRECISION,
   cast(sys.ifthenelse(c."type" IN 
('int','smallint','tinyint','bigint','hugeint','float','real','double','oid'), 
2, sys.ifthenelse(c."type" IN ('decimal','numeric'), 10, NULL)) AS int) AS 
NUMERIC_PRECISION_RADIX,
   cast(sys.ifthenelse(c."type" IN 
('int','smallint','tinyint','bigint','hugeint','float','real','double','decimal','numeric','oid'),
 c."type_scale", NULL) AS int) AS NUMERIC_SCALE,
   cast(sys.ifthenelse(c."type" IN 
('date','timestamp','timestamptz','time','timetz'), c."type_scale" -1, NULL) AS 
int) AS DATETIME_PRECISION,
-  cast(CASE c."type" WHEN 'day_interval' THEN 'interval day' WHEN 
'month_interval' THEN 'interval month' WHEN 'sec_interval' THEN 'interval 
second' ELSE NULL END AS varchar(40)) AS INTERVAL_TYPE,
-  cast(sys.ifthenelse(c."type" IN 
('day_interval','month_interval','sec_interval'), c."type_scale" -1, NULL) AS 
int) AS INTERVAL_PRECISION,
+  cast(CASE c."type" WHEN 'day_interval' THEN 'interval day' WHEN 
'month_interval' THEN (CASE c."type_digits" WHEN 1 THEN 'interval year' WHEN 2 
THEN 'interval year to month' WHEN 3 THEN 'interval month' ELSE NULL END) WHEN 
'sec_interval' THEN (CASE c."type_digits" WHEN 5 THEN 'interval day to hour' 
WHEN 6 THEN 'interval day to minute' WHEN 7 THEN 'interval day to second' WHEN 
8 THEN 'interval hour' WHEN 9 THEN 'interval hour to minute' WHEN 10 THEN 
'interval hour to second' WHEN 11 THEN 'interval minute' WHEN 12 THEN 'interval 
minute to second' WHEN 13 THEN 'interval second' ELSE NULL END) ELSE NULL END 
AS varchar(40)) AS INTERVAL_TYPE,
+  cast(CASE c."type" WHEN 'day_interval' THEN 0 WHEN 'month_interval' THEN 0 
WHEN 'sec_interval' THEN (sys.ifthenelse(c."type_digits" IN (7, 10, 12, 13), 

MonetDB: default - Merge with Jun2023 branch.

2023-10-25 Thread Sjoerd Mullender via checkin-list
Changeset: 23904801fe79 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/23904801fe79
Modified Files:
sql/backends/monet5/sql.h
sql/backends/monet5/sql_upgrades.c

sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128

sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (truncated from 764 to 300 lines):

diff --git a/monetdb5/modules/atoms/Tests/All b/monetdb5/modules/atoms/Tests/All
--- a/monetdb5/modules/atoms/Tests/All
+++ b/monetdb5/modules/atoms/Tests/All
@@ -38,3 +38,5 @@ startswith
 endswith
 contains
 HAVE_ICONV?asciify
+
+ts_and_tstz_to_str_bug
diff --git a/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test 
b/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test
@@ -0,0 +1,16 @@
+statement ok
+CREATE TABLE t2 (dt TIMESTAMP)
+
+statement ok
+INSERT INTO t2 (dt) VALUES('2023-10-11 11:36')
+
+query I
+SELECT
+levenshtein(sys.timestamp_to_str(cast(dt as timestamp with time zone), 
'%Y-%d-%d %H:%M:%S'),
+sys.timestamp_to_str(dt, '%Y-%d-%d %H:%M:%S'))
+FROM t2
+
+0
+
+statement ok
+DROP TABLE t2
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
@@ -282,7 +282,6 @@ extern str SQLflush_log(Client cntxt, Ma
 extern str SQLsuspend_log_flushing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str SQLresume_log_flushing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str SQLhot_snapshot(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-extern str SQLhot_snapshot_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str SQLpersist_unlogged(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 
 extern str SQLsession_prepared_statements(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -5179,6 +5179,7 @@ sql_update_jun2023(Client c, mvc *sql, s
char *err = NULL, *buf = GDKmalloc(bufsize);
res_table *output;
BAT *b;
+   sql_subtype t1, t2;
 
(void) sql;
if (buf == NULL)
@@ -5546,7 +5547,6 @@ sql_update_jun2023(Client c, mvc *sql, s
/* Add new sysadmin procedure calls: stop, pause and resume with two
   arguments, first arg is query OID and second the user username that
   the query in bound to. */
-   sql_subtype t1, t2;
sql_find_subtype(, "bigint", 64, 0);
sql_find_subtype(, "varchar", 0, 0);
if (!sql_bind_func(sql, "sys", "pause", , , F_PROC, true)) {
@@ -5781,6 +5781,38 @@ sql_update_jun2023(Client c, mvc *sql, s
 }
 
 static str
+sql_update_jun2023_sp3(Client c, mvc *sql, sql_schema *s)
+{
+   (void)s;
+   char *err = NULL;
+   sql_subtype t1, t2;
+
+   sql_find_subtype(, "timestamp", 0, 0);
+   sql_find_subtype(, "varchar", 0, 0);
+
+   if 

MonetDB: Jun2023 - Fix upgrade output.

2023-10-25 Thread Sjoerd Mullender via checkin-list
Changeset: 5d16b384dec7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5d16b384dec7
Modified Files:

sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128

sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: Jun2023
Log Message:

Fix upgrade output.


diffs (truncated from 611 to 300 lines):

diff --git 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -367,7 +367,7 @@ update sys.functions set system = true w
 delete from sys.triggers where name = 'system_update_tables' and table_id = 
2067;
 
 Running database upgrade commands:
-CREATE FUNCTION "timestamp_to_str"(d TIMESTAMP, format STRING) RETURNS STRING 
EXTERNAL NAME mtime."timestamp_to_str";
-GRANT EXECUTE ON FUNCTION "timestamp_to_str"(TIMESTAMP, STRING) TO PUBLIC;
+CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING 
EXTERNAL NAME mtime."timestamp_to_str";
+GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC;
 UPDATE sys.functions SET system = true WHERE system <> true AND name = 
'timestamp_to_str' AND schema_id = 2000 and type = 1;
 
diff --git a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
@@ -367,7 +367,7 @@ update sys.functions set system = true w
 delete from sys.triggers where name = 'system_update_tables' and table_id = 
2067;
 
 Running database upgrade commands:
-CREATE FUNCTION "timestamp_to_str"(d TIMESTAMP, format STRING) RETURNS STRING 
EXTERNAL NAME mtime."timestamp_to_str";
-GRANT EXECUTE ON FUNCTION "timestamp_to_str"(TIMESTAMP, STRING) TO PUBLIC;
+CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING 
EXTERNAL NAME mtime."timestamp_to_str";
+GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC;
 UPDATE sys.functions SET system = true WHERE system <> true AND name = 
'timestamp_to_str' AND schema_id = 2000 and type = 1;
 
diff --git 
a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -436,7 +436,7 @@ update sys.functions set system = true w
 delete from sys.triggers where name = 'system_update_tables' and table_id = 
2067;
 
 Running database upgrade commands:
-CREATE FUNCTION "timestamp_to_str"(d TIMESTAMP, format STRING) RETURNS STRING 
EXTERNAL NAME mtime."timestamp_to_str";
-GRANT EXECUTE ON FUNCTION "timestamp_to_str"(TIMESTAMP, STRING) TO PUBLIC;
+CREATE FUNCTION timestamp_to_str(d TIMESTAMP, format STRING) RETURNS STRING 
EXTERNAL NAME mtime."timestamp_to_str";
+GRANT EXECUTE ON FUNCTION timestamp_to_str(TIMESTAMP, STRING) TO PUBLIC;
 UPDATE sys.functions SET system = true WHERE system <> true AND name = 
'timestamp_to_str' AND schema_id = 2000 and type = 1;
 
diff --git 

MonetDB: Jun2023 - Remove declaration of non-existent function.

2023-10-25 Thread Sjoerd Mullender via checkin-list
Changeset: f4e4c30f4480 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f4e4c30f4480
Modified Files:
sql/backends/monet5/sql.h
Branch: Jun2023
Log Message:

Remove declaration of non-existent function.


diffs (11 lines):

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
@@ -282,7 +282,6 @@ extern str SQLflush_log(Client cntxt, Ma
 extern str SQLsuspend_log_flushing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str SQLresume_log_flushing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str SQLhot_snapshot(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-extern str SQLhot_snapshot_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 
 extern str SQLsession_prepared_statements(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
 extern str SQLsession_prepared_statements_args(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: monetdburl - Avoid Unicode characters in normal strings...

2023-10-27 Thread Sjoerd Mullender via checkin-list
Changeset: 6fc9e8f0ba1f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6fc9e8f0ba1f
Modified Files:
clients/mapilib/mapi.c
Branch: monetdburl
Log Message:

Avoid Unicode characters in normal strings, use UTF-8 encoding explicitly.
MSVC doesn't like \u23ce (doesn't know how to convert to whatever code
page it's using).


diffs (26 lines):

diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1214,7 +1214,7 @@ mapi_log_header(Mapi mid, const char *fi
if (firstcall == 0)
firstcall = now;
double seconds = (double)(now - firstcall) / 1e6;
-   mnstr_printf(mid->tracelog, "â–¶ [%u] t=%.3fs %s %s(), line %ld\n", 
mid->index, seconds, mark, filename, line);
+   mnstr_printf(mid->tracelog, "\342\226\266 [%u] t=%.3fs %s %s(), line 
%ld\n", mid->index, seconds, mark, filename, line); /* U+25B6: right-pointing 
triangle */
 }
 
 void
@@ -1271,7 +1271,7 @@ mapi_impl_log_data(Mapi mid, const char 
mapi_log_header(mid, filename, line, mark);
mnstr_write(mid->tracelog, start, 1, len);
if (len > 0 && start[len - 1] != '\n')
-   mnstr_writeStr(mid->tracelog, "\u23ce\n");
+   mnstr_writeStr(mid->tracelog, "\342\217\216\n"); /* U+23CE: 
return symbol */
mnstr_flush(mid->tracelog, MNSTR_FLUSH_DATA);
 }
 
@@ -4677,4 +4677,3 @@ bailout:
// malloc failure is the only way these calls could have failed
return mapi_printError(mid, __func__, MERROR, "%s: %s", error_message, 
mnstr_peek_error(error_stream));
 }
-
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: monetdburl - Install openssl libraries on Windows.

2023-10-27 Thread Sjoerd Mullender via checkin-list
Changeset: ecff245bc383 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ecff245bc383
Modified Files:
NT/mkodbcwxs.py
NT/mksqlwxs.py
Branch: monetdburl
Log Message:

Install openssl libraries on Windows.


diffs (50 lines):

diff --git a/NT/mkodbcwxs.py b/NT/mkodbcwxs.py
--- a/NT/mkodbcwxs.py
+++ b/NT/mkodbcwxs.py
@@ -36,10 +36,12 @@ def main():
 if sys.argv[2] == '64':
 folder = r'ProgramFiles64Folder'
 arch = 'x64'
+libcrypto = '-x64'
 vcpkg = r'C:\vcpkg\installed\x64-windows\{}'
 else:
 folder = r'ProgramFilesFolder'
 arch = 'x86'
+libcrypto = ''
 vcpkg = r'C:\vcpkg\installed\x86-windows\{}'
 vcdir = os.getenv('VCINSTALLDIR')
 if vcdir is None:
@@ -91,6 +93,8 @@ def main():
vcpkg.format(r'bin\iconv-2.dll'),
vcpkg.format(r'bin\bz2.dll'),
vcpkg.format(r'bin\charset-1.dll'), # for iconv-2.dll
+   vcpkg.format(r'bin\libcrypto-3{}.dll'.format(libcrypto)),
+   vcpkg.format(r'bin\libssl-3{}.dll'.format(libcrypto)),
vcpkg.format(r'bin\lz4.dll'),
vcpkg.format(r'bin\liblzma.dll'),
vcpkg.format(r'bin\zlib1.dll')])
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -43,10 +43,12 @@ def main():
 if sys.argv[2] == '64':
 folder = r'ProgramFiles64Folder'
 arch = 'x64'
+libcrypto = '-x64'
 vcpkg = r'C:\vcpkg\installed\x64-windows\{}'
 else:
 folder = r'ProgramFilesFolder'
 arch = 'x86'
+libcrypto = ''
 vcpkg = r'C:\vcpkg\installed\x86-windows\{}'
 vcdir = os.getenv('VCINSTALLDIR')
 if vcdir is None:
@@ -158,6 +160,8 @@ def main():
vcpkg.format(r'bin\bz2.dll'),
vcpkg.format(r'bin\charset-1.dll'), # for iconv-2.dll
vcpkg.format(r'bin\getopt.dll'),
+   vcpkg.format(r'bin\libcrypto-3{}.dll'.format(libcrypto)),
+   vcpkg.format(r'bin\libssl-3{}.dll'.format(libcrypto)),
vcpkg.format(r'bin\libxml2.dll'),
vcpkg.format(r'bin\lz4.dll'),
vcpkg.format(r'bin\liblzma.dll'),
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Give catalog_cnt and catalog_lid bats a name ...

2023-10-27 Thread Sjoerd Mullender via checkin-list
Changeset: da26af578332 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/da26af578332
Modified Files:
gdk/gdk_logger.c
Branch: default
Log Message:

Give catalog_cnt and catalog_lid bats a name for debugging purposes.


diffs (52 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1642,11 +1642,23 @@ cleanup_and_swap(logger *lg, int *r, con
lg->catalog_id = noids;
lg->dcatalog = ndels;
 
+   /* failing to rename these two bats is not fatal */
+   if (BBPrename(lg->catalog_cnt, NULL) != GDK_SUCCEED)
+   GDKclrerr();
+   if (BBPrename(lg->catalog_lid, NULL) != GDK_SUCCEED)
+   GDKclrerr();
BBPunfix(lg->catalog_cnt->batCacheid);
BBPunfix(lg->catalog_lid->batCacheid);
 
lg->catalog_cnt = ncnts;
lg->catalog_lid = nlids;
+   char bak[FILENAME_MAX];
+   strconcat_len(bak, sizeof(bak), lg->fn, "_catalog_cnt", NULL);
+   if (BBPrename(lg->catalog_cnt, bak) < 0)
+   GDKclrerr();
+   strconcat_len(bak, sizeof(bak), lg->fn, "_catalog_lid", NULL);
+   if (BBPrename(lg->catalog_lid, bak) < 0)
+   GDKclrerr();
lg->cnt = BATcount(lg->catalog_bid);
lg->deleted -= cleanup;
return rcnt;
@@ -2061,16 +2073,24 @@ log_load(const char *fn, const char *log
BBPretain(lg->catalog_id->batCacheid);
BBPretain(lg->dcatalog->batCacheid);
}
+   /* failing to rename the catalog_cnt and catalog_lid bats is not
+* fatal */
lg->catalog_cnt = logbat_new(TYPE_lng, 1, SYSTRANS);
if (lg->catalog_cnt == NULL) {
GDKerror("failed to create catalog_cnt bat");
goto error;
}
+   strconcat_len(bak, sizeof(bak), fn, "_catalog_cnt", NULL);
+   if (BBPrename(lg->catalog_cnt, bak) < 0)
+   GDKclrerr();
lg->catalog_lid = logbat_new(TYPE_lng, 1, SYSTRANS);
if (lg->catalog_lid == NULL) {
GDKerror("failed to create catalog_lid bat");
goto error;
}
+   strconcat_len(bak, sizeof(bak), fn, "_catalog_lid", NULL);
+   if (BBPrename(lg->catalog_lid, bak) < 0)
+   GDKclrerr();
if (bm_get_counts(lg) != GDK_SUCCEED)
goto error;
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - With LOCK_OWNER defined (debug only), remove ...

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

With LOCK_OWNER defined (debug only), remove lock from list even when not 
inited.


diffs (31 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -380,9 +380,11 @@ MT_thread_add_mylock(MT_Lock *lock)
 void
 MT_thread_del_mylock(MT_Lock *lock)
 {
+   struct winthread *w;
if (threadslot == TLS_OUT_OF_INDEXES)
-   return;
-   struct winthread *w = TlsGetValue(threadslot);
+   w = 
+   else
+   w = TlsGetValue(threadslot);
 
if (w) {
if (w->mylocks == lock) {
@@ -864,9 +866,11 @@ MT_thread_add_mylock(MT_Lock *lock)
 void
 MT_thread_del_mylock(MT_Lock *lock)
 {
+   struct posthread *p;
if (!thread_initialized)
-   return;
-   struct posthread *p = pthread_getspecific(threadkey);
+   p = 
+   else
+   p = pthread_getspecific(threadkey);
 
if (p) {
if (p->mylocks == lock) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch.

2023-10-27 Thread Sjoerd Mullender via checkin-list
Changeset: ed279f37a2f6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ed279f37a2f6
Modified Files:
gdk/gdk_system.c
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (19 lines):

diff --git a/common/stream/Tests/read_tests.py 
b/common/stream/Tests/read_tests.py
--- a/common/stream/Tests/read_tests.py
+++ b/common/stream/Tests/read_tests.py
@@ -148,4 +148,3 @@ if __name__ == "__main__":
 else:
 print("Usage: python3 read_tests.py [TESTDATANAME]", file=sys.stderr)
 sys.exit(1)
-
diff --git a/common/stream/Tests/testdata.py b/common/stream/Tests/testdata.py
--- a/common/stream/Tests/testdata.py
+++ b/common/stream/Tests/testdata.py
@@ -216,6 +216,7 @@ class TestFile:
 else:
 raise Exception("Unknown compression scheme: " + self.compression)
 f.write(content)
+f.close()
 return filename
 
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Use thread-local storage instead of arrays in...

2023-11-01 Thread Sjoerd Mullender via checkin-list
Changeset: 54dd0625ee0b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/54dd0625ee0b
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk_system.c
gdk/gdk_system.h
sql/backends/monet5/UDF/capi/capi.c
Branch: default
Log Message:

Use thread-local storage instead of arrays indexed by thread id for CAPI.


diffs (276 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -357,6 +357,7 @@ size_t HEAPvmsize(Heap *h);
 void IMPSdestroy(BAT *b);
 lng IMPSimprintsize(BAT *b);
 int MT_access(const char *pathname, int mode);
+gdk_return MT_alloc_tls(MT_TLS_t *newkey);
 int MT_check_nr_cores(void);
 void MT_cond_broadcast(MT_Cond *cond);
 void MT_cond_destroy(MT_Cond *cond);
@@ -393,6 +394,8 @@ void MT_thread_setdata(void *data);
 void MT_thread_setlockwait(MT_Lock *lock);
 void MT_thread_setsemawait(MT_Sema *sema);
 void MT_thread_setworking(const char *work);
+void *MT_tls_get(MT_TLS_t key);
+void MT_tls_set(MT_TLS_t key, void *val);
 void OIDXdestroy(BAT *b);
 ssize_t OIDfromStr(const char *src, size_t *len, oid **dst, bool external);
 ssize_t OIDtoStr(str *dst, size_t *len, const oid *src, bool external);
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -225,11 +225,11 @@ static pthread_key_t threadkey;
 #define thread_setself(self)   pthread_setspecific(threadkey, self)
 #else
 static CRITICAL_SECTION winthread_cs;
-static DWORD threadslot = TLS_OUT_OF_INDEXES;
+static DWORD threadkey = TLS_OUT_OF_INDEXES;
 #define thread_lock()  EnterCriticalSection(_cs)
 #define thread_unlock()LeaveCriticalSection(_cs)
-#define thread_self()  TlsGetValue(threadslot)
-#define thread_setself(self)   TlsSetValue(threadslot, self)
+#define thread_self()  TlsGetValue(threadkey)
+#define thread_setself(self)   TlsSetValue(threadkey, self)
 #endif
 static bool thread_initialized = false;
 
@@ -361,16 +361,16 @@ MT_thread_init(void)
return false;
}
 #else
-   threadslot = TlsAlloc();
-   if (threadslot == TLS_OUT_OF_INDEXES) {
+   threadkey = TlsAlloc();
+   if (threadkey == TLS_OUT_OF_INDEXES) {
GDKwinerror("Creating thread-local slot for thread failed");
return false;
}
mainthread.wtid = GetCurrentThreadId();
if (thread_setself() == 0) {
GDKwinerror("Setting thread-local value failed");
-   TlsFree(threadslot);
-   threadslot = TLS_OUT_OF_INDEXES;
+   TlsFree(threadkey);
+   threadkey = TLS_OUT_OF_INDEXES;
return false;
}
InitializeCriticalSection(_cs);
@@ -457,6 +457,46 @@ find_mtthread(MT_Id tid)
return t;
 }
 
+gdk_return
+MT_alloc_tls(MT_TLS_t *newkey)
+{
+#ifdef HAVE_PTHREAD_H
+   int ret;
+   if ((ret = pthread_key_create(newkey, NULL)) != 0) {
+   GDKsyserr(ret, "Creating TLS key for thread failed");
+   return GDK_FAIL;
+   }
+#else
+   if ((*newkey = TlsAlloc()) == TLS_OUT_OF_INDEXES) {
+   GDKwinerror("Creating TLS key for thread failed");
+   return GDK_FAIL;
+   }
+#endif
+   return GDK_SUCCEED;
+}
+
+void
+MT_tls_set(MT_TLS_t key, void *val)
+{
+#ifdef HAVE_PTHREAD_H
+   pthread_setspecific(key, val);
+#else
+   assert(key != TLS_OUT_OF_INDEXES);
+   TlsSetValue(key, val);
+#endif
+}
+
+void *
+MT_tls_get(MT_TLS_t key)
+{
+#ifdef HAVE_PTHREAD_H
+   return pthread_getspecific(key);
+#else
+   assert(key != TLS_OUT_OF_INDEXES);
+   return TlsGetValue(key);
+#endif
+}
+
 const char *
 MT_thread_getname(void)
 {
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -436,6 +436,8 @@ typedef struct MT_RWLock {
 
 #define MT_rwlock_wrunlock(l)  ReleaseSRWLockExclusive(&(l)->lock)
 
+typedef DWORD MT_TLS_t;
+
 #else
 
 typedef struct MT_Lock {
@@ -606,8 +608,14 @@ MT_rwlock_wrtry(MT_RWLock *l)
 
 #endif
 
+typedef pthread_key_t MT_TLS_t;
+
 #endif
 
+gdk_export gdk_return MT_alloc_tls(MT_TLS_t *newkey);
+gdk_export void MT_tls_set(MT_TLS_t key, void *val);
+gdk_export void *MT_tls_get(MT_TLS_t key);
+
 #ifdef LOCK_STATS
 gdk_export void GDKlockstatistics(int);
 gdk_export MT_Lock * volatile GDKlocklist;
diff --git a/sql/backends/monet5/UDF/capi/capi.c 
b/sql/backends/monet5/UDF/capi/capi.c
--- a/sql/backends/monet5/UDF/capi/capi.c
+++ b/sql/backends/monet5/UDF/capi/capi.c
@@ -39,7 +39,6 @@ static bool option_enable_mprotect = fal
 const char *longjmp_enableflag = "enable_longjmp";
 static bool option_enable_longjmp = false;
 
-struct _allocated_region;
 typedef struct _allocated_region {
struct _allocated_region *next;
 } allocated_region;
@@ -54,8 +53,11 @@ typedef struct _mprotected_region {
 
 static char *mprotect_region(void *addr, 

MonetDB: Jun2023 - Removed impossible pattern.

2023-11-01 Thread Sjoerd Mullender via checkin-list
Changeset: d00824ca3022 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d00824ca3022
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
sql/backends/monet5/sql.c
Branch: Jun2023
Log Message:

Removed impossible pattern.


diffs (41 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -30270,11 +30270,6 @@ nil_2time_timestamp;
 cast to timestamp and check for overflow
 batcalc
 timestamp
-pattern batcalc.timestamp(X_0:bat[:oid], X_1:int, 
X_2:bat[:BAT]):bat[:timestamp] 
-nil_2time_timestamp;
-cast to timestamp and check for overflow
-batcalc
-timestamp
 pattern batcalc.timestamp(X_0:bat[:timestamp], X_1:bat[:oid], 
X_2:int):bat[:timestamp] 
 timestamp_2time_timestamp;
 cast timestamp to timestamp and check for overflow
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -21495,11 +21495,6 @@ nil_2time_timestamp;
 cast to timestamp and check for overflow
 batcalc
 timestamp
-pattern batcalc.timestamp(X_0:bat[:oid], X_1:int, 
X_2:bat[:BAT]):bat[:timestamp] 
-nil_2time_timestamp;
-cast to timestamp and check for overflow
-batcalc
-timestamp
 pattern batcalc.timestamp(X_0:bat[:timestamp], X_1:bat[:oid], 
X_2:int):bat[:timestamp] 
 timestamp_2time_timestamp;
 cast timestamp to timestamp and check for overflow
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
@@ -5293,7 +5293,6 @@ pattern("sql", "decypher", SQLdecypher, 
  pattern("batcalc", "lng", batstr_2dec_lng, false, "cast to dec(lng) and check 
for overflow", args(1,5, 
batarg("",lng),batarg("v",str),batarg("s",oid),arg("digits",int),arg("scale",int))),
  pattern("calc", "timestamp", nil_2time_timestamp, false, "cast to timestamp 
and check for overflow", args(1,3, 
arg("",timestamp),arg("v",void),arg("digits",int))),
  pattern("batcalc", "timestamp", nil_2time_timestamp, false, "cast to 
timestamp and check for overflow", args(1,3, 
batarg("",timestamp),batarg("v",oid),arg("digits",int))),
- pattern("batcalc", "timestamp", nil_2time_timestamp, false, "cast to 
timestamp and check for overflow", args(1,4, 
batarg("",timestamp),batarg("v",oid),arg("digits",int),batarg("r",bat))),
  pattern("calc", "timestamp", str_2time_timestamp, false, "cast to timestamp 
and check for overflow", args(1,3, 
arg("",timestamp),arg("v",str),arg("digits",int))),
  pattern("calc", "timestamp", str_2time_timestamptz, false, "cast to timestamp 
and check for overflow", args(1,4, 
arg("",timestamp),arg("v",str),arg("digits",int),arg("has_tz",int))),
  pattern("calc", "timestamp", timestamp_2time_timestamp, false, "cast 
timestamp to timestamp and check for overflow", args(1,3, 
arg("",timestamp),arg("v",timestamp),arg("digits",int))),
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Removed the last compiled-in limit to the num...

2023-11-02 Thread Sjoerd Mullender via checkin-list
Changeset: 1df45f7a222b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1df45f7a222b
Modified Files:
gdk/ChangeLog
gdk/gdk.h
gdk/gdk_system.c
Branch: default
Log Message:

Removed the last compiled-in limit to the number of threads.


diffs (201 lines):

diff --git a/gdk/ChangeLog b/gdk/ChangeLog
--- a/gdk/ChangeLog
+++ b/gdk/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Thu Nov  2 2023 Sjoerd Mullender 
+- Removed the compiled-in limit on the number of threads that can be used.
+  The number of threads are still limited, but the limit is dictated
+  solely by the operating system and the availability of enough memory.
+
 * Thu Sep 28 2023 Sjoerd Mullender 
 - We now prevent accidental upgrades from a database without 128 bit
   integers to one with 128 bit integers (also known as HUGEINT) from
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1971,18 +1971,7 @@ VALptr(const ValRecord *v)
}
 }
 
-/*
- * The kernel maintains a central table of all active threads.  They
- * are indexed by their tid. The structure contains information on the
- * input/output file descriptors, which should be set before a
- * database operation is started. It ensures that output is delivered
- * to the proper client.
- *
- * The Thread structure should be ideally made directly accessible to
- * each thread. This speeds up access to tid and file descriptors.
- */
-#define THREADS1024
-#define THREADDATA 3
+#define THREADS1024/* maximum value for gdk_nr_threads */
 
 typedef struct threadStruct *Thread;
 
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -262,36 +262,6 @@ THRhighwater(void)
return false;
 }
 
-static uint32_t allocated[THREADS / 32];
-static MT_Lock alloclock = MT_LOCK_INITIALIZER(alloclock);
-
-static MT_Id
-alloc_thread(void)
-{
-   MT_Id mtid = 0;
-   MT_lock_set();
-   for (int i = 0; i < THREADS / 32; i++) {
-   if (allocated[i] != ~UINT32_C(0)) {
-   int x = candmask_lobit(~allocated[i]);
-   allocated[i] |= UINT32_C(1) << x;
-   mtid = (MT_Id) (i * 32 + x + 1);
-   break;
-   }
-   }
-   MT_lock_unset();
-   return mtid;
-}
-
-static void
-dealloc_thread(MT_Id mtid)
-{
-   assert(mtid > 0 && mtid <= THREADS);
-   mtid--;
-   MT_lock_set();
-   allocated[mtid / 32] &= ~(UINT32_C(1) << (mtid % 32));
-   MT_lock_unset();
-}
-
 void
 dump_threads(void)
 {
@@ -329,7 +299,6 @@ static void
 rm_mtthread(struct mtthread *t)
 {
struct mtthread **pt;
-   MT_Id mtid = t->tid;
 
assert(t != );
thread_lock();
@@ -340,7 +309,6 @@ rm_mtthread(struct mtthread *t)
ATOMIC_DESTROY(>exited);
free(t);
thread_unlock();
-   dealloc_thread(mtid);
 }
 
 bool
@@ -375,8 +343,7 @@ MT_thread_init(void)
}
InitializeCriticalSection(_cs);
 #endif
-   allocated[0] = 1;
-   mainthread.tid = 1;
+   mainthread.tid = (MT_Id) 
mainthread.next = NULL;
mtthreads = 
thread_initialized = true;
@@ -406,11 +373,7 @@ MT_thread_register(void)
if (self == NULL)
return false;
 
-   if ((mtid = alloc_thread()) == 0) {
-   TRC_DEBUG(IO_, "Too many threads\n");
-   GDKerror("too many threads\n");
-   return false;
-   }
+   mtid = (MT_Id) self;
*self = (struct mtthread) {
.detached = false,
 #ifdef HAVE_PTHREAD_H
@@ -824,24 +787,17 @@ MT_create_thread(MT_Id *t, void (*f) (vo
TRC_CRITICAL(GDK, "Thread's name is too large\n");
return -1;
}
-   if ((mtid = alloc_thread()) == 0) {
-   TRC_DEBUG(IO_, "Too many threads\n");
-   GDKerror("too many threads\n");
-   return -1;
-   }
 
 #ifdef HAVE_PTHREAD_H
pthread_attr_t attr;
int ret;
if ((ret = pthread_attr_init()) != 0) {
GDKsyserr(ret, "Cannot init pthread attr");
-   dealloc_thread(mtid);
return -1;
}
if ((ret = pthread_attr_setstacksize(, THREAD_STACK_SIZE)) != 0) {
GDKsyserr(ret, "Cannot set stack size");
pthread_attr_destroy();
-   dealloc_thread(mtid);
return -1;
}
 #endif
@@ -851,9 +807,9 @@ MT_create_thread(MT_Id *t, void (*f) (vo
 #ifdef HAVE_PTHREAD_H
pthread_attr_destroy();
 #endif
-   dealloc_thread(mtid);
return -1;
}
+   mtid = (MT_Id) self;
 
*self = (struct mtthread) {
.func = f,
@@ -867,9 +823,10 @@ MT_create_thread(MT_Id *t, void (*f) (vo
strcpy_len(self->threadname, threadname, sizeof(self->threadname));
char *p;
if 

MonetDB: default - Removed workingset array.

2023-11-02 Thread Sjoerd Mullender via checkin-list
Changeset: 59042ddcfe06 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/59042ddcfe06
Modified Files:
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_runtime.c
monetdb5/mal/mal_runtime.h
Branch: default
Log Message:

Removed workingset array.
This is the penultimate step in removing compile-time restrictions on
the number of threads.


diffs (136 lines):

diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -721,8 +721,6 @@ profilerEvent(MalEvent *me, NonMalEvent 
 str
 openProfilerStream(Client cntxt, int m)
 {
-   int j;
-
 #ifdef HAVE_SYS_RESOURCE_H
getrusage(RUSAGE_SELF, );
prevUsage = infoUsage;
@@ -759,29 +757,6 @@ openProfilerStream(Client cntxt, int m)
maleventstream = cntxt->fdout;
profilerUser = cntxt->user;
 
-   // Ignore the JSON rendering mode, use compiled time version
-
-   /* show all in progress instructions for stethoscope startup */
-   /* wait a short time for instructions to finish updating their thread 
admin
-* and then follow the locking scheme */
-
-   MT_sleep_ms(200);
-
-   for (j = 0; j < THREADS; j++) {
-   struct MalEvent me = {
-   .cntxt = workingset[j].cntxt,
-   .mb = workingset[j].mb,
-   .stk = workingset[j].stk,
-   .pci = workingset[j].pci,
-   .clk = workingset[j].clock,
-   };
-   if (me.cntxt && me.mb && me.stk && me.pci) {
-   /* show the event  assuming the quintuple is aligned */
-   MT_lock_unset(_profileLock);
-   profilerEvent(, NULL);
-   MT_lock_set(_profileLock);
-   }
-   }
MT_lock_unset(_profileLock);
return MAL_SUCCEED;
 }
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -346,43 +346,19 @@ mal_runtime_reset(void)
dropUSRstats();
 }
 
-/*
- * Each MAL instruction is executed by a single thread, which means we can
- * keep a simple working set around to make Stethscope attachement easy.
- * The entries are privately accessed and only can be influenced by a starting 
stehoscope to emit work in progress.
- */
-Workingset workingset[THREADS];
-
 /* At the start of each MAL stmt */
 void
 runtimeProfileBegin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci,
RuntimeProfile prof)
 {
-   MT_Id tid = MT_getpid();
-   lng clk = GDKusec();
+   (void) cntxt;
+   (void) mb;
+   (void) stk;
+   (void) pci;
 
assert(pci);
-   /* keep track on the instructions taken in progress for stethoscope */
-   if (tid > 0 && tid <= THREADS) {
-   tid--;
-   if (profilerStatus) {
-   MT_lock_set(_profileLock);
-   workingset[tid].cntxt = cntxt;
-   workingset[tid].mb = mb;
-   workingset[tid].stk = stk;
-   workingset[tid].pci = pci;
-   workingset[tid].clock = clk;
-   MT_lock_unset(_profileLock);
-   } else {
-   workingset[tid].cntxt = cntxt;
-   workingset[tid].mb = mb;
-   workingset[tid].stk = stk;
-   workingset[tid].pci = pci;
-   workingset[tid].clock = clk;
-   }
-   }
/* always collect the MAL instruction execution time */
-   prof->ticks = clk;
+   prof->ticks = GDKusec();
 }
 
 /* At the end of each MAL stmt */
@@ -390,21 +366,8 @@ void
 runtimeProfileExit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci,
   RuntimeProfile prof)
 {
-   MT_Id tid = MT_getpid();
lng ticks = GDKusec();
 
-   /* keep track on the instructions in progress */
-   if (tid > 0 && tid <= THREADS) {
-   tid--;
-   if (profilerStatus) {
-   MT_lock_set(_profileLock);
-   workingset[tid] = (struct WORKINGSET) { 0 };
-   MT_lock_unset(_profileLock);
-   } else {
-   workingset[tid] = (struct WORKINGSET) { 0 };
-   }
-   }
-
if (profilerStatus > 0)
profilerEvent(&(struct MalEvent) { cntxt, mb, stk, pci, ticks,
  ticks - prof->ticks },
diff --git a/monetdb5/mal/mal_runtime.h b/monetdb5/mal/mal_runtime.h
--- a/monetdb5/mal/mal_runtime.h
+++ b/monetdb5/mal/mal_runtime.h
@@ -59,16 +59,6 @@ typedef struct USERSTAT {
 } *UserStats;
 extern size_t usrstatscnt;
 
-typedef struct WORKINGSET {
-   Client cntxt;
-   MalBlkPtr mb;
-   MalStkPtr 

MonetDB: default - Debugging help: tell OS the names of our thre...

2023-11-02 Thread Sjoerd Mullender via checkin-list
Changeset: 175f3fa63046 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/175f3fa63046
Modified Files:
cmake/monetdb-defines.cmake
gdk/gdk_system.c
monetdb_config.h.in
Branch: default
Log Message:

Debugging help: tell OS the names of our threads.  The debuggers then show them.


diffs (57 lines):

diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -121,6 +121,7 @@ function(monetdb_configure_defines)
   cmake_push_check_state()
 set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
 check_function_exists("pthread_kill" HAVE_PTHREAD_KILL)
+check_function_exists("pthread_setname_np" HAVE_PTHREAD_SETNAME_NP)
 check_function_exists("pthread_sigmask" HAVE_PTHREAD_SIGMASK)
   cmake_pop_check_state()
   check_symbol_exists("regcomp" "regex.h" HAVE_POSIX_REGEX)
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -48,6 +48,8 @@
 #include /* for strerror */
 #include /* for sysconf symbols */
 
+#include "mutils.h"
+
 #ifdef LOCK_STATS
 
 ATOMIC_TYPE GDKlockcnt = ATOMIC_VAR_INIT(0);
@@ -692,6 +694,22 @@ thread_starter(void *arg)
struct mtthread *self = (struct mtthread *) arg;
void *data = self->data;
 
+#ifdef HAVE_PTHREAD_H
+#ifdef HAVE_PTHREAD_SETNAME_NP
+   /* name can be at most 16 chars including \0 */
+   char *name = GDKstrndup(self->threadname, 15);
+   if (name != NULL) {
+   pthread_setname_np(pthread_self(), name);
+   GDKfree(name);
+   }
+#endif
+#else
+   wchar_t *wname = utf8towchar(self->threadname);
+   if (wname != NULL) {
+   SetThreadDescription(GetCurrentThread(), wname);
+   free(wname);
+   }
+#endif
self->data = NULL;
self->sp = THRsp();
thread_setself(self);
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -170,6 +170,7 @@
 #cmakedefine HAVE_UNAME 1
 // #cmakedefine HAVE_SEMTIMEDOP
 #cmakedefine HAVE_PTHREAD_KILL 1
+#cmakedefine HAVE_PTHREAD_SETNAME_NP 1
 #cmakedefine HAVE_PTHREAD_SIGMASK 1
 #cmakedefine HAVE_GETOPT 1
 // End Section: monetdb configure defines
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch.

2023-11-02 Thread Sjoerd Mullender via checkin-list
Changeset: a1c93533dc71 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a1c93533dc71
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
gdk/gdk_logger.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/kernel/bat5.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/remote.c
monetdb5/modules/mal/tablet.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_mitosis.c
sql/backends/monet5/sql.c
tools/mserver/mserver5.c
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (truncated from 498 to 300 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -30330,11 +30330,6 @@ nil_2time_timestamp;
 cast to timestamp and check for overflow
 batcalc
 timestamp
-pattern batcalc.timestamp(X_0:bat[:oid], X_1:int, 
X_2:bat[:BAT]):bat[:timestamp] 
-nil_2time_timestamp;
-cast to timestamp and check for overflow
-batcalc
-timestamp
 pattern batcalc.timestamp(X_0:bat[:timestamp], X_1:bat[:oid], 
X_2:int):bat[:timestamp] 
 timestamp_2time_timestamp;
 cast timestamp to timestamp and check for overflow
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -21555,11 +21555,6 @@ nil_2time_timestamp;
 cast to timestamp and check for overflow
 batcalc
 timestamp
-pattern batcalc.timestamp(X_0:bat[:oid], X_1:int, 
X_2:bat[:BAT]):bat[:timestamp] 
-nil_2time_timestamp;
-cast to timestamp and check for overflow
-batcalc
-timestamp
 pattern batcalc.timestamp(X_0:bat[:timestamp], X_1:bat[:oid], 
X_2:int):bat[:timestamp] 
 timestamp_2time_timestamp;
 cast timestamp to timestamp and check for overflow
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2773,8 +2773,7 @@ internal_log_bat(logger *lg, BAT *b, log
if (b->ttype == TYPE_msk) {
BATiter bi = bat_iterator(b);
if (offset % 32 == 0) {
-   if (!mnstr_writeIntArray
-   (lg->current->output_log, (int *) ((char *) bi.base 
+ offset / 32),
+   if (!mnstr_writeIntArray(lg->current->output_log, (int 
*) ((char *) bi.base + offset / 32),
 (size_t) ((nr + 31) / 32)))
ok = GDK_FAIL;
} else {
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -418,9 +418,8 @@ prepareMalEvent(Client cntxt, MalBlkPtr 
goto 
cleanup_and_exit;
}
} else {
-   if (!logadd
-   (, 
",\"mode\":\"%s\"",
-(di.transient 
? "transient" : "persistent"))) {
+   if (!logadd(, 
",\"mode\":\"%s\"",
+   
(di.transient ? "transient" : "persistent"))) {

BBPunfix(d->batCacheid);
goto 
cleanup_and_exit;
}
@@ -514,8 +513,7 @@ prepareMalEvent(Client cntxt, MalBlkPtr 
if (!ok)
goto cleanup_and_exit;
}
-   if (!logadd
-   (, ",\"eol\":%d", 
getVarEolife(mb, getArg(pci, j
+   if (!logadd(, ",\"eol\":%d", 
getVarEolife(mb, getArg(pci, j
goto cleanup_and_exit;
// if (!logadd(, ",\"fixed\":%d", 
isVarFixed(mb,getArg(pci,j return NULL;
if (!logadd(, "}"))
diff --git a/monetdb5/modules/atoms/mtime.h b/monetdb5/modules/atoms/mtime.h
--- a/monetdb5/modules/atoms/mtime.h
+++ b/monetdb5/modules/atoms/mtime.h
@@ -48,8 +48,7 @@ date_sub_msec_interval(date *ret, date d
*ret = date_nil;
return MAL_SUCCEED;
}
-   if (is_date_nil
-   ((*ret = date_add_day(d, (int) (-ms / (24 * 60 * 60 * 1000))
+   if (is_date_nil((*ret = date_add_day(d, (int) (-ms / (24 * 60 * 60 * 
1000))
throw(MAL, "mtime.date_sub_msec_interval",
  SQLSTATE(22003) "overflow in calculation");

MonetDB: default - Incompatibility between mac and linux.

2023-11-02 Thread Sjoerd Mullender via checkin-list
Changeset: 144c1d89474b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/144c1d89474b
Modified Files:
gdk/gdk_system.c
Branch: default
Log Message:

Incompatibility between mac and linux.


diffs (16 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -699,7 +699,11 @@ thread_starter(void *arg)
/* name can be at most 16 chars including \0 */
char *name = GDKstrndup(self->threadname, 15);
if (name != NULL) {
-   pthread_setname_np(pthread_self(), name);
+   pthread_setname_np(
+#ifdef __USE_GNU
+   pthread_self(),
+#endif
+   name);
GDKfree(name);
}
 #endif
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Changelog blurb.

2023-11-02 Thread Sjoerd Mullender via checkin-list
Changeset: 50ff4edecafc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/50ff4edecafc
Modified Files:
sql/ChangeLog.Jun2023
Branch: Jun2023
Log Message:

Changelog blurb.


diffs (14 lines):

diff --git a/sql/ChangeLog.Jun2023 b/sql/ChangeLog.Jun2023
--- a/sql/ChangeLog.Jun2023
+++ b/sql/ChangeLog.Jun2023
@@ -1,3 +1,10 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Thu Nov  2 2023 Sjoerd Mullender 
+- Added a missing interface function sys.timestamp_to_str with
+  a TIMESTAMP (as opposed to TIMESTAMP WITH TIME ZONE) argument.
+  The missing interface caused error messages being produced when the
+  function was called with a TIMESTAMP argument, although it did give
+  the correct result.
+
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch, not changing any f...

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: b5cad503588a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b5cad503588a
Modified Files:
.bumpversion.cfg
MonetDB.spec
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
cmake/monetdb-versions.cmake
gdk/libbat.rc
monetdb5/tools/libmonetdb5.rc
Branch: default
Log Message:

Merge with Jun2023 branch, not changing any files..

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Post release build.

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: bdfb3e98be81 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bdfb3e98be81
Modified Files:
.bumpversion.cfg
MonetDB.spec
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
cmake/monetdb-versions.cmake
gdk/libbat.rc
monetdb5/tools/libmonetdb5.rc
Branch: Jun2023
Log Message:

Post release build.


diffs (191 lines):

diff --git a/.bumpversion.cfg b/.bumpversion.cfg
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 11.47.13
+current_version = 11.47.14
 commit = False
 tag = False
 
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -7,7 +7,7 @@
 # Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V.
 
 %global name MonetDB
-%global version 11.47.13
+%global version 11.47.14
 %{!?buildno: %global buildno %(date +%Y%m%d)}
 
 # Use bcond_with to add a --with option; i.e., "without" is default.
diff --git a/clients/mapilib/mapi.rc b/clients/mapilib/mapi.rc
--- a/clients/mapilib/mapi.rc
+++ b/clients/mapilib/mapi.rc
@@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 #define sversion(major,minor,patch)#major "." #minor "." #patch "\0"
 
 1 VERSIONINFO
-  FILEVERSION version(11,47,13)
-  PRODUCTVERSION version(11,47,13)
+  FILEVERSION version(11,47,14)
+  PRODUCTVERSION version(11,47,14)
   FILEFLAGSMASK 0x3fL
   FILEFLAGS 0
   FILEOS VOS_NT_WINDOWS32
@@ -21,14 +21,14 @@ BEGIN
   VALUE "Comments", "\0"
   VALUE "CompanyName", "MonetDB B.V.\0"
   VALUE "FileDescription", "MonetDB Application Interface DLL\0"
-  VALUE "FileVersion", sversion(11,47,13)
+  VALUE "FileVersion", sversion(11,47,14)
   VALUE "InternalName", "Mapi\0"
   VALUE "LegalCopyright", "Copyright (c) MonetDB B.V. 2008-2023\0"
   VALUE "LegalTrademarks", "\0"
   VALUE "OriginalFilename", "Mapi.dll\0"
   VALUE "PrivateBuild", "\0"
   VALUE "ProductName", "MonetDB Client Libraries\0"
-  VALUE "ProductVersion", sversion(11,47,13)
+  VALUE "ProductVersion", sversion(11,47,14)
   VALUE "SpecialBuild", "\0"
 END
   END
diff --git a/clients/odbc/driver/driver.rc b/clients/odbc/driver/driver.rc
--- a/clients/odbc/driver/driver.rc
+++ b/clients/odbc/driver/driver.rc
@@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 #define sversion(major,minor,patch)#major "." #minor "." #patch "\0"
 
 1 VERSIONINFO
-  FILEVERSION version(11,47,13)
-  PRODUCTVERSION version(11,47,13)
+  FILEVERSION version(11,47,14)
+  PRODUCTVERSION version(11,47,14)
   FILEFLAGSMASK 0x3fL
   FILEFLAGS 0
   FILEOS VOS_NT_WINDOWS32
@@ -21,14 +21,14 @@ BEGIN
   VALUE "Comments", "\0"
   VALUE "CompanyName", "MonetDB B.V.\0"
   VALUE "FileDescription", "MonetDB ODBC Driver DLL\0"
-  VALUE "FileVersion", sversion(11,47,13)
+  VALUE "FileVersion", sversion(11,47,14)
   VALUE "InternalName", "MonetODBC\0"
   VALUE "LegalCopyright", "Copyright (c) MonetDB B.V. 2008-2023\0"
   VALUE "LegalTrademarks", "\0"
   VALUE "OriginalFilename", "MonetODBC.dll\0"
   VALUE "PrivateBuild", "\0"
   VALUE "ProductName", "MonetDB SQL Server\0"
-  VALUE "ProductVersion", sversion(11,47,13)
+  VALUE "ProductVersion", sversion(11,47,14)
   VALUE "SpecialBuild", "\0"
 END
   END
diff --git a/clients/odbc/winsetup/setup.rc b/clients/odbc/winsetup/setup.rc
--- a/clients/odbc/winsetup/setup.rc
+++ b/clients/odbc/winsetup/setup.rc
@@ -65,8 +65,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION version(11,47,13)
- PRODUCTVERSION version(11,47,13)
+ FILEVERSION version(11,47,14)
+ PRODUCTVERSION version(11,47,14)
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -83,12 +83,12 @@ BEGIN
 BEGIN
 VALUE "CompanyName", "MonetDB B.V."
 VALUE "FileDescription", "MonetDB ODBC Setup DLL"
-VALUE "FileVersion", sversion(11,47,13)
+VALUE "FileVersion", sversion(11,47,14)
 VALUE "InternalName", "MonetODBCs.dll"
 VALUE "LegalCopyright", "Copyright (c) MonetDB B.V. 2008-2023"
 VALUE "OriginalFilename", "MonetODBCs.dll"
 VALUE "ProductName", "MonetDB SQL Server"
-VALUE "ProductVersion", sversion(11,47,13)
+VALUE "ProductVersion", sversion(11,47,14)
 END
 END
 BLOCK "VarFileInfo"
diff --git a/cmake/monetdb-versions.cmake b/cmake/monetdb-versions.cmake
--- a/cmake/monetdb-versions.cmake
+++ b/cmake/monetdb-versions.cmake
@@ -10,10 +10,10 @@
 
 set(MONETDB_VERSION_MAJOR "11")
 set(MONETDB_VERSION_MINOR "47")
-set(MONETDB_VERSION_PATCH "13")
+set(MONETDB_VERSION_PATCH "14")
 
 if(RELEASE_VERSION)
-  set(MONETDB_RELEASE "Jun2023-SP3")
+  set(MONETDB_RELEASE "unreleased")
 endif()
 set(MONETDB_VERSION 
"${MONETDB_VERSION_MAJOR}.${MONETDB_VERSION_MINOR}.${MONETDB_VERSION_PATCH}")
 
diff --git a/gdk/libbat.rc b/gdk/libbat.rc
--- a/gdk/libbat.rc
+++ 

MonetDB: Jun2023 - Setting tag Jun2023_13 for the release build.

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: 4f0d7e054d28 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4f0d7e054d28
Modified Files:
.hgtags
Branch: Jun2023
Log Message:

Setting tag Jun2023_13 for the release build.


diffs (8 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -813,3 +813,4 @@ ce63ebe9a78c52ef0cbe8fd6f2159d2637f0387c
 1efa83c6409769d13b2ee30e497d5f7ab42fa955 Jun2023_9
 6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_11
 6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_SP2_release
+e6eb06773c17035954ac5d001cfe1f09ff3425cc Jun2023_13
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch.

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: 55c86dd2f722 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/55c86dd2f722
Modified Files:
.hgtags
MonetDB.spec
cmake/monetdb-versions.cmake
debian/changelog
misc/packages/deb/changelog
misc/packages/rpm/changelog
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (234 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -813,3 +813,4 @@ ce63ebe9a78c52ef0cbe8fd6f2159d2637f0387c
 1efa83c6409769d13b2ee30e497d5f7ab42fa955 Jun2023_9
 6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_11
 6f88424ebfd9d82c072cf21d89070e04321983da Jun2023_SP2_release
+e6eb06773c17035954ac5d001cfe1f09ff3425cc Jun2023_13
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -89,7 +89,7 @@ Group: Applications/Databases
 License: MPL-2.0
 URL: https://www.monetdb.org/
 BugURL: https://github.com/MonetDB/MonetDB/issues
-Source: 
https://www.monetdb.org/downloads/sources/Jun2023-SP2/%{name}-%{version}.tar.bz2
+Source: 
https://www.monetdb.org/downloads/sources/Jun2023-SP3/%{name}-%{version}.tar.bz2
 
 # The Fedora packaging document says we need systemd-rpm-macros for
 # the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7
@@ -867,6 +867,26 @@ fi
 %endif
 
 %changelog
+* Fri Nov 03 2023 Sjoerd Mullender  - 11.47.13-20231103
+- Rebuilt.
+- GH#7300: Implement missing standard SQL DATE and TIMESTAMP functions
+- GH#7324: string_distance('method',str1, str2) as a generic distance
+  function
+- GH#7409: Numpy table returning UDFs with variadic arguments
+
+* Thu Nov  2 2023 Sjoerd Mullender  - 11.47.13-20231103
+- sql: Added a missing interface function sys.timestamp_to_str with
+  a TIMESTAMP (as opposed to TIMESTAMP WITH TIME ZONE) argument.
+  The missing interface caused error messages being produced when the
+  function was called with a TIMESTAMP argument, although it did give
+  the correct result.
+
+* Tue Oct 31 2023 Sjoerd Mullender  - 11.47.13-20231103
+- gdk: A bug was fixed where the administration of which bats were in use was
+  interpreted incorrectly during startup, causing problems later.  One
+  symptom that has been observed was failure to startup with a message
+  that the catalog tables could not be loaded.
+
 * Fri Sep 29 2023 Sjoerd Mullender  - 11.47.11-20230929
 - Rebuilt.
 
diff --git a/cmake/monetdb-versions.cmake b/cmake/monetdb-versions.cmake
--- a/cmake/monetdb-versions.cmake
+++ b/cmake/monetdb-versions.cmake
@@ -42,7 +42,7 @@ set(MONETDB_VERSION "${MONETDB_VERSION_M
 # common/options and common/utils)
 set(GDK_VERSION_MAJOR "27")
 set(GDK_VERSION_MINOR "0")
-set(GDK_VERSION_PATCH "4")
+set(GDK_VERSION_PATCH "5")
 set(GDK_VERSION 
"${GDK_VERSION_MAJOR}.${GDK_VERSION_MINOR}.${GDK_VERSION_PATCH}")
 
 # version of the MAPI library (subdirectory clients/mapilib)
@@ -54,7 +54,7 @@ set(MAPI_VERSION "${MAPI_VERSION_MAJOR}.
 # version of the MONETDB5 library (subdirectory monetdb5, not including extras 
or sql)
 set(MONETDB5_VERSION_MAJOR "34")
 set(MONETDB5_VERSION_MINOR "0")
-set(MONETDB5_VERSION_PATCH "3")
+set(MONETDB5_VERSION_PATCH "4")
 set(MONETDB5_VERSION 
"${MONETDB5_VERSION_MAJOR}.${MONETDB5_VERSION_MINOR}.${MONETDB5_VERSION_PATCH}")
 
 # version of the MONETDBE library (subdirectory tools/monetdbe)
@@ -72,5 +72,5 @@ set(STREAM_VERSION "${STREAM_VERSION_MAJ
 # version of the SQL library (subdirectory sql)
 set(SQL_VERSION_MAJOR "14")
 set(SQL_VERSION_MINOR "0")
-set(SQL_VERSION_PATCH "4")
+set(SQL_VERSION_PATCH "5")
 set(SQL_VERSION 
"${SQL_VERSION_MAJOR}.${SQL_VERSION_MINOR}.${SQL_VERSION_PATCH}")
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,32 @@
+monetdb (11.47.13) unstable; urgency=low
+
+  * Rebuilt.
+  * GH#7300: Implement missing standard SQL DATE and TIMESTAMP functions
+  * GH#7324: string_distance('method',str1, str2) as a generic distance
+function
+  * GH#7409: Numpy table returning UDFs with variadic arguments
+
+ -- Sjoerd Mullender   Fri, 03 Nov 2023 10:48:08 +0100
+
+monetdb (11.47.13) unstable; urgency=low
+
+  * sql: Added a missing interface function sys.timestamp_to_str with
+a TIMESTAMP (as opposed to TIMESTAMP WITH TIME ZONE) argument.
+The missing interface caused error messages being produced when the
+function was called with a TIMESTAMP argument, although it did give
+the correct result.
+
+ -- Sjoerd Mullender   Thu, 2 Nov 2023 10:48:08 +0100
+
+monetdb (11.47.13) unstable; urgency=low
+
+  * gdk: A bug was fixed where the administration of which bats were in use was
+interpreted incorrectly during startup, causing problems later.  One
+symptom that has been observed was failure to startup with a message
+that the catalog tables could not be loaded.
+
+ -- Sjoerd Mullender   Tue, 31 Oct 2023 10:48:08 +0100
+
 monetdb (11.47.11) unstable; urgency=low
 
   * Rebuilt.
diff --git a/gdk/ChangeLog-Archive b/gdk/ChangeLog-Archive
--- a/gdk/ChangeLog-Archive
+++ 

MonetDB: default - Add check for SetThreadDescription function.

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: f353cd142601 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f353cd142601
Modified Files:
cmake/monetdb-defines.cmake
gdk/gdk_system.c
monetdb_config.h.in
Branch: default
Log Message:

Add check for SetThreadDescription function.


diffs (40 lines):

diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -124,6 +124,7 @@ function(monetdb_configure_defines)
 check_function_exists("pthread_setname_np" HAVE_PTHREAD_SETNAME_NP)
 check_function_exists("pthread_sigmask" HAVE_PTHREAD_SIGMASK)
   cmake_pop_check_state()
+  check_function_exists("SetThreadDescription" HAVE_SETTHREADDESCRIPTION)
   check_symbol_exists("regcomp" "regex.h" HAVE_POSIX_REGEX)
 endfunction()
 
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -708,12 +708,14 @@ thread_starter(void *arg)
}
 #endif
 #else
+#ifdef HAVE_SETTHREADDESCRIPTION
wchar_t *wname = utf8towchar(self->threadname);
if (wname != NULL) {
SetThreadDescription(GetCurrentThread(), wname);
free(wname);
}
 #endif
+#endif
self->data = NULL;
self->sp = THRsp();
thread_setself(self);
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -154,6 +154,7 @@
 #cmakedefine HAVE_POSIX_FALLOCATE 1
 #cmakedefine HAVE_POSIX_MADVISE 1
 #cmakedefine HAVE_PUTENV 1
+#cmakedefine HAVE_SETTHREADDESCRIPTION 1
 #cmakedefine HAVE_SETSID 1
 #cmakedefine HAVE_SHUTDOWN 1
 #cmakedefine HAVE_SIGACTION 1
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch, not changing any f...

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: 4dff56632d32 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4dff56632d32
Modified Files:
.bumpversion.cfg
MonetDB.spec
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
cmake/monetdb-versions.cmake
gdk/libbat.rc
monetdb5/tools/libmonetdb5.rc
Branch: default
Log Message:

Merge with Jun2023 branch, not changing any files.

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Updated library versions.

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: 5826d931fb14 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5826d931fb14
Modified Files:
cmake/monetdb-versions.cmake
Branch: Jun2023
Log Message:

Updated library versions.


diffs (28 lines):

diff --git a/cmake/monetdb-versions.cmake b/cmake/monetdb-versions.cmake
--- a/cmake/monetdb-versions.cmake
+++ b/cmake/monetdb-versions.cmake
@@ -42,7 +42,7 @@ set(MONETDB_VERSION "${MONETDB_VERSION_M
 # common/options and common/utils)
 set(GDK_VERSION_MAJOR "27")
 set(GDK_VERSION_MINOR "0")
-set(GDK_VERSION_PATCH "4")
+set(GDK_VERSION_PATCH "5")
 set(GDK_VERSION 
"${GDK_VERSION_MAJOR}.${GDK_VERSION_MINOR}.${GDK_VERSION_PATCH}")
 
 # version of the MAPI library (subdirectory clients/mapilib)
@@ -54,7 +54,7 @@ set(MAPI_VERSION "${MAPI_VERSION_MAJOR}.
 # version of the MONETDB5 library (subdirectory monetdb5, not including extras 
or sql)
 set(MONETDB5_VERSION_MAJOR "34")
 set(MONETDB5_VERSION_MINOR "0")
-set(MONETDB5_VERSION_PATCH "3")
+set(MONETDB5_VERSION_PATCH "4")
 set(MONETDB5_VERSION 
"${MONETDB5_VERSION_MAJOR}.${MONETDB5_VERSION_MINOR}.${MONETDB5_VERSION_PATCH}")
 
 # version of the MONETDBE library (subdirectory tools/monetdbe)
@@ -72,5 +72,5 @@ set(STREAM_VERSION "${STREAM_VERSION_MAJ
 # version of the SQL library (subdirectory sql)
 set(SQL_VERSION_MAJOR "14")
 set(SQL_VERSION_MINOR "0")
-set(SQL_VERSION_PATCH "4")
+set(SQL_VERSION_PATCH "5")
 set(SQL_VERSION 
"${SQL_VERSION_MAJOR}.${SQL_VERSION_MINOR}.${SQL_VERSION_PATCH}")
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Pre-release version number update.

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: c7ec4c48e135 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c7ec4c48e135
Modified Files:
.bumpversion.cfg
MonetDB.spec
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
cmake/monetdb-versions.cmake
gdk/libbat.rc
monetdb5/tools/libmonetdb5.rc
Branch: Jun2023
Log Message:

Pre-release version number update.


diffs (191 lines):

diff --git a/.bumpversion.cfg b/.bumpversion.cfg
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 11.47.12
+current_version = 11.47.13
 commit = False
 tag = False
 
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -7,7 +7,7 @@
 # Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V.
 
 %global name MonetDB
-%global version 11.47.12
+%global version 11.47.13
 %{!?buildno: %global buildno %(date +%Y%m%d)}
 
 # Use bcond_with to add a --with option; i.e., "without" is default.
diff --git a/clients/mapilib/mapi.rc b/clients/mapilib/mapi.rc
--- a/clients/mapilib/mapi.rc
+++ b/clients/mapilib/mapi.rc
@@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 #define sversion(major,minor,patch)#major "." #minor "." #patch "\0"
 
 1 VERSIONINFO
-  FILEVERSION version(11,47,12)
-  PRODUCTVERSION version(11,47,12)
+  FILEVERSION version(11,47,13)
+  PRODUCTVERSION version(11,47,13)
   FILEFLAGSMASK 0x3fL
   FILEFLAGS 0
   FILEOS VOS_NT_WINDOWS32
@@ -21,14 +21,14 @@ BEGIN
   VALUE "Comments", "\0"
   VALUE "CompanyName", "MonetDB B.V.\0"
   VALUE "FileDescription", "MonetDB Application Interface DLL\0"
-  VALUE "FileVersion", sversion(11,47,12)
+  VALUE "FileVersion", sversion(11,47,13)
   VALUE "InternalName", "Mapi\0"
   VALUE "LegalCopyright", "Copyright (c) MonetDB B.V. 2008-2023\0"
   VALUE "LegalTrademarks", "\0"
   VALUE "OriginalFilename", "Mapi.dll\0"
   VALUE "PrivateBuild", "\0"
   VALUE "ProductName", "MonetDB Client Libraries\0"
-  VALUE "ProductVersion", sversion(11,47,12)
+  VALUE "ProductVersion", sversion(11,47,13)
   VALUE "SpecialBuild", "\0"
 END
   END
diff --git a/clients/odbc/driver/driver.rc b/clients/odbc/driver/driver.rc
--- a/clients/odbc/driver/driver.rc
+++ b/clients/odbc/driver/driver.rc
@@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 #define sversion(major,minor,patch)#major "." #minor "." #patch "\0"
 
 1 VERSIONINFO
-  FILEVERSION version(11,47,12)
-  PRODUCTVERSION version(11,47,12)
+  FILEVERSION version(11,47,13)
+  PRODUCTVERSION version(11,47,13)
   FILEFLAGSMASK 0x3fL
   FILEFLAGS 0
   FILEOS VOS_NT_WINDOWS32
@@ -21,14 +21,14 @@ BEGIN
   VALUE "Comments", "\0"
   VALUE "CompanyName", "MonetDB B.V.\0"
   VALUE "FileDescription", "MonetDB ODBC Driver DLL\0"
-  VALUE "FileVersion", sversion(11,47,12)
+  VALUE "FileVersion", sversion(11,47,13)
   VALUE "InternalName", "MonetODBC\0"
   VALUE "LegalCopyright", "Copyright (c) MonetDB B.V. 2008-2023\0"
   VALUE "LegalTrademarks", "\0"
   VALUE "OriginalFilename", "MonetODBC.dll\0"
   VALUE "PrivateBuild", "\0"
   VALUE "ProductName", "MonetDB SQL Server\0"
-  VALUE "ProductVersion", sversion(11,47,12)
+  VALUE "ProductVersion", sversion(11,47,13)
   VALUE "SpecialBuild", "\0"
 END
   END
diff --git a/clients/odbc/winsetup/setup.rc b/clients/odbc/winsetup/setup.rc
--- a/clients/odbc/winsetup/setup.rc
+++ b/clients/odbc/winsetup/setup.rc
@@ -65,8 +65,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION version(11,47,12)
- PRODUCTVERSION version(11,47,12)
+ FILEVERSION version(11,47,13)
+ PRODUCTVERSION version(11,47,13)
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -83,12 +83,12 @@ BEGIN
 BEGIN
 VALUE "CompanyName", "MonetDB B.V."
 VALUE "FileDescription", "MonetDB ODBC Setup DLL"
-VALUE "FileVersion", sversion(11,47,12)
+VALUE "FileVersion", sversion(11,47,13)
 VALUE "InternalName", "MonetODBCs.dll"
 VALUE "LegalCopyright", "Copyright (c) MonetDB B.V. 2008-2023"
 VALUE "OriginalFilename", "MonetODBCs.dll"
 VALUE "ProductName", "MonetDB SQL Server"
-VALUE "ProductVersion", sversion(11,47,12)
+VALUE "ProductVersion", sversion(11,47,13)
 END
 END
 BLOCK "VarFileInfo"
diff --git a/cmake/monetdb-versions.cmake b/cmake/monetdb-versions.cmake
--- a/cmake/monetdb-versions.cmake
+++ b/cmake/monetdb-versions.cmake
@@ -10,10 +10,10 @@
 
 set(MONETDB_VERSION_MAJOR "11")
 set(MONETDB_VERSION_MINOR "47")
-set(MONETDB_VERSION_PATCH "12")
+set(MONETDB_VERSION_PATCH "13")
 
 if(RELEASE_VERSION)
-  set(MONETDB_RELEASE "unreleased")
+  set(MONETDB_RELEASE "Jun2023-SP3")
 endif()
 set(MONETDB_VERSION 
"${MONETDB_VERSION_MAJOR}.${MONETDB_VERSION_MINOR}.${MONETDB_VERSION_PATCH}")
 
diff --git a/gdk/libbat.rc b/gdk/libbat.rc
--- 

MonetDB: Jun2023 - Moved contents of ChangeLog.Jun2023 to MonetD...

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: e6eb06773c17 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e6eb06773c17
Modified Files:
MonetDB.spec
debian/changelog
gdk/ChangeLog-Archive
gdk/ChangeLog.Jun2023
misc/packages/deb/changelog
misc/packages/rpm/changelog
sql/ChangeLog-Archive
sql/ChangeLog.Jun2023
Branch: Jun2023
Log Message:

Moved contents of ChangeLog.Jun2023 to MonetDB.spec, debian/changelog and 
ChangeLog-Archive.


diffs (198 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -89,7 +89,7 @@ Group: Applications/Databases
 License: MPL-2.0
 URL: https://www.monetdb.org/
 BugURL: https://github.com/MonetDB/MonetDB/issues
-Source: 
https://www.monetdb.org/downloads/sources/Jun2023-SP2/%{name}-%{version}.tar.bz2
+Source: 
https://www.monetdb.org/downloads/sources/Jun2023-SP3/%{name}-%{version}.tar.bz2
 
 # The Fedora packaging document says we need systemd-rpm-macros for
 # the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7
@@ -860,6 +860,26 @@ fi
 %endif
 
 %changelog
+* Fri Nov 03 2023 Sjoerd Mullender  - 11.47.13-20231103
+- Rebuilt.
+- GH#7300: Implement missing standard SQL DATE and TIMESTAMP functions
+- GH#7324: string_distance('method',str1, str2) as a generic distance
+  function
+- GH#7409: Numpy table returning UDFs with variadic arguments
+
+* Thu Nov  2 2023 Sjoerd Mullender  - 11.47.13-20231103
+- sql: Added a missing interface function sys.timestamp_to_str with
+  a TIMESTAMP (as opposed to TIMESTAMP WITH TIME ZONE) argument.
+  The missing interface caused error messages being produced when the
+  function was called with a TIMESTAMP argument, although it did give
+  the correct result.
+
+* Tue Oct 31 2023 Sjoerd Mullender  - 11.47.13-20231103
+- gdk: A bug was fixed where the administration of which bats were in use was
+  interpreted incorrectly during startup, causing problems later.  One
+  symptom that has been observed was failure to startup with a message
+  that the catalog tables could not be loaded.
+
 * Fri Sep 29 2023 Sjoerd Mullender  - 11.47.11-20230929
 - Rebuilt.
 
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,32 @@
+monetdb (11.47.13) unstable; urgency=low
+
+  * Rebuilt.
+  * GH#7300: Implement missing standard SQL DATE and TIMESTAMP functions
+  * GH#7324: string_distance('method',str1, str2) as a generic distance
+function
+  * GH#7409: Numpy table returning UDFs with variadic arguments
+
+ -- Sjoerd Mullender   Fri, 03 Nov 2023 10:48:08 +0100
+
+monetdb (11.47.13) unstable; urgency=low
+
+  * sql: Added a missing interface function sys.timestamp_to_str with
+a TIMESTAMP (as opposed to TIMESTAMP WITH TIME ZONE) argument.
+The missing interface caused error messages being produced when the
+function was called with a TIMESTAMP argument, although it did give
+the correct result.
+
+ -- Sjoerd Mullender   Thu, 2 Nov 2023 10:48:08 +0100
+
+monetdb (11.47.13) unstable; urgency=low
+
+  * gdk: A bug was fixed where the administration of which bats were in use was
+interpreted incorrectly during startup, causing problems later.  One
+symptom that has been observed was failure to startup with a message
+that the catalog tables could not be loaded.
+
+ -- Sjoerd Mullender   Tue, 31 Oct 2023 10:48:08 +0100
+
 monetdb (11.47.11) unstable; urgency=low
 
   * Rebuilt.
diff --git a/gdk/ChangeLog-Archive b/gdk/ChangeLog-Archive
--- a/gdk/ChangeLog-Archive
+++ b/gdk/ChangeLog-Archive
@@ -1,6 +1,12 @@
 # DO NOT EDIT THIS FILE -- MAINTAINED AUTOMATICALLY
 # This file contains past ChangeLog entries
 
+* Tue Oct 31 2023 Sjoerd Mullender  - 11.47.13-20231103
+- A bug was fixed where the administration of which bats were in use was
+  interpreted incorrectly during startup, causing problems later.  One
+  symptom that has been observed was failure to startup with a message
+  that the catalog tables could not be loaded.
+
 * Fri Sep 22 2023 Sjoerd Mullender  - 11.47.7-20230925
 - Fixed a number of data races (race conditions).
 
diff --git a/gdk/ChangeLog.Jun2023 b/gdk/ChangeLog.Jun2023
--- a/gdk/ChangeLog.Jun2023
+++ b/gdk/ChangeLog.Jun2023
@@ -1,9 +1,3 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
-* Tue Oct 31 2023 Sjoerd Mullender 
-- A bug was fixed where the administration of which bats were in use was
-  interpreted incorrectly during startup, causing problems later.  One
-  symptom that has been observed was failure to startup with a message
-  that the catalog tables could not be loaded.
-
diff --git a/misc/packages/deb/changelog b/misc/packages/deb/changelog
--- a/misc/packages/deb/changelog
+++ b/misc/packages/deb/changelog
@@ -1,3 +1,32 @@
+monetdb (11.47.13) unstable; urgency=low
+
+  * Rebuilt.
+  * GH#7300: Implement missing standard SQL DATE and TIMESTAMP functions
+  * GH#7324: string_distance('method',str1, str2) as a generic distance
+function
+  * 

MonetDB: default - Fix and approve information_schema upgrade code.

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: 7432d4b9ec97 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7432d4b9ec97
Modified Files:
sql/backends/monet5/sql_upgrades.c

sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128

sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Fix and approve information_schema upgrade code.


diffs (truncated from 3699 to 300 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -6301,9 +6301,9 @@ sql_update_default(Client c, mvc *sql, s
"  cast(NULL AS varchar(1)) AS SCOPE_NAME,\n"
"  cast(NULL AS int) AS MAXIMUM_CARDINALITY,\n"
"  cast(NULL AS int) AS DTD_IDENTIFIER,\n"
-   "  cast(sys.\"ifthenelse\"(sys.\"locate\"('begin',f.\"func\") > 
0, sys.\"ifthenelse\"(sys.\"endswith\"(f.\"func\",';'), 
sys.\"substring\"(f.\"func\", sys.\"locate\"('begin',f.\"func\"), 
sys.\"length\"(sys.\"substring\"(f.\"func\", 
sys.\"locate\"('begin',f.\"func\")))-1), sys.\"substring\"(f.\"func\", 
sys.\"locate\"('begin',f.\"func\"))), NULL) AS varchar(8196) AS ROUTINE_BODY,\n"
+   "  cast(sys.\"ifthenelse\"(sys.\"locate\"('begin',f.\"func\") > 
0, sys.\"ifthenelse\"(sys.\"endswith\"(f.\"func\",';'), 
sys.\"substring\"(f.\"func\", sys.\"locate\"('begin',f.\"func\"), 
sys.\"length\"(sys.\"substring\"(f.\"func\", 
sys.\"locate\"('begin',f.\"func\")))-1), sys.\"substring\"(f.\"func\", 
sys.\"locate\"('begin',f.\"func\"))), NULL) AS varchar(8196)) AS 
ROUTINE_BODY,\n"
"  f.\"func\" AS ROUTINE_DEFINITION,\n"
-   "  cast(sys.\"ifthenelse\"(sys.\"locate\"('external 
name',f.\"func\") > 0, sys.\"ifthenelse\"(sys.\"endswith\"(f.\"func\",';'), 
sys.\"substring\"(f.\"func\", 14 + sys.\"locate\"('external name',f.\"func\"), 
sys.\"length\"(sys.\"substring\"(f.\"func\", 14 + sys.\"locate\"('external 
name',f.\"func\")))-1), sys.\"substring\"(f.\"func\", 14 + 
sys.\"locate\"('external name',f.\"func\"))), NULL) AS varchar(1024) AS 
EXTERNAL_NAME,\n"
+   "  cast(sys.\"ifthenelse\"(sys.\"locate\"('external 
name',f.\"func\") > 0, sys.\"ifthenelse\"(sys.\"endswith\"(f.\"func\",';'), 
sys.\"substring\"(f.\"func\", 14 + sys.\"locate\"('external name',f.\"func\"), 
sys.\"length\"(sys.\"substring\"(f.\"func\", 14 + sys.\"locate\"('external 
name',f.\"func\")))-1), sys.\"substring\"(f.\"func\", 14 + 
sys.\"locate\"('external name',f.\"func\"))), NULL) AS varchar(1024)) AS 
EXTERNAL_NAME,\n"
"  fl.\"language_keyword\" AS EXTERNAL_LANGUAGE,\n"
"  'GENERAL' AS PARAMETER_STYLE,\n"
"  'YES' AS IS_DETERMINISTIC,\n"
@@ -6374,7 +6374,7 @@ sql_update_default(Client c, mvc *sql, s
"  cast(NULL AS varchar(1)) AS SEQUENCE_CATALOG,\n"
"  s.\"name\" AS SEQUENCE_SCHEMA,\n"
"  sq.\"name\" AS SEQUENCE_NAME,\n"
-   "  cast('bigint' AS varchar(16)) AS DATA_TYPE,\n"
+   "  cast('BIGINT' AS varchar(16)) AS DATA_TYPE,\n"
"  cast(64 AS SMALLINT) AS NUMERIC_PRECISION,\n"
"  cast(2 AS SMALLINT) AS NUMERIC_PRECISION_RADIX,\n"
"  cast(0 AS SMALLINT) AS NUMERIC_SCALE,\n"
diff --git 

MonetDB: Jun2023 - Fix an out-of-bounds write by making sure eno...

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: c729ee7c51ff for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c729ee7c51ff
Modified Files:
gdk/gdk_string.c
Branch: Jun2023
Log Message:

Fix an out-of-bounds write by making sure enough bytes are allocated.


diffs (65 lines):

diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -765,7 +765,7 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
 {
oid gid;
BUN i, p, nils = 0;
-   size_t *restrict lengths = NULL, *restrict lastseplength = NULL, 
separator_length = 0, next_length;
+   size_t *restrict lengths = NULL, separator_length = 0, next_length;
str *restrict astrings = NULL;
BATiter bi, bis = (BATiter) {0};
BAT *bn = NULL;
@@ -926,9 +926,7 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
 * each group, then the the total offset */
lengths = GDKzalloc(ngrp * sizeof(*lengths));
astrings = GDKmalloc(ngrp * sizeof(str));
-   if (sep)
-   lastseplength = GDKzalloc(ngrp * 
sizeof(*lastseplength));
-   if (lengths == NULL || astrings == NULL || (sep && 
lastseplength == NULL)) {
+   if (lengths == NULL || astrings == NULL) {
goto finish;
}
/* at first, set astrings[i] to str_nil, then for each
@@ -970,14 +968,11 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
if (!strNil(sl)) {
next_length = 
strlen(sl);
lengths[gid] += 
next_length;
-   lastseplength[gid] = 
next_length;
-   } else
-   lastseplength[gid] = 0;
+   }
astrings[gid] = NULL;
} else if (!skip_nils) {
nils++;
lengths[gid] = (size_t) -1;
-   lastseplength[gid] = 0;
astrings[gid] = (char *) 
str_nil;
}
}
@@ -988,7 +983,7 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
if (separator) {
for (i = 0; i < ngrp; i++) {
if (astrings[i] == NULL) {
-   if ((astrings[i] = GDKmalloc(lengths[i] 
+ 1 - separator_length)) == NULL) {
+   if ((astrings[i] = GDKmalloc(lengths[i] 
+ 1)) == NULL) {
goto finish;
}
astrings[i][0] = 0;
@@ -1000,7 +995,7 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
assert(sep != NULL);
for (i = 0; i < ngrp; i++) {
if (astrings[i] == NULL) {
-   if ((astrings[i] = GDKmalloc(lengths[i] 
+ 1 - lastseplength[i])) == NULL) {
+   if ((astrings[i] = GDKmalloc(lengths[i] 
+ 1)) == NULL) {
goto finish;
}
astrings[i][0] = 0;
@@ -1076,7 +1071,6 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
if (has_nils)
*has_nils = nils;
GDKfree(lengths);
-   GDKfree(lastseplength);
if (astrings) {
for (i = 0; i < ngrp; i++) {
if (astrings[i] != str_nil)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch.

2023-11-03 Thread Sjoerd Mullender via checkin-list
Changeset: f1deb321bc1b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f1deb321bc1b
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (65 lines):

diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -765,7 +765,7 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
 {
oid gid;
BUN i, p, nils = 0;
-   size_t *restrict lengths = NULL, *restrict lastseplength = NULL, 
separator_length = 0, next_length;
+   size_t *restrict lengths = NULL, separator_length = 0, next_length;
str *restrict astrings = NULL;
BATiter bi, bis = (BATiter) {0};
BAT *bn = NULL;
@@ -926,9 +926,7 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
 * each group, then the the total offset */
lengths = GDKzalloc(ngrp * sizeof(*lengths));
astrings = GDKmalloc(ngrp * sizeof(str));
-   if (sep)
-   lastseplength = GDKzalloc(ngrp * 
sizeof(*lastseplength));
-   if (lengths == NULL || astrings == NULL || (sep && 
lastseplength == NULL)) {
+   if (lengths == NULL || astrings == NULL) {
goto finish;
}
/* at first, set astrings[i] to str_nil, then for each
@@ -970,14 +968,11 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
if (!strNil(sl)) {
next_length = 
strlen(sl);
lengths[gid] += 
next_length;
-   lastseplength[gid] = 
next_length;
-   } else
-   lastseplength[gid] = 0;
+   }
astrings[gid] = NULL;
} else if (!skip_nils) {
nils++;
lengths[gid] = (size_t) -1;
-   lastseplength[gid] = 0;
astrings[gid] = (char *) 
str_nil;
}
}
@@ -988,7 +983,7 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
if (separator) {
for (i = 0; i < ngrp; i++) {
if (astrings[i] == NULL) {
-   if ((astrings[i] = GDKmalloc(lengths[i] 
+ 1 - separator_length)) == NULL) {
+   if ((astrings[i] = GDKmalloc(lengths[i] 
+ 1)) == NULL) {
goto finish;
}
astrings[i][0] = 0;
@@ -1000,7 +995,7 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
assert(sep != NULL);
for (i = 0; i < ngrp; i++) {
if (astrings[i] == NULL) {
-   if ((astrings[i] = GDKmalloc(lengths[i] 
+ 1 - lastseplength[i])) == NULL) {
+   if ((astrings[i] = GDKmalloc(lengths[i] 
+ 1)) == NULL) {
goto finish;
}
astrings[i][0] = 0;
@@ -1076,7 +1071,6 @@ concat_strings(BAT **bnp, ValPtr pt, BAT
if (has_nils)
*has_nils = nils;
GDKfree(lengths);
-   GDKfree(lastseplength);
if (astrings) {
for (i = 0; i < ngrp; i++) {
if (astrings[i] != str_nil)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Fixed layout.

2023-11-02 Thread Sjoerd Mullender via checkin-list
Changeset: 98f7e12a4fa0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/98f7e12a4fa0
Modified Files:
gdk/gdk_logger.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/atoms/mtime.h
monetdb5/modules/kernel/bat5.c
monetdb5/modules/mal/bbp.c
monetdb5/modules/mal/calc.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/remote.c
monetdb5/modules/mal/tablet.c
monetdb5/modules/mal/tokenizer.c
monetdb5/optimizer/opt_evaluate.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_mitosis.c
monetdb5/optimizer/opt_remap.c
tools/mserver/mserver5.c
Branch: Jun2023
Log Message:

Fixed layout.
The indent program sometimes makes weird choices...


diffs (truncated from 456 to 300 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2753,8 +2753,7 @@ internal_log_bat(logger *lg, BAT *b, log
if (b->ttype == TYPE_msk) {
BATiter bi = bat_iterator(b);
if (offset % 32 == 0) {
-   if (!mnstr_writeIntArray
-   (lg->current->output_log, (int *) ((char *) bi.base 
+ offset / 32),
+   if (!mnstr_writeIntArray(lg->current->output_log, (int 
*) ((char *) bi.base + offset / 32),
 (size_t) ((nr + 31) / 32)))
ok = GDK_FAIL;
} else {
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -418,9 +418,8 @@ prepareMalEvent(Client cntxt, MalBlkPtr 
goto 
cleanup_and_exit;
}
} else {
-   if (!logadd
-   (, 
",\"mode\":\"%s\"",
-(di.transient 
? "transient" : "persistent"))) {
+   if (!logadd(, 
",\"mode\":\"%s\"",
+   
(di.transient ? "transient" : "persistent"))) {

BBPunfix(d->batCacheid);
goto 
cleanup_and_exit;
}
@@ -514,8 +513,7 @@ prepareMalEvent(Client cntxt, MalBlkPtr 
if (!ok)
goto cleanup_and_exit;
}
-   if (!logadd
-   (, ",\"eol\":%d", 
getVarEolife(mb, getArg(pci, j
+   if (!logadd(, ",\"eol\":%d", 
getVarEolife(mb, getArg(pci, j
goto cleanup_and_exit;
// if (!logadd(, ",\"fixed\":%d", 
isVarFixed(mb,getArg(pci,j return NULL;
if (!logadd(, "}"))
diff --git a/monetdb5/modules/atoms/mtime.h b/monetdb5/modules/atoms/mtime.h
--- a/monetdb5/modules/atoms/mtime.h
+++ b/monetdb5/modules/atoms/mtime.h
@@ -48,8 +48,7 @@ date_sub_msec_interval(date *ret, date d
*ret = date_nil;
return MAL_SUCCEED;
}
-   if (is_date_nil
-   ((*ret = date_add_day(d, (int) (-ms / (24 * 60 * 60 * 1000))
+   if (is_date_nil((*ret = date_add_day(d, (int) (-ms / (24 * 60 * 60 * 
1000))
throw(MAL, "mtime.date_sub_msec_interval",
  SQLSTATE(22003) "overflow in calculation");
return MAL_SUCCEED;
@@ -62,8 +61,7 @@ date_add_msec_interval(date *ret, date d
*ret = date_nil;
return MAL_SUCCEED;
}
-   if (is_date_nil
-   ((*ret = date_add_day(d, (int) (ms / (24 * 60 * 60 * 1000))
+   if (is_date_nil((*ret = date_add_day(d, (int) (ms / (24 * 60 * 60 * 
1000))
throw(MAL, "mtime.date_add_msec_interval",
  SQLSTATE(22003) "overflow in calculation");
return MAL_SUCCEED;
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -664,10 +664,11 @@ HASHinfo(BAT *bk, BAT *bv, Hash *h, str 
 
for (i = 0; i < COLLISION + 1; i++)
if (cnt[i]) {
-   if (BUNappend
-   (bk,
-pre(s, local_utoa(i ? (((size_t) 1) << (i - 
1)) : 0, buf),
-prebuf), false) != GDK_SUCCEED
+ 

MonetDB: Jun2023 - Be more careful in which parts of sql_catalog...

2023-11-07 Thread Sjoerd Mullender via checkin-list
Changeset: 81d4cd0063e7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/81d4cd0063e7
Modified Files:
gdk/ChangeLog.Jun2023
gdk/gdk_logger.c
gdk/gdk_logger_internals.h
Branch: Jun2023
Log Message:

Be more careful in which parts of sql_catalog_bid/sql_catalog_id/sql_dcatalog 
is saved.


diffs (truncated from 305 to 300 lines):

diff --git a/gdk/ChangeLog.Jun2023 b/gdk/ChangeLog.Jun2023
--- a/gdk/ChangeLog.Jun2023
+++ b/gdk/ChangeLog.Jun2023
@@ -1,3 +1,10 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Tue Nov  7 2023 Sjoerd Mullender 
+- When saving the SQL catalog during a low-level commit, we should
+  only save the part of the catalog that corresponds to the part of the
+  write-ahead log that has been processed.  What we did was save more,
+  which resulted in the catalog containing references to tables and
+  columns whose disk presence is otherwise only in the write-ahead log.
+
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -94,7 +94,7 @@ typedef struct logformat_t {
 
 typedef enum { LOG_OK, LOG_EOF, LOG_ERR } log_return;
 
-static gdk_return bm_commit(logger *lg, uint32_t *updated, BUN maxupdated);
+static gdk_return bm_commit(logger *lg, logged_range *pending, uint32_t 
*updated, BUN maxupdated);
 static gdk_return tr_grow(trans *tr);
 
 #define log_lock(lg)   MT_lock_set(&(lg)->lock)
@@ -1089,6 +1089,8 @@ log_open_output(logger *lg)
new_range->next = NULL;
logged_range *current = lg->current;
assert(current && current->next == NULL);
+   new_range->cnt = current->cnt;
+   new_range->deleted = current->deleted;
current->next = new_range;
ATOMIC_INC(>nr_open_files);
return GDK_SUCCEED;
@@ -1381,11 +1383,11 @@ log_readlogs(logger *lg, const char *fil
 }
 
 static gdk_return
-log_commit(logger *lg, uint32_t *updated, BUN maxupdated)
+log_commit(logger *lg, logged_range *pending, uint32_t *updated, BUN 
maxupdated)
 {
TRC_DEBUG(WAL, "commit");
 
-   return bm_commit(lg, updated, maxupdated);
+   return bm_commit(lg, pending, updated, maxupdated);
 }
 
 static gdk_return
@@ -1649,19 +1651,25 @@ cleanup_and_swap(logger *lg, int *r, con
lg->catalog_lid = nlids;
lg->cnt = BATcount(lg->catalog_bid);
lg->deleted -= cleanup;
+   for (logged_range *p = lg->pending; p; p = p->next) {
+   p->cnt -= cleanup;
+   p->deleted -= cleanup;
+   }
return rcnt;
 }
 
 /* this function is called with log_lock() held; it releases the lock
  * before returning */
 static gdk_return
-bm_subcommit(logger *lg, uint32_t *updated, BUN maxupdated)
+bm_subcommit(logger *lg, logged_range *pending, uint32_t *updated, BUN 
maxupdated)
 {
+   BUN cnt = pending ? pending->cnt : BATcount(lg->catalog_bid);
+   BUN dcnt = pending ? pending->deleted : BATcount(lg->dcatalog);
BUN p, q;
BAT *catalog_bid = lg->catalog_bid;
BAT *catalog_id = lg->catalog_id;
BAT *dcatalog = lg->dcatalog;
-   BUN nn = 13 + BATcount(catalog_bid);
+   BUN nn = 13 + cnt;
bat *n = GDKmalloc(sizeof(bat) * nn);
bat *r = GDKmalloc(sizeof(bat) * nn);
BUN *sizes = GDKmalloc(sizeof(BUN) * nn);
@@ -1704,27 +1712,31 @@ bm_subcommit(logger *lg, uint32_t *updat
n[i++] = col;
}
/* now commit catalog, so it's also up to date on disk */
-   sizes[i] = lg->cnt;
+   sizes[i] = cnt;
n[i++] = catalog_bid->batCacheid;
-   sizes[i] = lg->cnt;
+   sizes[i] = cnt;
n[i++] = catalog_id->batCacheid;
-   sizes[i] = BATcount(dcatalog);
+   sizes[i] = dcnt;
n[i++] = dcatalog->batCacheid;
 
-   if (cleanup &&
-   (rcnt = cleanup_and_swap(lg, r, bids, lids, cnts, catalog_bid,
-catalog_id, dcatalog, cleanup, updated,
-maxupdated)) < 0) {
-   GDKfree(n);
-   GDKfree(r);
-   GDKfree(sizes);
-   log_unlock(lg);
-   return GDK_FAIL;
+   if (cleanup) {
+   if ((rcnt = cleanup_and_swap(lg, r, bids, lids, cnts,
+catalog_bid, catalog_id, dcatalog,
+cleanup, updated,
+maxupdated)) < 0) {
+   GDKfree(n);
+   GDKfree(r);
+   GDKfree(sizes);
+   log_unlock(lg);
+   return GDK_FAIL;
+   }
+   cnt -= cleanup;
+   dcnt -= cleanup;
}
if (dcatalog != lg->dcatalog) {
-   i = subcommit_list_add(i, n, sizes, 
lg->catalog_bid->batCacheid, BATcount(lg->catalog_bid));
-   i = subcommit_list_add(i, n, sizes, lg->catalog_id->batCacheid, 
BATcount(lg->catalog_bid));
-   

MonetDB: default - Merge with Jun2023 branch.

2023-11-07 Thread Sjoerd Mullender via checkin-list
Changeset: 3f7be6f05660 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3f7be6f05660
Modified Files:
gdk/gdk_logger.c
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (truncated from 305 to 300 lines):

diff --git a/gdk/ChangeLog.Jun2023 b/gdk/ChangeLog.Jun2023
--- a/gdk/ChangeLog.Jun2023
+++ b/gdk/ChangeLog.Jun2023
@@ -1,3 +1,10 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Tue Nov  7 2023 Sjoerd Mullender 
+- When saving the SQL catalog during a low-level commit, we should
+  only save the part of the catalog that corresponds to the part of the
+  write-ahead log that has been processed.  What we did was save more,
+  which resulted in the catalog containing references to tables and
+  columns whose disk presence is otherwise only in the write-ahead log.
+
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -94,7 +94,7 @@ typedef struct logformat_t {
 
 typedef enum { LOG_OK, LOG_EOF, LOG_ERR } log_return;
 
-static gdk_return bm_commit(logger *lg, uint32_t *updated, BUN maxupdated);
+static gdk_return bm_commit(logger *lg, logged_range *pending, uint32_t 
*updated, BUN maxupdated);
 static gdk_return tr_grow(trans *tr);
 
 #define log_lock(lg)   MT_lock_set(&(lg)->lock)
@@ -1089,6 +1089,8 @@ log_open_output(logger *lg)
new_range->next = NULL;
logged_range *current = lg->current;
assert(current && current->next == NULL);
+   new_range->cnt = current->cnt;
+   new_range->deleted = current->deleted;
current->next = new_range;
ATOMIC_INC(>nr_open_files);
return GDK_SUCCEED;
@@ -1381,11 +1383,11 @@ log_readlogs(logger *lg, const char *fil
 }
 
 static gdk_return
-log_commit(logger *lg, uint32_t *updated, BUN maxupdated)
+log_commit(logger *lg, logged_range *pending, uint32_t *updated, BUN 
maxupdated)
 {
TRC_DEBUG(WAL, "commit");
 
-   return bm_commit(lg, updated, maxupdated);
+   return bm_commit(lg, pending, updated, maxupdated);
 }
 
 static gdk_return
@@ -1661,19 +1663,25 @@ cleanup_and_swap(logger *lg, int *r, con
GDKclrerr();
lg->cnt = BATcount(lg->catalog_bid);
lg->deleted -= cleanup;
+   for (logged_range *p = lg->pending; p; p = p->next) {
+   p->cnt -= cleanup;
+   p->deleted -= cleanup;
+   }
return rcnt;
 }
 
 /* this function is called with log_lock() held; it releases the lock
  * before returning */
 static gdk_return
-bm_subcommit(logger *lg, uint32_t *updated, BUN maxupdated)
+bm_subcommit(logger *lg, logged_range *pending, uint32_t *updated, BUN 
maxupdated)
 {
+   BUN cnt = pending ? pending->cnt : BATcount(lg->catalog_bid);
+   BUN dcnt = pending ? pending->deleted : BATcount(lg->dcatalog);
BUN p, q;
BAT *catalog_bid = lg->catalog_bid;
BAT *catalog_id = lg->catalog_id;
BAT *dcatalog = lg->dcatalog;
-   BUN nn = 13 + BATcount(catalog_bid);
+   BUN nn = 13 + cnt;
bat *n = GDKmalloc(sizeof(bat) * nn);
bat *r = GDKmalloc(sizeof(bat) * nn);
BUN *sizes = GDKmalloc(sizeof(BUN) * nn);
@@ -1716,27 +1724,31 @@ bm_subcommit(logger *lg, uint32_t *updat
n[i++] = col;
}
/* now commit catalog, so it's also up to date on disk */
-   sizes[i] = lg->cnt;
+   sizes[i] = cnt;
n[i++] = catalog_bid->batCacheid;
-   sizes[i] = lg->cnt;
+   sizes[i] = cnt;
n[i++] = catalog_id->batCacheid;
-   sizes[i] = BATcount(dcatalog);
+   sizes[i] = dcnt;
n[i++] = dcatalog->batCacheid;
 
-   if (cleanup &&
-   (rcnt = cleanup_and_swap(lg, r, bids, lids, cnts, catalog_bid,
-catalog_id, dcatalog, cleanup, updated,
-maxupdated)) < 0) {
-   GDKfree(n);
-   GDKfree(r);
-   GDKfree(sizes);
-   log_unlock(lg);
-   return GDK_FAIL;
+   if (cleanup) {
+   if ((rcnt = cleanup_and_swap(lg, r, bids, lids, cnts,
+catalog_bid, catalog_id, dcatalog,
+cleanup, updated,
+maxupdated)) < 0) {
+   GDKfree(n);
+   GDKfree(r);
+   GDKfree(sizes);
+   log_unlock(lg);
+   return GDK_FAIL;
+   }
+   cnt -= cleanup;
+   dcnt -= cleanup;
}
if (dcatalog != lg->dcatalog) {
-   i = subcommit_list_add(i, n, sizes, 
lg->catalog_bid->batCacheid, BATcount(lg->catalog_bid));
-   i = subcommit_list_add(i, n, sizes, lg->catalog_id->batCacheid, 
BATcount(lg->catalog_bid));
-   i = subcommit_list_add(i, n, sizes, lg->dcatalog->batCacheid, 
BATcount(lg->dcatalog));
+   i = 

MonetDB: default - Remove unused struct members.

2023-11-07 Thread Sjoerd Mullender via checkin-list
Changeset: 3911bab6c4f3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3911bab6c4f3
Modified Files:
gdk/gdk_logger.c
gdk/gdk_logger_internals.h
sql/storage/bat/bat_logger.c
Branch: default
Log Message:

Remove unused struct members.


diffs (94 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1494,7 +1494,7 @@ log_switch_bat(BAT *old, BAT *new, const
 static gdk_return
 bm_get_counts(logger *lg)
 {
-   BUN p, q, deleted = 0;
+   BUN p, q;
const log_bid *bids = (const log_bid *) Tloc(lg->catalog_bid, 0);
 
BATloop(lg->catalog_bid, p, q) {
@@ -1507,7 +1507,6 @@ bm_get_counts(logger *lg)
assert(b);
cnt = BATcount(b);
} else {
-   deleted++;
lid = BBP_desc(bids[p]) ? 1 : -1;
}
if (BUNappend(lg->catalog_cnt, , false) != GDK_SUCCEED)
@@ -1515,8 +1514,6 @@ bm_get_counts(logger *lg)
if (BUNappend(lg->catalog_lid, , false) != GDK_SUCCEED)
return GDK_FAIL;
}
-   lg->deleted = deleted;
-   lg->cnt = BATcount(lg->catalog_bid);
return GDK_SUCCEED;
 }
 
@@ -1634,7 +1631,7 @@ cleanup_and_swap(logger *lg, int *r, con
r[rcnt++] = lg->catalog_id->batCacheid;
r[rcnt++] = lg->dcatalog->batCacheid;
 
-   assert(lg->deleted - cleanup == BATcount(ndels));
+   assert(BATcount(lg->dcatalog) - cleanup == BATcount(ndels));
 
logbat_destroy(lg->catalog_bid);
logbat_destroy(lg->catalog_id);
@@ -1661,8 +1658,6 @@ cleanup_and_swap(logger *lg, int *r, con
strconcat_len(bak, sizeof(bak), lg->fn, "_catalog_lid", NULL);
if (BBPrename(lg->catalog_lid, bak) < 0)
GDKclrerr();
-   lg->cnt = BATcount(lg->catalog_bid);
-   lg->deleted -= cleanup;
for (logged_range *p = lg->pending; p; p = p->next) {
p->cnt -= cleanup;
p->deleted -= cleanup;
@@ -3279,7 +3274,6 @@ log_add_bat(logger *lg, BAT *b, log_id i
|| BUNappend(lg->catalog_cnt, , false) != GDK_SUCCEED ||
BUNappend(lg->catalog_lid, , false) != GDK_SUCCEED)
return GDK_FAIL;
-   lg->cnt++;
if (lg->current)
lg->current->cnt++;
BBPretain(bid);
@@ -3304,7 +3298,6 @@ log_del_bat(logger *lg, log_bid bid)
if (BUNreplace(lg->catalog_lid, p, , false) != GDK_SUCCEED)
return GDK_FAIL;
if (BUNappend(lg->dcatalog, , true) == GDK_SUCCEED) {
-   lg->deleted++;
if (lg->current)
lg->current->deleted++;
return GDK_SUCCEED;
diff --git a/gdk/gdk_logger_internals.h b/gdk/gdk_logger_internals.h
--- a/gdk/gdk_logger_internals.h
+++ b/gdk/gdk_logger_internals.h
@@ -76,8 +76,6 @@ struct logger {
BAT *catalog_cnt;   /* count of ondisk buns (transient) */
BAT *catalog_lid;   /* last tid, after which it gets 
released/destroyed */
BAT *dcatalog;  /* deleted from catalog table */
-   BUN cnt;/* number of persistent bats, incremented on 
log flushing */
-   BUN deleted;/* number of destroyed persistent bats, needed 
for catalog vacuum */
BAT *seqs_id;   /* int id column */
BAT *seqs_val;  /* lng value column */
BAT *dseqs; /* deleted from seqs table */
diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -112,7 +112,6 @@ replace_bat(old_logger *old_lg, logger *

MT_rwlock_rdunlock(>thashlock);
return GDK_FAIL;
}
-   lg->deleted++;
break;
}
}
@@ -123,7 +122,6 @@ replace_bat(old_logger *old_lg, logger *
(rc = BUNappend(lg->catalog_cnt, 
&(lng){BATcount(newcol)}, false)) == GDK_SUCCEED) {
BBPretain(newcol->batCacheid);
}
-   lg->cnt++;
}
}
return rc;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Different error message when running single-t...

2023-10-31 Thread Sjoerd Mullender via checkin-list
Changeset: 5012083edb0d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5012083edb0d
Modified Files:
sql/test/merge-partitions/Tests/mergepart30.test
Branch: default
Log Message:

Different error message when running single-threaded.
Both messages are correct, the check happens to be done in a different order.


diffs (49 lines):

diff --git a/sql/test/merge-partitions/Tests/mergepart30.test 
b/sql/test/merge-partitions/Tests/mergepart30.test
--- a/sql/test/merge-partitions/Tests/mergepart30.test
+++ b/sql/test/merge-partitions/Tests/mergepart30.test
@@ -192,9 +192,14 @@ ALTER TABLE table1 DROP TABLE another2
 statement ok
 ALTER TABLE table1 ADD TABLE another1 AS PARTITION FROM RANGE MINVALUE TO 10 
WITH NULL VALUES
 
+skipif threads=1
 statement error 42000!ALTER TABLE: conflicting partitions: 0 to 5 and absolute 
min value to 10 from table sys.another1
 ALTER TABLE table1 ADD TABLE another2 AS PARTITION FROM 0 to 5
 
+onlyif threads=1
+statement error 42000!ALTER TABLE: there are values in column a outside the 
partition range
+ALTER TABLE table1 ADD TABLE another2 AS PARTITION FROM 0 to 5
+
 query I rowsort
 SELECT a FROM table1
 
@@ -222,15 +227,30 @@ ALTER TABLE table1 DROP TABLE another2
 statement ok
 ALTER TABLE table1 ADD TABLE another1 AS PARTITION FROM RANGE MINVALUE TO 
RANGE MAXVALUE
 
+skipif threads=1
 statement error 42000!ALTER TABLE: conflicting partitions: 0 to 5 and absolute 
min value to absolute max value from table sys.another1
 ALTER TABLE table1 ADD TABLE another2 AS PARTITION FROM 0 to 5
 
+onlyif threads=1
+statement error 42000!ALTER TABLE: there are values in column a outside the 
partition range
+ALTER TABLE table1 ADD TABLE another2 AS PARTITION FROM 0 to 5
+
+skipif threads=1
 statement error 42000!ALTER TABLE: conflicting partitions: absolute min value 
to 2 and absolute min value to absolute max value from table sys.another1
 ALTER TABLE table1 ADD TABLE another2 AS PARTITION FROM RANGE MINVALUE to 2
 
+onlyif threads=1
+statement error 42000!ALTER TABLE: there are values in column a outside the 
partition range
+ALTER TABLE table1 ADD TABLE another2 AS PARTITION FROM RANGE MINVALUE to 2
+
+skipif threads=1
 statement error 42000!ALTER TABLE: conflicting partitions: 2 to absolute max 
value and absolute min value to absolute max value from table sys.another1
 ALTER TABLE table1 ADD TABLE another2 AS PARTITION FROM 2 to RANGE MAXVALUE
 
+onlyif threads=1
+statement error 42000!ALTER TABLE: there are values in column a outside the 
partition range
+ALTER TABLE table1 ADD TABLE another2 AS PARTITION FROM 2 to RANGE MAXVALUE
+
 query I rowsort
 SELECT a FROM table1
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Added flag --ci to help with continuous integ...

2023-10-30 Thread Sjoerd Mullender via checkin-list
Changeset: 713fb332fd98 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/713fb332fd98
Modified Files:
testing/Mtest.py.in
Branch: default
Log Message:

Added flag --ci to help with continuous integration.
Like former --jenkins flag.


diffs (20 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -3489,6 +3489,7 @@ def main(argv) :
 parser.add_argument('--single-in-memory', action='store_true', 
dest='single_in_memory', help='use --in-memory for SingleServer directories')
 parser.add_argument('--approve', action='store_true', help='produce 
.newtest file in testing directory with calculated content')
 parser.add_argument('--stop-at-crash', action='store_true', 
dest='stop_crash', help='stop testing when the server crashes')
+parser.add_argument('--ci', action='store_true', dest='ci', help='special 
handling for continuous integration (no error return unless serious problem)')
 global produce_html
 if produce_html:
 parser.add_argument('--no-html', action='store_false', 
dest='produce_html', help='do not produce HTML files')
@@ -4309,7 +4310,7 @@ VALUES (%s, '%s', '%s', '%s',
 """)
 else:
 print("No differences encountered during testing.")
-sys.exit(1 if Failed or errseen else 0)
+sys.exit(1 if not opts.ci and (Failed or errseen) else 0)
 
 finally:
 # cleanup the place where we put our UNIX sockets
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge with Jun2023 branch.

2023-10-31 Thread Sjoerd Mullender via checkin-list
Changeset: cef924c31c5b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cef924c31c5b
Modified Files:
gdk/gdk_logger.c
Branch: default
Log Message:

Merge with Jun2023 branch.


diffs (38 lines):

diff --git a/gdk/ChangeLog.Jun2023 b/gdk/ChangeLog.Jun2023
--- a/gdk/ChangeLog.Jun2023
+++ b/gdk/ChangeLog.Jun2023
@@ -1,3 +1,9 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Tue Oct 31 2023 Sjoerd Mullender 
+- A bug was fixed where the administration of which bats were in use was
+  interpreted incorrectly during startup, causing problems later.  One
+  symptom that has been observed was failure to startup with a message
+  that the catalog tables could not be loaded.
+
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1506,7 +1506,7 @@ bm_get_counts(logger *lg)
cnt = BATcount(b);
} else {
deleted++;
-   lid = 1;
+   lid = BBP_desc(bids[p]) ? 1 : -1;
}
if (BUNappend(lg->catalog_cnt, , false) != GDK_SUCCEED)
return GDK_FAIL;
@@ -1705,8 +1705,11 @@ bm_subcommit(logger *lg, uint32_t *updat
}
bat col = bids[p];
 
-   if (lids && lids[p] != lng_nil && lids[p] <= lg->saved_tid)
+   if (lids && lids[p] != lng_nil && lids[p] <= lg->saved_tid) {
cleanup++;
+   if (lids[p] == -1)
+   continue;
+   }
TRC_DEBUG(WAL, "new %s (%d)\n", BBP_logical(col), col);
assert(col);
sizes[i] = cnts ? (BUN) cnts[p] : 0;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Use correct syntax for find_package with vers...

2023-10-31 Thread Sjoerd Mullender via checkin-list
Changeset: 735195338f72 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/735195338f72
Modified Files:
cmake/monetdb-findpackages.cmake
sql/server/sql_parser.y
Branch: default
Log Message:

Use correct syntax for find_package with version; we need bison 3.0.
Bison 3.0 has `%define parse.error verbose', 3.6 introduced `%define
parse.error detailed'.


diffs (24 lines):

diff --git a/cmake/monetdb-findpackages.cmake b/cmake/monetdb-findpackages.cmake
--- a/cmake/monetdb-findpackages.cmake
+++ b/cmake/monetdb-findpackages.cmake
@@ -9,7 +9,7 @@
 #]]
 
 # Detect required packages
-find_package(BISON REQUIRED 3.2)
+find_package(BISON 3.0 REQUIRED)
 find_package(Iconv)
 find_package(Threads)
 
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -175,7 +175,7 @@ uescape_xform(char *restrict s, const ch
 %parse-param { mvc *m }
 %lex-param { void *m }
 
-/* only possible from bison 3.6 and up */
+/* only possible from bison 3.0 and up */
 %define parse.error verbose
 
 /* reentrant parser */
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Fix a bug during startup.

2023-10-31 Thread Sjoerd Mullender via checkin-list
Changeset: 36890da7c473 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/36890da7c473
Modified Files:
gdk/ChangeLog.Jun2023
gdk/gdk_logger.c
Branch: Jun2023
Log Message:

Fix a bug during startup.
If during startup the catalog_bid files contains a reference to a bat
that has already been deleted, and the WAL contains statements to create
a new bat (i.e. a new table), and that already deleted bat's id gets
reused, the logger got confused about this and the bat might not
actually survive the subcommit.
This was fixed by setting the catalog_lid entry to a special value (-1)
that is recognized as meaning, the bat was pre-deleted and the entry
should just be removed from the catalog by cleanup_and_swap.  I.e. no
other actions to be performed.


diffs (38 lines):

diff --git a/gdk/ChangeLog.Jun2023 b/gdk/ChangeLog.Jun2023
--- a/gdk/ChangeLog.Jun2023
+++ b/gdk/ChangeLog.Jun2023
@@ -1,3 +1,9 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Tue Oct 31 2023 Sjoerd Mullender 
+- A bug was fixed where the administration of which bats were in use was
+  interpreted incorrectly during startup, causing problems later.  One
+  symptom that has been observed was failure to startup with a message
+  that the catalog tables could not be loaded.
+
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1506,7 +1506,7 @@ bm_get_counts(logger *lg)
cnt = BATcount(b);
} else {
deleted++;
-   lid = 1;
+   lid = BBP_desc(bids[p]) ? 1 : -1;
}
if (BUNappend(lg->catalog_cnt, , false) != GDK_SUCCEED)
return GDK_FAIL;
@@ -1693,8 +1693,11 @@ bm_subcommit(logger *lg, uint32_t *updat
}
bat col = bids[p];
 
-   if (lids && lids[p] != lng_nil && lids[p] <= lg->saved_tid)
+   if (lids && lids[p] != lng_nil && lids[p] <= lg->saved_tid) {
cleanup++;
+   if (lids[p] == -1)
+   continue;
+   }
TRC_DEBUG(WAL, "new %s (%d)\n", BBP_logical(col), col);
assert(col);
sizes[i] = cnts ? (BUN) cnts[p] : 0;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Fix output order.

2023-10-26 Thread Sjoerd Mullender via checkin-list
Changeset: 4d04f17f2f30 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4d04f17f2f30
Modified Files:
sql/test/emptydb/Tests/check.stable.out
Branch: default
Log Message:

Fix output order.


diffs (43 lines):

diff --git a/sql/test/emptydb/Tests/check.stable.out 
b/sql/test/emptydb/Tests/check.stable.out
--- a/sql/test/emptydb/Tests/check.stable.out
+++ b/sql/test/emptydb/Tests/check.stable.out
@@ -1885,9 +1885,6 @@ select 'null in fkeys.delete_action', de
 [ "sys.functions", "sys",  "insert",   "SYSTEM",   "insert",   
"str",  "Internal C",   "Scalar function",  false,  false,  false,  false,  
NULL,   "res_0","char", 0,  0,  "out",  "arg_1","char", 
0,  0,  "in",   "arg_2","int",  32, 0,  "in",   
"arg_3","int",  32, 0,  "in",   "arg_4","char", 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",  "insert",   "SYSTEM",   "insert",   
"str",  "Internal C",   "Scalar function",  false,  false,  false,  false,  
NULL,   "res_0","clob", 0,  0,  "out",  "arg_1","clob", 
0,  0,  "in",   "arg_2","int",  32, 0,  "in",   
"arg_3","int",  32, 0,  "in",   "arg_4","clob", 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",  "insert",   "SYSTEM",   "insert",   
"str",  "Internal C",   "Scalar function",  false,  false,  false,  false,  
NULL,   "res_0","varchar",  0,  0,  "out",  "arg_1",
"varchar",  0,  0,  "in",   "arg_2","int",  32, 0,  
"in",   "arg_3","int",  32, 0,  "in",   "arg_4",
"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",  "persist_unlogged", "SYSTEM",   "create 
function sys.persist_unlogged() returns table(\"table\" string, \"table_id\" 
int, \"rowcount\" bigint) external name sql.persist_unlogged;","sql",  
"MAL",  "Function returning a table",   true,   false,  false,  true,   NULL,   
"table","clob", 0,  0,  "out",  "table_id", "int",  32, 
0,  "out",  "rowcount", "bigint",   64, 0,  "out",  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",  "persist_unlogged", "SYSTEM",   "create 
function sys.persist_unlogged(sname string) returns table(\"table\" string, 
\"table_id\" int, \"rowcount\" bigint) external name sql.persist_unlogged;",
"sql",  "MAL",  "Function returning a table",   true,   false,  false,  
true,   NULL,   "table","clob", 0,  0,  "out",  "table_id", 
"int",  32, 0,  "out",  "rowcount", "bigint",   64, 0,  
"out",  "sname","clob", 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,   

MonetDB: default - Complete granting of persist_unlogged during ...

2023-10-26 Thread Sjoerd Mullender via checkin-list
Changeset: fdd9e222643b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fdd9e222643b
Modified Files:
sql/backends/monet5/sql_upgrades.c

sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128

sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Complete granting of persist_unlogged during upgrade.


diffs (truncated from 312 to 300 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -6315,6 +6315,8 @@ sql_update_default(Client c, mvc *sql, s
"RETURNS TABLE(\"table\" STRING, \"table_id\" INT, 
\"rowcount\" BIGINT)\n"
"EXTERNAL NAME sql.persist_unlogged;\n"
"GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO 
PUBLIC;\n"
+   "GRANT EXECUTE ON FUNCTION sys.persist_unlogged(string) 
TO PUBLIC;\n"
+   "GRANT EXECUTE ON FUNCTION sys.persist_unlogged(string, 
string) TO PUBLIC;\n"
"UPDATE sys.functions SET system = true WHERE system <> 
true AND\n"
"name = 'persist_unlogged' AND schema_id = 2000;\n";
printf("Running database upgrade commands:\n%s\n", query);
diff --git 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -753,6 +753,8 @@ CREATE FUNCTION sys.persist_unlogged(sna
 RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT)
 EXTERNAL NAME sql.persist_unlogged;
 GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC;
+GRANT EXECUTE ON FUNCTION sys.persist_unlogged(string) TO PUBLIC;
+GRANT EXECUTE ON FUNCTION sys.persist_unlogged(string, string) TO PUBLIC;
 UPDATE sys.functions SET system = true WHERE system <> true AND
 name = 'persist_unlogged' AND schema_id = 2000;
 
diff --git a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
@@ -753,6 +753,8 @@ CREATE FUNCTION sys.persist_unlogged(sna
 RETURNS TABLE("table" STRING, "table_id" INT, "rowcount" BIGINT)
 EXTERNAL NAME sql.persist_unlogged;
 GRANT EXECUTE ON FUNCTION sys.persist_unlogged() TO PUBLIC;
+GRANT EXECUTE ON FUNCTION sys.persist_unlogged(string) TO PUBLIC;
+GRANT EXECUTE ON FUNCTION sys.persist_unlogged(string, string) TO PUBLIC;
 UPDATE sys.functions SET system = true WHERE system <> true AND
 name = 'persist_unlogged' AND schema_id = 2000;
 
diff --git 
a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
@@ -822,6 +822,8 @@ CREATE FUNCTION sys.persist_unlogged(sna
 RETURNS TABLE("table" STRING, "table_id" 

MonetDB: monetdburl - Merge with default branch.

2023-10-26 Thread Sjoerd Mullender via checkin-list
Changeset: e5a27cc67839 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e5a27cc67839
Branch: monetdburl
Log Message:

Merge with default branch.


diffs (truncated from 3758 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -54,7 +54,7 @@
 # derivatives (CentOS, Scientific Linux), the geos library is not
 # available.  However, the geos library is available in the Extra
 # Packages for Enterprise Linux (EPEL).
-%if %{fedpkgs}
+%if %{fedpkgs} && (0%{?rhel} != 7) && (0%{?rhel} != 8)
 # By default create the MonetDB-geom-MonetDB5 package on Fedora and RHEL 7
 %bcond_without geos
 %endif
@@ -534,6 +534,7 @@ exit 0
 %if %{with cintegration}
 %{_libdir}/monetdb5/lib_capi.so
 %endif
+%{_libdir}/monetdb5/lib_csv.so
 %{_libdir}/monetdb5/lib_generator.so
 %doc %{_mandir}/man1/mserver5.1.gz
 %dir %{_datadir}/doc/MonetDB
diff --git a/debian/monetdb5-server.install b/debian/monetdb5-server.install
--- a/debian/monetdb5-server.install
+++ b/debian/monetdb5-server.install
@@ -4,4 +4,5 @@ debian/tmp/usr/lib/x86_64-linux-gnu/libm
 
 # usr/lib/x86_64-linux-gnu/monetdb5/lib_*.so EXCEPT: 
lib_{fits,geom,gsl,microbenchmark,opt_sql_append,pyapi*,rapi,sql,udf}.so
 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/lib_capi.so 
usr/lib/x86_64-linux-gnu/monetdb5
+debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/lib_csv.so 
usr/lib/x86_64-linux-gnu/monetdb5
 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/lib_generator.so 
usr/lib/x86_64-linux-gnu/monetdb5
diff --git a/monetdb5/ChangeLog b/monetdb5/ChangeLog
--- a/monetdb5/ChangeLog
+++ b/monetdb5/ChangeLog
@@ -1,6 +1,13 @@
 # ChangeLog file for MonetDB5
 # This file is updated with Maddlog
 
+* Fri Oct 20 2023 Panagiotis Koutsourakis 
+- Change how json is stored in the database: We now normalize json
+  strings after parsing, removing whitespace and eliminating duplicate
+  keys in objects.
+- The function json.filter now properly returns json scalars instead of
+  wrapping them in an array.
+
 * Wed Sep 13 2023 Sjoerd Mullender 
 - Removed the MAL tokenizer module.  It was never usable from SQL and
   in this form never would be.
diff --git a/monetdb5/ChangeLog.json-storage b/monetdb5/ChangeLog.json-storage
deleted file mode 100644
--- a/monetdb5/ChangeLog.json-storage
+++ /dev/null
@@ -1,10 +0,0 @@
-# ChangeLog file for monetdb5
-# This file is updated with Maddlog
-
-* Fri Oct 20 2023 Panagiotis Koutsourakis 
-- Change how json is stored in the database: We now normalize json
-  strings after parsing, removing whitespace and eliminating duplicate
-  keys in objects.
-- The function json.filter now properly returns json scalars instead of
-  wrapping them in an array.
-
diff --git a/monetdb5/modules/atoms/Tests/All b/monetdb5/modules/atoms/Tests/All
--- a/monetdb5/modules/atoms/Tests/All
+++ b/monetdb5/modules/atoms/Tests/All
@@ -38,3 +38,5 @@ startswith
 endswith
 contains
 HAVE_ICONV?asciify
+
+ts_and_tstz_to_str_bug
diff --git a/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test 
b/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/atoms/Tests/ts_and_tstz_to_str_bug.test
@@ -0,0 +1,16 @@
+statement ok
+CREATE TABLE t2 (dt TIMESTAMP)
+
+statement ok
+INSERT INTO t2 (dt) VALUES('2023-10-11 11:36')
+
+query I
+SELECT
+levenshtein(sys.timestamp_to_str(cast(dt as timestamp with time zone), 
'%Y-%d-%d %H:%M:%S'),
+sys.timestamp_to_str(dt, '%Y-%d-%d %H:%M:%S'))
+FROM t2
+
+0
+
+statement ok
+DROP TABLE t2
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
@@ -282,7 +282,6 @@ extern str SQLflush_log(Client cntxt, Ma
 extern str SQLsuspend_log_flushing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str SQLresume_log_flushing(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str SQLhot_snapshot(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-extern str SQLhot_snapshot_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 extern str SQLpersist_unlogged(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
 
 extern str SQLsession_prepared_statements(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -5179,6 +5179,7 @@ sql_update_jun2023(Client c, mvc *sql, s
char *err = NULL, *buf = GDKmalloc(bufsize);
res_table *output;
BAT *b;
+   sql_subtype t1, t2;
 
(void) sql;
if (buf == NULL)
@@ -5546,7 +5547,6 @@ sql_update_jun2023(Client c, mvc *sql, s
/* Add new sysadmin procedure calls: stop, pause and resume with two
   arguments, first arg is query OID and second the user username that
   the query in bound to. */
-   sql_subtype t1, t2;
sql_find_subtype(, 

MonetDB: monetdburl - Update RPM and DEB configs.

2023-10-26 Thread Sjoerd Mullender via checkin-list
Changeset: 76327c6d427a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/76327c6d427a
Modified Files:
MonetDB.spec
debian/control
debian/monetdb-client-testing.install
Branch: monetdburl
Log Message:

Update RPM and DEB configs.


diffs (53 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -123,6 +123,10 @@ BuildRequires: geos-devel >= 3.10.0
 BuildRequires: pkgconfig(libcurl)
 BuildRequires: pkgconfig(liblzma)
 BuildRequires: pkgconfig(libxml-2.0)
+%if 0%{?rhel} != 7
+BuildRequires: pkgconfig(openssl) >= 1.1.1
+%global with_openssl 1
+%endif
 %if %{with pcre}
 BuildRequires: pkgconfig(libpcre) >= 4.5
 %endif
@@ -369,6 +373,7 @@ developer.
 %{_bindir}/ODBCtester
 %{_bindir}/arraytest
 %{_bindir}/bincopydata
+%{_bindir}/murltest
 %{_bindir}/odbcsample1
 %{_bindir}/sample0
 %{_bindir}/sample1
@@ -805,6 +810,7 @@ fi
 -DWITH_CURL=ON \
 -DWITH_LZ4=ON \
 -DWITH_LZMA=ON \
+-DWITH_OPENSSL=%{?with_openssl:ON}%{!?with_openssl:OFF} \
 -DWITH_PCRE=ON \
 -DWITH_PROJ=OFF \
 -DWITH_READLINE=ON \
diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,7 @@ Build-Depends: debhelper (>= 12), cmake 
  libxml2-dev, pkg-config,
  python3, python3-dev, python3-numpy,
  unixodbc-dev, zlib1g-dev, r-base-dev,
- libcfitsio-dev
+ libcfitsio-dev, openssl-dev (>= 1.1.1)
 Standards-Version: 3.8.0
 X-Python-Version: >= 2.6
 
diff --git a/debian/monetdb-client-testing.install 
b/debian/monetdb-client-testing.install
--- a/debian/monetdb-client-testing.install
+++ b/debian/monetdb-client-testing.install
@@ -4,6 +4,7 @@ debian/tmp/usr/bin/ODBCmetadata usr/bin
 debian/tmp/usr/bin/ODBCtester usr/bin
 debian/tmp/usr/bin/arraytest usr/bin
 debian/tmp/usr/bin/bincopydata usr/bin
+debian/tmp/usr/bin/murltest usr/bin
 debian/tmp/usr/bin/odbcsample1 usr/bin
 debian/tmp/usr/bin/sample0 usr/bin
 debian/tmp/usr/bin/sample1 usr/bin
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Install lib_csv.so.

2023-10-26 Thread Sjoerd Mullender via checkin-list
Changeset: a683fe70b809 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a683fe70b809
Modified Files:
MonetDB.spec
debian/monetdb5-server.install
Branch: default
Log Message:

Install lib_csv.so.


diffs (20 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -534,6 +534,7 @@ exit 0
 %if %{with cintegration}
 %{_libdir}/monetdb5/lib_capi.so
 %endif
+%{_libdir}/monetdb5/lib_csv.so
 %{_libdir}/monetdb5/lib_generator.so
 %doc %{_mandir}/man1/mserver5.1.gz
 %dir %{_datadir}/doc/MonetDB
diff --git a/debian/monetdb5-server.install b/debian/monetdb5-server.install
--- a/debian/monetdb5-server.install
+++ b/debian/monetdb5-server.install
@@ -4,4 +4,5 @@ debian/tmp/usr/lib/x86_64-linux-gnu/libm
 
 # usr/lib/x86_64-linux-gnu/monetdb5/lib_*.so EXCEPT: 
lib_{fits,geom,gsl,microbenchmark,opt_sql_append,pyapi*,rapi,sql,udf}.so
 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/lib_capi.so 
usr/lib/x86_64-linux-gnu/monetdb5
+debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/lib_csv.so 
usr/lib/x86_64-linux-gnu/monetdb5
 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/lib_generator.so 
usr/lib/x86_64-linux-gnu/monetdb5
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - No new enough geos library on CentOS 7 and 8.

2023-10-26 Thread Sjoerd Mullender via checkin-list
Changeset: 1a4c065e87b3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1a4c065e87b3
Modified Files:
MonetDB.spec
Branch: default
Log Message:

No new enough geos library on CentOS 7 and 8.


diffs (12 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -54,7 +54,7 @@
 # derivatives (CentOS, Scientific Linux), the geos library is not
 # available.  However, the geos library is available in the Extra
 # Packages for Enterprise Linux (EPEL).
-%if %{fedpkgs}
+%if %{fedpkgs} && (0%{?rhel} != 7) && (0%{?rhel} != 8)
 # By default create the MonetDB-geom-MonetDB5 package on Fedora and RHEL 7
 %bcond_without geos
 %endif
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jun2023 - Close file explicitly so that it gets flushed.

2023-10-26 Thread Sjoerd Mullender via checkin-list
Changeset: 3e39482edab1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3e39482edab1
Modified Files:
common/stream/Tests/read_tests.py
common/stream/Tests/testdata.py
Branch: Jun2023
Log Message:

Close file explicitly so that it gets flushed.


diffs (19 lines):

diff --git a/common/stream/Tests/read_tests.py 
b/common/stream/Tests/read_tests.py
--- a/common/stream/Tests/read_tests.py
+++ b/common/stream/Tests/read_tests.py
@@ -148,4 +148,3 @@ if __name__ == "__main__":
 else:
 print("Usage: python3 read_tests.py [TESTDATANAME]", file=sys.stderr)
 sys.exit(1)
-
diff --git a/common/stream/Tests/testdata.py b/common/stream/Tests/testdata.py
--- a/common/stream/Tests/testdata.py
+++ b/common/stream/Tests/testdata.py
@@ -216,6 +216,7 @@ class TestFile:
 else:
 raise Exception("Unknown compression scheme: " + self.compression)
 f.write(content)
+f.close()
 return filename
 
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: new_rmt_opt - Closing branch new_rmt_opt.

2023-11-06 Thread Sjoerd Mullender via checkin-list
Changeset: d597a7918f40 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d597a7918f40
Branch: new_rmt_opt
Log Message:

Closing branch new_rmt_opt.

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Merge new_rmt_opt into default.

2023-11-06 Thread Sjoerd Mullender via checkin-list
Changeset: b22b663c3f2d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b22b663c3f2d
Modified Files:
sql/backends/monet5/sql_gencode.c
Branch: default
Log Message:

Merge new_rmt_opt into default.


diffs (truncated from 484 to 300 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -354,7 +354,8 @@ static int
Client c = MCgetClient(m->clientid);
MalBlkPtr curBlk = 0;
InstrPtr curInstr = 0, p, o;
-   sqlid table_id = prp->id;
+   tid_uri *tu = ((list*)prp->value.pval)->h->data;
+   sqlid table_id = tu->id;
node *n;
int i, q, v, res = -1, added_to_cache = 0, *lret, *rret;
size_t len = 1024, nr, pwlen = 0;
@@ -389,6 +390,7 @@ static int
 
sql_table *rt = sql_trans_find_table(m->session->tr, table_id);
const char *uri = mapiuri_uri(rt->query, m->sa);
+   assert(strcmp(tu->uri, uri) == 0);
if (!rt) {
sql_error(m, 10, SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto cleanup;
@@ -928,8 +930,12 @@ static int
Symbol symbackup = c->curprg;
exception_buffer ebsave = m->sa->eb;
 
-   if (prp->id == 0) {
-   sql_error(m, 003, SQLSTATE(42000) "Missing property on the 
input relation");
+   if (list_empty(prp->value.pval)) {
+   sql_error(m, 003, SQLSTATE(42000) "Missing REMOTE property on 
the input relation");
+   goto bailout;
+   }
+   if (list_length(prp->value.pval) != 1) {
+   sql_error(m, 003, SQLSTATE(42000) "REMOTE property on the input 
relation is NOT unique");
goto bailout;
}
if (strlen(mod) >= IDLENGTH) {
diff --git a/sql/server/rel_distribute.c b/sql/server/rel_distribute.c
--- a/sql/server/rel_distribute.c
+++ b/sql/server/rel_distribute.c
@@ -15,6 +15,12 @@
 #include "rel_remote.h"
 #include "sql_privileges.h"
 
+typedef struct rmt_prop_state {
+   int depth;
+   prop* rmt;
+   sql_rel* orig;
+} rps;
+
 static int
 has_remote_or_replica( sql_rel *rel )
 {
@@ -66,7 +72,7 @@ has_remote_or_replica( sql_rel *rel )
 }
 
 static sql_rel *
-rewrite_replica(mvc *sql, list *exps, sql_table *t, sql_table *p, int 
remote_prop)
+do_replica_rewrite(mvc *sql, list *exps, sql_table *t, sql_table *p, int 
remote_prop)
 {
node *n, *m;
sql_rel *r = rel_basetable(sql, p, t->base.name);
@@ -96,11 +102,15 @@ rewrite_replica(mvc *sql, list *exps, sq
 
/* set_remote() */
if (remote_prop && p && isRemote(p)) {
-   sqlid id = p->base.id;
-   char *local_name = sa_strconcat(sql->sa, sa_strconcat(sql->sa, 
p->s->base.name, "."), p->base.name);
-   prop *p = r->p = prop_create(sql->sa, PROP_REMOTE, r->p);
-   p->id = id;
-   p->value.pval = local_name;
+   list *uris = sa_list(sql->sa);
+   tid_uri *tu = SA_NEW(sql->sa, tid_uri);
+   tu->id = p->base.id;
+   tu->uri = sa_strconcat(sql->sa, sa_strconcat(sql->sa, 
p->s->base.name, "."), p->base.name);
+   append(uris, tu);
+
+   prop *rmt_prop = r->p = prop_create(sql->sa, PROP_REMOTE, r->p);
+   rmt_prop->id = p->base.id;
+   rmt_prop->value.pval = uris;
}
return r;
 }
@@ -109,24 +119,33 @@ static sql_rel *
 replica_rewrite(visitor *v, sql_table *t, list *exps)
 {
sql_rel *res = NULL;
-   const char *uri = (const char *) v->data;
+   prop *rp = ((rps*)v->data)->rmt;
+   sqlid tid = rp->id;
+   list *uris = rp->value.pval;
 
if (mvc_highwater(v->sql))
return sql_error(v->sql, 10, SQLSTATE(42000) "Query too 
complex: running out of stack space");
 
-   if (uri) {
-   /* replace by the replica which matches the uri */
-   for (node *n = t->members->h; n; n = n->next) {
+   /* if there was a REMOTE property in any higher node and there is not
+* a local tid then use the available uris to rewrite */
+   if (uris && !tid) {
+   for (node *n = t->members->h; n && !res; n = n->next) {
sql_part *p = n->data;
sql_table *pt = find_sql_table_id(v->sql->session->tr, 
t->s, p->member);
 
-   if (isRemote(pt) && strcmp(uri, pt->query) == 0) {
-   res = rewrite_replica(v->sql, exps, t, pt, 0);
-   break;
+   if (!isRemote(pt))
+   continue;
+
+   for (node *m = uris->h; m && !res; m = m->next) {
+   if (strcmp(((tid_uri*)m->data)->uri, pt->query) 
== 0) {
+   res = do_replica_rewrite(v->sql, exps, 
t, pt, 0);
+   }
}
 

MonetDB: Jun2023 - Check snprintf result so that we don't need d...

2023-11-06 Thread Sjoerd Mullender via checkin-list
Changeset: 28af495bf842 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/28af495bf842
Modified Files:
tools/merovingian/client/monetdb.c
Branch: Jun2023
Log Message:

Check snprintf result so that we don't need dirty tricks to compile.


diffs (31 lines):

diff --git a/tools/merovingian/client/monetdb.c 
b/tools/merovingian/client/monetdb.c
--- a/tools/merovingian/client/monetdb.c
+++ b/tools/merovingian/client/monetdb.c
@@ -2509,8 +2509,11 @@ main(int argc, char *argv[])
if (mero_host == NULL)
mero_host = "/tmp";
/* first try the port given (or else its default) */
-   snprintf(buf, sizeof(buf), "%s/.s.merovingian.%d",
-mero_host, mero_port == -1 ? MAPI_PORT : mero_port);
+   if (snprintf(buf, sizeof(buf), "%s/.s.merovingian.%d",
+mero_host, mero_port == -1 ? MAPI_PORT 
: mero_port) >= (int) sizeof(buf)) {
+   fprintf(stderr, "monetdb: directory name too long\n");
+   exit(1);
+   }
if ((err = control_ping(buf, -1, NULL)) == NULL) {
mero_host = buf;
} else {
@@ -2530,9 +2533,11 @@ main(int argc, char *argv[])
while ((e = readdir(d)) != NULL) {
if (strncmp(e->d_name, 
".s.merovingian.", 15) != 0)
continue;
-   snprintf(buf, sizeof(buf), "%s/%s", 
mero_host, e->d_name);
-   if (stat(buf, ) == -1)
+   if (snprintf(buf, sizeof(buf), "%s/%s", 
mero_host, e->d_name) >= (int) sizeof(buf) ||
+   stat(buf, ) == -1) {
+   /* too long or doesn't exist */
continue;
+   }
if (S_ISSOCK(s.st_mode)) {
char *nerr;
if ((nerr = control_ping(buf, 
-1, NULL)) == NULL) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


  1   2   3   4   5   6   7   8   9   10   >