X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id DCA7E9DCB49; Mon, 6 Mar 2006 07:54:20 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99641-08; Mon, 6 Mar 2006 07:54:23 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) by postgresql.org (Postfix) with ESMTP id C0F5F9DC81D; Mon, 6 Mar 2006 07:54:18 -0400 (AST) Received: from [213.162.97.75] (helo=mail.metronet.co.uk) by pih-relay05.plus.net with esmtp (Exim) id 1FGEI6-0003wx-2o; Mon, 06 Mar 2006 11:54:18 +0000 Received: from mainbox.archonet.com (unknown [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 1F32840DE71; Mon, 6 Mar 2006 11:29:57 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id CF34FFF04; Mon, 6 Mar 2006 11:29:56 +0000 (GMT) Message-ID: <440C1D34.6060308@archonet.com> Date: Mon, 06 Mar 2006 11:29:56 +0000 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: Emil Rachovsky Cc: "pgsql-general@postgresql.org" , "pgsql-sql@postgresql.org" Subject: Re: problem with overloading the "coalesce" function References: <20060306111333.83983.qmail@web54306.mail.yahoo.com> In-Reply-To: <20060306111333.83983.qmail@web54306.mail.yahoo.com> 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, score=0.121 required=5 tests=[AWL=0.121] X-Spam-Score: 0.121 X-Spam-Level: X-Archive-Number: 200603/200 X-Sequence-Number: 92065 Emil Rachovsky wrote: > > --- Richard Huxton wrote: > >> Emil Rachovsky wrote: >>> Hi, >>> I am trying to overload the "coalesce" function to >>> accept an integer and a string. Here it is : >>> >>> CREATE OR REPLACE FUNCTION "coalesce"(a int4, b >>> "varchar") >>> RETURNS "varchar" AS >> ... >>> I have added it to pg_catalog, but still I cant't >> use >>> it, I get an error on the second parameter >> What is the error? > > The error is : invalid input syntax for integer > That is,it expects an integer as a second parameter, > since the first is an integer. Hmm - looking at the source (and \df in psql) it seems the basic problem is that COALESCE() isn't a function. It has its own code in the parser and its own expression-node. So - your function never gets called because the parser sees coalesce() and doesn't build a function - it builds a coalesce-expression. It should work fine if you rename your function of course. HTH -- Richard Huxton Archonet Ltd