Description:
A prepared statement continues to use the value of div_precision_increment that was active when the statement was prepared, even after the SESSION variable is restored to its default value.
After restoration, @@SESSION.div_precision_increment is 4, but executing the prepared statement still produces a result whose scale corresponds to div_precision_increment=8.
How to repeat:
SET SESSION div_precision_increment = 8;
PREPARE s FROM
'SELECT CAST(1 AS DECIMAL(10,2)) / 3 AS result';
SET SESSION div_precision_increment = DEFAULT;
SELECT @@SESSION.div_precision_increment;
-- 4
EXECUTE s;
Actual Result: 0.3333333333
Expected Result: 0.333333
Description: A prepared statement continues to use the value of div_precision_increment that was active when the statement was prepared, even after the SESSION variable is restored to its default value. After restoration, @@SESSION.div_precision_increment is 4, but executing the prepared statement still produces a result whose scale corresponds to div_precision_increment=8. How to repeat: SET SESSION div_precision_increment = 8; PREPARE s FROM 'SELECT CAST(1 AS DECIMAL(10,2)) / 3 AS result'; SET SESSION div_precision_increment = DEFAULT; SELECT @@SESSION.div_precision_increment; -- 4 EXECUTE s; Actual Result: 0.3333333333 Expected Result: 0.333333