| Bug #121231 | Prepared statement uses stale div_precision_increment value after SESSION variable change | ||
|---|---|---|---|
| Submitted: | 4 Sep 14:57 | Modified: | 23 Sep 7:16 |
| Reporter: | Xiaoyuan Xie | Email Updates: | |
| Status: | Open | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | 9.7.2 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[10 Sep 7:51]
Xiaoyuan Xie
New version: 9.7.2
[23 Sep 7:16]
Xiaoyuan Xie
This bug appears to be related to session configuration handling rather than specifically to prepared statements.

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