UPDATE is not allowed in a non-volatile function
От | Gaetano Mendola |
---|---|
Тема | UPDATE is not allowed in a non-volatile function |
Дата | |
Msg-id | cm62lp$16li$1@news.hub.org обсуждение исходный текст |
Ответы |
Re: UPDATE is not allowed in a non-volatile function
|
Список | pgsql-hackers |
Hi all, I missed the discussion on hacker about this, and I'd like to give my HO. The fact that a non-volatile function can not perform update is a good improvement but on the other side will limit too much if I know what I'm doing. I did a sort of Lookup framework and this is extensively used in my project. The core is a "read" function that retrieve data from a very huge table. I declared the "read" function as "STABLE" this because each call with the same argument will return always the same value. For performances reason this "read" function first look in a little table (lt) that is used as a first level cache, if the data is not found then the function retrieve the data from the big one (bt) and replace the oldest required row in the lt. As you can understand I have to update lt in order to perform my replace policy. The "read" is often used inside other "STABLE" function. Not being able to declare "read" as STABLE I have to modify the function caller as well... :-( C++ have the same "problem": a const function can not modify the internal status of an object (that is great), however C++ permit to declare some internal status as "mutable" in this way a non-const function is able to modify status marked as mutable. ( For example you need to count how many time a const function was called ). I think a clean solution is be able to declare a table as "mutable" as well. Am I completely wrong or out of mind ? Regards Gaetano Mendola
В списке pgsql-hackers по дате отправления: