Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w5Wvb-003LJQ-1G for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 22:42:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5WvZ-00HBFI-34 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 22:42:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w5WvZ-00HBF9-26 for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 22:42:18 +0000 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w5WvY-000000012jJ-1Km2 for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 22:42:17 +0000 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-38bd3c6c502so2479351fa.1 for ; Wed, 25 Mar 2026 15:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774478535; cv=none; d=google.com; s=arc-20240605; b=GBqkUG+vEncq6kU2U80uOejgopT6sqStb9/giOMV+Otx3Ev3qq1RgAdBUsGIZYngqG g98ZfjoijiNp/F1E+bsIpktmYCNGG8d88aXeOwjZaizynceCQczMCVaFv505Ot0vXIaF vlry0TjAplIXquMkBshDhpELDlM+GOIjf5mPvOsczD8Zu8d4f5u8EOUEdlNENFSl30y8 GINW3Ias0XaFr81et0NainyhCJ+1QifsV/+oNIH0AD0wQlVo7zv2ApdEpcFHMw9MHRCZ GyKSGYEe0w2Ci9uAV+1Y5KJxq2eAJPVOdiieC0IXH3A5y9zw037dP8uaJ7qbWl7o8nMJ KePQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=jzsVPkBHcdoyBXN7L3JMJ8tWtrwylD5ldxaCDh2g7bs=; fh=PEQb/wcjey4WTCcLSyl6l/VBMH8ne1PS4GpBnGEIlcc=; b=IZpA1EhM0XpPanaDTzOh8Bmh/Te3GPzBofcBFHHTDH5cWW8VOtdkJK27k1CHjvtSmX p0Fj5Bz2P4lz1MPj26mIi8A0vT1qPu/A1val17k+s/XhTPXYiGMFLSCFXx93T0v3TkzL pgVCZKmSzq9GmKEh6ZjVBvaDjHsWeU3A+eZmqUpG/XSEPsfSKomIWKTxFoQ8Oj8HxsFW ZXHRHgCM6gtan7PAwoTlZxY/GHUi8Pb3ZcwTTuiQdZ7uC91swLMkUNKLtM2UpjeRuchD inJq2ESYy7emMiKXRXPhXbUwg+6rnduW1xtdu6FapfyR3upsxsNfCEo/9kRhpcHTInbF r/8A==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774478535; x=1775083335; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jzsVPkBHcdoyBXN7L3JMJ8tWtrwylD5ldxaCDh2g7bs=; b=MsYIHyo15QXMQaJzKj8kUPt1XfPYmMc2Ivuzph8Rd43JbN6kI4fjraw41ecbNt1KQk RtHazZNR5gcu0vapTe/3KTlm+PYxQ9zxNDvv6PD3yVtOIZs8cHy0MQClpBTOJwBUXOVH uVShETI7HieeFpmFgqnwoNF1wJAgyU7oELigg2ann5ZOz2vSm06z/NNgLXgJ3VI6mAUm wzuyYG7dp65Q8FiWJDDlV0uxcNmi8NIfgy35H4S835q+Oa6t1FEAN5dnG8yNnNqK3VwV ViW4o1rGSu9O2JP1Cic9bx/OZTAk5E+KFKt8begcpsjDcPeHsR0ACeUaopgrRPJ2Vl18 sqgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774478535; x=1775083335; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jzsVPkBHcdoyBXN7L3JMJ8tWtrwylD5ldxaCDh2g7bs=; b=B4uaP+7X/g/gZ5tvfP8wv445JPMHsATnW204xfkn/ZVHXa/q6LetT3N13CYgC6YKdC LwY6dhdKSY3R3SA62enN5s0qEiiyQQF2xhMerT8JGlLuofn15UFlGXlz4WFJ3bMkHFNY 1hAsNZERn3GzSmRLDSR60iiJRyvRcDyBeR3jT+eC8htPjYK6zh1wLDUOjheIp7D7L6rR sLH5UBl4fkGYR5/HXrlRWKvUpIjyqq+SfUsZ16BAxBLLn/I7B/mJw7talXGfPk80RjYy v/7oeRtSdViF3XhDiz7b7KeB1cEjP4cJpmYI2u7ax2djLr6GnwVxtHVZFMO1PoWXPr+w 9OpQ== X-Forwarded-Encrypted: i=1; AJvYcCURxZHSGb3NF16r4wi1PHBoQVkaKRI19KlJyvS9Ts7Mt0wBqLaKOshsy9GcbZgX+nzoP8z1WG6N66WCEt8y@lists.postgresql.org X-Gm-Message-State: AOJu0YzTyTk1OPvH+v+9WCSRaWgZZb8PRTqYgocQXMZKVQv560niFz2d +/J3MNt6RoopWuJFu/lj7XgjlClRo9twMyww89UC5RuaU+d5fp+pgn8/2lELx6KrUajGVvvxH3X YssXnCC/tnYt1YDxHSoVWisWaT5br1a0= X-Gm-Gg: ATEYQzwjoHU+tPZMNK0zFQyBa+cyqppjYJwcVxUltajqbOA6FGwfe1UtrIbFfmbCjVS zTZbqqzWTe8JhkCnfYPMeuuRk9fGIs6LRQuXrTU5IFQFtKexwky9Sm0hlvbLXbpFxqCuyAWsB/J jMgN/TA6qmMOzWAydQJD6rm69btoZFaENQiprDQHc6PtgyqcQCX6g1FVPuOR+5TokCtif4UKiwI 7BjAOamg0uFlaUkjyxIv8f0MiTsxZgDz5nYcGVd7Mg7D+XgkIXBgFWwnkctaLVuWEXGMu9WZ8iy cFwjxkLrIFdjcyGafnjqFPeHzuSIM7dftii7eHWNX0KwoOFo3ixtkaUHJl29gLXbKNITgeJosbQ mqK1/ X-Received: by 2002:a05:651c:4382:10b0:38b:fb66:5797 with SMTP id 38308e7fff4ca-38c4302c717mr14611581fa.12.1774478533977; Wed, 25 Mar 2026 15:42:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Matthias van de Meent Date: Wed, 25 Mar 2026 23:42:01 +0100 X-Gm-Features: AQROBzBcN4rzmYZjDMBHeUHpRjvTIa-vQNCgGlr-EvG7Xz0lCTn4_C1OdrXBztk Message-ID: Subject: Re: SQL-level pg_datum_image_equal To: David Rowley Cc: jian he , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 25 Mar 2026 at 22:51, David Rowley wrote: > > On Thu, 26 Mar 2026 at 10:25, Matthias van de Meent > wrote: > > I'm happy to mark this function as STABLE for now (to prevent its > > inclusion in permanent storage), and/or to adjust the code to adjust > > for subnormal inputs (values with incorrect/inconsistent/unexpected > > sign extensions). > > You lost me at this part. How does marking the function as STABLE > prevent users from persisting things on disk based on the return value > of the function? I expected the primary use case for this would be in > trigger functions that make decisions about data that goes into > tables. Indexes and stored generated columns' expression may only contain IMMUTABLE functions, so that they don't change output when the inputs values are unchanged. As the current datum_image_equal depends on the volatile contents/definition of sign-extended bytes (which we clearly don't have a defined/expected value for) that makes the output of this function not immutable for the "same" input values. Marking it as STABLE would therefore prevent its values from being stored inside PostgreSQL's definitions and storing the wrong value (or making a decision based on the wrong value, in case of partial indexes). That wouldn't solve the issue when used in a trigger function, indeed; which is why the second part shows that pg_datum_image_equal could itself check and adjust byval types to have consistent sign-extended bytes before passing them on to datum_image_equal, so that it won't be sensitive to the issue discussed in the memoization thread. Kind regards, Matthias van de Meent