agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: Alexey Kondratov <a.kondratov@postgrespro.ru>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Zhihong Yu <zyu@yugabyte.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Cc: Steve Singer <steve@ssinger.info>
Cc: pgsql-hackers@lists.postgresql.org, Robert Haas <robertmhaas@gmail.com>
Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Jose Luis Tallon <jltallon@adv-solutions.net>
Subject: Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
Date: Wed, 23 Dec 2020 19:12:11 +0300
Message-ID: <f64e9fb8e3aa323d135db789322dbae3@postgrespro.ru> (raw)
In-Reply-To: <20201223052200.GP30237@telsasoft.com>
References: <7ec67c56-2377-cd05-51a0-691104404abe@enterprisedb.com>
<20201216004517.GA18498@alvherre.pgsql>
<X9lcV/nYVU5WYf7D@paquier.xyz>
<X+GWnexHZdt/aaVl@paquier.xyz>
<20201222083204.GL30237@telsasoft.com>
<X+HDFVXTYbTJMSXZ@paquier.xyz>
<20201222211537.GO30237@telsasoft.com>
<CALNJ-vQeFpTdTgHdU4fcO94pRcxpAC7X5ujeM06rUHoKwgO5Sg@mail.gmail.com>
<20201223052200.GP30237@telsasoft.com>
On 2020-12-23 08:22, Justin Pryzby wrote:
> On Tue, Dec 22, 2020 at 03:22:19PM -0800, Zhihong Yu wrote:
>> Justin:
>> For reindex_index() :
>>
>> + if (options->tablespaceOid == MyDatabaseTableSpace)
>> + options->tablespaceOid = InvalidOid;
>> ...
>> + oldTablespaceOid = iRel->rd_rel->reltablespace;
>> + if (set_tablespace &&
>> + (options->tablespaceOid != oldTablespaceOid ||
>> + (options->tablespaceOid == MyDatabaseTableSpace &&
>> OidIsValid(oldTablespaceOid))))
>>
>> I wonder why the options->tablespaceOid == MyDatabaseTableSpace clause
>> appears again in the second if statement.
>> Since the first if statement would assign InvalidOid
>> to options->tablespaceOid when the first if condition is satisfied.
>
> Good question. Alexey mentioned on Sept 23 that he added the first
> stanza. to
> avoid storing the DB's tablespace OID (rather than InvalidOid).
>
> I think the 2nd half of the "or" is unnecessary since that was added
> setting to
> options->tablespaceOid = InvalidOid.
> If requesting to move to the DB's default tablespace, it'll now hit the
> first
> part of the OR:
>
>> + (options->tablespaceOid != oldTablespaceOid ||
>
> Without the first stanza setting, it would've hit the 2nd condition:
>
>> + (options->tablespaceOid == MyDatabaseTableSpace &&
>> OidIsValid(oldTablespaceOid))))
>
> which means: "user requested to move a table to the DB's default
> tblspace, and
> it was previously on a nondefault space".
>
> So I think we can drop the 2nd half of the OR. Thanks for noticing.
Yes, I have not noticed that we would have already assigned
tablespaceOid to InvalidOid in this case. Back to the v7 we were doing
this assignment a bit later, so this could make sense, but now it seems
to be redundant. For some reason I have mixed these refactorings
separated by a dozen of versions...
Thanks
--
Alexey Kondratov
Postgres Professional https://www.postgrespro.com
Russian Postgres Company
view thread (154+ messages) latest in thread
Message-ID: <f64e9fb8e3aa323d135db789322dbae3@postgrespro.ru>
Permalink: ../f64e9fb8e3aa323d135db789322dbae3@postgrespro.ru/
Also on: postgresql.org/message-id/f64e9fb8e3aa323d135db789322dbae3@postgrespro.ru
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: a.kondratov@postgrespro.ru, pryzby@telsasoft.com, zyu@yugabyte.com, michael@paquier.xyz, alvherre@alvh.no-ip.org, peter.eisentraut@enterprisedb.com, masahiko.sawada@2ndquadrant.com, steve@ssinger.info, robertmhaas@gmail.com, a.korotkov@postgrespro.ru, sawada.mshk@gmail.com, jltallon@adv-solutions.net
Subject: Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
In-Reply-To: <f64e9fb8e3aa323d135db789322dbae3@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox