[MDEV-16612] SP variables do not return expected NULL in summary rows in ROLLUP queries Created: 2018-06-28  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Stored routines
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This script:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2);
DROP PROCEDURE IF EXISTS p1;
DELIMITER $$
CREATE PROCEDURE p1()
BEGIN
  DECLARE v INT DEFAULT 10;
  SELECT id, 10 AS n, COUNT(*) FROM t1 GROUP BY id, n WITH ROLLUP;
  SELECT id, v, COUNT(*) FROM t1 GROUP BY id, v WITH ROLLUP;
END;
$$
DELIMITER ;
CALL p1;

produces the following output:

+------+------+----------+
| id   | n    | COUNT(*) |
+------+------+----------+
|    1 |   10 |        1 |
|    1 | NULL |        1 |
|    2 |   10 |        1 |
|    2 | NULL |        1 |
| NULL | NULL |        2 |
+------+------+----------+
 
+------+------+----------+
| id   | v    | COUNT(*) |
+------+------+----------+
|    1 |   10 |        1 |
|    1 |   10 |        1 |
|    2 |   10 |        1 |
|    2 |   10 |        1 |
| NULL |   10 |        2 |
+------+------+----------+

Notice:

  • The first query correctly returns NULL in the column n for summary rows 2,4,5
  • The second query erroneously returns 10 in the same rows

Generated at Thu Feb 08 08:30:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.