Changeset: b0b885b0b5c5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b0b885b0b5c5
Removed Files:
        monetdb5/extras/mal_optimizer_template/CMakeLists.txt
        monetdb5/extras/mal_optimizer_template/opt_sql_append.c
Modified Files:
        MonetDB.spec
        NT/mksqlwxs.py
        debian/monetdb-server.install
        debian/rules
        monetdb5/extras/CMakeLists.txt
Branch: Dec2025
Log Message:

Removed unused example optimizer opt_sql_append.


diffs (truncated from 453 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -1017,7 +1017,6 @@ install -d -m 0775 "${RPM_BUILD_ROOT}"%{
 install -d -m 0775 "${RPM_BUILD_ROOT}"%{_rundir}/monetdb
 
 # remove unwanted stuff
-rm -f "${RPM_BUILD_ROOT}"%{_libdir}/monetdb5*/lib_opt_sql_append.so
 rm -f "${RPM_BUILD_ROOT}"%{_libdir}/monetdb5*/lib_microbenchmark*.so
 rm -f "${RPM_BUILD_ROOT}"%{_libdir}/monetdb5*/lib_udf*.so
 rm -f "${RPM_BUILD_ROOT}"%{_bindir}/monetdb_mtest.sh
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -207,9 +207,9 @@ def main():
     print(r'            <Directory Id="lib" Name="lib">')
     print(r'              <Directory Id="monetdb5" Name="monetdb5">')
     id = comp(features, id, 16,
-              [rf'lib\monetdb5-{version}\{x}' for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.dll') and ('geom' not in x) and ('pyapi' not 
in x) and ('opt_sql_append' not in x) and ('microbenchmark' not in x) and 
('udf' not in x), os.listdir(os.path.join(sys.argv[3], 'lib', 
f'monetdb5-{version}'))))])
+              [rf'lib\monetdb5-{version}\{x}' for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.dll') and ('geom' not in x) and ('pyapi' not 
in x) and ('microbenchmark' not in x) and ('udf' not in x), 
os.listdir(os.path.join(sys.argv[3], 'lib', f'monetdb5-{version}'))))])
     id = comp(debug, id, 16,
-              [rf'lib\monetdb5-{version}\{x}' for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.pdb') and ('geom' not in x) and 
('opt_sql_append' not in x) and ('microbenchmark' not in x) and ('udf' not in 
x), os.listdir(os.path.join(sys.argv[3], 'lib', f'monetdb5-{version}'))))])
+              [rf'lib\monetdb5-{version}\{x}' for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.pdb') and ('geom' not in x) and 
('microbenchmark' not in x) and ('udf' not in x), 
os.listdir(os.path.join(sys.argv[3], 'lib', f'monetdb5-{version}'))))])
     id = comp(geom, id, 16,
               [rf'lib\monetdb5-{version}\{x}' for x in sorted(filter(lambda x: 
x.startswith('_') and (x.endswith('.dll') or x.endswith('.pdb')) and ('geom' in 
x), os.listdir(os.path.join(sys.argv[3], 'lib', f'monetdb5-{version}'))))])
     id = comp(pyapi3, id, 16,
diff --git a/debian/monetdb-server.install b/debian/monetdb-server.install
--- a/debian/monetdb-server.install
+++ b/debian/monetdb-server.install
@@ -2,7 +2,7 @@ debian/tmp/usr/bin/mserver5* usr/bin
 debian/tmp/usr/lib/x86_64-linux-gnu/libmonetdb5*.so.* usr/lib/x86_64-linux-gnu
 debian/tmp/usr/lib/x86_64-linux-gnu/libmonetdbsql*.so* usr/lib/x86_64-linux-gnu
 
-# usr/lib/x86_64-linux-gnu/monetdb5*/lib_*.so EXCEPT: 
lib_{fits,geom,gsl,microbenchmark,opt_sql_append,pyapi*,rapi,sql,udf}.so
+# usr/lib/x86_64-linux-gnu/monetdb5*/lib_*.so EXCEPT: 
lib_{fits,geom,gsl,microbenchmark,pyapi*,rapi,sql,udf}.so
 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5*/lib_capi.so 
usr/lib/x86_64-linux-gnu/monetdb5
 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5*/lib_csv.so 
usr/lib/x86_64-linux-gnu/monetdb5
 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5*/lib_generator.so 
usr/lib/x86_64-linux-gnu/monetdb5
diff --git a/debian/rules b/debian/rules
--- a/debian/rules
+++ b/debian/rules
@@ -57,7 +57,6 @@ override_dh_strip:
 override_dh_auto_install:
        dh_auto_install
        rm debian/tmp/usr/bin/monetdb_mtest.sh
-       rm debian/tmp/usr/lib/*/monetdb5*/lib_opt_sql_append.so
        rm debian/tmp/usr/lib/*/monetdb5*/lib_microbenchmark*.so
        rm debian/tmp/usr/lib/*/monetdb5*/lib_udf*.so
 
diff --git a/monetdb5/extras/CMakeLists.txt b/monetdb5/extras/CMakeLists.txt
--- a/monetdb5/extras/CMakeLists.txt
+++ b/monetdb5/extras/CMakeLists.txt
@@ -10,5 +10,4 @@
 # Copyright 1997 - July 2008 CWI.
 #]]
 
-add_subdirectory(mal_optimizer_template)
 add_subdirectory(rapi)
diff --git a/monetdb5/extras/mal_optimizer_template/CMakeLists.txt 
b/monetdb5/extras/mal_optimizer_template/CMakeLists.txt
deleted file mode 100644
--- a/monetdb5/extras/mal_optimizer_template/CMakeLists.txt
+++ /dev/null
@@ -1,56 +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.
-#]]
-
-if(MONETDB_STATIC)
-  add_library(opt_sql_append STATIC)
-else()
-  add_library(opt_sql_append MODULE)
-endif()
-
-target_sources(opt_sql_append
-  PRIVATE
-  opt_sql_append.c)
-
-target_include_directories(opt_sql_append
-  PRIVATE
-  $<TARGET_PROPERTY:mal,INTERFACE_INCLUDE_DIRECTORIES>
-  $<TARGET_PROPERTY:optimizer,INTERFACE_INCLUDE_DIRECTORIES>
-  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
-  $<INSTALL_INTERFACE:${INCLUDEDIR}/monetdb>)
-
-target_link_libraries(opt_sql_append
-  PRIVATE
-  monetdb_config_header
-  bat
-  monetdb5)
-
-target_compile_definitions(opt_sql_append
-  PRIVATE
-  LIBOPT_SQL_APPEND)
-
-set_target_properties(opt_sql_append
-  PROPERTIES
-  NO_SONAME ON
-  OUTPUT_NAME
-  _opt_sql_append)
-
-install(TARGETS
-  opt_sql_append
-  DESTINATION ${CMAKE_INSTALL_LIBDIR}/monetdb5-${MONETDB_VERSION}
-  COMPONENT server)
-
-if(WIN32)
-  install(FILES
-    $<TARGET_PDB_FILE:opt_sql_append>
-    DESTINATION ${CMAKE_INSTALL_LIBDIR}/monetdb5-${MONETDB_VERSION}
-    OPTIONAL)
-endif()
diff --git a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c 
b/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
deleted file mode 100644
--- a/monetdb5/extras/mal_optimizer_template/opt_sql_append.c
+++ /dev/null
@@ -1,329 +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.
- */
-
-/*
- * @a S. Manegold
- * @- SQL append show-case optimizer
- *
- * This optimizer is mainly for demonstrating how to implement a MAL
- * optimizer in principle.
- *
- * Purely for that purpose, the optimizer's task is to recognize MAL code
- * patterns like
- *
- *  ...
- *  v3 := sql.append( ..., ..., ..., ..., v0 );
- *  ...
- *  v5 := ... v0 ...;
- *  ...
- *
- * i.e., an sql.append() statement that is eventually followed by some other
- * statement later on in the MAL program that uses the same v0 BAT as
- * argument as the sql.append() statement does,
- * Do you assume a single reuse of the variable v0?
- * Do you assume a non-nested  MAL block ?
- *
- * and transform them into
- *
- *  ...
- *  v1 := aggr.count( v0 );
- *  v2 := algebra.slice( v0, 0, v1 );
- *  v3 := sql.append( ..., ..., ..., ..., v2 );
- *  ...
- *  v5 := ... v0 ...;
- *  ...
- *
- * i.e., handing a BAT view v2 of BAT v0 as argument to the sql.append()
- * statement, rather than the original BAT v0.
- * My advice, always use new variable names, it may capture some easy
- * to make errors.
- *
- * As a refinement, patterns like
- *
- *  ...
- *  v3 := sql.append( ..., ..., ..., ..., v0 );
- *  v4 := aggr.count( v0 );
- *  ...
- *  v5 := ... v0 ...;
- *  ...
- *
- * are transformed into
- *
- *  ...
- *  v4 := aggr.count( v0 );
- *  v2 := algebra.slice( v0, 0, v4 );
- *  v3 := sql.append( ..., ..., ..., ..., v2 );
- *  ...
- *  v5 := ... v0 ...;
- *  ...
- *
- */
-
-/*
- * It is mandatory to make optimizers part of the 'optimizer' module.
- * This allows the optimizer implementation to find them and react on them.
- */
-#include "monetdb_config.h"
-#include "opt_support.h"
-#include "mal_interpreter.h"
-
-/* focus initially on persistent tables. */
-
-static int
-OPTsql_appendImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
-{
-       InstrPtr *old = NULL;
-       int i, limit, slimit, actions = 0;
-
-       (void) cntxt;
-       (void) pci; /* Tell compilers that we know that we do not */
-       (void) stk; /* use these function parameters, here.       */
-
-       /* In general, a MAL optimizer transforms a given MAL program into a
-        * modified one by sequentially walking through the given program
-        * and concurrently creating a new one from scratch by
-        * (1) copying statements as is, modified, or in a different order,
-        * or (2) omitting statements or (3) introducing new statements.
-        */
-
-       /* check for logical error: mb must never be NULL */
-       assert (mb != NULL);
-
-       /* save the old stage of the MAL block */
-       old = mb->stmt;
-       limit= mb->stop;
-       slimit = mb->ssize;
-
-       /* initialize the statement list. Notice, the symbol table remains 
intact */
-       if (newMalBlkStmt(mb, mb->ssize) < 0)
-               return 0;
-
-       /* the plan signature can be copied safely */
-       pushInstruction(mb, old[0]);
-
-       /* iterate over the instructions of the input MAL program */
-       for (i = 1; i < limit; i++) {
-               InstrPtr p = old[i];
-
-               /* check for
-                *  v3 := sql.append( ..., ..., ..., ..., v0 );
-                */
-               if (getModuleId(p) == sqlRef &&
-                   getFunctionId(p) == appendRef &&
-                   p->argc > 5 &&
-                   p->retc == 1 &&
-                   isaBatType(getArgType(mb, p, 5))) {
-                       /* found
-                        *  v3 := sql.append( ..., ..., ..., ..., v0 );
-                        */
-                       int j = 0, k = 0;
-                       InstrPtr q1 = NULL, q2 = NULL;
-                       bit found = FALSE;
-
-                       /* check whether next is
-                        *  v4 := aggr.count(v0);
-                        */
-                       if (i+1 < limit) {
-                               InstrPtr q = old[i+1];
-                               if (getModuleId(q) == aggrRef &&
-                                   getFunctionId(q) == countRef &&
-                                   q->argc == 2 &&
-                                   q->retc == 1 &&
-                                   getArg(q, 1) == getArg(p, 5)) {
-                                       /* found
-                                        *  v3 := sql.append( ..., ..., ..., 
..., v0 );
-                                        *  v4 := aggr.count(v0);
-                                        */
-                                       /* issue/execute
-                                        *  v4 := aggr.count(v0);
-                                        * before
-                                        *  v3 := sql.append( ..., ..., ..., 
..., v0 );
-                                        */
-                                       pushInstruction(mb, q);
-                                       q1 = q;
-                                       i++;
-                                       actions++;      /* to keep track if 
anything has been done */
-                               }
-                       }
-
-                       /* look for
-                        *  v5 := ... v0 ...;
-                        */
-                       /* an expensive loop, better would be to remember that 
v0
-                        * has a different role.  A typical method is to keep a
-                        * map from variable -> instruction where it was
-                        * detected. Then you can check each assignment for use 
of
-                        * v0
-                       */
-                       for (j = i+1; !found  && j < limit; j++)
-                               for (k = old[j]->retc; !found && k < 
old[j]->argc; k++)
-                                       found = (getArg(old[j], k) == getArg(p, 
5));
-                       if (found) {
-                               /* replace
-                                *  v3 := sql.append( ..., ..., ..., ..., v0 );
-                                * with
-                                *  v1 := aggr.count( v0 );
-                                *  v2 := algebra.slice( v0, 0, v1 );
-                                *  v3 := sql.append( ..., ..., ..., ..., v2 );
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to