Lists: | pgsql-bugs |
---|
From: | rok(dot)kralj(at)gmail(dot)com |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #8230: Time interval size overflow |
Date: | 2013-06-16 11:03:53 |
Message-ID: | E1UoAkT-0006qe-E5@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 8230
Logged by: Rok Kralj
Email address: rok(dot)kralj(at)gmail(dot)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.
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | rok(dot)kralj(at)gmail(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #8230: Time interval size overflow |
Date: | 2014-01-25 20:56:52 |
Message-ID: | 20140125205652.GC9750@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On Sun, Jun 16, 2013 at 11:03:53AM +0000, rok(dot)kralj(at)gmail(dot)com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 8230
> Logged by: Rok Kralj
> Email address: rok(dot)kralj(at)gmail(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
Attachment | Content-Type | Size |
---|---|---|
interval.diff | text/x-diff | 1.6 KB |
From: | Rok Kralj <rok(dot)kralj(at)gmail(dot)com> |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #8230: Time interval size overflow |
Date: | 2014-01-25 21:07:36 |
Message-ID: | CAMWF=HS0BRVvWCXfquz7x8n8sD7LLLmnDs-n86WukxGhYxSD4Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Hello Bruce,
thank you for your contribution. However, as seen from my later report, the
situation is much much worse (complex, if you want) than this bug. Please
see this:
Rok Kralj,
PostgreSQL enthusiast
2014-01-25 Bruce Momjian <bruce(at)momjian(dot)us>
> On Sun, Jun 16, 2013 at 11:03:53AM +0000, rok(dot)kralj(at)gmail(dot)com wrote:
> > The following bug has been logged on the website:
> >
> > Bug reference: 8230
> > Logged by: Rok Kralj
> > Email address: rok(dot)kralj(at)gmail(dot)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(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + Everyone has their own god. +
>
--
eMail: rok(dot)kralj(at)gmail(dot)com
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Rok Kralj <rok(dot)kralj(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #8230: Time interval size overflow |
Date: | 2014-01-25 21:30:37 |
Message-ID: | 20140125213037.GE9750@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On Sat, Jan 25, 2014 at 10:07:36PM +0100, Rok Kralj wrote:
> Hello Bruce,
>
> thank you for your contribution. However, as seen from my later report, the
> situation is much much worse (complex, if you want) than this bug. Please see
> this:
>
> http://www.postgresql.org/message-id/CAMWF=
> HS++N9-NKsh-o5QSymvp0Np-VB0GdWwAt4uie1h8ZdNTQ(at)mail(dot)gmail(dot)com
Yes, I see that in my mailbox and will address those shortly, but at
least this patch fixes part of the problem.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +