Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
11.7.2, 12.0
-
None
Description
I run this script:
DELIMITER /
|
CREATE OR REPLACE FUNCTION f1() RETURNS INT |
BEGIN
|
SET @counter= COALESCE(@counter, 0) + 1; |
RETURN @counter; |
END; |
/
|
DELIMITER ;
|
SET @counter=0; |
SELECT f1()=1, @counter FROM seq_1_to_5; |
+--------+----------+
|
| f1()=1 | @counter |
|
+--------+----------+
|
| 1 | 1 |
|
| 0 | 2 |
|
| 0 | 3 |
|
| 0 | 4 |
|
| 0 | 5 |
|
+--------+----------+
|
So far so good: the counter increments by one every row.
Now I change the query to use ROWs:
SELECT ROW(f1(),1) = ROW(1,1), @counter FROM seq_1_to_5; |
+------------------+----------+
|
| (f1(),1) = (1,1) | @counter |
|
+------------------+----------+
|
| 0 | 7 |
|
| 0 | 9 |
|
| 0 | 11 |
|
| 0 | 13 |
|
| 0 | 15 |
|
+------------------+----------+
|
Now the counter increments twice per row. Looks wrong.
Tracing in gdb reveals that Item_func_sp::execute() is indeed called twice per row:
- From Item_func_sp::bring_value()
- From Arg_comparator::compare_int_signed() when Arg_comparator::compare_row() evaluates equality of its members.
Attachments
Issue Links
- is caused by
-
MDEV-12252 ROW data type for stored function return values
-
- Closed
-
Hello sanja_byelkin,
Please review a patch for this issue for 11.8:
https://github.com/MariaDB/server/commit/d9fbadaf2a13edd97fd9eca0f86cbaa6165da47d
Thanks.