Stable functions problem - Mailing list pgsql-hackers

From Gaetano Mendola
Subject Stable functions problem
Date
Msg-id cq4758$88$1@floppy.pyrenet.fr
Whole thread Raw
Responses Re: Stable functions problem
List pgsql-hackers
Hi all,
after several weeks away I downloaded today the 8.0rc1 and I
tested it with our application.

I'm having a bounce of errors because IMMUTABLE and STABLE
attributes for some of my functions. Let me explain with an example,
what I do is  ( plpgsql )


my_id_user = sp_id_user( a_login );

IF  my_id_user > 0 THEN    RETURN -5;  -- error code for existing user
END IF;

INSERT INTO users ( login ) VALUES ( a_login );

my_id_user = sp_id_user( a_login );


now here I can continue my function using the my_id_user, unfortunatelly
that sp_id_user is declared as IMMUTABLE this mean that at the second call
of sp_id_user my_id_user will not contain the user id.

This was working untill 7.4, is there a way to force sp_id_user to
be reevaluated ? That function is declared immutable because is ofthen
used in expresssion like this:

select * from user_data where id_user = sp_id_user('login');


I believe is a good idea write in the release notes, with a bigger font, this
optimization about stable and immutable functions.


Regards
Gaetano Mendola






pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Help extending pg_class
Next
From: Alvaro Herrera
Date:
Subject: Re: Bitmapset data type???