Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 3F714EDF370 for ; Tue, 22 May 2012 16:56:21 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SWvBr-0001VB-2D for pgsql-bugs@postgresql.org; Tue, 22 May 2012 19:56:20 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q4MJtndO007004; Tue, 22 May 2012 15:55:50 -0400 (EDT) To: Robert Haas cc: will@heroku.com, pgsql-bugs@postgresql.org Subject: Re: BUG #6626: union all with values of type "unknown" In-reply-to: References: Comments: In-reply-to Robert Haas message dated "Tue, 22 May 2012 15:41:00 -0400" Date: Tue, 22 May 2012 15:55:49 -0400 Message-ID: <7003.1337716549@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/150 X-Sequence-Number: 33121 Robert Haas writes: >> deik3qfhu265n6=> with hello as (select 'hello' as name) >> deik3qfhu265n6-> , bye as (select 'bye' as name) >> deik3qfhu265n6-> select * from hello UNION ALL select * from bye; >> ERROR:  failed to find conversion function from unknown to text > I think it should return a column of type text, just as if you'd done this: > select v from (select 'hello' union all select 'bye') x(v); I don't think it's a great idea to make CTEs handle this differently from other places where the same issue arises (from memory, views and INSERT/SELECT have problems with unknown literals, and there are probably other places I'm forgetting). Should we institute a uniform policy of forcing unknown sub-select outputs to text type? This would almost certainly break a few peoples' queries, but the reduction of surprise might be worth it for most. regards, tom lane