Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsql function

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: tkarlik(at)ultimo(dot)pl
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsql function
Date: 2009-09-04 17:23:06
Message-ID: 20090904172306.GJ5603@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

tkarlik(at)ultimo(dot)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.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2009-09-04 17:26:19 Re: BUG #5028: CASE returns ELSE value always when type is "char"
Previous Message Sam Mason 2009-09-04 17:03:29 Re: BUG #5028: CASE returns ELSE value always when type is "char"