Skip to content
Permalink
Browse files

MDEV-20351 Window function BIT_OR() OVER (..) return a wrong data type

  • Loading branch information...
abarkov committed Aug 15, 2019
1 parent c23a5e0 commit 841294cfaa0e9591de446a4f083477b61e05e3cc
Showing with 59 additions and 1 deletion.
  1. +35 −0 mysql-test/main/win.result
  2. +23 −0 mysql-test/main/win.test
  3. +1 −1 sql/item_windowfunc.h
@@ -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
#
@@ -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 #
@@ -1282,7 +1282,7 @@ class Item_window_func : public Item_func_or_sum

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

0 comments on commit 841294c

Please sign in to comment.
You can’t perform that action at this time.