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.98.2) (envelope-from ) id 1xKANm-00000000gwW-2hBT for pgsql-bugs@arkaria.postgresql.org; Fri, 23 Oct 2026 08:12:11 +0000 Received: from localhost ([127.0.0.1]:35978 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xKANm-0000000F6ms-0mpJ for pgsql-bugs@arkaria.postgresql.org; Fri, 23 Oct 2026 08:12:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xJtOr-0000000C7Kp-2IuT for pgsql-bugs@lists.postgresql.org; Thu, 22 Oct 2026 14:04:09 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xJtOo-00000000QJg-49ve for pgsql-bugs@lists.postgresql.org; Thu, 22 Oct 2026 14:04:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=GXLvd3GnEllV9dmaPGMHSqTxKuJYpTAk2JNDmUEmxGU=; b=0EFoqZ98l2S/+sqsxyc6iH/2uD DSwhwj2UxryJrL1Rkou1TA/l6cPcpgszLUW1VOQCt5WHZ5JST2Qw2PVXksxvbu4aApl5EuOA4xxQX I43LT12E4QrZBP+g3jJbVrKInpKDsc4UAEi4HPdKcdaryVjssR5q/Dm+w71bTuvIbssPiqh+DgFA6 0c2gD8qW3V7IsUPwHGqivzSqsgbbd5rPE9073++ZBGxqsr6dT2JgVkJkkrg7DalwoCGZOZvja62qo KgQr7H1FPP0T36BPvvaMsprh2xJhgS4gqgT4hwM+rvIOmZFhVqAooYLPj05cOXa0GEUGZDKpWt9Hn dSIzDKQw==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xJtOn-000000016As-1p17 for pgsql-bugs@lists.postgresql.org; Thu, 22 Oct 2026 14:04:05 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xJtOm-0000000356u-0AcZ for pgsql-bugs@lists.postgresql.org; Thu, 22 Oct 2026 14:04:04 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19789: "expression not found in statistics object" for a boolean domain column in an MCV statistics object To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: alpkeles99@gmail.com Reply-To: alpkeles99@gmail.com, pgsql-bugs@lists.postgresql.org Date: Thu, 22 Oct 2026 14:03:45 +0000 Message-ID: <19789-b6592eeba8c6f6e1@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19789 Logged by: Alperen Keles Email address: alpkeles99@gmail.com PostgreSQL version: 18.6 Operating system: macOS 26.7 arm64 Description: =20 Hello, If a column whose type is a domain over boolean is part of an MCV extended statistics object, a query that uses that column as a boolean condition together with another clause on the object's columns fails in the planner with an internal error: CREATE DOMAIN db AS bool; CREATE TABLE t (a int8, b db); INSERT INTO t VALUES (1, true); CREATE STATISTICS t_s (mcv) ON a, b FROM t; ANALYZE t; SELECT * FROM t WHERE a =3D 1 AND b; ERROR: expression not found in statistics object The same error occurs with NOT b, b =3D true, b =3D false, b <> false, b::bool, a =3D 1 OR b, for EXPLAIN and DELETE, with two columns of the domain (WHERE b1 AND b2), with a domain over that domain, and with statistics created without a kind list (so including mcv). It does not occur with a plain boolean column, with a domain over int4 or text compared to a constant, with b IS TRUE or b IS NULL, with only ndistinct or dependencies statistics, or before ANALYZE. Reproduced on 18.6 (REL_18_STABLE a85b5523e67) and master 158b6d5109f, both with --enable-cassert, on macOS arm64. 13.23 fails on the same statements with "ERROR: unknown clause type: 125" (T_RelabelType). The message changed with e33ae53ddec (the 14.5 fix for MCV statistics on boolean expressions), but the failure remains. As far as I can tell, the domain column used as a boolean is a RelabelType over the Var. statext_is_compatible_clause_internal() strips the RelabelType and accepts the clause as a plain column reference, but mcv_get_match_bitmap() gets the unstripped clause. That clause is not a Var, so it goes to the bare boolean expression branch, and mcv_match_expression() does not find it among the statistics object's expressions. Found with a query fuzzer. Regards, Alperen Keles