db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-4752) CheapDateFormatter returns incorrect and invalid date strings
Date Fri, 23 Jul 2010 08:15:51 GMT

     [ https://issues.apache.org/jira/browse/DERBY-4752?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Knut Anders Hatlen updated DERBY-4752:

       Fix Version/s:
    Issue & fix info:   (was: [Patch Available])

I committed the 1c patch to trunk with revision 967000.

Lily: This class is only used for formatting timestamps when writing messages to derby.log,
so it's not part of normal query processing unless statement logging is turned on. And even
in the cases where logging is turned on, the 32% slow-down is only for the generation of the
timestamp, which is just a small part of the total query cost, so the overall performance
impact will probably more like 1% than 30% (depending on the complexity of the query, of course).
I think that in environments where performance is critical, statement logging is almost certainly
turned off, and that's why I don't worry too much about it.

> CheapDateFormatter returns incorrect and invalid date strings
> -------------------------------------------------------------
>                 Key: DERBY-4752
>                 URL: https://issues.apache.org/jira/browse/DERBY-4752
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions:
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>             Fix For:
>         Attachments: CheapFormatterPerfTest.java, derby-4752-1a.diff, derby-4752-1b.diff,
> CheapDateFormatter has multiple problems. These are the ones I'm aware of:
> 1) On the boundary between non-leap years and leap years it will return first day of
thirteenth month in previous year (for instance, 2011-13-01 instead of 2012-01-01)
> 2) It treats all years divisible by four as leap years. Those divisible by 100 and not
by 400 are not leap years. It attempts to adjust for that (see the snippet below) but it always
ends up setting leapYear=true if (year%4)==0.
> 		// It's a leap year if divisible by 4, unless divisible by 100,
> 		// unless divisible by 400.
> 		if ((year % 4L) == 0) {
> 			if ((year % 100L) == 0) {
> 				if ((year % 400L) == 0) {
> 					leapYear = true;
> 				}
> 			}
> 			leapYear = true;
> 		}
> 3) More leap year trouble. To find out which year it is, it calculates the number of
four year periods that have elapsed since 1970-01-01. A four year period is considered 365*3+366
days. Although most four year periods are of that length, some are shorter, so we'll get one
day off starting from year 2100, two days off from year 2200, and so on.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message