Re: A question of volatility

From: Dean Rasheed <dean_rasheed(at)hotmail(dot)com>
To: Michael Glaesemann <grzm(at)seespotcode(dot)net>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: A question of volatility
Date: 2007-11-25 10:09:57
Message-ID: BAY113-W22BFDBED462A24F2F1741FF2740@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


>> If I have a couple of STABLE functions f1() and f2(), and then I
>> write a third function f3()
>> which does nothing other than call f1() and f2(), is it safe to
>> mark f(3) as IMMUTABLE?
>
> No. Why would calling two STABLE functions be IMMUTABLE? If it's
> going to be anything other than STABLE, it would be VOLATILE.
>
> Michael Glaesemann
> grzm seespotcode net
>

Thanks for that. I was afraid it would sound like a stupid question,
which is why I used the "novice" mailing list. I've only been using
Postgres a few weeks.

My reason for asking is that some languages maintain a dependency tree
of functions, and so could in theory do something clever with
dependent functions - such as distinguishing between *declared* and
*derived* volatility.

Example scenario - suppose I wrote an IMMUTABLE function calc_vat()
which multiplied its input by 0.175 (the VAT rate here in the UK) and
a whole library of other functions based on that. Then, some time
later, I decided that I would quite like to be able to vary the VAT
rate, so I made my calc_vat() function read from a table, making it
STABLE. What you're saying is that I would have to search through all
the functions in the database finding any that call calc_vat(), and
any that call those functions, and so on, making sure that they are
all at least STABLE.

Is there anything available that would help with that process? In
Oracle's PL/SQL, for example, after changing the function, I would
select from USER_OBJECTS, to find any functions which had been marked
invalid by my change.

Cheers, Dean.

_________________________________________________________________
The next generation of MSN Hotmail has arrived - Windows Live Hotmail
http://www.newhotmail.co.uk

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2007-11-25 17:51:38 Re: A question of volatility
Previous Message Andreas 2007-11-25 09:10:08 Re: How cast interval to minutes as number?