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 1qoryH-003FmF-Pk for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Oct 2023 21:02:53 +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 1qoryF-00C9Jz-If for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Oct 2023 21:02:52 +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.94.2) (envelope-from ) id 1qoryF-00C9JY-9I for pgsql-hackers@lists.postgresql.org; Fri, 06 Oct 2023 21:02:52 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qory8-000ely-Vd for pgsql-hackers@lists.postgresql.org; Fri, 06 Oct 2023 21:02:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=XPUFxsZLlwrW6C/CP6nyERbjlRAFUS4W49o5eU9vlNY=; b=HOGAt Q8hajq23W6dMlID5xIKP7uoLtSWt7Nwk+O1pX2VSuOS8vYHeMiZCYuOiDHtENCUMO9OdC7C5/N52b AaaEX6DU9IMIEuV6VOxuuD34DvMsH9+pq2g0G4FXd/c44Z5dfhGsPKWjRTI6PM2gyaNv/J3zwFykU InV5ruIRYO9tZVqiGIpEugzRyhWvr4LOQhCwm5kgiUb29k+NjEyS7PUvu/adJpO2e7LO/u05H+Zvl yJ5azd9j2Sqxd8chCMyPGyWEUkakiAg/uriOQutG+IgwRSinjdbXc1P0hnTXPra/gKcWIRRwIIA4p hmXtCI6fTsdJUgAYOvoLLhVr1ojLQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1qory7-006SWS-38; Fri, 06 Oct 2023 17:02:43 -0400 Date: Fri, 6 Oct 2023 17:02:43 -0400 From: Bruce Momjian To: Sergei Glukhov Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Problem, partition pruning for prepared statement with IS NULL clause. Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="+0k6zITfR7jNxDrn" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --+0k6zITfR7jNxDrn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Oct 6, 2023 at 05:00:54PM -0400, Bruce Momjian wrote: > On Fri, Oct 6, 2023 at 06:09:45PM +0400, Sergei Glukhov wrote: > > Test case: > > ------ > > set plan_cache_mode to force_generic_plan; > > prepare stmt AS select * from hp where a is null and b = $1; > > explain execute stmt('xxx'); > > ------ > > I can confirm the crash in git master. There were some UTF8 non-space whitespace characters in the email so attached is a clean reproducable SQL crash file. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you. --+0k6zITfR7jNxDrn Content-Type: application/sql Content-Disposition: attachment; filename="crash.sql" Content-Transfer-Encoding: quoted-printable create function part_hashint4_noop(value int4, seed int8)=0Areturns int8 as= $$=0Aselect value + seed;=0A$$ language sql strict immutable parallel safe= ;=0A=0Acreate operator class part_test_int4_ops for type int4 using hash as= =0Aoperator 1 =3D,=0Afunction 2 part_hashint4_noop(int4, int8);=0A=0Acreate= function part_hashtext_length(value text, seed int8)=0Areturns int8 as $$= =0Aselect length(coalesce(value, ''))::int8=0A$$ language sql strict immuta= ble parallel safe;=0A=0Acreate operator class part_test_text_ops for type t= ext using hash as=0Aoperator 1 =3D,=0Afunction 2 part_hashtext_length(text,= int8);=0A=0A=0Acreate table hp (a int, b text, c int)=0Apartition by hash = (a part_test_int4_ops, b part_test_text_ops);=0Acreate table hp0 partition = of hp for values with (modulus 4, remainder 0);=0Acreate table hp3 partitio= n of hp for values with (modulus 4, remainder 3);=0Acreate table hp1 partit= ion of hp for values with (modulus 4, remainder 1);=0Acreate table hp2 part= ition of hp for values with (modulus 4, remainder 2);=0A=0Ainsert into hp v= alues (null, null, 0);=0Ainsert into hp values (1, null, 1);=0Ainsert into = hp values (1, 'xxx', 2);=0Ainsert into hp values (null, 'xxx', 3);=0Ainsert= into hp values (2, 'xxx', 4);=0Ainsert into hp values (1, 'abcde', 5);=0A= =0Aset plan_cache_mode to force_generic_plan;=0Aprepare stmt AS select * fr= om hp where a is null and b =3D $1;=0Aexplain execute stmt('xxx');=0A=0A --+0k6zITfR7jNxDrn--