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 1vArpD-006jTE-Da for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Oct 2025 15:29:31 +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 1vArpA-001zrp-Dl for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Oct 2025 15:29: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 1vArp9-001zrS-RQ for pgsql-hackers@lists.postgresql.org; Mon, 20 Oct 2025 15:29:27 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1vArp7-002oNB-0J for pgsql-hackers@postgresql.org; Mon, 20 Oct 2025 15:29:25 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 156471D00117; Mon, 20 Oct 2025 11:29:24 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Mon, 20 Oct 2025 11:29:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm1; t=1760974163; x= 1761060563; bh=opHMRlqRl2zNg3AURHn72VPP4v8dpfbbM5KLh+2EkYE=; b=P ef7YNRxhuBBxcBx8o40nqVH9z0Qa56F7HcRTho9S73ffHrRekiyH+c7VbL06gXrD WUWNLjWciriLJ/1LZPUk/xdQewevIr8c6H63gNhHTaEKRZZWR7s1LfV8KO9fT1O6 2oCGGT06/6LMEvun2gsJ1YC4szvCYM8ZK49TMb1y3rxxJtCUiZVrrvP8gz1uTVOi pgRkrRLoDBxFUf0qCLHV2qrXf2GTGs7jxvj6JYVlGxA7hzwyFGDWrPsvc99mOjZ/ Jk0AV2SodO9hm/mB1VMASDYLf+UbWkEbXcGCYBcYAYzFkOvZNzt/ymnjl96OlaDT 87kuwTF34knnvt0NHPOtw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1760974163; x=1761060563; bh=o pHMRlqRl2zNg3AURHn72VPP4v8dpfbbM5KLh+2EkYE=; b=w4XhpOsX6lBc3JlkF l773rFB2mmdOsmU2LFseM3VWcG8NCKbCHmitXqZ44OjeIYQ/AWSplHj51vyaccon Oz8nSqpnL/cqLtNt0wXsjPMwuhQJvTxb0uKG0HN+51eZpjefl2ugPkuvjEvgAyq2 g8l0N1m0HyrIeBr4Qf46QGkv3TO57qmDU/PlGuO1eGNDaKyO7bMufal9E+/9RXfQ biY4XrTN3OpEfRgQotreSVVy/I8sv+h23O/+TK29simvDeUp4pjL6RqHX3qqmlg9 tfuxG5fdXi4oNxwabyqTH+Co8rBhxdefX8yVCPCC6aSm9P4xyZ+vUKWNNwABT03O YNGKQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddufeekudekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeetuedvheffkeevgfeuheevteevkefggedttdeufeeuheduuddthfef fffhjeefffenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv sehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopeehpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdprhgtphht thhopehjihgrnhdruhhnihhvvghrshgrlhhithihsehgmhgrihhlrdgtohhmpdhrtghpth htoheprhgvshhhkhgvkhhirhhilhhlsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhg shhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepth hglhesshhsshdrphhghhdrphgrrdhush X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 20 Oct 2025 11:29:23 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1760974161; bh=2QHh/Eci3KXEduf3NPngzdmXsGl1H1AWVgxcqTzD2TI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=cTqAhHD7Ll8mSu7G0JIFr9ShWherwFhc5S9zjDX7p1VYQxWHTrIBaKAxzWFipnMH/ Pz/vCKFNDdXW6M9Z+mh0osgaahto054+KPk0sC/SKCsX/c9emMIJiSP5oZPdwyf4ky mvrws4C0USKV74Yi3DqEdBa1+jimRb9yTxFfT+q9JwXUDP7nuvhV/baqIQI9TAALAU 53d9/tif/pEewuS9jYCWsIn67gd9FtoCMjT/3npFWxaVV2zSVJMD3YXGXvwWTrXVL4 8AiTpEFYgsW8sDOxCbBpUW+BDf08cHYLQrkSykxmwXcNVopBQ/zVj2LM2tLa4cMOUG g23zSaJ5OhODg== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id 30C3A6A; Mon, 20 Oct 2025 17:29:21 +0200 (CEST) Date: Mon, 20 Oct 2025 18:29:21 +0300 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: jian he Cc: Peter Eisentraut , Tom Lane , PostgreSQL-development , Kirill Reshke Subject: Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt Message-ID: <202510201522.r7i6dr2wm2h7@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-Oct-20, jian he wrote: > @@ -15632,11 +15623,6 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, > Oid refRelId, char *cmd, > querytree_list = lappend(querytree_list, stmt); > querytree_list = list_concat(querytree_list, afterStmts); > } > - else if (IsA(stmt, CreateStatsStmt)) > - querytree_list = lappend(querytree_list, > - transformStatsStmt(oldRelId, > - (CreateStatsStmt *) stmt, > - cmd)); > > The above "cmd" is the queryString, which is useful for error reporting. > > create table t(a int); > create statistics xxx on (a + 1 is not null) from t; > alter table t alter column a set data type text; > > with patch, v4-0001-Restructure-CreateStatsStmt-parse-analysis-proces.patch > ERROR: operator does not exist: text + integer > DETAIL: No operator of that name accepts the given argument types. > HINT: You might need to add explicit type casts. > > In the master branch, the error message also includes the error position. > ERROR: operator does not exist: text + integer > LINE 1: alter table t alter column a set data type text; > ^ > DETAIL: No operator of that name accepts the given argument types. > HINT: You might need to add explicit type casts. Interesting, thanks for the example. I think this example illustrates very well why the 'cmd' is rather useless here -- note how the error message refers to an operator that appears nowhere in the query string. The user says "SET DATA TYPE text" and then we complain about the "text+integer" operator? That makes no sense and I don't think it's in any way useful. I think a user-friendly thing we could do is add an errcontext callback that shows that we're trying to reapply a statistics object. We should discuss that in a separate thread for a separate patch though, and also I don't think that thread should prevent this rework from being applied now. We could add this test scenario to the regression tests though, if only to show how it would change later. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/