[MDEV-30240] Wrong result upon aggregate function with SQL_BUFFER_RESULT Created: 2022-12-16  Updated: 2023-01-03  Resolved: 2023-01-03

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.11.2, 10.5.19, 10.6.12, 10.7.8, 10.8.7, 10.9.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: 11.0-sel


 Description   

CREATE TABLE t1 (pk INT PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (a INT);
INSERT INTO t2 VALUES (1),(2);
 
SELECT SQL_BUFFER_RESULT MIN(pk) FROM t1, t2;
SELECT MIN(pk) FROM t1, t2;
 
DROP TABLE t1, t2;

10.5 97c6cd97

SELECT SQL_BUFFER_RESULT MIN(pk) FROM t1, t2;
MIN(pk)
NULL
SELECT MIN(pk) FROM t1, t2;
MIN(pk)
1

The problem appeared in 10.5(.15) after this commit:

commit 38058c04a4fc021f381f8000e40ed23bd4fb8d75
Commit:     Monty
CommitDate: Tue Feb 8 14:32:29 2022 +0200
 
    MDEV-26585 Wrong query results when `using index for group-by`



 Comments   
Comment by Michael Widenius [ 2023-01-03 ]

The problem was that when storing rows into a temporary table, MIN/MAX items that where marked as constants (as their value had been computed at start of query) would be reset.

Generated at Thu Feb 08 10:14:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.