Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group