Changeset: 4c0d1a200646 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4c0d1a200646
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_statement.c
        sql/server/rel_exp.c
        sql/server/rel_optimize_sel.c
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (truncated from 810 to 300 lines):

diff --git a/documentation/source/build.rst b/documentation/source/build.rst
--- a/documentation/source/build.rst
+++ b/documentation/source/build.rst
@@ -99,12 +99,12 @@ README-Fedora .... Which version
 Windows
 =======
 
-Run as Administrator::
+Start cmd.exe in "Run as administrator" mode and run commands::
 
   @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile 
-InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object 
System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && 
SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
   choco feature enable -n allowGlobalConfirmation
-  choco install ActivePerl ant ruby python3 hg git winflexbison
-  cinst VisualStudio2019community --package-parameters "--add 
Microsoft.VisualStudio.Workload.NativeDesktop --add 
microsoft.visualstudio.component.vc.cmake.project --add 
microsoft.visualstudio.component.vc.ATLMFC"
+  choco install ActivePerl ant ruby python3 hg git winflexbison3
+  choco install VisualStudio2022community --package-parameters "--add 
Microsoft.VisualStudio.Workload.NativeDesktop --add 
microsoft.visualstudio.component.vc.cmake.project"
   refreshenv
 
   cd \
@@ -114,19 +114,19 @@ Run as Administrator::
   vcpkg integrate install
   # needed for 64 bits (with the available python being 64 bit this is needed)
   set VCPKG_DEFAULT_TRIPLET=x64-windows
-  vcpkg install libiconv bzip2 geos libxml2 pcre pcre2 zlib getopt
+  vcpkg install libiconv bzip2 geos libxml2 pcre pcre2 zlib getopt openssl
 
 To compile MonetDB (as normal user)::
 
   hg clone https://dev.monetdb.org/hg/MonetDB/
 
-  "c:\Program Files (x86)\Microsoft Visual 
Studio\2019\Community\common7\tools\vsdevcmd.bat"
-  "c:\Program Files (x86)\Microsoft Visual 
Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
+  "c:\Program Files\Microsoft Visual 
Studio\2022\Community\common7\tools\vsdevcmd.bat"
+  "c:\Program Files\Microsoft Visual 
Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
 
   cd MonetDB
   mkdir build
   cd build
-  cmake -G "Visual Studio 16 2019" 
-DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake 
-DCMAKE_INSTALL_PREFIX=%HOME%\install -A x64 ..
+  cmake -G "Visual Studio 17 2022" 
-DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake 
-DCMAKE_INSTALL_PREFIX=%HOME%\install -A x64 ..
   cmake --build . --target ALL_BUILD --config Release
   cmake --build . --target INSTALL --config Release
   set 
PATH=%HOME%\install\bin;%HOME%\install\lib;%HOME%\install\lib\monetdb5;\vcpkg\installed\x64-windows\bin;\vcpkg\installed\x64-windows\debug\bin;%PATH%
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -1043,6 +1043,7 @@ term(Client cntxt, MalBlkPtr curBlk, Ins
                                tpe = typeElm(cntxt, getVarType(curBlk, 
cstidx));
                                if (tpe < 0)
                                        return 3;
+                               cst.bat = isaBatType(tpe);
                                if (tpe != getVarType(curBlk, cstidx)) {
                                        cstidx = defConstant(curBlk, tpe, &cst);
                                        if (cstidx < 0)
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
@@ -1605,6 +1605,15 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                if (from->type->eclass == EC_SEC && to->type->eclass == EC_SEC) 
{
                        // trivial conversion because EC_SEC is always in 
milliseconds
                        s = l;
+               } else if (depth && sel && l->nrcols == 0 && left && 
left->nrcols && exp_unsafe(e, false, true)) {
+                       stmt *rows = bin_find_smallest_column(be, left);
+                       l = stmt_const(be, rows, l);
+                       s = stmt_convert(be, l, sel, from, to);
+               } else if (depth && l->nrcols == 0 && left && left->nrcols && 
from->type->localtype > to->type->localtype &&
+                               exp_unsafe(e, false, true)) {
+                       stmt *rows = bin_find_smallest_column(be, left);
+                       l = stmt_const(be, rows, l);
+                       s = stmt_convert(be, l, sel, from, to);
                } else {
                        s = stmt_convert(be, l, (!push&&l->nrcols==0)?NULL:sel, 
from, to);
                }
@@ -2829,12 +2838,12 @@ can_join_exp(sql_rel *rel, sql_exp *e, b
                        sql_exp *l = e->l, *r = e->r, *f = e->f;
 
                        if (f) {
-                               int ll = rel_find_exp(rel->l, l) != NULL;
-                               int rl = rel_find_exp(rel->r, l) != NULL;
-                               int lr = rel_find_exp(rel->l, r) != NULL;
-                               int rr = rel_find_exp(rel->r, r) != NULL;
-                               int lf = rel_find_exp(rel->l, f) != NULL;
-                               int rf = rel_find_exp(rel->r, f) != NULL;
+                               int ll = rel_has_exp(rel->l, l, true) == 0;
+                               int rl = rel_has_exp(rel->r, l, true) == 0;
+                               int lr = rel_has_exp(rel->l, r, true) == 0;
+                               int rr = rel_has_exp(rel->r, r, true) == 0;
+                               int lf = rel_has_exp(rel->l, f, true) == 0;
+                               int rf = rel_has_exp(rel->r, f, true) == 0;
                                int nrcr1 = 0, nrcr2 = 0, nrcl1 = 0, nrcl2 = 0;
 
                                if ((ll && !rl &&
@@ -2848,15 +2857,15 @@ can_join_exp(sql_rel *rel, sql_exp *e, b
                        } else {
                                int ll = 0, lr = 0, rl = 0, rr = 0, cst = 0;
                                if (l->card != CARD_ATOM || !exp_is_atom(l)) {
-                                       ll = rel_find_exp(rel->l, l) != NULL;
-                                       rl = rel_find_exp(rel->r, l) != NULL;
+                                       ll = rel_has_exp(rel->l, l, true) == 0;
+                                       rl = rel_has_exp(rel->r, l, true) == 0;
                                } else if (anti) {
                                        ll = 1;
                                        cst = 1;
                                }
                                if (r->card != CARD_ATOM || !exp_is_atom(r)) {
-                                       lr = rel_find_exp(rel->l, r) != NULL;
-                                       rr = rel_find_exp(rel->r, r) != NULL;
+                                       lr = rel_has_exp(rel->l, r, true) == 0;
+                                       rr = rel_has_exp(rel->r, r, true) == 0;
                                } else if (anti) {
                                        rr = cst?0:1;
                                }
@@ -2871,16 +2880,16 @@ can_join_exp(sql_rel *rel, sql_exp *e, b
                                sql_exp *ee = n->data;
 
                                if (ee->card != CARD_ATOM || !exp_is_atom(ee)) {
-                                       ll |= rel_find_exp(rel->l, ee) != NULL;
-                                       rl |= rel_find_exp(rel->r, ee) != NULL;
+                                       ll |= rel_has_exp(rel->l, ee, true) == 
0;
+                                       rl |= rel_has_exp(rel->r, ee, true) == 
0;
                                }
                        }
                        for (node *n = r->h ; n ; n = n->next) {
                                sql_exp *ee = n->data;
 
                                if (ee->card != CARD_ATOM || !exp_is_atom(ee)) {
-                                       lr |= rel_find_exp(rel->l, ee) != NULL;
-                                       rr |= rel_find_exp(rel->r, ee) != NULL;
+                                       lr |= rel_has_exp(rel->l, ee, true) == 
0;
+                                       rr |= rel_has_exp(rel->r, ee, true) == 
0;
                                }
                        }
                        if ((ll && !lr && !rl && rr) || (!ll && lr && rl && 
!rr))
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
@@ -3770,7 +3770,7 @@ temporal_convert(backend *be, stmt *v, s
        MalBlkPtr mb = be->mb;
        InstrPtr q = NULL;
        const char *convert = t->type->impl, *mod = mtimeRef;
-       bool add_tz = false, pushed = (v->cand && v->cand == sel);
+       bool add_tz = false, pushed = (v->cand && v->cand == sel), cand = 0;
 
        if (before) {
                if (f->type->eclass == EC_TIMESTAMP_TZ && (t->type->eclass == 
EC_TIMESTAMP || t->type->eclass == EC_TIME)) {
@@ -3801,6 +3801,7 @@ temporal_convert(backend *be, stmt *v, s
                                convert = "timestamptz";
                        mod = calcRef;
                        add_tz = true;
+                       cand = 1;
                } else {
                        return v;
                }
@@ -3832,17 +3833,28 @@ temporal_convert(backend *be, stmt *v, s
        }
        q = pushArgument(mb, q, v->nr);
 
+       if (cand) {
+               if (sel && !pushed && !v->cand) {
+                       q = pushArgument(mb, q, sel->nr);
+                       pushed = 1;
+               } else if (v->nrcols > 0) {
+                       q = pushNilBat(mb, q);
+               }
+       }
+
        if (EC_VARCHAR(f->type->eclass))
                q = pushInt(mb, q, t->digits);
 
        if (add_tz)
                        q = pushLng(mb, q, be->mvc->timezone);
 
-       if (sel && !pushed && !v->cand) {
-               q = pushArgument(mb, q, sel->nr);
-               pushed = 1;
-       } else if (v->nrcols > 0) {
-               q = pushNilBat(mb, q);
+       if (!cand) {
+               if (sel && !pushed && !v->cand) {
+                       q = pushArgument(mb, q, sel->nr);
+                       pushed = 1;
+               } else if (v->nrcols > 0) {
+                       q = pushNilBat(mb, q);
+               }
        }
 
        bool enabled = be->mvc->sa->eb.enabled;
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -1741,6 +1741,27 @@ exps_find_prop(list *exps, rel_prop kind
        return NULL;
 }
 
+/* check is one of the exps can be found in this relation */
+static sql_exp* rel_find_exp_and_corresponding_rel_(sql_rel *rel, sql_exp *e, 
bool subexp, sql_rel **res);
+
+static bool
+rel_find_exps_and_corresponding_rel_(sql_rel *rel, list *l, bool subexp, 
sql_rel **res)
+{
+       int all = 1;
+
+       if (list_empty(l))
+               return true;
+       for(node *n = l->h; n && (subexp || all); n = n->next) {
+               sql_exp *ne = rel_find_exp_and_corresponding_rel_(rel, n->data, 
subexp, res);
+               if (subexp && ne)
+                       return true;
+               all &= (ne?1:0);
+       }
+       if (all)
+               return true;
+       return false;
+}
+
 static sql_exp *
 rel_find_exp_and_corresponding_rel_(sql_rel *rel, sql_exp *e, bool subexp, 
sql_rel **res)
 {
@@ -1767,22 +1788,28 @@ rel_find_exp_and_corresponding_rel_(sql_
                return rel_find_exp_and_corresponding_rel_(rel, e->l, subexp, 
res);
        case e_aggr:
        case e_func:
-               if (e->l) {
-                       list *l = e->l;
-                       node *n = l->h;
-
-                       ne = n->data;
-                       while ((subexp || ne != NULL) && n != NULL) {
-                               ne = rel_find_exp_and_corresponding_rel_(rel, 
n->data, subexp, res);
-                               if (subexp && ne)
-                                       break;
-                               n = n->next;
-                       }
-                       return ne;
+               if (e->l)
+                       if (rel_find_exps_and_corresponding_rel_(rel, e->l, 
subexp, res))
+                               return e;
+               return NULL;
+       case e_cmp:
+               if (!subexp)
+                       return NULL;
+
+               if (e->flag == cmp_or || e->flag == cmp_filter) {
+                       if (rel_find_exps_and_corresponding_rel_(rel, e->l, 
subexp, res) ||
+                               rel_find_exps_and_corresponding_rel_(rel, e->r, 
subexp, res))
+                               return e;
+               } else if (e->flag == cmp_in || e->flag == cmp_notin) {
+                       if (rel_find_exp_and_corresponding_rel_(rel, e->l, 
subexp, res) ||
+                               rel_find_exps_and_corresponding_rel_(rel, e->r, 
subexp, res))
+                               return e;
+               } else if (rel_find_exp_and_corresponding_rel_(rel, e->l, 
subexp, res) ||
+                           rel_find_exp_and_corresponding_rel_(rel, e->r, 
subexp, res) ||
+                           (!e->f || rel_find_exp_and_corresponding_rel_(rel, 
e->f, subexp, res))) {
+                               return e;
                }
-               break;
-               /* fall through */
-       case e_cmp:
+               return NULL;
        case e_psm:
                return NULL;
        case e_atom:
@@ -1934,7 +1961,8 @@ exp_single_bound_cmp_exp_is_false(sql_ex
 }
 
 static inline bool
-exp_two_sided_bound_cmp_exp_is_false(sql_exp* e) {
+exp_two_sided_bound_cmp_exp_is_false(sql_exp* e)
+{
     assert(e->type == e_cmp);
     sql_exp* v = e->l;
     sql_exp* l = e->r;
@@ -1945,7 +1973,8 @@ exp_two_sided_bound_cmp_exp_is_false(sql
 }
 
 static inline bool
-exp_regular_cmp_exp_is_false(sql_exp* e) {
+exp_regular_cmp_exp_is_false(sql_exp* e)
+{
     assert(e->type == e_cmp);
 
     if (is_semantics(e) && !is_any(e)) return exp_is_cmp_exp_is_false(e);
@@ -2054,6 +2083,17 @@ exp_is_not_null(sql_exp *e)
        return false;
 }
 
+static int
+exps_have_null(list *l)
+{
+       if (!l)
+               return false;
+       for(node *n = l->h; n; n = n->next)
+               if (exp_is_null(n->data))
+                       return true;
+       return false;
+}
+
 int
 exp_is_null(sql_exp *e )
 {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to