Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2Oz4-00018x-Un for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Jan 2021 01:42:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2Oz3-00032C-R4 for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Jan 2021 01:42:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2Oz2-000325-Hr for pgsql-hackers@lists.postgresql.org; Thu, 21 Jan 2021 01:42:01 +0000 Received: from new3-smtp.messagingengine.com ([66.111.4.229]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2Oyz-0002jx-5i for pgsql-hackers@lists.postgresql.org; Thu, 21 Jan 2021 01:41:59 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id C529258041A; Wed, 20 Jan 2021 20:41:55 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 20 Jan 2021 20:41:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=Qov1IR95vnzT51Zxwm07m69jsBX XczMKCsPJN5rNRYc=; b=Cm7UAbP20Uv3UhlrmjFAur8pi2ZYO8DcNwnbwqOOm9k 338ztZI9jWFQttoHnjJ8zaIMtxg3gGayJwk0+xJOmdRiEqvKEdEdl6FYSF7WTz/l UoHFgrRftUhEfTWPTwd88wm3gb3euWQ4HcyxQDaBYGLatCeLs7SZiO3DC3GZlvjT 3pclYLIfsXz7YZaTSL4v986hFX7SwyA2oiMPB1W8A6qEkrxjwjkFzQRgpvTDltlr oSzWHIDifkSeo4R+EnkGYbN3u23f8Qmr+bq7VcEpUCDawE2850kOIihhpWLK27vJ xWox+o4kw1pmHOCNECUI1PcNwYtTz2DB6el5ih/hI7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Qov1IR 95vnzT51Zxwm07m69jsBXXczMKCsPJN5rNRYc=; b=rxD9Ou48DfoOdcjAQcNFAw cV8GQ9afLZZbIePTzOPkRT7hSEBrMCL/dGfaRD4n3tyawgZyn9aaLFgkIQye/muO iZ9RezO4QTyW5dtLTee8IM1y5e0u3MuwNctkpQxyhmRbJpUwmhZLeitqBR8D7VlZ kiRA6S9X8ex7BI6Qy+kdTXpki3uf9IxD9qP9UEuohlY+tO1prY/7+xP/0yKhWTei E+W9bc7BhpryHbbOu27LbZTcrSb567i2mEWkaS0hrN3m9v5GrEBBbXJqRLUttjTB 26nYaWPW70V/TK1bKrqH8InCtyRj/yb7rm29OwMDYVst9ir8sZA0gLHITcK9ugDg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefgdefiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepvdegudeuhfdtueeltedtveejheeh ieevueeigeelteegleejleeiueeiheegvefhnecukfhppeduuddurddutddvrddukedtrd dukeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep mhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 684F9108005F; Wed, 20 Jan 2021 20:41:51 -0500 (EST) Date: Thu, 21 Jan 2021 10:41:46 +0900 From: Michael Paquier To: Alvaro Herrera Cc: Alexey Kondratov , Justin Pryzby , Peter Eisentraut , Masahiko Sawada , Steve Singer , pgsql-hackers@lists.postgresql.org, Robert Haas , Alexander Korotkov , Masahiko Sawada , Jose Luis Tallon Subject: Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly Message-ID: References: <03f88f70618ce73e75837b6125a143f7@postgrespro.ru> <20210120183439.GA21339@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="n39a3p29B5FL+J79" Content-Disposition: inline In-Reply-To: <20210120183439.GA21339@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --n39a3p29B5FL+J79 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 20, 2021 at 03:34:39PM -0300, Alvaro Herrera wrote: > On 2021-Jan-20, Alexey Kondratov wrote: >> Ugh, forgot to attach the patches. Here they are. >=20 > Yeah, looks reasonable. Patch 0002 still has a whole set of issues as I pointed out a couple of hours ago, but if we agree on 0001 as being useful if done independently, I'd rather get that done first. This way or just merging both things in a single commit is not a big deal seeing the amount of code, so I am fine with any approach. It may be possible that 0001 requires more changes depending on the work to-be-done for 0002 though? >> + /* No work if no change in tablespace. */ >> + oldTablespaceOid =3D rd_rel->reltablespace; >> + if (tablespaceOid !=3D oldTablespaceOid || >> + (tablespaceOid =3D=3D MyDatabaseTableSpace && OidIsValid(oldTablespac= eOid))) >> + { >> + /* Update the pg_class row. */ >> + rd_rel->reltablespace =3D (tablespaceOid =3D=3D MyDatabaseTableSpace)= ? >> + InvalidOid : tablespaceOid; >> + CatalogTupleUpdate(pg_class, &tuple->t_self, tuple); >> + >> + changed =3D true; >> + } >> + >> + if (changed) >> + /* Record dependency on tablespace */ >> + changeDependencyOnTablespace(RelationRelationId, >> + reloid, rd_rel->reltablespace); >=20 > Why have a separate "if (changed)" block here instead of merging with > the above? Yep. + if (SetRelTablespace(reloid, newTableSpace)) + /* Make sure the reltablespace change is visible */ + CommandCounterIncrement(); At quick glance, I am wondering why you just don't do a CCI within SetRelTablespace(). -- Michael --n39a3p29B5FL+J79 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmAI29oACgkQnvQgOdby QH3IexAAoFyFMTHSV7ZTvmla/2MDg+xPZ/yElqrYYTslNAQNB7bBujHB9uV3sl9d Rwd4yIej8ff5yNGjhVtvDUxLjcYCIBKmwRSTEgekvBxth1ter6+VNndkDukiDYsl l3Q7s82TJlvuWz0CMqkxsh2dt0v1Vr65YWqXZu4Vr3Dqn/471bQdulkD62SWTnJK SiJp7L7H5i7S825GTdfLz+Rqeg8hdnSVMSY80EYAZR5bv/LSvVuRFi5eL6pt/Vot JKl7mRRben5on0HCEMWSesLbL2OnYDfdJ0AClc9cNCInhSbc+Cz4mol1dAvbphM7 Y1dBL8FbjidPnl4X6gE3BSsmtZ5BujFjsE4khR31/K/aeVQZize2KEsMlZD1ejB1 JCKTDPvT+NN7CfxyX3LW5C8Opc/eJYsXRjNuggnShcqmrWW3KjeQI8ZqZwKsJfxm XjBPYawflid1FRtrA0JY1hcdDM69wabPm1aN+f+F3ecHK2GGqRtGv3BoyX2aJxKY Y4RQNtrp5AvPf6kY/iqe2dX60lUU3/PgG/V331XmH7ei8OTwknhyAifz3SC61EsG Yifh4oRA+v/fdNTJygUs8KbX4MyCXLLfyCKBFm/T9CdNvLQslJ6YSIZEktGfCv3T wck6afvR0pSntiIdVXGp9q3O/LfmV4331C7HBVRVEtldQrkpD0E= =5jDX -----END PGP SIGNATURE----- --n39a3p29B5FL+J79--