Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aygD9-00032o-KH for pgsql-sql@arkaria.postgresql.org; Fri, 06 May 2016 13:54:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aygD8-0000S0-K5 for pgsql-sql@arkaria.postgresql.org; Fri, 06 May 2016 13:54:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aygC9-0007o6-I0 for pgsql-sql@postgresql.org; Fri, 06 May 2016 13:53:29 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aygC6-0002p7-Il for pgsql-sql@postgresql.org; Fri, 06 May 2016 13:53:29 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id F078C207C6 for ; Fri, 6 May 2016 09:53:24 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Fri, 06 May 2016 09:53:24 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=4yJJ1VtZvmJTwEyWMFVjKJBtl5U=; b=Vquxrm b+YjMX8NuMMBEMltkEk7SZkns1pmP1HWs/BVrGKFLWllA1QrUEAPAenxK6wrvZKZ B9b9/aahxYaqTR7pd2VwvHxSwv/Q8SOQasCCMWtU3njG6DuIDQ3adSW+7J2aVJ+r ckRxRgYPeliKg9ghj2ogO6o9z9BnDKNGc9naU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=4yJJ1VtZvmJTwEy WMFVjKJBtl5U=; b=jvKp3fJqR+EhXrJC5nX9VMielt9rqLQMjGcb/Wvhb9ED/Sh eraJVchvesTlHnZihz6V/Dk7jndx8/rTM0wIoiO9hm74CYTgIRZ1Nq06YdOauYeC 38tH64B0ZafBhjlnfe7+3e6lLE3wZvHgPKGGH+sVMV7Jes0yANNHQfjQWir8= X-Sasl-enc: xnwMa6qdZQTHKrDXHY2Sqq8iLz11fiX0vNnDLq59sUCo 1462542804 Received: from [192.168.1.2] (174-24-160-10.tukw.qwest.net [174.24.160.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 772CBC00016; Fri, 6 May 2016 09:53:24 -0400 (EDT) Subject: Re: weird error message To: Michael Moore , postgres list References: From: Adrian Klaver Message-ID: Date: Fri, 6 May 2016 06:53:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 05/05/2016 01:14 PM, Michael Moore wrote: > SELECT COALESCE(dt, i) FROM (SELECT null AS dt, null AS i) q; > gives > ERROR: failed to find conversion function from unknown to text > ********** Error ********** > > ERROR: failed to find conversion function from unknown to text > SQL state: XX000 > > So, I understand the datatype of 'null' is 'unknown', but what does > 'text' have to do with it? Hmm: hplc=> SELECT null AS dt, null AS i; dt | i ----+--- | (1 row) hplc=> select null::text as dt, null::text as i; dt | i ----+--- | (1 row) hplc=> SELECT COALESCE(dt, i) FROM (SELECT null::text AS dt, null::text AS i) q; coalesce ---------- (1 row) hplc=> SELECT COALESCE(dt, i) FROM (SELECT null AS dt, null AS i) q; ERROR: failed to find conversion function from unknown to text So it is not the conversion from NULL to text per se, just when it is done on the output of a derived table. I don't why that is, maybe someone else can chime in. > > Mike > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql