Re: Support for REINDEX CONCURRENTLY - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Support for REINDEX CONCURRENTLY
Date
Msg-id CAHGQGwEruBrbdmA7vEpR-iy_D61jCtC1hGwBk3RFq0SpBA1ndw@mail.gmail.com
Whole thread Raw
In response to Re: Support for REINDEX CONCURRENTLY  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Support for REINDEX CONCURRENTLY  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-hackers
On Wed, Mar 27, 2013 at 8:26 AM, Michael Paquier
<michael.paquier@gmail.com> wrote:
>
>
> On Wed, Mar 27, 2013 at 3:05 AM, Fujii Masao <masao.fujii@gmail.com> wrote:
>>
>> ISTM you failed to make the patches from your repository.
>> 20130323_1_toastindex_v7.patch contains all the changes of
>> 20130323_2_reindex_concurrently_v25.patch
>
> Oops, sorry I haven't noticed.
> Please find correct versions attached (realigned with latest head at the
> same time).

Thanks!

-    reltoastidxid = rel->rd_rel->reltoastidxid;
+    /* Fetch the list of indexes on toast relation if necessary */
+    if (OidIsValid(reltoastrelid))
+    {
+        Relation toastRel = relation_open(reltoastrelid, lockmode);
+        RelationGetIndexList(toastRel);
+        reltoastidxids = list_copy(toastRel->rd_indexlist);
+        relation_close(toastRel, NoLock);

list_copy() seems not to be required here. We can just set reltoastidxids to
the return list of RelationGetIndexList().

Since we call relation_open() with lockmode, ISTM that we should also call
relation_close() with the same lockmode instead of NoLock. No?

-    if (OidIsValid(reltoastidxid))
-        ATExecSetTableSpace(reltoastidxid, newTableSpace, lockmode);
+    foreach(lc, reltoastidxids)
+    {
+        Oid idxid = lfirst_oid(lc);
+        if (OidIsValid(idxid))
+            ATExecSetTableSpace(idxid, newTableSpace, lockmode);

Since idxid is the pg_index.indexrelid, ISTM it should never be invalid.
If this is true, the check of OidIsValid(idxid) is not required.

Regards,

-- 
Fujii Masao



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: [COMMITTERS] pgsql: Allow external recovery_config_directory
Next
From: Fujii Masao
Date:
Subject: Re: [COMMITTERS] pgsql: Allow external recovery_config_directory