Bug #118329 Contribution: Optimize BigDecimal zero value handling to reduce memory foot ...
Submitted: 2 Jun 12:32 Modified: 25 Jul 18:08
Reporter: OCA Admin (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:9.x OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[2 Jun 12:32] OCA Admin
Description:
This bug tracks a contribution by chengjun huang (Github user: SubtleSpark), as described in http://github.com/mysql/mysql-connector-j/pull/117

How to repeat:
See description

Suggested fix:
See contribution code attached
[2 Jun 12:32] OCA Admin
Contribution submitted via Github - Optimize BigDecimal zero value handling to reduce memory footprint 
(*) Contribution by chengjun huang (Github SubtleSpark, mysql-connector-j/pull/117#issuecomment-2925303388): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_2556548079.txt (text/plain), 2.26 KiB.

[2 Jun 12:47] MySQL Verification Team
Hello chengjun huang,

Thank you for the report and contribution.

regards,
Umesh
[3 Jul 15:49] Filipe Silva
Hi Chengjun Huang,

Can you please elaborate on this patch? Your assumption that Connector/J creates a new BigDecimal instance for each zero value seems to be wrong.

Actually, the test code you added into BigDecimalValueFactoryTest#testCreateFromBigDecimal doesn't fail without the remaining of your patch.

Please clarify.
[25 Jul 13:36] chengjun huang
I'm sorry for submitting the wrong test case.
Below is the correct test case. Please use it to replace the one I submitted in com.mysql.cj.result.BigDecimalValueFactoryTest.testCreateFromBigDecimal()

```code
assertSame(this.vf.createFromBigDecimal(new BigDecimal("0.0")), this.vf.createFromBigDecimal(new BigDecimal("0.0")));
assertNotSame(this.vf.createFromBigDecimal(new BigDecimal("0.0")), this.vf.createFromBigDecimal(new BigDecimal("0")));
```
[25 Jul 18:08] Filipe Silva
Thank you. It makes sense now.