Re: Suggestions please: names for function
Peter Eisentraut wrote:
Tom Lane writes:
mlw <markw@mohawksoft.com> writes:
(1) const or constant
(2) cacheable
(3) volatileI was wondering about "const" for case 1, also. I think there is some
precedent for using "const" with this meaning in other programming
languages.I think the meaning of "const" tends to be "cannot change the result" --
which may actually make sense in SQL in a future life if you can pass
around table descriptors or cursor references.
A function, such as sin(x) could be considered constant for the result based on
value 'x'
Import Notes
Reference msg id not found: Pine.LNX.4.30.0204031152470.684-100000@peter.localdomain
mlw writes:
A function, such as sin(x) could be considered constant for the result based on
value 'x'
It could also be considered deterministic, strict, cacheable,
mathematically sensible, real, pleasant, or good. ;-)
Out of those, I believe "const" is the worst term, because saying "sin(x)
is a constant function" sounds pretty wrong.
--
Peter Eisentraut peter_e@gmx.net
Peter Eisentraut <peter_e@gmx.net> writes:
It could also be considered deterministic, strict, cacheable,
mathematically sensible, real, pleasant, or good. ;-)
Out of those, I believe "const" is the worst term, because saying "sin(x)
is a constant function" sounds pretty wrong.
Yeah, that was my problem with "const" too. But "deterministic" has the
same problem --- in the ordinary meaning of the term, a function doesn't
become nondeterministic just because it depends on SET TIMEZONE as well
as its explicit parameters. It's also too long and too hard to spell
correctly ;-).
"cacheable" (whatever spelling; I suppose we should consider accepting
both, cf analyze/analyse) is a fine term except that it isn't quite clear
whether to use it for case 1 or case 2, which means that people won't be
able to remember which case it applies to ... unless we come up with
some really memorable choice for the other case.
So far the only suggestion I've seen that really makes me happy is
"volatile" for case 3. Brad's idea of "invariant" for case 1 isn't
too bad, but as a partner for "cacheable" it seems a bit weak;
if you haven't looked at the manual lately, will you remember which
is which?
regards, tom lane
It occurs to me that we also need a better term for the overall concept.
"cacheability" has misled at least two people (that I can recall) into
thinking that we maintain some kind of function result cache --- which
is not true, and if it were true we'd need the term "cacheable" for
control parameters for the cache, which this categorization is not.
I am thinking that "mutability" might be a good starting point instead
of "cacheability". This leads immediately to what seems like a fairly
reasonable set of names:
pg_proc column: promutable or proismutable
case 1: "immutable"
case 2: "mutable", or perhaps "stable"
case 3: "volatile"
Thoughts?
regards, tom lane
Tom Lane wrote:
It occurs to me that we also need a better term for the overall concept.
"cacheability" has misled at least two people (that I can recall) into
thinking that we maintain some kind of function result cache --- which
is not true, and if it were true we'd need the term "cacheable" for
control parameters for the cache, which this categorization is not.I am thinking that "mutability" might be a good starting point instead
of "cacheability". This leads immediately to what seems like a fairly
reasonable set of names:pg_proc column: promutable or proismutable
case 1: "immutable"
case 2: "mutable", or perhaps "stable"
case 3: "volatile"
I like 1 and 3 :-)
I think 2 should be something like "stable." Mutable and volitile have very
similar meanings.
I'm not sure, the word stable is right, though. Cacheable has the best meaning,
but implies something that isn't. How about "persistent" or "fixed?"
Tom Lane writes:
Peter Eisentraut <peter_e@gmx.net> writes:
It could also be considered deterministic, strict, cacheable,
mathematically sensible, real, pleasant, or good. ;-)Out of those, I believe "const" is the worst term, because saying "sin(x)
is a constant function" sounds pretty wrong.Yeah, that was my problem with "const" too. But "deterministic" has the
same problem --- in the ordinary meaning of the term, a function doesn't
become nondeterministic just because it depends on SET TIMEZONE as well
as its explicit parameters. It's also too long and too hard to spell
correctly ;-).
As it turns out, Oracle, IBM, and Microsoft use it for exactly the same
purpose, and it is standard ...
If you're not happy with labelling case 2 nondeterministic, add an
additional clause, like USES EXTERNAL STATE. We could dig through all the
adjectives in the world, but I don't think any will catch the situation
quite like saying what's actually going on.
So far the only suggestion I've seen that really makes me happy is
"volatile" for case 3.
Volatile means "subject to rapid or unexpected change", which is not
really what case 3 is.
Brad's idea of "invariant" for case 1 isn't too bad, but as a partner
for "cacheable" it seems a bit weak; if you haven't looked at the
manual lately, will you remember which is which?
Actually, IBM has VARIANT as an alias for NOT DETERMINISTIC (and NOT
VARIANT for DETERMINISTIC).
--
Peter Eisentraut peter_e@gmx.net