MonetDB: default - Clean up some library mess.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: 548ab7923877 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/548ab7923877
Modified Files:
clients/odbc/driver/CMakeLists.txt
common/utils/CMakeLists.txt
common/utils/mcrypt.h
common/utils/muuid.h
ctest/monetdb5/mal/CMakeLists.txt
geom/lib/CMakeLists.txt
geom/monetdb5/CMakeLists.txt
monetdb5/extras/mal_optimizer_template/CMakeLists.txt
monetdb5/extras/rapi/CMakeLists.txt
monetdb5/mal/CMakeLists.txt
monetdb5/modules/atoms/CMakeLists.txt
monetdb5/modules/kernel/CMakeLists.txt
monetdb5/modules/mal/CMakeLists.txt
monetdb5/tools/CMakeLists.txt
sql/backends/monet5/CMakeLists.txt
sql/backends/monet5/UDF/capi/CMakeLists.txt
sql/backends/monet5/UDF/pyapi3/CMakeLists.txt
sql/backends/monet5/UDF/pyapi3/pyheader.h
sql/backends/monet5/UDF/udf/CMakeLists.txt
sql/backends/monet5/vaults/fits/CMakeLists.txt
sql/backends/monet5/vaults/netcdf/CMakeLists.txt
sql/backends/monet5/vaults/shp/CMakeLists.txt
sql/server/CMakeLists.txt
sql/storage/CMakeLists.txt
sql/storage/bat/CMakeLists.txt
tools/merovingian/daemon/CMakeLists.txt
tools/monetdbe/CMakeLists.txt
tools/mserver/CMakeLists.txt
Branch: default
Log Message:

Clean up some library mess.
mutils is part of GDK and MAPI, so don't include it separately if either
one is included already.
mcrypt is part of MAPI, so don't include it separately if MAPI is
included already.


diffs (truncated from 370 to 300 lines):

diff --git a/clients/odbc/driver/CMakeLists.txt 
b/clients/odbc/driver/CMakeLists.txt
--- a/clients/odbc/driver/CMakeLists.txt
+++ b/clients/odbc/driver/CMakeLists.txt
@@ -127,7 +127,6 @@ target_include_directories(MonetODBC
 target_link_libraries(MonetODBC
   PRIVATE
   monetdb_config_header
-  mutils
   mapi
   mutf8
   ${ODBCINST_LIBRARIES})
diff --git a/common/utils/CMakeLists.txt b/common/utils/CMakeLists.txt
--- a/common/utils/CMakeLists.txt
+++ b/common/utils/CMakeLists.txt
@@ -32,10 +32,7 @@ target_link_libraries(mutils
   mutf8)
 
 target_compile_definitions(mutils PRIVATE
-  LIBMUTILS
-  LIBGDK
-  LIBMAPI
-  LIBMEROUTIL)
+  LIBMUTILS)
 
 set_target_properties(mutils
   PROPERTIES
@@ -74,8 +71,6 @@ target_link_libraries(mcrypt
 
 target_compile_definitions(mcrypt
   PRIVATE
-  LIBMONETDB5
-  LIBMAPI
   LIBMCRYPT)
 
 set_target_properties(mcrypt
@@ -108,8 +103,7 @@ target_link_libraries(msabaoth
 
 target_compile_definitions(msabaoth
   PRIVATE
-  LIBMSABAOTH
-  LIBMONETDB5)
+  LIBMSABAOTH)
 
 set_target_properties(msabaoth
   PROPERTIES
diff --git a/common/utils/mcrypt.h b/common/utils/mcrypt.h
--- a/common/utils/mcrypt.h
+++ b/common/utils/mcrypt.h
@@ -14,7 +14,7 @@
 #define _SEEN_MCRYPT_H 1
 
 #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__)
-#if !defined(LIBMAPI) && !defined(LIBMCRYPT) && !defined(LIBMONETDB5)
+#if !defined(LIBMAPI) && !defined(LIBMCRYPT)
 #define mcrypt_export extern __declspec(dllimport)
 #else
 #define mcrypt_export extern __declspec(dllexport)
diff --git a/common/utils/muuid.h b/common/utils/muuid.h
--- a/common/utils/muuid.h
+++ b/common/utils/muuid.h
@@ -17,13 +17,14 @@
  * msabaoth is part of monetdb5 and we want this function to be
  * exported so that the call in sql can be satisfied by the version
  * that is included in monetdb5 */
-extern
 #ifdef WIN32
-#if !defined(LIBMSABAOTH) && !defined(LIBMUUID)
+#if !defined(LIBMONETDB5) && !defined(LIBMSABAOTH)
 __declspec(dllimport)
 #else
 __declspec(dllexport)
 #endif
+#else
+extern
 #endif
 char *generateUUID(void);
 
diff --git a/ctest/monetdb5/mal/CMakeLists.txt 
b/ctest/monetdb5/mal/CMakeLists.txt
--- a/ctest/monetdb5/mal/CMakeLists.txt
+++ b/ctest/monetdb5/mal/CMakeLists.txt
@@ -17,7 +17,6 @@ target_link_libraries(test_malEmbeddedBo
   mal
   mcrypt
   msabaoth
-  mutils
   stream
   bat
   ${CMAKE_DL_LIBS}
@@ -32,7 +31,6 @@ target_link_libraries(test_malInclude
   mal
   mcrypt
   msabaoth
-  mutils
   stream
   bat
   ${CMAKE_DL_LIBS}
diff --git a/geom/lib/CMakeLists.txt b/geom/lib/CMakeLists.txt
--- a/geom/lib/CMakeLists.txt
+++ b/geom/lib/CMakeLists.txt
@@ -28,7 +28,6 @@ if(GEOS_FOUND)
 
   target_link_libraries(geomlib
 PRIVATE
-mutils
 stream
 bat
 monetdb_config_header
diff --git a/geom/monetdb5/CMakeLists.txt b/geom/monetdb5/CMakeLists.txt
--- a/geom/monetdb5/CMakeLists.txt
+++ b/geom/monetdb5/CMakeLists.txt
@@ -50,7 +50,6 @@ if(GEOS_FOUND)
 
   target_link_libraries(geomodule
 PRIVATE
-mutils
 stream
 bat
 geomlib
diff --git a/monetdb5/extras/mal_optimizer_template/CMakeLists.txt 
b/monetdb5/extras/mal_optimizer_template/CMakeLists.txt
--- a/monetdb5/extras/mal_optimizer_template/CMakeLists.txt
+++ b/monetdb5/extras/mal_optimizer_template/CMakeLists.txt
@@ -26,7 +26,6 @@ target_include_directories(opt_sql_appen
 target_link_libraries(opt_sql_append
   PRIVATE
   

MonetDB: default - More efficient implementation of text_pump_in()

2024-05-31 Thread Joeri van Ruth via checkin-list
Changeset: 064ab92cd39d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/064ab92cd39d
Modified Files:
common/stream/text_stream.c
Branch: default
Log Message:

More efficient implementation of text_pump_in()


diffs (105 lines):

diff --git a/common/stream/text_stream.c b/common/stream/text_stream.c
--- a/common/stream/text_stream.c
+++ b/common/stream/text_stream.c
@@ -89,42 +89,69 @@ take_byte(inner_state_t *ist)
 static pump_result
 text_pump_in(inner_state_t *ist, pump_action action)
 {
-   bool crlf_pending = ist->crlf_pending;
+   assert(ist->dst_win.count > 0);
+   assert(ist->src_win.count > 0 || action == PUMP_FINISH);
 
-   while (ist->src_win.count > 0 && ist->dst_win.count > 0) {
-   char c = take_byte(ist);
-   switch (c) {
-   case '\r':
-   if (crlf_pending) {
-   // put the previous one, which is 
clearly not followed by an \n
-   put_byte(ist, '\r');
-   }
-   crlf_pending = true;
-   continue;
-   case '\n':
-   put_byte(ist, c);
-   crlf_pending = false;
-   continue;
-   default:
-   if (crlf_pending) {
-   put_byte(ist, '\r');
-   crlf_pending = false;
-   // if dst_win.count was 1, there is no 
room for another put_byte().
-   if (ist->dst_win.count > 0) {
-   put_byte(ist, c);
-   } else {
-   // no room anymore for char c, 
put it back!
-   ist->src_win.start--;
-   ist->src_win.count++;
-   }
-   } else {
-   put_byte(ist, c);
-   }
-   continue;
+   if (ist->crlf_pending) {
+   if (ist->src_win.count > 0) {
+   if (ist->src_win.start[0] != '\n') {
+   // CR not followed by a LF, emit it
+   put_byte(ist, '\r');
+   }
+   } else {
+   assert(action == PUMP_FINISH);
+   // CR followed by end of file, not LF, so emit it
+   put_byte(ist, '\r');
}
+   // in any case, the CR is no longer pending
+   ist->crlf_pending = false;
}
 
-   ist->crlf_pending = crlf_pending;
+   while (1) {
+   size_t span = ist->src_win.count < ist->dst_win.count
+   ? ist->src_win.count
+   : ist->dst_win.count;
+   if (span == 0)
+   break;
+
+   if (ist->src_win.start[0] == '\r') {
+   // Looking at a CR. We'll handle just that, then make 
another round of the while loop
+   if (ist->src_win.count == 1) {
+   // Don't know what will follow, move it to the 
flag.
+   // Then stop, as all available input has been 
consumed
+   take_byte(ist);
+   ist->crlf_pending = true;
+   break;
+   }
+   assert(ist->src_win.count > 1); // We can safely look 
ahead
+   if (ist->src_win.start[1] == '\n') {
+   // Drop the CR, move the LF
+   take_byte(ist);
+   put_byte(ist, take_byte(ist));
+   } else {
+   // Move the CR
+   put_byte(ist, take_byte(ist));
+   }
+   // progress has been made, consider the situation anew
+   continue;
+   } else {
+   // The remaining input data does not start with a CR.
+   // Move all non-CR data to the output buffer
+   char *cr = memchr(ist->src_win.start, '\r', span);
+   if (cr != NULL) {
+   span = cr - ist->src_win.start;
+   }
+   assert(span > 0);
+   memcpy(ist->dst_win.start, ist->src_win.start, span);
+   ist->src_win.start += span;
+   

MonetDB: default - Use of text_pump_in_with_putback is supposed ...

2024-05-31 Thread Joeri van Ruth via checkin-list
Changeset: 9ff9f083b319 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9ff9f083b319
Modified Files:
common/stream/text_stream.c
Branch: default
Log Message:

Use of text_pump_in_with_putback is supposed to be temporary


diffs (49 lines):

diff --git a/common/stream/text_stream.c b/common/stream/text_stream.c
--- a/common/stream/text_stream.c
+++ b/common/stream/text_stream.c
@@ -30,6 +30,7 @@ struct inner_state {
pump_buffer src_win;
pump_buffer dst_win;
pump_buffer putback_win;
+   pump_state *outer_state;
char putback_buf[UTF8BOMLENGTH];
bool crlf_pending;
char buffer[BUFFER_SIZE];
@@ -150,16 +151,20 @@ text_pump_in(inner_state_t *ist, pump_ac
 static pump_result
 text_pump_in_with_putback(inner_state_t *ist, pump_action action)
 {
-   if (ist->putback_win.count > 0) {
-   pump_buffer tmp = ist->src_win;
-   ist->src_win = ist->putback_win;
-   pump_result ret = text_pump_in(ist, PUMP_NO_FLUSH);
-   ist->putback_win = ist->src_win;
-   ist->src_win = tmp;
-   if (ret == PUMP_ERROR)
-   return PUMP_ERROR;
+   if (ist->putback_win.count == 0) {
+   // no need for this function anymore
+   assert(ist->outer_state->worker == text_pump_in_with_putback);
+   ist->outer_state->worker = text_pump_in;
+   return text_pump_in(ist, action);
}
-   return text_pump_in(ist, action);
+
+   // first empty the putback buffer
+   pump_buffer tmp = ist->src_win;
+   ist->src_win = ist->putback_win;
+   pump_result ret = text_pump_in(ist, PUMP_NO_FLUSH);
+   ist->putback_win = ist->src_win;
+   ist->src_win = tmp;
+   return ret;
 }
 
 
@@ -295,6 +300,7 @@ create_text_stream(stream *inner)
state->finalizer = text_end;
state->get_error = get_error;
 
+   inner_state->outer_state = state;
inner_state->putback_win.start = inner_state->putback_buf;
inner_state->putback_win.count = 0;
if (inner->readonly) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - The ODBC driver does not use __declspec, it u...

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: 7763c63b4b93 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7763c63b4b93
Modified Files:
clients/odbc/driver/CMakeLists.txt
clients/odbc/driver/ODBCGlobal.h
clients/odbc/setup/drvcfg.h
clients/odbc/winsetup/setup.c
Branch: default
Log Message:

The ODBC driver does not use __declspec, it uses a .def file instead.


diffs (77 lines):

diff --git a/clients/odbc/driver/CMakeLists.txt 
b/clients/odbc/driver/CMakeLists.txt
--- a/clients/odbc/driver/CMakeLists.txt
+++ b/clients/odbc/driver/CMakeLists.txt
@@ -124,10 +124,6 @@ target_include_directories(MonetODBC
   $
   $)
 
-target_compile_definitions(MonetODBC
-  PRIVATE
-  LIBMONETODBCS)
-
 target_link_libraries(MonetODBC
   PRIVATE
   monetdb_config_header
diff --git a/clients/odbc/driver/ODBCGlobal.h b/clients/odbc/driver/ODBCGlobal.h
--- a/clients/odbc/driver/ODBCGlobal.h
+++ b/clients/odbc/driver/ODBCGlobal.h
@@ -49,16 +49,6 @@
 
 #define ODBCDEBUG  1
 
-#ifdef WIN32
-#ifndef LIBMONETODBC
-#define odbc_export extern __declspec(dllimport)
-#else
-#define odbc_export extern __declspec(dllexport)
-#endif
-#else
-#define odbc_export extern
-#endif
-
 /* standard ODBC driver include files */
 #include   /* ODBC C typedefs */
 /* Note: sqlext.h includes sql.h so it is not needed here to be included */
diff --git a/clients/odbc/setup/drvcfg.h b/clients/odbc/setup/drvcfg.h
--- a/clients/odbc/setup/drvcfg.h
+++ b/clients/odbc/setup/drvcfg.h
@@ -32,16 +32,6 @@
 
 #define ODBCVER 0x0351
 
-#ifdef WIN32
-#ifndef LIBMONETODBCS
-#define odbc_export extern __declspec(dllimport)
-#else
-#define odbc_export extern __declspec(dllexport)
-#endif
-#else
-#define odbc_export extern
-#endif
-
 #include 
 
 /
@@ -148,7 +138,7 @@ extern "C" {
 #endif
 
 /* ONLY IMPLEMENTED IN DRIVER SETUP (not in ODBCINST) */
-   odbc_export int ODBCINSTGetProperties(HODBCINSTPROPERTY hFirstProperty);
+   extern int ODBCINSTGetProperties(HODBCINSTPROPERTY hFirstProperty);
 
 #if defined(__cplusplus)
 }
diff --git a/clients/odbc/winsetup/setup.c b/clients/odbc/winsetup/setup.c
--- a/clients/odbc/winsetup/setup.c
+++ b/clients/odbc/winsetup/setup.c
@@ -22,10 +22,6 @@
 #define ALREADY_HAVE_WINDOWS_TYPE 1
 #include 
 #include 
-#ifdef EXPORT
-#undef EXPORT
-#endif
-#define EXPORT __declspec(dllexport)
 #include 
 #include "resource.h"
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Use buffer instead of strdup.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: e811acf9ead8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e811acf9ead8
Modified Files:
common/utils/mutils.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/merovingian.h
Branch: default
Log Message:

Use buffer instead of strdup.


diffs (87 lines):

diff --git a/common/utils/mutils.c b/common/utils/mutils.c
--- a/common/utils/mutils.c
+++ b/common/utils/mutils.c
@@ -838,7 +838,7 @@ get_bin_path(void)
uint32_t size = PATH_MAX;
if (_NSGetExecutablePath(buf, ) == 0 &&
realpath(buf, _bin_path) != NULL)
-   return _bin_path;
+   return _bin_path;
 #elif defined(BSD) && defined(KERN_PROC_PATHNAME)  /* BSD */
int mib[4];
size_t cb = sizeof(_bin_path);
diff --git a/tools/merovingian/daemon/merovingian.c 
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -52,6 +52,7 @@
 #include "msabaoth.h"
 #include "mutils.h" /* MT_lockf */
 #include "mcrypt.h" /* mcrypt_BackendSum */
+#include "mstring.h"   /* strcpy_len */
 #include "utils/utils.h"
 #include "utils/properties.h"
 #include "utils/glob.h"
@@ -102,7 +103,10 @@ typedef struct _threadlist {
 /* globals */
 
 /* full path to the mserver5 binary */
-char *_mero_mserver = NULL;
+#ifndef PATH_MAX
+# define PATH_MAX 1024
+#endif
+char _mero_mserver[PATH_MAX];
 /* list of databases that we have started */
 dpair _mero_topdp = NULL;
 /* lock to _mero_topdp, initialised as recursive later on */
@@ -472,8 +476,12 @@ main(int argc, char *argv[])
/* where is the mserver5 binary we fork on demand?
 * first try to locate it based on our binary location, fall-back to
 * hardcoded bin-dir */
-   _mero_mserver = get_bin_path();
-   if (_mero_mserver != NULL) {
+   p = get_bin_path();
+   if (p != NULL) {
+   if (strcpy_len(_mero_mserver, p, sizeof(_mero_mserver)) >= 
sizeof(_mero_mserver)) {
+   Mlevelfprintf(ERROR, stderr, "fatal: monetdbd full path 
name is too long\n");
+   exit(1);
+   }
/* Find where the string monetdbd actually starts */
char *s = strstr(_mero_mserver, "monetdbd");
if (s != NULL) {
@@ -483,9 +491,7 @@ main(int argc, char *argv[])
for (int i = 0; i < 8; i++)
s[i] = "mserver5"[i];
if (stat(_mero_mserver, ) == -1)
-   _mero_mserver = NULL;
-   else
-   _mero_mserver = strdup(_mero_mserver);
+   _mero_mserver[0] = 0;
}
}
/* setup default database properties, constants: unlike historical
@@ -699,8 +705,11 @@ main(int argc, char *argv[])
}
}
 
-   if (_mero_mserver == NULL) {
-   _mero_mserver = BINDIR "/mserver5";
+   if (_mero_mserver[0] == 0) {
+   if (strcpy_len(_mero_mserver, BINDIR "/mserver5", 
sizeof(_mero_mserver)) >= sizeof(_mero_mserver)) {
+   Mlevelfprintf(ERROR, stderr, "fatal: mserver5 full path 
name is too long\n");
+   MERO_EXIT_CLEAN(1);
+   }
if (stat(_mero_mserver, ) == -1) {
/* exit early if this is not going to work well */
Mlevelfprintf(ERROR, stderr, "cannot stat %s 
executable: %s\n",
diff --git a/tools/merovingian/daemon/merovingian.h 
b/tools/merovingian/daemon/merovingian.h
--- a/tools/merovingian/daemon/merovingian.h
+++ b/tools/merovingian/daemon/merovingian.h
@@ -75,7 +75,7 @@ void setLogLevel(loglevel level);
}   
\
} while (0)
 
-extern char *_mero_mserver;
+extern char _mero_mserver[];
 extern dpair _mero_topdp;
 extern pthread_mutex_t _mero_topdp_lock;
 extern volatile int _mero_keep_logging;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: balanced_union - Closing branch balanced_union.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: d5084b4aa997 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d5084b4aa997
Branch: balanced_union
Log Message:

Closing branch balanced_union.

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


MonetDB: default - Merge balanced_union branch into default.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: 57cde1d14e40 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/57cde1d14e40
Branch: default
Log Message:

Merge balanced_union branch into default.


diffs (truncated from 3330 to 300 lines):

diff --git a/monetdb5/optimizer/opt_support.c b/monetdb5/optimizer/opt_support.c
--- a/monetdb5/optimizer/opt_support.c
+++ b/monetdb5/optimizer/opt_support.c
@@ -264,6 +264,8 @@ isUpdateInstruction(InstrPtr p)
&& (getFunctionId(p) == appendRef || getFunctionId(p) == 
replaceRef
|| getFunctionId(p) == deleteRef))
return TRUE;
+   if (getModuleId(p) == matRef)
+   return TRUE;
return FALSE;
 }
 
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2328,6 +2328,13 @@ rel2bin_args(backend *be, sql_rel *rel, 
args = rel2bin_args(be, rel->l, args);
args = rel2bin_args(be, rel->r, args);
break;
+   case op_munion:
+   if (rel->l) {
+   for (node* n = ((list*)rel->l)->h; n; n = n->next) {
+   args = rel2bin_args(be, n->data, args);
+   }
+   }
+   break;
case op_groupby:
if (rel->r)
args = exps2bin_args(be, rel->r, args);
@@ -3864,6 +3871,65 @@ rel_rename(backend *be, sql_rel *rel, st
 }
 
 static stmt *
+rel2bin_munion(backend *be, sql_rel *rel, list *refs)
+{
+   mvc *sql = be->mvc;
+   list *l, *rstmts;
+   node *n, *m;
+   stmt *rel_stmt = NULL, *sub;
+   int i, len = 0, nr_unions = list_length((list*)rel->l);
+
+   /* convert to stmt and store the munion operands in rstmts list */
+   rstmts = sa_list(sql->sa);
+   for (n = ((list*)rel->l)->h; n; n = n->next) {
+   rel_stmt = subrel_bin(be, n->data, refs);
+   rel_stmt = subrel_project(be, rel_stmt, refs, n->data);
+   if (!rel_stmt)
+   return NULL;
+   list_append(rstmts, rel_stmt);
+   if (!len || len > list_length(rel_stmt->op4.lval))
+   len = list_length(rel_stmt->op4.lval);
+   }
+
+   /* construct relation */
+   l = sa_list(sql->sa);
+
+   /* for every op4 lval node */
+   //len = list_length(((stmt*)rstmts->h->data)->op4.lval);
+   for (i = 0; i < len; i++) {
+   /* extract t and c name from the first stmt */
+   stmt *s = list_fetch(((stmt*)rstmts->h->data)->op4.lval, i);
+   if (s == NULL)
+   return NULL;
+   const char *rnme = table_name(sql->sa, s);
+   const char *nme = column_name(sql->sa, s);
+   /* create a const column also from the first stmt */
+   s = stmt_pack(be, column(be, s), nr_unions);
+   /* for every other rstmt */
+   for (m = rstmts->h->next; m; m = m->next) {
+   stmt *t = list_fetch(((stmt*)m->data)->op4.lval, i);
+   if (t == NULL)
+   return NULL;
+   s = stmt_pack_add(be, s, column(be, t));
+   if (s == NULL)
+   return NULL;
+   }
+   s = stmt_alias(be, s, rnme, nme);
+   if (s == NULL)
+   return NULL;
+   list_append(l, s);
+   }
+   sub = stmt_list(be, l);
+
+   sub = rel_rename(be, rel, sub);
+   if (need_distinct(rel))
+   sub = rel2bin_distinct(be, sub, NULL);
+   if (is_single(rel))
+   sub = rel2bin_single(be, sub);
+   return sub;
+}
+
+static stmt *
 rel2bin_union(backend *be, sql_rel *rel, list *refs)
 {
mvc *sql = be->mvc;
@@ -7294,6 +7360,10 @@ subrel_bin(backend *be, sql_rel *rel, li
s = rel2bin_union(be, rel, refs);
sql->type = Q_TABLE;
break;
+   case op_munion:
+   s = rel2bin_munion(be, rel, refs);
+   sql->type = Q_TABLE;
+   break;
case op_except:
s = rel2bin_except(be, rel, refs);
sql->type = Q_TABLE;
diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -3447,6 +3447,78 @@ stmt_append_bulk(backend *be, stmt *c, l
 }
 
 stmt *
+stmt_pack(backend *be, stmt *c, int n)
+{
+   MalBlkPtr mb = be->mb;
+   InstrPtr q = NULL;
+
+   if (c == NULL || c->nr < 0)
+   goto bailout;
+   q = newStmtArgs(mb, matRef, packIncrementRef, 3);
+   if (q == NULL)
+   goto bailout;
+   q = pushArgument(mb, q, c->nr);
+   q = pushInt(mb, q, n);
+   bool enabled = be->mvc->sa->eb.enabled;
+   

MonetDB: balanced_union - small fix, use proper relation .

2024-05-31 Thread Niels Nes via checkin-list
Changeset: 52bfa5340d5c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/52bfa5340d5c
Modified Files:
sql/server/rel_optimize_others.c
Branch: balanced_union
Log Message:

small fix, use proper relation .


diffs (12 lines):

diff --git a/sql/server/rel_optimize_others.c b/sql/server/rel_optimize_others.c
--- a/sql/server/rel_optimize_others.c
+++ b/sql/server/rel_optimize_others.c
@@ -653,7 +653,7 @@ rel_mark_used(mvc *sql, sql_rel *rel, in
 
positional_exps_mark_used(rel, l);
rel_exps_mark_used(sql->sa, rel, l);
-   rel_mark_used(sql, rel->l, 0);
+   rel_mark_used(sql, l, 0);
/* based on child check set expression list */
if (first && is_project(l->op) && 
need_distinct(l))
positional_exps_mark_used(l, rel);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - When things go wrong, dump merovingian.log file.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: c49ab073c042 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c49ab073c042
Modified Files:
tools/merovingian/client/Tests/monetdbd.py
Branch: default
Log Message:

When things go wrong, dump merovingian.log file.
So that there is some hope in figuring out what went wrong.


diffs (13 lines):

diff --git a/tools/merovingian/client/Tests/monetdbd.py 
b/tools/merovingian/client/Tests/monetdbd.py
--- a/tools/merovingian/client/Tests/monetdbd.py
+++ b/tools/merovingian/client/Tests/monetdbd.py
@@ -155,6 +155,9 @@ class MonetDBD:
 self.runner.print()
 self.runner.print('ABORT ABORT exception occurred, stopping 
all databases')
 self.runner.print()
+logfile = self.run_monetdbd('get', 'logfile', output=True)
+
self.runner.print(open(logfile.split('\n')[1][7:].strip()).read())
+self.runner.print()
 self.run_monetdb('stop', '-a')
 self.proc.terminate()
 if exc_type == None:
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Save output from get_bin_path() in case it ge...

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: c35679b96ca0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c35679b96ca0
Modified Files:
tools/merovingian/daemon/merovingian.c
Branch: default
Log Message:

Save output from get_bin_path() in case it gets called again.


diffs (12 lines):

diff --git a/tools/merovingian/daemon/merovingian.c 
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -484,6 +484,8 @@ main(int argc, char *argv[])
s[i] = "mserver5"[i];
if (stat(_mero_mserver, ) == -1)
_mero_mserver = NULL;
+   else
+   _mero_mserver = strdup(_mero_mserver);
}
}
/* setup default database properties, constants: unlike historical
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: balanced_union - Merge with default branch.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: 84987918aa9b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/84987918aa9b
Branch: balanced_union
Log Message:

Merge with default branch.


diffs (truncated from 714 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
@@ -6657,7 +6657,7 @@ sql_update_default(Client c, mvc *sql, s
if (BATcount(b) == 0) {
/* do update */
sql_table *t;
-   const char query[] =
+   const char query1[] =
"update sys._columns set type_digits = 7 where 
type = 'tinyint' and type_digits <> 7;\n"
"update sys._columns set type_digits = 15 where 
type = 'smallint' and type_digits <> 15;\n"
"update sys._columns set type_digits = 31 where 
type = 'int' and type_digits <> 31;\n"
@@ -7061,37 +7061,102 @@ sql_update_default(Client c, mvc *sql, s
t->system = 0;
if ((t = mvc_bind_table(sql, s, "describe_tables")) != 
NULL)
t->system = 0;
-   printf("Running database upgrade commands:\n%s\n", 
query);
+   printf("Running database upgrade commands:\n%s\n", 
query1);
fflush(stdout);
-   err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
-
-   list *l;
-   if ((l = sa_list(sql->sa)) != NULL) {
-   sql_subtype tp1, tp2;
-   sql_find_subtype(, "date", 0, 0);
-   list_append(l, );
-   list_append(l, );
-   sql_find_subtype(, "day_interval", 0, 0);
-   list_append(l, );
-   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
-   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
-   "returns table (value date)\n"
-   "external name 
generator.series;\n"
-   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
-   "returns table (value date)\n"
-   "external name 
generator.series;\n"
-   "update sys.functions set 
system = true where system <> true and name = 'generate_series' and schema_id = 
2000;\n";
-   sql->session->status = 0;
-   sql->errstr[0] = '\0';
-   printf("Running database upgrade 
commands:\n%s\n", query);
+   err = SQLstatementIntern(c, query1, "update", true, 
false, NULL);
+   if (err == MAL_SUCCEED) {
+   const char query2[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
+   "returns table (value date)\n"
+   "external name generator.series;\n"
+   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
+   "returns table (value date)\n"
+   "external name generator.series;\n"
+   "update sys.functions set system = true 
where system <> true and name = 'generate_series' and schema_id = 2000;\n";
+   sql->session->status = 0;
+   sql->errstr[0] = '\0';
+   printf("Running database upgrade 
commands:\n%s\n", query2);
+   fflush(stdout);
+   err = SQLstatementIntern(c, query2, "update", 
true, false, NULL);
+   if (err == MAL_SUCCEED) {
+   const char query3[] =
+   "drop view sys.sessions;\n"
+   "drop function 
sys.sessions();\n"
+   "create function 
sys.sessions()\n"
+   " returns table(\n"
+   "  \"sessionid\" int,\n"
+   "  \"username\" string,\n"
+   "  \"login\" 

MonetDB: default - Cleaned up the upgrade code.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: e351962c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e351962c
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-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:

Cleaned up the upgrade code.


diffs (truncated from 783 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
@@ -6657,7 +6657,7 @@ sql_update_default(Client c, mvc *sql, s
if (BATcount(b) == 0) {
/* do update */
sql_table *t;
-   const char query[] =
+   const char query1[] =
"update sys._columns set type_digits = 7 where 
type = 'tinyint' and type_digits <> 7;\n"
"update sys._columns set type_digits = 15 where 
type = 'smallint' and type_digits <> 15;\n"
"update sys._columns set type_digits = 31 where 
type = 'int' and type_digits <> 31;\n"
@@ -7061,21 +7061,11 @@ sql_update_default(Client c, mvc *sql, s
t->system = 0;
if ((t = mvc_bind_table(sql, s, "describe_tables")) != 
NULL)
t->system = 0;
-   printf("Running database upgrade commands:\n%s\n", 
query);
+   printf("Running database upgrade commands:\n%s\n", 
query1);
fflush(stdout);
-   err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
-
-   list *l;
-   if (!(l = sa_list(sql->sa)))
-   return  "allocation failed";
-   sql_subtype tp1, tp2;
-   sql_find_subtype(, "date", 0, 0);
-   list_append(l, );
-   list_append(l, );
-   sql_find_subtype(, "day_interval", 0, 0);
-   list_append(l, );
-   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
-   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
+   err = SQLstatementIntern(c, query1, "update", true, 
false, NULL);
+   if (err == MAL_SUCCEED) {
+   const char query2[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
"returns table (value date)\n"
"external name generator.series;\n"
"create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
@@ -7084,92 +7074,89 @@ sql_update_default(Client c, mvc *sql, s
"update sys.functions set system = true 
where system <> true and name = 'generate_series' and schema_id = 2000;\n";
sql->session->status = 0;
sql->errstr[0] = '\0';
-   printf("Running database upgrade 

MonetDB: default - fix merge conflict in 0a8d1af0c436

2024-05-31 Thread Yunus Koning via checkin-list
Changeset: 3f4c730fed75 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3f4c730fed75
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: default
Log Message:

fix merge conflict in 0a8d1af0c436


diffs (135 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
@@ -7066,32 +7066,110 @@ sql_update_default(Client c, mvc *sql, s
err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
 
list *l;
-   if ((l = sa_list(sql->sa)) != NULL) {
-   sql_subtype tp1, tp2;
-   sql_find_subtype(, "date", 0, 0);
-   list_append(l, );
-   list_append(l, );
-   sql_find_subtype(, "day_interval", 0, 0);
-   list_append(l, );
-   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
-   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
-   "returns table (value date)\n"
-   "external name 
generator.series;\n"
-   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
-   "returns table (value date)\n"
-   "external name 
generator.series;\n"
-   "update sys.functions set 
system = true where system <> true and name = 'generate_series' and schema_id = 
2000;\n";
-   sql->session->status = 0;
-   sql->errstr[0] = '\0';
-   printf("Running database upgrade 
commands:\n%s\n", query);
-   fflush(stdout);
-   err = SQLstatementIntern(c, query, 
"update", true, false, NULL);
-   }
+   if (!(l = sa_list(sql->sa)))
+   return  "allocation failed";
+   sql_subtype tp1, tp2;
+   sql_find_subtype(, "date", 0, 0);
+   list_append(l, );
+   list_append(l, );
+   sql_find_subtype(, "day_interval", 0, 0);
+   list_append(l, );
+   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
+   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
+   "returns table (value date)\n"
+   "external name generator.series;\n"
+   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
+   "returns table (value date)\n"
+   "external name generator.series;\n"
+   "update sys.functions set system = true 
where system <> true and name = 'generate_series' and schema_id = 2000;\n";
+   sql->session->status = 0;
+   sql->errstr[0] = '\0';
+   printf("Running database upgrade 
commands:\n%s\n", query);
+   fflush(stdout);
+   err = SQLstatementIntern(c, query, "update", 
true, false, NULL);
}
}
BBPunfix(b->batCacheid);
}
res_table_destroy(output);
+
+   const char *query = "select id from args where func_id = (select id 
from functions where schema_id = 2000 and name = 'sessions');\n";
+   err = SQLstatementIntern(c, query, "update", true, false, );
+   if (err)
+   goto end;
+   b = BATdescriptor(output->cols[0].b);
+   if (b && BATcount(b) < 15) {
+   query =
+   "drop view sys.sessions;\n"
+   "drop function sys.sessions();\n"
+   "create function sys.sessions()\n"
+   " returns table(\n"
+   "  \"sessionid\" int,\n"
+   "  \"username\" string,\n"
+   "  \"login\" timestamp,\n"
+   "  \"idle\" timestamp,\n"
+   "  \"optimizer\" string,\n"
+   "  \"sessiontimeout\" int,\n"
+   "  \"querytimeout\" 

MonetDB: balanced_union - Merge with default branch.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: cfca19afb8c2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cfca19afb8c2
Modified Files:
sql/server/rel_dump.c
Branch: balanced_union
Log Message:

Merge with default branch.


diffs (239 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3610,7 +3610,7 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
pos = binsearch(NULL, 0, bi.type, bi.base,
bi.vh ? bi.vh->base : NULL,
bi.width, 0, bi.count,
-   ATOMnilptr(bi.type), -1, 1);
+   ATOMnilptr(bi.type), -1, 0);
if (pos == 0)
pos = oid_nil;
else
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
@@ -6645,19 +6645,13 @@ sql_update_dec2023_sp4(Client c, mvc *sq
 static str
 sql_update_default(Client c, mvc *sql, sql_schema *s)
 {
-   allocator *old_sa = sql->sa;
char *err;
res_table *output;
BAT *b;
 
-   if ((sql->sa = sa_create(sql->pa)) == NULL) {
-   sql->sa = old_sa;
-   return "sa_create failed";
-   }
-
err = SQLstatementIntern(c, "SELECT id FROM sys.functions WHERE 
schema_id = 2000 AND name = 'describe_type' AND func LIKE '%sql_datatype%';\n", 
"update", true, false, );
if (err)
-   goto end;
+   return err;
b = BATdescriptor(output->cols[0].b);
if (b) {
if (BATcount(b) == 0) {
@@ -7070,114 +7064,34 @@ sql_update_default(Client c, mvc *sql, s
printf("Running database upgrade commands:\n%s\n", 
query);
fflush(stdout);
err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
+
+   list *l;
+   if ((l = sa_list(sql->sa)) != NULL) {
+   sql_subtype tp1, tp2;
+   sql_find_subtype(, "date", 0, 0);
+   list_append(l, );
+   list_append(l, );
+   sql_find_subtype(, "day_interval", 0, 0);
+   list_append(l, );
+   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
+   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
+   "returns table (value date)\n"
+   "external name 
generator.series;\n"
+   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
+   "returns table (value date)\n"
+   "external name 
generator.series;\n"
+   "update sys.functions set 
system = true where system <> true and name = 'generate_series' and schema_id = 
2000;\n";
+   sql->session->status = 0;
+   sql->errstr[0] = '\0';
+   printf("Running database upgrade 
commands:\n%s\n", query);
+   fflush(stdout);
+   err = SQLstatementIntern(c, query, 
"update", true, false, NULL);
+   }
+   }
}
BBPunfix(b->batCacheid);
}
res_table_destroy(output);
-   list *l;
-   if ((l = sa_list(sql->sa)) != NULL) {
-   sql_subtype tp1, tp2;
-   sql_find_subtype(, "date", 0, 0);
-   list_append(l, );
-   list_append(l, );
-   sql_find_subtype(, "day_interval", 0, 0);
-   list_append(l, );
-   if (!sql_bind_func_(sql, s->base.name, "generate_series", l, 
F_UNION, true, true)) {
-   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
-   "returns table (value date)\n"
-   "external name generator.series;\n"
-   "create function sys.generate_series(first 
date, \"limit\" date, stepsize interval day)\n"
-   "returns table (value date)\n"
-   "external name generator.series;\n"
-   "update sys.functions set system = true where 
system 

MonetDB: default - Merge with Dec2023 branch.

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: 06b5a9250dec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/06b5a9250dec
Modified Files:
gdk/gdk_aggr.c
Branch: default
Log Message:

Merge with Dec2023 branch.


diffs (12 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3610,7 +3610,7 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
pos = binsearch(NULL, 0, bi.type, bi.base,
bi.vh ? bi.vh->base : NULL,
bi.width, 0, bi.count,
-   ATOMnilptr(bi.type), -1, 1);
+   ATOMnilptr(bi.type), -1, 0);
if (pos == 0)
pos = oid_nil;
else
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Dec2023 - Fix searching for smallest value in revsorted...

2024-05-31 Thread Sjoerd Mullender via checkin-list
Changeset: 5ab1adc1ae79 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5ab1adc1ae79
Modified Files:
gdk/gdk_aggr.c
Branch: Dec2023
Log Message:

Fix searching for smallest value in revsorted column with nils.
Fixes #7529.


diffs (12 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3650,7 +3650,7 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
pos = binsearch(NULL, 0, bi.type, bi.base,
bi.vh ? bi.vh->base : NULL,
bi.width, 0, bi.count,
-   ATOMnilptr(bi.type), -1, 1);
+   ATOMnilptr(bi.type), -1, 0);
if (pos == 0)
pos = oid_nil;
else
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - place upgrade code in proper scope

2024-05-31 Thread Yunus Koning via checkin-list
Changeset: 0a8d1af0c436 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0a8d1af0c436
Modified Files:
sql/backends/monet5/sql_upgrades.c
Branch: default
Log Message:

place upgrade code in proper scope


diffs (163 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
@@ -6645,19 +6645,13 @@ sql_update_dec2023_sp4(Client c, mvc *sq
 static str
 sql_update_default(Client c, mvc *sql, sql_schema *s)
 {
-   allocator *old_sa = sql->sa;
char *err;
res_table *output;
BAT *b;
 
-   if ((sql->sa = sa_create(sql->pa)) == NULL) {
-   sql->sa = old_sa;
-   return "sa_create failed";
-   }
-
err = SQLstatementIntern(c, "SELECT id FROM sys.functions WHERE 
schema_id = 2000 AND name = 'describe_type' AND func LIKE '%sql_datatype%';\n", 
"update", true, false, );
if (err)
-   goto end;
+   return err;
b = BATdescriptor(output->cols[0].b);
if (b) {
if (BATcount(b) == 0) {
@@ -7070,114 +7064,34 @@ sql_update_default(Client c, mvc *sql, s
printf("Running database upgrade commands:\n%s\n", 
query);
fflush(stdout);
err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
+
+   list *l;
+   if ((l = sa_list(sql->sa)) != NULL) {
+   sql_subtype tp1, tp2;
+   sql_find_subtype(, "date", 0, 0);
+   list_append(l, );
+   list_append(l, );
+   sql_find_subtype(, "day_interval", 0, 0);
+   list_append(l, );
+   if (!sql_bind_func_(sql, s->base.name, 
"generate_series", l, F_UNION, true, true)) {
+   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
+   "returns table (value date)\n"
+   "external name 
generator.series;\n"
+   "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval day)\n"
+   "returns table (value date)\n"
+   "external name 
generator.series;\n"
+   "update sys.functions set 
system = true where system <> true and name = 'generate_series' and schema_id = 
2000;\n";
+   sql->session->status = 0;
+   sql->errstr[0] = '\0';
+   printf("Running database upgrade 
commands:\n%s\n", query);
+   fflush(stdout);
+   err = SQLstatementIntern(c, query, 
"update", true, false, NULL);
+   }
+   }
}
BBPunfix(b->batCacheid);
}
res_table_destroy(output);
-   list *l;
-   if ((l = sa_list(sql->sa)) != NULL) {
-   sql_subtype tp1, tp2;
-   sql_find_subtype(, "date", 0, 0);
-   list_append(l, );
-   list_append(l, );
-   sql_find_subtype(, "day_interval", 0, 0);
-   list_append(l, );
-   if (!sql_bind_func_(sql, s->base.name, "generate_series", l, 
F_UNION, true, true)) {
-   const char query[] = "create function 
sys.generate_series(first date, \"limit\" date, stepsize interval month)\n"
-   "returns table (value date)\n"
-   "external name generator.series;\n"
-   "create function sys.generate_series(first 
date, \"limit\" date, stepsize interval day)\n"
-   "returns table (value date)\n"
-   "external name generator.series;\n"
-   "update sys.functions set system = true where 
system <> true and name = 'generate_series' and schema_id = 2000;\n";
-   sql->session->status = 0;
-   sql->errstr[0] = '\0';
-   printf("Running database upgrade commands:\n%s\n", 
query);
-   fflush(stdout);
-   err = SQLstatementIntern(c, query, "update", true, 
false, NULL);
-   }
-   }
-   if (err)
-   goto end;
-
-   const char *query = "select id from args where func_id = (select id 
from functions where schema_id = 2000 and name = 'sessions');\n";
-   err = SQLstatementIntern(c, query, "update", true, 

MonetDB: default - add exp2str

2024-05-31 Thread Niels Nes via checkin-list
Changeset: eba9c8b0cdfc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/eba9c8b0cdfc
Modified Files:
sql/server/rel_dump.c
sql/server/rel_dump.h
sql/server/rel_schema.c
Branch: default
Log Message:

add exp2str
test that we never have more than just the expression in a check constraint.


diffs (64 lines):

diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -383,6 +383,34 @@ cleanup:
return fres;
 }
 
+str
+exp2str( mvc *sql, sql_exp *exp)
+{
+   buffer *b = NULL;
+   stream *s = NULL;
+   char *res = NULL;
+
+   b = buffer_create(1024);
+   if(b == NULL)
+   goto cleanup;
+   s = buffer_wastream(b, "exp_dump");
+   if(s == NULL)
+   goto cleanup;
+
+   exp_print(sql, s, exp, 0, NULL, 0, 0, 0);
+   res = buffer_get_buf(b);
+
+cleanup:
+   if(b)
+   buffer_destroy(b);
+   if(s)
+   close_stream(s);
+
+   char* fres = SA_STRDUP(sql->sa, res);
+   free (res);
+   return fres;
+}
+
 static void
 exps_print(mvc *sql, stream *fout, list *exps, int depth, list *refs, int 
alias, int brackets, int decorate)
 {
diff --git a/sql/server/rel_dump.h b/sql/server/rel_dump.h
--- a/sql/server/rel_dump.h
+++ b/sql/server/rel_dump.h
@@ -20,6 +20,7 @@ extern void rel_print_(mvc *sql, stream 
 extern void rel_print_refs(mvc *sql, stream* fout, sql_rel *rel, int depth, 
list *refs, int decorate);
 
 extern str rel2str( mvc *sql, sql_rel *rel);
+extern str exp2str( mvc *sql, sql_exp *exp);
 extern sql_rel *rel_read(mvc *sql, char *ra, int *pos, list *refs);
 extern void exp_print(mvc *sql, stream *fout, sql_exp *e, int depth, list 
*refs, int comma, int alias, int decorate);
 
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -388,8 +388,10 @@ sql_rel* create_check_plan(sql_query *qu
 
mvc *sql = query->sql;
exp_kind ek = {type_value, card_value, FALSE};
-   sql_rel* rel = rel_basetable(sql, t, t->base.name);
+   sql_rel* rel = rel_basetable(sql, t, t->base.name), *orel = rel;
sql_exp *e = rel_logical_value_exp(query, , s->data.sym, sql_sel | 
sql_no_subquery, ek);
+   assert(rel == orel);
+   (void)orel;
rel->exps = rel_base_projection(sql, rel, 0);
list *pexps = sa_list(sql->sa);
pexps = append(pexps, e);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: balanced_union - merged with default

2024-05-31 Thread Niels Nes via checkin-list
Changeset: 67c2882b41ab for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/67c2882b41ab
Branch: balanced_union
Log Message:

merged with default


diffs (12 lines):

diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -14,7 +14,7 @@
 #define _MUTILS_H_
 
 #ifdef WIN32
-#if !defined(LIBMUTILS) && !defined(LIBGDK) && !defined(LIBMEROUTIL)
+#if !defined(LIBMUTILS) && !defined(LIBGDK) && !defined(LIBMEROUTIL) && 
!defined(LIBMAPI)
 #define mutils_export extern __declspec(dllimport)
 #else
 #define mutils_export extern __declspec(dllexport)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: label - merged with default

2024-05-31 Thread Niels Nes via checkin-list
Changeset: 716f54fcbe17 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/716f54fcbe17
Branch: label
Log Message:

merged with default


diffs (12 lines):

diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -14,7 +14,7 @@
 #define _MUTILS_H_
 
 #ifdef WIN32
-#if !defined(LIBMUTILS) && !defined(LIBGDK) && !defined(LIBMEROUTIL)
+#if !defined(LIBMUTILS) && !defined(LIBGDK) && !defined(LIBMEROUTIL) && 
!defined(LIBMAPI)
 #define mutils_export extern __declspec(dllimport)
 #else
 #define mutils_export extern __declspec(dllexport)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - add missing exception in the mutils.h file fo...

2024-05-31 Thread Niels Nes via checkin-list
Changeset: f308ba3e2015 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f308ba3e2015
Modified Files:
common/utils/mutils.h
Branch: default
Log Message:

add missing exception in the mutils.h file for libmapi


diffs (12 lines):

diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -14,7 +14,7 @@
 #define _MUTILS_H_
 
 #ifdef WIN32
-#if !defined(LIBMUTILS) && !defined(LIBGDK) && !defined(LIBMEROUTIL)
+#if !defined(LIBMUTILS) && !defined(LIBGDK) && !defined(LIBMEROUTIL) && 
!defined(LIBMAPI)
 #define mutils_export extern __declspec(dllimport)
 #else
 #define mutils_export extern __declspec(dllexport)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org