Re: Insert via Select Problem - Mailing list pgsql-general

From Tom Lane
Subject Re: Insert via Select Problem
Date
Msg-id 6545.973528575@sss.pgh.pa.us
Whole thread Raw
In response to Insert via Select Problem  (Tara Pierkowski <tara@vilaj.com>)
List pgsql-general
Tara Pierkowski <tara@vilaj.com> writes:
> In essence, what I have found is that if I execute a somewhat lengthy query
> and dump the output to the screen I get a result set that is different than
> if I execute the exact same query but use the query as the source for an
> insert command.

You didn't show us the data types of the source table, but I'll bet that
one of the GROUP BY columns has a different type than the column you are
trying to INSERT it into.  This is a known bug in 7.0.* (and all earlier
releases) --- the type coercion is done at the wrong time, and the GROUP
operator gets confused because it's expecting to see a different
datatype than what it actually gets.

It's fixed for 7.1, but in the meantime you can work around it by
explicitly coercing the SELECT-list item to the destination column type.

            regards, tom lane

pgsql-general by date:

Previous
From: Tara Pierkowski
Date:
Subject: Insert via Select Problem
Next
From: Jonathan Arrien
Date:
Subject: initdb