From: | "Tomasz Karlik" <Tomasz(dot)Karlik(at)ultimo(dot)pl> |
---|---|
To: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>, <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Odp: Re: Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction |
Date: | 2009-09-08 05:48:09 |
Message-ID: | 4AA60C390200002D00003261@mars.ultimo.pl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
>>> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> 9/7/2009 3:47 PM >>>
Hello
2009/9/7 Tomasz Karlik <Tomasz(dot)Karlik(at)ultimo(dot)pl>:
>
>
>>>> 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;
>
it some strange. What version do you use?
on 5.4
postgres=# explain select * from pg_class where relname='aaa';
QUERY PLAN
--------------------------------------------------------------------------------
-------------
Index Scan using pg_class_relname_nsp_index on pg_class (cost=0.00..8.27 rows=
1 width=185)
Index Cond: (relname = 'aaa'::name)
(2 rows)
the casting is implicit.
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 SELECT INTO?
From | Date | Subject | |
---|---|---|---|
Next Message | Martin Edlman | 2009-09-08 13:30:30 | BUG #5043: Stored procedure returning different results for same arguments |
Previous Message | Luke Koops | 2009-09-07 20:29:45 | Re: BUG #5038: WAL file is pending deletion in pg_xlog folder, this interferes with WAL archiving. |