Re: Bug in CREATE FUNCTION with character type (CONFIRMED BUG)
| От | Pavel Stehule |
|---|---|
| Тема | Re: Bug in CREATE FUNCTION with character type (CONFIRMED BUG) |
| Дата | |
| Msg-id | h2o162867791004150722ice0be678k587badc7e97b74f9@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: Bug in CREATE FUNCTION with character type (CONFIRMED BUG) (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: Bug in CREATE FUNCTION with character type
(CONFIRMED BUG)
|
| Список | pgsql-bugs |
2010/4/15 Tom Lane <tgl@sss.pgh.pa.us>:
> Pavel Stehule <pavel.stehule@gmail.com> writes:
>> I think, so RETURNS TABLE can be modified for returning typmode
>> without significant problems - this function is called in table
>> context and I don't see any problematic use case.
>
> RETURNS TABLE is just a shorthand for some OUT parameters. =C2=A0I don't
> believe it's either easy or a good idea to make it work differently
> from every other function-argument-or-result case.
>
I don't know now. It minimally have to be documented
foodmart=3D# create function f() returns table (a varchar(10), b
varchar(20)) as $$values('Pavel','Stehule')$$ language sql;
CREATE FUNCTION
Time: 121,506 ms
foodmart=3D# select * from f();
a | b
-------+---------
Pavel | Stehule
(1 row)
Time: 0,718 ms
foodmart=3D# create table x as select * from f();
SELECT
Time: 105,357 ms
foodmart=3D# \d x
Table "public.x"
Column | Type | Modifiers
--------+-------------------+-----------
a | character varying |
b | character varying |
workaround is relative simple
foodmart=3D# create function f() returns table (a varchar(10), b
varchar(20)) as $$values('Pavel','Stehule')$$ language sql;
CREATE FUNCTION
Time: 1,009 ms
foodmart=3D# create table x as select a::varchar(20), b::varchar(20)
from (select * from f()) x ;
SELECT
Time: 48,592 ms
foodmart=3D# \d x
Table "public.x"
Column | Type | Modifiers
--------+-----------------------+-----------
a | character varying(20) |
b | character varying(20) |
Regards
Pavel Stehule
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0regards, tom lane
>
В списке pgsql-bugs по дате отправления: