UPDATE is not allowed in a non-volatile function

From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: UPDATE is not allowed in a non-volatile function
Date: 2004-11-01 19:26:32
Message-ID: cm62lp$16li$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2004-11-01 19:45:26 Re: [PATCHES] Open Items
Previous Message Dawid Kuroczko 2004-11-01 18:01:43 '\0' characters in procedural languages.