Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Merlin Moncure
On Wed, Aug 6, 2008 at 3:29 PM, Florian Pflug <[EMAIL PROTECTED]> wrote: > Merlin Moncure wrote: >> >> you missed the point...if your return type is a composite type that is >> backed by the table (CREATE TABLE, not CREATE TYPE), then you can >> 'alter' the type by altering the table. This can be

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Dimitri Fontaine
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, Le 6 août 08 à 20:42, Marko Kreen a écrit : But you missed my point: if you don't have functions backed by table, the DROP+CREATE results in inappropriate behaviour that can be avoided. Just wanted to say I agree with Marko here: it seems w

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Marko Kreen
On 8/6/08, Florian Pflug <[EMAIL PROTECTED]> wrote: > Merlin Moncure wrote: > > you missed the point...if your return type is a composite type that is > > backed by the table (CREATE TABLE, not CREATE TYPE), then you can > > 'alter' the type by altering the table. This can be done without full > >

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Florian Pflug
Merlin Moncure wrote: you missed the point...if your return type is a composite type that is backed by the table (CREATE TABLE, not CREATE TYPE), then you can 'alter' the type by altering the table. This can be done without full drop recreate of the function. Which - at least IMHO - clearly sh

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Marko Kreen
On 8/6/08, Merlin Moncure <[EMAIL PROTECTED]> wrote: > On Wed, Aug 6, 2008 at 2:28 PM, Marko Kreen <[EMAIL PROTECTED]> wrote: > > On 8/6/08, Merlin Moncure <[EMAIL PROTECTED]> wrote: > >> On Wed, Aug 6, 2008 at 2:20 AM, Marko Kreen <[EMAIL PROTECTED]> wrote: > >> > But the main problem is that

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Asko Oja
Don't you think we try to be careful but still we manage to overlook several times in year something and cause some stupid downtime. On Wed, Aug 6, 2008 at 9:13 PM, Merlin Moncure <[EMAIL PROTECTED]> wrote: > On Wed, Aug 6, 2008 at 2:20 AM, Marko Kreen <[EMAIL PROTECTED]> wrote: > > But the main

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Merlin Moncure
On Wed, Aug 6, 2008 at 2:28 PM, Marko Kreen <[EMAIL PROTECTED]> wrote: > On 8/6/08, Merlin Moncure <[EMAIL PROTECTED]> wrote: >> On Wed, Aug 6, 2008 at 2:20 AM, Marko Kreen <[EMAIL PROTECTED]> wrote: >> > But the main problem is that if the DROP/CREATE happens, the failure >> > mode is very nasty

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Marko Kreen
On 8/6/08, Merlin Moncure <[EMAIL PROTECTED]> wrote: > On Wed, Aug 6, 2008 at 2:20 AM, Marko Kreen <[EMAIL PROTECTED]> wrote: > > But the main problem is that if the DROP/CREATE happens, the failure > > mode is very nasty - you get permanent error on existing backends. > > (Main case I'm talking

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Merlin Moncure
On Wed, Aug 6, 2008 at 2:20 AM, Marko Kreen <[EMAIL PROTECTED]> wrote: > But the main problem is that if the DROP/CREATE happens, the failure > mode is very nasty - you get permanent error on existing backends. > (Main case I'm talking about is functions calling other functions.) > > Some sorta rec

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Hannu Krosing
On Wed, 2008-08-06 at 15:41 +0200, Pavel Stehule wrote: > 2008/8/6 Hannu Krosing <[EMAIL PROTECTED]>: > > On Wed, 2008-08-06 at 12:13 +0200, Pavel Stehule wrote: > >> 2008/8/6 Hannu Krosing <[EMAIL PROTECTED]>: > >> > On Tue, 2008-08-05 at 16:17 +0200, Pavel Stehule wrote: > > .. > >> >> you cannot

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Pavel Stehule
2008/8/6 Hannu Krosing <[EMAIL PROTECTED]>: > On Wed, 2008-08-06 at 12:13 +0200, Pavel Stehule wrote: >> 2008/8/6 Hannu Krosing <[EMAIL PROTECTED]>: >> > On Tue, 2008-08-05 at 16:17 +0200, Pavel Stehule wrote: > .. >> >> you cannot change header of function. It's same as change C header of >> >> fu

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Hannu Krosing
On Wed, 2008-08-06 at 12:13 +0200, Pavel Stehule wrote: > 2008/8/6 Hannu Krosing <[EMAIL PROTECTED]>: > > On Tue, 2008-08-05 at 16:17 +0200, Pavel Stehule wrote: .. > >> you cannot change header of function. It's same as change C header of > >> function without complete recompilation. > > > > SQL i

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Pavel Stehule
2008/8/6 Hannu Krosing <[EMAIL PROTECTED]>: > On Tue, 2008-08-05 at 16:17 +0200, Pavel Stehule wrote: >> 2008/8/5 Asko Oja <[EMAIL PROTECTED]>: >> > postgres=# create or replace function pavel ( i_param text, status OUT int, >> > status_text OUT text ) returns record as $$ select 200::int, 'ok'::te

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Hannu Krosing
On Tue, 2008-08-05 at 16:17 +0200, Pavel Stehule wrote: > 2008/8/5 Asko Oja <[EMAIL PROTECTED]>: > > 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 > >

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-06 Thread Hannu Krosing
On Tue, 2008-08-05 at 16:16 +0200, Pavel Stehule wrote: > 2008/8/5 Martin Pihlak <[EMAIL PROTECTED]>: > >>> DROP FUNCTION > >>> create function foo() returns integer as $$ begin return 2; end; $$ > >>> language plpgsql; > >>> CREATE FUNCTION > >>> execute c1; > >>> psql:test.sql:11: ERROR: cache

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Marko Kreen
On 8/5/08, Merlin Moncure <[EMAIL PROTECTED]> wrote: > On Tue, Aug 5, 2008 at 10:12 AM, Martin Pihlak <[EMAIL PROTECTED]> wrote: > >>> DROP FUNCTION > >>> create function foo() returns integer as $$ begin return 2; end; $$ > language plpgsql; > >>> CREATE FUNCTION > >>> execute c1; > >>> psql

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Merlin Moncure
On Tue, Aug 5, 2008 at 10:12 AM, Martin Pihlak <[EMAIL PROTECTED]> wrote: >>> 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 >> >> T

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Marko Kreen
On 8/5/08, Pavel Stehule <[EMAIL PROTECTED]> wrote: > >> 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. Thats why plan invalidation fo

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Pavel Stehule
2008/8/5 Asko Oja <[EMAIL PROTECTED]>: > 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 O

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Pavel Stehule
2008/8/5 Martin Pihlak <[EMAIL PROTECTED]>: >>> 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, st

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Martin Pihlak
>> 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

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Asko Oja
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

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Asko Oja
> 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'::tex

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Tom Lane
Martin Pihlak <[EMAIL PROTECTED]> 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 functi

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Asko Oja
Hi Thanks for pointing to another thing to fix :) postgres=# create type public.ret_status as ( status integer, status_text text); CREATE TYPE postgres=# create or replace function pavel ( i_param text ) returns public.ret_status as $$ select 200::int, 'ok'::text; $$ language sql; CREATE FUNCTION

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Pavel Stehule
2008/8/5 Martin Pihlak <[EMAIL PROTECTED]>: > Pavel Stehule wrote: >> Hello >> >> try version 8.3. There lot of dependencies are solved. >> > > Yes, 8.3 was the version I was testing with. Same results on the HEAD: > > $ psql -e -f test.sql > select version(); >

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Asko Oja
Hi Sadly PostgreSQL inability to invalidate plan cache when function is dropped causes us downtime and costs money. ERROR: cache lookup failed for function 24865) This time our developers just rewrote function to use OUT parameters instead of return type. Currently i had to forbid dropping functi

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Martin Pihlak
Pavel Stehule wrote: > Hello > > try version 8.3. There lot of dependencies are solved. > Yes, 8.3 was the version I was testing with. Same results on the HEAD: $ psql -e -f test.sql select version(); version

Re: [HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Pavel Stehule
Hello try version 8.3. There lot of dependencies are solved. Regards Pavel Stehule 2008/8/5 Martin Pihlak <[EMAIL PROTECTED]>: > Howdy, > > What is the status of plan invalidation vs stored procedures? From > the initial design discussion I understand that function change handling > was postpone

[HACKERS] plan invalidation vs stored procedures

2008-08-05 Thread Martin Pihlak
Howdy, What is the status of plan invalidation vs stored procedures? From the initial design discussion I understand that function change handling was postponed to "some time in the future". Is anybody already working on that or maybe some ideas of how to implement this? The business case for the