Thread: replacing a function called "isnull" reports an error

replacing a function called "isnull" reports an error

From
César Arnold
Date:
Hi, I created a function called "isnull" for test
purposes and when trying to replace it returns the
message belows :

-- Function: public.isnull(anyelement)

-- DROP FUNCTION public.isnull(anyelement);

CREATE OR REPLACE FUNCTION public.isnull(anyelement) RETURNS bool AS
'   SELECT $1 is null;
'
LANGUAGE 'sql' VOLATILE;

ERROR:  syntax error at or near "isnull" at character
120

Thanks.



_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade!
http://br.acesso.yahoo.com/


Re: replacing a function called "isnull" reports an error

From
Peter Eisentraut
Date:
César Arnold wrote:
> Hi, I created a function called "isnull" for test
> purposes and when trying to replace it returns the
> message belows :

ISNULL is a reserved word.  You need to quote the name or pick a
different one.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: replacing a function called "isnull" reports an error

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> César Arnold wrote:
>> Hi, I created a function called "isnull" for test
>> purposes and when trying to replace it returns the
>> message belows :

> ISNULL is a reserved word.  You need to quote the name or pick a
> different one.

I think what he's unhappy about is this inconsistency:

regression=# create function isnull(int) returns bool as 'select $1 is null' language sql;
CREATE FUNCTION
regression=# drop function isnull(int);
DROP FUNCTION
regression=# create function public.isnull(int) returns bool as 'select $1 is null' language sql;
ERROR:  syntax error at or near "isnull" at character 24
LINE 1: create function public.isnull(int) returns bool as 'select $...
                               ^
regression=#

ISNULL is a func_name_keyword, so it's legal standing on its own, but we
only allow ColId in a qualified name.  Possibly that could be relaxed.

            regards, tom lane

Re: replacing a function called "isnull" reports an error

From
César Arnold
Date:
Thanks Tom,
I'm trying to drop the function and it's giving a
similar message that the function cannot be dropped
...

I have supposed that "isnull" was a reserved word, butthe system could not accept to create a function if
it cannot drop it (I guess).
Thanks again.
--- Tom Lane <tgl@sss.pgh.pa.us> escreveu:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > César Arnold wrote:
> >> Hi, I created a function called "isnull" for test
> >> purposes and when trying to replace it returns
> the
> >> message belows :
>
> > ISNULL is a reserved word.  You need to quote the
> name or pick a
> > different one.
>
> I think what he's unhappy about is this
> inconsistency:
>
> regression=# create function isnull(int) returns
> bool as 'select $1 is null' language sql;
> CREATE FUNCTION
> regression=# drop function isnull(int);
> DROP FUNCTION
> regression=# create function public.isnull(int)
> returns bool as 'select $1 is null' language sql;
> ERROR:  syntax error at or near "isnull" at
> character 24
> LINE 1: create function public.isnull(int) returns
> bool as 'select $...
>                                ^
> regression=#
>
> ISNULL is a func_name_keyword, so it's legal
> standing on its own, but we
> only allow ColId in a qualified name.  Possibly that
> could be relaxed.
>
>             regards, tom lane
>


_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade!
http://br.acesso.yahoo.com/