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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

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: Sun, 27 Nov 2005 08:45:18 -0700
  • Message-id: <20051127154517(dot)GA34720(at)winnie(dot)fuhr(dot)org>

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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group