MonetDB: txtsim - merged with default

2023-04-15 Thread Niels Nes
Changeset: c8c9990c8f46 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c8c9990c8f46
Branch: txtsim
Log Message:

merged with default


diffs (22 lines):

diff --git a/sql/backends/monet5/rel_physical.c 
b/sql/backends/monet5/rel_physical.c
--- a/sql/backends/monet5/rel_physical.c
+++ b/sql/backends/monet5/rel_physical.c
@@ -13,6 +13,9 @@
 #include "rel_exp.h"
 #include "rel_rel.h"
 
+#define IS_ORDER_BASED_AGGR(name) (strcmp((name), "quantile") == 0 || 
strcmp((name), "quantile_avg") == 0 || \
+  strcmp((name), "median") == 0 || 
strcmp((name), "median_avg") == 0) 
+
 static sql_rel *
 rel_add_orderby(visitor *v, sql_rel *rel)
 {
@@ -26,7 +29,7 @@ rel_add_orderby(visitor *v, sql_rel *rel
list *aa = e->l;
 
/* for now we only handle one sort 
order */
-   if (strcmp(af->func->base.name, 
"quantile") == 0 && aa && list_length(aa) == 2) {
+   if 
(IS_ORDER_BASED_AGGR(af->func->base.name) && aa && list_length(aa) == 2) {
sql_exp *obe = aa->h->data;
if (obe) { 
sql_rel *l = rel->l = 
rel_project(v->sql->sa, rel->l, rel_projections(v->sql, rel->l, NULL, 1, 1));
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: txtsim - merged with default

2023-04-15 Thread Niels Nes
Changeset: b12064d5209a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b12064d5209a
Branch: txtsim
Log Message:

merged with default


diffs (130 lines):

diff --git a/sql/server/sql_datetime.c b/sql/server/sql_datetime.c
--- a/sql/server/sql_datetime.c
+++ b/sql/server/sql_datetime.c
@@ -484,15 +484,15 @@ int
 process_odbc_interval(mvc *sql, itype interval, int val, sql_subtype *t, lng 
*i)
 {
assert(sql);
-   int mul = 1;
+   lng mul = 1;
int d = inttype2digits(interval, interval);
switch (interval) {
case iyear:
mul *= 12;
-   /* fall through */
+   break;
case iquarter:
mul *= 3;
-   /* fall through */
+   break;
case imonth:
break;
case iweek:
@@ -505,9 +505,13 @@ process_odbc_interval(mvc *sql, itype in
mul *= 60;
/* fall through */
case imin:
-   mul *= 6;
+   mul *= 60;
/* fall through */
case isec:
+   mul *= 1000;
+   break;
+   case insec:
+   d = 5;
break;
default:
snprintf(sql->errstr, ERRSIZE, _("Internal error: bad 
interval qualifier (%d)\n"), interval);
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -6481,19 +6481,26 @@ odbc_datetime_func:
   append_symbol(l, $3);
   $$ = _symbol_create_list( SQL_UNOP, l ); 
}
-| TIMESTAMPADD '(' odbc_tsi_qualifier ',' intval ',' search_condition ')'
+| TIMESTAMPADD '(' odbc_tsi_qualifier ',' scalar_exp ',' search_condition 
')'
{ dlist *l = L(); 
  append_list( l, append_string(L(), sa_strdup(SA, 
"timestampadd")));
  append_int(l, FALSE); /* ignore distinct */
   sql_subtype t; 
  lng i = 0;
-  if (process_odbc_interval(m, $3, $5, , ) < 0) {
+  if (process_odbc_interval(m, $3, 1, , ) < 0) {
yyerror(m, "incorrect interval");
$$ = NULL;
YYABORT;
   }
   append_symbol(l, $7);
-  append_symbol(l, _newAtomNode(atom_int(SA, , i)));
+  append_symbol(l, _symbol_create_list( SQL_BINOP, 
+ append_symbol(
+   append_symbol(
+ append_int(
+   append_list(L(), append_string(L(), sa_strdup(SA, 
"sql_mul"))),
+   FALSE), /* ignore distinct */
+ _newAtomNode(atom_int(SA, , i))),
+   $5)));
   $$ = _symbol_create_list( SQL_BINOP, l ); 
}
 | TIMESTAMPDIFF '(' odbc_tsi_qualifier ',' search_condition ',' 
search_condition ')'
@@ -6655,7 +6662,9 @@ odbc_data_type:
 ;
 
 odbc_tsi_qualifier:
-SQL_TSI_SECOND
+  SQL_TSI_FRAC_SECOND
+{ $$ = insec; }
+| SQL_TSI_SECOND
 { $$ = isec; }
 | SQL_TSI_MINUTE
 { $$ = imin; }
diff --git 
a/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test 
b/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test
--- a/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test
+++ b/sql/test/odbc-escape-sequences/Tests/time-date-interval-functions.test
@@ -260,7 +260,7 @@ 
 query T rowsort
 select {fn timestampadd(SQL_TSI_HOUR, 10, {ts '2022-11-14 14:13:12.654321'}) }
 
-2022-11-15 00:13:12
+2022-11-15 00:13:12.654321
 
 # corner cases
 query T rowsort
@@ -273,27 +273,25 @@ select sql_sub({fn timestampadd(SQL_TSI_
 
 0:00:00
 
-# TODO Implement SQL_TSI_FRAC_SECOND option
-statement error 42000!syntax error in: "select { fn 
timestampadd(sql_tsi_frac_second"
+query T rowsort
 select { fn timestampadd(SQL_TSI_FRAC_SECOND, 123, timestamp'2022-11-14 
14:13:12') }
-# 
-# 2022-11-14 14:13:12.123
+
+2022-11-14 14:13:12.123000
 
 query T rowsort
 select { fn timestampadd(SQL_TSI_SECOND, 11, timestamp'2022-11-14 14:13:12') }
 
 2022-11-14 14:13:23
 
-statement error 42000!syntax error in: "select { fn 
timestampadd(sql_tsi_second, 11.234"
+query T rowsort
 select { fn timestampadd(SQL_TSI_SECOND, 11.234, timestamp'2022-11-14 
14:13:12') }
-# 
-# 2022-11-14 14:13:23.234
+
+2022-11-14 14:13:23.234000
 
-# TODO: add support for integer expression as second argument.
-statement error 42000!syntax error in: "select { fn 
timestampadd(sql_tsi_second, 15*"
+query T rowsort
 select { fn timestampadd(SQL_TSI_SECOND, 15*60, timestamp'2022-11-14 
14:13:12') }
-# 
-# 2022-11-14 14:28:12
+
+2022-11-14 14:28:12
 
 query T rowsort
 select { fn timestampadd(SQL_TSI_MINUTE, 

MonetDB: txtsim - merged with default

2023-04-15 Thread Niels Nes
Changeset: 1f3ed84d73b9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1f3ed84d73b9
Modified Files:
sql/backends/monet5/CMakeLists.txt
Branch: txtsim
Log Message:

merged with default


diffs (truncated from 704 to 300 lines):

diff --git a/clients/odbc/ChangeLog b/clients/odbc/ChangeLog
--- a/clients/odbc/ChangeLog
+++ b/clients/odbc/ChangeLog
@@ -1,3 +1,8 @@
 # ChangeLog file for odbc
 # This file is updated with Maddlog
 
+* Thu Apr 13 2023 Martin van Dinther 
+- Enhanced SQLTables() by adding support for table type names: 'BASE TABLE',
+  'GLOBAL TEMPORARY' and 'LOCAL TEMPORARY' in parameter TableType. These are
+  synonyms of: 'TABLE', 'GLOBAL TEMPORARY TABLE' and 'LOCAL TEMPORARY TABLE'.
+
diff --git a/clients/odbc/driver/SQLTables.c b/clients/odbc/driver/SQLTables.c
--- a/clients/odbc/driver/SQLTables.c
+++ b/clients/odbc/driver/SQLTables.c
@@ -221,6 +221,18 @@ MNDBTables(ODBCStmt *stmt,
continue;
}
buf[j] = 0;
+   /* Some ODBC applications use different 
table type names.
+* Replace those names to valid MonetDB 
table type names
+* as defined in sys.tables_types */
+   if (strcmp("BASE TABLE", buf) == 0) {
+   strcpy(buf, "TABLE");
+   } else
+   if (strcmp("GLOBAL TEMPORARY", buf) == 
0) {
+   strcpy(buf, "GLOBAL TEMPORARY 
TABLE");
+   } else
+   if (strcmp("LOCAL TEMPORARY", buf) == 
0) {
+   strcpy(buf, "LOCAL TEMPORARY 
TABLE");
+   }
pos += snprintf(query + pos, querylen - 
pos, "'%s',", buf);
j = 0;
} else if (j < sizeof(buf) &&
diff --git a/clients/odbc/tests/ODBCmetadata.c 
b/clients/odbc/tests/ODBCmetadata.c
--- a/clients/odbc/tests/ODBCmetadata.c
+++ b/clients/odbc/tests/ODBCmetadata.c
@@ -529,6 +529,36 @@ main(int argc, char **argv)
"NULL   odbctst pk2cTABLE   NULL\n"
"NULL   odbctst pk_uc   TABLE   odbctst.pk_uc table comment\n");
 
+   ret = SQLTables(stmt, (SQLCHAR*)"", SQL_NTS,
+   (SQLCHAR*)"odbctst", SQL_NTS, (SQLCHAR*)"%", SQL_NTS,
+   (SQLCHAR*)"BASE TABLE,GLOBAL TEMPORARY,LOCAL 
TEMPORARY", SQL_NTS);
+   compareResult(stmt, ret, "SQLTables (odbctst, %)",
+   "Resultset with 5 columns\n"
+   "Resultset with 7 rows\n"
+   "TABLE_CAT  TABLE_SCHEM TABLE_NAME  TABLE_TYPE  
REMARKS\n"
+   "WVARCHAR(1)WVARCHAR(1024)  WVARCHAR(1024)  WVARCHAR(25)
WVARCHAR(65000)\n"
+   "NULL   odbctst CUSTOMERS   TABLE   NULL\n"
+   "NULL   odbctst LINES   TABLE   NULL\n"
+   "NULL   odbctst ORDERS  TABLE   NULL\n"
+   "NULL   odbctst fk2cTABLE   NULL\n"
+   "NULL   odbctst nopk_twoucs TABLE   odbctst.nopk_twoucs 
table comment\n"
+   "NULL   odbctst pk2cTABLE   NULL\n"
+   "NULL   odbctst pk_uc   TABLE   odbctst.pk_uc table comment\n");
+
+   // All user tables in schema tmp
+   ret = SQLTables(stmt, (SQLCHAR*)"", SQL_NTS,
+   (SQLCHAR*)"tmp", SQL_NTS, (SQLCHAR*)"%", SQL_NTS,
+   (SQLCHAR*)"'BASE TABLE','GLOBAL TEMPORARY','LOCAL 
TEMPORARY'", SQL_NTS);
+   compareResult(stmt, ret, "SQLTables (tmp, %)",
+   "Resultset with 5 columns\n"
+   "Resultset with 4 rows\n"
+   "TABLE_CAT  TABLE_SCHEM TABLE_NAME  TABLE_TYPE  
REMARKS\n"
+   "WVARCHAR(1)WVARCHAR(1024)  WVARCHAR(1024)  WVARCHAR(25)
WVARCHAR(65000)\n"
+   "NULL   tmp glbl_nopk_twoucsGLOBAL TEMPORARY TABLE  
NULL\n"
+   "NULL   tmp glbl_pk_uc  GLOBAL TEMPORARY TABLE  NULL\n"
+   "NULL   tmp tmp_nopk_twoucs LOCAL TEMPORARY TABLE   NULL\n"
+   "NULL   tmp tmp_pk_uc   LOCAL TEMPORARY TABLE   
NULL\n");
+
// All user tables and views in schema odbctst
ret = SQLTables(stmt, (SQLCHAR*)"", SQL_NTS,
(SQLCHAR*)"odbctst", SQL_NTS, (SQLCHAR*)"%", SQL_NTS,
diff --git a/clients/odbc/tests/ODBCtester.c b/clients/odbc/tests/ODBCtester.c
--- a/clients/odbc/tests/ODBCtester.c
+++ b/clients/odbc/tests/ODBCtester.c
@@ -17,7 +17,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 static void
 prerr(SQLSMALLINT tpe, SQLHANDLE hnd, const char *func, 

MonetDB: txtsim - merged with default

2023-04-12 Thread Niels Nes
Changeset: b91ab1b777ed for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b91ab1b777ed
Branch: txtsim
Log Message:

merged with default


diffs (174 lines):

diff --git a/clients/odbc/tests/ODBCtester.c b/clients/odbc/tests/ODBCtester.c
--- a/clients/odbc/tests/ODBCtester.c
+++ b/clients/odbc/tests/ODBCtester.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static void
 prerr(SQLSMALLINT tpe, SQLHANDLE hnd, const char *func, const char *pref)
@@ -81,6 +82,8 @@ compareResult(char * testname, char * te
}
 }
 
+#define LLFMT   "%" PRId64
+
 static SQLRETURN
 testGetDataTruncatedString(SQLHANDLE stmt, SWORD ctype)
 {
@@ -99,7 +102,7 @@ testGetDataTruncatedString(SQLHANDLE stm
check(ret, SQL_HANDLE_STMT, stmt, "SQLExecDirect");
 
ret = SQLRowCount(stmt, );
-   pos += snprintf(outp + pos, outp_len - pos, "SQLRowCount is %ld\n", 
RowCount);
+   pos += snprintf(outp + pos, outp_len - pos, "SQLRowCount is " LLFMT 
"\n", (int64_t) RowCount);
check(ret, SQL_HANDLE_STMT, stmt, "SQLRowCount");
 
ret = SQLNumResultCols(stmt, );
@@ -118,7 +121,7 @@ testGetDataTruncatedString(SQLHANDLE stm
 
/* test SQLGetData(SQL_C_(W)CHAR, 20) with a restricted buffer 
size (20) for the queried string value (47) */
ret = SQLGetData(stmt, (UWORD)col, (SWORD)ctype, (PTR), 
(SQLLEN)20, );
-   pos += snprintf(outp + pos, outp_len - pos, "SQLGetData(%d, %s, 
20) returns %d, vallen %ld, buf: '%s'\n", col, ctype_str, ret, vallen, buf);
+   pos += snprintf(outp + pos, outp_len - pos, "SQLGetData(%d, %s, 
20) returns %d, vallen " LLFMT ", buf: '%s'\n", col, ctype_str, ret, (int64_t) 
vallen, buf);
/* we expect SQL_SUCCESS_WITH_INFO with warning msg set, fetch 
them */
if (ret == SQL_SUCCESS_WITH_INFO) {
SQLCHAR state[6];
@@ -130,7 +133,7 @@ testGetDataTruncatedString(SQLHANDLE stm
 
/* get the next data part of the value (this is how 
SQLGetData is intended to be used to get large data in chunks) */
ret = SQLGetData(stmt, (UWORD)col, (SWORD)ctype, 
(PTR), (SQLLEN)30, );
-   pos += snprintf(outp + pos, outp_len - pos, 
"SQLGetData(%d, %s, 30) returns %d, vallen %ld, buf: '%s'\n", col, ctype_str, 
ret, vallen, buf2);
+   pos += snprintf(outp + pos, outp_len - pos, 
"SQLGetData(%d, %s, 30) returns %d, vallen " LLFMT ", buf: '%s'\n", col, 
ctype_str, ret, (int64_t) vallen, buf2);
if (ret == SQL_SUCCESS_WITH_INFO) {
ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, 
state, , msg, sizeof(msg), );
pos += snprintf(outp + pos, outp_len - pos, 
"SQLstate %s, Errnr %d, Message %s\n", (char*)state, (int)errnr, (char*)msg);
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -398,6 +398,7 @@ SQLprepareClient(Client c, const char *p
 
if (mvc_trans(m) < 0) {
// we have -1 here
+   MT_lock_set(_contextLock);
throw(INVCRED, "checkCredentials", INVCRED_INVALID_USER 
" '%s'", c->username);
}
 
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -1602,6 +1602,19 @@ push_up_table(mvc *sql, sql_rel *rel, li
return rel;
 }
 
+static bool
+exps_have_rank(list *exps)
+{
+   if (!exps)
+   return false;
+   for(node *n=exps->h; n; n = n->next) {
+   sql_exp *e = n->data;
+   if (is_analytic(e))
+   return true;
+   }
+   return false;
+}
+
 static sql_rel *
 rel_unnest_dependent(mvc *sql, sql_rel *rel)
 {
@@ -1682,7 +1695,7 @@ rel_unnest_dependent(mvc *sql, sql_rel *
}
}
 
-   if (r && is_simple_project(r->op) && 
((!exps_have_freevar(sql, r->exps) && !exps_have_unsafe(r->exps, 1)) || 
is_distinct_set(sql, l, ad))) {
+   if (r && is_simple_project(r->op) && ((!r->r && 
!exps_have_rank(r->exps)) || (!exps_have_freevar(sql, r->exps) && 
!exps_have_unsafe(r->exps, 1)) || is_distinct_set(sql, l, ad))) {
rel = push_up_project(sql, rel, ad);
return rel_unnest_dependent(sql, rel);
}
diff --git a/sql/test/SQLancer/Tests/sqlancer18.test 
b/sql/test/SQLancer/Tests/sqlancer18.test
--- a/sql/test/SQLancer/Tests/sqlancer18.test
+++ b/sql/test/SQLancer/Tests/sqlancer18.test
@@ -313,7 +313,7 @@ SELECT vx.vc0 FROM vx WHERE vx.vc0 <> AL
 1970-01-01
 NULL
 
-statement error GDK reported error: mergejoin: more than one match
+statement error GDK reported error: BATsubcross: 

MonetDB: txtsim - merged with default

2023-04-12 Thread Niels Nes
Changeset: ea7f5a6a7ad9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ea7f5a6a7ad9
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
Branch: txtsim
Log Message:

merged with default


diffs (truncated from 796 to 300 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -49511,7 +49511,7 @@ Write db snapshot to the given tar(.gz) 
 sql
 hot_snapshot
 unsafe pattern sql.hot_snapshot(X_0:str, X_1:bit):void 
-SQLhot_snapshot_wrap;
+SQLhot_snapshot;
 Write db snapshot to the given tar(.gz/.lz4/.bz/.xz) file on either server or 
client
 sql
 importColumn
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
@@ -37916,7 +37916,7 @@ Write db snapshot to the given tar(.gz) 
 sql
 hot_snapshot
 unsafe pattern sql.hot_snapshot(X_0:str, X_1:bit):void 
-SQLhot_snapshot_wrap;
+SQLhot_snapshot;
 Write db snapshot to the given tar(.gz/.lz4/.bz/.xz) file on either server or 
client
 sql
 importColumn
diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c
--- a/clients/odbc/driver/SQLGetInfo.c
+++ b/clients/odbc/driver/SQLGetInfo.c
@@ -839,7 +839,7 @@ MNDBGetInfo(ODBCDbc *dbc,
sValue = MONETDB_SERVER_NAME;
break;
case SQL_SPECIAL_CHARACTERS:
-   sValue = "!$&'()*+,-./:;<=>?@[]^`{|}~";
+   sValue = "!#$%&'()*+,-./:;<=>?@[]^`{|}~";
break;
case SQL_SQL_CONFORMANCE:
nValue = SQL_SC_SQL92_FULL;
diff --git a/clients/odbc/tests/CMakeLists.txt 
b/clients/odbc/tests/CMakeLists.txt
--- a/clients/odbc/tests/CMakeLists.txt
+++ b/clients/odbc/tests/CMakeLists.txt
@@ -30,10 +30,18 @@ target_link_libraries(ODBCmetadata
   PRIVATE
   ODBC::ODBC)
 
+add_executable(ODBCtester
+  ODBCtester.c)
+
+target_link_libraries(ODBCtester
+  PRIVATE
+  ODBC::ODBC)
+
 install(TARGETS
   ODBCgetInfo
   ODBCStmtAttr
   ODBCmetadata
+  ODBCtester
   RUNTIME
   DESTINATION
   ${CMAKE_INSTALL_BINDIR}
@@ -44,6 +52,7 @@ if(WIN32)
 $
 $
 $
+$
 DESTINATION ${CMAKE_INSTALL_BINDIR}
 OPTIONAL)
 endif()
diff --git a/clients/odbc/tests/ODBCgetInfo.c b/clients/odbc/tests/ODBCgetInfo.c
--- a/clients/odbc/tests/ODBCgetInfo.c
+++ b/clients/odbc/tests/ODBCgetInfo.c
@@ -960,7 +960,7 @@ const struct {
.info = SQL_SPECIAL_CHARACTERS,
.name = "SQL_SPECIAL_CHARACTERS",
.type = STRING,
-   .str = "!$&'()*+,-./:;<=>?@[]^`{|}~",
+   .str = "!#$%&'()*+,-./:;<=>?@[]^`{|}~",
},
{
.info = SQL_SQL_CONFORMANCE,
diff --git a/clients/odbc/tests/ODBCtester.c b/clients/odbc/tests/ODBCtester.c
new file mode 100644
--- /dev/null
+++ b/clients/odbc/tests/ODBCtester.c
@@ -0,0 +1,227 @@
+/*
+ * 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 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V.
+ */
+
+#ifdef _MSC_VER
+#include 
+#endif
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static void
+prerr(SQLSMALLINT tpe, SQLHANDLE hnd, const char *func, const char *pref)
+{
+   SQLCHAR state[6];
+   SQLINTEGER errnr;
+   SQLCHAR msg[256];
+   SQLSMALLINT msglen;
+   SQLRETURN ret;
+
+   ret = SQLGetDiagRec(tpe, hnd, 1, state, , msg, sizeof(msg), 
);
+   switch (ret) {
+   case SQL_SUCCESS_WITH_INFO:
+   if (msglen >= (signed int) sizeof(msg))
+   fprintf(stderr, "(message truncated)\n");
+   /* fall through */
+   case SQL_SUCCESS:
+   fprintf(stderr, "%s: %s: SQLstate %s, Errnr %d, Message %s\n", 
func, pref, (char*)state, (int)errnr, (char*)msg);
+   break;
+   case SQL_INVALID_HANDLE:
+   fprintf(stderr, "%s: %s, invalid handle passed to error 
function\n", func, pref);
+   break;
+   case SQL_ERROR:
+   fprintf(stderr, "%s: %s, unexpected error from 
SQLGetDiagRec\n", func, pref);
+   break;
+   case SQL_NO_DATA:
+   break;
+   default:
+   fprintf(stderr, "%s: %s, weird return value from 
SQLGetDiagRec\n", func, pref);
+   break;
+   }
+}
+
+static void
+check(SQLRETURN ret, SQLSMALLINT tpe, SQLHANDLE hnd, const char *func)
+{
+   switch (ret) {
+   case SQL_SUCCESS:
+   break;
+   case SQL_SUCCESS_WITH_INFO:
+   prerr(tpe, hnd, func, "Info");
+   break;
+   case SQL_ERROR:
+   prerr(tpe, hnd, func, "Error");
+   break;
+  

MonetDB: txtsim - merged with default

2023-04-06 Thread Niels Nes
Changeset: 48dbe00e25bf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/48dbe00e25bf
Branch: txtsim
Log Message:

merged with default


diffs (26 lines):

diff --git a/clients/odbc/tests/ODBCgetInfo.c b/clients/odbc/tests/ODBCgetInfo.c
--- a/clients/odbc/tests/ODBCgetInfo.c
+++ b/clients/odbc/tests/ODBCgetInfo.c
@@ -1080,19 +1080,19 @@ const struct {
.info = SQL_TIMEDATE_ADD_INTERVALS,
.name = "SQL_TIMEDATE_ADD_INTERVALS",
.type = INTEGER,
-   .i = 0,
+   .i = SQL_FN_TSI_SECOND | SQL_FN_TSI_MINUTE | SQL_FN_TSI_HOUR | 
SQL_FN_TSI_DAY | SQL_FN_TSI_WEEK | SQL_FN_TSI_MONTH | SQL_FN_TSI_QUARTER | 
SQL_FN_TSI_YEAR,
},
{
.info = SQL_TIMEDATE_DIFF_INTERVALS,
.name = "SQL_TIMEDATE_DIFF_INTERVALS",
.type = INTEGER,
-   .i = 0,
+   .i = SQL_FN_TSI_SECOND | SQL_FN_TSI_MINUTE | SQL_FN_TSI_HOUR | 
SQL_FN_TSI_DAY | SQL_FN_TSI_WEEK | SQL_FN_TSI_MONTH | SQL_FN_TSI_QUARTER | 
SQL_FN_TSI_YEAR,
},
{
.info = SQL_TIMEDATE_FUNCTIONS,
.name = "SQL_TIMEDATE_FUNCTIONS",
.type = INTEGER,
-   .i = SQL_FN_TD_CURRENT_DATE | SQL_FN_TD_CURRENT_TIME | 
SQL_FN_TD_CURRENT_TIMESTAMP | SQL_FN_TD_CURDATE | SQL_FN_TD_CURTIME | 
SQL_FN_TD_DAYOFMONTH | SQL_FN_TD_DAYOFWEEK | SQL_FN_TD_DAYOFYEAR | 
SQL_FN_TD_EXTRACT | SQL_FN_TD_HOUR | SQL_FN_TD_MINUTE | SQL_FN_TD_MONTH | 
SQL_FN_TD_NOW | SQL_FN_TD_QUARTER | SQL_FN_TD_SECOND | SQL_FN_TD_WEEK | 
SQL_FN_TD_YEAR,
+   .i = SQL_FN_TD_CURRENT_DATE | SQL_FN_TD_CURRENT_TIME | 
SQL_FN_TD_CURRENT_TIMESTAMP | SQL_FN_TD_CURDATE | SQL_FN_TD_CURTIME | 
SQL_FN_TD_DAYNAME | SQL_FN_TD_DAYOFMONTH | SQL_FN_TD_DAYOFWEEK | 
SQL_FN_TD_DAYOFYEAR | SQL_FN_TD_EXTRACT | SQL_FN_TD_HOUR | SQL_FN_TD_MINUTE | 
SQL_FN_TD_MONTH | SQL_FN_TD_MONTHNAME | SQL_FN_TD_NOW | SQL_FN_TD_QUARTER | 
SQL_FN_TD_SECOND | SQL_FN_TD_TIMESTAMPADD | SQL_FN_TD_TIMESTAMPDIFF | 
SQL_FN_TD_WEEK | SQL_FN_TD_YEAR,
},
{
.info = SQL_TXN_CAPABLE,
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: txtsim - merged with default

2023-04-06 Thread Niels Nes
Changeset: 1e531b6297a0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1e531b6297a0
Branch: txtsim
Log Message:

merged with default


diffs (truncated from 577 to 300 lines):

diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c
--- a/clients/odbc/driver/SQLGetInfo.c
+++ b/clients/odbc/driver/SQLGetInfo.c
@@ -1037,15 +1037,16 @@ MNDBGetInfo(ODBCDbc *dbc,
break;
case SQL_TIMEDATE_ADD_INTERVALS:
case SQL_TIMEDATE_DIFF_INTERVALS:
-   /* SQL_FN_TSI_FRAC_SECOND |
-* SQL_FN_TSI_SECOND |
-* SQL_FN_TSI_MINUTE |
-* SQL_FN_TSI_HOUR |
-* SQL_FN_TSI_DAY |
-* SQL_FN_TSI_WEEK |
-* SQL_FN_TSI_MONTH |
-* SQL_FN_TSI_QUARTER |
-* SQL_FN_TSI_YEAR */
+   /* when server is 11.46 or higher */
+   nValue = SQL_FN_TSI_SECOND |
+   SQL_FN_TSI_MINUTE |
+   SQL_FN_TSI_HOUR |
+   SQL_FN_TSI_DAY |
+   SQL_FN_TSI_WEEK |
+   SQL_FN_TSI_MONTH |
+   SQL_FN_TSI_QUARTER |
+   SQL_FN_TSI_YEAR;
+   /* SQL_FN_TSI_FRAC_SECOND | */
break;
case SQL_TIMEDATE_FUNCTIONS:
nValue = SQL_FN_TD_CURRENT_DATE |
@@ -1053,7 +1054,7 @@ MNDBGetInfo(ODBCDbc *dbc,
SQL_FN_TD_CURRENT_TIMESTAMP |
SQL_FN_TD_CURDATE |
SQL_FN_TD_CURTIME |
-   /* SQL_FN_TD_DAYNAME | */
+   SQL_FN_TD_DAYNAME | /* when server is 11.46 or 
higher */
SQL_FN_TD_DAYOFMONTH |
SQL_FN_TD_DAYOFWEEK |
SQL_FN_TD_DAYOFYEAR |
@@ -1061,12 +1062,12 @@ MNDBGetInfo(ODBCDbc *dbc,
SQL_FN_TD_HOUR |
SQL_FN_TD_MINUTE |
SQL_FN_TD_MONTH |
-   /* SQL_FN_TD_MONTHNAME | */
+   SQL_FN_TD_MONTHNAME |   /* when server is 11.46 or 
higher */
SQL_FN_TD_NOW |
SQL_FN_TD_QUARTER |
SQL_FN_TD_SECOND |
-   /* SQL_FN_TD_TIMESTAMPADD | */
-   /* SQL_FN_TD_TIMESTAMPDIFF | */
+   SQL_FN_TD_TIMESTAMPADD |/* when server is 11.46 
or higher */
+   SQL_FN_TD_TIMESTAMPDIFF |   /* when server is 11.46 
or higher */
SQL_FN_TD_WEEK |
SQL_FN_TD_YEAR;
break;
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -519,6 +519,9 @@ heapinit(BAT *b, const char *buf,
return -1;
}
 
+   if (strcmp(type, "wkba") == 0)
+   TRC_WARNING(GDK, "type wkba (SQL name: GeometryA) is 
deprecated\n");
+
if (properties & ~0x0F81) {
TRC_CRITICAL(GDK, "unknown properties are set: incompatible 
database on line %d of BBP.dir\n", lineno);
return -1;
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -100,10 +100,11 @@ HASHclear(Hash *h)
memset(h->Bckt, 0xFF, h->nbucket * h->width);
 }
 
-#define HASH_VERSION   4
-/* this is only for the change of hash function of the UUID type; if
- * HASH_VERSION is increased again from 4, the code associated with
- * HASH_VERSION_NOUUID must be deleted */
+#define HASH_VERSION   5
+/* this is only for the change of hash function of the UUID type and MBR
+ * type; if HASH_VERSION is increased again from 5, the code associated
+ * with HASH_VERSION_NOUUID and HASH_VERSION_NOMBR must be deleted */
+#define HASH_VERSION_NOMBR 4
 #define HASH_VERSION_NOUUID3
 #define HASH_HEADER_SIZE   7   /* nr of size_t fields in header */
 
@@ -500,7 +501,17 @@ BATcheckhash(BAT *b)
 ((size_t) 1 << 24) |
 #endif
 HASH_VERSION_NOUUID) &&
-strcmp(ATOMname(b->ttype), 
"uuid") != 0)
+strcmp(ATOMname(b->ttype), 
"uuid") != 0 &&
+strcmp(ATOMname(b->ttype), 
"mbr") != 0)
+#endif
+#ifdef HASH_VERSION_NOMBR
+/* if not uuid, also allow 
previous version */
+|| (hdata[0] == (
+#ifdef PERSISTENTHASH
+((size_t) 1 << 24) |
+#endif
+HASH_VERSION_NOMBR) &&
+strcmp(ATOMname(b->ttype), 
"mbr") != 0)
 #endif
   

MonetDB: txtsim - merged with default

2023-04-01 Thread Niels Nes
Changeset: 23dc57b5baaf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/23dc57b5baaf
Modified Files:
clients/Tests/exports.stable.out
Branch: txtsim
Log Message:

merged with default


diffs (truncated from 1782 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -946,7 +946,6 @@ int getBitConstant(MalBlkPtr mb, bit val
 int getBlockBegin(MalBlkPtr mb, int pc);
 int getBlockExit(MalBlkPtr mb, int pc);
 int getBteConstant(MalBlkPtr mb, bte val);
-Client getClientContext(void);
 int getDblConstant(MalBlkPtr mb, dbl val);
 str getExceptionMessage(const char *);
 str getExceptionMessageAndState(const char *);
diff --git a/clients/examples/C/testcondvar.c b/clients/examples/C/testcondvar.c
--- a/clients/examples/C/testcondvar.c
+++ b/clients/examples/C/testcondvar.c
@@ -12,8 +12,6 @@
 #include "gdk.h"
 #include "gdk_system.h"
 
-#include 
-
 #define NN (3)
 
 volatile int timeout = 100; // set this to 0 during interactive debugging
diff --git a/clients/odbc/driver/SQLExecute.c b/clients/odbc/driver/SQLExecute.c
--- a/clients/odbc/driver/SQLExecute.c
+++ b/clients/odbc/driver/SQLExecute.c
@@ -424,9 +424,6 @@ MNDBExecute(ODBCStmt *stmt)
return SQL_ERROR;
}
 
-   /* internal state correctness checks */
-   assert(stmt->State == PREPARED0 || stmt->State == EXECUTED0 || 
stmt->ImplRowDescr->descRec != NULL);
-
assert(stmt->Dbc);
assert(stmt->Dbc->mid);
hdl = stmt->hdl;
diff --git a/gdk/gdk_analytic_bounds.c b/gdk/gdk_analytic_bounds.c
--- a/gdk/gdk_analytic_bounds.c
+++ b/gdk/gdk_analytic_bounds.c
@@ -1161,7 +1161,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
break;
}
default:
-   assert(0);
+   MT_UNREACHABLE();
}
if (is_lng_nil(limit) || limit < 0 || 
is_int_nil(int_limit) || int_limit < 0) {
goto invalid_bound;
@@ -1446,7 +1446,7 @@ GDKanalyticalwindowbounds(BAT *r, BAT *b
case 2:
return GDKanalyticalgroupsbounds(r, b, p, l, bound, tp2, 
preceding);
default:
-   assert(0);
+   MT_UNREACHABLE();
}
GDKerror("42000!unit type %d not supported (this is a bug).\n", unit);
return GDK_FAIL;
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -100,55 +100,51 @@ BATcreatedesc(oid hseq, int tt, bool hea
.batTransient = true,
.batRestricted = BAT_WRITE,
};
-   if (heapnames && (bn->theap = GDKmalloc(sizeof(Heap))) == NULL) {
-   GDKfree(bn);
-   return NULL;
-   }
 
-   /*
-* add to BBP
-*/
-   if (BBPinsert(bn) == 0) {
-   GDKfree(bn->theap);
-   GDKfree(bn);
-   return NULL;
-   }
-   /*
-* fill in heap names, so HEAPallocs can resort to disk for
-* very large writes.
-*/
if (heapnames) {
-   assert(bn->theap != NULL);
+   if ((bn->theap = GDKmalloc(sizeof(Heap))) == NULL) {
+   GDKfree(bn);
+   return NULL;
+   }
*bn->theap = (Heap) {
-   .parentid = bn->batCacheid,
.farmid = BBPselectfarm(role, bn->ttype, offheap),
.dirty = true,
};
 
-   const char *nme = BBP_physical(bn->batCacheid);
-   settailname(bn->theap, nme, tt, width);
-
if (ATOMneedheap(tt)) {
if ((bn->tvheap = GDKmalloc(sizeof(Heap))) == NULL) {
-   BBPclear(bn->batCacheid);
-   HEAPfree(bn->theap, true);
GDKfree(bn->theap);
GDKfree(bn);
return NULL;
}
*bn->tvheap = (Heap) {
-   .parentid = bn->batCacheid,
.farmid = BBPselectfarm(role, bn->ttype, 
varheap),
.dirty = true,
};
+   }
+   }
+   /*
+* add to BBP
+*/
+   if (BBPinsert(bn) == 0) {
+   GDKfree(bn->tvheap);
+   GDKfree(bn->theap);
+   GDKfree(bn);
+   return NULL;
+   }
+   if (bn->theap) {
+   bn->theap->parentid = bn->batCacheid;
+   ATOMIC_INIT(>theap->refs, 1);
+   const char *nme = BBP_physical(bn->batCacheid);
+   settailname(bn->theap, nme, tt, width);
+
+   if (bn->tvheap) {
+   

MonetDB: txtsim - merged with default

2023-03-11 Thread Niels Nes
Changeset: bc01344b2d05 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bc01344b2d05
Branch: txtsim
Log Message:

merged with default


diffs (truncated from 948 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -787,6 +787,7 @@ 44e45c9a451f6afd933773094ec25723f713d3be
 44e45c9a451f6afd933773094ec25723f713d3be Jan2022_SP5_release
 43d4a717410d6f6692a16a878640fc7e0f248725 Jan2022_25
 43d4a717410d6f6692a16a878640fc7e0f248725 Jan2022_SP6_release
+700e099bfee85318da09aabcd78ec7ea6e8fb6ef Jul2021_29
 5c50a4071c86d1621e20a885a51cc36f2f23eec4 Sep2022_9
 41ca60d96bd0198ca5d74937630a442a5fbaf1cd Sep2022_11
 41ca60d96bd0198ca5d74937630a442a5fbaf1cd Sep2022_SP1_release
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3578,7 +3578,6 @@ main(int argc, char **argv)
} else {
if (mode == SQL) {
setFormatter("sql");
-   mapi_set_size_header(mid, false);
} else {
setFormatter("raw");
mapi_set_size_header(mid, true);
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -546,17 +546,26 @@ runMALsequence(Client cntxt, MalBlkPtr m
ret= createException(MAL, "mal.interpreter", 
"prematurely stopped client");
break;
}
-#ifndef NDEBUG
-   if (cntxt->itrace || stk->status) {
-   if (stk->status == 'p'){
-   // execution is paused
+
+   if (stk->status) {
+   /* pause procedure from SYSMON */
+   if (stk->status == 'p') {
while (stk->status == 'p')
MT_sleep_ms(50);
continue;
}
-   if (stk->status == 'q')
-   stk->cmd = 'x';
+   /* stop procedure from SYSMON */
+   if (stk->status == 'q') {
+   stkpc = mb->stop;
+   ret = createException(MAL, "mal.interpreter",
+ 
"Query with tag "OIDFMT" received stop signal",
+ 
mb->tag);
+   break;
+   }
+   }
 
+#ifndef NDEBUG
+   if (cntxt->itrace) {
if (stk->cmd == 0)
stk->cmd = cntxt->itrace;
mdbStep(cntxt, mb, stk, stkpc);
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -368,7 +368,7 @@ MSscheduleClient(str command, str challe
mnstr_printf(c->fdout, "!%s\n", s);
mnstr_flush(c->fdout, MNSTR_FLUSH_DATA);
GDKfree(s);
-   c->mode = FINISHCLIENT;
+   MCcloseClient(c);
}
if (!GDKgetenv_isyes(mal_enableflag) &&
(strncasecmp("sql", lang, 3) != 0 && uid != 0)) 
{
diff --git a/monetdb5/modules/kernel/CMakeLists.txt 
b/monetdb5/modules/kernel/CMakeLists.txt
--- a/monetdb5/modules/kernel/CMakeLists.txt
+++ b/monetdb5/modules/kernel/CMakeLists.txt
@@ -18,7 +18,7 @@ target_sources(kernel
   bat5.c
   algebra.c algebra.h
   group.c group.h
-  aggr.c
+  aggr.c aggr.h
   batmmath.c
   batstr.c
   batcolor.c
diff --git a/monetdb5/modules/kernel/aggr.c b/monetdb5/modules/kernel/aggr.c
--- a/monetdb5/modules/kernel/aggr.c
+++ b/monetdb5/modules/kernel/aggr.c
@@ -11,6 +11,7 @@
 #include "monetdb_config.h"
 #include "mal.h"
 #include "mal_exception.h"
+#include "aggr.h"
 
 /*
  * grouped aggregates
@@ -24,7 +25,7 @@ AGGRgrouped(bat *retval1, bat *retval2, 
const bat *quantile,
const char *malfunc)
 {
-   BAT *b, *g, *e, *s, *bn = NULL, *cnts, *q = NULL;
+   BAT *b, *g, *e, *s, *bn = NULL, *cnts = NULL, *q = NULL;
double qvalue;
 
/* exactly one of grpfunc1, grpfunc2 and quantilefunc is non-NULL */
@@ -124,7 +125,7 @@ AGGRsum3_int(bat *retval, const bat *bid
   BATgroupsum, NULL, NULL, NULL, 
"aggr.sum");
 }
 
-static str
+str
 AGGRsum3_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid)
 {
return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, true, 0, TYPE_lng,
@@ -132,7 +133,7 @@ AGGRsum3_lng(bat *retval, const bat *bid
 }
 
 #ifdef HAVE_HGE
-static str
+str
 AGGRsum3_hge(bat *retval, const bat *bid, const bat *gid, const