Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YofOG-00053E-62 for pgsql-bugs@arkaria.postgresql.org; Sat, 02 May 2015 21:56:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YofOF-0001xX-JQ for pgsql-bugs@arkaria.postgresql.org; Sat, 02 May 2015 21:56:03 +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 1YofOD-0001vA-Gz for pgsql-bugs@postgresql.org; Sat, 02 May 2015 21:56:01 +0000 Received: from mail-pa0-f41.google.com ([209.85.220.41]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YofOA-00041j-Tp for pgsql-bugs@postgresql.org; Sat, 02 May 2015 21:56:00 +0000 Received: by pacwv17 with SMTP id wv17so125160536pac.0 for ; Sat, 02 May 2015 14:55:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:mime-version:content-transfer-encoding; bh=WRroBZ5RN3zARZ5pizt6XUQa/HfM6PFVhW2OS3zH4JI=; b=LoxDfjFmQ9Szx76XZgwAt5Up8oEmoW9+5v8JMI8nJGBD+GDF/S5yXjML/LQoVLS4mz iwi0jDuiIdtH7BnPgJGKKUNAJ4q7kez861JwZbYx1bT/N12UqxwhMm09PxmhMKNZox0G rbuDtJPR+xSAstyj7udkXFmNwcebF8XLnhYAA9N09qhpcs745Nmoru4ahFLrJwSeoEpN kdxpciISaqNZkpU9MEg/CsEeINunKlFYT9CJ2ctx+YYhOSdj9O9gMSbCxnbOwSp9Jhkg 3oJDY/sLOnYr/HVJrqrWRk9lAMRu4dM4cJ8K/sb0UUmnv2+aulkBTo6qtKw1tH+TXgRd NTsQ== X-Gm-Message-State: ALoCoQnHT8s+oyKEtC7iFs36U5L00vBAOqfHQ6Fnadbrj7KhHnLVTpz1NxXTOb1Lcb6/beEMkPLl X-Received: by 10.70.56.98 with SMTP id z2mr29138408pdp.120.1430603757640; Sat, 02 May 2015 14:55:57 -0700 (PDT) Received: from [192.168.0.105] (c-69-181-249-16.hsd1.ca.comcast.net. [69.181.249.16]) by mx.google.com with ESMTPSA id c16sm8471916pdl.61.2015.05.02.14.55.55 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Sat, 02 May 2015 14:55:56 -0700 (PDT) Message-ID: <1430603756.2499.44.camel@jeff-desktop> Subject: Re: Failure to coerce unknown type to specific type From: Jeff Davis To: Tom Lane Cc: Robert Haas , Postgres-Bugs Date: Sat, 02 May 2015 14:55:56 -0700 In-Reply-To: <37798.1430500134@sss.pgh.pa.us> 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> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 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 can see two possibilities: 1. Resolve "u" from the subselect as text, and later fail to find a match for +(text,int). 2. Resolve +(unknown, int) to +(int, int) first, then inform the subselect that it's looking for an int (in the same way that you propose the insert pass down some context). I don't think the second one really makes sense though. For example: select u+i, u||'suffix'::text from (select '1' as u, '2'::int as i) s; In that case, "+" would be resolved to +(int, int) and || would be resolved to ||(text, text). But "u" from the subselect can't be both an int and text. Then again, we probably want to fail a query like that anyway. So maybe it does make sense as long as we can figure out a single type for "u", and we fail otherwise. Regards, Jeff Davis -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs