Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsql function - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsql function
Date
Msg-id 20090904172306.GJ5603@alvh.no-ip.org
Whole thread Raw
In response to BUG #5035: cast 'text' to 'name' doesnt work in plpgsql function  ("" <tkarlik@ultimo.pl>)
Responses Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsql function  (Tom Lane <tgl@sss.pgh.pa.us>)
Odp: Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction  ("Tomasz Karlik" <Tomasz.Karlik@ultimo.pl>)
List pgsql-bugs
tkarlik@ultimo.pl wrote:

> Without casting function executes much slower:
>
> CREATE OR REPLACE FUNCTION table_exists(tblname text) RETURNS boolean AS '
> DECLARE
>     exists boolean;
> BEGIN
>     SELECT 1 INTO exists FROM pg_class WHERE relname = name($1);
>     RETURN exists;
> END;
> ' LANGUAGE 'plpgsql' IMMUTABLE;

If you're looking for a speedy answer, try a SQL function, not plpgsql.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-bugs by date:

Previous
From: Sam Mason
Date:
Subject: Re: BUG #5028: CASE returns ELSE value always when type is "char"
Next
From: "Kevin Grittner"
Date:
Subject: Re: BUG #5028: CASE returns ELSE value always when type is "char"