Bug #118391 Inconsistent BIGINT overflow behavior with unary minus operator in multiplication
Submitted: 8 Jun 16:43 Modified: 9 Jun 5:25
Reporter: Long Gu Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.4.2, 8.0 OS:Any
Assigned to: CPU Architecture:Any

[8 Jun 16:43] Long Gu
Description:
MySQL shows inconsistent behavior when handling mathematically equivalent expressions involving unary minus operators and large number multiplication.

How to repeat:
1. Execute: SELECT -(-(100)) * 100000000000000000;
   Result: 10000000000000000000 (succeeds)

2. Execute: SELECT 100 * 100000000000000000;
   Result: ERROR 1690 (22003) at line 1: BIGINT value is out of range in '(100 * 100000000000000000)'
[9 Jun 5:25] MySQL Verification Team
Hello Long Gu,

Thank you for the report and feedback.
Verified as described. 

regards,
Umesh
[10 Jun 12:23] Tor Didriksen
Posted by developer:
 
SELECT -(-(100)) * 100000000000000000;
is computed as DECIMAL, hence no overflow