Re: BUG #8516: Calling VOLATILE from STABLE function

From: Terje Elde <terje(at)elde(dot)net>
To: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
Cc: 'Bruce Momjian' <bruce(at)momjian(dot)us>, Dwayne Towell <dwayne(at)docketnavigator(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8516: Calling VOLATILE from STABLE function
Date: 2013-10-11 08:02:36
Message-ID: 2798C998-40E6-4979-AD0A-64D744D015B7@elde.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Oct 11, 2013, at 9:21 AM, Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr> wrote:

> Inter function dependencies is a hard topic indeed. I still would like
> to see some kind of progress being made someday. The general case is
> turing complete tho, because you can use EXECUTE against programatically
> generated SQL.
>
> You could even generate a CREATE FUNCTION command from within a PL
> function and EXECUTE it then call the created function… and I think I've
> seen people do that in the past.
>
> Still some kind of limited in scope static analysis for the cases where
> it's possible to do so would be great. With pg_depend tracking so that
> you know you're doing something wrong at DROP FUNCTION time.

I'm not very familiar with PostgreSQL internals, so I might be way off here, and I'm asking as much out of curiousity as anything else…

Would it be possible (and make sense) to solve this in a completely different way, not walking the function tree or doing static analysis, but simply setting and checking a bit during execution?

That is, when you execute a STABLE function, set a bit (clear it when function is done), and always check it when executing any VOLATILE function?

If a volatile function checks the bit, and you're "inside" a stable function, you could then raise an exception for calling volatile inside stable?

Terje

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-10-11 08:14:29 Re: Bit String expand bug
Previous Message Dimitri Fontaine 2013-10-11 07:21:21 Re: BUG #8516: Calling VOLATILE from STABLE function