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 1w68XR-003zPq-2o for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 14:51:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w68XO-00ACyk-29 for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 14:51:51 +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 1w68XO-00ACyb-0s for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 14:51:50 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w68XM-00000001KiC-3UwQ for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 14:51:49 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5a0ff30b240so2564310e87.0 for ; Fri, 27 Mar 2026 07:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774623107; cv=none; d=google.com; s=arc-20240605; b=ae82kO6ExtFJb1Rz7MyH5QQzL8qRzqpHNXz+mp0wreWsFbeyiOmvviC5QDePmOVL1g SDjkuhpgDlhkcAsSvyPRyaB/BDYyS8s26wZNjOcCTR9kz9BbK9cb8hQDUE4SriBvUSnl sNnz5A0JDs0x9GpkkfMB796jBgjtz52f3+66DvbOQSOiMSpiYZd2ms+7iTZtqL7PjbRm 1jX88wJ+0rrHOLAa5aUG4Ur9TDj+RH5r+ieOb04FzfNV5fcJ+vkNXfQgqbno2Tos1a2z vnOpLweaTj6p/e5W1Ww95Ifpdpf7T2QSl4THzUKIGv5jeYHJCP0mRW+H0eK1w8vaqP9K P+Xw== 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=IDtvZ+YM36cr/4xeizXKPjMj3IKrWqvvbhRfHwtfRlg=; fh=q0sr7fdifhyY9Mc/miEQin2IbKJ+AaToRrLnQOi4Wug=; b=C4+t52vUnKLHDAX/fhHVPJhnWyvcq2+tuiCPQP/nkrPiU2+QP9GHwmdd3m9+fzzrax Y8lkK7Reh4sAexqfFFYtf/4zM4eK+Y3RpGaPdlulPt889QC9uPXbypUBRKoo82+gZwSj sCdpfgWh4BP/e/7miT4YKnvVDjh/DGKbRsRETp1mIubLNFvuSiaLOYx8K+iLPahPLJ8p t7EWwxlUhllhdNzLQ0Geo0uuWJ4T5wZvCcET9+c0ubanLMGrnPUKsgFCU3wqTTOcndbf 6RZF/OIVQVxhGYX3J1k9FmMndm+x2WogDjYJE+4o2r8fnJoaNalKiXXc+qyuLLuF+O1L AN8w==; 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=1774623107; x=1775227907; 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=IDtvZ+YM36cr/4xeizXKPjMj3IKrWqvvbhRfHwtfRlg=; b=YuHzq0haul9ieho1eEdhB/nHE3dKCFA3nYPJmBc1kQM4d9NeMEq75rdFo+u2uXTfbg Xlg9w+/jJEhr+B0fsZ15nQzusHhw4nVOyy09an/Plxl/ZTwTWx+wVXo+au5DmuI5a8/U F0ESHDJY6xdsFtsWRXxJEJ1D6bSGAF48nOHucsNLsyB5hyrQOXnfe1EU1Ywt1tfAiN5Z b+c9+M/7R5tirqlKmeGs5uMWzPi3Here2hp+S9jjPM2IL6B0ahve69EbLbEm7nSQiA2e onLJ5C5RkxGahFcZvTTz+1OsRawLn1NLMZ8ue1AoZIgcFsBruxBmm8UPJGoLJAsS6Dkq ozqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774623107; x=1775227907; 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=IDtvZ+YM36cr/4xeizXKPjMj3IKrWqvvbhRfHwtfRlg=; b=GjnGSU4V3jXMyQD0+K7PVMGzR6LOPOQKgHyPl+O66CelQMOAbntMd1PQoHXC0/6cGU 8WGtk3Hw/N6h/LKuFDGOSDWx5PX17DGlyfJNY1mw47rGMeAuguNKgd9NJXYUbzPO+0nd yBzqi/Qpk7ZhJl4dgAeVXaL0JOWK10SOp41ubHJExyXWjsBmUWyXINsRtgwKbmvNKPeo O77E04flwmle5zeK87n38utFgKISxQAon8u76rMVLStJHF/N5tINk4o76y5g12KHL7Nn by7PqQ7mmyS/zFjdrP/A5KQrV9tUeQ3c0f96gh5Q/zevRcaawZ5Cl8+6pnHeHXo4cdMu /jcQ== X-Forwarded-Encrypted: i=1; AJvYcCUtvN6vQCj+aBh5VcMzQWH209b3u5eKe1gGhQUxDocWgaJDuNrHn/rkADIwlnlRYdvLhuW9tNreEEidOrIv@lists.postgresql.org X-Gm-Message-State: AOJu0YxgYmsJfaUl0PbS3K4c6/K/T8FaRknEZ+gOHexnNvfHpeNE9lmq qYT31dKt4vKhqzGMksx04T3sgO+ha+To87WcWf4kDQ1q+TW4TxC0bGyedxZs4thVtlwdaGYcs7X 8cVmED/ci+g2G4ehYURn156Gi//D5Gv8= X-Gm-Gg: ATEYQzx5ZH3TxBOUucpQRvGYunwdehN+xvrDRfzm6x31DAYU1eq8H5xUPllEm9zLcKI JN4nbwnfVsnxVH+qQiWJKcbhTtD1LikWb/myuTlql2Sm26lNNq7lxNvAkW1fes8qaHWIDLJa0ou R8HqJ6FAaJDnOzwzFxGZSLpPW+zjn79TZcfwGyH4R65hfukLldSqcOeTcEpEyP9pL3nFnNOw/BE NBvpy8JxYk75G0EirpLfYg4Vf1OvuZER2oWLZL+00aFNZlXTrfPIWKiTS92541hdGq0SjnzL/39 g+eJyA69vsqSH+GyVOj+pi9JdRaWyTXlQsNMU9BbNdfQj7D7BwOEwOF8LBD1RUdKjjuKHkmu2xo 0OjPE X-Received: by 2002:a05:6512:3d27:b0:5a2:851a:264a with SMTP id 2adb3069b0e04-5a2ab7f015bmr1277969e87.10.1774623106832; Fri, 27 Mar 2026 07:51:46 -0700 (PDT) MIME-Version: 1.0 References: <1010250.1774545419@sss.pgh.pa.us> In-Reply-To: <1010250.1774545419@sss.pgh.pa.us> From: Matthias van de Meent Date: Fri, 27 Mar 2026 15:51:35 +0100 X-Gm-Features: AQROBzA16GAwDBl4drIvoLdmsnKv_aQVDQbizvFSXzGC8nJZBSwJJ99QXbAvrSo Message-ID: Subject: Re: SQL-level pg_datum_image_equal To: Tom Lane Cc: David Rowley , 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 Thu, 26 Mar 2026 at 18:17, Tom Lane wrote: > > Matthias van de Meent writes: > > On Wed, 25 Mar 2026 at 22:51, David Rowley wrote: > >> 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. > > This seems to me to be a rather creative misinterpretation of what > STABLE and IMMUTABLE mean. If you want to claim that IMMUTABLE means > that, then the function isn't STABLE either, since it could give > different results for the "same" input values within one query. > Moreover, switching from IMMUTABLE to STABLE wouldn't fix the > problem of users assuming more than they should. Yeah, that's fair. > The actual problem here is that datum_image_eq is assuming more > than it should about the contents of a pass-by-value Datum. > That was okay for its original use-cases because a false not-equal > report would just end in not applying some optimization. But > Memoize thinks that the answers are exact, and users would too > if we expose the function at SQL level. > > I think what David proposed at > > is not a hack, but in fact correcting datum_image_eq/datum_image_hash > to not assume that unspecified bits are reliably the same. Agreed. Kind regards, Matthias van de Meent Databricks (https://www.databricks.com)