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 1w5EwR-0032vQ-03 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 03:29:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5EwO-00BMxc-27 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 03:29:57 +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.96) (envelope-from ) id 1w5EwO-00BMxU-1F for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 03:29:56 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w5EwM-00000000zir-033Z for pgsql-hackers@postgresql.org; Wed, 25 Mar 2026 03:29:56 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id EE84EEC01F6; Tue, 24 Mar 2026 23:29:52 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Tue, 24 Mar 2026 23:29:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; 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=fm1; t=1774409392; x=1774495792; bh=jahv/ToD2V Ir+BjONWSaX2VE4RyMUhE3e+c8sWK8tm0=; b=0dCxt3wOjQdtksctvE04Fqef9w TYxf26xILK7IFsB4hn4TjZ7aEK4zvBOERMN0PHGAVsuLg+7SYS2RNQPoIpy8hlj5 3wsLiPYU6AxfCB4xJzHW/pd8f2ulQwACWnZrXYr7zXeKgXEAWcp1M8/9Rj4Tz+0Q V0sogJMaXzl1T0q2pr2uHUuBPioYPogRCiVibDgWvBb6s1rgCV/DMJn9J6YfllTS FDDjuQP5aOb5a/NQs/No0YTCXk9EbGztApb5bbjimLV2LpHRnliXumjR4o5iV81w y+C/dephSwa6FapB5Sdax/KW/8n1mFR66piB2b5TUf5DPvPXsObHc37su0lQ== 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=fm1; t= 1774409392; x=1774495792; bh=jahv/ToD2VIr+BjONWSaX2VE4RyMUhE3e+c 8sWK8tm0=; b=zuhUVvtpxEplP3Njc3m4I7GPdUf29H53hEbKGS4rkhXqMETKBb+ cn3NGe2eZ/7OsJFu+joiPErEOBinGWNYV0DKQnLQPHW7AZxzncprZwUjJ+ePhq6v 1DOGktVqlPbBXFUsN9Th4WFEr10J+NGAI9qLvgBNaZkfJOd1if6SyDBsdjP1pUbt 2Vn85jnLy7G51fVgyyDar8F5g8cEFh3Z6YzI/h3lksqTXOX2p+2MGlDuNjOUTr/o SGIutBH8A8W4AD5LdHMhW7cwzPb9fqD8P5N53nPjIVsV1obO1idMmXHB27lMADqq hmPdKgGwzGayIoQeGI8GaTkSAWl1qUKu97g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefvdeffeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtsfdttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepfeffgfelvdffgedtveelgfdtgefghfdvkefggeetieevjeekteduleevjefh ueegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeegpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehnrghthhgrnhgusghoshhsrghrthesghhmrghilh drtghomhdprhgtphhtthhopeiihhhonhhgleehtdegudelsehgmhgrihhlrdgtohhmpdhr tghpthhtohepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidprhgtphhtthhopehpgh hsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Mar 2026 23:29:52 -0400 (EDT) Date: Tue, 24 Mar 2026 23:29:52 -0400 From: Andres Freund To: Nathan Bossart Cc: Michael Paquier , shihao zhong , PostgreSQL-development Subject: Re: Fixes inconsistent behavior in vacuum when it processes multiple relations Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-03-24 16:47:30 -0500, Nathan Bossart wrote: > On Fri, Mar 20, 2026 at 04:32:48PM -0400, Andres Freund wrote: > > On 2026-03-20 14:39:11 -0500, Nathan Bossart wrote: > >> On Fri, Mar 20, 2026 at 12:27:49PM -0400, Andres Freund wrote: > >> > Why wasn't it enough to add const markers and keep passing by pointer? > >> > >> IIRC the idea was to prevent similar problems in the future. > > > > Seems using const VacuumParams *params should suffice for that? I don't think > > it's particularly likely that we'll accept code that casts the const away and > > then later get hurt by that. > > > >> To avoid the extra #includes, we could instead use the back-patched version > >> (e.g., commit 661643deda). > > > > I'd probably not go quite there, at least the params should largely be const, > > with a local on-stack copy where we do need to modify. > > Here is a first try. Thanks! Looks reasonable on a skim. > static bool > -vacuum_rel(Oid relid, RangeVar *relation, VacuumParams params, > +vacuum_rel(Oid relid, RangeVar *relation, const VacuumParams *params, > BufferAccessStrategy bstrategy) > { > LOCKMODE lmode; > @@ -2014,18 +2014,21 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams params, > Oid save_userid; > int save_sec_context; > int save_nestlevel; > + VacuumParams params_copy; > VacuumParams toast_vacuum_params; I'd maybe not name it _copy, but params_local or params_table or such, as somehow it seems a bit odd to modify the copy. But I can't really explain why it feels odd. I wonder if more of the code in the function should be updated to use the copy, otherwise it seems like it could more easily happen that a part of the code not using the modified version is moved until after a modification, and the code author assumes the modifications now have taken effect. Greetings, Andres Freund