Re: pg_config wrongly marked as not parallel safe?

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: laurenz(dot)albe(at)cybertec(dot)at
Cc: sfrost(at)snowman(dot)net, andres(at)anarazel(dot)de, mail(at)joeconway(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_config wrongly marked as not parallel safe?
Date: 2018-11-29 01:46:17
Message-ID: 20181129.104617.257378264.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Tue, 27 Nov 2018 06:33:42 +0100, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote in <8dcb0bb248e9aaef0f1ef0faa27ab583bfa5bb84(dot)camel(at)cybertec(dot)at>
> On Mon, 2018-11-26 at 19:51 -0500, Stephen Frost wrote:
> > If a function's results can change across minor or major versions, we
> > shouldn't be marking it as immutable because, by definition, it's not
> > immutable.
> >
> > We, today, have a baked in assumption that any function marked as
> > immutable will remain immutable across all major versions that we allow
> > indexes to be retained through, which is all of them since about 8.3 at
> > this point.
> >
> > We absolutely need a policy that if you decide to change the results of
> > some immutable function across a major version change, you need to
> > consider the results on indexes and possibly write into pg_upgrade
> > checks to try and detect any usage of that immutable function. I hope
> > we're in agreement there.
>
> It's hard to make a guarantee that a function will never change in the
> future. What if we fix some rounding or overflow problem in a floating
> point function?

+1.

Actually, some geometric comparisons are performed counting
tolerance margin, the validity of which is in doubt. Their
behavior has been changed in recent major version and still has a
room for improvement, and the functions are parallel-safe and
immutable. Immutablity is mentiond mainly in the light of
optimization in the documentation.

https://www.postgresql.org/docs/current/xfunc-volatility.html

> If we went that far, hardly any function could be IMMUTABLE.
>
> I think it is best to use IMMUTABLE whenever we don't expect it to
> change and it is a function useful for indexes, and if it happens to
> change nonetheless, write into the release notes that certain indexes
> have to be rebuilt after upgrade.
> Of course, there is no problem to mark pg_config as stable, because
> there is little chance it will be used in an index anyway.

Agreed. We have the following description in the documentation.

| A common error is to label a function IMMUTABLE when its results
| depend on a configuration parameter. For example, a function that
| manipulates timestamps might well have results that depend on the
| TimeZone setting. For safety, such functions should be labeled
| STABLE instead.

Still this isn't mentioning upgrades. We could add to this that
something like that immutablity is not guaranteed beyond
PostgreSQL versions, the results of immutable functions might
change for certain reasons including bug fixes, blah, blah..

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-11-29 02:00:11 Re: Add extension options to control TAP and isolation tests
Previous Message Michael Paquier 2018-11-29 01:33:18 Re: Handling of REGRESS_OPTS in MSVC for regression tests