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 1jLVmv-0002lN-FQ for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2020 17:43:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jLVmu-0002bT-5f for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2020 17:43:56 +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 1jLVmt-0002bL-Re for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2020 17:43:55 +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 1jLVmq-0001lQ-GS for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2020 17:43:54 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id DB5C421C5958; Mon, 6 Apr 2020 20:43:47 +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 47DCB21C5856; Mon, 6 Apr 2020 20:43:46 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1586195027; bh=bDq6f6Y9zIpPos6bSeg3uudSqt22TxqYplXboEpPzmg=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=MfuwGF8hO9+OhqgzITzI1MWyf40p1uevfSOrJQfhJfOUtA6BZbJLSEGjVXGRGqCnR zVGcOUSCM2aFCKCg4JdXMKijlECMUrz8omtCTpSI9MOCPrzRZWrRb509h82xiLIZ4z yK0zPuVg5LASSMRq6MoTpEUwmtVxfhUEqvTyNHgk= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 06 Apr 2020 20:43:46 +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: <20200403182712.GR14618@telsasoft.com> References: <39a055a7a8cd19552f35f4cb98a8cd80@postgrespro.ru> <20200326180112.GH17431@telsasoft.com> <20200327040106.GC20103@telsasoft.com> <20200328001112.GX20103@telsasoft.com> <20200330183439.GQ20103@telsasoft.com> <624921b1ebca9897173d85c424c00646@postgrespro.ru> <20200401060334.GB142683@paquier.xyz> <20200401115718.GQ14618@telsasoft.com> <20200401130836.GT14618@telsasoft.com> <20200403182712.GR14618@telsasoft.com> User-Agent: Roundcube Webmail/1.4.0 Message-ID: X-Sender: a.kondratov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-04-03 21:27, Justin Pryzby wrote: > On Wed, Apr 01, 2020 at 08:08:36AM -0500, Justin Pryzby wrote: >> Or maybe you'd want me to squish my changes into yours and resend >> after any >> review comments ? > > I didn't hear any feedback, so I've now squished all "parenthesized" > and "fix" > commits. > Thanks for the input, but I am afraid that the patch set became a bit messy now. I have eyeballed it and found some inconsistencies. const char *name; /* name of database to reindex */ - int options; /* Reindex options flags */ + List *rawoptions; /* Raw options */ + int options; /* Parsed options */ bool concurrent; /* reindex concurrently? */ You introduced rawoptions in the 0002, but then removed it in 0003. So is it required or not? Probably this is a rebase artefact. +/* XXX: reusing reindex_option_list */ + | CLUSTER opt_verbose '(' reindex_option_list ')' qualified_name cluster_index_specification Could we actually simply reuse vac_analyze_option_list? From the first sight it does just the right thing, excepting the special handling of spelling ANALYZE/ANALYSE, but it does not seem to be a problem. > > 0004 reduces duplicative error handling, as a separate commit so > Alexey can review it and/or integrate it. > @@ -2974,27 +2947,6 @@ ReindexRelationConcurrently(Oid relationOid, Oid tablespaceOid, int options) /* Open relation to get its indexes */ heapRelation = table_open(relationOid, ShareUpdateExclusiveLock); - /* - * We don't support moving system relations into different tablespaces, - * unless allow_system_table_mods=1. - */ - if (OidIsValid(tablespaceOid) && - !allowSystemTableMods && IsSystemRelation(heapRelation)) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied: \"%s\" is a system catalog", - RelationGetRelationName(heapRelation)))); ReindexRelationConcurrently is used for all cases, but it hits different code paths in the case of database, table and index. I have not checked yet, but are you sure it is safe removing these validations in the case of REINDEX CONCURRENTLY? > > The last two commits save a few > dozen lines of code, but not sure they're desirable. > Sincerely, I do not think that passing raw strings down to the guts is a good idea. Yes, it saves us a few checks here and there now, but it may reduce a further reusability of these internal routines in the future. > > XXX: for cluster/vacuum, it might be more friendly to check before > clustering > the table, rather than after clustering and re-indexing. > Yes, I think it would be much more user-friendly. -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company