X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 645F3529AD for ; Tue, 19 Jul 2005 11:30:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41661-09 for ; Tue, 19 Jul 2005 14:30:28 +0000 (GMT) Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id 8989B529A7 for ; Tue, 19 Jul 2005 11:30:27 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id D24DE418335; Tue, 19 Jul 2005 15:30:20 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id A6E8915EE6; Tue, 19 Jul 2005 15:18:31 +0100 (BST) Received: from mainbox.archonet.com ([127.0.0.1]) by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05011-09; Tue, 19 Jul 2005 15:18:28 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 636DF15ED9; Tue, 19 Jul 2005 15:18:28 +0100 (BST) Message-ID: <42DD0BB4.6050108@archonet.com> Date: Tue, 19 Jul 2005 15:18:28 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: ilejn@yandex.ru Cc: pgsql-general@postgresql.org Subject: Re: Old question - failed to find conversion function from References: <42DCC1E9.2060300@aeccom.com> <42DCCCCE.000006.04382@mfront8.yandex.ru> <42DCDE07.4020906@archonet.com> <42DCEFEE.000005.12199@mfront8.yandex.ru> In-Reply-To: <42DCEFEE.000005.12199@mfront8.yandex.ru> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.056 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/767 X-Sequence-Number: 80865 Ilja Golshtein wrote: >>Well, it would obviously be better if PG could figure out it was safe, >>but I'm not sure there's a general case where it is. You can see it's OK >>because you know there's only one row in your SELECT result-set. > > > I think, it's OK because NULL can be compared with anything > with predictable result and no additional information about > types is necessary. > Is it correct vision? Yes*, but you've not got a single NULL in your examples, you've got a set of rows containing one unnamed column with an unspecified type. That set happens to have only one row and that contains a NULL. > I agree it's hard to proceed your query with UNION > and some sort of error is reasonable here. But from outside the brackets, they look the same. What would happen ideally, is that PG would notice we have a single row and column here and collapse this down to a single scalar value. However, I'm not sure under what circumstances it can do so (or does), or whether it is cost-effective. [* Actually, I think NULLs are typed in SQL, which means you should be able to get type violations. ] -- Richard Huxton Archonet Ltd