Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yp1Ep-0007Lb-IP for pgsql-bugs@arkaria.postgresql.org; Sun, 03 May 2015 21:15:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yp1Eo-000656-Tv for pgsql-bugs@arkaria.postgresql.org; Sun, 03 May 2015 21:15:46 +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 1Yp1En-00064z-W9 for pgsql-bugs@postgresql.org; Sun, 03 May 2015 21:15:46 +0000 Received: from nm7-vm6.bullet.mail.ne1.yahoo.com ([98.138.91.100]) by magus.postgresql.org with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Yp1Ej-0004p9-RM for pgsql-bugs@postgresql.org; Sun, 03 May 2015 21:15:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s2048; t=1430687738; bh=Wc0JIGFNWpp3YparqLHhwc1p4ZCFp+D7zxQ1vJE9q0w=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=jMf4WtzHzbWyykMnoTvmwZ41ipGmWWIQ1AGgaxZxrArrA39eISTT1V9Oue5miTZElSn3JDlvS5RCSKJDyGNcpwvO7pVGEgk5joe38Cje3fEzcR/cguG3EpStvT6AsTzrOwDIp4Krnugaq6+WnU7SWXMcKFmPuNO3NrsFfRyigY4+8JGAtDWmy11Q2jr38Ehw2PrtEanz2MgU7LTKDuV1eDBDPShuRCzGpjBj0RcPgH/KBSDOcaqpWHKnpHdjkU98oY9Ccu+z9c+moQEbVX1BaLnHp0VG0vgOhXv0br6Zeq7+0N0XQpPjS1u7WPC7cZThtmjwG7ArMgu+GcCFEFBZuw== Received: from [98.138.100.114] by nm7.bullet.mail.ne1.yahoo.com with NNFMP; 03 May 2015 21:15:38 -0000 Received: from [98.138.89.171] by tm105.bullet.mail.ne1.yahoo.com with NNFMP; 03 May 2015 21:15:38 -0000 Received: from [127.0.0.1] by omp1027.mail.ne1.yahoo.com with NNFMP; 03 May 2015 21:15:38 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 549737.88568.bm@omp1027.mail.ne1.yahoo.com X-YMail-OSG: MwJ_yDEVM1nDtvs5WXLRA.w1rj3gyo5bAYCClZNI2qqvtlyP4_HeZCukZnjL8nN 9yUz36ADiaeHBBopzYkELEMsMo3NQCdvo8IyJmUjgAWK39t1D9oeN3MP8M_rsC15ObhuRKgibu02 10jsiJU_YiA1KscgufCgH0ARwz3E4mgNK3gRkna08LmmG4M.mggA0xbqDzFqsp86Zt0vDFVVCv6H z5y_eqU2fJ6QqoMPT0rKXdbcoNoP0xodOYh5btCZB_l8kbtwTL.RMnA.uPWmbJxHCG18.L7CUr4N LfzFGVDqc9RkljeUYFPsO1rT0bB7SfINfmLgwtQGipawsM1jQFbY88s47pVSH.rTzCRqnn9TjSfZ Do5yXvl3IF62I9JZEd1DaFsS5n5vXD8_qQO0UPY2nawpGBGcfsahYKJ5ucCu2oc4GgsbRqxzHq4B iawPu_KYN1Jv2iUJ4qlNRKqHia6ftRTuSdJmRZ0lZwNDKzNyJ6QCnVwZsrH9ZHjK9jAJxS2FqOF3 E29.Jq6k07Z4kt8.R_EKmX1f55HLkSMq09i7hYy1kBDkZ4neRnTtU Received: by 98.138.105.217; Sun, 03 May 2015 21:15:38 +0000 Date: Sun, 3 May 2015 21:15:27 +0000 (UTC) From: Kevin Grittner Reply-To: Kevin Grittner To: Tom Lane Cc: Robert Haas , Jeff Davis , Postgres-Bugs Message-ID: <946937656.655853.1430687727733.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: <25218.1430684934@sss.pgh.pa.us> References: <25218.1430684934@sss.pgh.pa.us> Subject: Re: Failure to coerce unknown type to specific type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 2461 X-Pg-Spam-Score: -2.0 (--) 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 Tom Lane wrote: > Kevin Grittner writes: >> If we >> *are* going to allow it, it would be pretty confusing to have it >> behave differently that what I previously outlined (regarding the >> equivalent long form CASE clause). > > AFAICT, we do treat them the same; can you provide an example where > we don't? No, I was just arguing that if we change the CASE clause to return untyped NULL, then the COALESCE clause should follow suit. > It would be interesting to try variants of the > > select u+i from (select '1' as u, '2'::int as i) s where u<'foo'::text; > > example to see what they do if the column has to be converted to two > mutually inconsistent types, assuming you can find candidate types > in each system. I finagled a syntax that was accepted by all servers on SQL Fiddle and got a row with a 3 without the WHERE clause from all products except PostgreSQL: -- Build Schema create table onerow (n int not null); insert into onerow values (1); -- Run SQL select u+i from (select cast('1' as char) as u, 2 as i from onerow) s; Then I added that WHERE clause. select u+i from (select cast('1' as char) as u, 2 as i from onerow) s where u Another idea would be to try things like > > select u+i from (select 'bar' as u, '2'::int as i) s where u<'foo'::text; > > and see exactly what error gets thrown. I changed '1' to 'bar' in the above code. MySQL and SQL Lite return a row with a 2. Oracle throws an error: ORA-01722: invalid number MS SQL Server throws an error: Conversion failed when converting the varchar value 'bar ' to data type int. Yes, my literal was three characters and the error message added a space. >> To restate it, this hardly seems like the most important issue to >> address; I just don't think the standard gives us much cover here. > > I stand by my opinion that the cases that are controversial here > are all illegal per spec. With that last bit you pointed out, I now agree. > We may well want to allow them on usability > grounds, but what the spec does *not* provide any cover for is claiming > that the spec requires some particular non-error interpretation. ok -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs