From: | Tino Wildenhain <tino(at)wildenhain(dot)de> |
---|---|
To: | Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: functions marked STABLE not allowed to do INSERT |
Date: | 2005-11-14 19:16:04 |
Message-ID: | 1131995764.7012.15.camel@Andrea.peacock.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Am Montag, den 14.11.2005, 13:29 -0500 schrieb Robert Treat:
> On Monday 14 November 2005 10:02, Tino Wildenhain wrote:
> > New in 8.1 it seems functions marked STABLE are
> > not allowed to have any INSERT statement in them.
> >
>
> Try hiding your inserts in seperate volitle sql function that you can select
> inside your stable function. I think the planner won't be smart enough to
> realize what your doing to it.
Now this is really a bug:
=# CREATE OR REPLACE function foo(int) RETURNS int as $$
$# DECLARE f ALIAS FOR $1;
$# BEGIN
$# RETURN (random()*f)::int;
$# END;
$# $$ LANGUAGE plpgsql STABLE;
=# SELECT foo(10);
foo
-----
6
(1 row)
Instead of screaming here, where I use a VOLATILE
function in my STABLE function which could really
be dangerous, it just works.
And the other example, where I do my insert on purpose
and fully knowing what I do gets refused.
Is this a shortcoming of the function compiler?
I dont think so - it retrieves the OID of used
functions anyway so the lookup on stableness
would be easy - and lets skip the silly scan
for INSERT instead.
Regards
Tino
From | Date | Subject | |
---|---|---|---|
Next Message | Jim C. Nasby | 2005-11-14 19:27:36 | Re: How to find a number of connections |
Previous Message | Tom Lane | 2005-11-14 19:01:15 | Re: 8.0 -> 8.1 dump duplicate key problem? |