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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Farid Zidan" <farid(at)zidsoft(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5490: Using distinct for select list causes insert of timestamp string literal to fail
Date: 2010-06-04 15:53:05
Message-ID: 18303.1275666785@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Farid Zidan" <farid(at)zidsoft(dot)com> writes:
> If you use keyword 'distinct' for the source select of the insert statement
> the insert fails. Insert succeeds if 'distinct' is not used in select list.

This isn't a bug, it's a consequence of the fact that you're not
specifying the types of the literal constants. DISTINCT forces
the parser to assign a data type to the constants (otherwise there
is no way to understand what duplicate-elimination means) and what
it will fall back to is "text". Try attaching an explicit cast,
eg
'2010-04-30 00:00:00'::timestamp

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Hartmut Goebel 2010-06-04 15:55:33 Re: BUG #5488: pg_dump does not quote column names -> pg_restore may fail when upgrading
Previous Message Farid Zidan 2010-06-04 14:32:43 BUG #5490: Using distinct for select list causes insert of timestamp string literal to fail