Odp: Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction

From: "Tomasz Karlik" <Tomasz(dot)Karlik(at)ultimo(dot)pl>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Odp: Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction
Date: 2009-09-07 06:28:45
Message-ID: 4AA4C43D0200002D0000321B@mars.ultimo.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>> Alvaro Herrera <alvherre(at)commandprompt(dot)com> 9/4/2009 7:23 PM >>>
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.

The same issue when using SQL function... However other casting (for example int4->int8) works properly.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2009-09-07 09:21:43 Re: BUG #5038: WAL file is pending deletion in pg_xlog folder, this interferes with WAL archiving.
Previous Message Ilian Georgiev 2009-09-06 20:48:31 BUG #5042: Update numeric within a rule