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 1vkvZR-004WC4-0s for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Jan 2026 02:46:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vkvZO-00GiZO-2m for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Jan 2026 02:46:15 +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 1vkvZO-00GiZG-0X for pgsql-hackers@lists.postgresql.org; Wed, 28 Jan 2026 02:46:14 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vkvZL-002fMy-1e for pgsql-hackers@lists.postgresql.org; Wed, 28 Jan 2026 02:46:13 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 009F4140015A; Tue, 27 Jan 2026 21:46:11 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Tue, 27 Jan 2026 21:46:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1769568370; x=1769654770; bh=YgaqIhSpvW ydjPIKHHBpO8oNVFctkDt8hiMdxmn7gZo=; b=CPwMAeYdHyBYCPfWAJfDCj7L3A +M3uh7BMyjOcSjN2sVMhhZAJfdazu1HRVRRNR5VQ/L8MHOQuK9g5lcEFDDiwELyz zUdyEnYrLggWWGJ3xaU6tFTm2R/llH2fEF+05UFc+eKOHsAX/vCy3aM1yWp/6HSE NmT4UwedvRinSEt201bs04T69xPWm+S4Fjv4XGYiGGK1WKjKkRvaeoMXYgQB+Nyz Y4xdBVTQ8IgQ8+NvCnbdlIeJ/hxcXXySPeBQY+Qr3thtY41cnXmMS7etrEYcP3vT VrTvWFuULMbioXP89VB2iATuIME4iG2oXEmwSiZRpj2rAXHneZOjEqTEp3HQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1769568370; x=1769654770; bh=YgaqIhSpvWydjPIKHHBpO8oNVFctkDt8hiM dxmn7gZo=; b=KvBIbJ1Zm1WKnOekXEo9GeyRMTtKzmwZvysxNvnHwejUOSK6dr5 /zy+cz+JTb3V1Sguh1t7tT1tRUO7YwvgNYTeywIlRQXnzNaAFvq4qlgp+pckKfuI sbGp3VMmRCirolCoF6hv51mJRGcC4qDIZsFlsH+MOmAh+JHhefCb+xmLyTYOsetk LFcbzOOE5I8yUe53RMOOdj1745yFgMM1laKWlkOJklv03TE0l7dJNiMbjTgdQBJl LqmPXVG9p4bplGQtN1nEH7RS1V5zr0Tvu/s/CmsgTpm37AjOVASum7svK0e9MPIM 4hdPZdLu/DCZubjUCVRtGwLLegbzg7etK2g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduiedvvdduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheptghorh gvhidrhhhuihhnkhgvrhesghhmrghilhdrtghomhdprhgtphhtthhopehlihdrvghvrghn rdgthhgrohesghhmrghilhdrtghomhdprhgtphhtthhopehtnhgurhifrghnghesghhmrg hilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhp ohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 27 Jan 2026 21:46:08 -0500 (EST) Date: Wed, 28 Jan 2026 11:46:04 +0900 From: Michael Paquier To: Corey Huinker Cc: Chao Li , Tender Wang , PostgreSQL Hackers Subject: Re: Extended Statistics set/restore/clear functions. Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bmP2HWKQkVU8cMBv" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --bmP2HWKQkVU8cMBv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 28, 2026 at 08:51:54AM +0900, Michael Paquier wrote: > On Tue, Jan 27, 2026 at 11:14:12AM -0500, Corey Huinker wrote: > >> 0001 - adds a test left out of dependencies >=20 > Applied this one now, you are right that it should have been added in > 302879bd68d1, so my mistake I guess. This code in v32-0002 has given me a pause, because we define numexprs and use it down the road for some input validation: + /* decode expression (if any) */ + exprdatum =3D SysCacheGetAttr(STATEXTOID, + tup, + Anum_pg_statistic_ext_stxexprs, + &isnull); + + if (!isnull) + { [...] + } + numexprs =3D list_length(exprs); Actually, I think that the patch split has been done incorrectly because missing this code on HEAD also means that we do not perform a=20 correct validation of ndistinct and dependencies data when any of these include expressions, because we are missing the negative attribute numbers, numexprs remaining at 0 all the time. This can be easily demonstrated with a statext object like that; CREATE STATISTICS stats_obj (dependencies) ON lower(name), upper(name) FROM tab_obj; The restore function would reject input like that, but it should be valid: [{"attributes": [-1], "dependency": -2, "degree": 1.000000}, {"attributes": [-2], "dependency": -1, "degree": 1.000000}] I'll go fix that now with some tests to cover things, after extracting the relevant portion of the code from v32-0002. -- Michael --bmP2HWKQkVU8cMBv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAml5eGwACgkQnvQgOdby QH0F1A//bs4T3SCjupQhQEgs1CQmbTTjlwJjnerwxaXGrT6cG4HkPmFyECGCASvs T+bb2DTTnUtKLpVSYSjE3sHp9cCILvYQ6Ls0ADmGmK8t3yutCiOShwtzU77WCXMt yHAaput1QlwGBZLHxWj1B17PH7L13RXowbbVk6TfGbTTzgHutoI1PuE/MBN6wWUy KdXJ9g9LUwuiCJSyDxp/N5/rKt1jEOqKVBzijFhzoVC3VqxGEv35cqA6MbJl9ewR J+snChDsg/nDV1C2jOP7PPRLGsl1o89UUipyTt92kfnKzF0GmfXncCjOEy+EBge4 POGrXaoLjQaNohmCTqv4sBsFQ1+3wys73xZ50HF6ElbCZaczzeOH45rrprsuDtzx FokALe/S8Ni0rUf0bfRBE+1WQZFV4JbS5z8t/oXcYzmHrGuYAVtvEj0D/rL8YDPX aJiCYjqcltiLGOGQ8eC7cgfzMEDl0pA+tay84fxwGS+g7JMjYO8x0EH7IHSYHX/L KaB//Y7dvaff/RXUSRmr239fLkjlg/zDzPs2EQBuNIE8SGv8fULQ1b6dcCYzWe28 C2RSgf6U4CArg/rKbcd8+XrHtjlRMXpD48+KGXLYlEvZHljmWwtduZufegdtyo5l xeY7aFffTe+P8v8n9DI//WiAow0uiY1VmAhd6BM7N4PresDI7QQ= =GaaU -----END PGP SIGNATURE----- --bmP2HWKQkVU8cMBv--