| From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
|---|---|
| To: | Tomasz Karlik <Tomasz(dot)Karlik(at)ultimo(dot)pl> |
| Cc: | Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-bugs(at)postgresql(dot)org |
| Subject: | Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction |
| Date: | 2009-09-07 13:47:51 |
| Message-ID: | 162867790909070647g5c7a731ag5c17695f11e8e4d5@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
2009/9/7 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
> 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
sorry 8.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.
>
> regards
> Pavel Stehule
>
>> 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.
>>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2009-09-07 17:17:18 | Re: BUG #5038: WAL file is pending deletion in pg_xlog folder, this interferes with WAL archiving. |
| Previous Message | Pavel Stehule | 2009-09-07 13:47:19 | Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction |