summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-08-15 10:32:42 +0400
committerAlexander Barkov <bar@mariadb.com>2019-08-15 10:32:42 +0400
commit841294cfaa0e9591de446a4f083477b61e05e3cc (patch)
tree30d9121175196222b24579e9c21ad2ba1505689f
parentc23a5e0e5eecad9ec8a8f5ffa1f28a86c5b2b261 (diff)
downloadmariadb-git-841294cfaa0e9591de446a4f083477b61e05e3cc.tar.gz
MDEV-20351 Window function BIT_OR() OVER (..) return a wrong data type
-rw-r--r--mysql-test/main/win.result35
-rw-r--r--mysql-test/main/win.test23
-rw-r--r--sql/item_windowfunc.h2
3 files changed, 59 insertions, 1 deletions
diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result
index 412bfca4bf2..80c4109fe27 100644
--- a/mysql-test/main/win.result
+++ b/mysql-test/main/win.result
@@ -3654,5 +3654,40 @@ d x
00:00:02 NULL
DROP TABLE t1;
#
+# MDEV-20351 Window function BIT_OR() OVER (..) return a wrong data type
+#
+CREATE TABLE t1 (pk INT, a INT, b BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (1, 0, 1), (2, 0, 18446744073709551615);
+CREATE TABLE t2 AS
+SELECT pk, a, bit_or(b) AS bit_or FROM t1 GROUP BY pk;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `pk` int(11) DEFAULT NULL,
+ `a` int(11) DEFAULT NULL,
+ `bit_or` bigint(21) unsigned NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+pk a b
+1 0 1
+2 0 18446744073709551615
+DROP TABLE t2;
+CREATE OR REPLACE TABLE t2 AS
+SELECT pk, a, BIT_OR(b) OVER (PARTITION BY a ORDER BY pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS bit_or
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `pk` int(11) DEFAULT NULL,
+ `a` int(11) DEFAULT NULL,
+ `bit_or` bigint(21) unsigned NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2;
+pk a bit_or
+1 0 18446744073709551615
+2 0 18446744073709551615
+DROP TABLE t2;
+DROP TABLE t1;
+#
# End of 10.3 tests
#
diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test
index d49be4a0433..e71a4376392 100644
--- a/mysql-test/main/win.test
+++ b/mysql-test/main/win.test
@@ -2359,6 +2359,29 @@ INSERT INTO t1 VALUES ('00:00:01'),('00:00:02');
SELECT *, LEAD(d) OVER (ORDER BY d) AS x FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-20351 Window function BIT_OR() OVER (..) return a wrong data type
+--echo #
+CREATE TABLE t1 (pk INT, a INT, b BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (1, 0, 1), (2, 0, 18446744073709551615);
+
+CREATE TABLE t2 AS
+SELECT pk, a, bit_or(b) AS bit_or FROM t1 GROUP BY pk;
+SHOW CREATE TABLE t2;
+SELECT * FROM t1;
+DROP TABLE t2;
+
+CREATE OR REPLACE TABLE t2 AS
+SELECT pk, a, BIT_OR(b) OVER (PARTITION BY a ORDER BY pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS bit_or
+ FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+DROP TABLE t1;
+
+
--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index e6389c01832..cc67c02f1ee 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -1282,7 +1282,7 @@ public:
bool fix_length_and_dec()
{
- decimals = window_func()->decimals;
+ Type_std_attributes::set(window_func());
return FALSE;
}