Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YoxGD-0002cn-CK for pgsql-bugs@arkaria.postgresql.org; Sun, 03 May 2015 17:00:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YoxGC-0003xV-Rt for pgsql-bugs@arkaria.postgresql.org; Sun, 03 May 2015 17:00:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YoxGB-0003vf-Cz for pgsql-bugs@postgresql.org; Sun, 03 May 2015 17:00:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1YoxG8-00005X-TZ for pgsql-bugs@postgresql.org; Sun, 03 May 2015 17:00:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t43H0mFX016365; Sun, 3 May 2015 13:00:48 -0400 From: Tom Lane To: Jeff Davis cc: Robert Haas , Postgres-Bugs Subject: Re: Failure to coerce unknown type to specific type In-reply-to: <1430603756.2499.44.camel@jeff-desktop> References: <1430.1428543112@sss.pgh.pa.us> <35651.1430347071@sss.pgh.pa.us> <1430459450.2499.17.camel@jeff-desktop> <37798.1430500134@sss.pgh.pa.us> <1430603756.2499.44.camel@jeff-desktop> Comments: In-reply-to Jeff Davis message dated "Sat, 02 May 2015 14:55:56 -0700" Date: Sun, 03 May 2015 13:00:48 -0400 Message-ID: <16364.1430672448@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Jeff Davis writes: > On Fri, 2015-05-01 at 10:08 -0700, Tom Lane wrote: >> What really ought to happen here, IMO, is that the output columns of the >> sub-select ought to get resolved to non-unknown types while we are doing >> parse analysis of the sub-select. > So, what would happen for something like: > select u+i from (select '1' as u, '2'::int as i) s; I don't think there's any useful alternative to failing on this type of case. You can't realistically postpone resolution of the subquery output types long enough for outer-level expression resolution to provide context. Even if you could, the behavior wouldn't be very well defined, because (as you note) there might be more than one such expression leading to contradictory results. I think it's reasonable to try to let context inform resolution of the subquery output types where there is exactly one immediate source of context, such as the INSERT/SELECT case or UNION/INTERSECT/EXCEPT cases. (Upthread, Kevin whines about our handling of UNION, but that's possibly fixable.) regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs