Re: plan invalidation vs stored procedures

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Asko Oja" <ascoja(at)gmail(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Martin Pihlak" <martin(dot)pihlak(at)gmail(dot)com>, "Pg Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plan invalidation vs stored procedures
Date: 2008-08-05 14:17:53
Message-ID: 162867790808050717u677508c7s3f44cc888d7ed1cd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2008/8/5 Asko Oja <ascoja(at)gmail(dot)com>:
> postgres=# create or replace function pavel ( i_param text, status OUT int,
> status_text OUT text ) returns record as $$ select 200::int, 'ok'::text; $$
> language sql;
> CREATE FUNCTION
> postgres=# create or replace function pavel ( i_param text, status OUT int,
> status_text OUT text, more_text OUT text ) returns record as $$ select
> 200::int, 'ok'::text, 'tom'::text; $$ language sql;
> ERROR: cannot change return type of existing function
> DETAIL: Row type defined by OUT parameters is different.
> HINT: Use DROP FUNCTION first.
>
> On Tue, Aug 5, 2008 at 5:04 PM, Asko Oja <ascoja(at)gmail(dot)com> wrote:
>>
>> > This is simply a bad, wrong, stupid way to do it. Why do you not use
>> > CREATE OR REPLACE FUNCTION?
>> I totally agree we should get this fixed first :)
>>
>> postgres=# create or replace function pavel ( i_param text, status OUT
>> int, status_text OUT text ) returns record as $$ select 200::int,
>> 'ok'::text; $$ language sql;
>> ERROR: cannot change return type of existing function
>> HINT: Use DROP FUNCTION first.
>>

you cannot change header of function. It's same as change C header of
function without complete recompilation.

>> On Tue, Aug 5, 2008 at 4:51 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>>
>>> Martin Pihlak <martin(dot)pihlak(at)gmail(dot)com> writes:
>>> > create function foo() returns integer as $$ begin return 1; end; $$
>>> > language plpgsql;
>>> > CREATE FUNCTION
>>> > prepare c1 as select * from foo();
>>> > PREPARE
>>> > execute c1;
>>> > foo
>>> > -----
>>> > 1
>>> > (1 row)
>>>
>>> > drop function foo();
>>> > DROP FUNCTION
>>> > create function foo() returns integer as $$ begin return 2; end; $$
>>> > language plpgsql;
>>> > CREATE FUNCTION
>>> > execute c1;
>>> > psql:test.sql:11: ERROR: cache lookup failed for function 36555
>>>
>>> This is simply a bad, wrong, stupid way to do it. Why do you not use
>>> CREATE OR REPLACE FUNCTION?
>>>
>>> regards, tom lane
>>>
>>> --
>>> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-hackers
>>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2008-08-05 14:18:41 Re: searching bison guru - grouping sets implementation
Previous Message Tom Lane 2008-08-05 14:17:19 Re: Parsing of pg_hba.conf and authentication inconsistencies