From: Gaetano Mendola <mendola@bigfoot.com>
To: Bruno Wolff III <bruno@wolff.to>
Subject: Re: Mislabeled timestamp functions (was Re: [SQL] [NOVICE] date_trunc'd
Date: Sun, 03 Oct 2004 13:18:27 +0200
Message-ID: <415FE003.9000501@bigfoot.com> (raw)
In-Reply-To: <20041003011641.GB19221@wolff.to>
References: <web-1583353@davinci.ethosmedia.com>
<Pine.GSO.4.10.10409271910480.22691-100000@solarwind>
<20041001182830.GA20624@wolff.to>
<13492.1096656574@sss.pgh.pa.us>
<15677.1096671183@sss.pgh.pa.us>
<415E6A15.1090105@bigfoot.com>
<20041002200451.GA14830@wolff.to>
<20041003011641.GB19221@wolff.to>
Bruno Wolff III wrote:
> On Sat, Oct 02, 2004 at 15:04:51 -0500,
> Bruno Wolff III <bruno@wolff.to> wrote:
>
>>On Sat, Oct 02, 2004 at 10:43:01 +0200,
>>
>>There has been such a distinction for a major release or two. "Stable"
>>is how you mark a function that will return the same value within a
>>single transaction.
>
>
> I should have said within a single statement instead of within a single
> transaction.
I know that but a stable function is not called once inside the same query,
instead an immutable is:
sp_immutable() is a simple immutable function
sp_stable() is a simple stable function
sp_foo() is a simple function
test is a table with two rows in it.
regression=# select sp_stable(), sp_immutable(), sp_foo() from test;
NOTICE: sp_immutable called
NOTICE: sp_stable called
NOTICE: sp_foo called
NOTICE: sp_stable called
NOTICE: sp_foo called
sp_stable | sp_immutable | sp_foo
-----------+--------------+--------
0 | 0 | 0
0 | 0 | 0
(2 rows)
so now do you see what do I mean ?
The stable function is threated "stable" only if inserted inside a filter:
regression=# select * from test where sp_stable() = 3;
NOTICE: sp_stable called
a
---
(0 rows)
and from this point of view immutable is not immutable enough:
regression=# select sp_immutable() from test where sp_immutable() = 3;
NOTICE: sp_immutable called
NOTICE: sp_immutable called
sp_immutable
--------------
(0 rows)
Regards
Gaetano Mendola
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mendola@bigfoot.com, bruno@wolff.to
Subject: Re: Mislabeled timestamp functions (was Re: [SQL] [NOVICE] date_trunc'd
In-Reply-To: <415FE003.9000501@bigfoot.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox