Re: BUG #8230: Time interval size overflow - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #8230: Time interval size overflow
Date
Msg-id 20140125205652.GC9750@momjian.us
Whole thread Raw
In response to BUG #8230: Time interval size overflow  (rok.kralj@gmail.com)
Responses Re: BUG #8230: Time interval size overflow
List pgsql-bugs
On Sun, Jun 16, 2013 at 11:03:53AM +0000, rok.kralj@gmail.com wrote:
> The following bug has been logged on the website:
>
> Bug reference:      8230
> Logged by:          Rok Kralj
> Email address:      rok.kralj@gmail.com
> PostgreSQL version: 9.2.4
> Operating system:   Arch Linux
> Description:
>
> As far as I know, the INTERVAL type is represented using three int32, one
> for months, days and milliseconds.
>
> However, overflow detections seems to work correctly only on these three
> types; if they get overflown indirectly, they do not get detected:
>
> SELECT INTERVAL '3000000000 days'
> ERROR:  interval field value out of range: "3000000000 days"
>
> SELECT INTERVAL '2000000000 years'
> -147483648 years
>
> I'm surprised this hasn't been reported yet. The expected behaviour is to
> raise an error.

The attached patch fixes the problem:

    test=> SELECT INTERVAL '2000000000 years';
    ERROR:  interval out of range
    LINE 1: SELECT INTERVAL '2000000000 years';

It also fixes this case

    test=> SELECT INTERVAL '2000000000-3 years';
    ERROR:  interval field value out of range: "2000000000-3 years"
    LINE 1: SELECT INTERVAL '2000000000-3 years';

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

Attachment

pgsql-bugs by date:

Previous
From: Marco Atzeri
Date:
Subject: Re: BUG #8970: ts_parse incorrectly split numbers in digit token
Next
From: Rok Kralj
Date:
Subject: Re: BUG #8230: Time interval size overflow