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 1l2IJj-0002Ev-Oz for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Jan 2021 18:34:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2IJi-0007q9-MB for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Jan 2021 18:34:54 +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 1l2IJi-0007q2-FH for pgsql-hackers@lists.postgresql.org; Wed, 20 Jan 2021 18:34:54 +0000 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2IJe-0007rB-0G for pgsql-hackers@lists.postgresql.org; Wed, 20 Jan 2021 18:34:53 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id B1D6E1BF1; Wed, 20 Jan 2021 13:34:47 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 20 Jan 2021 13:34:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=+fFpegUu0wM70L35ke2+ihc5PwGyaoFH7X/Esw55S4c=; b=e5FOb9Z/ n7nDsD8ZsEIVW5a9o/V9N93DfVEo/WHAXvju4+LLuWQPqlF2XFUsoc5zWlW5HZC5 U7EwaDjwESSKiTyXxPqW5HZlk0pMTyDASu+ZHv4OzTmszwu+89GpB0qxTkTxEeow tdBxE1DaUfHX5ebXvm/9E+xoROemg7Neov0/NxtL46Gf3f7SmdFQBv1J4GHbfPIU mtVau1J5d/6eUUZm5yQ2BRJko1nvATQGy9G3EzyroHK43vFII+rJSpG5+TSjmAs6 ZQ2OnHrZ33kDEf6BpfwBGJPjuao/dXLuFsegIEhERVxTMQxkWwDKpAlKqU9BP1ow goN2hYN+yFQZcQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddvgdduudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjfgesthekredttderudenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepueffhfejieeuueffgedvudekgeeltdeviedvieeufeei ieevgfetheeufeethedvnecukfhppeduledtrdelhedrudelrddujeejnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegr lhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.177]) by mail.messagingengine.com (Postfix) with ESMTPA id 6DF0A24005B; Wed, 20 Jan 2021 13:34:45 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 3D1292A0FBF; Wed, 20 Jan 2021 15:34:39 -0300 (-03) Date: Wed, 20 Jan 2021 15:34:39 -0300 From: Alvaro Herrera To: Alexey Kondratov Cc: Michael Paquier , 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: <20210120183439.GA21339@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <03f88f70618ce73e75837b6125a143f7@postgrespro.ru> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2021-Jan-20, Alexey Kondratov wrote: > On 2021-01-20 21:08, Alexey Kondratov wrote: > > > > I did a refactoring of ATExecSetTableSpaceNoStorage() in the 0001. New > > function SetRelTablesapce() is placed into the tablecmds.c. Following > > 0002 gets use of it. Is it close to what you and Michael suggested? > > Ugh, forgot to attach the patches. Here they are. Yeah, looks reasonable. > + /* No work if no change in tablespace. */ > + oldTablespaceOid = rd_rel->reltablespace; > + if (tablespaceOid != oldTablespaceOid || > + (tablespaceOid == MyDatabaseTableSpace && OidIsValid(oldTablespaceOid))) > + { > + /* Update the pg_class row. */ > + rd_rel->reltablespace = (tablespaceOid == MyDatabaseTableSpace) ? > + InvalidOid : tablespaceOid; > + CatalogTupleUpdate(pg_class, &tuple->t_self, tuple); > + > + changed = true; > + } > + > + if (changed) > + /* Record dependency on tablespace */ > + changeDependencyOnTablespace(RelationRelationId, > + reloid, rd_rel->reltablespace); Why have a separate "if (changed)" block here instead of merging with the above? -- Álvaro Herrera 39°49'30"S 73°17'W