MonetDB: Aug2024 - More timeout cleanup.

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

More timeout cleanup.


diffs (truncated from 418 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
@@ -512,28 +512,6 @@ class Comment:
 def write(self, f, newline = False):
 f.write(str(self))
 
-class Timer:
-# interface to the threading.Timer function that interprets a
-# timeout of 0 as no timeout
-def __init__(self, interval, function, args):
-self.timer = None
-self.function = function
-self.args = args
-self.interval = interval
-
-def settimeout(self, interval):
-self.interval = interval
-
-def start(self):
-if self.timer is None and self.interval > 0:
-self.timer = threading.Timer(self.interval, self.function, 
args=self.args)
-self.timer.start()
-
-def cancel(self):
-if self.timer is not None:
-self.timer.cancel()
-self.timer = None
-
 REV = ''# revision (output of hg id), default unknown
 
 black = 'black' # #00
@@ -1354,7 +1332,7 @@ def PerformDir(env, testdir, testlist, t
 crs = dbh.cursor()
 try:
 crs.execute("call 
logging.setcomplevel('SQL_EXECUTION', 'INFO')")
-except socket.timeout:
+except TimeoutError:
 print('\nTimeout setting log level.\n')
 crs.close()
 dbh.close()
@@ -1700,7 +1678,7 @@ def GetBitsAndModsAndThreads(env) :
 crs = dbh.cursor()
 try:
 crs.execute('select distinct module from 
sys.malfunctions() order by module')
-except socket.timeout:
+except TimeoutError:
 pass
 else:
 mods = crs.fetchall()
@@ -2516,13 +2494,13 @@ def stacktrace(proc, outfile):
 with process.Popen(['gdb', '-p', str(proc.pid), '-batch', '-ex', 
'thread apply all bt full'], stdout=process.PIPE,
text=True) as p:
 try:
+out, err = p.communicate(timeout=60)
+except TimeoutExpired:
 # gdb sometimes hangs when trying to get the stack
 # trace: kill it mercilessly if it does
-t = Timer(60, reallyKill, args = [p])
-t.start()
-except AttributeError:
-t = None
-out, err = p.communicate()
+p.kill()
+p.wait()
+out = err = ''
 if t is not None:
 t.cancel()
 except KeyboardInterrupt:
@@ -2584,7 +2562,6 @@ class ServerClass:
 self.inmem = inmem
 self.dbg = dbg
 self.dbname = dbname
-self.running = None
 self.lock = threading.Lock()
 
 def poll(self):
@@ -2596,7 +2573,7 @@ class ServerClass:
 else:
 self.proc.terminate()
 try:
-self.proc.wait(timeout=60)
+self.proc.wait(timeout=30)
 except TimeoutExpired:
 self.proc.kill()
 self.wait()
@@ -2607,14 +2584,15 @@ class ServerClass:
 self.errfile.close()
 
 def start(self, timeout):
-self.running = Timer(timeout, self.stopsessions, [])
-self.running.start()
+if timeout:
+self.timer = threading.Timer(timeout, self.stopsessions, [])
+self.timer.start()
 
 def stop(self):
 if self.lock.acquire():
-if self.running:
-self.running.cancel()
-self.running = None
+if self.timer:
+self.timer.cancel()
+self.timer = None
 self.lock.release()
 
 def sendusr1(self):
@@ -2631,7 +2609,7 @@ class ServerClass:
 def stopsessions(self):
 if self.lock.acquire(blocking=False):
 try:
-if self.running is not None:
+if self.timer is not None:
 self.stacktrace()
 try:
 dbh = pymonetdb.connect(username='monetdb',
@@ -2651,11 +2629,11 @@ class ServerClass:
 crs.execute(f'call sys.stopsession({x[0]})')
 if procdebug and not ids:
 print('no sessions to stop')
-except socket.timeout:
+except TimeoutError:
 self.proc.kill()
 crs.close()
 dbh.close()
-self.

MonetDB: default - Merge with Aug2024 branch.

2025-02-03 Thread Sjoerd Mullender via checkin-list
Changeset: ce1edf03f7f1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ce1edf03f7f1
Modified Files:
testing/Mtest.py.in
testing/sqllogictest.py
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (truncated from 418 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
@@ -512,28 +512,6 @@ class Comment:
 def write(self, f, newline = False):
 f.write(str(self))
 
-class Timer:
-# interface to the threading.Timer function that interprets a
-# timeout of 0 as no timeout
-def __init__(self, interval, function, args):
-self.timer = None
-self.function = function
-self.args = args
-self.interval = interval
-
-def settimeout(self, interval):
-self.interval = interval
-
-def start(self):
-if self.timer is None and self.interval > 0:
-self.timer = threading.Timer(self.interval, self.function, 
args=self.args)
-self.timer.start()
-
-def cancel(self):
-if self.timer is not None:
-self.timer.cancel()
-self.timer = None
-
 REV = ''# revision (output of hg id), default unknown
 
 black = 'black' # #00
@@ -1354,7 +1332,7 @@ def PerformDir(env, testdir, testlist, t
 crs = dbh.cursor()
 try:
 crs.execute("call 
logging.setcomplevel('SQL_EXECUTION', 'INFO')")
-except socket.timeout:
+except TimeoutError:
 print('\nTimeout setting log level.\n')
 crs.close()
 dbh.close()
@@ -1708,7 +1686,7 @@ def GetBitsAndModsAndThreads(env) :
 crs = dbh.cursor()
 try:
 crs.execute('select distinct module from 
sys.malfunctions() order by module')
-except socket.timeout:
+except TimeoutError:
 pass
 else:
 mods = crs.fetchall()
@@ -2582,13 +2560,13 @@ def stacktrace(proc, outfile):
 with process.Popen(['gdb', '-p', str(proc.pid), '-batch', '-ex', 
'thread apply all bt full'], stdout=process.PIPE,
text=True) as p:
 try:
+out, err = p.communicate(timeout=60)
+except TimeoutExpired:
 # gdb sometimes hangs when trying to get the stack
 # trace: kill it mercilessly if it does
-t = Timer(60, reallyKill, args = [p])
-t.start()
-except AttributeError:
-t = None
-out, err = p.communicate()
+p.kill()
+p.wait()
+out = err = ''
 if t is not None:
 t.cancel()
 except KeyboardInterrupt:
@@ -2650,7 +2628,6 @@ class ServerClass:
 self.inmem = inmem
 self.dbg = dbg
 self.dbname = dbname
-self.running = None
 self.lock = threading.Lock()
 
 def poll(self):
@@ -2662,7 +2639,7 @@ class ServerClass:
 else:
 self.proc.terminate()
 try:
-self.proc.wait(timeout=60)
+self.proc.wait(timeout=30)
 except TimeoutExpired:
 self.proc.kill()
 self.wait()
@@ -2673,14 +2650,15 @@ class ServerClass:
 self.errfile.close()
 
 def start(self, timeout):
-self.running = Timer(timeout, self.stopsessions, [])
-self.running.start()
+if timeout:
+self.timer = threading.Timer(timeout, self.stopsessions, [])
+self.timer.start()
 
 def stop(self):
 if self.lock.acquire():
-if self.running:
-self.running.cancel()
-self.running = None
+if self.timer:
+self.timer.cancel()
+self.timer = None
 self.lock.release()
 
 def sendusr1(self):
@@ -2697,7 +2675,7 @@ class ServerClass:
 def stopsessions(self):
 if self.lock.acquire(blocking=False):
 try:
-if self.running is not None:
+if self.timer is not None:
 self.stacktrace()
 try:
 dbh = pymonetdb.connect(username='monetdb',
@@ -2717,11 +2695,11 @@ class ServerClass:
 crs.execute(f'call sys.stopsession({x[0]})')
 if procdebug and not ids:
 print('no sessions to stop')
-except socket.timeout:
+except TimeoutError:
 self.proc.kill()
 crs.close()
 dbh.close()
-

MonetDB: nested - more windows fixes

2025-02-03 Thread Niels Nes via checkin-list
Changeset: 3293617c206b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3293617c206b
Modified Files:
monetdb5/modules/mal/tablet.c
Branch: nested
Log Message:

more windows fixes


diffs (21 lines):

diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -526,7 +526,7 @@ static int
 output_multiset(Tablet *as, stream *fd, bstream *in)
 {
size_t len = BUFSIZ, locallen = BUFSIZ;
-   int res = 0;
+   ssize_t res = 0;
char *buf = GDKmalloc(len);
char *localbuf = GDKmalloc(len);
BUN i = 0;
@@ -550,7 +550,7 @@ output_multiset(Tablet *as, stream *fd, 
GDKfree(localbuf);
GDKfree(buf);
if (res < 0)
-   return -1;
+   return (int)res;
return 0;
 }
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: const_aggr_elim - New version cleanup atom one func added

2025-02-03 Thread Wolf Schulz via checkin-list
Changeset: 54ffd3c27b39 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/54ffd3c27b39
Modified Files:
sql/server/rel_optimize_proj.c
sql/server/sql_atom.c
sql/server/sql_atom.h
Branch: const_aggr_elim
Log Message:

New version cleanup atom one func added


diffs (92 lines):

diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -2539,34 +2539,19 @@ rel_remove_const_aggr(visitor *v, sql_re
sql_exp *w = m->data;
 
if(w->type == e_atom && w->card == 
CARD_ATOM) {
-   if(sum && 
!(((atom*)w->l)->isnull || atom_is_zero((atom*)w->l))) {
-   continue;
-   }
-
-   if(prd && 
!(((atom*)w->l)->isnull || ((atom*)w->l)->data.val.lval == 1)) {
+   atom *wa = w->l;
+
+   if(sum && !(wa->isnull || 
atom_is_zero(wa))) {
continue;
}
-   
-   /*if(cnt && 
((atom*)w->l)->isnull) { // && 0
-   list_remove_node(se, 
NULL, m);
-   sql_exp 
*rr=exp_atom_lng(v->sql->sa, 0);
-   list_append(se, rr);
-   
-
-   
exp_setalias(rr,e->alias.label,e->alias.rname,e->alias.name);
-   n->data = rr;
-
-   v->changes++;
-
+
+   if(prd && !(wa->isnull || 
atom_is_one(wa))) {
continue;
}
-   else if(cnt) {
-   continue;
-   }*/
 
/* Handle: select 
count(distinct NULL) + 3 == 3 */
if(cnt) {
-   
if(((atom*)w->l)->isnull) {
+   if(wa->isnull) {

list_remove_node(se, NULL, m);
 

w=exp_atom_lng(v->sql->sa, 0);
diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -1080,6 +1080,33 @@ atom_is_zero(atom *a)
 }
 
 int
+atom_is_one(atom *a)
+{
+   if (a->isnull || !ATOMlinear(a->tpe.type->localtype))
+   return 0;
+   switch (ATOMstorage(a->tpe.type->localtype)) {
+   case TYPE_bte:
+   return a->data.val.btval == 1;
+   case TYPE_sht:
+   return a->data.val.shval == 1;
+   case TYPE_int:
+   return a->data.val.ival == 1;
+   case TYPE_lng:
+   return a->data.val.lval == 1;
+#ifdef HAVE_HGE
+   case TYPE_hge:
+   return a->data.val.hval == 1;
+#endif
+   case TYPE_flt:
+   return a->data.val.fval == 1;
+   case TYPE_dbl:
+   return a->data.val.dval == 1;
+   default:
+   return 0;
+   }
+}
+
+int
 atom_is_true(atom *a)
 {
if (a->isnull)
diff --git a/sql/server/sql_atom.h b/sql/server/sql_atom.h
--- a/sql/server/sql_atom.h
+++ b/sql/server/sql_atom.h
@@ -65,6 +65,7 @@ extern atom *atom_inc(allocator *sa, ato
 extern int atom_is_true(atom *a);
 extern int atom_is_false(atom *a);
 extern int atom_is_zero(atom *a);
+extern int atom_is_one(atom *a);
 
 extern unsigned int atom_digits(atom *a);
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: odbc_loader - Approve

2025-02-03 Thread Martin van Dinther via checkin-list
Changeset: 1b597215423f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1b597215423f
Modified Files:
clients/Tests/exports.stable.out
Branch: odbc_loader
Log Message:

Approve


diffs (20 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
@@ -1627,6 +1627,7 @@ str lng_num2dec_flt(flt *res, const lng 
 str lng_num2dec_int(int *res, const lng *v, const int *d2, const int *s2);
 str lng_num2dec_lng(lng *res, const lng *v, const int *d2, const int *s2);
 str lng_num2dec_sht(sht *res, const lng *v, const int *d2, const int *s2);
+const char *mapiuri_uri(const char *uri, allocator *sa);
 int mapiuri_valid(const char *uri, allocator *sa);
 sql_schema *mvc_bind_schema(mvc *c, const char *sname);
 sql_table *mvc_bind_table(mvc *c, sql_schema *s, const char *tname);
@@ -1653,6 +1654,8 @@ list *rel_projections(mvc *sql, sql_rel 
 void res_tables_destroy(res_table *results);
 list *sa_list(allocator *sa);
 char *sa_message(allocator *sa, _In_z_ _Printf_format_string_ const char 
*format, ...) __attribute__((__format__(__printf__, 2, 3)));
+msettings *sa_msettings_create(allocator *sa);
+char *sa_msettings_to_string(const msettings *mp, allocator *sa, size_t 
size_hint);
 str sht_dec2_bte(bte *res, const int *s1, const sht *v);
 str sht_dec2_dbl(dbl *res, const int *s1, const sht *v);
 str sht_dec2_flt(flt *res, const int *s1, const sht *v);
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: const_aggr_elim - add tests for corner cases aggr elim ...

2025-02-03 Thread Wolf Schulz via checkin-list
Changeset: c91be587f47c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c91be587f47c
Modified Files:
sql/test/rel-optimizers/Tests/const-aggr-elim.test
Branch: const_aggr_elim
Log Message:

add tests for corner cases aggr elim aggr


diffs (71 lines):

diff --git a/sql/test/rel-optimizers/Tests/const-aggr-elim.test 
b/sql/test/rel-optimizers/Tests/const-aggr-elim.test
--- a/sql/test/rel-optimizers/Tests/const-aggr-elim.test
+++ b/sql/test/rel-optimizers/Tests/const-aggr-elim.test
@@ -120,3 +120,67 @@ project (
 | | table("sys"."baz") [ "baz"."b" NOT NULL ]
 | ) [ "baz"."b" NOT NULL ] [ "sys"."count"() NOT NULL as "%1"."%1" ]
 ) [ "%1"."%1" NOT NULL ]
+
+query T nosort
+plan select prod(cast(1 as real)) from baz group by b;
+
+project (
+| group by (
+| | table("sys"."baz") [ "baz"."b" NOT NULL ]
+| ) [ "baz"."b" NOT NULL ] [ "baz"."b" NOT NULL ]
+) [ real(24) "1" as "%1"."%1" ]
+
+query T nosort
+plan select prod(1), sum(0) from baz group by a
+
+project (
+| group by (
+| | table("sys"."baz") [ "baz"."a" NOT NULL ]
+| ) [ "baz"."a" NOT NULL ] [ "baz"."a" NOT NULL ]
+) [ tinyint(1) "1" as "%1"."%1", tinyint(1) "0" as "%2"."%2" ]
+
+query II rowsort
+select prod(1), sum(0) from baz group by a
+
+1
+0
+1
+0
+1
+0
+1
+0
+1
+0
+
+query II rowsort
+select prod(null) + 1, sum(null) + 1 from baz group by a
+
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+
+query T nosort
+plan select count(null) + 3 from baz group by a
+
+project (
+| group by (
+| | table("sys"."baz") [ "baz"."a" NOT NULL ]
+| ) [ "baz"."a" NOT NULL ] [ "baz"."a" NOT NULL ]
+) [ "sys"."sql_add"(bigint(1) "0", bigint(2) "3") NOT NULL ]
+
+query I rowsort
+select count(null) + 3 from baz group by a
+
+3
+3
+3
+3
+3
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: const_aggr_elim - Merges default

2025-02-03 Thread stefanos mavros via checkin-list
Changeset: f031c775f29e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f031c775f29e
Branch: const_aggr_elim
Log Message:

Merges default


diffs (truncated from 4726 to 300 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -18,12 +18,8 @@
  */
 
 #include "monetdb_config.h"
-#ifndef HAVE_GETOPT_LONG
-#  include "monet_getopt.h"
-#else
-# ifdef HAVE_GETOPT_H
-#  include "getopt.h"
-# endif
+#ifdef HAVE_GETOPT_H
+#include "getopt.h"
 #endif
 #include "stream.h"
 #include "mapi.h"
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -11,12 +11,8 @@
  */
 
 #include "monetdb_config.h"
-#ifndef HAVE_GETOPT_LONG
-#  include "monet_getopt.h"
-#else
-# ifdef HAVE_GETOPT_H
-#  include "getopt.h"
-# endif
+#ifdef HAVE_GETOPT_H
+#include "getopt.h"
 #endif
 #include "mapi.h"
 #include 
diff --git a/cmake/Modules/FindGetopt.cmake b/cmake/Modules/FindGetopt.cmake
deleted file mode 100644
--- a/cmake/Modules/FindGetopt.cmake
+++ /dev/null
@@ -1,17 +0,0 @@
-# - Find Getopt
-# Find the native getopt headers and libraries.
-#
-# GETOPT_INCLUDE_DIR   - where to find getopt.h, etc.
-# GETOPT_LIBRARIES - List of libraries when using getopt.
-# GETOPT_FOUND - True if getopt found.
-
-##find_path(HAVE_GETOPT_H "getopt.h")
-##check_symbol_exists("getopt_long" "getopt.h" HAVE_GETOPT_LONG)
-
-##find_library(GETOPT_LIB "getopt.lib")
-#cmakedefine HAVE_GETOPT_H @HAVE_GETOPT_H@
-#cmakedefine HAVE_GETOPT_LONG @HAVE_GETOPT_LONG@
-
-#define HAVE_GETOPT_LONG 1
-#cmakedefine HAVE_GETOPT_H @HAVE_GETOPT_H@
-#cmakedefine GETOPT_LIB @GETOPT_LIB@
diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -74,10 +74,6 @@ function(monetdb_configure_defines)
   check_function_exists("getentropy" HAVE_GETENTROPY)
   check_function_exists("getexecname" HAVE_GETEXECNAME)
   check_function_exists("getlogin" HAVE_GETLOGIN)
-  cmake_push_check_state()
-set(CMAKE_REQUIRED_INCLUDES "${HAVE_GETOPT_H}")
-check_symbol_exists("getopt_long" "getopt.h" HAVE_GETOPT_LONG)
-  cmake_pop_check_state()
   check_function_exists("getrlimit" HAVE_GETRLIMIT)
   check_function_exists("gettid" HAVE_GETTID)
   check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
@@ -175,9 +171,6 @@ macro(monetdb_macro_variables)
 CACHE
 INTERNAL
 "C udfs extension is available")
-  if(HAVE_GETOPT_H)
-set(HAVE_GETOPT 1)
-  endif()
   # compiler options, profiling (google perf tools), valgrind
   # Check that posix regex is available when pcre is not found
   # "monetdb5/module/mal/pcre.c" assumes the regex library is available
diff --git a/common/options/CMakeLists.txt b/common/options/CMakeLists.txt
--- a/common/options/CMakeLists.txt
+++ b/common/options/CMakeLists.txt
@@ -11,8 +11,7 @@
 #]]
 
 set(moptions_public_headers
-  ${CMAKE_CURRENT_SOURCE_DIR}/monet_options.h
-  ${CMAKE_CURRENT_SOURCE_DIR}/monet_getopt.h)
+  ${CMAKE_CURRENT_SOURCE_DIR}/monet_options.h)
 
 add_library(moptions
   STATIC)
@@ -24,16 +23,13 @@ target_sources(moptions
   ${moptions_public_headers})
 
 target_include_directories(moptions
-  PRIVATE
-  $<$:${HAVE_GETOPT_H}>
   PUBLIC
   $
   $)
 
 target_link_libraries(moptions
   PRIVATE
-  monetdb_config_header
-  $<$:${GETOPT_LIB}>)
+  monetdb_config_header)
 
 if(NOT MONETDB_STATIC)
   set_target_properties(moptions
@@ -44,7 +40,6 @@ endif()
 
 install(FILES
   monet_options.h
-  monet_getopt.h
   DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/monetdb
   COMPONENT
   monetdbdev)
diff --git a/common/options/getopt.c b/common/options/getopt.c
deleted file mode 100644
--- a/common/options/getopt.c
+++ /dev/null
@@ -1,941 +0,0 @@
-/*
- * 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.
- */
-
-/* Getopt for GNU.
-   NOTE: getopt is now part of the C library, so if you don't know what
-   "Keep this file name-space clean" means, talk to drep...@gnu.org
-   before changing it!
-   Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
-   Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHAN

MonetDB: const_aggr_elim - Adds some comments for clarity

2025-02-03 Thread stefanos mavros via checkin-list
Changeset: 2b345d7a347d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2b345d7a347d
Modified Files:
sql/server/rel_optimize_proj.c
Branch: const_aggr_elim
Log Message:

Adds some comments for clarity


diffs (54 lines):

diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -2515,6 +2515,11 @@ rel_remove_const_aggr(visitor *v, sql_re
}
 
if(!list_empty(rel->r)) {
+   /* in the general case in an expression of an aggregate over
+* a constant can be rewritten as just the const e.g.
+*   aggr(const) -> const
+*/
+
for(node *n = exps->h; n; n = n->next) {
sql_exp *e = n->data;
 
@@ -2524,11 +2529,17 @@ rel_remove_const_aggr(visitor *v, sql_re
 
sql_func *j = ((sql_subfunc *)e->f)->func;
 
+   /* some aggregates with const values can only be 
eliminated
+* under certain circumstances e.g.
+*   sum(NULL)   -> NULL, sum(0)  -> 0
+*   prod(NULL)  -> NULL, prod(1) -> 1
+*   count(NULL) -> 0
+*/
int sum = strcmp(j->base.name, "sum") == 0,
prd = strcmp(j->base.name, "prod") == 0,
cnt = strcmp(j->base.name, "count") == 0;
 
-   if(!j->s && j->system == 1) { // && !cnt
+   if(!j->s && j->system == 1) {
list *se = e->l;
 
if(se == NULL) {
@@ -2549,7 +2560,6 @@ rel_remove_const_aggr(visitor *v, sql_re
continue;
}
 
-   /* Handle: select 
count(distinct NULL) + 3 == 3 */
if(cnt) {
if(wa->isnull) {

list_remove_node(se, NULL, m);
@@ -2572,9 +2582,9 @@ rel_remove_const_aggr(visitor *v, sql_re
}
}
 
-   /* 
+   /*
 * Below code replaces GROUP BY with PROJECT in some cases;
-* Triggers on... 
+* Triggers on...
 * select 1 having true; select 42 from foo group by x; select n from 
foo group by rollup(n);
*/
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Aug2024 - Work around bug in pymonetdb.

2025-02-03 Thread Sjoerd Mullender via checkin-list
Changeset: fce090da651f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fce090da651f
Modified Files:
testing/sqllogictest.py
Branch: Aug2024
Log Message:

Work around bug in pymonetdb.
If an error (e.g. timeout) happens during "ON CLIENT" file transfer,
pymonetdb calls the mapi method _sabotage() which sets the socket
attribute to None.  If we then (legitimately) call the close method on
the database handler, we get an AttributeError because the close calls
disconnect which tries to call the socket close method, but socket is
already None.


diffs (15 lines):

diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py
--- a/testing/sqllogictest.py
+++ b/testing/sqllogictest.py
@@ -242,7 +242,10 @@ class SQLLogic:
 pass
 self.crs = None
 if self.dbh:
-self.dbh.close()
+try:
+self.dbh.close()
+except AttributeError:
+pass
 self.dbh = None
 
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org