Changeset: 6acf7f50a952 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6acf7f50a952
Modified Files:
        monetdb5/optimizer/opt_mergetable.c
        sql/backends/monet5/sql_upgrades.c
        sql/server/rel_select.c
        sql/server/rel_unnest.c
        sql/test/subquery/Tests/subquery3.sql
        sql/test/subquery/Tests/subquery3.stable.out
Branch: grouping-analytics
Log Message:

Merge with default


diffs (113 lines):

diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -312,7 +312,7 @@ mat_delta(matlist_t *ml, MalBlkPtr mb, I
                                        if(!q)
                                                return NULL;
 
-                                       /* remove last argument */
+                                       /* remove last argument (inserts only 
on last part) */
                                        if (k < mat[m].mi->argc-1)
                                                q->argc--;
                                        /* make sure to resolve again */
@@ -344,7 +344,7 @@ mat_delta(matlist_t *ml, MalBlkPtr mb, I
                        if(!q)
                                return NULL;
 
-                       /* remove last argument */
+                       /* remove last argument (inserts only on last part) */
                        if (k < mat[m].mi->argc-1)
                                q->argc--;
                        /* make sure to resolve again */
@@ -2135,7 +2135,7 @@ OPTmergetableImplementation(Client cntxt
 
                /* delta* operator have a ins bat as last argument, we move the 
inserts into the last delta statement, ie
                 * all but last need to remove one argument */
-               if (match == 3 && bats == 4 && isDelta(p) && 
+               if (match == 3 && (bats == 4 || bats == 5) && isDelta(p) && 
                   (m=is_a_mat(getArg(p,fm), &ml)) >= 0 &&
                   (n=is_a_mat(getArg(p,fn), &ml)) >= 0 &&
                   (o=is_a_mat(getArg(p,fo), &ml)) >= 0){
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -1972,6 +1972,9 @@ sql_update_nov2019_missing_dependencies(
                                                                
FLUSH_INSERTS_IF_BUFFERFILLED
                                                        }
                                                }
+                                       } else if (sql->session->status == -1) {
+                                               sql->session->status = 0;
+                                               sql->errstr[0] = 0;
                                        }
                                }
                        }
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -3188,7 +3188,7 @@ static sql_exp *
                if (uaname)
                        GDKfree(uaname);
                return e;
-       } else if (is_sql_join(f)) { /* the is_sql_join test must come before 
is_sql_where, because the join conditions are handled with sql_where */
+       } else if (!query_has_outer(query) && is_sql_join(f)) { /* the 
is_sql_join test must come before is_sql_where, because the join conditions are 
handled with sql_where */
                char *uaname = GDKmalloc(strlen(aname) + 1);
                sql_exp *e = sql_error(sql, 02, SQLSTATE(42000) "%s: aggregate 
functions not allowed in JOIN conditions",
                                       uaname ? toUpperCopy(uaname, aname) : 
aname);
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -1479,7 +1479,10 @@ rewrite_simplify_exp(mvc *sql, sql_rel *
                if (is_func(ie->type) && list_length(ie->l) == 1 && 
is_not_func(sf)) {
                        args = ie->l;
 
-                       return args->h->data;   
+                       ie = args->h->data;     
+                       if (exp_name(e))
+                               exp_prop_alias(sql->sa, ie, e);
+                       return ie;
                }
        }
        return e;
diff --git a/sql/test/subquery/Tests/subquery3.sql 
b/sql/test/subquery/Tests/subquery3.sql
--- a/sql/test/subquery/Tests/subquery3.sql
+++ b/sql/test/subquery/Tests/subquery3.sql
@@ -148,6 +148,16 @@ GROUP BY col1; --MonetDB outputs this on
        -- 2468
        -- 2468
 
+SELECT
+    NOT AVG(col2) * col1 <> ANY (SELECT 20 FROM tbl_ProductSales HAVING 
MAX(col1) IS NULL) AS a1
+FROM another_T
+GROUP BY col1, col2, col5
+ORDER BY a1 NULLS FIRST;
+       -- True
+       -- True
+       -- True
+       -- True
+
 /* We shouldn't allow the following internal functions/procedures to be called 
from regular queries */
 --SELECT "identity"(col1) FROM another_T;
 --SELECT "rowid"(col1) FROM another_T;
diff --git a/sql/test/subquery/Tests/subquery3.stable.out 
b/sql/test/subquery/Tests/subquery3.stable.out
--- a/sql/test/subquery/Tests/subquery3.stable.out
+++ b/sql/test/subquery/Tests/subquery3.stable.out
@@ -173,6 +173,19 @@ stdout of test 'subquery3` in directory 
 [ 2468 ]
 [ 2468 ]
 [ 2468 ]
+#SELECT
+#    NOT AVG(col2) * col1 <> ANY (SELECT 20 FROM tbl_ProductSales HAVING 
MAX(col1) IS NULL) AS a1
+#FROM another_T
+#GROUP BY col1, col2, col5
+#ORDER BY a1 NULLS FIRST;
+% . # table_name
+% a1 # name
+% boolean # type
+% 5 # length
+[ true ]
+[ true ]
+[ true ]
+[ true ]
 #DROP TABLE tbl_ProductSales;
 #DROP TABLE another_T;
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to