pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Frazer McLean <frazer@frazermclean.co.uk>
Cc: pgsql-general@postgresql.org
Subject: Re: Unexpected interval comparison
Date: Tue, 21 Mar 2017 10:42:16 -0400
Message-ID: <30765.1490107336@sss.pgh.pa.us> (raw)
In-Reply-To: <1490104629.422698.918452336.26FA96B7@webmail.messagingengine.com>
References: <1490104629.422698.918452336.26FA96B7@webmail.messagingengine.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

Frazer McLean <frazer@frazermclean.co.uk> writes:
> I came across an unexpected comparison (tested on PostgreSQL 9.4 and
> 9.6) for intervals with a large difference in magnitude.

>   '1 year'::interval > '32618665 years'::interval;

> Is this a bug?

It looks like the problem is overflow of the result of interval_cmp_value,
because it's trying to compute

=# select '32618665'::int8 * 30 * 86400 * 1000000;
ERROR:  bigint out of range

It's not immediately obvious how to avoid that while preserving the same
comparison semantics :-(

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (17+ messages)  latest in thread

Message-ID: <30765.1490107336@sss.pgh.pa.us>
Permalink:  ../30765.1490107336@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/30765.1490107336@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, frazer@frazermclean.co.uk
  Subject: Re: Unexpected interval comparison
  In-Reply-To: <30765.1490107336@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox