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

From Michael Paquier
Subject Re: Support for REINDEX CONCURRENTLY
Date
Msg-id CAB7nPqSTz=0iXzKvsqazz7Zto-myR_G8vmxZqPRj0J6z15++Fg@mail.gmail.com
Whole thread Raw
In response to Re: Support for REINDEX CONCURRENTLY  (Fujii Masao <masao.fujii@gmail.com>)
Responses Re: Support for REINDEX CONCURRENTLY  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Thanks for the comments. Please find updated patches attached.

On Thu, Mar 28, 2013 at 3:12 AM, Fujii Masao <masao.fujii@gmail.com> wrote:
-       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().
Good catch. I thought that I took care of such things in previous versions at
all the places.

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

-       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.
Indeed...
--
Michael
Attachment

pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Next
From: Andres Freund
Date:
Subject: Re: Support for REINDEX CONCURRENTLY