Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jHY52-0006s8-Du for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2020 19:22:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jHY51-0003Aj-7M for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2020 19:22:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jHY50-0003Ac-OB for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2020 19:22:14 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jHY4x-0005WM-DU for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2020 19:22:13 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 26D5121C56D8; Thu, 26 Mar 2020 22:22:09 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from mail.postgrespro.ru (cyclops.l.postgrespro.ru [192.168.27.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id BD3CB21C49D0; Thu, 26 Mar 2020 22:22:08 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1585250528; bh=Rz0A+r+ufPrRwOrsEUM+GJqOeej4OAdbv1YWYn4GtjM=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=pG4wgk+pQfJsJeZvWrq0XfivCzRrGBNFE8mrOo86D3Sm6q+1KvuSrxbF8enqWvfI6 Fkn4uO4c+lBxJ6J7R1iVbchFk2s0oEsjopucy140Q4HNFPdQQdDwlk2R9m00k16MJb biLKIs4qD8EpAs3gtG33j7lY73u1e9/MhRQrQkpI= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 26 Mar 2020 22:22:08 +0300 From: Alexey Kondratov To: Justin Pryzby Cc: Michael Paquier , Masahiko Sawada , Steve Singer , pgsql-hackers@lists.postgresql.org, Alvaro Herrera , Robert Haas , Alexander Korotkov , Masahiko Sawada , Jose Luis Tallon Subject: Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly In-Reply-To: <20200326180112.GH17431@telsasoft.com> References: <3ae48673-283c-3e99-3dd8-36ebb81614b5@postgrespro.ru> <20191202082134.GI1696@paquier.xyz> <20200211164848.GO1412@telsasoft.com> <20200229145304.GI29456@telsasoft.com> <20200309200447.GA32459@telsasoft.com> <20200325234027.GH21443@telsasoft.com> <39a055a7a8cd19552f35f4cb98a8cd80@postgrespro.ru> <20200326180112.GH17431@telsasoft.com> User-Agent: Roundcube Webmail/1.4.0 Message-ID: <39c239a12c4dde0a3c78e2ab5d8eb55b@postgrespro.ru> X-Sender: a.kondratov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-03-26 21:01, Justin Pryzby wrote: > >> @@ -262,7 +280,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel) >> * and error messages should refer to the operation as VACUUM not >> CLUSTER. >> */ >> void >> -cluster_rel(Oid tableOid, Oid indexOid, int options) >> +cluster_rel(Oid tableOid, Oid indexOid, Oid tablespaceOid, int >> options) > > Add a comment here about the tablespaceOid parameter, like the other > functions > where it's added. > > The permission checking is kind of duplicitive, so I'd suggest to > factor it > out. Ideally we'd only have one place that checks for > pg_global/system/mapped. > It needs to check that it's not a system relation, or that > system_table_mods > are allowed, and in any case that if it's a mapped rel, that it's not > being > moved. I would pass a boolean indicating if the tablespace is being > changed. > Yes, but I wanted to make sure first that all necessary validations are there to do not miss something as I did last time. I do not like repetitive code either, so I would like to introduce more common check after reviewing the code as a whole. > > Another issue is this: >> +VACUUM ( FULL [, ...] ) [ TABLESPACE > class="parameter">new_tablespace ] [ > class="parameter">table_and_columns [, ...] ] > As you mentioned in your v1 patch, in the other cases, "tablespace > [tablespace]" is added at the end of the command rather than in the > middle. I > wasn't able to make that work, maybe because "tablespace" isn't a fully > reserved word (?). I didn't try with "SET TABLESPACE", although I > understand > it'd be better without "SET". > Initially I tried "SET TABLESPACE", but also failed to completely get rid of shift/reduce conflicts. I will try to rewrite VACUUM's part again with OptTableSpace. Maybe I will manage it this time. I will take into account all your text edits as well. Thanks -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company