Re: BUG #5490: Using distinct for select list causes insert of timestamp string literal to fail - Mailing list pgsql-bugs

From Greg Stark
Subject Re: BUG #5490: Using distinct for select list causes insert of timestamp string literal to fail
Date
Msg-id AANLkTilLvx4m4TlHxeFERL60Xubiz0IhTjUXqTkoH6Le@mail.gmail.com
Whole thread Raw
In response to Re: BUG #5490: Using distinct for select list causes insert of timestamp string literal to fail  (Farid Zidan <farid@zidsoft.com>)
Responses Re: BUG #5490: Using distinct for select list causes insert of timestamp string literal to fail  (Farid Zidan <farid@zidsoft.com>)
List pgsql-bugs
On Fri, Jun 4, 2010 at 7:18 PM, Farid Zidan <farid@zidsoft.com> wrote:
> If a simple SQL statement works on 9+ different databases

For what it's worth are you sure it works as you expect in these other
databases?

I suspect what they're doing is doing a DISTINCT of the text values
and then converting the results. That's not the same as what you're
suggesting it do (insert distinct timestamp values) since different
text values can represent the same timestamp. For example look at what
this does:

 select cast(x as timestamp with time zone) from (select distinct x
from (values ('2010-01-01 12:00PM UTC'), ('2010-01-01 7:00AM EST')) as
x(x)) as y;

If you inserted those values into a table with a timestamp with time
zone column you would get duplicate values even with the distinct.

This is the problem with depending on non-standard extensions. You're
never really sure that they're working. They be working on some
systems but doing something unexpected on other systems.

--
greg

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #5488: pg_dump does not quote column names -> pg_restore may fail when upgrading
Next
From: Robert Haas
Date:
Subject: Re: superuser unable to modify settings of a system table