Changeset: 656d9ee09475 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/656d9ee09475
Modified Files:
        .github/workflows/linux.yml
        MonetDB.spec
        clients/Tests/exports.stable.out
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/rel_physical.c
        sql/backends/monet5/sql.c
        sql/common/sql_list.c
        sql/include/sql_list.h
        sql/include/sql_relation.h
        sql/server/rel_dump.c
        sql/server/rel_exp.c
        sql/server/rel_exp.h
        sql/server/rel_optimize_others.c
        sql/server/rel_optimize_proj.c
        sql/server/rel_optimize_sel.c
        sql/server/rel_optimizer.c
        sql/server/rel_optimizer_private.h
        sql/server/rel_prop.c
        sql/server/rel_prop.h
        sql/server/rel_rel.c
        sql/server/rel_rel.h
        sql/server/rel_rewriter.c
        sql/server/rel_select.c
        sql/server/rel_statistics.c
        sql/server/rel_unnest.c
        sql/server/sql_mvc.h
        sql/server/sql_parser.y
        sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
        sql/test/BugTracker-2015/Tests/crash.Bug-3736.test
        sql/test/BugTracker-2021/Tests/batappend-undefined.Bug-7130.test
        sql/test/BugTracker-2025/Tests/7650_right_join_crash.test
        sql/test/BugTracker-2026/Tests/7834-BATsubcross-more-than-one-match.test
        sql/test/BugTracker-2026/Tests/7841-BATsubcross-more-than-one-match.test
        sql/test/SQLancer/Tests/sqlancer11.test
        sql/test/SQLancer/Tests/sqlancer17.test
        sql/test/SQLancer/Tests/sqlancer23.test
        sql/test/Tests/keys.test
        
sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
        sql/test/miscellaneous/Tests/simple_selects.test
        sql/test/rel-optimizers/Tests/groupjoin.test
        
sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
Branch: pp_hashjoin
Log Message:

merged with default


diffs (truncated from 7211 to 300 lines):

diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -46,7 +46,7 @@ jobs:
     runs-on: ${{ matrix.os }}
     steps:
       - name: Checkout
-        uses: actions/checkout@v4
+        uses: actions/checkout@v6
         with:
           ref: ${{ github.ref }}
 
@@ -175,7 +175,7 @@ jobs:
       - name: Tar files
         run: tar -cvf mtests.tar mTests
       - name: Publish mtest results
-        uses: actions/upload-artifact@v4
+        uses: actions/upload-artifact@v7
         with:
           name: mtest-${{ github.sha }}-${{ matrix.os }}-${{ matrix.c_compiler 
}}
           path: mtests.tar
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -456,6 +456,7 @@ developer.
 %{_bindir}/smack01
 %{_bindir}/sqlsample.php
 %{_bindir}/sqlsample.pl
+%{_bindir}/sqlsample.py
 %{_bindir}/streamcat
 %{_bindir}/testcondvar
 %endif
@@ -1069,6 +1070,7 @@ rm "${RPM_BUILD_ROOT}"%{_bindir}/smack01
 rm "${RPM_BUILD_ROOT}"%{_bindir}/sqllogictest.py
 rm "${RPM_BUILD_ROOT}"%{_bindir}/sqlsample.php
 rm "${RPM_BUILD_ROOT}"%{_bindir}/sqlsample.pl
+rm "${RPM_BUILD_ROOT}"%{_bindir}/sqlsample.py
 rm "${RPM_BUILD_ROOT}"%{_bindir}/streamcat
 rm "${RPM_BUILD_ROOT}"%{_bindir}/testcondvar
 rm -r "${RPM_BUILD_ROOT}"%{_datadir}/doc/MonetDB*
diff --git a/clients/Tests/All b/clients/Tests/All
--- a/clients/Tests/All
+++ b/clients/Tests/All
@@ -1,4 +1,4 @@
-exports
+MERCURIAL?exports
 
HAVE_HGE&HAVE_FITS&HAVE_GEOM&HAVE_LIBR&HAVE_LIBPY3&HAVE_NETCDF&HAVE_SHP&HAVE_CUDF?MAL-signatures-hge
 
!HAVE_HGE&HAVE_FITS&HAVE_GEOM&HAVE_LIBR&HAVE_LIBPY3&HAVE_NETCDF&HAVE_SHP&HAVE_CUDF?MAL-signatures
 NOT_WIN32?melcheck
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
@@ -1650,6 +1650,7 @@ cq *qc_find(qc *cache, int id);
 cq *qc_insert(qc *cache, allocator *sa, sql_rel *r, symbol *s, list *params, 
mapi_query_t type, char *codedstr, int no_mitosis);
 void rel_base_use_all(mvc *sql, sql_rel *rel);
 sql_rel *rel_basetable(mvc *sql, sql_table *t, const char *tname);
+list *rel_boundvar(mvc *sql, sql_rel *rel);
 sql_rel *rel_project(allocator *sa, sql_rel *l, list *e);
 list *rel_projections(mvc *sql, sql_rel *rel, const char *tname, int settname, 
int intern);
 void res_tables_destroy(res_table *results);
diff --git a/clients/examples/CMakeLists.txt b/clients/examples/CMakeLists.txt
--- a/clients/examples/CMakeLists.txt
+++ b/clients/examples/CMakeLists.txt
@@ -11,3 +11,4 @@
 add_subdirectory(C)
 add_subdirectory(perl)
 add_subdirectory(php)
+add_subdirectory(python)
diff --git a/clients/examples/python/CMakeLists.txt 
b/clients/examples/python/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/clients/examples/python/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+# 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 https://mozilla.org/MPL/2.0/.
+#
+# For copyright information, see the file debian/copyright.
+#]]
+
+install(FILES
+  sqlsample.py
+  PERMISSIONS ${PROGRAM_PERMISSIONS_DEFAULT}
+  DESTINATION ${CMAKE_INSTALL_BINDIR}
+  COMPONENT clienttest)
diff --git a/debian/monetdb-client-testing.install 
b/debian/monetdb-client-testing.install
--- a/debian/monetdb-client-testing.install
+++ b/debian/monetdb-client-testing.install
@@ -17,5 +17,6 @@ debian/tmp/usr/bin/smack00 usr/bin
 debian/tmp/usr/bin/smack01 usr/bin
 debian/tmp/usr/bin/sqlsample.php usr/bin
 debian/tmp/usr/bin/sqlsample.pl usr/bin
+debian/tmp/usr/bin/sqlsample.py usr/bin
 debian/tmp/usr/bin/streamcat usr/bin
 debian/tmp/usr/bin/testcondvar usr/bin
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -1922,7 +1922,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                        if (r) { /* check new ordered aggregation */
                                list *obe = r->h->data;
                                if (obe && obe->h) {
-                                       stmt *orderby = NULL, *orderby_ids, 
*orderby_grp;
+                                       stmt *orderby = NULL, *orderby_ids = 
NULL, *orderby_grp = NULL;
                                        /* order by */
                                        if (grp) {
                                                orderby = stmt_order(be, grp, 
true, true);
@@ -1944,6 +1944,8 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                                orderby_ids = stmt_result(be, 
orderby, 1);
                                                orderby_grp = stmt_result(be, 
orderby, 2);
                                        }
+                                       if (!orderby_ids)
+                                               return NULL;
                                        /* depending on type of aggr project 
input or ordered column */
                                        for (node *n = l->h; n; n = n->next)
                                                n->data = stmt_project(be, 
orderby_ids, n->data);
@@ -2714,7 +2716,6 @@ rel2bin_table(backend *be, sql_rel *rel,
                sql_subfunc *f = op->f;
                stmt *psub = NULL;
                list *ops = NULL;
-               stmt *ids = NULL;
 
                if (rel->l) { /* first construct the sub relation */
                        sql_rel *l = rel->l;
@@ -2732,22 +2733,31 @@ rel2bin_table(backend *be, sql_rel *rel,
                }
 
                assert(f);
-               if (f->func->res && list_length(f->func->res) + 1 == 
list_length(rel->exps) && !f->func->varres) {
+               list *outers = NULL;
+               if (f->func->res && rel->nr_outers && list_length(f->func->res) 
+ rel->nr_outers == list_length(rel->exps) && !f->func->varres) {
                        /* add inputs in correct order ie loop through args of 
f and pass column */
                        list *exps = op->l;
+                       outers = sa_list(be->mvc->sa);
                        ops = sa_list(be->mvc->sa);
                        if (exps) {
-                               for (node *en = exps->h; en; en = en->next) {
+                               node *en = exps->h;
+                               for (int c = 0; en && c < rel->nr_outers; en = 
en->next, c++) {
                                        sql_exp *e = en->data;
 
                                        /* find column */
                                        stmt *s = exp_bin(be, e, sub, NULL, 
NULL, NULL, NULL, NULL, 0, 0, 0);
                                        if (!s)
                                                return NULL;
-                                       if (en->next)
-                                               append(ops, s);
-                                       else /* last added exp is the ids (todo 
use name base lookup !!) */
-                                               ids = s;
+                                       append(outers, s);
+                               }
+                               for (; en; en = en->next) {
+                                       sql_exp *e = en->data;
+
+                                       /* find column */
+                                       stmt *s = exp_bin(be, e, sub, NULL, 
NULL, NULL, NULL, NULL, 0, 0, 0);
+                                       if (!s)
+                                               return NULL;
+                                       append(ops, s);
                                }
                        }
                } else {
@@ -2774,18 +2784,21 @@ rel2bin_table(backend *be, sql_rel *rel,
                                int i = 0;
 
                                /* correlated table returning function */
-                               if (list_length(f->func->res) + 1 == 
list_length(rel->exps)) {
+                               if (rel->nr_outers && 
(list_length(f->func->res) + rel->nr_outers) == list_length(rel->exps)) {
                                        /* use a simple nested loop solution 
for this case, ie
-                                        * output a table of (input) row-ids, 
the output of the table producing function
+                                        * output a table of (input) row, the 
output of the table producing function
                                         */
                                        /* make sure the input for 
sql.unionfunc are bats */
-                                       if (ids)
-                                               ids = column(be, ids);
+                                       if (outers)
+                                               for(node *n = outers->h; n; n = 
n->next)
+                                                       n->data = column(be, 
n->data);
                                        if (ops)
                                                for (node *en = ops->h; en; en 
= en->next)
                                                        en->data = column(be, 
(stmt *) en->data);
 
-                                       int narg = 3 + list_length(rel->exps);
+                                       int narg = 2 + list_length(rel->exps);
+                                       if (outers)
+                                               narg += list_length(outers);
                                        if (ops)
                                                narg += list_length(ops);
                                        InstrPtr q = newStmtArgs(be->mb, 
sqlRef, "unionfunc", narg);
@@ -2813,14 +2826,18 @@ rel2bin_table(backend *be, sql_rel *rel,
                                        str fcn = backend_function_imp(be, 
f->func);
                                        q = pushStr(be->mb, q, mod);
                                        q = pushStr(be->mb, q, fcn);
+                                       q = pushInt(be->mb, q, rel->nr_outers);
                                        psub = stmt_direct_func(be, q);
                                        if (psub == NULL) {
                                                freeInstruction(be->mb, q);
                                                return NULL;
                                        }
 
-                                       if (ids) /* push input rowids column */
-                                               q = pushArgument(be->mb, q, 
ids->nr);
+                                       if (outers) /* push input row column */
+                                               for (node *n = outers->h; n; n 
= n->next) {
+                                                       stmt *outer = n->data;
+                                                       q = 
pushArgument(be->mb, q, outer->nr);
+                                               }
 
                                        /* add inputs in correct order ie loop 
through args of f and pass column */
                                        if (ops) {
@@ -2833,9 +2850,8 @@ rel2bin_table(backend *be, sql_rel *rel,
                                        pushInstruction(be->mb, q);
 
                                        /* name output of dependent columns, 
output of function is handled the same as without correlation */
-                                       int len = 
list_length(rel->exps)-list_length(f->func->res);
-                                       assert(len== 1);
-                                       for (i=0, m=rel->exps->h; m && i<len; m 
= m->next, i++) {
+                                       //int len = 
list_length(rel->exps)-list_length(f->func->res);
+                                       for (i=0, m=rel->exps->h; m; m = 
m->next, i++) {
                                                sql_exp *exp = m->data;
                                                stmt *s = stmt_rs_column(be, 
psub, i, exp_subtype(exp));
 
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
@@ -203,7 +203,9 @@ has_groupby(sql_rel *rel)
                case op_buildhash:
                case op_probehash:
                case op_partition:
-                       return has_groupby(rel->l);
+                       if (rel->l)
+                               return has_groupby(rel->l);
+                       return 0;
                case op_insert:
                case op_update:
                case op_delete:
@@ -237,11 +239,14 @@ has_groupby(sql_rel *rel)
 #define EPB 3
 
 static sql_rel *
-rel_partition(mvc *sql, sql_rel *rel)
+rel_partition(visitor *v, mvc *sql, sql_rel *rel)
 {
        if (mvc_highwater(sql))
                return sql_error(sql, 10, SQLSTATE(42000) "Query too complex: 
running out of stack space");
 
+       if (v->opt >= 0 && rel->opt >= v->opt) /* only once */
+        return 0;
+
        switch (rel->op) {
        case op_basetable:
        case op_sample:
@@ -252,7 +257,7 @@ rel_partition(mvc *sql, sql_rel *rel)
        case op_groupby:
        case op_topn:
                if (rel->l)
-                       rel_partition(sql, rel->l);
+                       rel_partition(v, sql, rel->l);
                break;
        case op_semi:
        case op_anti:
@@ -260,20 +265,20 @@ rel_partition(mvc *sql, sql_rel *rel)
        case op_inter:
        case op_except:
                if (rel->l)
-                       rel_partition(sql, rel->l);
+                       rel_partition(v, sql, rel->l);
                if (rel->r)
-                       rel_partition(sql, rel->r);
+                       rel_partition(v, sql, rel->r);
                break;
        case op_munion:
                for (node *n = ((list*)rel->l)->h; n; n = n->next)
-                       rel_partition(sql, n->data);
+                       rel_partition(v, sql, n->data);
                break;
        case op_insert:
        case op_update:
        case op_delete:
        case op_truncate:
                if (rel->r /*&& rel->card <= CARD_AGGR*/)
-                       rel_partition(sql, rel->r);
+                       rel_partition(v, sql, rel->r);
                break;
        case op_join:
        case op_left:
@@ -281,9 +286,9 @@ rel_partition(mvc *sql, sql_rel *rel)
        case op_full:
                if (has_groupby(rel->l) || has_groupby(rel->r)) {
                        if (rel->l)
-                               rel_partition(sql, rel->l);
+                               rel_partition(v, sql, rel->l);
                        if (rel->r)
-                               rel_partition(sql, rel->r);
+                               rel_partition(v, sql, rel->r);
                } else {
                        _rel_partition(sql, rel);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to