[
https://issues.apache.org/jira/browse/DERBY-853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15406955#comment-15406955
]
ASF subversion and git services commented on DERBY-853:
-------------------------------------------------------
Commit 1755133 from [~bryanpendleton] in branch 'code/trunk'
[ https://svn.apache.org/r1755133 ]
DERBY-853: ResultSetMetaData.getScale returns inconsistent values
This patch was contributed by Danoja Dias (danojadias at gmail dot com)
When a SQL statement contains arithmetic expressions, the result of the
expression may be of a different type than the operands to the expression,
due to type precedence rules which may require promoting the operand
values during evaluation of the expression.
For example, subtracting a DOUBLE from a DECIMAL results in a DOUBLE.
In some of these cases, Derby was reporting that the result column
had a non-zero scale, although the result column was not of DECIMAL type.
This change modifies the NumericTypeCompiler so that it only computes
a non-zero scale for the result column when it is of DECIMAL type.
> ResultSetMetaData.getScale returns inconsistent values for DOUBLE type.
> -----------------------------------------------------------------------
>
> Key: DERBY-853
> URL: https://issues.apache.org/jira/browse/DERBY-853
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 10.2.1.6
> Reporter: Daniel John Debrunner
> Assignee: Danoja Dias
> Priority: Trivial
> Labels: derby_triage10_5_2
> Attachments: BryanPossibleIdea.diff, Derby-853.diff,
> Derby-853_2.diff, Derby-853_3.diff, Derby853.java
>
>
> If a DOUBLE column is returned in the result set then getScale() returns 0.
> If a DOUBLE expression is returned and the expression is the result of a
> DOUBLE combined with a DECIMAL then it seems the scale from the decimal
> sometimes affects the result set metadata.
> E.g. DECIMAL(10,2) - DOUBLE returns a DOUBLE with getScale() returning 2.
> See the test output for jdbcapi/metadata.java
> double -- precision: 15 scale: 0 display size: 22 type name: DOUBLE
> double precision - dec(10,2) -- precision: 15 scale: 0 display size: 22 type
> name: DOUBLE
> dec(10,2) - double precision -- precision: 15 scale: 2 display size: 22 type
> name: DOUBLE
> First line is a DOUBLE column, second is DOUBLE - DECIMAL, third is DECIMAL -
> DOUBLE
> I assume the scale should always be zero for a DOUBLE, as it holds no
> meaning, but I can't see any proof of that in JDBC spec, javadoc or tutorial
> book.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)