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

From Tomasz Karlik
Subject Odp: Re: Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction
Date
Msg-id 4AA60C390200002D00003261@mars.ultimo.pl
Whole thread Raw
In response to Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-bugs
>>> Pavel Stehule <pavel.stehule@gmail.com> 9/7/2009 3:47 PM >>>
Hello

2009/9/7 Tomasz Karlik <Tomasz.Karlik@ultimo.pl>:
>
>
>>>> Alvaro Herrera <alvherre@commandprompt.com> 9/4/2009 7:23 PM >>>
> 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 =3D name($1);
>>     RETURN exists;
>> END;
>> ' LANGUAGE 'plpgsql' IMMUTABLE;
>

it some strange. What version do you use?

on 5.4

postgres=3D# explain select * from pg_class where relname=3D'aaa';
                                         QUERY PLAN

---------------------------------------------------------------------------=
-----
-------------
Index Scan using pg_class_relname_nsp_index on pg_class  (cost=3D0.00..8.27=
 rows=3D
1 width=3D185)
   Index Cond: (relname =3D 'aaa'::name)
(2 rows)

the casting is implicit.

=20
It does'nt work only inside function. Look for execution times in my first =
post. Maybe the planner treats SQL SELECT query other than procedural SELEC=
T INTO?

pgsql-bugs by date:

Previous
From: Luke Koops
Date:
Subject: Re: BUG #5038: WAL file is pending deletion in pg_xlog folder, this interferes with WAL archiving.
Next
From: "Martin Edlman"
Date:
Subject: BUG #5043: Stored procedure returning different results for same arguments