Re: When IMMUTABLE is not. - Mailing list pgsql-hackers

From chap@anastigmatix.net
Subject Re: When IMMUTABLE is not.
Date
Msg-id 69234e25e34e68425f49630f79ef9991@anastigmatix.net
Whole thread Raw
In response to Re: When IMMUTABLE is not.  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: When IMMUTABLE is not.
Re: When IMMUTABLE is not.
Re: When IMMUTABLE is not.
List pgsql-hackers
On 2023-06-15 09:21, Tom Lane wrote:
> Yura Sokolov <y.sokolov@postgrespro.ru> writes:
>> not enough to be sure function doesn't manipulate data.
> 
> Of course not.  It is the user's responsibility to mark functions
> properly.

And also, isn't it the case that IMMUTABLE should mark a function,
not merely that "doesn't manipulate data", but whose return value
doesn't depend in any way on data (outside its own arguments)?

The practice among PLs of choosing an SPI readonly flag based on
the IMMUTABLE/STABLE/VOLATILE declaration seems to be a sort of
peculiar heuristic, not something inherent in what that declaration
means to the optimizer. (And also influences what snapshot the
function is looking at, and therefore what it can see, which has
also struck me more as a tacked-on effect than something inherent
in the declaration's meaning.)

Regards,
-Chap



pgsql-hackers by date:

Previous
From: Yura Sokolov
Date:
Subject: Re: When IMMUTABLE is not.
Next
From: Yura Sokolov
Date:
Subject: Re: When IMMUTABLE is not.