Re: Why do subselects in target lists behave differently wrt implicit casts?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mike Mascari <mascarm(at)mascari(dot)com>
Cc: PostgreSQL-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why do subselects in target lists behave differently wrt implicit casts?
Date: 2004-07-10 18:58:27
Message-ID: 19378.1089485907@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mike Mascari <mascarm(at)mascari(dot)com> writes:
> This is a really trivial question, but I'm curious. Why do
> subselects in target lists behave differently than simple queries?

> [lexus] insert into bar select '';
> INSERT 1319585 1
> [lexus] insert into bar select (select '') as key;
> ERROR: failed to find conversion function from "unknown" to
> character varying

The undecorated literal constant starts out marked as type UNKNOWN.
There is a hack to reinterpret it as the type of the destination
column in an INSERT context. The hack doesn't know anything about
looking inside subselects, though.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2004-07-10 19:11:37 Re: win32 port
Previous Message Bret Busby 2004-07-10 18:23:27 Re: Training and certification