pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedFunction Volatility Stable vs Immutable
3+ messages / 2 participants
[nested] [flat]
* Function Volatility Stable vs Immutable
@ 2019-06-25 02:31 Igal @ Lucee.org <igal@lucee.org>
2019-06-25 02:38 ` Re: Function Volatility Stable vs Immutable David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Igal @ Lucee.org @ 2019-06-25 02:31 UTC (permalink / raw)
To: pgsql-general
If a function select data from a table, and the rows in the table may
change, would that function qualify for Immutable or does it have to be
Stable? I'm asking because according to the docs [1]: "An IMMUTABLE
function cannot modify the database and is guaranteed to return the same
results given the same arguments forever".
So for the same arguments, the result would change only if the data in
the table changes. Does that mean that it violates the "forever" clause
and therefore can be only marked as Stable and not Immutable?
Thanks,
Igal
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Function Volatility Stable vs Immutable
2019-06-25 02:31 Function Volatility Stable vs Immutable Igal @ Lucee.org <igal@lucee.org>
@ 2019-06-25 02:38 ` David G. Johnston <david.g.johnston@gmail.com>
2019-06-25 02:54 ` Re: Function Volatility Stable vs Immutable Igal @ Lucee.org <igal@lucee.org>
0 siblings, 1 reply; 3+ messages in thread
From: David G. Johnston @ 2019-06-25 02:38 UTC (permalink / raw)
To: Igal @ Lucee.org <igal@lucee.org>; +Cc: pgsql-general
On Mon, Jun 24, 2019 at 7:31 PM Igal @ Lucee.org <igal@lucee.org> wrote:
> If a function select data from a table, and the rows in the table may
> change, would that function qualify for Immutable or does it have to be
> Stable? I'm asking because according to the docs [1]: "An IMMUTABLE
> function cannot modify the database and is guaranteed to return the same
> results given the same arguments forever".
>
> So for the same arguments, the result would change only if the data in
> the table changes. Does that mean that it violates the "forever" clause
> and therefore can be only marked as Stable and not Immutable?
>
Yes
Forever means beyond the lifetime of a single transaction and thus it is
possible for the changing of the table contents to impact the return value
of the function.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Function Volatility Stable vs Immutable
2019-06-25 02:31 Function Volatility Stable vs Immutable Igal @ Lucee.org <igal@lucee.org>
2019-06-25 02:38 ` Re: Function Volatility Stable vs Immutable David G. Johnston <david.g.johnston@gmail.com>
@ 2019-06-25 02:54 ` Igal @ Lucee.org <igal@lucee.org>
0 siblings, 0 replies; 3+ messages in thread
From: Igal @ Lucee.org @ 2019-06-25 02:54 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-general
On 6/24/2019 7:38 PM, David G. Johnston wrote:
> On Mon, Jun 24, 2019 at 7:31 PM Igal @ Lucee.org <igal@lucee.org
> <mailto:igal@lucee.org>> wrote:
>
> If a function select data from a table, and the rows in the table may
> change, would that function qualify for Immutable or does it have
> to be
> Stable? I'm asking because according to the docs [1]: "An IMMUTABLE
> function cannot modify the database and is guaranteed to return
> the same
> results given the same arguments forever".
>
> So for the same arguments, the result would change only if the
> data in
> the table changes. Does that mean that it violates the "forever"
> clause
> and therefore can be only marked as Stable and not Immutable?
>
>
> Yes
>
> Forever means beyond the lifetime of a single transaction and thus it
> is possible for the changing of the table contents to impact the
> return value of the function.
Thanks for clarifying, David.
Igal
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2019-06-25 02:54 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 02:31 Function Volatility Stable vs Immutable Igal @ Lucee.org <igal@lucee.org>
2019-06-25 02:38 ` David G. Johnston <david.g.johnston@gmail.com>
2019-06-25 02:54 ` Igal @ Lucee.org <igal@lucee.org>
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