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 1jHWol-0004ni-MY for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2020 18:01:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jHWoj-00084x-HE for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2020 18:01:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jHWoj-00084a-3t for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2020 18:01:21 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jHWof-0001Dm-Fm for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2020 18:01:20 +0000 Received: by mail-qk1-x742.google.com with SMTP id e11so7694240qkg.9 for ; Thu, 26 Mar 2020 11:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QsRZbEGTYxFJDlfzrXYDyFln+z6X7geyuANE6bBi1Pw=; b=iKoIArlBnUCHp7c9hiy14AWMJQRQUh/Gakh1dPnaFsffCUggv1P8ElG7ivAditKt0z VANifHgqRCjxeu3C+waBSteHwxFAADX0ef9M88GA0ifDIJfDZJkkWpRwagNomcFM0exp 5Olau5vVZLu1WqMdoig9Wpq5RsL7XuL6DrZLwXYdMQaJueZ19cE3y6QgTnfp3f1lXRbc YYqA2U6m+TgiAg8013lvMxOCf26WcSkB3xgEtD2p41Bf9Hmhvh8fO6rjXdYQ01gWmLHE 5Q96h+IJpcmfPUIjzyi/YCOQsz0FDd3kPwAFbzkjf/a4u02gDha0HlOCQokw27PsP522 6JKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QsRZbEGTYxFJDlfzrXYDyFln+z6X7geyuANE6bBi1Pw=; b=k1K8AEMqtE3diCiacCYgr99Jh8yCoEwIpDCZz4+Sxa1LAmSR1Lp4XwyXeAamzhTR85 oBDwgolFfERN5Tn0YXWDgvDd4wYTnTXhgAsDH64MIQI+mYWh/jJXT5nvB0BhP9+F/H3K b94YlmVzxstLMLEqJCwkyiZkRx2JsstZdiAxIvhlKrQzqiIwQqAvlOFZkpXek6Efw6W0 urAajPEpjBmwzVgKfeU65EH5OZ3FAZGiPnwxtpktp/rBizKXKEHDax0LED4T8648kuWw H4ZdA2ZjZDttr5raIFmSf94Eowwzc68y6i6q/I+DknM6b97mhOdz/rC42KWlSawJYipA YWjA== X-Gm-Message-State: ANhLgQ3YXWRP7OpOxowaAW79PQorStezfmZ0r/B33lS8HV1tNcMruqFi KiGc+n5YOKnCM8TpsmNP/A+htw== X-Google-Smtp-Source: ADFU+vto9M8Ky+X2URo4tMhZzTka33wYbaQCj2bsPRGLbEof2xwjvBfGbAm2vtkPTdl4sITc4pzXEQ== X-Received: by 2002:a37:61d0:: with SMTP id v199mr9583585qkb.305.1585245675377; Thu, 26 Mar 2020 11:01:15 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id h129sm1852235qkf.54.2020.03.26.11.01.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Mar 2020 11:01:14 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id E63E880096B; Thu, 26 Mar 2020 13:01:12 -0500 (CDT) Date: Thu, 26 Mar 2020 13:01:12 -0500 From: Justin Pryzby To: Alexey Kondratov 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 Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <39a055a7a8cd19552f35f4cb98a8cd80@postgrespro.ru> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > I included your new solution regarding this part from 0004 into 0001. It > seems that at least a tip of the problem was in that we tried to change > tablespace to pg_default being already there. Right, causing it to try to drop that filenode twice. > +++ b/doc/src/sgml/ref/cluster.sgml > + The name of a specific tablespace to store clustered relations. Could you phrase these like you did in the comments: " the name of the tablespace where the clustered relation is to be rebuilt." > +++ b/doc/src/sgml/ref/reindex.sgml > + The name of a specific tablespace to store rebuilt indexes. " The name of a tablespace where indexes will be rebuilt" > +++ b/doc/src/sgml/ref/vacuum.sgml > + The name of a specific tablespace to write a new copy of the table. > + This specifies a tablespace, where all rebuilt indexes will be created. say "specifies the tablespace where", with no comma. > + else if (!OidIsValid(classtuple->relfilenode)) > + { > + /* > + * Skip all mapped relations. > + * relfilenode == 0 checks after that, similarly to > + * RelationIsMapped(). I would say "OidIsValid(relfilenode) checks for that, ..." > @@ -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. Another issue is this: > +VACUUM ( FULL [, ...] ) [ TABLESPACE new_tablespace ] [ 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". -- Justin