pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Interval support for Postgres
18+ messages / 3 participants
[nested] [flat]

* Interval support for Postgres
@ 2005-04-21 09:07 Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-21 09:07 UTC (permalink / raw)
  To: pgsql-jdbc

Hi folks,

here's a patch that adds functionality to the PGInterval class. I'd be happy 
to see this in upstream.

I'll enhance the unit tests if you want to apply this to upstream.



Best,
Oliver

Attachments:

  pgjdbc_interval.diff.gz (application/x-gzip, 3.6K) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
@ 2005-04-21 18:32 ` Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  0 siblings, 1 reply; 18+ messages in thread

From: Kris Jurka @ 2005-04-21 18:32 UTC (permalink / raw)
  To: Oliver Siegmar <o.siegmar@vitrado.de>; +Cc: pgsql-jdbc



On Thu, 21 Apr 2005, Oliver Siegmar wrote:

> here's a patch that adds functionality to the PGInterval class. I'd be happy 
> to see this in upstream.

You cannot use regex code in this class because it must compile with 1.2 
and 1.3 JDKs.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-21 19:37   ` Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-21 19:37 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

On Thursday 21 April 2005 20:32, Kris Jurka wrote:
> On Thu, 21 Apr 2005, Oliver Siegmar wrote:
> > here's a patch that adds functionality to the PGInterval class. I'd be
> > happy to see this in upstream.
>
> You cannot use regex code in this class because it must compile with 1.2
> and 1.3 JDKs.

Can it be placed in the JDBC3 package, then? This requires JDK 1.4 anyway, 
right?


Oliver



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
@ 2005-04-21 19:43     ` Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  0 siblings, 1 reply; 18+ messages in thread

From: Kris Jurka @ 2005-04-21 19:43 UTC (permalink / raw)
  To: Oliver Siegmar <o.siegmar@vitrado.de>; +Cc: pgsql-jdbc



On Thu, 21 Apr 2005, Oliver Siegmar wrote:

> On Thursday 21 April 2005 20:32, Kris Jurka wrote:
> > On Thu, 21 Apr 2005, Oliver Siegmar wrote:
> > > here's a patch that adds functionality to the PGInterval class. I'd be
> > > happy to see this in upstream.
> >
> > You cannot use regex code in this class because it must compile with 1.2
> > and 1.3 JDKs.
> 
> Can it be placed in the JDBC3 package, then? This requires JDK 1.4 anyway, 
> right?
> 

It could, but I'd be against it.  Having a different PGInterval behavior 
for JDBC2 and JDBC3 builds would be rather odd.  While regex may be 
convenient here it certainly isn't essential.  If you want to get this in 
I'd recommend rewriting to do the parsing manually.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-21 20:02       ` Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-21 20:02 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

On Thursday 21 April 2005 21:43, Kris Jurka wrote:
> On Thu, 21 Apr 2005, Oliver Siegmar wrote:
> > On Thursday 21 April 2005 20:32, Kris Jurka wrote:
> > > On Thu, 21 Apr 2005, Oliver Siegmar wrote:
> > > > here's a patch that adds functionality to the PGInterval class. I'd
> > > > be happy to see this in upstream.
> > >
> > > You cannot use regex code in this class because it must compile with
> > > 1.2 and 1.3 JDKs.
> >
> > Can it be placed in the JDBC3 package, then? This requires JDK 1.4
> > anyway, right?
>
> It could, but I'd be against it.  Having a different PGInterval behavior
> for JDBC2 and JDBC3 builds would be rather odd.  While regex may be
> convenient here it certainly isn't essential.  If you want to get this in
> I'd recommend rewriting to do the parsing manually.

Well, actually there is almost no implementation at all. Parsing strings in 
Java in 2005 is a royal pain in the ass - doing that for 0.x% users suck even 
more.

Let's assume I'd write a JDBC2 version with old-school string parsing - would 
you apply it to upstream, or are there any other show stoppers?


Oliver



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
@ 2005-04-21 21:00         ` Kris Jurka <books@ejurka.com>
  2005-04-21 21:47           ` Re: Interval support for Postgres Oliver Jowett <oliver@opencloud.com>
  2005-04-22 11:01           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  0 siblings, 3 replies; 18+ messages in thread

From: Kris Jurka @ 2005-04-21 21:00 UTC (permalink / raw)
  To: Oliver Siegmar <o.siegmar@vitrado.de>; +Cc: pgsql-jdbc



On Thu, 21 Apr 2005, Oliver Siegmar wrote:

> Well, actually there is almost no implementation at all. Parsing strings in 
> Java in 2005 is a royal pain in the ass - doing that for 0.x% users suck even 
> more.

Well, just be thankful the 8.0 release finally dropped JDK 1.1 support.

> Let's assume I'd write a JDBC2 version with old-school string parsing - would 
> you apply it to upstream, or are there any other show stoppers?
> 

We definitely want something better for PGInterval.  I do have some 
questions about the implementation you've got.

1) You have an "int milliseconds" field.  PG supports microsecond 
precision in intervals.  Is there any reason not to go with a plain "float 
seconds" field instead of splitting these up?

2) getValue() calls nf.format(Math.abs(milliseconds)), if milliseconds is 
2 won't the NumberFormat(ter) turn that into .02 ?

3) In general the whole "before" API is confusing.  Do you have any better 
ideas on how to handle this?
  a) Note getValue() returns the wrong value if hours == 0 and minutes < 0.
  b) Doesn't clone() need to copy the before setting?
  c) After a setValue() if someone does setYear() don't they need to
     know the before setting (which is protected).


Kris Jurka




^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-21 21:47           ` Oliver Jowett <oliver@opencloud.com>
  2 siblings, 0 replies; 18+ messages in thread

From: Oliver Jowett @ 2005-04-21 21:47 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: Oliver Siegmar <o.siegmar@vitrado.de>; pgsql-jdbc

Kris Jurka wrote:

> 1) You have an "int milliseconds" field.  PG supports microsecond 
> precision in intervals.  Is there any reason not to go with a plain "float 
> seconds" field instead of splitting these up?

Can you represent all of 0.000000 .. 59.999999 exactly as floats?

-O



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-22 11:01           ` Oliver Siegmar <o.siegmar@vitrado.de>
  2 siblings, 0 replies; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-22 11:01 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

Hi Kris,

On Thursday 21 April 2005 23:00, Kris Jurka wrote:
> 1) You have an "int milliseconds" field.  PG supports microsecond
> precision in intervals.  Is there any reason not to go with a plain "float
> seconds" field instead of splitting these up?

Working with floating points is more difficult because of the requirements of 
Calendar's roll() - but see the new patch, it uses double for seconds (and 
microseconds).

> 2) getValue() calls nf.format(Math.abs(milliseconds)), if milliseconds is
> 2 won't the NumberFormat(ter) turn that into .02 ?

Right, fixed.

> 3) In general the whole "before" API is confusing.  Do you have any better
> ideas on how to handle this?

Yes, done.

>   a) Note getValue() returns the wrong value if hours == 0 and minutes < 0.

Right, fixed.

>   b) Doesn't clone() need to copy the before setting?

No, because it was only used to initialize the values - "before" is dropped 
anyway.

>   c) After a setValue() if someone does setYear() don't they need to
>      know the before setting (which is protected).

I thought these setters only for internal use (they all were protected). Now 
they're public and "before" has gone.



Take a look at the new patch, I'm sure you'll find tons of things you don't 
like... ;-)



Oliver

Attachments:

  pgjdbc_interval2.diff.gz (application/x-gzip, 3.7K) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-23 06:38           ` Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2 siblings, 1 reply; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-23 06:38 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

On Thursday 21 April 2005 23:00, Kris Jurka wrote:
> On Thu, 21 Apr 2005, Oliver Siegmar wrote:
> > Well, actually there is almost no implementation at all. Parsing strings
> > in Java in 2005 is a royal pain in the ass - doing that for 0.x% users
> > suck even more.
>
> Well, just be thankful the 8.0 release finally dropped JDK 1.1 support.

The applied patch contains all modifications from the last one 
(pgjdbc_interval2.diff) as well as a replacement for the regular expression 
code.

The patch should be JDK 1.2 compatible, now.



Oliver

Attachments:

  pgjdbc_interval3.diff.gz (application/x-gzip, 3.6K) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
@ 2005-04-29 08:01             ` Kris Jurka <books@ejurka.com>
  2005-04-29 10:25               ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  0 siblings, 1 reply; 18+ messages in thread

From: Kris Jurka @ 2005-04-29 08:01 UTC (permalink / raw)
  To: Oliver Siegmar <o.siegmar@vitrado.de>; +Cc: pgsql-jdbc



On Sat, 23 Apr 2005, Oliver Siegmar wrote:

> The applied patch contains all modifications from the last one 
> (pgjdbc_interval2.diff) as well as a replacement for the regular expression 
> code.
> 

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.
 - Calendar.getTimeInMillis is protected before 1.4 
 - Added db access to the test case

My one remaining question is about the roll function.  What is the purpose 
of roll, don't we want add?  Ignoring carryover seems like a mistake.  
Also in the roll method the milliseconds calculation should round the 
value so 0.6006 seconds becomes 601 milliseconds.

Kris Jurka

Attachments:

pgjdbc_interval4.diff (text/plain, 19.7K) download diff -rcN clean/org/postgresql/test/jdbc2/IntervalTest.java interval/org/postgresql/test/jdbc2/IntervalTest.java *** clean/org/postgresql/test/jdbc2/IntervalTest.java Wed Dec 31 16:00:00 1969 --- interval/org/postgresql/test/jdbc2/IntervalTest.java Fri Apr 29 00:35:35 2005 *************** *** 0 **** --- 1,163 ---- + package org.postgresql.test.jdbc2; + + import java.util.Calendar; + import java.util.Date; + import java.util.GregorianCalendar; + import java.sql.*; + + import junit.framework.TestCase; + + import org.postgresql.util.PGInterval; + import org.postgresql.test.TestUtil; + + public class IntervalTest extends TestCase + { + + private Connection _conn; + + public IntervalTest(String name) + { + super(name); + } + + protected void setUp() throws Exception + { + _conn = TestUtil.openDB(); + TestUtil.createTable(_conn, "testinterval", "v interval"); + } + + protected void tearDown() throws Exception + { + TestUtil.dropTable(_conn, "testinterval"); + TestUtil.closeDB(_conn); + } + + public void testOnlineTests() throws SQLException + { + PreparedStatement pstmt = _conn.prepareStatement("INSERT INTO testinterval VALUES (?)"); + pstmt.setObject(1, new PGInterval(2004, 13, 28, 0, 0, 43000.9013)); + pstmt.executeUpdate(); + pstmt.close(); + + Statement stmt = _conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT v FROM testinterval"); + assertTrue(rs.next()); + PGInterval pgi = (PGInterval)rs.getObject(1); + assertEquals(2005, pgi.getYears()); + assertEquals(1, pgi.getMonths()); + assertEquals(28, pgi.getDays()); + assertEquals(11, pgi.getHours()); + assertEquals(56, pgi.getMinutes()); + assertEquals(40.9013, pgi.getSeconds(), 0.000001); + assertTrue(!rs.next()); + rs.close(); + stmt.close(); + } + + public void testOfflineTests() + throws Exception + { + PGInterval pgi = new PGInterval(2004, 4, 20, 15, 57, 12.1); + + assertEquals(2004, pgi.getYears()); + assertEquals(4, pgi.getMonths()); + assertEquals(20, pgi.getDays()); + assertEquals(15, pgi.getHours()); + assertEquals(57, pgi.getMinutes()); + assertEquals(12.1, pgi.getSeconds(), 0); + + PGInterval pgi2 = new PGInterval("@ 2004 years 4 mons 20 days 15 hours 57 mins 12.1 secs"); + assertEquals(pgi, pgi2); + + // Singular units + PGInterval pgi3 = new PGInterval("@ 2004 year 4 mon 20 day 15 hour 57 min 12.1 sec"); + assertEquals(pgi, pgi3); + + PGInterval pgi4 = new PGInterval("2004 years 4 mons 20 days 15:57:12.1"); + assertEquals(pgi, pgi4); + + // Ago test + pgi = new PGInterval("@ 2004 years 4 mons 20 days 15 hours 57 mins 12.1 secs ago"); + assertEquals(-2004, pgi.getYears()); + assertEquals(-4, pgi.getMonths()); + assertEquals(-20, pgi.getDays()); + assertEquals(-15, pgi.getHours()); + assertEquals(-57, pgi.getMinutes()); + assertEquals(-12.1, pgi.getSeconds(), 0); + + // Char test + pgi = new PGInterval("@ +2004 years -4 mons +20 days -15 hours +57 mins -12.1 secs"); + assertEquals(2004, pgi.getYears()); + assertEquals(-4, pgi.getMonths()); + assertEquals(20, pgi.getDays()); + assertEquals(-15, pgi.getHours()); + assertEquals(57, pgi.getMinutes()); + assertEquals(-12.1, pgi.getSeconds(), 0); + } + + public void testCalendar() + throws Exception + { + Calendar cal = new GregorianCalendar(); + Calendar cal2 = (Calendar)cal.clone(); + + PGInterval pgi = new PGInterval("@ 1 year -23 hours -3 mins -3.30 secs"); + pgi.roll(cal2); + + cal2.roll(Calendar.YEAR, -1); + cal2.roll(Calendar.HOUR, 23); + cal2.roll(Calendar.MINUTE, 3); + cal2.roll(Calendar.SECOND, 3); + cal2.roll(Calendar.MILLISECOND, 300); + + assertEquals(cal, cal2); + + pgi.roll(cal2); + PGInterval pgi2 = new PGInterval("@ 1 year -23 hours -3 mins -3.30 secs ago"); + pgi2.roll(cal2); + + assertEquals(cal, cal2); + + pgi = new PGInterval("@ 1 year -23 hours -3 mins -3.30 secs ago"); + pgi.roll(cal2); + + cal2.roll(Calendar.YEAR, 1); + cal2.roll(Calendar.HOUR, -23); + cal2.roll(Calendar.MINUTE, -3); + cal2.roll(Calendar.SECOND, -3); + cal2.roll(Calendar.MILLISECOND, -300); + + assertEquals(cal, cal2); + } + + public void testDate() + throws Exception + { + Date date = new Date(); + Date date2 = new Date(date.getTime()); + + PGInterval pgi = new PGInterval("@ +2004 years -4 mons +20 days -15 hours +57 mins -12.1 secs"); + pgi.roll(date); + + PGInterval pgi2 = new PGInterval("@ +2004 years -4 mons +20 days -15 hours +57 mins -12.1 secs ago"); + pgi2.roll(date); + + assertEquals(date2, date); + } + + public void testISODate() + throws Exception + { + Date date = new Date(); + Date date2 = new Date(date.getTime()); + + PGInterval pgi = new PGInterval("+2004 years -4 mons +20 days -15:57:12.1"); + pgi.roll(date); + + PGInterval pgi2 = new PGInterval("-2004 years 4 mons -20 days 15:57:12.1"); + pgi2.roll(date); + + assertEquals(date2, date); + } + + } diff -rcN clean/org/postgresql/test/jdbc2/Jdbc2TestSuite.java interval/org/postgresql/test/jdbc2/Jdbc2TestSuite.java *** clean/org/postgresql/test/jdbc2/Jdbc2TestSuite.java Fri Feb 4 01:14:27 2005 --- interval/org/postgresql/test/jdbc2/Jdbc2TestSuite.java Fri Apr 29 00:01:12 2005 *************** *** 81,86 **** --- 81,87 ---- suite.addTestSuite(CursorFetchTest.class); suite.addTestSuite(ServerCursorTest.class); + suite.addTestSuite(IntervalTest.class); suite.addTestSuite(GeometricTest.class); suite.addTestSuite(LoginTimeoutTest.class); diff -rcN clean/org/postgresql/util/PGInterval.java interval/org/postgresql/util/PGInterval.java *** clean/org/postgresql/util/PGInterval.java Mon Jan 24 22:13:41 2005 --- interval/org/postgresql/util/PGInterval.java Fri Apr 29 00:40:29 2005 *************** *** 10,33 **** package org.postgresql.util; import java.io.Serializable; public class PGInterval extends PGobject implements Serializable, Cloneable { public PGInterval() { setType("interval"); } ! public PGInterval(String value ) { ! setType("interval"); ! this.value = value; } ! /* ! * This must be overidden to allow the object to be cloned */ public Object clone() { ! return new PGInterval( value ); } } --- 10,446 ---- package org.postgresql.util; import java.io.Serializable; + import java.sql.SQLException; + import java.text.DecimalFormat; + import java.util.Calendar; + import java.util.Date; + import java.util.Locale; + import java.util.StringTokenizer; + /** + * This implements a class that handles the PostgreSQL interval type + */ public class PGInterval extends PGobject implements Serializable, Cloneable { + + private int years; + private int months; + private int days; + private int hours; + private int minutes; + private double seconds; + + private final static DecimalFormat secondsFormat = new DecimalFormat("#.00####"); + + + /** + * reuired by the driver + */ public PGInterval() { setType("interval"); } ! ! /** ! * Initialize a interval with a given interval string representation ! * ! * @param value String representated interval (e.g. '3 years 2 mons') ! * @throws SQLException Is thrown if the string representation has an unknown format ! * @see #setValue(String) ! */ ! public PGInterval(String value) ! throws SQLException { ! this(); ! setValue(value); ! } ! ! /** ! * Initializes all values of this interval to the specified values ! * ! * @param years Years ! * @param months Months ! * @param days Days ! * @param hours Hours ! * @param minutes Minutes ! * @param seconds Seconds ! * @see #setValue(int, int, int, int, int, double) ! */ ! public PGInterval(int years, int months, int days, int hours, int minutes, double seconds) ! { ! this(); ! setValue(years, months, days, hours, minutes, seconds); ! } ! ! /** ! * Sets a interval string represented value to this instance. ! * This method only recognize the format, that Postgres returns - ! * not all input formats are supported (e.g. '1 yr 2 m 3 s')! ! * ! * @param value String representated interval (e.g. '3 years 2 mons') ! * @throws SQLException Is thrown if the string representation has an unknown format ! */ ! public void setValue(String value) ! throws SQLException ! { ! final boolean ISOFormat = !value.startsWith("@"); ! ! // Just a simple '0' ! if (!ISOFormat && value.length() == 3 && value.charAt(2) == '0') ! { ! setValue(0, 0, 0, 0, 0, 0.0); ! return; ! } ! ! int years = 0; ! int months = 0; ! int days = 0; ! int hours = 0; ! int minutes = 0; ! double seconds = 0; ! ! try ! { ! String valueToken = null; ! ! value = value.replace('+', ' ').replace('@', ' '); ! final StringTokenizer st = new StringTokenizer(value); ! for (int i = 1; st.hasMoreTokens(); i++) ! { ! String token = st.nextToken(); ! ! if ((i & 1) == 1) ! { ! if (token.indexOf(':') == -1) ! { ! valueToken = token; ! continue; ! } ! ! // This handles hours, minutes, seconds and microseconds for ! // ISO intervals ! int offset = (token.charAt(0) == '-') ? 1 : 0; ! ! hours = nullSafeIntGet(token.substring(offset+0, offset+2)); ! minutes = nullSafeIntGet(token.substring(offset+3, offset+5)); ! seconds = nullSafeDoubleGet(token.substring(offset+6, token.length())); ! ! if (offset == 1) ! { ! hours = -hours; ! minutes = -minutes; ! seconds = -seconds; ! } ! ! valueToken = null; ! } ! else ! { ! // This handles years, months, days for both, ISO and ! // Non-ISO intervals. Hours, minutes, seconds and microseconds ! // are handled for Non-ISO intervals here. ! ! if (token.startsWith("year")) ! years = nullSafeIntGet(valueToken); ! else if (token.startsWith("mon")) ! months = nullSafeIntGet(valueToken); ! else if (token.startsWith("day")) ! days = nullSafeIntGet(valueToken); ! else if (token.startsWith("hour")) ! hours = nullSafeIntGet(valueToken); ! else if (token.startsWith("min")) ! minutes = nullSafeIntGet(valueToken); ! else if (token.startsWith("sec")) ! seconds = nullSafeDoubleGet(valueToken); ! } ! } ! } ! catch (NumberFormatException e) ! { ! throw new PSQLException(GT.tr("Conversion of interval failed"), PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE, e); ! } ! ! if (!ISOFormat && value.endsWith("ago")) ! { ! // Inverse the leading sign ! setValue(-years, -months, -days, -hours, -minutes, -seconds); ! } ! else ! { ! setValue(years, months, days, hours, minutes, seconds); ! } ! } ! ! /** ! * Set all values of this interval to the specified values ! * ! * @param years Years ! * @param months Months ! * @param days Days ! * @param hours Hours ! * @param minutes Minutes ! * @param seconds Seconds ! */ ! public void setValue(int years, int months, int days, int hours, int minutes, double seconds) ! { ! setYears(years); ! setMonths(months); ! setDays(days); ! setHours(hours); ! setMinutes(minutes); ! setSeconds(seconds); ! } ! ! /** ! * Returns the stored interval information as a string ! * ! * @return String represented interval ! */ ! public String getValue() ! { ! StringBuffer sb = new StringBuffer(); ! sb.append(years).append(" years "); ! sb.append(months).append(" mons "); ! sb.append(days).append(" days "); ! sb.append(hours).append(" hour "); ! sb.append(minutes).append(" mins "); ! sb.append(secondsFormat.format(seconds)).append(" secs"); ! return sb.toString(); ! } ! ! /** ! * Returns the years represented by this interval ! * ! * @return Years ! */ ! public int getYears() ! { ! return years; ! } ! ! /** ! * Set the years of this interval to the specified value ! * ! * @param Years ! */ ! public void setYears(int years) ! { ! this.years = years; ! } ! ! /** ! * Returns the months represented by this interval ! * ! * @return Months ! */ ! public int getMonths() ! { ! return months; ! } ! ! /** ! * Set the months of this interval to the specified value ! * ! * @param Months ! */ ! public void setMonths(int months) ! { ! this.months = months; ! } ! ! /** ! * Returns the days represented by this interval ! * ! * @return Days ! */ ! public int getDays() ! { ! return days; ! } ! ! /** ! * Set the days of this interval to the specified value ! * ! * @param Days ! */ ! public void setDays(int days) ! { ! this.days = days; ! } ! ! /** ! * Returns the hours represented by this interval ! * ! * @return Hours ! */ ! public int getHours() ! { ! return hours; ! } ! ! /** ! * Set the hours of this interval to the specified value ! * ! * @param Hours ! */ ! public void setHours(int hours) ! { ! this.hours = hours; ! } ! ! /** ! * Returns the minutes represented by this interval ! * ! * @return Minutes ! */ ! public int getMinutes() ! { ! return minutes; ! } ! ! /** ! * Set the minutes of this interval to the specified value ! * ! * @param Minutes ! */ ! public void setMinutes(int minutes) ! { ! this.minutes = minutes; ! } ! ! /** ! * Returns the seconds represented by this interval ! * ! * @return Seconds ! */ ! public double getSeconds() ! { ! return seconds; ! } ! ! /** ! * Set the seconds of this interval to the specified value ! * ! * @param Seconds ! */ ! public void setSeconds(double seconds) ! { ! this.seconds = seconds; ! } ! ! /** ! * Rolls this interval on a given calendar ! * ! * @param cal Calendar instance to roll on ! */ ! public void roll(Calendar cal) ! { ! // Avoid precision loss ! // Be aware postgres doesn't return more than 60 seconds - no overflow can happen ! final int microseconds = (int)(getSeconds() * 1000000.0); ! final int seconds = microseconds / 1000000; // Strip off fractal part ! final int milliseconds = microseconds / 1000 - seconds * 1000; ! ! cal.roll(Calendar.YEAR, getYears()); ! cal.roll(Calendar.MONTH, getMonths()); ! cal.roll(Calendar.DAY_OF_WEEK_IN_MONTH, getDays()); ! cal.roll(Calendar.HOUR, getHours()); ! cal.roll(Calendar.MINUTE, getMinutes()); ! cal.roll(Calendar.SECOND, seconds); ! cal.roll(Calendar.MILLISECOND, milliseconds); ! } ! ! /** ! * Rolls this interval on a given date ! * ! * @param cal Date instance to roll on ! */ ! public void roll(Date date) ! { ! final Calendar cal = Calendar.getInstance(); ! cal.setTime(date); ! roll(cal); ! date.setTime(cal.getTime().getTime()); ! } ! ! /** ! * Returns integer value of value or 0 if value is null ! * ! * @param value integer as string value ! * @return integer parsed from string value ! * @throws NumberFormatException if the string contains invalid chars ! */ ! private int nullSafeIntGet(String value) ! throws NumberFormatException ! { ! return (value == null) ? 0 : Integer.parseInt(value); ! } ! ! /** ! * Returns double value of value or 0 if value is null ! * ! * @param value double as string value ! * @return double parsed from string value ! * @throws NumberFormatException if the string contains invalid chars ! */ ! private double nullSafeDoubleGet(String value) ! throws NumberFormatException ! { ! return (value == null) ? 0 : Double.parseDouble(value); ! } ! ! /** ! * Returns whether an object is equal to this one or not ! * ! * @param obj Object to compare with ! * @return true if the two intervals are identical ! */ ! public boolean equals(Object obj) ! { ! if (obj == null) ! return false; ! ! if (obj == this) ! return true; ! ! if (!(obj instanceof PGInterval)) ! return false; ! ! final PGInterval pgi = (PGInterval)obj; ! ! return ! pgi.years == years && ! pgi.months == months && ! pgi.days == days && ! pgi.hours == hours && ! pgi.minutes == minutes && ! pgi.seconds == seconds; } ! /** ! * Returns a hashCode for this object ! * ! * @return hashCode ! */ ! public int hashCode() ! { ! return ((((((7 * 31 + ! (int)Double.doubleToLongBits(seconds)) * 31 + ! minutes) * 31 + ! hours) * 31 + ! days) * 31 + ! months) * 31 + ! years) * 31; ! } ! ! /** ! * This clones the interval ! * ! * @return Cloned interval */ public Object clone() { ! return new PGInterval(years, months, days, hours, minutes, seconds); } + }
^ permalink raw reply [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-29 10:25               ` Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 10:35                 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-29 10:25 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

On Friday 29 April 2005 10:01, Kris Jurka wrote:
> On Sat, 23 Apr 2005, Oliver Siegmar wrote:
> > The applied patch contains all modifications from the last one
> > (pgjdbc_interval2.diff) as well as a replacement for the regular
> > expression code.
>
> 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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 10:25               ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
@ 2005-04-29 10:35                 ` Kris Jurka <books@ejurka.com>
  2005-04-29 15:38                   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  0 siblings, 1 reply; 18+ messages in thread

From: Kris Jurka @ 2005-04-29 10:35 UTC (permalink / raw)
  To: Oliver Siegmar <o.siegmar@vitrado.de>; +Cc: pgsql-jdbc



On Fri, 29 Apr 2005, Oliver Siegmar wrote:

> On Friday 29 April 2005 10:01, Kris Jurka wrote:
> > On Sat, 23 Apr 2005, Oliver Siegmar wrote:
> > > The applied patch contains all modifications from the last one
> > > (pgjdbc_interval2.diff) as well as a replacement for the regular
> > > expression code.
> >
> > 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.

Well the constructor and setXXX methods allow it.  I'm not saying we need 
to go out of our way to make all excessive values possible, but if we can 
allow say 90 seconds with no other harm, why not?  If we're going to 
prevent it, we should prevent it at set time, not at getValue time.

> > 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()

Surely it does, consider a calendar 2001-01-01 00:00:45 and an interval of 
20 seconds.  roll gives 2001-01-01 00:00:05 while add gives the 
correct 2001-01-01 00:01:05

> > 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?
> 

final int milliseconds = microseconds / 1000 - seconds * 1000;

Shouldn't this be "microseconds + 500 / 1000" (although it does need to 
account for the sign.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 10:25               ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 10:35                 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-29 15:38                   ` Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 20:42                     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-29 15:38 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

Hi Kris,

On Friday 29 April 2005 12:35, Kris Jurka wrote:
> > > 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()
>
> Surely it does, consider a calendar 2001-01-01 00:00:45 and an interval of
> 20 seconds.  roll gives 2001-01-01 00:00:05 while add gives the
> correct 2001-01-01 00:01:05

Oh...I must have goofed. You're right - I tried to implement a working add() 
version.

In the initial implementation of add() (a never sent implementation) I was too 
demanding. It is just not possible to "roll" every date forth and back and 
get the initial date, of course. Just think of Mar 31 plus one month and then 
one month back...that cannot be Mar 31 and that's okay. This has to be 
considered when testing - not any starting date can be used to roll forth and 
back.

> Shouldn't this be "microseconds + 500 / 1000" (although it does need to
> account for the sign.

Yeah, good point - applied that, too.


Give pgjdbc_interval5.diff a new try ;-)


Oliver

Attachments:

  pgjdbc_interval5.diff.gz (application/x-gzip, 4.1K) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 10:25               ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 10:35                 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 15:38                   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
@ 2005-04-29 20:42                     ` Kris Jurka <books@ejurka.com>
  2005-04-30 08:14                       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  0 siblings, 1 reply; 18+ messages in thread

From: Kris Jurka @ 2005-04-29 20:42 UTC (permalink / raw)
  To: Oliver Siegmar <o.siegmar@vitrado.de>; +Cc: pgsql-jdbc



On Fri, 29 Apr 2005, Oliver Siegmar wrote:

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

Applied.  Thanks.

Kris Jurka




^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 10:25               ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 10:35                 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 15:38                   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 20:42                     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-30 08:14                       ` Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-30 08:25                         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-30 08:14 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

On Friday 29 April 2005 22:42, Kris Jurka wrote:
> On Fri, 29 Apr 2005, Oliver Siegmar wrote:
> > Give pgjdbc_interval5.diff a new try ;-)
>
> Applied.  Thanks.

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


Oliver



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 10:25               ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 10:35                 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 15:38                   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 20:42                     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-30 08:14                       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
@ 2005-04-30 08:25                         ` Kris Jurka <books@ejurka.com>
  2005-04-30 08:43                           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  0 siblings, 1 reply; 18+ messages in thread

From: Kris Jurka @ 2005-04-30 08:25 UTC (permalink / raw)
  To: Oliver Siegmar <o.siegmar@vitrado.de>; +Cc: pgsql-jdbc



On Sat, 30 Apr 2005, Oliver Siegmar wrote:

> > On Fri, 29 Apr 2005, Oliver Siegmar wrote:
> > > Give pgjdbc_interval5.diff a new try ;-)
> 
> Thanks. Could you also add it to the 8.0 branch? That'd be great!
> 

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.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 10:25               ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 10:35                 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 15:38                   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 20:42                     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-30 08:14                       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-30 08:25                         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
@ 2005-04-30 08:43                           ` Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-30 09:59                             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Oliver Siegmar @ 2005-04-30 08:43 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

On Saturday 30 April 2005 10:25, Kris Jurka wrote:
> On Sat, 30 Apr 2005, Oliver Siegmar wrote:
> > > On Fri, 29 Apr 2005, Oliver Siegmar wrote:
> > > > Give pgjdbc_interval5.diff a new try ;-)
> >
> > Thanks. Could you also add it to the 8.0 branch? That'd be great!
>
> 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





^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Interval support for Postgres
  2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 18:32 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 19:37   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 19:43     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-21 20:02       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-21 21:00         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-23 06:38           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 08:01             ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 10:25               ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 10:35                 ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-29 15:38                   ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-29 20:42                     ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-30 08:14                       ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
  2005-04-30 08:25                         ` Re: Interval support for Postgres Kris Jurka <books@ejurka.com>
  2005-04-30 08:43                           ` Re: Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
@ 2005-04-30 09:59                             ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 18+ messages in thread

From: Kris Jurka @ 2005-04-30 09:59 UTC (permalink / raw)
  To: Oliver Siegmar <o.siegmar@vitrado.de>; +Cc: pgsql-jdbc



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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread


end of thread, other threads:[~2005-04-30 09:59 UTC | newest]

Thread overview: 18+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-04-21 09:07 Interval support for Postgres Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-21 18:32 ` Kris Jurka <books@ejurka.com>
2005-04-21 19:37   ` Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-21 19:43     ` Kris Jurka <books@ejurka.com>
2005-04-21 20:02       ` Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-21 21:00         ` Kris Jurka <books@ejurka.com>
2005-04-21 21:47           ` Oliver Jowett <oliver@opencloud.com>
2005-04-22 11:01           ` Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-23 06:38           ` Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-29 08:01             ` Kris Jurka <books@ejurka.com>
2005-04-29 10:25               ` Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-29 10:35                 ` Kris Jurka <books@ejurka.com>
2005-04-29 15:38                   ` Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-29 20:42                     ` Kris Jurka <books@ejurka.com>
2005-04-30 08:14                       ` Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-30 08:25                         ` Kris Jurka <books@ejurka.com>
2005-04-30 08:43                           ` Oliver Siegmar <o.siegmar@vitrado.de>
2005-04-30 09:59                             ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox