Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yoyqx-00072b-42 for pgsql-bugs@arkaria.postgresql.org; Sun, 03 May 2015 18:42:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yoyqw-0005zZ-Hk for pgsql-bugs@arkaria.postgresql.org; Sun, 03 May 2015 18:42:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yoyqu-0005zQ-JL for pgsql-bugs@postgresql.org; Sun, 03 May 2015 18:42:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Yoyqn-0001c8-NH for pgsql-bugs@postgresql.org; Sun, 03 May 2015 18:42:55 +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 t43IglVG022463; Sun, 3 May 2015 14:42:47 -0400 From: Tom Lane To: Kevin Grittner cc: Jeff Davis , Robert Haas , Postgres-Bugs Subject: Re: Failure to coerce unknown type to specific type In-reply-to: <1378610475.587034.1430677687479.JavaMail.yahoo@mail.yahoo.com> References: <16364.1430672448@sss.pgh.pa.us> <1378610475.587034.1430677687479.JavaMail.yahoo@mail.yahoo.com> Comments: In-reply-to Kevin Grittner message dated "Sun, 03 May 2015 18:28:07 -0000" Date: Sun, 03 May 2015 14:42:47 -0400 Message-ID: <22462.1430678567@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 Kevin Grittner writes: > Tom Lane wrote: >> Jeff Davis writes: >>> 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. > According to SQL Fiddle: MySQL, SQL Lite, and MS SQL Server all > come up with 3 as the answer. Really? The :: syntax is a Postgres-ism, so you surely didn't test this query on those. >> 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. > Do you have a simple example of what you mean? Jeff already pointed out the issue, but consider select u+i from (select '1' as u, '2'::int as i) s where u<'foo'::text; At the very least such a query would behave differently depending on whether we process the outer query's WHERE clause before or after its SELECT output list. 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