[Commits] 9ada227fb4ec01b34ac29187c2b165208b5b5f40 Post-review addition to the fix for mdev-10868.

Igor Babaev igor at askmonty.org
Fri Sep 30 23:13:18 EEST 2016


commit 9ada227fb4ec01b34ac29187c2b165208b5b5f40
Author: Igor Babaev <igor at askmonty.org>
Commit: Igor Babaev <igor at askmonty.org>

    Post-review addition to the fix for mdev-10868.
---
 mysql-test/r/win.result |   34 +++++++++++++++++++++++++++++++++-
 mysql-test/t/win.test   |   12 +++++++++++-
 sql/sql_window.cc       |    7 ++++++-
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index 7cbf644..746ce5a 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -2348,5 +2348,37 @@ pk	c	CNT
 8	2	0.5000
 9	2	0.4000
 10	2	0.3333
-drop view v1,v2,v3;
+select pk, c, c/count(*) over (partition by c order by pk
+range between 3 preceding and current row) as CNT
+from t1;
+pk	c	CNT
+1	1	1.0000
+2	1	0.5000
+3	1	0.3333
+4	1	0.2500
+5	2	2.0000
+6	2	1.0000
+7	2	0.6667
+8	2	0.5000
+9	2	0.5000
+10	2	0.5000
+create view v4 as select pk, c, c/count(*) over (partition by c order by pk
+range between 3 preceding and current row) as CNT
+from t1;
+show create view v4;
+View	Create View	character_set_client	collation_connection
+v4	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`pk` AS `pk`,`t1`.`c` AS `c`,(`t1`.`c` / count(0) over ( partition by `t1`.`c` order by `t1`.`pk` range between 3 preceding  and  current row )) AS `CNT` from `t1`	latin1	latin1_swedish_ci
+select * from v4;
+pk	c	CNT
+1	1	1.0000
+2	1	0.5000
+3	1	0.3333
+4	1	0.2500
+5	2	2.0000
+6	2	1.0000
+7	2	0.6667
+8	2	0.5000
+9	2	0.5000
+10	2	0.5000
+drop view v1,v2,v3,v4;
 drop table t0,t1;
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index 971e91a..7052368 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -1414,5 +1414,15 @@ eval create view v3 as $q;
 show create view v3;
 select * from v3;
 
-drop view v1,v2,v3;
+let $q=
+select pk, c, c/count(*) over (partition by c order by pk
+                               range between 3 preceding and current row) as CNT
+from t1;
+
+eval $q;
+eval create view v4 as $q;
+show create view v4;
+select * from v4;
+
+drop view v1,v2,v3,v4;
 drop table t0,t1;
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 28be70c..f49cc94 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -107,7 +107,11 @@
   case UNITS_ROWS:
     str->append(STRING_WITH_LEN(" rows "));
     break;
-  case UNITS_RANGE: str->append(STRING_WITH_LEN(" range "));
+  case UNITS_RANGE:
+    str->append(STRING_WITH_LEN(" range "));
+    break; 
+  default:
+    DBUG_ASSERT(0);
   }
 
   str->append(STRING_WITH_LEN("between "));
@@ -129,6 +133,7 @@
        str->append(STRING_WITH_LEN(" ties "));
        break;
      default: 
+       DBUG_ASSERT(0);
        ;
      }
   } 


More information about the commits mailing list