You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kathey Marsden (JIRA)" <ji...@apache.org> on 2007/10/12 00:49:50 UTC
[jira] Created: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
-------------------------------------------------------------------------------------------------------------
Key: DERBY-3126
URL: https://issues.apache.org/jira/browse/DERBY-3126
Project: Derby
Issue Type: Sub-task
Components: JDBC, Network Client
Reporter: Kathey Marsden
Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Daniel John Debrunner (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534867 ]
Daniel John Debrunner commented on DERBY-3126:
----------------------------------------------
I think that SQL does not have the concept of a negative scale, thus DRDA does not either. I think conversion to the same value with zero scale is the correct behaviour for SQL.
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Attachments: derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_stat.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kathey Marsden resolved DERBY-3126.
-----------------------------------
Resolution: Fixed
Fix Version/s: 10.4.0.0
10.3.1.5
Derby Info: (was: [Patch Available])
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Fix For: 10.3.1.5, 10.4.0.0
>
> Attachments: derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_stat.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kathey Marsden closed DERBY-3126.
---------------------------------
Assignee: Kathey Marsden
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Assignee: Kathey Marsden
> Fix For: 10.3.1.5, 10.4.0.0
>
> Attachments: derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_stat.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534637 ]
Knut Anders Hatlen commented on DERBY-3126:
-------------------------------------------
The patch looks correct to me. Two small comments:
1) There's some strange use of tabs in NetStatementRequest.
2) I think it would be good to add a test case which tested negative scale. To me it seems like this code assumes that the scale is not negative and not greater than 255:
+ lidAndLengths[i][1] = (precision << 8) + // use precision above
+ (scale << 0);
I know this code was not introduced by you, but I would feel more comfortable if there was a test to verify that it works.
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Attachments: derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_stat.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kathey Marsden updated DERBY-3126:
----------------------------------
Attachment: derby-2073_stat.txt
derby-2073_diff.txt
Updating patch with more tests and fixed some code formatting.
I'll commit this patch Monday, October 15, if I don't hear comments. Please let me know if you need more time to review.
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Attachments: derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_stat.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (DERBY-3126) Inserting BigDecimal
value in PreparedStatement with setBigDecimal into double column loses
fractional digits
Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534182 ]
kmarsden edited comment on DERBY-3126 at 10/11/07 5:53 PM:
-----------------------------------------------------------------
Attached is a patch for DERBY-3126. The patch is called derby-2073_diff.txt
The change changes NetStatementRequest.computeProtocolTypesAndLengths to always look at the data scale and precision when sending decimal values to the server rather than using the parameterMetaData values which are never set. For null values it just uses scale 0 and precision 1. For non-null values I used the pre-existing Utils.computeBigDecimalPrecision method to compute precision.
Getting the scale and precision from the data is the only way to make sure the server gets the actual data value set by the user. There was some talk in the old comments about scale and precision for output and inout parameters but as far as I can tell the scale set with registerOutputParameter is not saved anywhere, so cannot be used here. I don't think it makes sense use the output scale for the input parameter as it might affect the value sent to the server. There may be additional issues with output parameter and registerOutputParameter, specifying a scale, since we don't seem to use the scale anywhere. I filed DERBY-3125 for the lack of use of the scale parameter in registerOutputParameter for both embedded and client.
I added a test to ParameterMappingTest which was only testing whole numbers for decimal values.
I also noticed that setObject with big decimal and specified scale has a similar issue, but it is not fixed by this patch. I filed DERBY-3127 for that.
tests passed
Kathey
was (Author: kmarsden):
Attached is a patch for DERBY-2073. The change changes NetStatementRequest.computeProtocolTypesAndLengths to always look at the data scale and precision when sending decimal values to the server rather than using the parameterMetaData values which are never set. For null values it just uses scale 0 and precision 1. For non-null values I used the pre-existing Utils.computeBigDecimalPrecision method to compute precision.
Getting the scale and precision from the data is the only way to make sure the server gets the actual data value set by the user. There was some talk in the old comments about scale and precision for output and inout parameters but as far as I can tell the scale set with registerOutputParameter is not saved anywhere, so cannot be used here. I don't think it makes sense use the output scale for the input parameter as it might affect the value sent to the server. There may be additional issues with output parameter and registerOutputParameter, specifying a scale, since we don't seem to use the scale anywhere. I filed DERBY-3125 for the lack of use of the scale parameter in registerOutputParameter for both embedded and client.
I added a test to ParameterMappingTest which was only testing whole numbers for decimal values.
I also noticed that setObject with big decimal and specified scale has a similar issue, but it is not fixed by this patch. I filed DERBY-3127 for that.
tests are running ...
Kathey
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Attachments: derby-2073_diff.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534855 ]
Knut Anders Hatlen commented on DERBY-3126:
-------------------------------------------
Thanks Kathey. I think the patch looks good. Do you know whether the problem with encoding BigDecimals with negative scale is a limitation in the DRDA protocol or a problem with our implementation?
One last nit... There's still a tab in NetStatementRequest:
public class NetStatementRequest extends NetPackageRequest implements StatementRequestInterface {
- java.util.ArrayList extdtaPositions_ = null; // Integers: build EXTDTA for column i
+
+ java.util.ArrayList extdtaPositions_ = null; // Integers: build EXTDTA for column i
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Attachments: derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_stat.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kathey Marsden updated DERBY-3126:
----------------------------------
Attachment: derby-2073_stat.txt
derby-2073_diff.txt
Attached is a patch for DERBY-2073. The change changes NetStatementRequest.computeProtocolTypesAndLengths to always look at the data scale and precision when sending decimal values to the server rather than using the parameterMetaData values which are never set. For null values it just uses scale 0 and precision 1. For non-null values I used the pre-existing Utils.computeBigDecimalPrecision method to compute precision.
Getting the scale and precision from the data is the only way to make sure the server gets the actual data value set by the user. There was some talk in the old comments about scale and precision for output and inout parameters but as far as I can tell the scale set with registerOutputParameter is not saved anywhere, so cannot be used here. I don't think it makes sense use the output scale for the input parameter as it might affect the value sent to the server. There may be additional issues with output parameter and registerOutputParameter, specifying a scale, since we don't seem to use the scale anywhere. I filed DERBY-3125 for the lack of use of the scale parameter in registerOutputParameter for both embedded and client.
I added a test to ParameterMappingTest which was only testing whole numbers for decimal values.
I also noticed that setObject with big decimal and specified scale has a similar issue, but it is not fixed by this patch. I filed DERBY-3127 for that.
tests are running ...
Kathey
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Attachments: derby-2073_diff.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kathey Marsden updated DERBY-3126:
----------------------------------
Derby Info: [Patch Available]
Marking patch available. Patch is ready for review
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Attachments: derby-2073_diff.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-3126) Inserting BigDecimal value in
PreparedStatement with setBigDecimal into double column loses fractional
digits
Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kathey Marsden updated DERBY-3126:
----------------------------------
Attachment: derby-2073_diff.txt
Here is an updated patch that handles negative scale with setBigDecimal. It does not take care of the exception Knut pointed out with setObject.
In order to send a packed decimal over DRDA, I had to convert the BigDecimal to an equivalent BigDecimal with zero scale. I put the conversion in the same place as the other scale and precision handling. I hope this is the right place in the code to do this.
suiltes.All passed. derbyall running.
Please review.
Kathey
> Inserting BigDecimal value in PreparedStatement with setBigDecimal into double column loses fractional digits
> -------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3126
> URL: https://issues.apache.org/jira/browse/DERBY-3126
> Project: Derby
> Issue Type: Sub-task
> Components: JDBC, Network Client
> Reporter: Kathey Marsden
> Attachments: derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_diff.txt, derby-2073_stat.txt, derby-2073_stat.txt
>
>
> Splitting this issue into two subtasks one for setBigDecimal and one for setObject as they take a different code path and I plan to submit separate patches. Reproduces with BigDecimalProblemTester attached to DERBY-2073
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.