Обсуждение: Function Volatility Stable vs Immutable

Поиск
Список
Период
Сортировка

Function Volatility Stable vs Immutable

От
"Igal @ Lucee.org"
Дата:
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





Re: Function Volatility Stable vs Immutable

От
"David G. Johnston"
Дата:
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.

Re: Function Volatility Stable vs Immutable

От
"Igal @ Lucee.org"
Дата:
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> 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