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.94.2) (envelope-from ) id 1raeb8-00Aon3-Di for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Feb 2024 16:28:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1raeb5-00EInP-Uy for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Feb 2024 16:28:27 +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.94.2) (envelope-from ) id 1raeb5-00EInH-MO for pgsql-bugs@lists.postgresql.org; Thu, 15 Feb 2024 16:28:27 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raeb3-006uFx-5E for pgsql-bugs@lists.postgresql.org; Thu, 15 Feb 2024 16:28:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 41FGSNF33263262; Thu, 15 Feb 2024 11:28:23 -0500 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org, David Rowley Subject: Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy In-reply-to: <18344-8d3f00bada6d09c6@postgresql.org> References: <18344-8d3f00bada6d09c6@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 15 Feb 2024 09:00:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3263260.1708014503.1@sss.pgh.pa.us> Date: Thu, 15 Feb 2024 11:28:23 -0500 Message-ID: <3263261.1708014503@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > The following query: > CREATE TABLE t (b bool, i int) PARTITION BY RANGE (b, i); > CREATE TABLE tp PARTITION OF t FOR VALUES FROM (false, 0) TO (false, 1); > SELECT * FROM t WHERE b IS NOT true; > fails with ERROR: invalid strategy number 0. > Reproduced on REL_12_STABLE .. master. > The first bad commit for this anomaly is e0693faf7. What seems to be happening is that gen_prune_step_op is getting op_is_ne = true and doing this: /* * For clauses that contain an <> operator, set opstrategy to * InvalidStrategy to signal get_matching_list_bounds to do the right * thing. */ opstep->opstrategy = op_is_ne ? InvalidStrategy : opstrategy; but then we're failing in get_matching_range_bounds, ie somebody taught get_matching_list_bounds to do the right thing but not any of the other code paths. I'm also wondering how we got there in the first place. It looks like match_boolean_partition_clause thinks it can translate "b IS NOT true" to "b <> true", which is flat wrong --- it gives the wrong result for null. regards, tom lane