Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9oNa-0000ec-Sm for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 14:55:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9oNZ-0006s9-Bm for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 14:55:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9oNZ-0006s0-0U for pgsql-hackers@lists.postgresql.org; Thu, 15 Jun 2023 14:55:17 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q9oNW-002YCx-FT for pgsql-hackers@lists.postgresql.org; Thu, 15 Jun 2023 14:55:16 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4f76a0a19d4so2609408e87.2 for ; Thu, 15 Jun 2023 07:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686840913; x=1689432913; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3B+mwq73n4JeP5YexbCLyu2nG7rZRMmp+225rg7vD5U=; b=Ak2e+rXmYg/2uMOHaudWA6TdOBLLzQ+pKK/skpa5qy0jWeMykpB902YEfh5+uUWN+K q1dl3N0QmONt3CIpv/FwUNDc3zwWIrJ9oEbSowxvyb6CAsDp2F2CiXNr6BnAmc7np8if Sq+vyUxm7qD9f7B/hzSNGlrW9+mwIXAUwLcFU17iLlwjEujzcitemVWHeRtTbL6GnN3i axREqbWBF/hxndmnC7H2xhPqmKcIrhNQ8qii9HwSd4GFDiUTbZQTsLVr+e/B4CgV65sg HFcPK7uxUqcxONsAi83LFqsgV9zz61Y7ian/Fa0RbtGQkWW1TfGRc88IQkrylP6FFTT4 cd0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686840913; x=1689432913; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3B+mwq73n4JeP5YexbCLyu2nG7rZRMmp+225rg7vD5U=; b=ldlxzpiKhDo3IcVAtEYotkuA8v0cjrqfZ7HG6xmmRzacHi9NDXiIhVaT0MK05g1Cau Qi27AVDVjoyhtbQ1B2cPWLp4kYmI8KZi0wuFdj2EGNt5KqHHemLGP4cAN5IiFGoTkMv6 j3usAxKCHnH6MYnxjozUHYW7SF+KU93HFzjl8SvM2hiW4STMsi061PVkMykfEVJdFkDu qDfWYtLrUr0+3CoxyC1MHcSRr7UOdR4dvD7mDVzI6Usp+xTxfbMjwXExxeZavbbK65LH ztmdtzch+VTI0H4tQU5TA+X2tIBoMPQp2Ue1tzdhV0SWbygYg2mDGOV3zfOo5725QBoX VhVw== X-Gm-Message-State: AC+VfDzlitZDzMt+WoytPv2iPnfq1ksbtR7t9rgp7J8kbtQt0acpV22D wXDNIm30ZIqifpz8GEg8s6Ybz+BuNGxrE6Xbbqg= X-Google-Smtp-Source: ACHHUZ7ix1w2yht+5zrnvkqO6ydXy7bhM2GverTUq3MwLB2Fx90FCvnoC2nJRD7n46k6Qdk09eYPSfP4ITbFNy6Scrc= X-Received: by 2002:a19:6912:0:b0:4f8:46e9:9f19 with SMTP id e18-20020a196912000000b004f846e99f19mr963725lfc.1.1686840913038; Thu, 15 Jun 2023 07:55:13 -0700 (PDT) MIME-Version: 1.0 References: <389c986d-fbb4-c644-9280-db7836af7ca9@postgrespro.ru> <2111925.1686835298@sss.pgh.pa.us> <69234e25e34e68425f49630f79ef9991@anastigmatix.net> <4c32f84bc097dee0081e4cc3e733ef8d@anastigmatix.net> <2131668.1686840541@sss.pgh.pa.us> In-Reply-To: <2131668.1686840541@sss.pgh.pa.us> From: Isaac Morland Date: Thu, 15 Jun 2023 10:55:01 -0400 Message-ID: Subject: Re: When IMMUTABLE is not. To: Tom Lane Cc: "David G. Johnston" , "chap@anastigmatix.net" , Yura Sokolov , "pgsql-hackers@lists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000006a119f05fe2c4181" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006a119f05fe2c4181 Content-Type: text/plain; charset="UTF-8" On Thu, 15 Jun 2023 at 10:49, Tom Lane wrote: In particular, we've never enforced that an immutable function can't > call non-immutable functions. While that would seem like a good idea > in the abstract, we've intentionally not tried to do it. (I'm pretty > sure there is more than one round of previous discussions of the point > in the archives, although locating relevant threads seems hard.) > One reason not to is that polymorphic functions have to be marked > with worst-case volatility labels. There are plenty of examples of > functions that are stable for some input types and immutable for > others (array_to_string, for instance); but the marking system can't > represent that so we have to label them stable. Enforcing that a > user-defined immutable function can't use such a function might > just break things for no gain. > More sophisticated type systems (which I am *not* volunteering to graft onto Postgres) can handle some of this, but even Haskell has unsafePerformIO. The current policy is both wise and practical. --0000000000006a119f05fe2c4181 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, 15 Jun 2023 at 10:49, Tom Lane &l= t;tgl@sss.pgh.pa.us> wrote:
=

In particular, we've never enforced that an immutable function can'= t
call non-immutable functions.=C2=A0 While that would seem like a good idea<= br> in the abstract, we've intentionally not tried to do it.=C2=A0 (I'm= pretty
sure there is more than one round of previous discussions of the point
in the archives, although locating relevant threads seems hard.)
One reason not to is that polymorphic functions have to be marked
with worst-case volatility labels.=C2=A0 There are plenty of examples of functions that are stable for some input types and immutable for
others (array_to_string, for instance); but the marking system can't represent that so we have to label them stable.=C2=A0 Enforcing that a
user-defined immutable function can't use such a function might
just break things for no gain.

More sop= histicated type systems (which I am *not* volunteering to graft onto Postgr= es) can handle some of this, but even Haskell has unsafePerformIO. The curr= ent policy is both wise and practical.
--0000000000006a119f05fe2c4181--