Bug #110983 | issue with window functions in stored procedures | ||
---|---|---|---|
Submitted: | 10 May 2023 23:10 | Modified: | 1 Jun 2023 8:50 |
Reporter: | Debra Cox | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S2 (Serious) |
Version: | 8.0.33 | OS: | Ubuntu (20.04) |
Assigned to: | CPU Architecture: | x86 | |
Tags: | regression |
[10 May 2023 23:10]
Debra Cox
[11 May 2023 7:18]
MySQL Verification Team
Hello Debra Cox, Thank you for the report and test case. Verified as described. regards, Umesh
[11 May 2023 7:20]
MySQL Verification Team
- 8.0.32 - Not affected ./mtr bug110983 --nocheck-testcases Logging: ./mtr bug110983 --nocheck-testcases MySQL Version 8.0.32 Checking supported features Using 'all' suites Collecting tests Checking leftover processes Removing old var directory - WARNING: Using the 'mysql-test/var' symlink Creating var directory '/export/home/tmp/ushastry/mysql-8.0.32/mysql-test/var' Installing system database Using parallel: 1 ============================================================================== TEST NAME RESULT TIME (ms) COMMENT ------------------------------------------------------------------------------ create table table1(id int); insert into table1 values(1),(2),(3),(4),(5),(6); CREATE PROCEDURE test2() BEGIN select count(*) over (rows between 5 preceding and 5 following) as A, count(*) over (rows between 5 preceding and 5 following) + 1 as "A+1", count(*) over (rows between 5 preceding and 5 following) - 1 as "A-1", count(*) over () as B, count(*) over () + 1 as "B+1", count(*) over () - 1 as "B-1" from table1 ; END $$ call test2()$$ A A+1 A-1 B B+1 B-1 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 call test2()$$ A A+1 A-1 B B+1 B-1 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 [ 50%] main.bug110983 [ pass ] 11 [100%] shutdown_report [ pass ] ------------------------------------------------------------------------------ - 8.0.33 - affected, looks like regression ./mtr bug110983 --nocheck-testcases Logging: ./mtr bug110983 --nocheck-testcases MySQL Version 8.0.33 Checking supported features Using 'all' suites Collecting tests Checking leftover processes Removing old var directory - WARNING: Using the 'mysql-test/var' symlink Creating var directory '/export/home/tmp/ushastry/mysql-8.0.33/mysql-test/var' Installing system database Using parallel: 1 ============================================================================== TEST NAME RESULT TIME (ms) COMMENT ------------------------------------------------------------------------------ create table table1(id int); insert into table1 values(1),(2),(3),(4),(5),(6); CREATE PROCEDURE test2() BEGIN select count(*) over (rows between 5 preceding and 5 following) as A, count(*) over (rows between 5 preceding and 5 following) + 1 as "A+1", count(*) over (rows between 5 preceding and 5 following) - 1 as "A-1", count(*) over () as B, count(*) over () + 1 as "B+1", count(*) over () - 1 as "B-1" from table1 ; END $$ call test2()$$ A A+1 A-1 B B+1 B-1 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 6 7 5 call test2()$$ A A+1 A-1 B B+1 B-1 6 2 0 6 2 0 6 3 1 6 3 1 6 4 2 6 4 2 6 5 3 6 5 3 6 6 4 6 6 4 6 7 5 6 7 5 [ 50%] main.bug110983 [ pass ] 10 [100%] shutdown_report [ pass ]
[12 May 2023 9:59]
Dag Wanvik
Posted by developer: Likely same root cause as Bug#35340987 (external bug Bug #110847)
[1 Jun 2023 8:50]
Dag Wanvik
Posted by developer: Fixed by the patch for Bug#35340987.
[17 Oct 2023 15:18]
Dag Wanvik
Posted by developer: Bug#35340987 has been backported to 8.0 branch, so this bug is now also fixed on said branch.
[21 Dec 2023 16:08]
Jon Stephens
Documented fix as follows in the MySQL 8.0.36 changelog: Performing an arithmetic operation on the result over a window function in a stored procedure gave the correct result the first time the procedure was executed, but returned an incorrect result on all subsequent invocations. Closed.