Skip site navigation (1) Skip section navigation (2)

Re: stable functions

From: Vincenzo Romano <vincenzo(dot)romano(at)gmail(dot)com>
To: "Filip =?utf-8?q?Rembia=C5=82kowski?=" <plk(dot)zuber(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: stable functions
Date: 2007-05-31 11:38:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Thursday 31 May 2007 13:23:36 Filip Rembiałkowski wrote:
> 2007/5/31, Vincenzo Romano <vincenzo(dot)romano(at)gmail(dot)com>:
> > Hi all.
> >
> > Can functions whose effect is to create functions (yep!)
> > be labelled as "stable"?
> According to the docs, no.
> "STABLE indicates that the function cannot modify the database (...)
> any function that has side-effects must be classified volatile"
> If you labeled creatorfunc(param) as stable, ant then issued "SELECT
> creatorfunc(sometable.param) FROM sometable", there is a theoretical
> risk that creatorfunc would be called only _once_ for each distinct
> value of param.

This is the complete quote:
STABLE indicates that the function cannot modify the database,
and that within a single table scan it will consistently return
the same result for the same argument values, but that its
result could change across SQL statements.
This is the appropriate selection for functions whose results
depend on database lookups, parameter variables (such as the
current time zone), etc.

They talk about table scans which should not involce the information schema
tables, the only tables that get modified by a fubction whose sole effect it
to create other functions.creatorfunc
Nonetheless your remark makes a lot of sense and I'm still in dubt.
In my case the "creatorfunc" has no parameters and returns void as it reads 
data from configuration tables.
And it should be OK if ti were run only once.

I'd say that some more explaination in the documentatio would be great under
"33.6. Function Volatility Categories".

Vincenzo Romano
Maybe Computer will never become as intelligent as Humans.
For sure they won't ever become so stupid. [VR-1988]

In response to


pgsql-general by date

Next:From: Erwin BrandstetterDate: 2007-05-31 11:52:11
Subject: Re: SELECT <all fields except "bad_field"> from mytbl;
Previous:From: Filip RembiałkowskiDate: 2007-05-31 11:23:36
Subject: Re: stable functions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group