Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction
От | Pavel Stehule |
---|---|
Тема | Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction |
Дата | |
Msg-id | 162867790909070647g5c7a731ag5c17695f11e8e4d5@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction (Pavel Stehule <pavel.stehule@gmail.com>) |
Список | pgsql-bugs |
2009/9/7 Pavel Stehule <pavel.stehule@gmail.com>: > 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 A= S ' >>> DECLARE >>> exists boolean; >>> BEGIN >>>=C2=A0=C2=A0=C2=A0=C2=A0 SELECT 1 INTO exists FROM pg_class WHERE relnam= e =3D name($1); >>>=C2=A0=C2=A0=C2=A0=C2=A0 RETURN exists; >>> END; >>> ' LANGUAGE 'plpgsql' IMMUTABLE; >> > > it some strange. What version do you use? > > on 5.4 sorry 8.4 > > postgres=3D# explain select * from pg_class where relname=3D'aaa'; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 QUERY PL= AN > > -------------------------------------------------------------------------= ------- > ------------- > =C2=A0Index Scan using pg_class_relname_nsp_index on pg_class =C2=A0(cost= =3D0.00..8.27 rows=3D > 1 width=3D185) > =C2=A0 Index Cond: (relname =3D '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 exa= mple >> int4->int8) works properly. >> >
В списке pgsql-bugs по дате отправления: