Changeset: d614d4bdafa2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d614d4bdafa2
Branch: Jun2023
Log Message:

Merge heads.


diffs (170 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -658,8 +658,8 @@ la_bat_updates(logger *lg, logaction *la
        if (bid < 0)
                return GDK_FAIL;
        if (!bid) {
-               GDKerror("la_bat_updates failed to find bid for object %d\n", 
la->cid);
-               return GDK_FAIL;
+               /* object already gone, nothing needed */
+               return GDK_SUCCEED;
        }
 
        if (!lg->flushing) {
diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -1605,6 +1605,9 @@ rel_simplify_groupby_columns(visitor *v,
                                                        if ((!e1ok && e2ok) || 
(e1ok && !e2ok)) {
                                                                sql_exp *c = 
e1ok ? e2 : e1;
                                                                bool done = 
false;
+                                                               exp_col = 
exps_find_exp(efrel->exps, c);
+                                                               if (exp_col)
+                                                                       c = 
exp_col;
 
                                                                while (!done) {
                                                                        if 
(is_numeric_upcast(c))
@@ -1720,13 +1723,13 @@ rel_groupby_cse(visitor *v, sql_rel *rel
                                if (exp_match_exp(e1, e2) || exp_refers(e1, e2) 
|| (e1_sub && e2_sub && (exp_match_exp(e1_sub, e2_sub) || exp_refers(e1_sub, 
e2_sub)))) {
 
                                        /* use e2 from rel->exps instead of e2 
from the rel->r as it can have an alias from the higher rel */
-                                       sql_exp *e2_in_exps = (e2->alias.rname 
== e2->l && e2->alias.name == e2->r) ?
+                                       sql_exp *e2_in_exps = (e2->l && 
e2->alias.rname == e2->l && e2->alias.name == e2->r) ?
                                                exps_bind_column2(rel->exps, 
e2->l, e2->r, NULL) :
                                                exps_bind_column(rel->exps, 
e2->alias.name, NULL, NULL, 0);
                                        assert(e2_in_exps);
 
                                        /* same as e2 */
-                                       sql_exp *e1_in_exps = (e1->alias.rname 
== e1->l && e1->alias.name == e1->r) ?
+                                       sql_exp *e1_in_exps = (e1->l && 
e1->alias.rname == e1->l && e1->alias.name == e1->r) ?
                                                exps_bind_column2(rel->exps, 
e1->l, e1->r, NULL) :
                                                exps_bind_column(rel->exps, 
e1->alias.name, NULL, NULL, 0);
                                        assert(e1_in_exps);
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -5976,8 +5976,6 @@ sql_trans_drop_table(sql_trans *tr, sql_
                if ((res = sys_drop_table(tr, gt?gt:t, drop_action)))
                        return res;
 
-       t->base.deleted = 1;
-
        if (gt && (res = os_del(s->tables, tr, gt->base.name, 
dup_base(&gt->base))))
                return res;
        if (t != gt && (res =os_del(tr->localtmps, tr, t->base.name, 
dup_base(&t->base))))
diff --git a/sql/test/rel-optimizers/optimize-proj/Tests/All 
b/sql/test/rel-optimizers/optimize-proj/Tests/All
new file mode 100644
--- /dev/null
+++ b/sql/test/rel-optimizers/optimize-proj/Tests/All
@@ -0,0 +1,1 @@
+groupby-cse
diff --git a/sql/test/rel-optimizers/optimize-proj/Tests/groupby-cse.test 
b/sql/test/rel-optimizers/optimize-proj/Tests/groupby-cse.test
--- a/sql/test/rel-optimizers/optimize-proj/Tests/groupby-cse.test
+++ b/sql/test/rel-optimizers/optimize-proj/Tests/groupby-cse.test
@@ -107,7 +107,7 @@ CREATE FUNCTION tableReturnUDF ()
 RETURNS TABLE(a1 int, a2 int, a3 int)
 BEGIN
     RETURN SELECT c1, c2, c3 FROM foo;
-END;
+END
 
 # the same expression should be removed from the GROUPBY op list of
 # group expressions (->l) exactly like in the case of basetable
@@ -148,7 +148,7 @@ 2
 2
 1
 
-## GROUPBY <--input-- PROJECT ########################################## 
+## GROUPBY <--input-- PROJECT ##########################################
 
 ## in this example the order by groups are aliases of the same column
 ## coming from the inner projection operator
@@ -295,7 +295,7 @@ project (
 | ) [ "sq"."c1_in_alias_1" as "c1_out_alias_1", "sq"."c2" ] [ 
"c1_out_alias_1", "c1_out_alias_1" as "c1_out_alias_2", "sys"."count" no nil 
("sq"."c3") NOT NULL as "%1"."%1" ]
 ) [ "c1_out_alias_1", "c1_out_alias_2", "%1"."%1" NOT NULL ]
 
-query III rowsort gb-over-pr 
+query III rowsort gb-over-pr
 SELECT
     c1_in_alias_1 AS c1_out_alias_1,
     c1_in_alias_2 AS c1_out_alias_2,
@@ -446,14 +446,14 @@ 1
 query T nosort
 PLAN
 SELECT
-    foo.c2 AS col, 
-    count(*) 
-FROM 
-    foo JOIN bar 
-ON 
-    foo.c2 = bar.c2 
+    foo.c2 AS col,
+    count(*)
+FROM
+    foo JOIN bar
+ON
+    foo.c2 = bar.c2
 GROUP BY
-    foo.c2, 
+    foo.c2,
     col
 ----
 project (
@@ -467,14 +467,14 @@ project (
 
 query II rowsort
 SELECT
-    foo.c2 AS col, 
-    count(*) 
-FROM 
-    foo JOIN bar 
-ON 
-    foo.c2 = bar.c2 
+    foo.c2 AS col,
+    count(*)
+FROM
+    foo JOIN bar
+ON
+    foo.c2 = bar.c2
 GROUP BY
-    foo.c2, 
+    foo.c2,
     col
 ----
 1
@@ -484,7 +484,7 @@ 2
 
 ## GROUPBY <--input-- TOPN/SAMPLE
 # this cannot happen since the TOPN/SAMPLE operators are pushed down to
-# the projections 
+# the projections
 
 ## GROUPBY <--input-- SEMI
 # this would not make sense since the alias cannot (probably?) exist in
@@ -494,9 +494,24 @@ 2
 ## GROUPBY <--input-- UNION
 # TODO: the union operator introduces a distinct in the form of group
 # bys which are NOT processed by the groupby-cse optimizer. this must be
-# investigated more eg 
+# investigated more eg
 # select c1 ca, c1 cb from foo union select c1 ca, c1 cb from bar;
 
 ## GROUPBY <--input-- MERGE
 # not applicable
 
+# crash from clickhouse
+query IIIII nosort
+SELECT c1 AS x, c1 - 1 AS x1, c1 - 2 AS x2, c1 - 3 AS x3, count(*) AS c FROM 
foo GROUP BY x, x1, x2, x3 ORDER BY c DESC LIMIT 10
+----
+1
+0
+-1
+-2
+3
+2
+1
+0
+-1
+1
+
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to