MonetDB: nested - wip

2025-01-30 Thread svetlin via checkin-list
Changeset: 1e93beef9a23 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1e93beef9a23
Modified Files:
sql/backends/monet5/sql.c
Branch: nested
Log Message:

wip


diffs (46 lines):

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
@@ -2318,6 +2318,7 @@ DELTAsub(bat *result, const bat *col, co
BBPunfix(res->batCacheid);
res = nres;
ret = BATappend(res, u, cminu, true);
+
BBPunfix(u->batCacheid);
BBPunfix(cminu->batCacheid);
cminu = NULL;
@@ -5830,8 +5831,23 @@ SQLfrom_json(Client cntxt, MalBlkPtr mb,
return msg;
int mtype = getArgType(mb, pci, pci->retc);
 
-   if (strcmp(BATatoms[mtype].name, "json") != 0)
-   throw(SQL, "SQLfrom_json", SQLSTATE(HY013) "Incorrect argument 
type");
+   if (isaBatType(mtype)) {
+   if(strcmp(BATatoms[getBatType(mtype)].name, "json") != 0 )
+   throw(SQL, "SQLfrom_json", SQLSTATE(HY013) "Incorrect 
bat argument type");
+   bat bid = *getArgReference_bat(stk, pci, pci->retc);
+   BAT *b = BATdescriptor(bid);
+   BATiter bi = bat_iterator(b);
+   BUN p, q;
+   BATloop(b, p, q) {
+   const char *json = (const char *) BUNtail(bi, p);
+   (void) json;
+   }
+   bat_iterator_end(&bi);
+   } else {
+   if (strcmp(BATatoms[mtype].name, "json") != 0)
+   throw(SQL, "SQLfrom_json", SQLSTATE(HY013) "Incorrect 
argument type");
+   }
+
str json = *(str*)getArgReference(stk, pci, pci->retc);
sql_subtype *t = *(sql_subtype**)getArgReference(stk, pci, pci->retc+1);
 
@@ -6866,7 +6882,7 @@ static mel_func sql_init_funcs[] = {
  pattern("sql", "stop_vacuum", SQLstr_stop_vacuum, true, "stop auto vacuum", 
args(0,2, arg("sname",str),arg("tname",str))),
  pattern("sql", "check", SQLcheck, false, "Return sql string of check 
constraint.", args(1,3, arg("sql",str), arg("sname", str), arg("name", str))),
  pattern("sql", "read_dump_rel", SQLread_dump_rel, false, "Reads sql_rel 
string into sql_rel object and then writes it to the return value", args(1,2, 
arg("sql",str), arg("sql_rel", str))),
- pattern("sql", "from_json", SQLfrom_json, false, "Reads json string into 
table of nested/multiset structures", args(1,3, batvarargany("t",0), 
arg("input", json), arg("type", ptr))),
+ pattern("sql", "from_json", SQLfrom_json, false, "Reads json string into 
table of nested/multiset structures", args(1,3, batvarargany("t",0), 
optbatarg("input", json), arg("type", ptr))),
  pattern("sql", "from_varchar", SQLfrom_varchar, false, "Reads string into 
table of nested/multiset structures", args(1,3, batvarargany("t",0), 
arg("input", str), arg("type", ptr))),
  { .imp=NULL }
 };
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: newjson - merge nested

2025-01-30 Thread svetlin via checkin-list
Changeset: 5b5eed0526cc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5b5eed0526cc
Branch: newjson
Log Message:

merge nested


diffs (46 lines):

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
@@ -2318,6 +2318,7 @@ DELTAsub(bat *result, const bat *col, co
BBPunfix(res->batCacheid);
res = nres;
ret = BATappend(res, u, cminu, true);
+
BBPunfix(u->batCacheid);
BBPunfix(cminu->batCacheid);
cminu = NULL;
@@ -5830,8 +5831,23 @@ SQLfrom_json(Client cntxt, MalBlkPtr mb,
return msg;
int mtype = getArgType(mb, pci, pci->retc);
 
-   if (strcmp(BATatoms[mtype].name, "json") != 0)
-   throw(SQL, "SQLfrom_json", SQLSTATE(HY013) "Incorrect argument 
type");
+   if (isaBatType(mtype)) {
+   if(strcmp(BATatoms[getBatType(mtype)].name, "json") != 0 )
+   throw(SQL, "SQLfrom_json", SQLSTATE(HY013) "Incorrect 
bat argument type");
+   bat bid = *getArgReference_bat(stk, pci, pci->retc);
+   BAT *b = BATdescriptor(bid);
+   BATiter bi = bat_iterator(b);
+   BUN p, q;
+   BATloop(b, p, q) {
+   const char *json = (const char *) BUNtail(bi, p);
+   (void) json;
+   }
+   bat_iterator_end(&bi);
+   } else {
+   if (strcmp(BATatoms[mtype].name, "json") != 0)
+   throw(SQL, "SQLfrom_json", SQLSTATE(HY013) "Incorrect 
argument type");
+   }
+
str json = *(str*)getArgReference(stk, pci, pci->retc);
sql_subtype *t = *(sql_subtype**)getArgReference(stk, pci, pci->retc+1);
 
@@ -6866,7 +6882,7 @@ static mel_func sql_init_funcs[] = {
  pattern("sql", "stop_vacuum", SQLstr_stop_vacuum, true, "stop auto vacuum", 
args(0,2, arg("sname",str),arg("tname",str))),
  pattern("sql", "check", SQLcheck, false, "Return sql string of check 
constraint.", args(1,3, arg("sql",str), arg("sname", str), arg("name", str))),
  pattern("sql", "read_dump_rel", SQLread_dump_rel, false, "Reads sql_rel 
string into sql_rel object and then writes it to the return value", args(1,2, 
arg("sql",str), arg("sql_rel", str))),
- pattern("sql", "from_json", SQLfrom_json, false, "Reads json string into 
table of nested/multiset structures", args(1,3, batvarargany("t",0), 
arg("input", json), arg("type", ptr))),
+ pattern("sql", "from_json", SQLfrom_json, false, "Reads json string into 
table of nested/multiset structures", args(1,3, batvarargany("t",0), 
optbatarg("input", json), arg("type", ptr))),
  pattern("sql", "from_varchar", SQLfrom_varchar, false, "Reads string into 
table of nested/multiset structures", args(1,3, batvarargany("t",0), 
arg("input", str), arg("type", ptr))),
  { .imp=NULL }
 };
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: nested - merge upstream

2025-01-30 Thread svetlin via checkin-list
Changeset: 1e784e119c1d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1e784e119c1d
Branch: nested
Log Message:

merge upstream


diffs (12 lines):

diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -3296,7 +3296,7 @@ dump_header(mvc *sql, MalBlkPtr mb, list
stmt *c = n->data;
sql_subtype *t = tail_type(c);
if (t->multiset) { /* properly handle subtable */
-   printf("%multiset\n");
+   printf("%%multiset\n");
}
sql_alias *tname = table_name(sql->sa, c);
const char *_empty = "";
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: nested - merge newjson

2025-01-30 Thread svetlin via checkin-list
Changeset: ef14cbd647eb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ef14cbd647eb
Branch: nested
Log Message:

merge newjson


diffs (truncated from 397 to 300 lines):

diff --git a/sql/backends/monet5/CMakeLists.txt 
b/sql/backends/monet5/CMakeLists.txt
--- a/sql/backends/monet5/CMakeLists.txt
+++ b/sql/backends/monet5/CMakeLists.txt
@@ -187,6 +187,7 @@ target_include_directories(sql
 target_link_libraries(sql
   PRIVATE
   monetdb_config_header
+  json
   sqlstorage
   sqlcommon
   batstore
@@ -226,6 +227,7 @@ install(TARGETS
   DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
 add_subdirectory(generator)
+add_subdirectory(vaults/json)
 if(WITH_UDF)
   add_subdirectory(UDF)
 endif()
diff --git a/sql/backends/monet5/vaults/json/CMakeLists.txt 
b/sql/backends/monet5/vaults/json/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/vaults/json/CMakeLists.txt
@@ -0,0 +1,47 @@
+#[[
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# Copyright 2024, 2025 MonetDB Foundation;
+# Copyright August 2008 - 2023 MonetDB B.V.;
+# Copyright 1997 - July 2008 CWI.
+#]]
+
+add_library(json OBJECT)
+#if(MONETDB_STATIC)
+#  add_library(json STATIC)
+#else()
+#  add_library(json SHARED)
+#endif()
+
+target_sources(json
+  PRIVATE
+  json.c)
+
+target_include_directories(json
+  PRIVATE
+  $
+  $
+  $
+  $
+  $
+  $
+  $
+  $
+  $)
+
+target_link_libraries(json
+  PRIVATE
+  monetdb_config_header
+  sqlinclude
+  monetdb5
+  bat
+  stream
+)
+
+set_target_properties(json
+  PROPERTIES
+  POSITION_INDEPENDENT_CODE ON)
diff --git a/sql/backends/monet5/vaults/json/json.c 
b/sql/backends/monet5/vaults/json/json.c
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/vaults/json/json.c
@@ -0,0 +1,295 @@
+/*
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2024 MonetDB Foundation;
+ * Copyright August 2008 - 2023 MonetDB B.V.;
+ * Copyright 1997 - July 2008 CWI.
+ */
+
+#include "monetdb_config.h"
+#include "rel_file_loader.h"
+#include "rel_exp.h"
+
+#include "mal_instruction.h"
+#include "mal_interpreter.h"
+#include "mal_parser.h"
+#include "mal_builder.h"
+#include "mal_namespace.h"
+#include "mal_exception.h"
+#include "mal_linker.h"
+#include "mal_backend.h"
+#include "sql_types.h"
+#include "rel_bin.h"
+#include "json.h"
+#include "mutils.h"
+
+#ifdef HAVE_FCNTL_H
+#include 
+#endif
+
+#include 
+// #include  // not available on Windows
+
+
+typedef struct JSONFileHandle {
+   allocator *sa;
+   char *filename;
+   int fd;
+   size_t size;
+} JSONFileHandle;
+
+
+static JSONFileHandle *
+json_open(const char *fname, allocator *sa)
+{
+   if (!sa)
+   return NULL;
+   int fd = MT_open(fname, O_RDONLY);
+   if (fd < 0){
+   // TODO add relevant trace component
+   TRC_ERROR(SQL_EXECUTION, "Error opening file %s", fname);
+   return NULL;
+   }
+   struct stat stb;
+if (MT_stat(fname, &stb) != 0) {
+   TRC_ERROR(SQL_EXECUTION, "Error stat file %s", fname);
+   close(fd);
+   return NULL;
+   }
+   JSONFileHandle *res = sa_alloc(sa, sizeof(JSONFileHandle));
+   res->sa = sa;
+   res->filename = sa_strdup(sa, fname);
+   res->fd = fd;
+   res->size = stb.st_size;
+   return res;
+}
+
+static void
+json_close(JSONFileHandle *jfh)
+{
+   if (jfh && jfh->fd)
+   close(jfh->fd);
+}
+
+
+static char *
+read_json_file(JSONFileHandle *jfh)
+{
+   char *content = NULL;
+   if (jfh) {
+   unsigned int length = (unsigned int)jfh->size;
+   content = sa_zalloc(jfh->sa, length + 1);
+   if (content) {
+   ssize_t nbytes = read(jfh->fd, content, length);
+   if (nbytes < 0)
+   return NULL;
+   content[length + 1] = '\0';
+   }
+   }
+   return content;
+}
+
+
+static size_t
+append_terms(allocator *sa, JSON *jt, size_t offset, BAT *b, char **error)
+{
+   JSONterm *t = jt->elm + offset;
+   char *v = NULL;
+   JSONterm *prev = offset > 0 ? (jt->elm + (offset - 1)) : NULL;
+   JSONterm *next = offset < (size_t)jt->free ? jt->elm + (offset + 1): 
NULL;
+   switch(t->kind) {
+   case JSON_ARRAY:
+   if ( (prev == NULL && next && next->kind > JSON_ARRAY)
+   || (prev && prev->kind == JSON_ARRAY) ) 
{
+   // array of basic types or array of arrays
+   v = sa

MonetDB: newjson - closing newjson branch

2025-01-30 Thread svetlin via checkin-list
Changeset: d501c5fb2932 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d501c5fb2932
Branch: newjson
Log Message:

closing newjson branch

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


MonetDB: default - We need to #include getopt.h in some form.

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: 8c95d12b6ed3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8c95d12b6ed3
Modified Files:
sql/server/sqlparse.c
Branch: default
Log Message:

We need to #include getopt.h in some form.


diffs (27 lines):

diff --git a/sql/server/sqlparse.c b/sql/server/sqlparse.c
--- a/sql/server/sqlparse.c
+++ b/sql/server/sqlparse.c
@@ -1,5 +1,23 @@
+/*
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2024, 2025 MonetDB Foundation;
+ * Copyright August 2008 - 2023 MonetDB B.V.;
+ * Copyright 1997 - July 2008 CWI.
+ */
 
 #include "monetdb_config.h"
+#ifndef HAVE_GETOPT_LONG
+#  include "monet_getopt.h"
+#else
+# ifdef HAVE_GETOPT_H
+#  include "getopt.h"
+# endif
+#endif
 #include "stream.h"
 #include "sql_mvc.h"
 #include "sql_parser.tab.h"
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Need braces around declaration after case label.

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: 4d51b9359998 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4d51b9359998
Modified Files:
sql/server/sqlparse.c
Branch: default
Log Message:

Need braces around declaration after case label.


diffs (20 lines):

diff --git a/sql/server/sqlparse.c b/sql/server/sqlparse.c
--- a/sql/server/sqlparse.c
+++ b/sql/server/sqlparse.c
@@ -423,7 +423,7 @@ sp_symbol2string(mvc *sql, symbol *se, i
  return res;
}
case SQL_AND:
-   case SQL_OR:
+   case SQL_OR: {
char *tok_str = token2string(se->token);
char *args = dlist2string(sql, se->data.lval, ", ", " (", " )", 
expression, err, depth + 1, indent);
char *res;
@@ -433,6 +433,7 @@ sp_symbol2string(mvc *sql, symbol *se, i
 if ((res = SA_NEW_ARRAY(sql->ta, char, strlen(tok_str) + 
strlen(args) + 1)))
 stpcpy(stpcpy(res, tok_str), args);
return res;
+   }
default:
/* generic */
if (se->type == type_list) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Implements indent in sqlparse tool

2025-01-30 Thread stefanos mavros via checkin-list
Changeset: 22ca3873e29b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/22ca3873e29b
Modified Files:
sql/server/sqlparse.c
Branch: default
Log Message:

Implements indent in sqlparse tool


diffs (221 lines):

diff --git a/sql/server/sqlparse.c b/sql/server/sqlparse.c
--- a/sql/server/sqlparse.c
+++ b/sql/server/sqlparse.c
@@ -7,7 +7,6 @@
 #include "sql_semantic.h"
 #include 
 
-
 extern void bat_storage_init(void *b);
 extern void bat_table_init(void *b);
 extern void bat_logger_init(void *b);
@@ -156,11 +155,11 @@ qname_schema_object(dlist *qname)
 }
 
 
-static char * sp_symbol2string(mvc *sql, symbol *se, int expression, char 
**err);
-static char * dlist2string(mvc *sql, dlist *l, char *sep, char *lb, char *rb, 
int expression, char **err);
+static char * sp_symbol2string(mvc *sql, symbol *se, int expression, char 
**err, int depth);
+static char * dlist2string(mvc *sql, dlist *l, char *sep, char *lb, char *rb, 
int expression, char **err, int depth, bool indent);
 
 static char *
-dnode2string(mvc *sql, dnode *n, int expression, char **err)
+dnode2string(mvc *sql, dnode *n, int expression, char **err, int depth)
 {
char *s = NULL;
if (n->type == type_string) {
@@ -177,9 +176,9 @@ dnode2string(mvc *sql, dnode *n, int exp
snprintf(buf, sizeof(buf), LLFMT, n->data.l_val);
s = sa_strdup(sql->ta, buf);
} else if (n->type == type_symbol) {
-   s = sp_symbol2string(sql, n->data.sym, expression, err);
+   s = sp_symbol2string(sql, n->data.sym, expression, err, depth);
} else if (n->type == type_list) {
-   s = dlist2string(sql, n->data.lval, ", ", "( ", " )", 
expression, err);
+   s = dlist2string(sql, n->data.lval, ", ", "( ", " )", 
expression, err, depth, false);
} else if (n->type == type_type) {
s = sql_subtype_string(sql->ta, &n->data.typeval);
}
@@ -187,7 +186,7 @@ dnode2string(mvc *sql, dnode *n, int exp
 }
 
 static char *
-dlist2string(mvc *sql, dlist *l, char *sep, char *lb, char *rb, int 
expression, char **err)
+dlist2string(mvc *sql, dlist *l, char *sep, char *lb, char *rb, int 
expression, char **err, int depth, bool indent)
 {
if (!l)
return " EMPTY_LIST";
@@ -195,20 +194,29 @@ dlist2string(mvc *sql, dlist *l, char *s
dnode *n;
 
size_t seplen = strlen(sep);
-   bool skipsep = lb;
+
+   bool first_el = lb;
for (n=l->h; n; n = n->next) {
-   char *s = dnode2string(sql, n, expression, err);
+   char *s = dnode2string(sql, n, expression, err, depth);
 
if (!s)
return NULL;
if (b) {
-   char *o = SA_NEW_ARRAY(sql->ta, char, strlen(b) + 
strlen(s) + seplen + 1);
+   size_t depth_chars = indent ? depth + 1 : 0;
+   char *o = SA_NEW_ARRAY(sql->ta, char, depth_chars + 
strlen(b) + strlen(s) + seplen + 1);
if (o) {
-   if (skipsep)
-   stpcpy(stpcpy(o, b), s);
-   else
-   stpcpy(stpcpy(stpcpy(o, b), sep), s);
-   skipsep = false;
+   char *tmp;
+   tmp = stpcpy(o, b);
+   if (!first_el)
+   tmp = stpcpy(tmp, sep);
+   if (indent) {
+   tmp = stpcpy(tmp, "\n");
+   for (int i=0; i < depth; i++)
+   tmp = stpcpy(tmp, "\t");
+   }
+   tmp = stpcpy(tmp, s);
+
+   first_el = false;
}
b = o;
if (b == NULL)
@@ -218,9 +226,20 @@ dlist2string(mvc *sql, dlist *l, char *s
}
}
if (rb) {
-   char *o = SA_NEW_ARRAY(sql->ta, char, strlen(b) + strlen(rb) + 
1);
-   if (o)
-   stpcpy(stpcpy(o, b), rb);
+   /* here we do (depth - 1) * tab + 1 * newline to align with the 
parent op */
+   size_t depth_chars = indent ? depth : 0;
+
+   char *o = SA_NEW_ARRAY(sql->ta, char, depth_chars + strlen(b) + 
strlen(rb) + 1);
+   if (o) {
+   char *tmp;
+   tmp = stpcpy(o, b);
+   if (indent) {
+   tmp = stpcpy(tmp, "\n");
+   for (int i=0; i < (depth - 1); i++)
+   tmp = stpcpy(tmp, "\t");
+   }
+   stpcpy(tmp, rb);
+   }
b = o;
}
return

MonetDB: default - Merge with Aug2024 branch.

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: aa26087ebc8f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/aa26087ebc8f
Modified Files:
sql/server/rel_optimize_sel.c
testing/Mtest.py.in
testing/sqllogictest.py
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (truncated from 2515 to 300 lines):

diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -2295,7 +2295,7 @@ find_fk( mvc *sql, list *rels, list *exp
 }
 
 static int
-rels_find_one_rel( sql_rel **rels, int nr, sql_exp *e)
+exp_find_one_rel( sql_rel **rels, int nr, sql_exp *e)
 {
int fnd = 0;
 
@@ -2309,6 +2309,22 @@ rels_find_one_rel( sql_rel **rels, int n
return fnd;
 }
 
+static int
+exps_find_one_rel( sql_rel **rels, int nr, list *exps)
+{
+   int fnd = 0;
+
+   for(node *n = exps->h; n; n = n->next) {
+   int nfnd = exp_find_one_rel(rels, nr, n->data);
+   if (nfnd != fnd && fnd)
+   return 0;
+   fnd = nfnd;
+   if (!fnd)
+   return 0;
+   }
+   return fnd;
+}
+
 /* TODO move popcount and popcount64 into gdk_*.h, used in gdk_cand, strimps 
and here */
 static inline int
 popcount64(uint64_t x)
@@ -2382,18 +2398,16 @@ order_joins(visitor *v, list *rels, list
 
h[ci] = r1[ci] = r2[ci] = 0;
r3[ci] = 0;
-   /* h[ci] = exp_find_rels(cje, rels) */
-   if (cje->type != e_cmp || !is_complex_exp(cje->flag) || 
!find_prop(cje->p, PROP_HASHCOL) ||
-  (cje->type == e_cmp && cje->f == NULL)) {
+   if (cje->type == e_cmp) {
cje->tmp = ci;
-   r1[ci] = rels_find_one_rel(rels_a, nr_rels, cje->l);
-   r2[ci] = rels_find_one_rel(rels_a, nr_rels, cje->r);
+   r1[ci] = cje->flag == cmp_filter ? 
exps_find_one_rel(rels_a, nr_rels, cje->l) : exp_find_one_rel(rels_a, nr_rels, 
cje->l);
+   r2[ci] = cje->flag == cmp_filter ? 
exps_find_one_rel(rels_a, nr_rels, cje->r) : exp_find_one_rel(rels_a, nr_rels, 
cje->r);
if (r1[ci])
h[ci] |= ((ulng)1)<<((r1[ci]-1)%64);
if (r2[ci])
h[ci] |= ((ulng)1)<<((r2[ci]-1)%64);
-   if (cje->f) {
-   r3[ci] = rels_find_one_rel(rels_a, nr_rels, 
cje->f);
+   if (cje->f && cje->flag != cmp_filter) {
+   r3[ci] = exp_find_one_rel(rels_a, nr_rels, 
cje->f);
if (r3[ci] == r2[ci])
r3[ci] = 0;
if (r3[ci])
@@ -2414,8 +2428,7 @@ order_joins(visitor *v, list *rels, list
 * */
if (0 && popcount64(h[cje->tmp]) > 2)
assert(0);
-   if (cje->type != e_cmp || !is_complex_exp(cje->flag) || 
!find_prop(cje->p, PROP_HASHCOL) ||
-   (cje->type == e_cmp && cje->f == NULL)) {
+   if (cje->type == e_cmp) {
l = rels_a[r1[cje->tmp]];
r = rels_a[r2[cje->tmp]];
if (l && r)
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -123,7 +123,7 @@ if isatty:
 res = 
ctypes.windll.kernel32.GetConsoleScreenBufferInfo(handle, csbi)
 assert res
 (bufx, bufy, curx, cury, wattr,
-left, top, right, bottom, maxx, maxy) = 
struct.unpack("Hhh", csbi.raw)
+left, top, right, bottom, maxx, maxy) = 
struct.unpack('Hhh', csbi.raw)
 return wattr
 reset = get_csbi_attributes(handle)
 def prred(str,
@@ -273,16 +273,16 @@ def remove(file):
 Warn(f'could not remove {file}')
 
 def isexecutable(TST, ext = '.sh') :
-if   os.name == "nt":
-for ext in ".exe", ".com", ".bat", ".cmd":
+if   os.name == 'nt':
+for ext in '.exe', '.com', '.bat', '.cmd':
 if TST.lower().endswith(ext):
 ext = ''
-if os.path.isfile(TST+ext) or os.path.isfile(TST+ext+".src"):
+if os.path.isfile(TST+ext) or os.path.isfile(TST+ext+'.src'):
 return (True, ext)
-elif os.name == "posix":
+elif os.name == 'posix':
 TST += ext
 if ( os.path.isfile(TST   ) and os.access(TST   ,os.X_OK) ) or 
\
-   ( os.path.isfile(TST+".src") and os.access(TST+".src",os.X_OK) ):
+   ( os.path.isfile(TST+'.src') and os.access(TST+'.src',os.X_OK) ):
 return (True, ext)
 return (False, '')
 ### isexecutable(TST,

MonetDB: Aug2024 - Reworked timeout handling in Mtest.

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: 116a59fdb4e6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/116a59fdb4e6
Modified Files:
testing/Mtest.py.in
testing/malmapi.py
testing/process.py
testing/sqllogictest.py
testing/sqltest.py
Branch: Aug2024
Log Message:

Reworked timeout handling in Mtest.


diffs (truncated from 825 to 300 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1272,7 +1272,12 @@ def PerformDir(env, testdir, testlist, t
 else:
 vaultopt = []
 if not oneserver:
-pSrvr = ServerClass(env['exe']['mserver5'] + 
[f'--dbpath={LogDBdir}'] + vaultopt + mserver5_opts, open(os.devnull, 'w'), 
open(os.devnull, 'w'), par['TIMEOUT'], os.path.join(LogDBdir, '.started'), 
TSTDB, dbg=env.get('DBG'))
+pSrvr = ServerClass(env['exe']['mserver5'] + 
[f'--dbpath={LogDBdir}'] + vaultopt + mserver5_opts,
+open(os.devnull, 'w'),
+open(os.devnull, 'w'),
+30 if par['TIMEOUT'] else 0,
+os.path.join(LogDBdir, '.started'),
+TSTDB, dbg=env.get('DBG'))
 pSrvr.LaunchIt()
 pSrvr.terminate()
 if not os.path.exists(TSTTRGDIR):
@@ -1345,8 +1350,12 @@ def PerformDir(env, testdir, testlist, t
 except:
 pass
 else:
+dbh.settimeout(10)
 crs = dbh.cursor()
-crs.execute("call 
logging.setcomplevel('SQL_EXECUTION', 'INFO')")
+try:
+crs.execute("call 
logging.setcomplevel('SQL_EXECUTION', 'INFO')")
+except socket.timeout:
+print('\nTimeout setting log level.\n')
 crs.close()
 dbh.close()
 os.environ['MAPIPORT'] = env['MAPIPORT'] = pSrvr.port
@@ -1656,12 +1665,12 @@ def GetBitsAndModsAndThreads(env) :
 proc.stderr = process._BufferedPipe(proc.stderr)
 proc.killed = False
 proc.onechild = True
-t = Timer(float(par['TIMEOUT']), killProc, args = [proc, stderr, cmd])
 qOut = qErr = ''
 mods = []
+timeout = par['TIMEOUT'] != 0
 try:
-t.start()
-while True:
+starttime = time.time()
+while not timeout or time.time() < starttime + 30:
 proc.poll()
 if proc.returncode is not None:
 qOut = proc.stdout.read()
@@ -1669,7 +1678,7 @@ def GetBitsAndModsAndThreads(env) :
 break
 if os.path.exists(os.path.join(dbpath, '.started')):
 break
-time.sleep(0.001)
+time.sleep(0.1)
 if proc.returncode is None:
 connurl = open(os.path.join(dbpath, '.conn')).read()
 res = mapiportre.search(connurl)
@@ -1679,28 +1688,38 @@ def GetBitsAndModsAndThreads(env) :
 hostname=HOST,
 port=int(res.group('port')),
 database=TSTPREF,
-autocommit=True)
+autocommit=True,
+connect_timeout=1.0)
 except KeyboardInterrupt:
 raise
 except:
 pass
 else:
+if timeout:
+dbh.settimeout(30)
 crs = dbh.cursor()
-crs.execute('select distinct module from 
sys.malfunctions() order by module')
-mods = crs.fetchall()
-mods = [x[0] for x in mods]
 try:
-mods.remove('user')
-except ValueError:
+crs.execute('select distinct module from 
sys.malfunctions() order by module')
+except socket.timeout:
 pass
+else:
+mods = crs.fetchall()
+mods = [x[0] for x in mods]
+try:
+mods.remove('user')
+except ValueError:
+pass
 crs.close()
 dbh.close()
 proc.terminate()
-qOut = proc.stdout.read()
-qErr = proc.stderr.read()
-proc.wait()
+qOut = proc.stdout.read(timeout=5)
+qErr = proc.stderr.read(ti

MonetDB: Aug2024 - Cleanup. Remove --RUBYCLIENT option.

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: c958540b6521 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c958540b6521
Modified Files:
testing/Mtest.py.in
Branch: Aug2024
Log Message:

Cleanup.  Remove --RUBYCLIENT option.


diffs (truncated from 1524 to 300 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -123,7 +123,7 @@ if isatty:
 res = 
ctypes.windll.kernel32.GetConsoleScreenBufferInfo(handle, csbi)
 assert res
 (bufx, bufy, curx, cury, wattr,
-left, top, right, bottom, maxx, maxy) = 
struct.unpack("Hhh", csbi.raw)
+left, top, right, bottom, maxx, maxy) = 
struct.unpack('Hhh', csbi.raw)
 return wattr
 reset = get_csbi_attributes(handle)
 def prred(str,
@@ -273,16 +273,16 @@ def remove(file):
 Warn(f'could not remove {file}')
 
 def isexecutable(TST, ext = '.sh') :
-if   os.name == "nt":
-for ext in ".exe", ".com", ".bat", ".cmd":
+if   os.name == 'nt':
+for ext in '.exe', '.com', '.bat', '.cmd':
 if TST.lower().endswith(ext):
 ext = ''
-if os.path.isfile(TST+ext) or os.path.isfile(TST+ext+".src"):
+if os.path.isfile(TST+ext) or os.path.isfile(TST+ext+'.src'):
 return (True, ext)
-elif os.name == "posix":
+elif os.name == 'posix':
 TST += ext
 if ( os.path.isfile(TST   ) and os.access(TST   ,os.X_OK) ) or 
\
-   ( os.path.isfile(TST+".src") and os.access(TST+".src",os.X_OK) ):
+   ( os.path.isfile(TST+'.src') and os.access(TST+'.src',os.X_OK) ):
 return (True, ext)
 return (False, '')
 ### isexecutable(TST, ext = '.sh') #
@@ -292,7 +292,7 @@ def CheckExec(cmd) :
 x = isexecutable(os.path.join(p,cmd),'')
 if x[0]:
 return os.path.join(p, cmd + x[1])
-return ""
+return ''
 ### CheckExec(cmd) #
 
 import argparse
@@ -302,16 +302,16 @@ import threading
 (F_SKIP, F_OK, F_WARN, F_SOCK, F_ERROR, F_TIME, F_ABRT, F_RECU, F_SEGV, 
F_FAIL) = range(10)
 
 FAILURES = {
-F_SKIP  : ("F_SKIP",  '-'),
-F_OK: ("F_OK",'o'),
-F_WARN  : ("F_WARN",  'x'),
-F_SOCK  : ("F_SOCK",  'S'),
-F_ERROR : ("F_ERROR", 'X'),
-F_TIME  : ("F_TIME",  'T'),
-F_ABRT  : ("F_ABRT",  'A'),
-F_RECU  : ("F_RECU",  'R'),
-F_SEGV  : ("F_SEGV",  'C'),
-F_FAIL  : ("F_FAIL",  'F'),
+F_SKIP  : ('F_SKIP',  '-'),
+F_OK: ('F_OK','o'),
+F_WARN  : ('F_WARN',  'x'),
+F_SOCK  : ('F_SOCK',  'S'),
+F_ERROR : ('F_ERROR', 'X'),
+F_TIME  : ('F_TIME',  'T'),
+F_ABRT  : ('F_ABRT',  'A'),
+F_RECU  : ('F_RECU',  'R'),
+F_SEGV  : ('F_SEGV',  'C'),
+F_FAIL  : ('F_FAIL',  'F'),
 }
 
 CONDITIONALS = {
@@ -320,28 +320,28 @@ CONDITIONALS = {
 # from configure.ag:
 # These should cover all AM_CONDITIONALS defined in configure.ag, i.e.,
 # `grep AM_CONDITIONAL configure.ag | sed 
's|^AM_CONDITIONAL(\([^,]*\),.*$|\1|' | sort -u`
-'HAVE_CUDF': "@HAVE_CUDF_FALSE@",
-'HAVE_CURL': "@HAVE_CURL_FALSE@",
-'HAVE_FITS': "@HAVE_FITS_FALSE@",
-'HAVE_GEOM': "@HAVE_GEOM_FALSE@",
-'HAVE_HGE' : "@HAVE_HGE_FALSE@",
-'HAVE_LIBBZ2'  : "@HAVE_LIBBZ2_FALSE@",
-'HAVE_LIBLZ4'  : "@HAVE_LIBLZ4_FALSE@",
-'HAVE_LIBLZMA' : "@HAVE_LIBLZMA_FALSE@",
-'HAVE_LIBPCRE' : "@HAVE_LIBPCRE_FALSE@",
-'HAVE_LIBPY3'  : "@HAVE_LIBPY3_FALSE@",
-'HAVE_LIBR': "@HAVE_LIBR_FALSE@",
-'HAVE_LIBXML'  : "@HAVE_LIBXML_FALSE@",
-'HAVE_LIBZ': "@HAVE_LIBZ_FALSE@",
-'HAVE_NETCDF'  : "@HAVE_NETCDF_FALSE@",
-'HAVE_ODBC': "@HAVE_ODBC_FALSE@",
-'HAVE_OPENSSL' : "@HAVE_OPENSSL_FALSE@",
-'HAVE_PROJ': "@HAVE_PROJ_FALSE@",
-'HAVE_SHP' : "@HAVE_SHP_FALSE@",
-'HAVE_GETENTROPY'  : "@HAVE_GETENTROPY_FALSE@",
-'NATIVE_WIN32' : "@NATIVE_WIN32_FALSE@",
-'NOT_WIN32': "@NOT_WIN32_FALSE@",
-'SANITIZER': "@SANITIZER_FALSE@",
+'HAVE_CUDF': '@HAVE_CUDF_FALSE@',
+'HAVE_CURL': '@HAVE_CURL_FALSE@',
+'HAVE_FITS': '@HAVE_FITS_FALSE@',
+'HAVE_GEOM': '@HAVE_GEOM_FALSE@',
+'HAVE_HGE' : '@HAVE_HGE_FALSE@',
+'HAVE_LIBBZ2'  : '@HAVE_LIBBZ2_FALSE@',
+'HAVE_LIBLZ4'  : '@HAVE_LIBLZ4_FALSE@',
+'HAVE_LIBLZMA' : '@HAVE_LIBLZMA_FALSE@',
+'HAVE_LIBPCRE' : '@HAVE_LIBPCRE_FALSE@',
+'HAVE_LIBPY3'  : '@HAVE_LIBPY3_FALSE@',
+'HAVE_LIBR': '@HAVE_LIBR_FALSE@',
+'HAVE_LIBXML'  : '@HAVE_LIBXML_FALSE@',
+'HAVE_LIBZ': '@HAVE_LIBZ_FALSE@',
+'HAVE_NETCDF'  : '@HAVE_NETCD

MonetDB: Aug2024 - Simplify exe "structure".

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: 6cc764636f7f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6cc764636f7f
Modified Files:
testing/Mtest.py.in
Branch: Aug2024
Log Message:

Simplify exe "structure".


diffs (147 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1272,7 +1272,7 @@ def PerformDir(env, testdir, testlist, t
 else:
 vaultopt = []
 if not oneserver:
-pSrvr = ServerClass(env['exe']['mserver5'][1] + 
[f'--dbpath={LogDBdir}'] + vaultopt + mserver5_opts, open(os.devnull, 'w'), 
open(os.devnull, 'w'), par['TIMEOUT'], os.path.join(LogDBdir, '.started'), 
TSTDB, dbg=env.get('DBG'))
+pSrvr = ServerClass(env['exe']['mserver5'] + 
[f'--dbpath={LogDBdir}'] + vaultopt + mserver5_opts, open(os.devnull, 'w'), 
open(os.devnull, 'w'), par['TIMEOUT'], os.path.join(LogDBdir, '.started'), 
TSTDB, dbg=env.get('DBG'))
 pSrvr.LaunchIt()
 pSrvr.terminate()
 if not os.path.exists(TSTTRGDIR):
@@ -1298,12 +1298,12 @@ def PerformDir(env, testdir, testlist, t
 if o != 'nodrop':
 opts.append(o)
 if inmem:
-cmd = env['exe']['mserver5'][1] + ['--set', 
f'gdk_dbname={TSTDB}', '--in-memory'] + mserver5_opts + opts
+cmd = env['exe']['mserver5'] + ['--set', 
f'gdk_dbname={TSTDB}', '--in-memory'] + mserver5_opts + opts
 pollfile = None
 cmd.append('--set')
 cmd.append(f'gdk_dbtrace={os.path.join(LogDBdir, 
"mdbtrace.log")}')
 else:
-cmd = env['exe']['mserver5'][1] + 
[f'--dbpath={LogDBdir}'] + mserver5_opts + opts
+cmd = env['exe']['mserver5'] + 
[f'--dbpath={LogDBdir}'] + mserver5_opts + opts
 pollfile = os.path.join(LogDBdir, '.started')
 if os.path.exists(keyfile):
 cmd.extend(['--set', f'monet_vault_key={keyfile}'])
@@ -1637,7 +1637,7 @@ def returnCode(proc, f = None):
 def GetBitsAndModsAndThreads(env) :
 global setpgrp
 rtrn = 0
-cmd = env['exe']['mserver5'][1].copy()
+cmd = env['exe']['mserver5'].copy()
 dbpath = os.path.join(env['GDK_DBFARM'], TSTPREF)
 try:
 os.unlink(os.path.join(dbpath, '.started'))
@@ -2041,20 +2041,26 @@ def RunTest(env, TST, COND, oktests, len
 elif MissingTests:
 reason = "as required test%s '%s' failed." % ('s' if len(MissingTests) 
!= 1 else '', "', '".join(MissingTests))
 elem = SkipTest(env, TST, EXT, reason, length)
-elif EXT == ".sql" and  not env['exe']['SQL_Client'][0]:
-reason = "as %s is not available." % env['SQLCLIENT'].split(None, 1)[0]
+elif EXT == ".sql" and 'SQL_Client' not in env['exe']:
+reason = f"as {env['SQLCLIENT'].split(None, 1)[0]} is not available."
 elem = SkipTest(env, TST, EXT, reason, length)
-elif EXT == ".sql" and  not env['exe']['SQL_Dump'][0]:
-reason = "as %s is not available." % env['SQLDUMP'].split(None, 1)[0]
+elif EXT == ".sql" and 'SQL_Dump' not in env['exe']:
+reason = f"as {env['SQLDUMP'].split(None, 1)[0]} is not available."
+elem = SkipTest(env, TST, EXT, reason, length)
+elif CALL == 'ruby' and 'ruby_client' not in env['exe']:
+reason = f"as {env['RUBYCLIENT'].split(None, 1)[0]} is not available."
 elem = SkipTest(env, TST, EXT, reason, length)
-elif SERVER == "SQL" and not env['exe']['mserver5'][0]:
-reason = "as %s is not available." % env['MSERVER'].split(None, 1)[0]
+elif CALL == 'R' and 'R_client' not in env['exe']:
+reason = f"as {env['RCLIENT'].split(None, 1)[0]} is not available."
 elem = SkipTest(env, TST, EXT, reason, length)
-elif EXT == ".malS" and not env['exe']['mserver5'][0]:
-reason = "as %s is not available." % env['MSERVER'].split(None, 1)[0]
+elif SERVER == "SQL" and 'mserver5' not in env['exe']:
+reason = f"as {env['MSERVER'].split(None, 1)[0]} is not available."
+elem = SkipTest(env, TST, EXT, reason, length)
+elif EXT == ".malS" and 'mserver5' not in env['exe']:
+reason = f"as {env['MSERVER'].split(None, 1)[0]} is not available."
 elem = SkipTest(env, TST, EXT, reason, length)
 elif MissingMods:
-reason = "as modules '%s` are missing." % str(MissingMods)
+reason = f"as modules '{MissingMods}` are missing."
 elem = SkipTest(env, TST, EXT, reason, length)
 elif skip_timeout and os.path.isfile(os.path.join(TSTSRCDIR, 
TST+".timeout")):
 reason = "test with timeout"
@@ -2837,7 +2843,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
 ClntErr = openutf8(ClntErrFile,"w")
 
 if PSRVR is None:
-Srvr = exe['mserver5'][1].copy()
+

MonetDB: Aug2024 - Remove support for .MAL.py tests.

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: 4a2d2b92c61a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4a2d2b92c61a
Modified Files:
testing/Mtest.py.in
Branch: Aug2024
Log Message:

Remove support for .MAL.py tests.


diffs (72 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1862,15 +1862,10 @@ def RunTest(env, TST, COND, oktests, len
 x  = isexecutable(TST)
 if not x[0]:
 x  = isexecutable(TST,'')
-xA = isexecutable(TST + ".MAL")
 xS = isexecutable(TST + ".SQL")
 if   x[0]:
 EXT = x[1]
 CALL = "other"
-elif xA[0]:
-EXT = ".MAL"+xA[1]
-CALL = "other"
-SERVER = "MAL"
 elif xS[0]:
 EXT = ".SQL"+xS[1]
 CALL = "other"
@@ -1881,7 +1876,6 @@ def RunTest(env, TST, COND, oktests, len
 ('.test', '.test',   'sqltest','SQL'),
 ('.maltest',  '.maltest','maltest','SQL'),
 ('.py',   '.py', 'python', ''),
-('.MAL.py',   '.MAL.py', 'python', 'MAL'),
 ('.SQL.py',   '.SQL.py', 'python', 'SQL'),
 ('.sql',  '.sql','sql','SQL'),
 ('.R','.R',  'R',  'SQL'),
@@ -2053,7 +2047,7 @@ def RunTest(env, TST, COND, oktests, len
 elif EXT == ".sql" and  not env['exe']['SQL_Dump'][0]:
 reason = "as %s is not available." % env['SQLDUMP'].split(None, 1)[0]
 elem = SkipTest(env, TST, EXT, reason, length)
-elif SERVER in ["MAL", "SQL"] and not env['exe']['mserver5'][0]:
+elif SERVER == "SQL" and not env['exe']['mserver5'][0]:
 reason = "as %s is not available." % env['MSERVER'].split(None, 1)[0]
 elem = SkipTest(env, TST, EXT, reason, length)
 elif EXT == ".malS" and not env['exe']['mserver5'][0]:
@@ -2830,7 +2824,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
 else:
 nodrop = False
 try:
-if SERVER in ["MAL", "SQL"]:
+if SERVER == "SQL":
 SrvrOutFile = TST+".server.out"
 SrvrErrFile = TST+".server.err"
 SrvrOut = openutf8(SrvrOutFile,"w")
@@ -2884,7 +2878,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
 ClntOut = openutf8(TestOutFile, 'a')
 ClntErr = openutf8(TestErrFile, 'a')
 
-if SERVER not in ["MAL", "SQL"] or pSrvr.started:
+if SERVER != "SQL" or pSrvr.started:
 if   CALL == "other":
 cmd = [os.path.join(".", TST + EXT), TST]
 returncode = RunIt(cmd, False, "", ClntOut, ClntErr, TIMEOUT, 
pSrvr)
@@ -3009,7 +3003,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
 if PSRVR is not None:
 PSRVR.stop()
 # PSRVR.timer.cancel()
-if SERVER in ["MAL", "SQL"] and pSrvr is not None:
+if SERVER == "SQL" and pSrvr is not None:
 if PSRVR is None and pSrvr.started:
 pSrvr.terminate()
 if procdebug:
@@ -3866,7 +3860,7 @@ def main(argv) :
 ErrXit("%s: not a valid test name" % args[0])
 args = [head]
 if tail != 'All':
-for ext in ('.test', '.maltest', 'MAL.py', '.SQL.py',
+for ext in ('.test', '.maltest', '.SQL.py',
 '.sql', '.py', '.R', '.rb', ''):
 # extensions .in and .src are never combined
 if tail.endswith(ext + '.in'):
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Aug2024 - Add TIMEOUT to environment during testing.

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: 0cb98deadb20 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0cb98deadb20
Modified Files:
testing/Mtest.py.in
Branch: Aug2024
Log Message:

Add TIMEOUT to environment during testing.


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
@@ -2726,6 +2726,8 @@ def RunIt(cmd, onechild, TestIn, TestOut
 if procdebug:
 print('RunIt: starting process "%s"\n' % '" "'.join(cmd))
 setpgrp = True
+if TimeOut:
+os.environ['TIMEOUT'] = str(TimeOut)
 with process.Popen(cmd, stdin=TestIn, stdout=TestOut,
stderr=TestErr, text=True) as proc:
 proc.killed = False
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Aug2024 - Python 3.6 compatibility.

2025-01-30 Thread Sjoerd Mullender via checkin-list
Changeset: 27d155c69583 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/27d155c69583
Modified Files:
testing/Mtest.py.in
testing/listexports.py
testing/process.py
Branch: Aug2024
Log Message:

Python 3.6 compatibility.


diffs (100 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1306,7 +1306,7 @@ def PerformDir(env, testdir, testlist, t
 cmd = env['exe']['mserver5'] + ['--set', 
f'gdk_dbname={TSTDB}', '--in-memory'] + mserver5_opts + opts
 pollfile = None
 cmd.append('--set')
-cmd.append(f'gdk_dbtrace={os.path.join(LogDBdir, 
'mdbtrace.log')}')
+cmd.append(f'gdk_dbtrace={os.path.join(LogDBdir, 
"mdbtrace.log")}')
 else:
 cmd = env['exe']['mserver5'] + 
[f'--dbpath={LogDBdir}'] + mserver5_opts + opts
 pollfile = os.path.join(LogDBdir, '.started')
@@ -2903,7 +2903,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
 Srvr.append('--dbpath=%s' % dbpath)
 if os.path.exists(os.path.join(dbpath, '.vaultkey')):
 Srvr.extend(['--set',
- f'monet_vault_key={os.path.join(dbpath, 
'.vaultkey')}'])
+ f'monet_vault_key={os.path.join(dbpath, 
".vaultkey")}'])
 if env.get('MULTIFARM'):
 Srvr.append('--dbextra=%s' % 
os.path.join(env['GDK_DBFARM'], TSTDB + '_transient'))
 shutil.rmtree(os.path.join(env['GDK_DBFARM'], TSTDB + 
'_transient'),
@@ -4234,7 +4234,7 @@ VALUES (%s, '%s', '%s', '%s',
 print()
 print(f'failed={Failed}, skipped={len(Failure[F_SKIP])}')
 if produce_html and (Failed or errseen):
-print(f'see {urllib.parse.urlunsplit(('file', '', 
urllib.request.pathname2url(os.path.join(TSTTRGBASE, TSTPREF, 'index.html')), 
'', ''))}')
+print(f'see {urllib.parse.urlunsplit(("file", "", 
urllib.request.pathname2url(os.path.join(TSTTRGBASE, TSTPREF, "index.html")), 
"", ""))}')
 print(f'Ran {num_tests - len(Failure[F_SKIP])} tests in 
{t_:7.3f}s')
 elif Failed:
 print('''\
diff --git a/testing/listexports.py b/testing/listexports.py
--- a/testing/listexports.py
+++ b/testing/listexports.py
@@ -109,7 +109,7 @@ def getrepofiles():
 import subprocess
 with subprocess.Popen(['hg', '--config', 'ui.verbose=False', 'files', 
'-I', '**.[ch]'],
   stdout=subprocess.PIPE,
-  text=True) as p:
+  universal_newlines=True) as p:
 out, err = p.communicate()
 fileset = set([os.path.join(srcdir, f) for f in filter(None, 
out.split('\n'))])
 else:
diff --git a/testing/process.py b/testing/process.py
--- a/testing/process.py
+++ b/testing/process.py
@@ -99,13 +99,14 @@ class _BufferedPipe:
 self._thread = threading.Thread(target=self._readerthread,
 args=(fd, self._queue))
 # self._thread.daemon = True
+self._continue = True
 self._thread.start()
 
 def _readerthread(self, fh, q):
 s = 0
 w = 0
 first = True
-while True:
+while self._continue:
 if verbose:
 print('fh.readline', flush=True)
 c = fh.readline()
@@ -117,20 +118,19 @@ class _BufferedPipe:
 self._nl = b'\n'
 self._cr = b'\r'
 first = False
-try:
-if not c:
-q.put(c)# put '' if at EOF
-break
-c = c.replace(self._cr, self._empty)
-if c:
-q.put(c)
-except queue.ShutDown:
+if not self._continue:
 break
+if not c:
+q.put(c)# put '' if at EOF
+break
+c = c.replace(self._cr, self._empty)
+if c:
+q.put(c)
 
 def close(self):
 if verbose:
 print('close _BufferedPipe', flush=True)
-self._queue.shutdown()
+self._continue = False
 if self._thread:
 if verbose:
 print('close: joining', flush=True)
@@ -167,9 +167,6 @@ class _BufferedPipe:
 except queue.Empty:
 print('queue.empty', flush=True)
 break
-except queue.ShutDown:
-print('queue shut down', flush=True)
-break
 if len(c) > size > 0:
 ret.append(c[:size])
 self._cur = c[size:]
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email 

MonetDB: default - Implements -b option that enables indent for ...

2025-01-30 Thread stefanos mavros via checkin-list
Changeset: 7a6458e25242 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7a6458e25242
Modified Files:
sql/server/sqlparse.c
Branch: default
Log Message:

Implements -b option that enables indent for sqlparse

for now only available for WHERE's propositional logic statements


diffs (168 lines):

diff --git a/sql/server/sqlparse.c b/sql/server/sqlparse.c
--- a/sql/server/sqlparse.c
+++ b/sql/server/sqlparse.c
@@ -155,11 +155,11 @@ qname_schema_object(dlist *qname)
 }
 
 
-static char * sp_symbol2string(mvc *sql, symbol *se, int expression, char 
**err, int depth);
+static char * sp_symbol2string(mvc *sql, symbol *se, int expression, char 
**err, int depth, bool indent);
 static char * dlist2string(mvc *sql, dlist *l, char *sep, char *lb, char *rb, 
int expression, char **err, int depth, bool indent);
 
 static char *
-dnode2string(mvc *sql, dnode *n, int expression, char **err, int depth)
+dnode2string(mvc *sql, dnode *n, int expression, char **err, int depth, bool 
indent)
 {
char *s = NULL;
if (n->type == type_string) {
@@ -176,9 +176,9 @@ dnode2string(mvc *sql, dnode *n, int exp
snprintf(buf, sizeof(buf), LLFMT, n->data.l_val);
s = sa_strdup(sql->ta, buf);
} else if (n->type == type_symbol) {
-   s = sp_symbol2string(sql, n->data.sym, expression, err, depth);
+   s = sp_symbol2string(sql, n->data.sym, expression, err, depth, 
indent);
} else if (n->type == type_list) {
-   s = dlist2string(sql, n->data.lval, ", ", "( ", " )", 
expression, err, depth, false);
+   s = dlist2string(sql, n->data.lval, ", ", "( ", " )", 
expression, err, depth, indent);
} else if (n->type == type_type) {
s = sql_subtype_string(sql->ta, &n->data.typeval);
}
@@ -197,7 +197,7 @@ dlist2string(mvc *sql, dlist *l, char *s
 
bool first_el = lb;
for (n=l->h; n; n = n->next) {
-   char *s = dnode2string(sql, n, expression, err, depth);
+   char *s = dnode2string(sql, n, expression, err, depth, indent);
 
if (!s)
return NULL;
@@ -284,7 +284,7 @@ sa_concat(allocator *sa, char *prefix, c
 }
 
 static char *
-sp_symbol2string(mvc *sql, symbol *se, int expression, char **err, int depth)
+sp_symbol2string(mvc *sql, symbol *se, int expression, char **err, int depth, 
bool indent)
 {
if (!se)
return "EMPTY SYMBOL";
@@ -294,17 +294,17 @@ sp_symbol2string(mvc *sql, symbol *se, i
SelectNode *s = (SelectNode*)se;
char *res = s->distinct?"SELECT DISTINCT (\n":"SELECT (\n";
if (s->from)
-   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->from, expression, err, depth), "\n");
+   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->from, expression, err, depth, indent), "\n");
if (s->where)
-   res = sa_concat(sql->ta, "", res, "WHERE ", 
sp_symbol2string(sql, s->where, expression, err, depth + 1), "\n");
+   res = sa_concat(sql->ta, "", res, "WHERE ", 
sp_symbol2string(sql, s->where, expression, err, depth + 1, indent), "\n");
if (s->groupby)
-   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->groupby, expression, err, depth), "\n");
+   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->groupby, expression, err, depth, indent), "\n");
if (s->having)
-   res = sa_concat(sql->ta, "", res, "HAVING ", 
sp_symbol2string(sql, s->having, expression, err, depth), "\n");
+   res = sa_concat(sql->ta, "", res, "HAVING ", 
sp_symbol2string(sql, s->having, expression, err, depth, indent), "\n");
if (s->orderby)
-   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->orderby, expression, err, depth), "\n");
+   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->orderby, expression, err, depth, indent), "\n");
if (s->selection)
-   res = sa_concat(sql->ta, "", res, "SELECTION ", 
dlist2string(sql, s->selection, ", ", "( ", " )", expression, err, depth, 
false), "\n");
+   res = sa_concat(sql->ta, "", res, "SELECTION ", 
dlist2string(sql, s->selection, ", ", "(", ")", expression, err, depth, 
indent), "\n");
return res;
}
case SQL_NOP: {
@@ -324,7 +324,7 @@ sp_symbol2string(mvc *sql, symbol *se, i
return NULL;
 
for (aux = ops; aux; aux = aux->next) {
-   if (!(inputs[i] = sp_symbol2string(sql, aux->data.sym, 
expression, err, depth))) {
+   if (!(inputs[i] = sp_symbol2string(sql, aux->data.sym, 
expression, err, depth, false))) {

MonetDB: default - Small changes in sqlparse output

2025-01-30 Thread stefanos mavros via checkin-list
Changeset: f698475e43c6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f698475e43c6
Modified Files:
sql/server/sqlparse.c
Branch: default
Log Message:

Small changes in sqlparse output


diffs (70 lines):

diff --git a/sql/server/sqlparse.c b/sql/server/sqlparse.c
--- a/sql/server/sqlparse.c
+++ b/sql/server/sqlparse.c
@@ -294,17 +294,17 @@ sp_symbol2string(mvc *sql, symbol *se, i
SelectNode *s = (SelectNode*)se;
char *res = s->distinct?"SELECT DISTINCT (\n":"SELECT (\n";
if (s->from)
-   res = sa_concat(sql->ta, " ", res, NULL, 
sp_symbol2string(sql, s->from, expression, err, depth), "\n");
+   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->from, expression, err, depth), "\n");
if (s->where)
-   res = sa_concat(sql->ta, " ", res, "WHERE ", 
sp_symbol2string(sql, s->where, expression, err, depth + 1), "\n");
+   res = sa_concat(sql->ta, "", res, "WHERE ", 
sp_symbol2string(sql, s->where, expression, err, depth + 1), "\n");
if (s->groupby)
-   res = sa_concat(sql->ta, " ", res, NULL, 
sp_symbol2string(sql, s->groupby, expression, err, depth), "\n");
+   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->groupby, expression, err, depth), "\n");
if (s->having)
-   res = sa_concat(sql->ta, " ", res, "HAVING ", 
sp_symbol2string(sql, s->having, expression, err, depth), "\n");
+   res = sa_concat(sql->ta, "", res, "HAVING ", 
sp_symbol2string(sql, s->having, expression, err, depth), "\n");
if (s->orderby)
-   res = sa_concat(sql->ta, " ", res, NULL, 
sp_symbol2string(sql, s->orderby, expression, err, depth), "\n");
+   res = sa_concat(sql->ta, "", res, NULL, 
sp_symbol2string(sql, s->orderby, expression, err, depth), "\n");
if (s->selection)
-   res = sa_concat(sql->ta, " ", res, "SELECTION ", 
dlist2string(sql, s->selection, ", ", "( ", " )", expression, err, depth, 
false), "\n");
+   res = sa_concat(sql->ta, "", res, "SELECTION ", 
dlist2string(sql, s->selection, ", ", "( ", " )", expression, err, depth, 
false), "\n");
return res;
}
case SQL_NOP: {
@@ -324,7 +324,7 @@ sp_symbol2string(mvc *sql, symbol *se, i
return NULL;
 
for (aux = ops; aux; aux = aux->next) {
-   if (!(inputs[i] = sp_symbol2string(sql, aux->data.sym, 
expression, err, 0))) {
+   if (!(inputs[i] = sp_symbol2string(sql, aux->data.sym, 
expression, err, depth))) {
return NULL;
}
inputs_length += strlen(inputs[i]);
@@ -437,7 +437,7 @@ sp_symbol2string(mvc *sql, symbol *se, i
/* generic */
if (se->type == type_list) {
char *tok_str = token2string(se->token);
-   char *args = dlist2string(sql, se->data.lval, ", ", "( 
", " )", expression, err, depth, false);
+   char *args = dlist2string(sql, se->data.lval, ", ", " 
(", " )", expression, err, depth, false);
char *res;
 
if (!args)
@@ -447,7 +447,7 @@ sp_symbol2string(mvc *sql, symbol *se, i
return res;
} else if (se->type == type_symbol) {
char *tok_str = token2string(se->token);
-   char *sym = sp_symbol2string(sql, se->data.sym, 
expression, err, 0);
+   char *sym = sp_symbol2string(sql, se->data.sym, 
expression, err, depth);
char *res;
 
if ((res = SA_NEW_ARRAY(sql->ta, char, strlen(tok_str) 
+ strlen(sym) + 5)))
@@ -523,12 +523,12 @@ main(int argc, char *argv[])
char *res = sp_symbol2string(m, m->sym, 1, &err, 0);
 
if (err)
-   printf("ERROR: %s\n", err);
+   printf("ERROR:\n%s\n", err);
else
-   printf("SYM: %s\n", res);
+   printf("SYM:\n%s\n", res);
} else {
if (m->session->status)
-   printf("ERROR: %s\n", m->errstr);
+   printf("ERROR:\n%s\n", m->errstr);
}
scanner_query_processed(&m->scanner);
m->sym = NULL;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Fixes crash in sqlparse's indent option

2025-01-30 Thread stefanos mavros via checkin-list
Changeset: 8bc4b838f165 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8bc4b838f165
Modified Files:
sql/server/sqlparse.c
Branch: default
Log Message:

Fixes crash in sqlparse's indent option


diffs (12 lines):

diff --git a/sql/server/sqlparse.c b/sql/server/sqlparse.c
--- a/sql/server/sqlparse.c
+++ b/sql/server/sqlparse.c
@@ -227,7 +227,7 @@ dlist2string(mvc *sql, dlist *l, char *s
}
if (rb) {
/* here we do (depth - 1) * tab + 1 * newline to align with the 
parent op */
-   size_t depth_chars = indent ? depth : 0;
+   size_t depth_chars = indent ? (depth > 0 ? depth : 1) : 0;
 
char *o = SA_NEW_ARRAY(sql->ta, char, depth_chars + strlen(b) + 
strlen(rb) + 1);
if (o) {
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: odbc_loader - Correct some comments

2025-01-30 Thread Martin van Dinther via checkin-list
Changeset: 0e8ad29683f4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0e8ad29683f4
Modified Files:
sql/server/rel_file_loader.h
sql/server/rel_select.c
Branch: odbc_loader
Log Message:

Correct some comments


diffs (42 lines):

diff --git a/sql/server/rel_file_loader.h b/sql/server/rel_file_loader.h
--- a/sql/server/rel_file_loader.h
+++ b/sql/server/rel_file_loader.h
@@ -17,8 +17,7 @@
 #include "sql_mvc.h"
 
 typedef str (*fl_add_types_fptr)(mvc *sql, sql_subfunc *f, char *filename, 
list *res_exps, char *name);
-typedef void *(*fl_load_fptr)(void *be, sql_subfunc *f, char *filename, 
sql_exp *topn); /* use void * as both return type and be
-   

argument are unknown types at this layer */
+typedef void *(*fl_load_fptr)(void *be, sql_subfunc *f, char *filename, 
sql_exp *topn); /* use void * as both return type and be argument are unknown 
types at this layer */
 
 typedef struct file_loader_t {
char *name;
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -768,7 +768,7 @@ proto_loader_add_table_column_types(mvc 
if (!proto)
return "URI scheme missing";
 
-   // check uri scheme on supported protocols (e.g. must be: 'file' or 
'odbc' or 'monetdb')
+   // find uri scheme in registered protocols (e.g. is: 'file' or 
'monetdb' or 'odbc')
proto_loader_t *pl = pl_find(proto);
if (!pl)
return sa_message(sql->ta, "URI protocol '%s' not supported", 
proto?proto:"");
@@ -794,7 +794,6 @@ rel_proto_loader(mvc *sql, list *exps, l
 
if ((f = bind_func_(sql, NULL, "proto_loader", tl, F_UNION, true, 
&found, false))) {
list *nexps = exps;
-   // TODO: test uri scheme on supported protocols (e.g. must be: 
'file' or 'odbc' or 'monetdb')
if (list_empty(tl) || f->func->vararg || (nexps = 
check_arguments_and_find_largest_any_type(sql, NULL, exps, f, 1, false))) {
list *res_exps = sa_list(sql->sa);
if (list_length(exps) == 1 && f && f->func->varres && 
strlen(f->func->mod) == 0 && strlen(f->func->imp) == 0) {
@@ -3798,7 +3797,7 @@ static sql_exp *
sql_exp *e = exp_aggr(sql->sa, exps, a, distinct, no_nil, 
groupby?groupby->card:CARD_ATOM, hasnil);
 
if (!obe && a->func->order_required && !handled_order) {
-   /* TODO preper error on missing order by */
+   /* TODO proper error on missing order by */
return NULL;
}
if (obe && !a->func->order_required && !a->func->opt_order)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: odbc_loader - Added checks on url, extract ODBC connect...

2025-01-30 Thread Martin van Dinther via checkin-list
Changeset: aeb9d08b4d80 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/aeb9d08b4d80
Modified Files:
sql/backends/monet5/vaults/odbc/odbc_loader.c
Branch: odbc_loader
Log Message:

Added checks on url, extract ODBC connection string part and SQL query string 
part.


diffs (121 lines):

diff --git a/sql/backends/monet5/vaults/odbc/odbc_loader.c 
b/sql/backends/monet5/vaults/odbc/odbc_loader.c
--- a/sql/backends/monet5/vaults/odbc/odbc_loader.c
+++ b/sql/backends/monet5/vaults/odbc/odbc_loader.c
@@ -27,8 +27,6 @@
 #include 
 
 typedef struct odbc_loader_t {
-   char *url;
-   SQLCHAR *query;
SQLHANDLE env;
SQLHANDLE dbc;
SQLHANDLE stmt;
@@ -67,22 +65,33 @@ odbc_relation(mvc *sql, sql_subfunc *f, 
 // list *typelist = sa_list(sql->sa);
 // list *nameslist = sa_list(sql->sa);
 
-   // TODO validate the url, should/could start with 'odbc:', if so
-   // remove 'odbc:' prefix from url so we get an ODBC connection string
+   if (!url || (url && strncasecmp("odbc:", url, 5) != 0))
+   return "Invalid URI. Expected to start with 'odbc:'.";
+
+   // skip 'odbc:' prefix from url so we get a connection string including 
the query
+   char * con_str = &url[5];
+   // the connection string must start with 'DSN=' or 'DRIVER=' else the 
ODBC driver manager can't load the ODBC driver
+   if (con_str && (strncasecmp("DSN=", con_str, 4) != 0) && 
(strncasecmp("DRIVER=", con_str, 7) != 0))
+   return "Invalid ODBC connection string. Should start with 
'DSN=' or 'DRIVER='.";
 
-   SQLCHAR * con_str = (SQLCHAR *) url;
-   // TODO validate the ODBC connection string, should start with 'DSN=' 
or 'DRIVER='
+   // locate the 'QUERY=' part to extract the SQL query string to execute
+   char * qry_str = strstr(con_str, "QUERY=");
+   if (qry_str == NULL)
+   return "Incomplete ODBC connection string. Missing 'QUERY=' 
part (to specify the SQL SELECT query to execute).";
 
-   // TODO get the SQL query string. Not from the url but from an 
additional provided parameter
-   // for test we use a static query:
-   SQLCHAR * query = (SQLCHAR *) "SELECT * FROM INFORMATION_SCHEMA.TABLES";
+   char * query = GDKstrdup(&qry_str[6]);  // we expect that QUERY= is at 
the end of the connection string
+
+   // create a new ODBC connection string without the QUERY= part
+   char * odbc_con_str = GDKstrndup(con_str, qry_str - con_str);
 
SQLHANDLE env = SQL_NULL_HENV;
SQLHANDLE dbc = SQL_NULL_HDBC;
SQLHANDLE stmt = SQL_NULL_HSTMT;
SQLRETURN ret;
SQLSMALLINT nr_cols = 0;
-   char * errmsg;
+   char * errmsg = NULL;
+
+   // printf("Extracted ODBC connection string: %s\nand SQL query: %s\n", 
odbc_con_str, query);
 
ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) {
@@ -91,51 +100,55 @@ odbc_relation(mvc *sql, sql_subfunc *f, 
ret = SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) 
{
SQLSMALLINT len = 0;
-   ret = SQLDriverConnect(dbc, NULL, con_str, 
SQL_NTS, NULL, 0, &len, SQL_DRIVER_NOPROMPT);
+   ret = SQLDriverConnect(dbc, NULL, (SQLCHAR *) 
odbc_con_str, SQL_NTS, NULL, 0, &len, SQL_DRIVER_NOPROMPT);
+   // printf("After SQLDriverConnect(%s)\n", 
odbc_con_str);
if (ret == SQL_SUCCESS || ret == 
SQL_SUCCESS_WITH_INFO) {
ret = SQLAllocHandle(SQL_HANDLE_STMT, 
dbc, &stmt);
if (ret == SQL_SUCCESS || ret == 
SQL_SUCCESS_WITH_INFO) {
-   ret = SQLExecDirect(stmt, 
query, SQL_NTS);
+   ret = SQLExecDirect(stmt, 
(SQLCHAR *) query, SQL_NTS);
+   // printf("After 
SQLExecDirect(%s)\n", query);
if (ret == SQL_SUCCESS || ret 
== SQL_SUCCESS_WITH_INFO) {
ret = 
SQLNumResultCols(stmt, &nr_cols);
+   // printf("Query has %d 
result columns\n", nr_cols);
// TODO for each column 
get the name, type, size/digits and scale
// 
list_append(nameslist, name);
// 
list_append(typelist, type);
} else {
-   errmsg = "ODBC 
SQLExecDirect query failed.\n";
+ 

MonetDB: odbc_loader - merge with default

2025-01-30 Thread Martin van Dinther via checkin-list
Changeset: def864f13116 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/def864f13116
Modified Files:
testing/listexports.py
Branch: odbc_loader
Log Message:

merge with default


diffs (truncated from 2815 to 300 lines):

diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -2295,7 +2295,7 @@ find_fk( mvc *sql, list *rels, list *exp
 }
 
 static int
-rels_find_one_rel( sql_rel **rels, int nr, sql_exp *e)
+exp_find_one_rel( sql_rel **rels, int nr, sql_exp *e)
 {
int fnd = 0;
 
@@ -2309,6 +2309,22 @@ rels_find_one_rel( sql_rel **rels, int n
return fnd;
 }
 
+static int
+exps_find_one_rel( sql_rel **rels, int nr, list *exps)
+{
+   int fnd = 0;
+
+   for(node *n = exps->h; n; n = n->next) {
+   int nfnd = exp_find_one_rel(rels, nr, n->data);
+   if (nfnd != fnd && fnd)
+   return 0;
+   fnd = nfnd;
+   if (!fnd)
+   return 0;
+   }
+   return fnd;
+}
+
 /* TODO move popcount and popcount64 into gdk_*.h, used in gdk_cand, strimps 
and here */
 static inline int
 popcount64(uint64_t x)
@@ -2382,18 +2398,16 @@ order_joins(visitor *v, list *rels, list
 
h[ci] = r1[ci] = r2[ci] = 0;
r3[ci] = 0;
-   /* h[ci] = exp_find_rels(cje, rels) */
-   if (cje->type != e_cmp || !is_complex_exp(cje->flag) || 
!find_prop(cje->p, PROP_HASHCOL) ||
-  (cje->type == e_cmp && cje->f == NULL)) {
+   if (cje->type == e_cmp) {
cje->tmp = ci;
-   r1[ci] = rels_find_one_rel(rels_a, nr_rels, cje->l);
-   r2[ci] = rels_find_one_rel(rels_a, nr_rels, cje->r);
+   r1[ci] = cje->flag == cmp_filter ? 
exps_find_one_rel(rels_a, nr_rels, cje->l) : exp_find_one_rel(rels_a, nr_rels, 
cje->l);
+   r2[ci] = cje->flag == cmp_filter ? 
exps_find_one_rel(rels_a, nr_rels, cje->r) : exp_find_one_rel(rels_a, nr_rels, 
cje->r);
if (r1[ci])
h[ci] |= ((ulng)1)<<((r1[ci]-1)%64);
if (r2[ci])
h[ci] |= ((ulng)1)<<((r2[ci]-1)%64);
-   if (cje->f) {
-   r3[ci] = rels_find_one_rel(rels_a, nr_rels, 
cje->f);
+   if (cje->f && cje->flag != cmp_filter) {
+   r3[ci] = exp_find_one_rel(rels_a, nr_rels, 
cje->f);
if (r3[ci] == r2[ci])
r3[ci] = 0;
if (r3[ci])
@@ -2414,8 +2428,7 @@ order_joins(visitor *v, list *rels, list
 * */
if (0 && popcount64(h[cje->tmp]) > 2)
assert(0);
-   if (cje->type != e_cmp || !is_complex_exp(cje->flag) || 
!find_prop(cje->p, PROP_HASHCOL) ||
-   (cje->type == e_cmp && cje->f == NULL)) {
+   if (cje->type == e_cmp) {
l = rels_a[r1[cje->tmp]];
r = rels_a[r2[cje->tmp]];
if (l && r)
diff --git a/sql/server/sqlparse.c b/sql/server/sqlparse.c
--- a/sql/server/sqlparse.c
+++ b/sql/server/sqlparse.c
@@ -1,5 +1,23 @@
+/*
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2024, 2025 MonetDB Foundation;
+ * Copyright August 2008 - 2023 MonetDB B.V.;
+ * Copyright 1997 - July 2008 CWI.
+ */
 
 #include "monetdb_config.h"
+#ifndef HAVE_GETOPT_LONG
+#  include "monet_getopt.h"
+#else
+# ifdef HAVE_GETOPT_H
+#  include "getopt.h"
+# endif
+#endif
 #include "stream.h"
 #include "sql_mvc.h"
 #include "sql_parser.tab.h"
@@ -7,7 +25,6 @@
 #include "sql_semantic.h"
 #include 
 
-
 extern void bat_storage_init(void *b);
 extern void bat_table_init(void *b);
 extern void bat_logger_init(void *b);
@@ -156,11 +173,11 @@ qname_schema_object(dlist *qname)
 }
 
 
-static char * sp_symbol2string(mvc *sql, symbol *se, int expression, char 
**err);
-static char * dlist2string(mvc *sql, dlist *l, char *sep, char *lb, char *rb, 
int expression, char **err);
+static char * sp_symbol2string(mvc *sql, symbol *se, int expression, char 
**err, int depth, bool indent);
+static char * dlist2string(mvc *sql, dlist *l, char *sep, char *lb, char *rb, 
int expression, char **err, int depth, bool indent);
 
 static char *
-dnode2string(mvc *sql, dnode *n, int expression, char **err)
+dnode2string(mvc *sql, dnode *n, int expression, char **err, int depth, bool 
indent)
 {
char *s = NULL;
if (n->type == ty

MonetDB: odbc_loader - Approve changed and new MAL signatures

2025-01-30 Thread Martin van Dinther via checkin-list
Changeset: 1a4be8d0a092 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1a4be8d0a092
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
Branch: odbc_loader
Log Message:

Approve changed and new MAL signatures


diffs (60 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
@@ -47376,12 +47376,12 @@ MATHunary_TANHflt
 monetdb
 epilogue
 command monetdb.epilogue():void
-MONETDBepilogue;
+MONETDBepilogue
 (empty)
 monetdb
 prelude
 pattern monetdb.prelude():void
-MONETDBprelude;
+MONETDBprelude
 (empty)
 mtime
 addmonths
@@ -49209,6 +49209,11 @@ unsafe pattern sql.next_value(X_0:str, X
 mvc_next_value
 return the next value of the sequence
 sql
+normalize_monetdb_url
+pattern sql.normalize_monetdb_url(X_0:str):str
+SQLnormalize_monetdb_url
+Normalize mapi:monetdb://, monetdb:// or monetdbs:// URL
+sql
 nth_value
 pattern sql.nth_value(X_0:any_1, X_1:lng, X_2:bit, X_3:bit, X_4:int, X_5:oid, 
X_6:oid):any_1
 SQLnth_value
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
@@ -35856,12 +35856,12 @@ MATHunary_TANHflt
 monetdb
 epilogue
 command monetdb.epilogue():void
-MONETDBepilogue;
+MONETDBepilogue
 (empty)
 monetdb
 prelude
 pattern monetdb.prelude():void
-MONETDBprelude;
+MONETDBprelude
 (empty)
 mtime
 addmonths
@@ -37664,6 +37664,11 @@ unsafe pattern sql.next_value(X_0:str, X
 mvc_next_value
 return the next value of the sequence
 sql
+normalize_monetdb_url
+pattern sql.normalize_monetdb_url(X_0:str):str
+SQLnormalize_monetdb_url
+Normalize mapi:monetdb://, monetdb:// or monetdbs:// URL
+sql
 nth_value
 pattern sql.nth_value(X_0:any_1, X_1:lng, X_2:bit, X_3:bit, X_4:int, X_5:oid, 
X_6:oid):any_1
 SQLnth_value
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: odbc_loader - Approve change. (new sys.normalize_monetd...

2025-01-30 Thread Martin van Dinther via checkin-list
Changeset: d88161ddea06 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d88161ddea06
Modified Files:
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: odbc_loader
Log Message:

Approve change. (new sys.normalize_monetdb_url() function).


diffs (57 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
@@ -2184,6 +2184,7 @@ select 'null in fkeys.delete_action', de
 [ "sys.functions", "sys",  "next_value_for",   "SYSTEM",   
"next_value",   "sql",  "Internal C",   "Scalar function",  true,   false,  
false,  true,   NULL,   "res_0","bigint",   63, 0,  "out",  
"arg_1","varchar",  0,  0,  "in",   "arg_2",
"varchar",  0,  0,  "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL
]
 [ "sys.functions", "sys",  "nextafter","SYSTEM",   "nextafter",
"mmath","Internal C",   "Scalar function",  false,  false,  false,  
false,  NULL,   "res_0","double",   53, 0,  "out",  
"arg_1","double",   53, 0,  "in",   "arg_2",
"double",   53, 0,  "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL
]
 [ "sys.functions", "sys",  "nextafter","SYSTEM",   "nextafter",
"mmath","Internal C",   "Scalar function",  false,  false,  false,  
false,  NULL,   "res_0","real", 24, 0,  "out",  "arg_1",
"real", 24, 0,  "in",   "arg_2","real", 24, 0,  "in",   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL]
+[ "sys.functions", "sys",  "normalize_monetdb_url","SYSTEM",   
"create function sys.normalize_monetdb_url(u string) returns string external 
name sql.normalize_monetdb_url;",  "sql",  "MAL",  "Scalar function",  
false,  false,  false,  true,   NULL,   "result",   "varchar",  0,  
0,  "out",  "u","varchar",  0,  0,  "in",   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL]
 [ "sys.functions", "sys",  "not",  "SYSTEM",   "not",  "calc", 
"Internal C",   "Scalar function",  false,  false,  false,  false,  NULL,   
"res_0","boolean",  1,  0,  "out",  "arg_1",
"boolean",  1,  0,  "in",   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   NULL,   
NULL,   NULL,   NU