Re: BUG #1651: static date field is not recognized automatically when group by is used

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Peter van der Meer" <peter(dot)vd(dot)meer(at)yifan(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1651: static date field is not recognized automatically when group by is used
Date: 2005-05-06 20:09:12
Message-ID: 17999.1115410152@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Peter van der Meer" <peter(dot)vd(dot)meer(at)yifan(dot)net> writes:
> This query doesn't work:
> INSERT INTO testthis(id, somedate) SELECT 2 as id, '2005-02-02' as
> somedate GROUP BY id, somedate;
> Executing it reports:
> ERROR: column "somedate" is of type date but expression is of type text

The GROUP BY forces the system to choose a type for the grouping column
(else it cannot know what semantics GROUP BY is to have) and given the
lack of any decoration on the literal, it chooses text. Sorry, but we
are unlikely to "fix" this. We do not want the semantics of SELECT to
change just because the result will later be used as an INSERT source,
so it's not workable to make use of the INSERT's column types in
resolving the type of the literal.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-05-06 20:13:52 Re: BUG #1653: Bug in date
Previous Message Guilherme 2005-05-06 19:37:22 BUG #1653: Bug in date