db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mayuresh Nirhali <Mayuresh.Nirh...@Sun.COM>
Subject Re: [jira] Commented: (DERBY-2386) timestampdiff function fails when using SQL_TSI_FRAC_SECOND for datepart parameter, except for very small intervals
Date Mon, 12 Mar 2007 18:02:19 GMT
Hello,

Daniel John Debrunner (JIRA) wrote:
>     [ https://issues.apache.org/jira/browse/DERBY-2386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12479347
] 
>
> Daniel John Debrunner commented on DERBY-2386:
> ----------------------------------------------
>
> I think the change to BIGINT is more involved than the patch. Doesn't some compile time
code have to change to indicate at bind time that this is returning a BIGINT?
>
>   
I did not quite follow this comment. I looked at the code around this 
issue and tried a lot of different combinations but did not see any 
failures, I guess, I am still missing the point here.
Dan, I would really appreciate if you could elaborate a little more on 
the comment  ??

Thanks
Mayuresh
> This test can never be true:
>
> if (ldiff > Long.MAX_VALUE || ldiff < Long.MIN_VALUE)
>
> since ldiff was already a long it cannot be outside its own range.
>
> FYI - the old check & code that was there:
>
> 		if (ldiff > Integer.MAX_VALUE || ldiff < Integer.MIN_VALUE)
> 			throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "INTEGER");
>         resultHolder.setValue( (int) ldiff);
>
> is not required, it could be simply
>
>           resultHolder.setValue(ldiff);
>
>
>   
>> timestampdiff function fails when using SQL_TSI_FRAC_SECOND for datepart parameter,
except for very small intervals
>> -------------------------------------------------------------------------------------------------------------------
>>
>>                 Key: DERBY-2386
>>                 URL: https://issues.apache.org/jira/browse/DERBY-2386
>>             Project: Derby
>>          Issue Type: Bug
>>          Components: SQL
>>    Affects Versions: 10.2.2.0
>>         Environment: SUSE Linux Enterprise Desktop 10
>>            Reporter: Don Smith
>>         Assigned To: Mayuresh Nirhali
>>             Fix For: 10.2.2.1, 10.2.3.0, 10.3.0.0
>>
>>         Attachments: derby2386.diff
>>
>>
>> Using the timestampdiff function produces and integer overflow except for very small
intervals. Error message is:
>> [Error Code: -1, SQL State: 22003]  The resulting value is outside the range for
the data type INTEGER.
>> I inserted the following row into my test table:
>> insert into datetest (ID, 
>> startdate, 
>> enddate) values (
>> 5, 
>> '2006-11-20 04:20:00.0', 
>> '2006-11-20 04:20:00.2');
>> This test row works:
>> select {fn timestampdiff(SQL_TSI_FRAC_SECOND, startdate, enddate)} as diff from datetest
where id = 5
>> DIFF
>> 200000000
>> The value also looks too large, which could be exacerbating the problem.
>>     
>
>   


Mime
View raw message