Changeset: c5da0e80df1a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c5da0e80df1a
Modified Files:
        sql/server/rel_exp.c
        testing/Mtest.py.in
Branch: default
Log Message:

Merge with Aug2024 branch.


diffs (289 lines):

diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -2875,7 +2875,14 @@ ignorecase(const bat *ic_id, bool *icase
        if ((c = BATdescriptor(*ic_id)) == NULL)
                throw(MAL, fname, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
 
-       assert(BATcount(c) >= 1);
+       if (BATcount(c) != 1) {
+               BUN cnt = BATcount(c);
+               BBPreclaim(c);
+               if (cnt == 0)
+                       throw(MAL, fname, SQLSTATE(42000) "Missing ignore case 
value\n");
+               else
+                       throw(MAL, fname, SQLSTATE(42000) "Multiple ignore case 
values passed, only one expected\n");
+       }
 
        BATiter bi = bat_iterator(c);
        *icase = *(bit *) BUNtloc(bi, 0);
diff --git a/sql/jdbc/tests/Tests/All b/sql/jdbc/tests/Tests/All
--- a/sql/jdbc/tests/Tests/All
+++ b/sql/jdbc/tests/Tests/All
@@ -1,5 +1,5 @@
 HAVE_JDBCTESTS?JDBC_API_Tester
-HAVE_JDBCTESTS?TLSTester
+HAVE_JDBCTESTS&HAVE_CRYPTOGRAPHY?TLSTester
 HAVE_JDBCTESTS?OnClientTester
 HAVE_JDBCCLIENT_JAR?Test_JdbcClient
 # next test should be done AFTER all the other tests have completed
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
@@ -1950,7 +1950,8 @@ exp_is_cmp_exp_is_false(sql_exp* e)
 }
 
 static inline bool
-exp_single_bound_cmp_exp_is_false(sql_exp* e) {
+exp_single_bound_cmp_exp_is_false(sql_exp* e)
+{
     assert(e->type == e_cmp);
     sql_exp* l = e->l;
     sql_exp* r = e->r;
@@ -1984,7 +1985,8 @@ exp_regular_cmp_exp_is_false(sql_exp* e)
 }
 
 static inline bool
-exp_or_exp_is_false(sql_exp* e) {
+exp_or_exp_is_false(sql_exp* e)
+{
     assert(e->type == e_cmp && e->flag == cmp_or);
 
        list* left = e->l;
@@ -2012,7 +2014,8 @@ exp_or_exp_is_false(sql_exp* e) {
 }
 
 static inline bool
-exp_cmp_exp_is_false(sql_exp* e) {
+exp_cmp_exp_is_false(sql_exp* e)
+{
     assert(e->type == e_cmp);
 
     switch (e->flag) {
@@ -2131,7 +2134,7 @@ exp_is_null(sql_exp *e )
                                return ((e->flag == cmp_in && 
exp_is_null(e->l)) ||
                                                (e->flag == cmp_notin && 
(exp_is_null(e->l) || exps_have_null(e->r))));
                        } else if (e->f) {
-                               return exp_is_null(e->l) || (!is_anti(e) && 
(exp_is_null(e->r) || exp_is_null(e->f)));
+                               return exp_is_null(e->l) && exp_is_null(e->r) 
&& exp_is_null(e->f);
                        } else {
                                return exp_is_null(e->l) || exp_is_null(e->r);
                        }
@@ -2660,6 +2663,14 @@ exp_has_func_or_cmp(sql_exp *e, bool cmp
                        return exps_have_func_or_cmp(e->f, true);
                return 0;
        case e_convert:
+               {
+                       sql_subtype *t = exp_totype(e);
+                       sql_subtype *f = exp_fromtype(e);
+                       if (t->type->eclass == EC_FLT && (f->type->eclass == 
EC_DEC || f->type->eclass == EC_NUM))
+                               return exp_has_func_or_cmp(e->l, cmp);
+                       if (f->type->localtype > t->type->localtype)
+                               return true;
+               }
                return exp_has_func_or_cmp(e->l, cmp);
        case e_func:
                return 1;
diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h
--- a/sql/server/rel_exp.h
+++ b/sql/server/rel_exp.h
@@ -160,6 +160,7 @@ extern int exp_is_join(sql_exp *e, list 
 extern int exp_is_eqjoin(sql_exp *e);
 extern int exp_is_join_exp(sql_exp *e);
 extern int exp_is_atom(sql_exp *e);
+/* exp_is_true/false etc return true if the expression is true, on unknown etc 
false is returned */
 extern int exp_is_true(sql_exp *e);
 extern int exp_is_false(sql_exp *e);
 extern int exp_is_zero(sql_exp *e);
diff --git a/sql/server/rel_optimize_exps.c b/sql/server/rel_optimize_exps.c
--- a/sql/server/rel_optimize_exps.c
+++ b/sql/server/rel_optimize_exps.c
@@ -456,7 +456,7 @@ rel_simplify_predicates(visitor *v, sql_
                sql_exp *le = n->data;
                sql_exp *re = n->next->data;
 
-               if (exp_is_atom(le) && !exp_is_null(le) && exp_is_atom(re) && 
le->type == e_atom && le->l && re->type == e_atom && re->l) {
+               if (exp_is_atom(le) && exp_is_not_null(le) && exp_is_atom(re) 
&& le->type == e_atom && le->l && re->type == e_atom && re->l) {
                        n = n->next->next;
                        if (exp_match_exp(le, re)) { /* x==y -> a */
                                sql_exp *res = n->data;
diff --git a/sql/server/rel_rewriter.c b/sql/server/rel_rewriter.c
--- a/sql/server/rel_rewriter.c
+++ b/sql/server/rel_rewriter.c
@@ -187,7 +187,7 @@ rewrite_simplify_exp(visitor *v, sql_rel
                sql_exp *l = e->l, *r = e->r;
                if (is_func(l->type) && exp_is_true(r) && 
(is_anyequal_func(((sql_subfunc*)l->f)) || 
is_exists_func(((sql_subfunc*)l->f))))
                        return l;
-               if (is_func(l->type) && exp_is_false(r) && !exp_is_null(r) && 
(is_anyequal_func(((sql_subfunc*)l->f)) || 
is_exists_func(((sql_subfunc*)l->f)))) {
+               if (is_func(l->type) && exp_is_false(r) && exp_is_not_null(r) 
&& (is_anyequal_func(((sql_subfunc*)l->f)) || 
is_exists_func(((sql_subfunc*)l->f)))) {
                        sql_subfunc *sf = l->f;
                        if (is_anyequal_func(sf))
                                return exp_in_func(v->sql, 
((list*)l->l)->h->data, ((list*)l->l)->h->next->data, !is_anyequal(sf), 0);
diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c
--- a/sql/server/rel_statistics.c
+++ b/sql/server/rel_statistics.c
@@ -1101,11 +1101,11 @@ rel_get_statistics_(visitor *v, sql_rel 
 
                if (lv != BUN_NONE) {
                        sql_exp *le = rel->exps->h->data, *oe = 
list_length(rel->exps) > 1 ? rel->exps->h->next->data : NULL;
-                       if (oe && oe->l && !exp_is_null(oe)) { /* no parameters 
*/
+                       if (oe && oe->l && exp_is_not_null(oe)) { /* no 
parameters */
                                BUN offset = (BUN) 
((atom*)oe->l)->data.val.lval;
                                lv = offset >= lv ? 0 : lv - offset;
                        }
-                       if (le->l && !exp_is_null(le)) {
+                       if (le->l && exp_is_not_null(le)) {
                                BUN limit = (BUN) ((atom*)le->l)->data.val.lval;
                                lv = MIN(lv, limit);
                        }
diff --git a/sql/test/BugTracker-2024/Tests/7554-incorrect-result-between.test 
b/sql/test/BugTracker-2024/Tests/7554-incorrect-result-between.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/7554-incorrect-result-between.test
@@ -0,0 +1,8 @@
+query T
+SELECT (1 BETWEEN NULL AND -1) IS NULL
+----
+False
+
+query I
+SELECT 1 WHERE ((1 BETWEEN NULL AND -1) IS NULL)
+----
diff --git 
a/sql/test/BugTracker-2024/Tests/7555-incorrect-semijoin-rewrite.test 
b/sql/test/BugTracker-2024/Tests/7555-incorrect-semijoin-rewrite.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/7555-incorrect-semijoin-rewrite.test
@@ -0,0 +1,32 @@
+statement ok
+CREATE TABLE t1 (c1 BOOLEAN)
+
+statement ok
+CREATE TABLE t0 (c0 INTEGER, PRIMARY KEY(c0) )
+
+statement ok
+INSERT INTO t1(c1) VALUES (true)
+
+statement ok
+INSERT INTO t0(c0) VALUES (2)
+
+statement ok
+INSERT INTO t0(c0) VALUES (1)
+
+query T
+SELECT t1.c1 FROM t0, t1 WHERE (NOT (t1.c1 != CAST(t0.c0 AS BOOLEAN)))
+----
+True
+True
+
+query T
+SELECT t1.c1 FROM t0, t1 WHERE (NOT (t1.c1 != CAST(t0.c0 AS BOOLEAN))) UNION 
ALL SELECT t1.c1 FROM t0, t1 WHERE (t1.c1 != CAST(t0.c0 AS BOOLEAN))
+----
+True
+True
+
+statement ok
+DROP table t0
+
+statement ok
+DROP table t1
diff --git a/sql/test/BugTracker-2024/Tests/7556-missing-ignore-case.test 
b/sql/test/BugTracker-2024/Tests/7556-missing-ignore-case.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/7556-missing-ignore-case.test
@@ -0,0 +1,14 @@
+statement ok
+CREATE TABLE  t0 ( c1 INTEGER  )
+
+statement ok
+CREATE VIEW v0(c0) AS SELECT NOT('a') FROM t0 ORDER BY (1)
+
+statement error
+SELECT v0.c0 FROM v0, t0 WHERE (STARTSWITH(t0.c1, v0.c0, v0.c0))
+
+statement ok
+DROP VIEW v0
+
+statement ok
+DROP TABLE t0
diff --git a/sql/test/BugTracker-2024/Tests/All 
b/sql/test/BugTracker-2024/Tests/All
--- a/sql/test/BugTracker-2024/Tests/All
+++ b/sql/test/BugTracker-2024/Tests/All
@@ -78,3 +78,6 @@ 7550-select-statistics-auth
 7552-nested-expression-with-null
 7553-join-on-startswith-crash
 7045-do-not-push-down-converts
+7554-incorrect-result-between
+7555-incorrect-semijoin-rewrite
+7556-missing-ignore-case
diff --git a/sql/test/merge-partitions/Tests/mergepart21.test 
b/sql/test/merge-partitions/Tests/mergepart21.test
--- a/sql/test/merge-partitions/Tests/mergepart21.test
+++ b/sql/test/merge-partitions/Tests/mergepart21.test
@@ -34,7 +34,9 @@ CREATE TABLE subtable2 (a int, b int, dd
 statement ok rowcount 1
 INSERT INTO subtable1 VALUES (4, 2, 1.2)
 
-statement error 22018!conversion of string 'ups' to type lng failed.
+# can be either "conversion of string 'ups' to type lng failed."
+# or "conversion of string to type lng failed."
+statement error 22018!conversion of string ...
 ALTER TABLE nexttest ADD TABLE subtable1 AS PARTITION IN ('ups')
 
 statement ok
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -402,12 +402,8 @@ CONDITIONALS = {
     'HAVE_JDBCCLIENT_JAR'  : False,
     'HAVE_JDBCTESTS_JAR'   : False,
     'HAVE_JDBCTESTS'       : False,
-#    'HAVE_LIBPANDAS3'      : False,
-    'HAVE_LIBSCIPY3'       : False,
     'HAVE_PERL'            : False,
     'HAVE_PHP'             : False,
-    'HAVE_PYODBC'          : False,
-    'HAVE_PYTHON_LZ4'      : False, # module lz4 is available
     'HAVE_RUBY'            : False,
     'HAVE_CPP'             : False,
     'HAVE_DATA_PATH'       : False,
@@ -416,6 +412,12 @@ CONDITIONALS = {
     'BAD_HOSTNAME'         : False,
     'HAVE_IPV6'            : False,
     'NOWAL'                : False,
+    # optional Python modules
+#    'HAVE_LIBPANDAS3'      : False,
+    'HAVE_LIBSCIPY3'       : False, # import scipy
+    'HAVE_CRYPTOGRAPHY'    : False, # import cryptography
+    'HAVE_PYODBC'          : False, # import pyodbc
+    'HAVE_PYTHON_LZ4'      : False, # import lz4
 }
 
 # a bunch of classes to help with generating (X)HTML files
@@ -3705,6 +3707,13 @@ def main(argv) :
     else:
         CONDITIONALS['HAVE_LIBSCIPY3'] = True
 
+    try:
+        import cryptography
+    except ImportError:
+        CONDITIONALS['HAVE_CRYPTOGRAPHY'] = False
+    else:
+        CONDITIONALS['HAVE_CRYPTOGRAPHY'] = True
+
     if env.get('TSTDATAPATH'):
         CONDITIONALS['HAVE_DATA_PATH'] = True
 
diff --git a/testing/sqllogictest.py b/testing/sqllogictest.py
--- a/testing/sqllogictest.py
+++ b/testing/sqllogictest.py
@@ -303,8 +303,9 @@ class SQLLogic:
                             if expected_err_msg.lower() == 
err_msg_received.lower():
                                 return result
                     msg = "statement was expected to fail with" \
-                            + (" error code {}".format(expected_err_code) if 
expected_err_code else '')\
-                            + (", error message 
{}".format(str(expected_err_msg)) if expected_err_msg else '')
+                            + (f" error code {expected_err_code}" if 
expected_err_code else '') \
+                            + (f", error message {repr(expected_err_msg)}" if 
expected_err_msg else '') \
+                            + f", received code {err_code_received}, message 
{repr(err_msg_received)}"
                     self.query_error(err_stmt or statement, str(msg), str(e))
                 return result
         except ConnectionError as e:
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to