Home > Archive > PostgreSQL JDBC > April 2005 > Re: Interval support for Postgres









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Interval support for Postgres
Oliver Siegmar

2005-04-29, 7:25 am

On Friday 29 April 2005 10:01, Kris Jurka wrote:
> On Sat, 23 Apr 2005, Oliver Siegmar wrote:
>
> Here's my version of it. Changes:
> - Always use noniso format for sending intervals to the backend.
> This makes it possible to support a seconds field of 90. Also
> don't need to worry about signs of fields.


Sounds reasonable. But I'm not sure if we should support "oversized" values -
I see no requirement for it, and it adds a lot of possible trouble.

Anyway...I have used the + concatination (in getValue()) knowingly, because
JDK < 5.0 compiles that to StringBuffer and JDK 5.0 to StringBuilder
automatically. The usage of StringBuffer and StringBuilder makes only sense
if the string isn't built as a one-liner.

> My one remaining question is about the roll function. What is the purpose
> of roll, don't we want add?


a) because the database doesn't return "oversized" values - so it doesn't
matter using add() or roll()

b) because add() is a beast. Consider the following simple example:

---------------------------------------------------------------------------
01: Calendar cal1 = Calendar.getInstance();
02: Calendar cal2 = (Calendar)cal1.clone();
03:
04: System.out.println(cal1.equals(cal2)); // returns true, of course
05:
06: cal1.add(Calendar.MONTH, -4);
07: cal1.add(Calendar. DAY_OF_WEEK_IN_MONTH
, 20);
08:
09: cal1.add(Calendar.MONTH, 4);
10: cal1.add(Calendar. DAY_OF_WEEK_IN_MONTH
, -20);
11:
12: System.out.println(cal1.equals(cal2)); // returns false
---------------------------------------------------------------------------

But if you twist line 9 and 10 - everything is ok. If you use add() you have
to use the inverse order if you want to "roll" backwards, again. I see no way
to get a PGInterval.add() method acting symmetric.

> Ignoring carryover seems like a mistake.


Not if all values are "in range". The method name roll() won't be
misunderstood, I think.

> Also in the roll method the milliseconds calculation should round the
> value so 0.6006 seconds becomes 601 milliseconds.


Why? When is the current implementation doing wrong?


Oliver

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Kris Jurka

2005-04-29, 8:26 pm



On Fri, 29 Apr 2005, Oliver Siegmar wrote:

> Give pgjdbc_interval5.diff a new try ;-)
>


Applied. Thanks.

Kris Jurka


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Oliver Siegmar

2005-04-30, 3:25 am

On Friday 29 April 2005 22:42, Kris Jurka wrote:
> On Fri, 29 Apr 2005, Oliver Siegmar wrote:
>
> Applied. Thanks.


Thanks. Could you also add it to the 8.0 branch? That'd be great!


Oliver

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere
" to majordomo@postgresql
.org)

Oliver Siegmar

2005-04-30, 3:25 am

On Saturday 30 April 2005 10:25, Kris Jurka wrote:
> On Sat, 30 Apr 2005, Oliver Siegmar wrote:
>
> That's not really our policy, new features go into head, bug fixes only in
> released branches. This isn't a terribly invasive patch, but it does make
> some behavioral differences (notably an existing parser of getValue()
> would only expect ISO format, not pg format). I don't think a convincing
> case can be made for needing this in 8.0, but you are free to try and
> convince other users and developers.


I understand. Well, it depends a lot on when 8.1 driver will be released as a
stable version (or how stable prereleases are for productional use). If a 8.1
JDBC-Driver release is planned for mid-2005, I'm okay. Otherwise it would be
imho a too long time to work with prereleases to get interval support.

....just my two cents...


Oliver



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere
" to majordomo@postgresql
.org)

Kris Jurka

2005-04-30, 7:25 am



On Sat, 30 Apr 2005, Oliver Siegmar wrote:

> I understand. Well, it depends a lot on when 8.1 driver will be released as a
> stable version (or how stable prereleases are for productional use). If a 8.1
> JDBC-Driver release is planned for mid-2005, I'm okay. Otherwise it would be
> imho a too long time to work with prereleases to get interval support.


The JDBC driver follows the server release schedule, which is roughly
yearly. 8.0 was released 1/2005 so a good guess at 8.1 is 1/2006. As you
well know it is an open source project, so people who need just interval
support in 8.0 can backpatch just that code. I think I can recall only
one other person in the past two years or so asking about extracting
interval fields in java, so I don't see this as a must have feature.

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql
.org

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com