Re: hidden errors calling a volatile function inside a stable function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Sabin Coanda <sabin(dot)coanda(at)deuromedia(dot)ro>, pgsql-general(at)postgresql(dot)org
Subject: Re: hidden errors calling a volatile function inside a stable function
Date: 2008-11-20 16:18:29
Message-ID: 2753.1227197909@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> writes:
> Merlin Moncure wrote:
>> On Thu, Nov 20, 2008 at 6:21 AM, Sabin Coanda
>> <sabin(dot)coanda(at)deuromedia(dot)ro> wrote:
>>> I found in a STABLE function, for instance "TEST_0"(), it is not allowed to
>>> use INSERT statement. Trying this will give me the error:
>>> ERROR: INSERT is not allowed in a non-volatile function
>>
>> Why did you lie when your declared your function stable? :-)

> I suspect the point here is that PostgreSQL tries to stop you violating
> your claims about the function's stability by preventing DML operations.
> However, it doesn't also attempt to prevent invocation of volatile
> functions.

All this behavior is documented; see
http://www.postgresql.org/docs/8.3/static/xfunc-volatility.html
particularly the NOTE at the bottom.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-11-20 16:20:16 Re: date range query help
Previous Message Bruce Momjian 2008-11-20 16:18:27 Re: List Ettiquette (perhaps Off Topic by now) was: Re: Database access over the Internet...