Re: problem with overloading the "coalesce" function

From: Richard Huxton <dev(at)archonet(dot)com>
To: Emil Rachovsky <zsevgymko(at)yahoo(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: problem with overloading the "coalesce" function
Date: 2006-03-06 11:29:56
Message-ID: 440C1D34.6060308@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Emil Rachovsky wrote:
>
> --- Richard Huxton <dev(at)archonet(dot)com> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Frank Church 2006-03-06 12:46:24 Re: How to determine the table a query or a views columns come from?
Previous Message Emil Rachovsky 2006-03-06 11:13:33 Re: problem with overloading the "coalesce" function

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Beutin 2006-03-06 13:25:52 Help with "missing FROM clause" needed
Previous Message Emil Rachovsky 2006-03-06 11:13:33 Re: problem with overloading the "coalesce" function