Re: boolean operator on interval producing strange results

From: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
To: "'Merlin Moncure'" <mmoncure(at)gmail(dot)com>, "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'postgres general'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: boolean operator on interval producing strange results
Date: 2007-02-20 14:46:52
Message-ID: 05ec01c754fd$f67350c0$6400a8c0@dualcore
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


All of these statements produce 'f' for me as well, via 8.2.1 on RHEL 4.

select ((now() - '1 day'::interval)::timestamp - now()) < 0;
select ((now() - '1 day'::interval)::timestamptz - now()) < 0;
select ('-1 days'::interval) < 0;

But all of these return 't':

select ((now() - '1 day'::interval)::timestamp - now()) < '0'::interval;
select ((now() - '1 day'::interval)::timestamptz - now()) <
'0'::interval;
select ('-1 days'::interval) < '0'::interval;

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Merlin Moncure
Sent: Tuesday, February 20, 2007 8:30 AM
To: Tom Lane
Cc: postgres general
Subject: Re: [GENERAL] boolean operator on interval producing strange
results

On 2/19/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Merlin Moncure" <mmoncure(at)gmail(dot)com> writes:
> > # select ((now() - '1 day'::interval)::timestamp - now()) < 0;
> > ?column?
> > ----------
> > f <-- looks busted to me
> > (1 row)
>
> If you'd casted to timestamptz then I'd agree this is busted.
> As-is, it might have something to do with your timezone setting,
> which you didn't mention?

show timezone reports us/eastern in both cases. also, i don't really
see how this matters, since we are comparing '-1 days'::interval with
0 in both cases. in fact:

# show timezone;
TimeZone
------------
US/Eastern
(1 row)

# select ('-1 days'::interval) < 0;
?column?
----------
f
(1 row)

as it happens, after months and months of faithful service, this
machine decided to dump core last night. so, we are scheduling some
downtime + yum update. (my previous mail was wrong, production was the
non-updated box). this is the only environmental difference I can
think of. At the very least I can report back if this fixes the
problem.

merlin

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2007-02-20 14:49:00 Re: Password issue revisited
Previous Message Tom Lane 2007-02-20 14:45:44 Re: boolean operator on interval producing strange results