Description:
When using the format function with a large value in conjunction with a cursor, the output string is truncated.
How to repeat:
CREATE PROCEDURE demo(out a varchar(1024))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE cur1 CURSOR FOR SELECT format(-1.7976931348623157E+307,256);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO a;
IF done THEN
LEAVE read_loop;
END IF;
END LOOP;
CLOSE cur1;
END;
mysql> call demo(@hello);
Query OK, 0 rows affected (0.02 sec)
mysql> select @hello;
+---------------------------------------------------------------+
| @hello |
+---------------------------------------------------------------+
| -17,976,931,348,623,158,000,000,000,000,000,000,000,000,000,0 |
+---------------------------------------------------------------+
1 row in set (0.01 sec)
mysql> SELECT format(-1.7976931348623157E+307,256);
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| format(-1.7976931348623157E+307,256) |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -17,976,931,348,623,158,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.000000000000000000000000000000 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)