Re: Strange interval arithmetic

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Strange interval arithmetic
Date: 2005-11-27 15:45:18
Message-ID: 20051127154517.GA34720@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Sun, Nov 27, 2005 at 11:15:04PM +0800, Christopher Kings-Lynne wrote:
> What's going on here? Some sort of integer wraparound?
[...]
> test=# select interval '2378234234 seconds';
> interval
> --------------
> 596523:14:07
> (1 row)

Looks like the value is stuck at 2^31 - 1 seconds:

test=> select interval '2147483646 seconds'; -- 2^31 - 2
interval
--------------
596523:14:06
(1 row)

test=> select interval '2147483647 seconds'; -- 2^31 - 1
interval
--------------
596523:14:07
(1 row)

test=> select interval '2147483648 seconds'; -- 2^31
interval
--------------
596523:14:07
(1 row)

--
Michael Fuhr

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2005-11-27 16:01:40 Re: Windows installation notes
Previous Message Christopher Kings-Lynne 2005-11-27 15:15:04 Strange interval arithmetic

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-11-27 16:29:35 Re: Case Conversion Fix for MB Chars
Previous Message Christopher Kings-Lynne 2005-11-27 15:15:04 Strange interval arithmetic