← Back to team overview

maria-developers team mailing list archive

Re: [Commits] 2d6649aa24c: MDEV-13186: main.win failure post MDEV-12336

 

Hi, Vicentiu!

Am 27.06.2017 um 11:31 schrieb vicentiu:
revision-id: 2d6649aa24c77321df349de5cee576dab1e344f4 (mariadb-10.2.6-55-g2d6649aa24c)
parent(s): c036d5ada7a5816d25915a2c6e0b6836b0cd6743
author: Vicențiu Ciorbaru
committer: Vicențiu Ciorbaru
timestamp: 2017-06-27 12:26:38 +0300
message:

MDEV-13186: main.win failure post MDEV-12336

During statement preparation st_order::item gets set to a value in
ref_ptr_array. During statement execution we were overriding that value,
causing subsequent checks for window functions to return true.

Whenever we do any setting from ref_ptr_array, make sure to always
store the value in all_fields as well.

For function items containing window functions, as MDEV-12336 has
discovered, we don't need to create a separate Item_direct_ref or
Item_aggregate_ref as they will be computed directly from the top-level
item once the window function argument columns are computed.

OK to push but add comment before IF with return explaining it.


---
  mysql-test/r/win.result | 12 ++++++++++++
  mysql-test/t/win.test   | 10 ++++++++++
  sql/item.cc             |  6 +++---
  3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index ec83998aa98..a67c336e5b4 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -3085,3 +3085,15 @@ select max(id), rank() over (order by max(id)) from t1 where id < 3;
  max(id)	rank() over (order by max(id))
  2	1
  drop table t1;
+#
+# main.win failure post MDEV-12336
+#
+create table t(a decimal(35,10), b int);
+insert into t values (1, 10), (2, 20), (3, 30);
+prepare stmt from "SELECT (CASE WHEN sum(t.a) over (partition by t.b)=1 THEN 1000 ELSE 300 END) AS a FROM t";
+execute stmt;
+a
+1000
+300
+300
+drop table t;
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index 95d32c5bd14..0ecb2b35074 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -1877,3 +1877,13 @@ select count(max(id)) over (order by max(id)) from t1 where id < 3;
  select max(id), rank() over (order by max(id)) from t1 where id < 3;
drop table t1;
+
+--echo #
+--echo # main.win failure post MDEV-12336
+--echo #
+create table t(a decimal(35,10), b int);
+insert into t values (1, 10), (2, 20), (3, 30);
+
+prepare stmt from "SELECT (CASE WHEN sum(t.a) over (partition by t.b)=1 THEN 1000 ELSE 300 END) AS a FROM t";
+execute stmt;
+drop table t;
diff --git a/sql/item.cc b/sql/item.cc
index df615b5ace9..05e5fd1ce45 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1920,6 +1920,9 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array,
        point to the temporary table.
      */
      split_sum_func(thd, ref_pointer_array, fields, split_flags);
+    if (type() == FUNC_ITEM) {
+      return;
+    }
    }
    else
    {
@@ -1979,9 +1982,6 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array,
                                          &ref_pointer_array[el], 0, name))))
        return;                                   // fatal_error is set
    }
-  else if (type() == FUNC_ITEM &&
-           ((Item_func *) this)->with_window_func)
-    return;
    else
    {
      if (!(item_ref= (new (thd->mem_root)
_______________________________________________
commits mailing list
commits@xxxxxxxxxxx
https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits