Skip site navigation (1) Skip section navigation (2)

Re: Bug in CREATE FUNCTION with character type (CONFIRMED BUG)

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin J Bluck <technology(at)netce(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Bug in CREATE FUNCTION with character type (CONFIRMED BUG)
Date: 2010-04-15 14:22:50
Message-ID: h2o162867791004150722ice0be678k587badc7e97b74f9@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugs
2010/4/15 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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.  I 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=# create function f() returns table (a varchar(10), b
varchar(20)) as $$values('Pavel','Stehule')$$ language sql;
CREATE FUNCTION
Time: 121,506 ms
foodmart=# select * from f();
   a   |    b
-------+---------
 Pavel | Stehule
(1 row)

Time: 0,718 ms
foodmart=# create table x as select * from f();
SELECT
Time: 105,357 ms
foodmart=# \d x
            Table "public.x"
 Column |       Type        | Modifiers
--------+-------------------+-----------
 a      | character varying |
 b      | character varying |

workaround is relative simple

foodmart=# create function f() returns table (a varchar(10), b
varchar(20)) as $$values('Pavel','Stehule')$$ language sql;
CREATE FUNCTION
Time: 1,009 ms
foodmart=# create table x as select a::varchar(20), b::varchar(20)
from (select * from f()) x ;
SELECT
Time: 48,592 ms
foodmart=# \d x
              Table "public.x"
 Column |         Type          | Modifiers
--------+-----------------------+-----------
 a      | character varying(20) |
 b      | character varying(20) |

Regards
Pavel Stehule


>                        regards, tom lane
>

In response to

Responses

pgsql-bugs by date

Next:From: suresh adapaDate: 2010-04-15 14:33:34
Subject: Dump and Restore in postgresql-8.3.6-1PGDG
Previous:From: Aditya VatsDate: 2010-04-15 14:14:36
Subject: BUG #5424: Not able to Install

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group