Re: [BUG?] Extreme dates

From: Markus Schaber <schabios(at)logi-track(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [BUG?] Extreme dates
Date: 2004-05-19 13:50:02
Message-ID: 20040519155002.67a46729@kingfisher.intern.logi-track.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi, Kris,

On Mon, 17 May 2004 15:45:12 -0500 (EST)
Kris Jurka <books(at)ejurka(dot)com> wrote:

> > [timestamps like 0002-10-30 are incorrectly seen as 2030-02-10].
>
> Yes, that's a bug alright. I've fixed this in both the stable and
> development cvs trees. While looking at this I noticed that the
> timestamp code has no provisions for BC dates, so if you're working
> with years in that area, that's something to be aware of. Fixing that
> has gone on the todo list, but I wanted to get this fix out to you
> now.

I just notified the change in the JDBC CVS, and have a (very small)
remark:

sbuf.append("0") is less efficient than sbuf.append('0').

The first reason is that for storing "0", there is a String object
created by the jvm, with an associated internal char[] array, which is
bound to the Class instance, while '0' as a constant scalar character is
no extra object.

And the second reason is that, as the StringBuffer source shows, adding
a String to a StringBuffer is much more work including a call to
System.ArrayCopy, while adding a simple character is just ensuring the
capacity and putting it in.

Interestingly, the lines below your insertion, already use chars, while
a little bit above, there's another example adding a single-byte String
(maybe because of lazyness to quote a ' inside of '').

So if you feel like peephole-optimizing, you can apply the attached
patch, if not, don't mind.

Thanks for your patience,
Markus Schaber
--
markus schaber | dipl. informatiker
logi-track ag | rennweg 14-16 | ch 8001 zürich
phone +41-43-888 62 52 | fax +41-43-888 62 53
mailto:schabios(at)logi-track(dot)com | www.logi-track.com

Attachment Content-Type Size
jdbccharpatch.diff text/plain 913 bytes

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message ow 2004-05-19 20:20:42 Re: [BUG?] Extreme dates
Previous Message Alban Mathieu 2004-05-19 13:23:58 Driver JDBC3 build 213 for postgreSQL 7.4