>>> 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.