From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Bryn Llewellyn <bryn@yugabyte.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Christophe Pettus <xof@thebuild.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: User's responsibility when using a chain of "immutable" functions?
Date: Wed, 29 Jun 2022 01:46:02 -0400
Message-ID: <2987095.1656481562@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFj8pRCgAGvRGSNFX2FeSrVfi+DQ5rc+MebTLCuydhyuecMJLw@mail.gmail.com>
References: <38FB5DA3-5940-43A9-8B09-5C856E2B18C4@yugabyte.com>
<80C40450-6C0C-46E2-AE82-E7D46120F7FF@thebuild.com>
<CAKFQuwbSo0z9aAq-Jok+aHoJvs+FhqTwHzz0Zu0ECTMAd=1NSQ@mail.gmail.com>
<F0219B86-511C-45DC-8C85-C7B8A1AE96D7@yugabyte.com>
<CAFj8pRCgAGvRGSNFX2FeSrVfi+DQ5rc+MebTLCuydhyuecMJLw@mail.gmail.com>
Pavel Stehule <pavel.stehule@gmail.com> writes:
> st 29. 6. 2022 v 6:28 odesÃlatel Bryn Llewellyn <bryn@yugabyte.com> napsal:
>> Moreover, this "hermetic" property of a to-be-immutable function can be
>> established only by human analysis of the function's source code.
> Our immutable functions are more tolerant than they should be - for real
> immutable functions we should disallow SQL inside functions (and everything
> that is not immutable (plpgsql_check raises warning in this case)), but it
> is allowed.
It's generally believed that Turing's proof of the undecidability of
the halting problem [1] implies that it's impossible to mechanically
prove or refute function properties like immutability. Admittedly,
Turing was concerned with the most general case --- that is, he showed
that *there exist* cases for which no algorithm can give the right
answer, not that any specific practical case can't be proven.
Still, that result has discouraged most people from spending much
time on mechanically checking such things. If you declare a function
immutable, Postgres will believe you; the consequences if you lied
are on your own head.
regards, tom lane
[1] https://en.wikipedia.org/wiki/Halting_problem
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, pavel.stehule@gmail.com, bryn@yugabyte.com, david.g.johnston@gmail.com, xof@thebuild.com
Subject: Re: User's responsibility when using a chain of "immutable" functions?
In-Reply-To: <2987095.1656481562@sss.pgh.pa.us>
References: <38FB5DA3-5940-43A9-8B09-5C856E2B18C4@yugabyte.com> <80C40450-6C0C-46E2-AE82-E7D46120F7FF@thebuild.com> <CAKFQuwbSo0z9aAq-Jok+aHoJvs+FhqTwHzz0Zu0ECTMAd=1NSQ@mail.gmail.com> <F0219B86-511C-45DC-8C85-C7B8A1AE96D7@yugabyte.com> <CAFj8pRCgAGvRGSNFX2FeSrVfi+DQ5rc+MebTLCuydhyuecMJLw@mail.gmail.com> <2987095.1656481562@sss.pgh.pa.us>
* 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