Skip to content

Commit

Permalink
MDEV-20351 Window function BIT_OR() OVER (..) return a wrong data type
Browse files Browse the repository at this point in the history
  • Loading branch information
abarkov committed Aug 15, 2019
1 parent c23a5e0 commit 841294c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
35 changes: 35 additions & 0 deletions mysql-test/main/win.result
Expand Up @@ -3654,5 +3654,40 @@ d x
00:00:02 NULL 00:00:02 NULL
DROP TABLE t1; 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 # End of 10.3 tests
# #
23 changes: 23 additions & 0 deletions mysql-test/main/win.test
Expand Up @@ -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; SELECT *, LEAD(d) OVER (ORDER BY d) AS x FROM t1;
DROP TABLE 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 #
--echo # End of 10.3 tests --echo # End of 10.3 tests
--echo # --echo #
2 changes: 1 addition & 1 deletion sql/item_windowfunc.h
Expand Up @@ -1282,7 +1282,7 @@ class Item_window_func : public Item_func_or_sum


bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals = window_func()->decimals; Type_std_attributes::set(window_func());
return FALSE; return FALSE;
} }


Expand Down

0 comments on commit 841294c

Please sign in to comment.